Преглед изворни кода

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.
Andreas Kling пре 6 година
родитељ
комит
7e93418927
2 измењених фајлова са 3 додато и 3 уклоњено
  1. 1 1
      Libraries/LibGUI/GAbstractButton.cpp
  2. 2 2
      Libraries/LibGUI/GButton.cpp

+ 1 - 1
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<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();

+ 2 - 2
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);