]> git.sesse.net Git - vlc/commitdiff
* ctrl_list.cpp: beginning of key handling in the playlist
authorCyril Deguet <asmax@videolan.org>
Sun, 22 Aug 2004 10:38:26 +0000 (10:38 +0000)
committerCyril Deguet <asmax@videolan.org>
Sun, 22 Aug 2004 10:38:26 +0000 (10:38 +0000)
modules/gui/skins2/controls/ctrl_list.cpp

index c6d7d50867f37bd3cd59809bf38abd631affbd4d..ddb29d41f21e9cafc32cc63fa88cfe3997a0a308 100644 (file)
@@ -161,7 +161,49 @@ void CtrlList::handleEvent( EvtGeneric &rEvent )
 {
     if( rEvent.getAsString().find( "key:down" ) != string::npos )
     {
-        char key = ((EvtKey&)rEvent).getKey();
+        int key = ((EvtKey&)rEvent).getKey();
+        VarList::Iterator it = m_rList.begin();
+        bool previousWasSelected = false;
+        while( it != m_rList.end() )
+        {
+            VarList::Iterator next = it;
+            ++next;
+            if( key == KEY_UP )
+            {
+                // Scroll up one item
+                if( it != m_rList.begin() || &*it != m_pLastSelected )
+                {
+                    bool nextWasSelected = ( &*next == m_pLastSelected );
+                    (*it).m_selected = nextWasSelected;
+                    if( nextWasSelected )
+                    {
+                        m_pLastSelected = &*it;
+                    }
+                }
+            }
+            else if( key == KEY_DOWN )
+            {
+                // Scroll down one item
+                if( next != m_rList.end() || &*it != m_pLastSelected )
+                {
+                    (*it).m_selected = previousWasSelected;
+                }
+                if( previousWasSelected )
+                {
+                    m_pLastSelected = &*it;
+                    previousWasSelected = false;
+                }
+                else
+                {
+                    previousWasSelected = ( &*it == m_pLastSelected );
+                }
+            }
+            it = next;
+        }
+
+        // Redraw the control
+        makeImage();
+        notifyLayout();
     }
 
     else if( rEvent.getAsString().find( "mouse:left" ) != string::npos )