LibGUI: Prevent "hide unnecessary scrollbars" from showing unwanted bars

When using this mode on an AbstractScrollWidget, it was not honoring the
related "scrollbars enabled" setting.

If scrollbars are disabled, they should never be made visible by the
"unnecessary scrollbars" logic.
This commit is contained in:
Andreas Kling 2023-01-08 22:59:06 +01:00
commit 33fd9ea5b3
Notes: sideshowbarker 2024-07-17 22:09:47 +09:00

View file

@ -156,11 +156,11 @@ void AbstractScrollableWidget::set_should_hide_unnecessary_scrollbars(bool shoul
return;
m_should_hide_unnecessary_scrollbars = should_hide_unnecessary_scrollbars;
if (should_hide_unnecessary_scrollbars)
if (should_hide_unnecessary_scrollbars) {
update_scrollbar_ranges();
else {
m_horizontal_scrollbar->set_visible(true);
m_vertical_scrollbar->set_visible(true);
} else {
m_horizontal_scrollbar->set_visible(m_scrollbars_enabled);
m_vertical_scrollbar->set_visible(m_scrollbars_enabled);
}
}
@ -176,6 +176,11 @@ void AbstractScrollableWidget::update_scrollbar_ranges()
void AbstractScrollableWidget::update_scrollbar_visibility()
{
if (!m_scrollbars_enabled) {
m_horizontal_scrollbar->set_visible(false);
m_vertical_scrollbar->set_visible(false);
return;
}
if (should_hide_unnecessary_scrollbars()) {
// If there has not been a min_size set, the content_size can be used as a substitute
auto effective_min_content_size = m_min_content_size;