]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins/controls/playlist.cpp
* src/input/control.c: added INPUT_ADD_INFO/INPUT_SET_NAME to input_Control().
[vlc] / modules / gui / skins / controls / playlist.cpp
index fe38445131721c151ee07cf5784a7fbcaf842ff4..4a88543f86b595e036b218b2937be8aa74f093ca 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -54,7 +54,7 @@
 //---------------------------------------------------------------------------
 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;
@@ -79,10 +79,31 @@ ControlPlayList::ControlPlayList( string id, bool visible, int width,
 
     // 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 );
@@ -154,7 +175,7 @@ void ControlPlayList::Init()
     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++ )
@@ -170,10 +191,10 @@ void ControlPlayList::Init()
     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  )
@@ -220,6 +241,7 @@ bool ControlPlayList::ProcessEvent( Event *evt )
                     if( Select[i] && i != PlayList->i_index )
                         playlist_Delete( PlayList, i );
                 }
+                RefreshList();
                 RefreshAll();
             }
             break;
@@ -229,10 +251,12 @@ bool ControlPlayList::ProcessEvent( Event *evt )
 //---------------------------------------------------------------------------
 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 )
         {
@@ -252,6 +276,8 @@ void ControlPlayList::RefreshList()
         Slider->ChangeSliderRange( Range );
         StartIndex = Slider->GetCursorPosition();
     }
+
+    vlc_mutex_unlock( &PlayList->object_lock );
 }
 //---------------------------------------------------------------------------
 void ControlPlayList::RefreshAll()
@@ -273,7 +299,7 @@ void ControlPlayList::Draw( int x, int y, int w, int h, Graphics *dest )
                          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 );
 
@@ -290,7 +316,7 @@ void ControlPlayList::Draw( int x, int y, int w, int h, Graphics *dest )
 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 );
     }
@@ -317,7 +343,7 @@ void ControlPlayList::DrawCase( Graphics *dest, int i, int x, int y, int w,
     }
 
     // Choose font
-    Font *F;
+    SkinFont *F;
     if( PlayList->i_index == i )
         F = PlayFont;
     else
@@ -349,13 +375,13 @@ char * ControlPlayList::GetFileName( int i )
 {
     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;
     }
 }
 //---------------------------------------------------------------------------
@@ -408,8 +434,19 @@ bool ControlPlayList::MouseDown( int x, int y, int button )
         {
             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;
@@ -459,9 +496,7 @@ bool ControlPlayList::MouseScroll( int x, int y, int direction )
     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:
@@ -519,12 +554,12 @@ bool ControlPlayList::ToolTipTest( int x, int y )
         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;
             }
         }