summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/AbstractButton.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-08 11:02:36 +0200
committerAndreas Kling <kling@serenityos.org>2020-10-08 23:21:39 +0200
commit18b6c47178440bc30d31d48b5f55a5518eeba064 (patch)
tree85791aedca314b9ca47134864976b7cff49d0f99 /Libraries/LibGUI/AbstractButton.cpp
parent48647cc3ede2453fdb66824fb81fbb561b044d87 (diff)
downloadserenity-18b6c47178440bc30d31d48b5f55a5518eeba064.zip
LibGUI: Set initial AbstractButton background/foreground color roles
Widgets should respect the background/foreground roles in a way that makes sense for the widget.
Diffstat (limited to 'Libraries/LibGUI/AbstractButton.cpp')
-rw-r--r--Libraries/LibGUI/AbstractButton.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Libraries/LibGUI/AbstractButton.cpp b/Libraries/LibGUI/AbstractButton.cpp
index ae14dddc42..36dc287941 100644
--- a/Libraries/LibGUI/AbstractButton.cpp
+++ b/Libraries/LibGUI/AbstractButton.cpp
@@ -35,6 +35,9 @@ namespace GUI {
AbstractButton::AbstractButton(const StringView& text)
: m_text(text)
{
+ set_background_role(Gfx::ColorRole::Button);
+ set_foreground_role(Gfx::ColorRole::ButtonText);
+
m_auto_repeat_timer = add<Core::Timer>();
m_auto_repeat_timer->on_timeout = [this] {
click();
@@ -172,7 +175,7 @@ void AbstractButton::paint_text(Painter& painter, const Gfx::IntRect& rect, cons
if (text().is_empty())
return;
- painter.draw_text(clipped_rect, text(), font, text_alignment, palette().button_text(), Gfx::TextElision::Right);
+ painter.draw_text(clipped_rect, text(), font, text_alignment, palette().color(foreground_role()), Gfx::TextElision::Right);
if (is_focused())
painter.draw_rect(clipped_rect.inflated(6, 4), palette().focus_outline());
}