]> git.sesse.net Git - vlc/commitdiff
Selection is almost working correctly
authorClément Stenac <zorglub@videolan.org>
Sun, 4 Dec 2005 20:07:30 +0000 (20:07 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 4 Dec 2005 20:07:30 +0000 (20:07 +0000)
modules/gui/skins2/controls/ctrl_tree.cpp

index f5c9dc77970b822b5149ffa6fac82163ace8b083..35fbcb9d568751e19188b1b5431063c28a33bc6d 100644 (file)
@@ -212,6 +212,7 @@ void CtrlTree::onPositionChange()
 
 void CtrlTree::handleEvent( EvtGeneric &rEvent )
 {
+    VarTree::Iterator toShow; bool needShow = false;
     if( rEvent.getAsString().find( "key:down" ) != string::npos )
     {
         int key = ((EvtKey&)rEvent).getKey();
@@ -233,9 +234,9 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
                     if( nextWasSelected )
                     {
                         m_pLastSelected = &*it;
+                        needShow = true; toShow = it;
                     }
                 }
-                ensureVisible( it );
             }
             else if( key == KEY_DOWN )
             {
@@ -249,13 +250,13 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
                 if( previousWasSelected )
                 {
                     m_pLastSelected = &*it;
+                    needShow = true; toShow = it;
                     previousWasSelected = false;
                 }
                 else
                 {
                     previousWasSelected = ( &*it == m_pLastSelected );
                 }
-                ensureVisible( it );
             }
             else if( key == KEY_RIGHT )
             {
@@ -310,6 +311,8 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
                 }
             }
         }
+        if( needShow )
+            ensureVisible( toShow );
 
         // Redraw the control
         makeImage();
@@ -475,7 +478,7 @@ bool CtrlTree::ensureVisible( VarTree::Iterator item )
     for( it = m_rTree.begin(); it != m_rTree.end();
          it = m_rTree.getNextVisibleItem( it ) )
     {
-        if( it == item ) break;
+        if( it->m_id == item->m_id ) break;
         focusItemIndex++;
     }
    return ensureVisible( focusItemIndex );