소스 검색

LibGUI: Set initial AbstractButton background/foreground color roles

Widgets should respect the background/foreground roles in a way that
makes sense for the widget.
Andreas Kling 4 년 전
부모
커밋
18b6c47178
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      Libraries/LibGUI/AbstractButton.cpp

+ 4 - 1
Libraries/LibGUI/AbstractButton.cpp

@@ -35,6 +35,9 @@ namespace GUI {
 AbstractButton::AbstractButton(const StringView& text)
 AbstractButton::AbstractButton(const StringView& text)
     : m_text(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 = add<Core::Timer>();
     m_auto_repeat_timer->on_timeout = [this] {
     m_auto_repeat_timer->on_timeout = [this] {
         click();
         click();
@@ -172,7 +175,7 @@ void AbstractButton::paint_text(Painter& painter, const Gfx::IntRect& rect, cons
 
 
     if (text().is_empty())
     if (text().is_empty())
         return;
         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())
     if (is_focused())
         painter.draw_rect(clipped_rect.inflated(6, 4), palette().focus_outline());
         painter.draw_rect(clipped_rect.inflated(6, 4), palette().focus_outline());
 }
 }