Skip to content

armgit / WacOS

Public Imported from GitHub
0

A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.

Rust

Finder: sort This PC drives by drive letter

Eternity070628eb16b89f092d
diff --git a/src/comum/idioma_en.inc b/src/comum/idioma_en.inc
index 60348df..90b571c 100644
--- a/src/comum/idioma_en.inc
+++ b/src/comum/idioma_en.inc
@@ -1814,3 +1814,4 @@
{ L"sem chave", L"no key" },
{ L"sem conexão", L"no connection" },
{ L"Espaço", L"Space" },
+{ L"Letra da Unidade", L"Drive Letter" },
diff --git a/src/finder/main.cpp b/src/finder/main.cpp
index 9c0f36e..4a7b453 100644
--- a/src/finder/main.cpp
+++ b/src/finder/main.cpp
@@ -328,7 +328,7 @@ static D2D1_RECT_F Inflate(D2D1_RECT_F r, float d) { return { r.left - d, r.top
// Visões, ordem e grupos
enum class View { Icons, List, Columns, Gallery };
-enum SortCol { SORT_NAME, SORT_SIZE, SORT_KIND, SORT_DATE, SORT_CREATED };
+enum SortCol { SORT_NAME, SORT_SIZE, SORT_KIND, SORT_DATE, SORT_CREATED, SORT_LETTER }; // SORT_LETTER: só em "Este Computador"
enum GroupBy { GROUP_NONE, GROUP_KIND, GROUP_DATE, GROUP_SIZE, GROUP_ADDED };
static View g_view = View::Icons;
@@ -519,6 +519,9 @@ static void SortItems() {
}
int c = 0;
switch (g_sortCol) {
+ case SORT_LETTER:
+ if (g_tagView == VIEW_COMPUTER) { c = towupper(a.path[0]) - towupper(b.path[0]); break; }
+ [[fallthrough]]; // fora de "Este Computador" a ordem por letra vira a por nome
case SORT_NAME:
if (a.dir != b.dir && g_groupBy == GROUP_NONE) return a.dir; // pastas primeiro (hábito do Windows)
c = StrCmpLogicalW(a.label.c_str(), b.label.c_str());
@@ -4511,7 +4514,7 @@ static void DrawGoTo(ID2D1DeviceContext* dc, const Palette& pal, ID2D1SolidColor
}
for (int k = 4; k >= 1; k--) { // sombra
br->SetColor(D2D1::ColorF(0, 0, 0, g_dark ? 0.10f : 0.05f));
- dc->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(r.left - k * 1.5f, r.top - k + 4, r.right + k * 1.5f, r.bottom + k * 2.5f), 16 + k, 16 + k), br);
+ dc->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(r.left - k * 1.5f, r.top - k + 4, r.right + k * 1.5f, r.bottom + k * 2.5f), 16.0f + k, 16.0f + k), br);
}
br->SetColor(g_dark ? D2D1::ColorF(0.17f, 0.17f, 0.18f, 1) : D2D1::ColorF(0.98f, 0.98f, 0.98f, 1));
dc->FillRoundedRectangle(D2D1::RoundedRect(r, 16, 16), br);
@@ -4990,6 +4993,7 @@ static void MakeAlias(const std::vector<std::wstring>& paths) {
}
static void Resort();
+static const wchar_t* SortName(SortCol c);
static void ShowMacMenu(POINT screen, const std::wstring& folder, const std::vector<std::wstring>& paths) {
using Item = ctxmenu::Item;
@@ -5096,8 +5100,9 @@ static void ShowMacMenu(POINT screen, const std::wstring& folder, const std::vec
items.push_back(paste);
items.push_back(sep);
Item sort = I(Tr(L"Ordenar Por"), 0, L"", 0xE8CB);
- const wchar_t* names[] = { Tr(L"Nome"), Tr(L"Tamanho"), Tr(L"Tipo"), Tr(L"Data de Modificação"), Tr(L"Data de Criação") };
- for (int k = 0; k <= (int)SORT_CREATED; k++) { Item it = I(names[k], M_SORT0 + k); it.checked = g_sortCol == k; sort.sub.push_back(it); }
+ const wchar_t* names[] = { Tr(L"Nome"), Tr(L"Tamanho"), Tr(L"Tipo"), Tr(L"Data de Modificação"), Tr(L"Data de Criação"), Tr(L"Letra da Unidade") };
+ int lastSort = g_tagView == VIEW_COMPUTER ? (int)SORT_LETTER : (int)SORT_CREATED;
+ for (int k = 0; k <= lastSort; k++) { Item it = I(names[k], M_SORT0 + k); it.checked = g_sortCol == k; sort.sub.push_back(it); }
items.push_back(sort);
items.push_back(I(Tr(L"Mostrar Opções de Visualização"), M_VIEWOPTS, L"", 0xE713));
{ Item hid = I(Tr(L"Mostrar Arquivos Ocultos"), M_HIDDEN, L"Ctrl+Shift+.", 0xE7B3); hid.checked = g_showHidden; items.push_back(hid); }
@@ -5127,9 +5132,9 @@ static void ShowMacMenu(POINT screen, const std::wstring& folder, const std::vec
for (auto& e : g_items) if (e.sel && !(e.tags & (1u << (id - M_TAG0)))) all = false;
SetTag(paths, id - M_TAG0, !all);
}
- if (id >= M_SORT0 && id <= M_SORT0 + (int)SORT_CREATED) {
+ if (id >= M_SORT0 && id <= M_SORT0 + (int)SORT_LETTER) {
int k = id - M_SORT0;
- if (k == g_sortCol) g_sortAsc = !g_sortAsc; else { g_sortCol = (SortCol)k; g_sortAsc = k == SORT_NAME || k == SORT_KIND; }
+ if (k == g_sortCol) g_sortAsc = !g_sortAsc; else { g_sortCol = (SortCol)k; g_sortAsc = k == SORT_NAME || k == SORT_KIND || k == SORT_LETTER; }
Resort();
}
switch (id) {
@@ -5254,6 +5259,20 @@ static void ShowContextMenu(POINT screen, bool keyboard, bool keepPoint = false)
RefreshTagView();
return;
}
+ if (folder.empty() && paths.empty() && g_tagView == VIEW_COMPUTER) { // Este Computador, no fundo: só a ordem
+ Render();
+ using ctxmenu::Item;
+ Item sort; sort.label = Tr(L"Ordenar Por");
+ for (int k = SORT_NAME; k <= SORT_LETTER; k++) { Item it; it.label = SortName((SortCol)k); it.id = 100 + k; it.checked = g_sortCol == k; sort.sub.push_back(it); }
+ int id = ctxmenu::ShowItems(g_hwnd, screen, { sort });
+ if (id >= 100 && id <= 100 + (int)SORT_LETTER) {
+ SortCol k = (SortCol)(id - 100);
+ if (k == g_sortCol) g_sortAsc = !g_sortAsc; // de novo na mesma coluna: inverte (como no menu das pastas)
+ else { g_sortCol = k; g_sortAsc = k == SORT_NAME || k == SORT_KIND || k == SORT_LETTER; }
+ Resort();
+ }
+ return;
+ }
if (folder.empty()) { // visão de etiqueta: sem menu de fundo; itens de uma pasta só
if (paths.empty()) return;
folder = Parent(paths[0]);
@@ -5454,7 +5473,7 @@ static void LoadOptions() {
if (k == L"janelaEscolher") { RECT r{}; if (swscanf_s(eq + 1, L"%ld %ld %ld %ld", &r.left, &r.top, &r.right, &r.bottom) == 4) g_pickWin = r; continue; }
if (k == L"visaoEscolher") { g_pickView = std::clamp((int)v, 0, 3); continue; }
if (k == L"visao") g_view = g_defaultView = (View)std::clamp((int)v, 0, 3);
- else if (k == L"ordem") g_sortCol = (SortCol)std::clamp((int)v, 0, (int)SORT_CREATED);
+ else if (k == L"ordem") g_sortCol = (SortCol)std::clamp((int)v, 0, (int)SORT_LETTER);
else if (k == L"ascendente") g_sortAsc = v != 0;
else if (k == L"grupo") g_groupBy = g_groupMain = (GroupBy)std::clamp((int)v, 0, (int)GROUP_ADDED);
else if (k == L"grupoDownloads") g_groupDl = std::clamp((int)v, 0, (int)GROUP_ADDED);
@@ -5487,6 +5506,7 @@ static const wchar_t* SortName(SortCol c) {
case SORT_SIZE: return Tr(L"Tamanho");
case SORT_KIND: return Tr(L"Tipo");
case SORT_DATE: return Tr(L"Data de Modificação");
+ case SORT_LETTER: return Tr(L"Letra da Unidade");
default: return Tr(L"Data de Criação");
}
}
@@ -5666,9 +5686,10 @@ static bool ViewOptsClick(D2D1_POINT_2F p) {
}
case OPT_SORT: {
std::vector<ctxmenu::Item> items;
- for (int c = SORT_NAME; c <= SORT_CREATED; c++) { ctxmenu::Item it; it.label = SortName((SortCol)c); it.id = 100 + c; it.checked = g_sortCol == c; items.push_back(it); }
+ int lastSort = g_tagView == VIEW_COMPUTER ? (int)SORT_LETTER : (int)SORT_CREATED;
+ for (int c = SORT_NAME; c <= lastSort; c++) { ctxmenu::Item it; it.label = SortName((SortCol)c); it.id = 100 + c; it.checked = g_sortCol == c; items.push_back(it); }
int r = ctxmenu::ShowItems(g_hwnd, below(), items);
- if (r >= 100) { g_sortCol = (SortCol)(r - 100); g_sortAsc = g_sortCol == SORT_NAME || g_sortCol == SORT_KIND; Resort(); }
+ if (r >= 100) { g_sortCol = (SortCol)(r - 100); g_sortAsc = g_sortCol == SORT_NAME || g_sortCol == SORT_KIND || g_sortCol == SORT_LETTER; Resort(); }
break;
}
case OPT_TEXT_SIZE: {
@@ -5897,7 +5918,7 @@ static D2D1_RECT_F PickOkRect() {
if (tahoe::On()) return { s.width - 110, y - 15, s.width - 16, y + 15 }; // cápsula do Tahoe
return { s.width - 104, y - 14, s.width - 16, y + 14 };
}
-static D2D1_RECT_F PickCancelRect() { auto o = PickOkRect(); float w = tahoe::On() ? 104 : 98; return { o.left - w, o.top, o.left - 10, o.bottom }; }
+static D2D1_RECT_F PickCancelRect() { auto o = PickOkRect(); float w = tahoe::On() ? 104.0f : 98.0f; return { o.left - w, o.top, o.left - 10, o.bottom }; }
static D2D1_RECT_F PickTypeRect() {
auto s = ClientDip(); float y = s.height - Lay::STATUS_H / 2;
float left = Lay::SIDEBAR_W + 16 + (g_pick.mode == 1 ? 330 : 0);