]> git.sesse.net Git - vlc/commitdiff
Should fix playlist scrolling
authorClément Stenac <zorglub@videolan.org>
Sat, 3 Dec 2005 13:34:40 +0000 (13:34 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 3 Dec 2005 13:34:40 +0000 (13:34 +0000)
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)

modules/gui/skins2/controls/ctrl_tree.cpp
modules/gui/skins2/src/vlcproc.cpp

index c8906267bb282ee675baf5877b41e0425a362430..f161784ce0e0e2b8c204324ce4323f36ef73d1dc 100644 (file)
@@ -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();
 
index 73bd8b81586fd5f05d86125f2d63c1c51a6df5dc..504e480c8b25e4d3eab7d252d23db719b2fdc02b 100644 (file)
@@ -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;
 }