]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/timer.cpp
* modules/gui/wxwindows/*: The wxwindows interface is now a "dialogs provider" module...
[vlc] / modules / gui / wxwindows / timer.cpp
index 969a55c5ab0caca872bd632b2254db14b85cdb1b..ef2e13ffc4fc340e60829d7975342c0a89e3b061 100644 (file)
@@ -2,7 +2,7 @@
  * timer.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: timer.cpp,v 1.9 2003/01/26 10:36:10 gbazin Exp $
+ * $Id: timer.cpp,v 1.26 2003/07/17 17:30:40 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -30,6 +30,7 @@
 #include <stdio.h>
 
 #include <vlc/vlc.h>
+#include <vlc/aout.h>
 
 #ifdef WIN32                                                 /* mingw32 hack */
 #undef Yield
 
 void DisplayStreamDate( wxControl *, intf_thread_t *, int );
 
+/* Callback prototype */
+static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
+                       vlc_value_t old_val, vlc_value_t new_val, void *param );
+
 /*****************************************************************************
  * Constructor.
  *****************************************************************************/
@@ -56,6 +61,18 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface )
 {
     p_intf = _p_intf;
     p_main_interface = _p_main_interface;
+    i_old_playing_status = PAUSE_S;
+    i_old_rate = DEFAULT_RATE;
+
+    /* Register callback for the intf-popupmenu variable */
+    playlist_t *p_playlist =
+        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                       FIND_ANYWHERE );
+    if( p_playlist != NULL )
+    {
+        var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
+        vlc_object_release( p_playlist );
+    }
 
     Start( 100 /*milliseconds*/, wxTIMER_CONTINUOUS );
 }
@@ -67,27 +84,6 @@ Timer::~Timer()
 /*****************************************************************************
  * Private methods.
  *****************************************************************************/
-/*****************************************************************************
- * wxModeManage: actualise the aspect of the interface whenever the input
- * changes.
- *****************************************************************************
- * The lock has to be taken before you call the function.
- *****************************************************************************/
-static int wxModeManage( intf_thread_t * p_intf )
-{
-    return 0;
-}
-
-/*****************************************************************************
- * wxSetupMenus: function that generates title/chapter/audio/subpic
- * menus with help from preceding functions
- *****************************************************************************
- * Function called with the lock on stream
- *****************************************************************************/
-static int wxSetupMenus( intf_thread_t * p_intf )
-{
-    return 0;
-}
 
 /*****************************************************************************
  * Manage: manage main thread messages
@@ -97,23 +93,23 @@ static int wxSetupMenus( intf_thread_t * p_intf )
  *****************************************************************************/
 void Timer::Notify()
 {
-    int i_stop;
+    vlc_bool_t b_pace_control;
 
     vlc_mutex_lock( &p_intf->change_lock );
 
     /* If the "display popup" flag has changed */
-    if( p_intf->b_menu_change )
+    if( p_intf->p_sys->b_popup_change )
     {
-        p_main_interface->p_popup_menu =
-            new PopupMenu( p_intf, p_main_interface );
-        p_intf->b_menu_change = 0;
-    }
+        wxPoint mousepos = wxGetMousePosition();
+
+        wxMouseEvent event = wxMouseEvent( wxEVT_RIGHT_UP );
+        event.m_x = p_main_interface->ScreenToClient(mousepos).x;
+        event.m_y = p_main_interface->ScreenToClient(mousepos).y;
 
-    /* Update the log window */
-    p_intf->p_sys->p_messages_window->UpdateLog();
+        p_main_interface->AddPendingEvent(event);
 
-    /* Update the playlist */
-    p_intf->p_sys->p_playlist_window->Manage();
+        p_intf->p_sys->b_popup_change = VLC_FALSE;
+    }
 
     /* Update the input */
     if( p_intf->p_sys->p_input == NULL )
@@ -121,36 +117,61 @@ void Timer::Notify()
         p_intf->p_sys->p_input = (input_thread_t *)vlc_object_find( p_intf,
                                                        VLC_OBJECT_INPUT,
                                                        FIND_ANYWHERE );
+
         /* Show slider */
-        if(p_intf->p_sys->p_input)
+        if( p_intf->p_sys->p_input )
         {
-            p_main_interface->frame_sizer->Add(
-                p_main_interface->slider_frame, 1, wxGROW, 0 );
-            p_main_interface->slider_frame->Show();
-            p_main_interface->frame_sizer->Layout();
-            p_main_interface->frame_sizer->Fit( p_main_interface );
+            //if( p_intf->p_sys->p_input->stream.b_seekable )
+            {
+                p_main_interface->slider_frame->Show();
+                p_main_interface->frame_sizer->Show(
+                    p_main_interface->slider_frame );
+                p_main_interface->frame_sizer->Layout();
+                p_main_interface->frame_sizer->Fit( p_main_interface );
+            }
+
             p_main_interface->statusbar->SetStatusText(
-                p_intf->p_sys->p_input->psz_source, 1 );
+                wxU(p_intf->p_sys->p_input->psz_source), 2 );
+
+            p_main_interface->TogglePlayButton( PLAYING_S );
+            i_old_playing_status = PLAYING_S;
+
+            /* Take care of the volume */
+            audio_volume_t i_volume;
+            aout_VolumeGet( p_intf, &i_volume );
+            p_main_interface->volctrl->SetValue( i_volume * 200 /
+                                                 AOUT_VOLUME_MAX );
+            p_main_interface->volctrl->SetToolTip(
+                wxString::Format((wxString)wxU(_("Volume")) + wxT(" %d"),
+                i_volume * 200 / AOUT_VOLUME_MAX ) );
+
+            /* control buttons for free pace streams */
+            b_pace_control = p_intf->p_sys->p_input->stream.b_pace_control;
         }
     }
     else if( p_intf->p_sys->p_input->b_dead )
     {
         /* Hide slider */
-        if(p_intf->p_sys->p_input)
+        //if( p_intf->p_sys->p_input->stream.b_seekable )
         {
             p_main_interface->slider_frame->Hide();
-            p_main_interface->frame_sizer->Remove(
+            p_main_interface->frame_sizer->Hide(
                 p_main_interface->slider_frame );
             p_main_interface->frame_sizer->Layout();
             p_main_interface->frame_sizer->Fit( p_main_interface );
+
+            p_main_interface->TogglePlayButton( PAUSE_S );
+            i_old_playing_status = PAUSE_S;
         }
 
-        p_main_interface->statusbar->SetStatusText( "", 1 );
+        p_main_interface->statusbar->SetStatusText( wxT(""), 2 );
 
         vlc_object_release( p_intf->p_sys->p_input );
         p_intf->p_sys->p_input = NULL;
     }
 
+
+
     if( p_intf->p_sys->p_input )
     {
         input_thread_t *p_input = p_intf->p_sys->p_input;
@@ -160,17 +181,22 @@ void Timer::Notify()
         if( !p_input->b_die )
         {
             /* New input or stream map change */
+            p_intf->p_sys->b_playing = 1;
+#if 0
             if( p_input->stream.b_changed )
             {
                 wxModeManage( p_intf );
                 wxSetupMenus( p_intf );
                 p_intf->p_sys->b_playing = 1;
+
+                p_main_interface->TogglePlayButton( PLAYING_S );
+                i_old_playing_status = PLAYING_S;
             }
+#endif
 
             /* Manage the slider */
             if( p_input->stream.b_seekable && p_intf->p_sys->b_playing )
             {
-
                 stream_position_t position;
 
                 /* Update the slider if the user isn't dragging it. */
@@ -180,23 +206,41 @@ void Timer::Notify()
                     vlc_mutex_unlock( &p_input->stream.stream_lock );
                     input_Tell( p_input, &position );
                     vlc_mutex_lock( &p_input->stream.stream_lock );
-                    p_intf->p_sys->i_slider_pos =
+                    if( position.i_size )
+                    {
+                        p_intf->p_sys->i_slider_pos =
                         ( SLIDER_MAX_POS * position.i_tell ) / position.i_size;
 
-                    p_main_interface->slider->SetValue(
-                        p_intf->p_sys->i_slider_pos );
+                        p_main_interface->slider->SetValue(
+                            p_intf->p_sys->i_slider_pos );
 
-                   DisplayStreamDate( p_main_interface->slider_box,
-                                      p_intf,
-                                      p_intf->p_sys->i_slider_pos );
+                        DisplayStreamDate( p_main_interface->slider_box,p_intf,
+                                           p_intf->p_sys->i_slider_pos );
+                    }
                 }
             }
 
-            if( p_intf->p_sys->i_part !=
-                p_input->stream.p_selected_area->i_part )
+            /* Manage Playing status */
+            if( i_old_playing_status != p_input->stream.control.i_status )
             {
-                p_intf->p_sys->b_chapter_update = 1;
-                wxSetupMenus( p_intf );
+                if( p_input->stream.control.i_status == PAUSE_S )
+                {
+                    p_main_interface->TogglePlayButton( PAUSE_S );
+                }
+                else
+                {
+                    p_main_interface->TogglePlayButton( PLAYING_S );
+                }
+                i_old_playing_status = p_input->stream.control.i_status;
+            }
+
+            /* Manage Speed status */
+            if( i_old_rate != p_input->stream.control.i_rate )
+            {
+                p_main_interface->statusbar->SetStatusText(
+                    wxString::Format(wxT("x%.2f"),
+                    1000.0 / p_input->stream.control.i_rate), 1 );
+                i_old_rate = p_input->stream.control.i_rate;
             }
         }
 
@@ -204,8 +248,9 @@ void Timer::Notify()
     }
     else if( p_intf->p_sys->b_playing && !p_intf->b_die )
     {
-        wxModeManage( p_intf );
         p_intf->p_sys->b_playing = 0;
+        p_main_interface->TogglePlayButton( PAUSE_S );
+        i_old_playing_status = PAUSE_S;
     }
 
     if( p_intf->b_die )
@@ -236,9 +281,23 @@ void DisplayStreamDate( wxControl *p_slider_frame, intf_thread_t * p_intf ,
         char psz_time[ OFFSETTOTIME_MAX_SIZE ];
 
         p_slider_frame->SetLabel(
-            input_OffsetToTime( p_intf->p_sys->p_input,
-                                psz_time,
-                                p_area->i_size * i_pos / SLIDER_MAX_POS ) );
+            wxU(input_OffsetToTime( p_intf->p_sys->p_input,
+                    psz_time, p_area->i_size * i_pos / SLIDER_MAX_POS )) );
 #undef p_area
      }
 }
+
+/*****************************************************************************
+ * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable.
+ *  We don't show the menu directly here because we don't want the
+ *  caller to block for a too long time.
+ *****************************************************************************/
+static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
+                        vlc_value_t old_val, vlc_value_t new_val, void *param )
+{
+    intf_thread_t *p_intf = (intf_thread_t *)param;
+
+    p_intf->p_sys->b_popup_change = VLC_TRUE;
+
+    return VLC_SUCCESS;
+}