feat: respect accent colors in more places in desktop
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user