]> git.sesse.net Git - vlc/commitdiff
skins2: fix slider position a bit erratic
authorErwan Tulou <erwan10@videolan.org>
Fri, 6 Aug 2010 06:56:23 +0000 (08:56 +0200)
committerErwan Tulou <erwan10@videolan.org>
Tue, 10 Aug 2010 09:30:50 +0000 (11:30 +0200)
This path simplifies code a bit, makes index consistent throughout the code
(spanned from 0 to n-1), and remove a += maxitems that seems wrong

modules/gui/skins2/controls/ctrl_tree.cpp

index 4c1fff0e82a26de3dde87690e694c0e18fd8e317..dad3e43aaff5091a2c54be442adc6774b1db4ed6 100644 (file)
@@ -608,29 +608,25 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
         m_rTree.getPositionVar().set( percentage );
     }
 
-    /* We changed the nodes, let's fix teh position var */
+    /* We changed the nodes, let's fix the position var */
     if( bChangedPosition )
     {
         VarTree::Iterator it;
-        int i = 0;
         int iFirst = 0;
         for( it = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();
              it != m_rTree.end();
              it = m_flat ? m_rTree.getNextLeaf( it )
                          : m_rTree.getNextVisibleItem( it ) )
         {
-            i++;
             if( it == m_firstPos )
-            {
-                iFirst = i;
                 break;
-            }
+            iFirst++;
         }
-        iFirst += maxItems();
-        if( iFirst >= (m_flat ? m_rTree.countLeafs() : m_rTree.visibleItems()) )
-            iFirst = m_flat ? m_rTree.countLeafs() : m_rTree.visibleItems();
-        float f_new = (float)iFirst / (float)( m_flat ? m_rTree.countLeafs()
-                                                      :m_rTree.visibleItems() );
+
+        int indexMax = ( m_flat ? m_rTree.countLeafs()
+                                : m_rTree.visibleItems() ) - 1;
+        float f_new = (float)iFirst / (float)indexMax;
+
         m_dontMove = true;
         m_rTree.getPositionVar().set( 1.0 - f_new );
         m_dontMove = false;