]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/interface.cpp
* INSTALL.win32: added a small note about running vlc under the msvc debugger.
[vlc] / modules / gui / wxwindows / interface.cpp
index 7fb68b7f9cee7b37177c5f54858b1a6fcf1dfdfd..f217ba14cd471fd05bc6e027e469d4f81b307fd2 100644 (file)
@@ -2,7 +2,7 @@
  * interface.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: interface.cpp,v 1.26 2003/05/11 15:55:51 gbazin Exp $
+ * $Id: interface.cpp,v 1.32 2003/05/22 12:00:56 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
 #include "bitmaps/previous.xpm"
 #include "bitmaps/next.xpm"
 #include "bitmaps/playlist.xpm"
-#define TOOLBAR_BMP_WIDTH 24
-#define TOOLBAR_BMP_HEIGHT 24
+#include "bitmaps/fast.xpm"
+#include "bitmaps/slow.xpm"
+
+#define TOOLBAR_BMP_WIDTH 36
+#define TOOLBAR_BMP_HEIGHT 36
 
 /* include the icon graphic */
 #include "share/vlc32x32.xpm"
@@ -115,6 +118,8 @@ enum
     PlayStream_Event,
     PrevStream_Event,
     NextStream_Event,
+    SlowStream_Event,
+    FastStream_Event,
 
     /* it is important for the id corresponding to the "About" command to have
      * this standard value as otherwise it won't be handled properly under Mac
@@ -148,6 +153,8 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU(PlayStream_Event, Interface::OnPlayStream)
     EVT_MENU(PrevStream_Event, Interface::OnPrevStream)
     EVT_MENU(NextStream_Event, Interface::OnNextStream)
+    EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
+    EVT_MENU(FastStream_Event, Interface::OnFastStream)
 
     /* Slider events */
     EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
@@ -164,6 +171,7 @@ Interface::Interface( intf_thread_t *_p_intf ):
     p_intf = _p_intf;
     p_prefs_dialog = NULL;
     i_old_playing_status = PAUSE_S;
+    p_open_dialog = NULL;
 
     /* Give our interface a nice little icon */
     p_intf->p_sys->p_icon = new wxIcon( vlc_xpm );
@@ -187,9 +195,11 @@ Interface::Interface( intf_thread_t *_p_intf ):
     /* Creation of the status bar
      * Helptext for menu items and toolbar tools will automatically get
      * displayed here. */
-    int i_status_width[2] = {-2,-3};
-    statusbar = CreateStatusBar( 2 );                            /* 2 fields */
-    statusbar->SetStatusWidths( 2, i_status_width );
+    int i_status_width[3] = {-6, -2, -9};
+    statusbar = CreateStatusBar( 3 );                            /* 2 fields */
+    statusbar->SetStatusWidths( 3, i_status_width );
+    statusbar->SetStatusText( wxString::Format(wxT("x%.2f"), 1.0), 1 );
+
 
     /* Make sure we've got the right background colour */
     SetBackgroundColour( slider_frame->GetBackgroundColour() );
@@ -207,6 +217,8 @@ Interface::Interface( intf_thread_t *_p_intf ):
 
 Interface::~Interface()
 {
+    /* Clean up */
+    if( p_open_dialog ) delete p_open_dialog;
     if( p_prefs_dialog ) p_prefs_dialog->Destroy();
 }
 
@@ -271,6 +283,10 @@ void Interface::CreateOurMenuBar()
     p_video_menu = new wxMenu;
     b_video_menu = 1;
 
+    /* Create the "Navigation" menu */
+    p_navig_menu = new wxMenu;
+    b_navig_menu = 1;
+
     /* Create the "Help" menu */
     wxMenu *help_menu = new wxMenu;
     help_menu->Append( About_Event, wxU(_("&About...")), wxU(_(HELP_ABOUT)) );
@@ -282,6 +298,7 @@ void Interface::CreateOurMenuBar()
     menubar->Append( settings_menu, wxU(_("&Settings")) );
     menubar->Append( p_audio_menu, wxU(_("&Audio")) );
     menubar->Append( p_video_menu, wxU(_("&Video")) );
+    menubar->Append( p_navig_menu, wxU(_("&Navigation")) );
     menubar->Append( help_menu, wxU(_("&Help")) );
 
     /* Attach the menu bar to the frame */
@@ -304,12 +321,14 @@ void Interface::CreateOurToolBar()
 #define HELP_PLO N_("Open playlist")
 #define HELP_PLP N_("Previous playlist item")
 #define HELP_PLN N_("Next playlist item")
+#define HELP_SLOW N_("Play slower")
+#define HELP_FAST N_("Play faster")
 
     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
                          * version because we don't include wx.rc */
 
     wxToolBar *toolbar = CreateToolBar(
-        wxTB_HORIZONTAL | wxTB_TEXT | wxTB_FLAT | wxTB_DOCKABLE );
+        wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
 
     toolbar->SetToolBitmapSize( wxSize(TOOLBAR_BMP_WIDTH,TOOLBAR_BMP_HEIGHT) );
 
@@ -335,6 +354,10 @@ void Interface::CreateOurToolBar()
                       wxBitmap( previous_xpm ), wxU(_(HELP_PLP)) );
     toolbar->AddTool( NextStream_Event, wxU(_("Next")), wxBitmap( next_xpm ),
                       wxU(_(HELP_PLN)) );
+    toolbar->AddTool( SlowStream_Event, wxU(_("Slower")), wxBitmap( slow_xpm ),
+                      wxU(_(HELP_SLOW)) );
+    toolbar->AddTool( FastStream_Event, wxU(_("Faster")), wxBitmap( fast_xpm ),
+                      wxU(_(HELP_FAST)) );
 
     toolbar->Realize();
 
@@ -386,9 +409,10 @@ void Interface::CreateOurSlider()
 void Interface::Open( int i_access_method )
 {
     /* Show/hide the open dialog */
-    OpenDialog dialog( p_intf, this, i_access_method );
+    if( p_open_dialog == NULL )
+        p_open_dialog = new OpenDialog( p_intf, this, i_access_method );
 
-    if( dialog.ShowModal() == wxID_OK )
+    if( p_open_dialog && p_open_dialog->ShowModal() == wxID_OK )
     {
         /* Update the playlist */
         playlist_t *p_playlist =
@@ -399,14 +423,15 @@ void Interface::Open( int i_access_method )
             return;
         }
 
-        playlist_Add( p_playlist, (const char *)dialog.mrl.mb_str(),
-                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
+        for( size_t i = 0; i < p_open_dialog->mrl.GetCount(); i++ )
+        {
+            playlist_Add( p_playlist,
+                (const char *)p_open_dialog->mrl[i].mb_str(),
+                PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
+        }
 
         TogglePlayButton( PLAYING_S );
 
-        /* Rebuild the playlist */
-        p_intf->p_sys->p_playlist_window->Rebuild();
-
         vlc_object_release( p_playlist );
     }
 }
@@ -421,15 +446,15 @@ void RecursiveDestroy( wxMenu *menu )
     for( ; node; )
     {
         wxMenuItem *item = node->GetData();
-       node = node->GetNext();
-
-       /* Delete the submenus */
-       wxMenu *submenu = item->GetSubMenu();
-       if( submenu )
-       {
-           RecursiveDestroy( submenu );
-       }
-       menu->Delete( item );
+        node = node->GetNext();
+
+        /* Delete the submenus */
+        wxMenu *submenu = item->GetSubMenu();
+        if( submenu )
+        {
+            RecursiveDestroy( submenu );
+        }
+        menu->Delete( item );
     }
 }
 
@@ -474,6 +499,25 @@ void Interface::OnMenuOpen(wxMenuEvent& event)
         }
         else b_video_menu = 1;
     }
+    else if( event.GetEventObject() == p_navig_menu )
+    {
+        if( b_navig_menu )
+        {
+            p_navig_menu = NavigMenu( p_intf, this );
+
+            /* Work-around for buggy wxGTK */
+            wxMenu *menu = GetMenuBar()->GetMenu( 5 );
+            RecursiveDestroy( menu );
+            /* End work-around */
+
+            menu =
+                GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")));
+            if( menu ) delete menu;
+
+            b_navig_menu = 0;
+        }
+        else b_navig_menu = 1;
+    }
 
 #else
     p_audio_menu = AudioMenu( p_intf, this );
@@ -484,6 +528,10 @@ void Interface::OnMenuOpen(wxMenuEvent& event)
     menu = GetMenuBar()->Replace( 4, p_video_menu, wxU(_("&Video")) );
     if( menu ) delete menu;
 
+    p_navig_menu = NavigMenu( p_intf, this );
+    menu = GetMenuBar()->Replace( 5, p_navig_menu, wxU(_("&Navigation")) );
+    if( menu ) delete menu;
+
 #endif
 }
 
@@ -524,10 +572,10 @@ void Interface::OnAbout( wxCommandEvent& WXUNUSED(event) )
 void Interface::OnPlaylist( wxCommandEvent& WXUNUSED(event) )
 {
     /* Show/hide the playlist window */
-    wxFrame *p_playlist_window = p_intf->p_sys->p_playlist_window;
+    Playlist *p_playlist_window = p_intf->p_sys->p_playlist_window;
     if( p_playlist_window )
     {
-        p_playlist_window->Show( ! p_playlist_window->IsShown() );
+        p_playlist_window->ShowPlaylist( ! p_playlist_window->IsShown() );
     }
 }
 
@@ -726,6 +774,30 @@ void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
     vlc_object_release( p_playlist );
 }
 
+void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) )
+{
+    input_thread_t *p_input =
+        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                           FIND_ANYWHERE );
+    if( p_input )
+    {
+        input_SetStatus( p_input, INPUT_STATUS_SLOWER );
+        vlc_object_release( p_input );
+    }
+}
+
+void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
+{
+    input_thread_t *p_input =
+        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                           FIND_ANYWHERE );
+    if( p_input )
+    {
+        input_SetStatus( p_input, INPUT_STATUS_FASTER );
+        vlc_object_release( p_input );
+    }
+}
+
 void Interface::TogglePlayButton( int i_playing_status )
 {
     if( i_playing_status == i_old_playing_status )
@@ -761,8 +833,6 @@ DragAndDrop::DragAndDrop( intf_thread_t *_p_intf )
 bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
                                const wxArrayString& filenames )
 {
-    unsigned int i;
-
     /* Add dropped files to the playlist */
 
     playlist_t *p_playlist =
@@ -773,12 +843,9 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
         return FALSE;
     }
 
-    for( i = 0; i < filenames.GetCount(); i++ )
+    for( size_t i = 0; i < filenames.GetCount(); i++ )
         playlist_Add( p_playlist, (const char *)filenames[i].mb_str(),
-                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
-
-    /* Rebuild the playlist */
-    p_intf->p_sys->p_playlist_window->Rebuild();
+                      PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
 
     vlc_object_release( p_playlist );