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

Add Finder separators and remove the Dock tooltip seam

Eternity070628fa54e649a9ac
diff --git a/src/finder/main.cpp b/src/finder/main.cpp
index afd26c7..0c9dfa1 100644
--- a/src/finder/main.cpp
+++ b/src/finder/main.cpp
@@ -1,4 +1,4 @@
-// Arquivos — gerenciador de arquivos no estilo do Finder (shell próprio, fase 4).
+// Arquivos — gerenciador de arquivos no estilo do Finder (shell próprio, fase 4).
// Primeira entrega: visão de ícones, barra lateral translúcida, menu de contexto próprio,
// arrastar e soltar, renomear no lugar. Roda ao lado do Explorer; não registra nada.
//
@@ -4616,7 +4616,7 @@ static void Render() {
dc->FillRectangle(D2D1::RectF(Lay::SIDEBAR_W, 0, s.width, s.height), br);
} else if (g_tahoe) {
// Tahoe: a janela inteira na cor do conteúdo, com a barra lateral num painel de vidro flutuante
- // (o desfoque da janela aparece só dentro dele); barras de cima e de baixo sem faixa nem divisa
+ // (o desfoque da janela aparece só dentro dele).
pal.bar = pal.content;
D2D1_RECT_F panel = SidePanelRect();
tahoe::SetPanel(g_hwnd, panel, SidePanelR());
@@ -4694,6 +4694,14 @@ static void Render() {
if (CoverFlowH() > 0) DrawCoverFlow(dc, br); // Leopard: o painel de capas em cima da lista
DrawToolbar(dc, pal, br);
DrawScrollbar(dc, pal, br);
+ const float pixel = 1.f / g_scale;
+ auto separator = [&](float y) {
+ const float top = std::round(y * g_scale) * pixel - pixel;
+ dc->FillRectangle(D2D1::RectF(Lay::SIDEBAR_W, top, s.width, top + pixel), br);
+ };
+ br->SetColor(g_dark ? D2D1::ColorF(1, 1, 1, 0.13f) : D2D1::ColorF(0, 0, 0, 0.12f));
+ if (g_tahoe || leo) separator(Lay::TOOLBAR_H);
+ separator(s.height - Lay::FOOTER_H);
DrawRenameField(dc, pal, br);
if (g_pick.on) DrawPicker(dc, pal, br);
diff --git a/src/shell/dock.cpp b/src/shell/dock.cpp
index 7f8ab94..4f0138c 100644
--- a/src/shell/dock.cpp
+++ b/src/shell/dock.cpp
@@ -1,7 +1,8 @@
-// Dock no estilo do macOS Sequoia. Duas janelas: o fundo (acrílico arredondado) e, por cima, uma
+// Dock no estilo do macOS Sequoia. Duas janelas: o fundo (acrílico arredondado) e, por cima, uma
// janela com alfa por pixel onde ficam os ícones (podem crescer para fora do fundo na ampliação;
// onde não há nada desenhado, o clique passa). Ver docs/dock-e-barra-de-menus.md.
#include "shell.h"
+#include <wrl/client.h>
#include "../menu/context_menu.h"
#include "../comum/ajustes_arquivo.h" // ajarq::GravarTexto (dock-pastas.txt)
#include <shellapi.h>
@@ -1092,7 +1093,7 @@ void CALLBACK FgEvent(HWINEVENTHOOK, DWORD, HWND h, LONG obj, LONG, DWORD, DWORD
// A etiqueta com o nome (pt, na janela dos ícones, sempre em pé): embaixo, acima do ícone com a setinha para baixo;
// dos lados, ao lado do ícone com a setinha apontando para ele (como no Mac com o Dock à esquerda ou à direita).
-struct LabelBox { D2D1_RECT_F r{}; D2D1_POINT_2F tri[3]{}; D2D1_POINT_2F in{}; std::wstring t; }; // in: da base da setinha para a ponta
+struct LabelBox { D2D1_RECT_F r{}; D2D1_POINT_2F tri[3]{}; std::wstring t; };
bool LabelGeom(int lab, LabelBox& L) {
if (!g_rotulos || lab < 0 || lab >= (int)g_items.size() || g_items[lab].kind == I_SEP || g_reveal <= 0.9f) return false;
auto& it = g_items[lab];
@@ -1104,7 +1105,6 @@ bool LabelGeom(int lab, LabelBox& L) {
L.r = { it.cx - tw / 2, top, it.cx + tw / 2, top + th };
float cx = it.cx, ab = L.r.bottom - 0.5f;
L.tri[0] = { cx - 7, ab }; L.tri[1] = { cx, ab + 7 }; L.tri[2] = { cx + 7, ab };
- L.in = { 0, 1 };
return true;
}
const float MAXW = 250; // a janela lateral tem ~280 pt para a etiqueta: título comprido ganha "…"
@@ -1118,7 +1118,6 @@ bool LabelGeom(int lab, LabelBox& L) {
float ab = tip.x + s * 7;
L.r = s > 0 ? D2D1::RectF(ab - 0.5f, tip.y - th / 2, ab - 0.5f + tw, tip.y + th / 2) : D2D1::RectF(ab + 0.5f - tw, tip.y - th / 2, ab + 0.5f, tip.y + th / 2);
L.tri[0] = { ab, tip.y - 7 }; L.tri[1] = tip; L.tri[2] = { ab, tip.y + 7 };
- L.in = { -s, 0 };
return true;
}
@@ -1417,23 +1416,33 @@ void Paint() {
br->SetColor(D2D1::ColorF(1, 1, 1, 0.97f));
rt->DrawTextW(t.c_str(), (UINT32)t.size(), g_tfLabel, r, br);
} else {
+ // Une a caixa e a seta para desenhar apenas o contorno externo.
+ const D2D1_POINT_2F* tip = lbox.tri;
+ const auto box = D2D1::RoundedRect(r, 6, 6);
+ Microsoft::WRL::ComPtr<ID2D1Factory> factory;
+ rt->GetFactory(&factory);
+ Microsoft::WRL::ComPtr<ID2D1RoundedRectangleGeometry> panel;
+ Microsoft::WRL::ComPtr<ID2D1PathGeometry> arrow, bubble;
+ Microsoft::WRL::ComPtr<ID2D1GeometrySink> arrowSink, bubbleSink;
+ bool combined = false;
+ if (SUCCEEDED(factory->CreateRoundedRectangleGeometry(box, &panel)) &&
+ SUCCEEDED(factory->CreatePathGeometry(&arrow)) && SUCCEEDED(arrow->Open(&arrowSink))) {
+ arrowSink->BeginFigure(tip[0], D2D1_FIGURE_BEGIN_FILLED);
+ arrowSink->AddLine(tip[1]);
+ arrowSink->AddLine(tip[2]);
+ arrowSink->EndFigure(D2D1_FIGURE_END_CLOSED);
+ if (SUCCEEDED(arrowSink->Close()) && SUCCEEDED(factory->CreatePathGeometry(&bubble)) &&
+ SUCCEEDED(bubble->Open(&bubbleSink))) {
+ HRESULT joined = panel->CombineWithGeometry(arrow.Get(), D2D1_COMBINE_MODE_UNION, nullptr, bubbleSink.Get());
+ combined = SUCCEEDED(bubbleSink->Close()) && SUCCEEDED(joined);
+ }
+ }
br->SetColor(dark ? D2D1::ColorF(0.17f, 0.17f, 0.18f, 0.92f) : D2D1::ColorF(0.94f, 0.94f, 0.95f, 0.95f));
- rt->FillRoundedRectangle(D2D1::RoundedRect(r, 6, 6), br);
- // setinha apontando para o ícone, como no Mac (embaixo para baixo; dos lados para a borda do Dock)
- const D2D1_POINT_2F* tp = lbox.tri;
- D2D1_POINT_2F n{ lbox.in.x * 0.5f, lbox.in.y * 0.5f };
- ID2D1Factory* f = nullptr; rt->GetFactory(&f);
- ID2D1PathGeometry* tri = nullptr; f->CreatePathGeometry(&tri);
- ID2D1GeometrySink* sk = nullptr; tri->Open(&sk);
- sk->BeginFigure(tp[0], D2D1_FIGURE_BEGIN_FILLED);
- sk->AddLine(tp[1]); sk->AddLine(tp[2]);
- sk->EndFigure(D2D1_FIGURE_END_CLOSED); sk->Close(); sk->Release();
- rt->FillGeometry(tri, br);
+ if (combined) rt->FillGeometry(bubble.Get(), br);
+ else rt->FillRoundedRectangle(box, br);
br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.14f) : D2D1::ColorF(0, 0, 0, 0.10f));
- rt->DrawRoundedRectangle(D2D1::RoundedRect(r, 6, 6), br, 0.8f);
- rt->DrawLine({ tp[0].x + n.x, tp[0].y + n.y }, tp[1], br, 0.8f);
- rt->DrawLine(tp[1], { tp[2].x + n.x, tp[2].y + n.y }, br, 0.8f);
- tri->Release(); f->Release();
+ if (combined) rt->DrawGeometry(bubble.Get(), br, 0.8f);
+ else rt->DrawRoundedRectangle(box, br, 0.8f);
br->SetColor(dark ? D2D1::ColorF(1, 1, 1, 0.92f) : D2D1::ColorF(0, 0, 0, 0.85f));
rt->DrawTextW(t.c_str(), (UINT32)t.size(), g_tfLabel, r, br);
}