Commit 41f42043 authored by Erwan Tulou's avatar Erwan Tulou

skins2: fix playlist arrows and enter no longer functioning

This patch fixes a regression brought by 88ba4526d03285a10e9abd59b9053c9d6927661
 that prevented arrows from being functional.
parent 830905f6
...@@ -283,6 +283,10 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) ...@@ -283,6 +283,10 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
/* Select it_sel */ /* Select it_sel */
it_sel->m_selected = true; it_sel->m_selected = true;
m_pLastSelected = &*it_sel; m_pLastSelected = &*it_sel;
// Redraw the control
makeImage();
notifyLayout();
} }
else if( key == KEY_PAGEDOWN ) else if( key == KEY_PAGEDOWN )
{ {
...@@ -307,7 +311,6 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) ...@@ -307,7 +311,6 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
ensureVisible( it ); ensureVisible( it );
makeImage(); makeImage();
notifyLayout(); notifyLayout();
return;
} }
} }
else if (key == KEY_PAGEUP ) else if (key == KEY_PAGEUP )
...@@ -328,130 +331,135 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent ) ...@@ -328,130 +331,135 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
ensureVisible( it ); ensureVisible( it );
makeImage(); makeImage();
notifyLayout(); 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 for( it = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();
EvtKey& rEvtKey = (EvtKey&)rEvent; it != m_rTree.end();
var_SetInteger( getIntf()->p_libvlc, "key-pressed", it = m_flat ? m_rTree.getNextLeaf( it )
rEvtKey.getModKey() ); : m_rTree.getNextVisibleItem( it ) )
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 )
{ {
// Scroll up one item VarTree::Iterator next = m_flat ?
if( ( it->parent() m_rTree.getNextLeaf( it ) :
&& it != it->parent()->begin() ) m_rTree.getNextVisibleItem( it );
|| &*it != m_pLastSelected ) if( key == KEY_UP )
{ {
bool nextWasSelected = ( &*next == m_pLastSelected ); // Scroll up one item
it->m_selected = nextWasSelected; if( ( it->parent()
if( nextWasSelected ) && it != it->parent()->begin() )
|| &*it != m_pLastSelected )
{ {
m_pLastSelected = &*it; bool nextWasSelected = ( &*next == m_pLastSelected );
needShow = true; toShow = it; it->m_selected = nextWasSelected;
if( nextWasSelected )
{
m_pLastSelected = &*it;
needShow = true; toShow = it;
}
} }
} }
} else if( key == KEY_DOWN )
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 )
{ {
m_pLastSelected = &*it; // Scroll down one item
needShow = true; toShow = it; if( ( it->parent()
previousWasSelected = false; && next != it->parent()->end() )
} || &*it != m_pLastSelected )
else {
{ (*it).m_selected = previousWasSelected;
previousWasSelected = ( &*it == m_pLastSelected ); }
} if( previousWasSelected )
{
m_pLastSelected = &*it;
needShow = true; toShow = it;
previousWasSelected = false;
}
else
{
previousWasSelected = ( &*it == m_pLastSelected );
}
// Fix last tree item selection // Fix last tree item selection
if( ( m_flat ? m_rTree.getNextLeaf( it ) if( ( m_flat ? m_rTree.getNextLeaf( it )
: m_rTree.getNextVisibleItem( it ) ) == m_rTree.end() : m_rTree.getNextVisibleItem( it ) ) == m_rTree.end()
&& &*it == m_pLastSelected ) && &*it == m_pLastSelected )
{ {
(*it).m_selected = true; (*it).m_selected = true;
}
} }
} else if( key == KEY_RIGHT )
else if( key == KEY_RIGHT )
{
// Go down one level (and expand node)
if( &*it == m_pLastSelected )
{ {
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; if( it->size() )
it->begin()->m_selected = true; {
m_pLastSelected = &*(it->begin()); it->m_selected = false;
it->begin()->m_selected = true;
m_pLastSelected = &*(it->begin());
}
else
{
m_rTree.action( &*it );
}
} }
else else
{ {
m_rTree.action( &*it ); it->m_expanded = true;
bChangedPosition = true;
} }
} }
else
{
it->m_expanded = true;
bChangedPosition = true;
}
} }
} else if( key == KEY_LEFT )
else if( key == KEY_LEFT )
{
// Go up one level (and close node)
if( &*it == m_pLastSelected )
{ {
if( it->m_expanded && it->size() ) // Go up one level (and close node)
if( &*it == m_pLastSelected )
{ {
it->m_expanded = false; if( it->m_expanded && it->size() )
bChangedPosition = true;
}
else
{
if( it->parent() && it->parent() != &m_rTree)
{ {
it->m_selected = false; it->m_expanded = false;
m_pLastSelected = it->parent(); bChangedPosition = true;
m_pLastSelected->m_selected = 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 == ' ' )
else if( key == KEY_ENTER || key == ' ' )
{
// Go up one level (and close node)
if( &*it == m_pLastSelected )
{ {
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 ) else if( rEvent.getAsString().find( "mouse:left" ) != string::npos )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment