Преглед на файлове

GButton: Only draw focus rect if there is a caption text.

Andreas Kling преди 6 години
родител
ревизия
ee363faf10
променени са 1 файла, в които са добавени 8 реда и са изтрити 6 реда
  1. 8 6
      LibGUI/GButton.cpp

+ 8 - 6
LibGUI/GButton.cpp

@@ -62,12 +62,14 @@ void GButton::paint_event(GPaintEvent& event)
         content_rect.set_width(content_rect.width() - m_icon->width() - 4);
         content_rect.set_width(content_rect.width() - m_icon->width() - 4);
     }
     }
     if (is_enabled()) {
     if (is_enabled()) {
-        painter.draw_text(content_rect, m_caption, font, text_alignment(), foreground_color(), TextElision::Right);
-        if (is_focused()) {
-            Rect focus_rect = { 0, 0, font.width(m_caption), font.glyph_height() };
-            focus_rect.inflate(6, 4);
-            focus_rect.center_within(content_rect);
-            painter.draw_rect(focus_rect, Color(140, 140, 140));
+        if (!m_caption.is_empty()) {
+            painter.draw_text(content_rect, m_caption, font, text_alignment(), foreground_color(), TextElision::Right);
+            if (is_focused()) {
+                Rect focus_rect = { 0, 0, font.width(m_caption), font.glyph_height() };
+                focus_rect.inflate(6, 4);
+                focus_rect.center_within(content_rect);
+                painter.draw_rect(focus_rect, Color(140, 140, 140));
+            }
         }
         }
     } else {
     } else {
         painter.draw_text(content_rect.translated(1, 1), m_caption, font, text_alignment(), Color::White, TextElision::Right);
         painter.draw_text(content_rect.translated(1, 1), m_caption, font, text_alignment(), Color::White, TextElision::Right);