]> git.sesse.net Git - vlc/commitdiff
skins2: fix arrows short of 1
authorErwan Tulou <erwan10@videolan.org>
Thu, 5 Aug 2010 16:05:45 +0000 (18:05 +0200)
committerErwan Tulou <erwan10@videolan.org>
Tue, 10 Aug 2010 09:30:50 +0000 (11:30 +0200)
For n items, index spans from 0 to (n-1).
This issue accounted for arrows failing to move the cursor past the end of
the visible list (short of 1 click)

modules/gui/skins2/controls/ctrl_tree.cpp

index c31962c4913b5c8d13cfec5eaa59390aefe7899c..b8be9b453f9cf4f8f7cb7b31d7e42392265cc0b4 100644 (file)
@@ -697,13 +697,13 @@ bool CtrlTree::ensureVisible( int focusItemIndex )
 
     if( it != m_rTree.end()
         && ( focusItemIndex < firstPosIndex
-           || focusItemIndex > firstPosIndex + maxItems() ) )
+           || focusItemIndex > firstPosIndex + maxItems() - 1 ) )
     {
         // Scroll to have the wanted stream visible
         VarPercent &rVarPos = m_rTree.getPositionVar();
-        rVarPos.set( 1.0 - (double)focusItemIndex /
-                           (double)( m_flat ? m_rTree.countLeafs()
-                                            : m_rTree.visibleItems() ) );
+        int indexMax = ( m_flat ? m_rTree.countLeafs()
+                                : m_rTree.visibleItems() ) - 1;
+        rVarPos.set( 1.0 - (double)focusItemIndex / (double)indexMax );
         return true;
     }
     return false;