From 41f420438587fd47b1004b419ef75533dc05e75a Mon Sep 17 00:00:00 2001 From: Erwan Tulou Date: Thu, 5 Aug 2010 15:56:08 +0200 Subject: [PATCH] skins2: fix playlist arrows and enter no longer functioning This patch fixes a regression brought by 88ba4526d03285a10e9abd59b9053c9d6927661 that prevented arrows from being functional. --- modules/gui/skins2/controls/ctrl_tree.cpp | 198 +++++++++++----------- 1 file changed, 103 insertions(+), 95 deletions(-) diff --git a/modules/gui/skins2/controls/ctrl_tree.cpp b/modules/gui/skins2/controls/ctrl_tree.cpp index b816d02b3f..34c29302b6 100644 --- a/modules/gui/skins2/controls/ctrl_tree.cpp +++ b/modules/gui/skins2/controls/ctrl_tree.cpp @@ -283,6 +283,10 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) /* Select it_sel */ it_sel->m_selected = true; m_pLastSelected = &*it_sel; + + // Redraw the control + makeImage(); + notifyLayout(); } else if( key == KEY_PAGEDOWN ) { @@ -307,7 +311,6 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) ensureVisible( it ); makeImage(); notifyLayout(); - return; } } else if (key == KEY_PAGEUP ) @@ -328,130 +331,135 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) ensureVisible( it ); makeImage(); notifyLayout(); - return; } - else + else if ( key == KEY_UP || + key == KEY_DOWN || + key == KEY_LEFT || + key == KEY_RIGHT || + key == KEY_ENTER || + key == ' ' ) { - // other keys to be forwarded to vlc core - EvtKey& rEvtKey = (EvtKey&)rEvent; - var_SetInteger( getIntf()->p_libvlc, "key-pressed", - rEvtKey.getModKey() ); - return; - } - - - 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 ) ) - { - VarTree::Iterator next = m_flat ? m_rTree.getNextLeaf( it ) - : m_rTree.getNextVisibleItem( it ); - if( key == KEY_UP ) + 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 ) ) { - // Scroll up one item - if( ( it->parent() - && it != it->parent()->begin() ) - || &*it != m_pLastSelected ) + VarTree::Iterator next = m_flat ? + m_rTree.getNextLeaf( it ) : + m_rTree.getNextVisibleItem( it ); + if( key == KEY_UP ) { - bool nextWasSelected = ( &*next == m_pLastSelected ); - it->m_selected = nextWasSelected; - if( nextWasSelected ) + // Scroll up one item + if( ( it->parent() + && it != it->parent()->begin() ) + || &*it != m_pLastSelected ) { - m_pLastSelected = &*it; - needShow = true; toShow = it; + bool nextWasSelected = ( &*next == m_pLastSelected ); + it->m_selected = nextWasSelected; + if( nextWasSelected ) + { + m_pLastSelected = &*it; + needShow = true; toShow = it; + } } } - } - else if( key == KEY_DOWN ) - { - // Scroll down one item - if( ( it->parent() - && next != it->parent()->end() ) - || &*it != m_pLastSelected ) - { - (*it).m_selected = previousWasSelected; - } - if( previousWasSelected ) + else if( key == KEY_DOWN ) { - m_pLastSelected = &*it; - needShow = true; toShow = it; - previousWasSelected = false; - } - else - { - previousWasSelected = ( &*it == m_pLastSelected ); - } + // Scroll down one item + if( ( it->parent() + && next != it->parent()->end() ) + || &*it != m_pLastSelected ) + { + (*it).m_selected = previousWasSelected; + } + if( previousWasSelected ) + { + m_pLastSelected = &*it; + needShow = true; toShow = it; + previousWasSelected = false; + } + else + { + previousWasSelected = ( &*it == m_pLastSelected ); + } - // Fix last tree item selection - if( ( m_flat ? m_rTree.getNextLeaf( it ) - : m_rTree.getNextVisibleItem( it ) ) == m_rTree.end() - && &*it == m_pLastSelected ) - { - (*it).m_selected = true; + // Fix last tree item selection + if( ( m_flat ? m_rTree.getNextLeaf( it ) + : m_rTree.getNextVisibleItem( it ) ) == m_rTree.end() + && &*it == m_pLastSelected ) + { + (*it).m_selected = true; + } } - } - else if( key == KEY_RIGHT ) - { - // Go down one level (and expand node) - if( &*it == m_pLastSelected ) + else if( key == KEY_RIGHT ) { - if( it->m_expanded ) + // Go down one level (and expand node) + if( &*it == m_pLastSelected ) { - if( it->size() ) + if( it->m_expanded ) { - it->m_selected = false; - it->begin()->m_selected = true; - m_pLastSelected = &*(it->begin()); + if( it->size() ) + { + it->m_selected = false; + it->begin()->m_selected = true; + m_pLastSelected = &*(it->begin()); + } + else + { + m_rTree.action( &*it ); + } } else { - m_rTree.action( &*it ); + it->m_expanded = true; + bChangedPosition = true; } } - else - { - it->m_expanded = true; - bChangedPosition = true; - } } - } - else if( key == KEY_LEFT ) - { - // Go up one level (and close node) - if( &*it == m_pLastSelected ) + else if( key == KEY_LEFT ) { - if( it->m_expanded && it->size() ) + // Go up one level (and close node) + if( &*it == m_pLastSelected ) { - it->m_expanded = false; - bChangedPosition = true; - } - else - { - if( it->parent() && it->parent() != &m_rTree) + if( it->m_expanded && it->size() ) { - it->m_selected = false; - m_pLastSelected = it->parent(); - m_pLastSelected->m_selected = true; + it->m_expanded = false; + bChangedPosition = true; + } + else + { + if( it->parent() && it->parent() != &m_rTree) + { + it->m_selected = false; + m_pLastSelected = it->parent(); + m_pLastSelected->m_selected = true; + } } } } - } - else if( key == KEY_ENTER || key == ' ' ) - { - // Go up one level (and close node) - if( &*it == m_pLastSelected ) + else if( key == KEY_ENTER || key == ' ' ) { - m_rTree.action( &*it ); + // Go up one level (and close node) + if( &*it == m_pLastSelected ) + { + m_rTree.action( &*it ); + } } } + if( needShow ) + ensureVisible( toShow ); + // Redraw the control + makeImage(); + notifyLayout(); + } + else + { + // other keys to be forwarded to vlc core + EvtKey& rEvtKey = (EvtKey&)rEvent; + var_SetInteger( getIntf()->p_libvlc, "key-pressed", + rEvtKey.getModKey() ); } - if( needShow ) - ensureVisible( toShow ); - // Redraw the control - makeImage(); - notifyLayout(); } else if( rEvent.getAsString().find( "mouse:left" ) != string::npos ) -- 2.39.2