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

Dock: round the corners of full-square icons

Eternity070628f1fcbf4a69e8
diff --git a/src/shell/dock.cpp b/src/shell/dock.cpp
index 2c225c1..0c4fad3 100644
--- a/src/shell/dock.cpp
+++ b/src/shell/dock.cpp
@@ -647,10 +647,33 @@ bool IsTileShaped(UINT w, UINT h, const std::vector<BYTE>& px) {
return true;
}
+// ícone quadrado cheio de cantos vivos (Buzz, Affinity, capas de jogos): passava como "já no formato" e
+// aparecia como um quadrado reto no meio dos ícones arredondados. Os cantos opacos da caixa do desenho denunciam;
+// aí recorta pelo mesmo quadrado arredondado do Jail (raio 22,5%), com a borda suavizada.
+void ArredondaCantos(UINT w, UINT h, std::vector<BYTE>& px) {
+ int x0 = w, y0 = h, x1 = -1, y1 = -1;
+ for (UINT y = 0; y < h; y++) for (UINT x = 0; x < w; x++) if (px[((size_t)y * w + x) * 4 + 3] > 40) { x0 = std::min<int>(x0, x); x1 = std::max<int>(x1, x); y0 = std::min<int>(y0, y); y1 = std::max<int>(y1, y); }
+ if (x1 < 0) return;
+ float bw = float(x1 - x0 + 1), bh = float(y1 - y0 + 1), r = std::min(bw, bh) * 0.225f;
+ auto A = [&](int x, int y) { return px[((size_t)y * w + x) * 4 + 3]; };
+ int d = std::max(1, (int)(std::min(bw, bh) * 0.02f)); // um pouco para dentro do canto (borda serrilhada do ícone)
+ int vivos = (A(x0 + d, y0 + d) > 200) + (A(x1 - d, y0 + d) > 200) + (A(x0 + d, y1 - d) > 200) + (A(x1 - d, y1 - d) > 200);
+ if (vivos < 3) return; // já arredondado (ou de formato próprio)
+ float cx = x0 + bw / 2, cy = y0 + bh / 2;
+ for (UINT y = 0; y < h; y++) for (UINT x = 0; x < w; x++) {
+ float qx = std::max(std::fabs(x + 0.5f - cx) - (bw / 2 - r), 0.f), qy = std::max(std::fabs(y + 0.5f - cy) - (bh / 2 - r), 0.f);
+ float cov = std::clamp(0.5f - (std::sqrt(qx * qx + qy * qy) - r), 0.f, 1.f);
+ if (cov >= 1) continue;
+ BYTE* o = &px[((size_t)y * w + x) * 4];
+ for (int c = 0; c < 4; c++) o[c] = (BYTE)std::lround(o[c] * cov); // pré-multiplicado: tudo junto
+ }
+}
+
std::vector<BYTE> Jail(UINT w, UINT h, const std::vector<BYTE>& src, bool dark);
} // namespace
void dock::Cela(UINT w, UINT h, std::vector<BYTE>& px) {
- if (!TAHOE_DOCK || shell::Setting(L"dock_icones_cinza", L"1") != L"1" || IsTileShaped(w, h, px)) return;
+ if (!TAHOE_DOCK || shell::Setting(L"dock_icones_cinza", L"1") != L"1") return;
+ if (IsTileShaped(w, h, px)) { ArredondaCantos(w, h, px); return; }
px = Jail(w, h, px, ui::IconStyle() == L"escuro");
}
namespace {