From: Cyril Deguet Date: Sun, 22 Aug 2004 10:38:26 +0000 (+0000) Subject: * ctrl_list.cpp: beginning of key handling in the playlist X-Git-Tag: 0.8.0~621 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=234278af61a70d3efcfca81c1539bbf7715b7f6e;p=vlc * ctrl_list.cpp: beginning of key handling in the playlist --- diff --git a/modules/gui/skins2/controls/ctrl_list.cpp b/modules/gui/skins2/controls/ctrl_list.cpp index c6d7d50867..ddb29d41f2 100644 --- a/modules/gui/skins2/controls/ctrl_list.cpp +++ b/modules/gui/skins2/controls/ctrl_list.cpp @@ -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 )