1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:07:45 +00:00

Themes: Support rubberband selection theming

This commit is contained in:
0xtechnobabble 2020-01-06 01:47:55 +02:00 committed by Andreas Kling
parent 56a2c21e0c
commit 123dcada05
9 changed files with 22 additions and 7 deletions

View file

@ -60,8 +60,11 @@ public:
Color threed_shadow1() const { return color(ColorRole::ThreedShadow1); }
Color threed_shadow2() const { return color(ColorRole::ThreedShadow2); }
Color hover_highlight() const { return color(ColorRole::ThreedHighlight); }
Color rubber_band_fill() const { return color(ColorRole::RubberBandFill); }
Color rubber_band_border() const { return color(ColorRole::RubberBandBorder); }
Color color(ColorRole role) const { return m_impl->color(role); }
void set_color(ColorRole, Color);
const SystemTheme& theme() const { return m_impl->theme(); }

View file

@ -32,17 +32,17 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
auto* data = (SystemTheme*)buffer->data();
auto get = [&](auto& name) {
auto get_color = [&](auto& name) {
auto color_string = file->read_entry("Colors", name);
auto color = Color::from_string(color_string);
if (!color.has_value())
return Color(Color::Black);
dbg() << "Parsed system color '" << name << "' = " << color.value();
dbg() << "Parsed system theme color '" << name << "' = " << color.value();
return color.value();
};
#define DO_COLOR(x) \
data->color[(int)ColorRole::x] = get(#x)
data->color[(int)ColorRole::x] = get_color(#x)
DO_COLOR(DesktopBackground);
DO_COLOR(ThreedHighlight);
@ -75,6 +75,8 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
DO_COLOR(MenuBaseText);
DO_COLOR(MenuSelection);
DO_COLOR(MenuSelectionText);
DO_COLOR(RubberBandFill);
DO_COLOR(RubberBandBorder);
buffer->seal();
buffer->share_globally();

View file

@ -36,6 +36,8 @@ enum class ColorRole {
HoverHighlight,
Selection,
SelectionText,
RubberBandFill,
RubberBandBorder,
__Count,