Commit 9d42fbd4 authored by Antoine Cellerier's avatar Antoine Cellerier

code CtrlTree::autoScoll . Its still mostly buggy and give you a headache if

you watch the playlist when it is called but i can't find what's wrong.
parent 3284ec0b
...@@ -142,6 +142,8 @@ void CtrlTree::onUpdate( Subject<VarPercent> &rPercent ) ...@@ -142,6 +142,8 @@ void CtrlTree::onUpdate( Subject<VarPercent> &rPercent )
int excessItems = m_rTree.visibleItems() - maxItems(); int excessItems = m_rTree.visibleItems() - maxItems();
fprintf( stderr, "Hullo\n");
if( excessItems > 0) if( excessItems > 0)
{ {
VarPercent &rVarPos = m_rTree.getPositionVar(); VarPercent &rVarPos = m_rTree.getPositionVar();
...@@ -149,15 +151,18 @@ void CtrlTree::onUpdate( Subject<VarPercent> &rPercent ) ...@@ -149,15 +151,18 @@ void CtrlTree::onUpdate( Subject<VarPercent> &rPercent )
#ifdef _MSC_VER #ifdef _MSC_VER
# define lrint (int) # define lrint (int)
#endif #endif
it = m_rTree.visibleItem(lrint( (1.0 - rVarPos.get()) * (double)excessItems ) + 1); /* FIXME : shouldn't need this +1 */ it = m_rTree.visibleItem(lrint( (1.0 - rVarPos.get()) * (double)excessItems ) + 1);
} }
if( m_lastPos != it ) if( m_lastPos != it )
{ {
fprintf( stderr, "updating\n" );
// Redraw the control if the position has changed // Redraw the control if the position has changed
m_lastPos = it; m_lastPos = it;
makeImage(); makeImage();
notifyLayout(); notifyLayout();
} }
else
fprintf( stderr, "not updating\n" );
} }
void CtrlTree::onResize() void CtrlTree::onResize()
...@@ -175,7 +180,7 @@ void CtrlTree::onResize() ...@@ -175,7 +180,7 @@ void CtrlTree::onResize()
#ifdef _MSC_VER #ifdef _MSC_VER
# define lrint (int) # define lrint (int)
#endif #endif
it = m_rTree.visibleItem(lrint( (1.0 - rVarPos.get()) * (double)excessItems ) + 1); /* FIXME : shouldn't need this +1 */ it = m_rTree.visibleItem(lrint( (1.0 - rVarPos.get()) * (double)excessItems ) + 1);
} }
// Redraw the control if the position has changed // Redraw the control if the position has changed
m_lastPos = it; m_lastPos = it;
...@@ -474,13 +479,48 @@ void CtrlTree::draw( OSGraphics &rImage, int xDest, int yDest ) ...@@ -474,13 +479,48 @@ void CtrlTree::draw( OSGraphics &rImage, int xDest, int yDest )
void CtrlTree::autoScroll() void CtrlTree::autoScroll()
{ {
// TODO FIXME TODO // Find the current playing stream
makeImage(); int playIndex = 0;
notifyLayout(); VarTree::Iterator it;
for( it = m_rTree.begin(); it != m_rTree.end(); )
{
if( it->m_playing ) break;
playIndex++;
IT_DISP_LOOP_END( it );
}
if( it == m_rTree.end() ) return;
// Find m_lastPos
int lastPosIndex = 0;
for( it = m_rTree.begin(); it != m_rTree.end(); )
{
if( it == m_lastPos ) break;
lastPosIndex++;
IT_DISP_LOOP_END( it );
}
if( it == m_rTree.end() ) return;
if( it != m_rTree.end()
&& ( playIndex < lastPosIndex
|| playIndex > lastPosIndex + maxItems() ) )
{
// Scroll to have the playing stream visible
VarPercent &rVarPos = m_rTree.getPositionVar();
rVarPos.set( 1.0 - (double)playIndex / (double)m_rTree.visibleItems() );
}
else
{
makeImage();
notifyLayout();
}
} }
void CtrlTree::makeImage() void CtrlTree::makeImage()
{ {
fprintf( stderr, "CtrlTree::makeImage()\n");
if( m_pImage ) if( m_pImage )
{ {
delete m_pImage; delete m_pImage;
...@@ -509,7 +549,6 @@ void CtrlTree::makeImage() ...@@ -509,7 +549,6 @@ void CtrlTree::makeImage()
ScaledBitmap bmp( getIntf(), *m_pBgBitmap, width, height ); ScaledBitmap bmp( getIntf(), *m_pBgBitmap, width, height );
m_pImage->drawBitmap( bmp, 0, 0 ); m_pImage->drawBitmap( bmp, 0, 0 );
// FIXME : Take care of the selection color
for( int yPos = 0; yPos < height; yPos += i_itemHeight ) for( int yPos = 0; yPos < height; yPos += i_itemHeight )
{ {
int rectHeight = __MIN( i_itemHeight, height - yPos ); int rectHeight = __MIN( i_itemHeight, height - yPos );
...@@ -550,7 +589,6 @@ void CtrlTree::makeImage() ...@@ -550,7 +589,6 @@ void CtrlTree::makeImage()
int bitmapWidth = itemImageWidth(); int bitmapWidth = itemImageWidth();
// FIXME : Draw the items
int yPos = 0; int yPos = 0;
it = m_lastPos; it = m_lastPos;
while( it != m_rTree.end() && yPos < height ) while( it != m_rTree.end() && yPos < height )
......
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