From c2a605f1722a585401a9707a7ccf54d3c5114085 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Fri, 18 Mar 2022 02:58:34 +0200 Subject: [PATCH] offload button colors to TopLevelStyles --- src/Button.cpp | 9 ++++++++- src/Button.hpp | 6 +++--- src/TopLevelStyles.hpp | 10 ++++++++++ src/main.cpp | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Button.cpp b/src/Button.cpp index cb84e62..4b106df 100644 --- a/src/Button.cpp +++ b/src/Button.cpp @@ -8,9 +8,16 @@ namespace Raven { void Button::on_init() { + auto top_level_styles = get_top_level_styles(); + + set_style_text_fill_color(top_level_styles->get_style_text_color()); + set_style_active_background_fill_color(top_level_styles->get_style_button_active_color()); + set_style_focused_background_fill_color(top_level_styles->get_style_button_focused_color()); + set_style_normal_background_fill_color(top_level_styles->get_style_button_normal_color()); + set_style_do_background_fill(true); set_style_background_fill_color(m_style_normal_background_fill_color); - set_style_font_description(get_top_level_styles()->get_style_controls_font_description()); + set_style_font_description(top_level_styles->get_style_controls_font_description()); set_did_init(true); } diff --git a/src/Button.hpp b/src/Button.hpp index 655a49b..4c29b7d 100644 --- a/src/Button.hpp +++ b/src/Button.hpp @@ -11,9 +11,9 @@ namespace Raven { class Button : public Widget { DEF_STYLE(text_fill_color, RGB, 0.0, 0.0, 0.0) -DEF_STYLE(normal_background_fill_color, RGB, 0.6941, 0.3843, 0.5254) -DEF_STYLE(focused_background_fill_color, RGB, 0.5607, 0.2470, 0.4431) -DEF_STYLE(active_background_fill_color, RGB, 0.896, 0.743, 0.979) +DEF_STYLE(normal_background_fill_color, RGB, 0.0, 0.0, 0.0) +DEF_STYLE(focused_background_fill_color, RGB, 0.0, 0.0, 0.0) +DEF_STYLE(active_background_fill_color, RGB, 0.0, 0.0, 0.0) DEF_STYLE(font_description, PangoFontDescription*, nullptr) diff --git a/src/TopLevelStyles.hpp b/src/TopLevelStyles.hpp index 0dbf330..db80098 100644 --- a/src/TopLevelStyles.hpp +++ b/src/TopLevelStyles.hpp @@ -4,12 +4,22 @@ #include "Forward.hpp" #include "pango/pango-font.h" #include "StyleMacros.hpp" +#include "RGB.hpp" namespace Raven { class TopLevelStyles { DEF_STYLE(controls_font_description, PangoFontDescription*, nullptr) +DEF_STYLE(text_color, RGB, 0.0, 0.0, 0.0) +DEF_STYLE(accent_color, RGB, 0.6941, 0.3843, 0.5254) +DEF_STYLE(accent_color_darker, RGB, 0.5607, 0.2470, 0.4431) +DEF_STYLE(background_color, RGB, 0.9764, 0.9607, 0.8431) + +DEF_STYLE(button_normal_color, RGB, m_style_accent_color) +DEF_STYLE(button_focused_color, RGB, m_style_accent_color_darker) +DEF_STYLE(button_active_color, RGB, m_style_accent_color_darker) + private: Window *m_window; public: diff --git a/src/main.cpp b/src/main.cpp index f1122df..9e143bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,7 +13,7 @@ int main() { button.set_current_geometry(Raven::Box(10, 10, 100, 30)); main_widget.set_current_geometry(window.get_current_geometry()); - main_widget.set_style_background_fill_color(Raven::RGB(0.9764, 0.9607, 0.8431)); + main_widget.set_style_background_fill_color(window.get_top_level_styles()->get_style_background_color()); main_widget.set_style_do_background_fill(true); window.set_main_widget(&main_widget);