offload button colors to TopLevelStyles

This commit is contained in:
hippoz 2022-03-18 02:58:34 +02:00
parent ef85745f58
commit c2a605f172
Signed by: hippoz
GPG key ID: 7C52899193467641
4 changed files with 22 additions and 5 deletions

View file

@ -8,9 +8,16 @@
namespace Raven { namespace Raven {
void Button::on_init() { 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_do_background_fill(true);
set_style_background_fill_color(m_style_normal_background_fill_color); 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); set_did_init(true);
} }

View file

@ -11,9 +11,9 @@ namespace Raven {
class Button : public Widget { class Button : public Widget {
DEF_STYLE(text_fill_color, RGB, 0.0, 0.0, 0.0) 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(normal_background_fill_color, RGB, 0.0, 0.0, 0.0)
DEF_STYLE(focused_background_fill_color, RGB, 0.5607, 0.2470, 0.4431) DEF_STYLE(focused_background_fill_color, RGB, 0.0, 0.0, 0.0)
DEF_STYLE(active_background_fill_color, RGB, 0.896, 0.743, 0.979) DEF_STYLE(active_background_fill_color, RGB, 0.0, 0.0, 0.0)
DEF_STYLE(font_description, PangoFontDescription*, nullptr) DEF_STYLE(font_description, PangoFontDescription*, nullptr)

View file

@ -4,12 +4,22 @@
#include "Forward.hpp" #include "Forward.hpp"
#include "pango/pango-font.h" #include "pango/pango-font.h"
#include "StyleMacros.hpp" #include "StyleMacros.hpp"
#include "RGB.hpp"
namespace Raven { namespace Raven {
class TopLevelStyles { class TopLevelStyles {
DEF_STYLE(controls_font_description, PangoFontDescription*, nullptr) 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: private:
Window *m_window; Window *m_window;
public: public:

View file

@ -13,7 +13,7 @@ int main() {
button.set_current_geometry(Raven::Box(10, 10, 100, 30)); button.set_current_geometry(Raven::Box(10, 10, 100, 30));
main_widget.set_current_geometry(window.get_current_geometry()); 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); main_widget.set_style_do_background_fill(true);
window.set_main_widget(&main_widget); window.set_main_widget(&main_widget);