Commit cc5e6f6c authored by Clément Stenac's avatar Clément Stenac

Should fix playlist scrolling

playlist-current must not be handled by a full rebuild but by two item updates, on oldval (to remove its playing status) and newval (to give it playing status)
parent d03436e7
......@@ -132,9 +132,6 @@ int CtrlTree::maxItems()
void CtrlTree::onUpdate( Subject<VarTree> &rTree )
{
// Invalidate the position when the tree is updated
m_lastPos = m_rTree.begin();
autoScroll();
m_pLastSelected = NULL;
}
......@@ -472,18 +469,15 @@ void CtrlTree::draw( OSGraphics &rImage, int xDest, int yDest )
void CtrlTree::autoScroll()
{
fprintf( stderr, "Autoscroll start\n");
// Find the current playing stream
int playIndex = 0;
VarTree::Iterator it;
for( it = m_rTree.begin(); it != m_rTree.end();
it = m_rTree.getNextVisibleItem( it ) )
{
fprintf (stderr, "Checking playindex is %i\n", playIndex);
if( it->m_playing ) break;
playIndex++;
}
fprintf (stderr, "broke playIndex\n");
if( it == m_rTree.end() ) return;
......@@ -492,27 +486,23 @@ void CtrlTree::autoScroll()
for( it = m_rTree.begin(); it != m_rTree.end();
it = m_rTree.getNextVisibleItem( it ) )
{
fprintf (stderr, "Testing, lastPos is %i\n", lastPosIndex );
if( it == m_lastPos ) break;
lastPosIndex++;
}
if( it == m_rTree.end() ) return;
fprintf( stderr, "I have %i visible\n", maxItems() );
if( it != m_rTree.end()
&& ( playIndex < lastPosIndex
|| playIndex > lastPosIndex + maxItems() ) )
{
fprintf( stderr, "Need to scroll\n");
// Scroll to have the playing stream visible
VarPercent &rVarPos = m_rTree.getPositionVar();
rVarPos.set( 1.0 - (double)playIndex / (double)m_rTree.visibleItems() );
}
else
{
fprintf( stderr, "No need to scroll\n");
makeImage();
notifyLayout();
}
......@@ -584,7 +574,6 @@ void CtrlTree::makeImage()
bgColor = ( bgColor == m_bgColor1 ? m_bgColor2 : m_bgColor1 );
}
}
// fprintf( stderr, "done\n");
int bitmapWidth = itemImageWidth();
......
......@@ -351,9 +351,9 @@ int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
playlist_t *p_playlist = (playlist_t*)pObj;
pThis->updateStreamName(p_playlist);
// Create a playlist notify command
// Create a playlist notify command (for old style playlist)
CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
// Create a playtree notify command
// Create a playtree notify command (for new style playtree)
CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
// Push the command in the asynchronous command queue
......@@ -424,15 +424,16 @@ int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
playlist_t *p_playlist = (playlist_t*)pObj;
pThis->updateStreamName(p_playlist);
// Create a playlist notify command
// Create a playlist notify command (old style playlist)
// TODO: selective update
CmdNotifyPlaylist *pCmd = new CmdNotifyPlaylist( pThis->getIntf() );
// Create a playtree notify command
CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
// Push the command in the asynchronous command queue
pQueue->push( CmdGenericPtr( pCmd ) );
pQueue->push( CmdGenericPtr( pCmdTree ) );
// Create two playtree notify commands: one for old item, one for new
CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
oldVal.i_int );
pQueue->push( CmdGenericPtr( pCmdTree ) , true );
pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), newVal.i_int );
pQueue->push( CmdGenericPtr( pCmdTree ) , true );
return VLC_SUCCESS;
}
......
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