From 180fb2f35bd81bae890f4938d6a5c3e017475c7a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 3 Oct 2018 01:19:57 +0200 Subject: [PATCH] Restrict scrolled window virtual area in non-scrollable direction If a wxScrolledWindow is only scrollable in one direction, its virtual size should only extend beyond the actual size of the window in this direction, as any contents not fitting the window wouldn't be visible anyhow. --- src/generic/scrlwing.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index aa269504c9..a55f832d94 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -767,8 +767,18 @@ bool wxScrollHelperBase::ScrollLayout() // If we're the scroll target, take into account the // virtual size and scrolled position of the window. + wxSize size = m_win->GetVirtualSize(); + + // However we should use the real window size in the direction in which + // scrolling is disabled, if any. + const wxSize clientSize = m_win->GetClientSize(); + if ( !IsScrollbarShown(wxHORIZONTAL) ) + size.x = clientSize.x; + if ( !IsScrollbarShown(wxVERTICAL) ) + size.y = clientSize.y; + m_win->GetSizer()->SetDimension(CalcScrolledPosition(wxPoint(0, 0)), - m_win->GetVirtualSize()); + size); return true; }