From 4d3478aa7157bde0f8e54df4464531abe901c7b5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 25 Mar 2019 13:58:47 +0100 Subject: GItemView: Hide the horizontal scrollbar since we never need it. This view always relayouts the content to fit the available width, so we don't need a horizontal scrollbar. :^) --- LibGUI/GItemView.cpp | 1 + LibGUI/GScrollableWidget.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'LibGUI') diff --git a/LibGUI/GItemView.cpp b/LibGUI/GItemView.cpp index 29195cdc7b..f5ef4ba387 100644 --- a/LibGUI/GItemView.cpp +++ b/LibGUI/GItemView.cpp @@ -7,6 +7,7 @@ GItemView::GItemView(GWidget* parent) : GAbstractView(parent) { + horizontal_scrollbar().set_visible(false); } GItemView::~GItemView() diff --git a/LibGUI/GScrollableWidget.cpp b/LibGUI/GScrollableWidget.cpp index a47e99e1d6..d0ec6a12cc 100644 --- a/LibGUI/GScrollableWidget.cpp +++ b/LibGUI/GScrollableWidget.cpp @@ -29,8 +29,11 @@ void GScrollableWidget::resize_event(GResizeEvent& event) { update_scrollbar_ranges(); - m_vertical_scrollbar->set_relative_rect(event.size().width() - m_vertical_scrollbar->preferred_size().width(), 0, m_vertical_scrollbar->preferred_size().width(), event.size().height() - m_horizontal_scrollbar->preferred_size().height()); - m_horizontal_scrollbar->set_relative_rect(0, event.size().height() - m_horizontal_scrollbar->preferred_size().height(), event.size().width() - m_vertical_scrollbar->preferred_size().width(), m_horizontal_scrollbar->preferred_size().height()); + int height_wanted_by_horizontal_scrollbar = m_horizontal_scrollbar->is_visible() ? m_horizontal_scrollbar->height() : 0; + int width_wanted_by_vertical_scrollbar = m_vertical_scrollbar->is_visible() ? m_vertical_scrollbar->width() : 0; + + m_vertical_scrollbar->set_relative_rect(event.size().width() - m_vertical_scrollbar->preferred_size().width(), 0, m_vertical_scrollbar->preferred_size().width(), event.size().height() - height_wanted_by_horizontal_scrollbar); + m_horizontal_scrollbar->set_relative_rect(0, event.size().height() - m_horizontal_scrollbar->preferred_size().height(), event.size().width() - m_vertical_scrollbar->preferred_size().width(), width_wanted_by_vertical_scrollbar); m_corner_widget->set_visible(m_vertical_scrollbar->is_visible() && m_horizontal_scrollbar->is_visible()); if (m_corner_widget->is_visible()) { -- cgit v1.2.3