diff --git a/LibGUI/GButton.cpp b/LibGUI/GButton.cpp index 7be6cc824a..af2edfe215 100644 --- a/LibGUI/GButton.cpp +++ b/LibGUI/GButton.cpp @@ -1,6 +1,7 @@ #include "GButton.h" #include #include +#include //#define GBUTTON_DEBUG @@ -36,18 +37,19 @@ void GButton::paint_event(GPaintEvent& event) StylePainter::paint_button(painter, rect(), m_button_style, m_being_pressed, m_hovered, m_checkable && m_checked); - if (!caption().is_empty() || m_icon) { - auto content_rect = rect().shrunken(10, 2); - auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Point(); - if (m_being_pressed) { - content_rect.move_by(1, 1); - icon_location.move_by(1, 1); - } - if (m_icon) - painter.blit(icon_location, *m_icon, m_icon->rect()); - auto& font = (m_checkable && m_checked) ? Font::default_bold_font() : this->font(); - painter.draw_text(content_rect, caption(), font, text_alignment(), Color::Black); + if (m_caption.is_empty() && !m_icon) + return; + + auto content_rect = rect().shrunken(10, 2); + auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Point(); + if (m_being_pressed) { + content_rect.move_by(1, 1); + icon_location.move_by(1, 1); } + if (m_icon) + painter.blit(icon_location, *m_icon, m_icon->rect()); + auto& font = (m_checkable && m_checked) ? Font::default_bold_font() : this->font(); + painter.draw_text(content_rect, m_caption, font, text_alignment(), Color::Black, TextElision::Right); } void GButton::mousemove_event(GMouseEvent& event)