diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-08-03 11:35:10 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-03 11:35:10 +0200 |
commit | 47511b593049559a7ea95d53e907563b5c74c133 (patch) | |
tree | 3835160b601a6b3050c4c57791865b911d993829 /Libraries | |
parent | 54c77cb71402333a22a3b775881f7d6b9d8a83b7 (diff) | |
download | serenity-47511b593049559a7ea95d53e907563b5c74c133.zip |
GWidget: Implement set_backcolor() and set_forecolor()
These are set-color-from-string variants used by the VisualBuilder's
code generator.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGUI/GWidget.cpp | 16 | ||||
-rw-r--r-- | Libraries/LibGUI/GWidget.h | 5 |
2 files changed, 18 insertions, 3 deletions
diff --git a/Libraries/LibGUI/GWidget.cpp b/Libraries/LibGUI/GWidget.cpp index 16961b30b2..1a07c4865b 100644 --- a/Libraries/LibGUI/GWidget.cpp +++ b/Libraries/LibGUI/GWidget.cpp @@ -569,3 +569,19 @@ void GWidget::focus_next_widget() focusable_widgets.first()->set_focus(true); } } + +void GWidget::set_backcolor(const StringView& color_string) +{ + auto color = Color::from_string(color_string); + if (!color.has_value()) + return; + set_background_color(color.value()); +} + +void GWidget::set_forecolor(const StringView& color_string) +{ + auto color = Color::from_string(color_string); + if (!color.has_value()) + return; + set_foreground_color(color.value()); +} diff --git a/Libraries/LibGUI/GWidget.h b/Libraries/LibGUI/GWidget.h index cb9f99f9a1..3c4af83d53 100644 --- a/Libraries/LibGUI/GWidget.h +++ b/Libraries/LibGUI/GWidget.h @@ -137,9 +137,8 @@ public: void set_background_color(Color color) { m_background_color = color; } void set_foreground_color(Color color) { m_foreground_color = color; } - // FIXME: Implement these. - void set_backcolor(const StringView&) {} - void set_forecolor(const StringView&) {} + void set_backcolor(const StringView&); + void set_forecolor(const StringView&); void set_autofill(bool b) { set_fill_with_background_color(b); } |