* playlist.cpp: Playlist control
*****************************************************************************
* Copyright (C) 2003 VideoLAN
- * $Id: playlist.cpp,v 1.5 2003/04/20 15:00:19 karibu Exp $
+ * $Id$
*
* Authors: Olivier Teulière <ipkiss@via.ecp.fr>
* Emmanuel Puig <karibu@via.ecp.fr>
//---------------------------------------------------------------------------
ControlPlayList::ControlPlayList( string id, bool visible, int width,
int infowidth, string font, string playfont, int selcolor, double *ptx,
- double *pty, int nb, bool longfilename, string help, Window *Parent )
+ double *pty, int nb, bool longfilename, string help, SkinWindow *Parent )
: GenericControl( id, visible, help, Parent )
{
Left = 0;
// Scroll
StartIndex = 0;
+
}
//---------------------------------------------------------------------------
ControlPlayList::~ControlPlayList()
{
+ if( CaseLeft )
+ {
+ delete[] CaseLeft;
+ }
+ if( CaseRight )
+ {
+ delete[] CaseRight;
+ }
+ if( CaseTextLeft )
+ {
+ delete[] CaseTextLeft;
+ }
+ if( Slider )
+ {
+ delete Slider;
+ }
+ if( TextClipRgn )
+ {
+ delete TextClipRgn;
+ }
if( PlayList != NULL )
{
vlc_object_release( PlayList );
TextWidth -= TextLeft;
// Set Text Clipping Region
- TextClipRgn = (Region *)new OSRegion;
+ TextClipRgn = (SkinRegion *)new OSRegion;
for( i = 0; i < Line; i++ )
{
for( j = 0; j < CaseHeight; j++ )
delete[] y;
// Get size of control
- Left = Slider->Left;
- Top = Slider->Top;
- Width = Slider->Left + Slider->Width;
- Height = Slider->Top + Slider->Height;
+ Left = Slider->GetLeft();
+ Top = Slider->GetTop();
+ Width = Slider->GetLeft() + Slider->GetWidth();
+ Height = Slider->GetTop() + Slider->GetHeight();
if( TextLeft < Left )
Left = TextLeft;
if( TextTop < Top )
if( Select[i] && i != PlayList->i_index )
playlist_Delete( PlayList, i );
}
+ RefreshList();
RefreshAll();
}
break;
//---------------------------------------------------------------------------
void ControlPlayList::RefreshList()
{
+ vlc_mutex_lock( &PlayList->object_lock );
+
if( NumOfItems != PlayList->i_size )
{
if( NumOfItems > 0 )
- delete Select;
+ delete[] Select;
NumOfItems = PlayList->i_size;
if( PlayList->i_size > 0 )
{
Slider->ChangeSliderRange( Range );
StartIndex = Slider->GetCursorPosition();
}
+
+ vlc_mutex_unlock( &PlayList->object_lock );
}
//---------------------------------------------------------------------------
void ControlPlayList::RefreshAll()
xI, yI, wI, hI) )
{
// Change clipping region
- Region *destClipRgn = (Region *)new OSRegion( 0, 0, w, h );
+ SkinRegion *destClipRgn = (SkinRegion *)new OSRegion( 0, 0, w, h );
TextClipRgn->Move( TextLeft - x, TextTop - y );
dest->SetClipRegion( TextClipRgn );
void ControlPlayList::DrawAllCase( Graphics *dest, int x, int y, int w, int h )
{
int i;
- for( i = 0; i < PlayList->i_size - StartIndex && i < Line * Column; i++ )
+ for( i = 0; i < NumOfItems - StartIndex && i < Line * Column; i++ )
{
DrawCase( dest, i + StartIndex, x, y, w, h );
}
}
// Choose font
- Font *F;
+ SkinFont *F;
if( PlayList->i_index == i )
F = PlayFont;
else
{
if( LongFileName )
{
- return PlayList->pp_items[i]->psz_name;
+ return PlayList->pp_items[i]->input.psz_name;
}
else
{
- string f = PlayList->pp_items[i]->psz_name;
+ string f = PlayList->pp_items[i]->input.psz_name;
int pos = f.rfind( DIRECTORY_SEPARATOR, f.size() );
- return PlayList->pp_items[i]->psz_name + pos + 1;
+ return PlayList->pp_items[i]->input.psz_name + pos + 1;
}
}
//---------------------------------------------------------------------------
{
for( j = 0; j < NumOfItems; j++ )
{
- if( j == i + StartIndex )
- Select[j] = !Select[j];
+ if( button & KEY_CTRL )
+ {
+ // CTRL is pressed
+ if( j == i + StartIndex )
+ {
+ Select[j] = !Select[j];
+ }
+ }
+ else
+ {
+ // CTRL is not pressed
+ Select[j] = ( j == i + StartIndex );
+ }
}
RefreshAll();
return true;
if( !TextClipRgn->Hit( x - Left, y - Top ) && !Slider->MouseOver( x, y ) )
return false;
- //long pos = Slider->GetCursorPosition();
long pos = StartIndex;
-fprintf(stderr," scroll %d %d\n", pos, StartIndex);
switch( direction )
{
case MOUSE_SCROLL_UP:
if( x >= CaseLeft[i] && x <= CaseRight[i] && y >=
TextTop + i * CaseHeight && y < TextTop + (i + 1) * CaseHeight )
{
- TextFont->GetSize( PlayList->pp_items[i + StartIndex]->psz_name, w,
+ TextFont->GetSize( PlayList->pp_items[i + StartIndex]->input.psz_name, w,
h );
if( w > FileWidth )
{
ParentWindow->ChangeToolTipText(
- (string)PlayList->pp_items[i + StartIndex]->psz_name );
+ (string)PlayList->pp_items[i + StartIndex]->input.psz_name );
return true;
}
}