From ee363faf102becd916090c8b37e03e2a22b0633f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 16 May 2019 14:05:28 +0200 Subject: [PATCH] GButton: Only draw focus rect if there is a caption text. --- LibGUI/GButton.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/LibGUI/GButton.cpp b/LibGUI/GButton.cpp index 371d52c614..3dbf12bc68 100644 --- a/LibGUI/GButton.cpp +++ b/LibGUI/GButton.cpp @@ -62,12 +62,14 @@ void GButton::paint_event(GPaintEvent& event) content_rect.set_width(content_rect.width() - m_icon->width() - 4); } 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 { painter.draw_text(content_rect.translated(1, 1), m_caption, font, text_alignment(), Color::White, TextElision::Right);