[Plib-devel] [PATCH] puListBox::setTopItem(): don't scroll off the list
Brought to you by:
sjbaker
From: Melchior F. <mf...@us...> - 2006-05-21 09:07:19
|
This isn't really a bug, but still something that should be "fixed": puListBox::setTopItem() allows to scroll off a list until only one entry is left on the top and the rest empty(C). This is useless and doesn't buy us anything -- on the contrary: it's very annoying because you shoot over the goal and have to scroll back for no reason. The list view is really a viewport to the list, so there's no reason to display anything else than list members. Empty space doesn't belong to the list. And if leaving the list is possible on the bottom then why not on top? (C) & (D)? This would at least be consistent. :-} Current behavior: (A) & (C) Desired behavior: (A) & (B) (A) correct with top=0 (B) correct with top=max (but not in plib) aaaaa _________ __bbbbb__ | aaaaa | | ccccc | | bbbbb | | ddddd | | ccccc | | eeeee | | ddddd | | fffff | --------- --------- eeeee fffff (C) silly (current plib) (D) even sillier, but consistent with (C)! aaaaa _________ bbbbb | | ccccc | | ddddd | | __eeeee__ |_aaaaa_| | fffff | bbbbb | | ccccc | | ddddd | | eeeee --------- fffff Index: src/pui/puListBox.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puListBox.cxx,v retrieving revision 1.26 diff -u -p -r1.26 puListBox.cxx --- src/pui/puListBox.cxx 18 Apr 2006 16:50:17 -0000 1.26 +++ src/pui/puListBox.cxx 21 May 2006 08:45:08 -0000 @@ -74,10 +74,11 @@ void puListBox::newList ( char ** _list void puListBox::setTopItem( int item_index ) { top = item_index ; - if ( top < 0 ) + int visible = getNumVisible(); + if ( top < 0 || num <= visible ) top = 0 ; - else if ( num > 0 && top > num-1 ) - top = num-1; + else if ( num > 0 && top > num-visible ) + top = num-visible; puPostRefresh () ; } |