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.
This commit is contained in:
Andreas Kling 2019-08-12 18:48:50 +02:00
parent af6483cabb
commit 7e93418927
Notes: sideshowbarker 2024-07-19 12:42:34 +09:00
2 changed files with 3 additions and 3 deletions

View file

@ -35,7 +35,7 @@ void GAbstractButton::set_checked(bool checked)
if (is_exclusive() && checked) {
parent_widget()->for_each_child_of_type<GAbstractButton>([&](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();

View file

@ -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);