Fix scrolling in small wxVListBox with tall items.
Scrolling in a small wxVListBox with tall items (i.e. taller than the height of wxVListBox itself) behaved wrongly: wrong item was being scrolled into view and Page Up/Down didn't scroll as much as they should. Fix both of these problems by checking for these corner cases explicitly. Closes #13454. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69180 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -249,7 +249,10 @@ bool wxVListBox::DoSetCurrent(int current)
|
|||||||
{
|
{
|
||||||
// it is, indeed, only partly visible, so scroll it into view to
|
// it is, indeed, only partly visible, so scroll it into view to
|
||||||
// make it entirely visible
|
// make it entirely visible
|
||||||
|
// BUT scrolling down when m_current is first visible makes it
|
||||||
|
// completely hidden, so that is even worse
|
||||||
while ( (size_t)m_current + 1 == GetVisibleRowsEnd() &&
|
while ( (size_t)m_current + 1 == GetVisibleRowsEnd() &&
|
||||||
|
(size_t)m_current != GetVisibleRowsBegin() &&
|
||||||
ScrollToRow(GetVisibleBegin() + 1) ) ;
|
ScrollToRow(GetVisibleBegin() + 1) ) ;
|
||||||
|
|
||||||
// but in any case refresh it as even if it was only partly visible
|
// but in any case refresh it as even if it was only partly visible
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
#include "wx/vscroll.h"
|
#include "wx/vscroll.h"
|
||||||
|
|
||||||
|
#include "wx/utils.h" // For wxMin/wxMax().
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// wxVarScrollHelperEvtHandler declaration
|
// wxVarScrollHelperEvtHandler declaration
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -308,14 +310,17 @@ size_t wxVarScrollHelperBase::GetNewScrollPosition(wxScrollWinEvent& event) cons
|
|||||||
}
|
}
|
||||||
else if ( evtType == wxEVT_SCROLLWIN_PAGEUP )
|
else if ( evtType == wxEVT_SCROLLWIN_PAGEUP )
|
||||||
{
|
{
|
||||||
return FindFirstVisibleFromLast(m_unitFirst);
|
// Page up should do at least as much as line up.
|
||||||
|
return wxMin(FindFirstVisibleFromLast(m_unitFirst),
|
||||||
|
m_unitFirst ? m_unitFirst - 1 : 0);
|
||||||
}
|
}
|
||||||
else if ( evtType == wxEVT_SCROLLWIN_PAGEDOWN )
|
else if ( evtType == wxEVT_SCROLLWIN_PAGEDOWN )
|
||||||
{
|
{
|
||||||
|
// And page down should do at least as much as line down.
|
||||||
if ( GetVisibleEnd() )
|
if ( GetVisibleEnd() )
|
||||||
return GetVisibleEnd() - 1;
|
return wxMax(GetVisibleEnd() - 1, m_unitFirst + 1);
|
||||||
else
|
else
|
||||||
return GetVisibleEnd();
|
return wxMax(GetVisibleEnd(), m_unitFirst + 1);
|
||||||
}
|
}
|
||||||
else if ( evtType == wxEVT_SCROLLWIN_THUMBRELEASE )
|
else if ( evtType == wxEVT_SCROLLWIN_THUMBRELEASE )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user