mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
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:
parent
af6483cabb
commit
7e93418927
Notes:
sideshowbarker
2024-07-19 12:42:34 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7e934189279
2 changed files with 3 additions and 3 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue