From 7e934189279e024a90003cbcfd2fa3eee9a6d308 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 12 Aug 2019 18:48:50 +0200 Subject: [PATCH] GButton: Allow non-checkable buttons to render as checked This changes the behavior of the "is_checkable" flag on GAbstractButton to only be about user interaction checkability. In other words, it now only prevents the user from checking/unchecking the button, the code. --- Libraries/LibGUI/GAbstractButton.cpp | 2 +- Libraries/LibGUI/GButton.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Libraries/LibGUI/GAbstractButton.cpp b/Libraries/LibGUI/GAbstractButton.cpp index 22fc7e14c0..6ecd836198 100644 --- a/Libraries/LibGUI/GAbstractButton.cpp +++ b/Libraries/LibGUI/GAbstractButton.cpp @@ -35,7 +35,7 @@ void GAbstractButton::set_checked(bool checked) if (is_exclusive() && checked) { parent_widget()->for_each_child_of_type([&](auto& sibling) { - if (!sibling.is_exclusive() || !sibling.is_checkable() || !sibling.is_checked()) + if (!sibling.is_exclusive() || !sibling.is_checked()) return IterationDecision::Continue; sibling.m_checked = false; sibling.update(); diff --git a/Libraries/LibGUI/GButton.cpp b/Libraries/LibGUI/GButton.cpp index d94fe81e74..fa03d1ff85 100644 --- a/Libraries/LibGUI/GButton.cpp +++ b/Libraries/LibGUI/GButton.cpp @@ -27,7 +27,7 @@ void GButton::paint_event(GPaintEvent& event) GPainter painter(*this); painter.add_clip_rect(event.rect()); - StylePainter::paint_button(painter, rect(), m_button_style, is_being_pressed(), is_hovered(), is_checkable() && is_checked(), is_enabled()); + StylePainter::paint_button(painter, rect(), m_button_style, is_being_pressed(), is_hovered(), is_checked(), is_enabled()); if (text().is_empty() && !m_icon) return; @@ -44,7 +44,7 @@ void GButton::paint_event(GPaintEvent& event) else painter.blit_dimmed(icon_location, *m_icon, m_icon->rect()); } - auto& font = (is_checkable() && is_checked()) ? Font::default_bold_font() : this->font(); + auto& font = is_checked() ? Font::default_bold_font() : this->font(); if (m_icon && !text().is_empty()) { content_rect.move_by(m_icon->width() + 4, 0); content_rect.set_width(content_rect.width() - m_icon->width() - 4);