feat: respect accent colors in more places in desktop

This commit is contained in:
2026-05-24 21:29:59 +02:00
parent c731f718e9
commit 96943116f8
12 changed files with 70 additions and 20 deletions
+19 -1
View File
@@ -7,6 +7,7 @@
#pragma once
#include "gui/gui.hpp"
#include "gui/mtk/settings.hpp"
namespace gui::mtk {
@@ -28,6 +29,16 @@ inline Color darken(Color c, uint8_t amount) {
return mix(c, colors::BLACK, amount);
}
// Light selection/hover tint derived from the desktop accent. Returns the
// canonical MENU_HOVER for the default blue accent so existing visuals are
// preserved exactly; otherwise tints white with ~11% of the accent.
inline Color accent_hover_tint(Color accent) {
if (accent.r == colors::ACCENT.r && accent.g == colors::ACCENT.g
&& accent.b == colors::ACCENT.b)
return colors::MENU_HOVER;
return mix(colors::WHITE, accent, 28);
}
struct Theme {
Color window_bg;
Color surface;
@@ -69,7 +80,7 @@ struct Theme {
int gap_lg;
};
inline Theme make_theme(Color accent = colors::ACCENT) {
inline Theme make_theme(Color accent) {
Theme theme {};
theme.window_bg = colors::WINDOW_BG;
theme.surface = Color::from_rgb(0xF5, 0xF5, 0xF5);
@@ -112,4 +123,11 @@ inline Theme make_theme(Color accent = colors::ACCENT) {
return theme;
}
// Zero-arg overload pulls the accent from the desktop appearance settings, so
// MTK widgets (buttons, menus, etc.) automatically pick up the user's chosen
// accent without each caller having to plumb it through.
inline Theme make_theme() {
return make_theme(load_system_accent());
}
} // namespace gui::mtk
+1 -1
View File
@@ -221,7 +221,7 @@ inline void draw_context_menu(Canvas& c,
Rect item = {menu.x + 2, menu.y + CONTEXT_MENU_PAD_Y + i * item_h,
menu.w - 4, item_h};
if (state.hover == i)
c.fill_rect(item.x, item.y, item.w, item.h, colors::MENU_HOVER);
c.fill_rect(item.x, item.y, item.w, item.h, accent_hover_tint(theme.accent));
Color label_color = items[i].enabled ? theme.text : theme.text_muted;
context_menu_draw_label(c, menu.x + 12, item.y + (item.h - fh) / 2,