]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wxwidgets: massive cleanup and simplification of the main interface...
authorGildas Bazin <gbazin@videolan.org>
Wed, 30 Nov 2005 23:56:51 +0000 (23:56 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 30 Nov 2005 23:56:51 +0000 (23:56 +0000)
18 files changed:
modules/gui/wxwidgets/Modules.am
modules/gui/wxwidgets/dialogs/vlm/vlm_slider_manager.cpp
modules/gui/wxwidgets/dialogs/vlm/vlm_slider_manager.hpp
modules/gui/wxwidgets/extrapanel.cpp
modules/gui/wxwidgets/extrapanel.hpp
modules/gui/wxwidgets/input_manager.cpp [new file with mode: 0644]
modules/gui/wxwidgets/input_manager.hpp [new file with mode: 0644]
modules/gui/wxwidgets/interface.cpp
modules/gui/wxwidgets/interface.hpp
modules/gui/wxwidgets/main_slider_manager.cpp [deleted file]
modules/gui/wxwidgets/main_slider_manager.hpp [deleted file]
modules/gui/wxwidgets/slider_manager.cpp [deleted file]
modules/gui/wxwidgets/slider_manager.hpp [deleted file]
modules/gui/wxwidgets/timer.cpp
modules/gui/wxwidgets/timer.hpp
modules/gui/wxwidgets/video.hpp
modules/gui/wxwidgets/wxwidgets.cpp
modules/gui/wxwidgets/wxwidgets.hpp

index 6dc68482076c3d4d4c5f805db4eed10c5678dfb3..2603d4660b176ae2493e790ac93212b5e138a3ee 100644 (file)
@@ -8,8 +8,7 @@ SOURCES_wxwidgets = \
        menus.cpp \
        timer.cpp \
        video.cpp \
-       slider_manager.cpp \
-       main_slider_manager.cpp \
+       input_manager.cpp \
        dialogs.cpp \
        dialogs/open.cpp \
        dialogs/streamout.cpp \
@@ -41,8 +40,7 @@ EXTRA_DIST += \
        extrapanel.hpp \
        timer.hpp \
        video.hpp \
-       slider_manager.hpp \
-       main_slider_manager.hpp \
+       input_manager.hpp \
        dialogs/fileinfo.hpp \
        dialogs/preferences.hpp \
        dialogs/wizard.hpp \
index c0a0ec9a93a5041832fa63012dc9b1049b1252bf..1b9d0e4cf0976445747d641936f7c16b12d0aef9 100644 (file)
@@ -2,7 +2,7 @@
  * vlm_slider_manager.cpp : Manage an input slider for a VLM stream
  *****************************************************************************
  * Copyright (C) 2000-2005 the VideoLAN team
- * $Id: timer.cpp 11981 2005-08-03 15:03:23Z xtophe $
+ * $Id$
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
  *
  * Constructor.
  *****************************************************************************/
 VLMSliderManager::VLMSliderManager( intf_thread_t *_p_intf,
-                                    VLMBroadcastStreamPanel *_p_sp ) :
-        SliderManager( _p_intf )
+                                    VLMBroadcastStreamPanel *_p_sp )
 {
+    p_intf = _p_intf;
+    p_input = NULL;
+
     p_sp = _p_sp;
-    _slider = p_sp->p_slider;
+    slider = p_sp->p_slider;
 
     b_slider_free = VLC_TRUE;
     time_string = wxU( "0:00:00 / 0:00:00");
@@ -47,9 +49,75 @@ VLMSliderManager::~VLMSliderManager()
 }
 
 /*****************************************************************************
- * Private methods.
+ * Public methods.
  *****************************************************************************/
+void VLMSliderManager::Update()
+{
+    /* Update the input */
+    if( p_input == NULL )
+    {
+        UpdateInput();
+
+        if( p_input )
+        {
+            slider->SetValue( 0 );
+            UpdateButtons( VLC_TRUE );
+        }
+    }
+    else if( p_input->b_dead )
+    {
+        HideSlider();
+        UpdateButtons( VLC_FALSE );
+
+        vlc_object_release( p_input );
+        p_input = NULL;
+    }
 
+    if( p_input && !p_input->b_die )
+    {
+        vlc_value_t pos;
+
+        /* Really manage the slider */
+        var_Get( p_input, "position", &pos );
+
+        if( pos.f_float > 0.0 && ! IsShown() ) ShowSlider();
+        else if( pos.f_float <= 0.0 ) HideSlider();
+
+        if( IsPlaying() && IsShown() )
+        {
+            /* Update the slider if the user isn't dragging it. */
+            if( IsFree() )
+            {
+                char psz_time[ MSTRTIME_MAX_SIZE ];
+                char psz_total[ MSTRTIME_MAX_SIZE ];
+                vlc_value_t time;
+                mtime_t i_seconds;
+
+                /* Update the value */
+                if( pos.f_float >= 0.0 )
+                {
+                    i_slider_pos = (int)(SLIDER_MAX_POS * pos.f_float);
+
+                    slider->SetValue( i_slider_pos );
+
+                    var_Get( p_input, "time", &time );
+                    i_seconds = time.i_time / 1000000;
+                    secstotimestr ( psz_time, i_seconds );
+
+                    var_Get( p_input, "length",  &time );
+                    i_seconds = time.i_time / 1000000;
+                    secstotimestr ( psz_total, i_seconds );
+
+                    UpdateTime( psz_time, psz_total );
+                }
+            }
+        }
+    }
+}
+
+/*****************************************************************************
+ * Private methods.
+ *****************************************************************************/
 void VLMSliderManager::UpdateInput()
 {
     if( p_sp->GetStream()->p_media->i_instance == 0 )
@@ -75,18 +143,18 @@ void VLMSliderManager::UpdateButtons( vlc_bool_t b_play )
 
 vlc_bool_t VLMSliderManager::IsShown()
 {
-    return _slider->IsEnabled();
+    return slider->IsEnabled();
 }
 
 void VLMSliderManager::ShowSlider()
 {
-    _slider->Enable();
+    slider->Enable();
 }
 
 void VLMSliderManager::HideSlider()
 {
-    _slider->SetValue( 0 );
-    _slider->Disable();
+    slider->SetValue( 0 );
+    slider->Disable();
     UpdateTime( "0:00:00", "0:00:00" );
 }
 
index 4ec06712932f51e584a5db243103c5c0987af747..facc51249bfc11d8b383c4a78306b84e327f6ab0 100644 (file)
@@ -2,7 +2,7 @@
  * vlm_slider_manager.hpp: Header for slider_manager
  *****************************************************************************
  * Copyright (C) 1999-2005 the VideoLAN team
- * $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $
+ * $Id$
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
  *
@@ -24,7 +24,7 @@
 #ifndef _VLM_SLIDER_MANAGER_H_
 #define _VLM_SLIDER_MANAGER_H_
 
-#include "slider_manager.hpp"
+#include "wxwidgets.hpp"
 
 namespace wxvlc
 {
@@ -32,7 +32,7 @@ namespace wxvlc
     /**
      * This class manages a slider corresponding to the main input
      */
-    class VLMSliderManager: public SliderManager
+    class VLMSliderManager
     {
     public:
         VLMSliderManager( intf_thread_t *, VLMBroadcastStreamPanel * );
@@ -40,6 +40,7 @@ namespace wxvlc
 
         wxString time_string;
 
+        void Update();
         void ProcessUpdate( wxScrollEvent & );
 
     protected:
@@ -56,6 +57,11 @@ namespace wxvlc
         virtual void ShowSlider();
 
         VLMBroadcastStreamPanel * p_sp;
+
+        intf_thread_t * p_intf;
+        input_thread_t *p_input;
+        wxSlider *slider;            ///< Slider for this input
+        int i_slider_pos;            ///< Current slider position
     };
 };
 
index 100239a4999aa0e1ce17b6493166674f44637838..fe3c690e8f056dbb53e2733c87684ed55d5f7615 100644 (file)
@@ -150,7 +150,6 @@ static const struct filter vfilters[] =
     { "clone", N_("Image clone"), N_("Creates several clones of the image") },
     { "distort", N_("Distortion"), N_("Adds distorsion effects") },
     { "invert", N_("Image inversion") , N_("Inverts the image colors") },
-    { "crop", N_("Image cropping"), N_("Crops the image") },
     { "motionblur", N_("Blurring"), N_("Creates a motion blurring on the image") },
     { "transform",  N_("Transformation"), N_("Rotates or flips the image") },
     { "magnify",  N_("Magnify"), N_("Magnifies part of the image") },
@@ -311,7 +310,7 @@ wxPanel *ExtraPanel::VideoPanel( wxWindow *parent )
     {
         wxCheckBox *box = new wxCheckBox( panel, Filter0_Event + i,
                                           wxU( _( vfilters[i].psz_name ) ) );
-        t_col_sizer->Add( box, 0, wxALL, 4 );
+        t_col_sizer->Add( box, 0, wxALL, 2 );
         box->SetToolTip( wxU( _( vfilters[i].psz_help ) ) );
     }
 
@@ -1215,13 +1214,11 @@ ExtraWindow::ExtraWindow( intf_thread_t *_p_intf, wxWindow *p_parent,
        wxFrame( p_parent, -1, wxU(_("Extended controls")), wxDefaultPosition,
                  wxDefaultSize, wxDEFAULT_FRAME_STYLE )
 {
-        fprintf(stderr,"Creating extrawindow\n");
     p_intf = _p_intf;
     SetIcon( *p_intf->p_sys->p_icon );
 
     wxBoxSizer *window_sizer = new wxBoxSizer( wxVERTICAL );
     SetSizer( window_sizer );
-//    panel = new ExtraPanel(  p_intf, this );//_extra_panel;
 
     panel = _extra_panel;
     window_sizer->Add( panel );
index 416c07ee5ef68d18fa8f34edb684e2be871046a2..bd7360d146fdb547e8def4c35ae0787c39193b4d 100644 (file)
@@ -2,7 +2,7 @@
  * extrapanel.hpp: Headers for the extra panel window
  *****************************************************************************
  * Copyright (C) 1999-2005 the VideoLAN team
- * $Id: wxwidgets.h 12670 2005-09-25 11:16:31Z zorglub $
+ * $Id$
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
  *
diff --git a/modules/gui/wxwidgets/input_manager.cpp b/modules/gui/wxwidgets/input_manager.cpp
new file mode 100644 (file)
index 0000000..5cc094c
--- /dev/null
@@ -0,0 +1,441 @@
+/*****************************************************************************
+ * slider_manager.cpp : Manage an input slider
+ *****************************************************************************
+ * Copyright (C) 2000-2005 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Gildas Bazin <gbazin@videolan.org>
+ *          Clément Stenac <zorglub@videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#include "input_manager.hpp"
+#include "interface.hpp"
+#include "video.hpp"
+
+#include <vlc_meta.h>
+
+/* include the toolbar graphics */
+#include "bitmaps/prev.xpm"
+#include "bitmaps/next.xpm"
+#include "bitmaps/playlist.xpm"
+
+/* IDs for the controls */
+enum
+{
+    SliderScroll_Event = wxID_HIGHEST,
+
+    DiscMenu_Event,
+    DiscPrev_Event,
+    DiscNext_Event
+};
+
+BEGIN_EVENT_TABLE(InputManager, wxPanel)
+    /* Slider events */
+    EVT_COMMAND_SCROLL(SliderScroll_Event, InputManager::OnSliderUpdate)
+
+    /* Disc Buttons events */
+    EVT_BUTTON(DiscMenu_Event, InputManager::OnDiscMenu)
+    EVT_BUTTON(DiscPrev_Event, InputManager::OnDiscPrev)
+    EVT_BUTTON(DiscNext_Event, InputManager::OnDiscNext)
+
+END_EVENT_TABLE()
+
+#define STATUS_STOP 0
+#define STATUS_PLAYING 1
+#define STATUS_PAUSE 2
+
+/*****************************************************************************
+ * Constructor.
+ *****************************************************************************/
+InputManager::InputManager( intf_thread_t *_p_intf, Interface *_p_main_intf,
+                            wxWindow *p_parent )
+  : wxPanel( p_parent )
+{
+    p_intf = _p_intf;
+    p_main_intf = _p_main_intf;
+    p_input = NULL;
+    i_old_playing_status = STATUS_STOP;
+    i_old_rate = INPUT_RATE_DEFAULT;
+    b_slider_free = VLC_TRUE;
+
+    /* Create slider */
+    slider = new wxSlider( this, SliderScroll_Event, 0, 0, SLIDER_MAX_POS );
+
+    /* Create disc buttons */
+    disc_frame = new wxPanel( this );
+
+    disc_menu_button = new wxBitmapButton( disc_frame, DiscMenu_Event,
+                                           wxBitmap( playlist_xpm ) );
+    disc_prev_button = new wxBitmapButton( disc_frame, DiscPrev_Event,
+                                           wxBitmap( prev_xpm ) );
+    disc_next_button = new wxBitmapButton( disc_frame, DiscNext_Event,
+                                           wxBitmap( next_xpm ) );
+
+    disc_sizer = new wxBoxSizer( wxHORIZONTAL );
+    disc_sizer->Add( disc_menu_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
+    disc_sizer->Add( disc_prev_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
+    disc_sizer->Add( disc_next_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
+    disc_frame->SetSizer( disc_sizer );
+    disc_sizer->Layout();
+
+    /* Add everything to the panel */
+    sizer = new wxBoxSizer( wxHORIZONTAL );
+    SetSizer( sizer );
+    sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
+    sizer->Add( disc_frame, 0, wxALL, 2 );
+
+    /* Hide by default */
+    sizer->Hide( disc_frame );
+    sizer->Hide( slider );
+
+    sizer->Layout();
+    Fit();
+}
+
+InputManager::~InputManager()
+{
+    vlc_mutex_lock( &p_intf->change_lock );
+    if( p_intf->p_sys->p_input ) vlc_object_release( p_intf->p_sys->p_input );
+    p_intf->p_sys->p_input = NULL;
+    vlc_mutex_unlock( &p_intf->change_lock );
+}
+
+/*****************************************************************************
+ * Public methods.
+ *****************************************************************************/
+vlc_bool_t InputManager::IsPlaying()
+{
+    return (p_input && !p_input->b_die);
+}
+
+/*****************************************************************************
+ * Private methods.
+ *****************************************************************************/
+void InputManager::UpdateInput()
+{
+    playlist_t *p_playlist =
+        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                       FIND_ANYWHERE );
+    if( p_playlist != NULL )
+    {
+        LockPlaylist( p_intf->p_sys, p_playlist );
+        p_input = p_intf->p_sys->p_input = p_playlist->p_input;
+        if( p_intf->p_sys->p_input )
+             vlc_object_yield( p_intf->p_sys->p_input );
+        UnlockPlaylist( p_intf->p_sys, p_playlist );
+        vlc_object_release( p_playlist );
+    }
+}
+
+void InputManager::UpdateNowPlaying()
+{
+    char *psz_now_playing = vlc_input_item_GetInfo( p_input->input.p_item,
+                _("Meta-information"), _(VLC_META_NOW_PLAYING) );
+    if( psz_now_playing && *psz_now_playing )
+    {
+        p_main_intf->statusbar->SetStatusText(
+                    wxString(wxU(psz_now_playing)) + wxT( " - " ) +
+                    wxU(p_input->input.p_item->psz_name), 2 );
+    }
+    else
+    {
+        p_main_intf->statusbar->SetStatusText(
+                   wxU(p_input->input.p_item->psz_name), 2 );
+    }
+    free( psz_now_playing );
+}
+
+void InputManager::UpdateButtons( vlc_bool_t b_play )
+{
+    if( !b_play )
+    {
+        if( i_old_playing_status == STATUS_STOP ) return;
+
+        i_old_playing_status = STATUS_STOP;
+        p_main_intf->TogglePlayButton( PAUSE_S );
+        p_main_intf->statusbar->SetStatusText( wxT(""), 0 );
+        p_main_intf->statusbar->SetStatusText( wxT(""), 2 );
+
+#ifdef wxHAS_TASK_BAR_ICON
+        if( p_main_intf->p_systray )
+        {
+            p_main_intf->p_systray->UpdateTooltip(
+                wxString(wxT("VLC media player - ")) + wxU(_("Stopped")) );
+        }
+#endif
+
+        return;
+    }
+
+    /* Manage Playing status */
+    vlc_value_t val;
+    var_Get( p_input, "state", &val );
+    val.i_int = val.i_int == PAUSE_S ? STATUS_PAUSE : STATUS_PLAYING;
+    if( i_old_playing_status != val.i_int )
+    {
+        i_old_playing_status = val.i_int;
+        p_main_intf->TogglePlayButton( val.i_int == STATUS_PAUSE ?
+                                       PAUSE_S : PLAYING_S );
+
+#ifdef wxHAS_TASK_BAR_ICON
+        if( p_main_intf->p_systray )
+        {
+            p_main_intf->p_systray->UpdateTooltip(
+                wxU(p_input->input.p_item->psz_name) + wxString(wxT(" - ")) +
+                (val.i_int == PAUSE_S ? wxU(_("Paused")) : wxU(_("Playing"))));
+        }
+#endif
+    }
+}
+
+void InputManager::UpdateDiscButtons()
+{
+    vlc_value_t val;
+    var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
+    if( val.i_int > 0 && !disc_frame->IsShown() )
+    {
+        vlc_value_t val;
+
+        #define HELP_MENU N_("Menu")
+        #define HELP_PCH N_("Previous chapter")
+        #define HELP_NCH N_("Next chapter")
+        #define HELP_PTR N_("Previous track")
+        #define HELP_NTR N_("Next track")
+
+        var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
+
+        if( val.i_int > 0 )
+        {
+            disc_menu_button->Show();
+            disc_sizer->Show( disc_menu_button );
+            disc_sizer->Layout();
+            disc_sizer->Fit( disc_frame );
+            disc_menu_button->SetToolTip( wxU(_( HELP_MENU ) ) );
+            disc_prev_button->SetToolTip( wxU(_( HELP_PCH ) ) );
+            disc_next_button->SetToolTip( wxU(_( HELP_NCH ) ) );
+        }
+        else
+        {
+            disc_menu_button->Hide();
+            disc_sizer->Hide( disc_menu_button );
+            disc_prev_button->SetToolTip( wxU(_( HELP_PTR ) ) );
+            disc_next_button->SetToolTip( wxU(_( HELP_NTR ) ) );
+        }
+
+        ShowDiscFrame();
+    }
+    else if( val.i_int == 0 && disc_frame->IsShown() )
+    {
+        HideDiscFrame();
+    }
+}
+
+void InputManager::HideSlider()
+{
+    ShowSlider( false );
+}
+
+void InputManager::HideDiscFrame()
+{
+    ShowDiscFrame( false );
+}
+
+void InputManager::UpdateTime()
+{
+    char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
+    mtime_t i_seconds;
+
+    i_seconds = var_GetTime( p_intf->p_sys->p_input, "length" ) / 1000000;
+    secstotimestr( psz_total, i_seconds );
+
+    i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) / 1000000;
+    secstotimestr( psz_time, i_seconds );
+
+    p_main_intf->statusbar->SetStatusText(
+        wxU(psz_time) + wxString(wxT(" / ")) +wxU(psz_total), 0 );
+}
+
+void InputManager::Update()
+{
+    /* Update the input */
+    if( p_input == NULL )
+    {
+        UpdateInput();
+
+        if( p_input )
+        {
+            slider->SetValue( 0 );
+        }
+        else
+        {
+            if( disc_frame->IsShown() ) HideDiscFrame();
+            if( slider->IsShown() ) HideSlider();
+        }
+    }
+    else if( p_input->b_dead )
+    {
+        UpdateButtons( VLC_FALSE );
+        vlc_object_release( p_input );
+        p_input = NULL;
+    }
+
+    if( p_input && !p_input->b_die )
+    {
+        vlc_value_t pos, len;
+
+        UpdateTime();
+        UpdateButtons( VLC_TRUE );
+        UpdateNowPlaying();
+        UpdateDiscButtons();
+
+        /* Really manage the slider */
+        var_Get( p_input, "position", &pos );
+        var_Get( p_input, "length", &len );
+
+        if( len.i_time > 0 && pos.f_float >= 0 &&
+            !slider->IsShown() ) ShowSlider();
+        else if( len.i_time < 0 && pos.f_float <= 0 &&
+                 slider->IsShown() ) HideSlider();
+
+        /* Update the slider if the user isn't dragging it. */
+        if( slider->IsShown() && b_slider_free )
+        {
+            i_slider_pos = (int)(SLIDER_MAX_POS * pos.f_float);
+            slider->SetValue( i_slider_pos );
+        }
+
+        /* Manage Speed status */
+        vlc_value_t val;
+        var_Get( p_input, "rate", &val );
+        if( i_old_rate != val.i_int )
+        {
+            p_main_intf->statusbar->SetStatusText(
+                wxString::Format(wxT("x%.2f"),
+                (float)INPUT_RATE_DEFAULT / val.i_int ), 1 );
+            i_old_rate = val.i_int;
+        }
+    }
+}
+
+/*****************************************************************************
+ * Event Handlers.
+ *****************************************************************************/
+void InputManager::OnDiscMenu( wxCommandEvent& WXUNUSED(event) )
+{
+    input_thread_t *p_input =
+        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                           FIND_ANYWHERE );
+    if( p_input )
+    {
+        vlc_value_t val; val.i_int = 2;
+
+        var_Set( p_input, "title  0", val);
+        vlc_object_release( p_input );
+    }
+}
+
+void InputManager::OnDiscPrev( wxCommandEvent& WXUNUSED(event) )
+{
+    input_thread_t *p_input =
+        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                           FIND_ANYWHERE );
+    if( p_input )
+    {
+        int i_type = var_Type( p_input, "prev-chapter" );
+        vlc_value_t val; val.b_bool = VLC_TRUE;
+
+        var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
+                 "prev-chapter" : "prev-title", val );
+
+        vlc_object_release( p_input );
+    }
+}
+
+void InputManager::OnDiscNext( wxCommandEvent& WXUNUSED(event) )
+{
+    input_thread_t *p_input =
+        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
+                                           FIND_ANYWHERE );
+    if( p_input )
+    {
+        int i_type = var_Type( p_input, "next-chapter" );
+        vlc_value_t val; val.b_bool = VLC_TRUE;
+
+        var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
+                 "next-chapter" : "next-title", val );
+
+        vlc_object_release( p_input );
+    }
+}
+
+void InputManager::OnSliderUpdate( wxScrollEvent& event )
+{
+    vlc_mutex_lock( &p_intf->change_lock );
+
+#ifdef WIN32
+    if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
+        || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
+    {
+#endif
+        if( i_slider_pos != event.GetPosition() && p_intf->p_sys->p_input )
+        {
+            vlc_value_t pos;
+            pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
+            var_Set( p_intf->p_sys->p_input, "position", pos );
+        }
+
+#ifdef WIN32
+        b_slider_free = VLC_TRUE;
+    }
+    else
+    {
+        b_slider_free = VLC_FALSE;
+        if( p_intf->p_sys->p_input ) UpdateTime();
+    }
+#endif
+
+#undef WIN32
+    vlc_mutex_unlock( &p_intf->change_lock );
+}
+
+void InputManager::ShowSlider( bool show )
+{
+    if( !!show == !!slider->IsShown() ) return;
+
+    if( p_intf->p_sys->b_video_autosize )
+        UpdateVideoWindow( p_intf, p_main_intf->video_window );
+
+    sizer->Show( slider, show );
+    sizer->Layout();
+
+    wxCommandEvent intf_event( wxEVT_INTF, 0 );
+    p_main_intf->AddPendingEvent( intf_event );
+}
+
+void InputManager::ShowDiscFrame( bool show )
+{
+    if( !!show == !!disc_frame->IsShown() ) return;
+
+    if( p_intf->p_sys->b_video_autosize )
+        UpdateVideoWindow( p_intf, p_main_intf->video_window );
+
+    sizer->Show( disc_frame, show );
+    sizer->Layout();
+
+    wxCommandEvent intf_event( wxEVT_INTF, 0 );
+    p_main_intf->AddPendingEvent( intf_event );
+}
diff --git a/modules/gui/wxwidgets/input_manager.hpp b/modules/gui/wxwidgets/input_manager.hpp
new file mode 100644 (file)
index 0000000..3206d23
--- /dev/null
@@ -0,0 +1,90 @@
+/*****************************************************************************
+ * input_manager.hpp: Header for input_manager
+ *****************************************************************************
+ * Copyright (C) 1999-2005 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Gildas Bazin <gbazin@videolan.org>
+ *          Clément Stenac <zorglub@videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#ifndef _INPUT_MANAGER_H_
+#define _INPUT_MANAGER_H_
+
+#include "wxwidgets.hpp"
+
+namespace wxvlc
+{
+    class Interface;
+
+    /**
+     * This class manages all the controls related to the input
+     */
+    class InputManager : public wxPanel
+    {
+    public:
+        InputManager( intf_thread_t *, Interface *, wxWindow * );
+        virtual ~InputManager();
+
+        void Update();
+        vlc_bool_t IsPlaying();
+
+    protected:
+        void UpdateInput();
+        void UpdateNowPlaying();
+        void UpdateButtons( vlc_bool_t );
+        void UpdateDiscButtons();
+        void UpdateTime();
+
+        void HideSlider();
+        void ShowSlider( bool show = true );
+
+        void OnSliderUpdate( wxScrollEvent& event );
+
+        void OnDiscMenu( wxCommandEvent& event );
+        void OnDiscPrev( wxCommandEvent& event );
+        void OnDiscNext( wxCommandEvent& event );
+
+        void HideDiscFrame();
+        void ShowDiscFrame( bool show = true );
+
+        wxPanel         *disc_frame;
+        wxBoxSizer      *disc_sizer;
+        wxBitmapButton  *disc_menu_button;
+        wxBitmapButton  *disc_prev_button;
+        wxBitmapButton  *disc_next_button;
+
+        intf_thread_t * p_intf;
+        input_thread_t *p_input;
+        Interface * p_main_intf;
+
+        wxSlider *slider;            ///< Slider for this input
+        int i_slider_pos;            ///< Current slider position
+        vlc_bool_t b_slider_free;    ///< Slider status
+
+        wxBoxSizer *sizer;
+
+    private:
+        DECLARE_EVENT_TABLE();
+
+        int i_old_playing_status;    ///< Previous playing status
+        int i_old_rate;              ///< Previous playing rate
+
+    };
+};
+
+#endif
index 805843b9e7e31860bdf558b94e7366b930a3dee0..db8bf469f1616d767d947475b5a4b0c4f4eab75c 100644 (file)
@@ -102,7 +102,7 @@ public:
 };
 
 BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
-   EVT_PAINT(VLCVolCtrl::OnPaint)
+    EVT_PAINT(VLCVolCtrl::OnPaint)
 
     /* Mouse events */
     EVT_LEFT_UP(VLCVolCtrl::OnChange)
@@ -139,11 +139,9 @@ enum
 
     Prefs_Event,
     Extended_Event,
-//    Undock_Event,
     Bookmarks_Event,
     Skins_Event,
 
-    SliderScroll_Event,
     StopStream_Event,
     PlayStream_Event,
     PrevStream_Event,
@@ -151,10 +149,6 @@ enum
     SlowStream_Event,
     FastStream_Event,
 
-    DiscMenu_Event,
-    DiscPrev_Event,
-    DiscNext_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
      * (where it is special and put into the "Apple" menu) */
@@ -180,7 +174,6 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU_OPEN(Interface::OnMenuOpen)
 
     EVT_MENU( Extended_Event, Interface::OnExtended )
-//    EVT_MENU( Undock_Event, Interface::OnUndock )
 
     EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
 
@@ -206,20 +199,9 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
     EVT_MENU(FastStream_Event, Interface::OnFastStream)
 
-    /* Disc Buttons events */
-    EVT_BUTTON(DiscMenu_Event, Interface::OnDiscMenu)
-    EVT_BUTTON(DiscPrev_Event, Interface::OnDiscPrev)
-    EVT_BUTTON(DiscNext_Event, Interface::OnDiscNext)
-
-    /* Slider events */
-    EVT_COMMAND_SCROLL(SliderScroll_Event, Interface::OnSliderUpdate)
-
     /* Custom events */
     EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)
     EVT_COMMAND(1, wxEVT_INTF, Interface::OnControlEvent)
-
-    EVT_TIMER(ID_CONTROLS_TIMER, Interface::OnControlsTimer)
-    EVT_TIMER(ID_SLIDER_TIMER, Interface::OnSliderTimer)
 END_EVENT_TABLE()
 
 /*****************************************************************************
@@ -231,43 +213,36 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
 {
     /* Initializations */
     p_intf = _p_intf;
-    i_old_playing_status = PAUSE_S;
     b_extra = VLC_FALSE;
-//    b_undock = VLC_FALSE;
-
-
-    extra_window = NULL;
+    extra_frame = 0;
 
     /* Give our interface a nice little icon */
     SetIcon( wxIcon( vlc_xpm ) );
 
-    /* Create a sizer for the main frame */
-    frame_sizer = new wxBoxSizer( wxVERTICAL );
-    SetSizer( frame_sizer );
+    /* Create a main panel that will fill in the interface window */
+    main_sizer = new wxBoxSizer( wxVERTICAL );
+    SetSizer( main_sizer );
+    main_panel = new wxPanel( this );
+    main_sizer->Add( main_panel, 1, wxEXPAND );
+    main_panel->SetFocus();
 
-    /* Create a dummy widget that can get the keyboard focus */
-    wxWindow *p_dummy = new wxWindow( this, 0, wxDefaultPosition,
-                                      wxSize(0,0) );
 #if defined(__WXGTK20__) && wxCHECK_VERSION(2,5,6)
     /* As ugly as your butt! Please remove when wxWidgets 2.6 fixed their
      * Accelerators bug. */
-    p_dummy->m_imData = 0;
+    main_panel->m_imData = 0;
     m_imData = 0;
 #endif
-    p_dummy->SetFocus();
-    frame_sizer->Add( p_dummy, 0, 0 );
+
+    /* Create a sizer for the main frame */
+    panel_sizer = new wxBoxSizer( wxVERTICAL );
+    main_panel->SetSizer( panel_sizer );
 
 #ifdef wxHAS_TASK_BAR_ICON
     /* Systray integration */
     p_systray = NULL;
-    if ( config_GetInt( p_intf, "wx-systray" ) )
+    if( config_GetInt( p_intf, "wx-systray" ) )
     {
-        p_systray = new Systray(this, p_intf);
-        p_systray->SetIcon( wxIcon( vlc16x16_xpm ), wxT("VLC media player") );
-        if ( (! p_systray->IsOk()) || (! p_systray->IsIconInstalled()) )
-        {
-            msg_Warn(p_intf, "Cannot set systray icon, weird things may happen");
-        }
+        p_systray = new Systray( this, p_intf );
     }
 #endif
 
@@ -277,11 +252,6 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
     /* Creation of the tool bar */
     CreateOurToolBar();
 
-    /* Create the extra panel */
-    extra_frame = new ExtraPanel( p_intf, this );
-    frame_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
-    frame_sizer->Hide( extra_frame );
-
     /* Creation of the status bar
      * Helptext for menu items and toolbar tools will automatically get
      * displayed here. */
@@ -294,21 +264,19 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
     video_window = 0;
     if( config_GetInt( p_intf, "wx-embed" ) )
     {
-        video_window = CreateVideoWindow( p_intf, this );
-        frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND, 0 );
+        video_window = CreateVideoWindow( p_intf, main_panel );
+        panel_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND, 0 );
     }
 
-    /* Creation of the slider sub-window */
-    CreateOurSlider();
-    frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 );
-    frame_sizer->Hide( slider_frame );
-
-    /* Make sure we've got the right background colour */
-    SetBackgroundColour( slider_frame->GetBackgroundColour() );
+    /* Creation of the input manager panel */
+    input_manager = new InputManager( p_intf, this, main_panel );
+    panel_sizer->Add( input_manager, 0, wxEXPAND , 0 );
 
     /* Layout everything */
-    frame_sizer->Layout();
-    frame_sizer->Fit(this);
+    panel_sizer->Layout();
+    panel_sizer->Fit( main_panel );
+    main_sizer->Layout();
+    main_sizer->Fit( this );
 
 #if wxUSE_DRAG_AND_DROP
     /* Associate drop targets with the main interface */
@@ -317,60 +285,31 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
 
     SetupHotkeys();
 
-    m_controls_timer.SetOwner(this, ID_CONTROLS_TIMER);
-    m_slider_timer.SetOwner(this, ID_SLIDER_TIMER);
-
     /* Start timer */
     timer = new Timer( p_intf, this );
 
-    /* */
+    /* Restore previous position / settings */
     WindowSettings *ws = p_intf->p_sys->p_window_settings;
     wxPoint p;
-    wxSize  s;
-    bool    b_shown;
+    wxSize s;
+    bool b_shown;
 
     ws->SetScreen( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ),
                    wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) );
 
-    if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) )
-        Move( p );
+    if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) ) Move( p );
 
-    /* Set minimum window size to prevent user from glitching it */
-    wxSize  s2;
+    /* Get minimum window size to prevent user from glitching it */
     s = GetSize();
-
-    /* save smallest possible default minimum size */
-    default_size = GetSize();
-
-    /* save slider size for height only for MinSizing */
-    slider_size = slider_sizer->GetSize();
-
-    /* and save extended gui size for MinSize scheme */
-    s2 = extra_frame->GetSize();
-    s2.SetWidth( s2.GetWidth() +
-                2 * wxSystemSettings::GetMetric( wxSYS_FRAMESIZE_X ) );
-    extended_size = s2;
-
-    /* Set initial minimum window size */
-    if( config_GetInt( p_intf, "wx-embed" ) )
-    {
-        s2 = video_window->GetSize();
-        s.SetHeight( s.GetHeight() - s2.GetHeight() );
-    }
-    if( config_GetInt( p_intf, "wx-extended" ) )
-    {
-        s.SetWidth( extended_size.GetWidth() );
-        s.SetHeight( s.GetHeight() + extended_size.GetHeight() );
-    }
-#if (wxCHECK_VERSION(2,5,4))
-    SetMinSize( s );
-#else
-    frame_sizer->SetMinSize( s );
-#endif
+    if( video_window && video_window->IsShown() )
+        s.SetHeight( s.GetHeight() - video_window->GetSize().GetHeight() );
+    main_min_size = s;
 
     /* Show extended GUI if requested */
-    if( ( b_extra = config_GetInt( p_intf, "wx-extended" ) ) )
-        frame_sizer->Show( extra_frame );
+    wxCommandEvent dummy;
+    if( config_GetInt( p_intf, "wx-extended" ) ) OnExtended( dummy );
+
+    SetIntfMinSize();
 }
 
 Interface::~Interface()
@@ -414,12 +353,10 @@ void Interface::OnControlEvent( wxCommandEvent& event )
     switch( event.GetId() )
     {
     case 0:
+        if( p_intf->p_sys->b_video_autosize )
         {
-          if( p_intf->p_sys->b_video_autosize )
-          {
-        frame_sizer->Layout();
-        frame_sizer->Fit(this);
-          }
+            main_sizer->Layout();
+            main_sizer->Fit(this);
         }
         break;
 
@@ -536,7 +473,7 @@ void Interface::CreateOurMenuBar()
 #endif
 /* End patch by zcot */
 
-    frame_sizer->SetMinSize( i_size, -1 );
+    panel_sizer->SetMinSize( i_size, -1 );
 
     /* Intercept all menu events in our custom event handler */
     PushEventHandler( new MenuEvtHandler( p_intf, this ) );
@@ -618,53 +555,6 @@ void Interface::CreateOurToolBar()
 #endif
 }
 
-void Interface::CreateOurSlider()
-{
-    /* Create a new frame and sizer containing the slider */
-    slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
-    slider_frame->SetAutoLayout( TRUE );
-    slider_sizer = new wxBoxSizer( wxHORIZONTAL );
-    //slider_sizer->SetMinSize( -1, 50 );
-
-    /* Create slider */
-    slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
-                           SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
-
-    /* Add Disc Buttons */
-    disc_frame = new wxPanel( slider_frame, -1, wxDefaultPosition,
-                              wxDefaultSize );
-    disc_frame->SetAutoLayout( TRUE );
-    disc_sizer = new wxBoxSizer( wxHORIZONTAL );
-
-    disc_menu_button = new wxBitmapButton( disc_frame, DiscMenu_Event,
-                                           wxBitmap( playlist_xpm ) );
-    disc_prev_button = new wxBitmapButton( disc_frame, DiscPrev_Event,
-                                           wxBitmap( prev_xpm ) );
-    disc_next_button = new wxBitmapButton( disc_frame, DiscNext_Event,
-                                           wxBitmap( next_xpm ) );
-
-    disc_sizer->Add( disc_menu_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
-    disc_sizer->Add( disc_prev_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
-    disc_sizer->Add( disc_next_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 1 );
-
-    disc_frame->SetSizer( disc_sizer );
-    disc_sizer->Layout();
-
-    /* Add everything to the frame */
-    slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
-    slider_sizer->Add( disc_frame, 0, wxALL, 2 );
-    slider_frame->SetSizer( slider_sizer );
-
-    disc_frame->Hide();
-    slider_sizer->Hide( disc_frame );
-
-    slider_sizer->Layout();
-    slider_sizer->Fit( slider_frame );
-
-    /* Hide the slider by default */
-    slider_frame->Hide();
-}
-
 static int ConvertHotkeyModifiers( int i_hotkey )
 {
     int i_accel_flags = 0;
@@ -758,118 +648,27 @@ void Interface::SetupHotkeys()
     delete [] p_entries;
 }
 
-void Interface::HideSlider( bool layout )
+void Interface::SetIntfMinSize()
 {
-    ShowSlider( false, layout );
-}
+    wxSize ms = main_min_size;
 
-void Interface::ShowSlider( bool show, bool layout )
-{
-    if( show )
+    if( extra_frame && extra_frame->IsShown() )
     {
-        //prevent the hide timers from hiding it now
-        m_slider_timer.Stop();
-        m_controls_timer.Stop();
-
-        //prevent continuous layout
-        if( slider_frame->IsShown() ) return;
-        
-        wxSize ms = GetMinSize();
-        ms.SetHeight( ms.GetHeight() + slider_size.GetHeight() );
-#if ( wxCHECK_VERSION( 2,5,4 ) )
-        SetMinSize( ms );
-#else
-        frame_sizer->SetMinSize( ms );
-#endif
+        ms.SetHeight( ms.GetHeight() + ext_min_size.GetHeight() );
+        if( ext_min_size.GetWidth() > ms.GetWidth() )
+            ms.SetWidth( ext_min_size.GetWidth() );
     }
-    else
-    {
-        //prevent continuous layout
-        if( !slider_frame->IsShown() ) return;
-        
-        wxSize ms = GetMinSize();
-        ms.SetHeight( ms.GetHeight() - slider_size.GetHeight() );
+
 #if ( wxCHECK_VERSION( 2,5,4 ) )
-        SetMinSize( ms );
+    SetMinSize( ms );
 #else
-        frame_sizer->SetMinSize( ms );
+    main_sizer->SetMinSize( ms );
 #endif
-    }
-
-    if( layout && p_intf->p_sys->b_video_autosize )
-        UpdateVideoWindow( p_intf, video_window );
-
-    slider_frame->Show( show );
-    frame_sizer->Show( slider_frame, show );
-
-    if( layout )
-    {
-        frame_sizer->Layout();
-        if( p_intf->p_sys->b_video_autosize ) frame_sizer->Fit( this );
-    }
-}
-
-void Interface::HideDiscFrame( bool layout )
-{
-    ShowDiscFrame( false, layout );
-}
-
-void Interface::ShowDiscFrame( bool show, bool layout )
-{
-    if( show )
-    {
-        //prevent the hide timer from hiding it now
-        m_controls_timer.Stop();
-
-        //prevent continuous layout
-        if( disc_frame->IsShown() ) return;
-    }
-    else
-    {
-        //prevent continuous layout
-        if( !disc_frame->IsShown() ) return;
-    }
-
-    if( layout && p_intf->p_sys->b_video_autosize )
-        UpdateVideoWindow( p_intf, video_window );
-
-    disc_frame->Show( show );
-    slider_sizer->Show( disc_frame, show );
-
-    if( layout )
-    {
-        slider_sizer->Layout();
-        if( p_intf->p_sys->b_video_autosize )
-            slider_sizer->Fit( slider_frame );
-    }
 }
 
 /*****************************************************************************
  * Event Handlers.
  *****************************************************************************/
-void Interface::OnControlsTimer( wxTimerEvent& WXUNUSED(event) )
-{
-    if( p_intf->p_sys->b_video_autosize )
-        UpdateVideoWindow( p_intf, video_window );
-
-    /* Hide slider and Disc Buttons */
-    //postpone layout, we'll do it ourselves
-    HideDiscFrame( false );
-    HideSlider( false );
-
-    slider_sizer->Layout();
-    if( p_intf->p_sys->b_video_autosize )
-    {
-        slider_sizer->Fit( slider_frame );
-        frame_sizer->Fit( this );
-    }
-}
-
-void Interface::OnSliderTimer( wxTimerEvent& WXUNUSED(event) )
-{
-    HideSlider();
-}
-
 void Interface::OnMenuOpen( wxMenuEvent& event )
 {
 #if defined( __WXMSW__ )
@@ -884,11 +683,6 @@ void Interface::OnMenuOpen( wxMenuEvent& event )
         p_settings_menu->AppendCheckItem( Extended_Event,
             wxU(_("Extended &GUI\tCtrl-G") ) );
         if( b_extra ) p_settings_menu->Check( Extended_Event, TRUE );
-#if 0
-        p_settings_menu->AppendCheckItem( Undock_Event,
-            wxU(_("&Undock Ext. GUI") ) );
-        if( b_undock ) p_settings_menu->Check( Undock_Event, TRUE );
-#endif
         p_settings_menu->Append( Bookmarks_Event,
                                  wxU(_("&Bookmarks...\tCtrl-B") ) );
         p_settings_menu->Append( Prefs_Event,
@@ -1028,38 +822,23 @@ void Interface::OnShowDialog( wxCommandEvent& event )
     }
 }
 
-void Interface::OnExtended(wxCommandEvent& event)
+void Interface::OnExtended( wxCommandEvent& WXUNUSED(event) )
 {
-    b_extra = (b_extra == VLC_TRUE ? VLC_FALSE : VLC_TRUE );
-
-    if( b_extra == VLC_FALSE )
+    if( !extra_frame )
     {
-        extra_frame->Hide();
-        frame_sizer->Hide( extra_frame );
-        wxSize ms = GetMinSize();
-        ms.SetHeight( ms.GetHeight() - extended_size.GetHeight() );
-        ms.SetWidth( default_size.GetWidth() );
-#if ( wxCHECK_VERSION( 2,5,4 ) )
-        SetMinSize( ms );
-#else
-        frame_sizer->SetMinSize( ms );
-#endif
+        /* Create the extra panel */
+        extra_frame = new ExtraPanel( p_intf, main_panel );
+        panel_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
+        ext_min_size = extra_frame->GetBestSize();
     }
-    else
-    {
-        extra_frame->Show();
-        frame_sizer->Show( extra_frame );
-        wxSize ms = GetMinSize();
-        ms.SetHeight( ms.GetHeight() + extended_size.GetHeight() );
-        ms.SetWidth( extended_size.GetWidth() );
-#if ( wxCHECK_VERSION( 2,5,4 ) )
-        SetMinSize( ms );
-#else
-        frame_sizer->SetMinSize( ms );
-#endif
-    }
-    frame_sizer->Layout();
-    frame_sizer->Fit(this);
+
+    b_extra = !b_extra;
+
+    panel_sizer->Show( extra_frame, b_extra );
+
+    SetIntfMinSize();
+    main_sizer->Layout();
+    main_sizer->Fit( this );
 }
 
 void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
@@ -1086,13 +865,12 @@ void Interface::PlayStream()
         {
             /* No stream was playing, start one */
             playlist_Play( p_playlist );
-            TogglePlayButton( PLAYING_S );
             vlc_object_release( p_playlist );
+            input_manager->Update();
             return;
         }
 
         var_Get( p_input, "state", &state );
-
         if( state.i_int != PAUSE_S )
         {
             /* A stream is being played, pause it */
@@ -1105,9 +883,9 @@ void Interface::PlayStream()
         }
         var_Set( p_input, "state", state );
 
-        TogglePlayButton( state.i_int );
         vlc_object_release( p_input );
         vlc_object_release( p_playlist );
+        input_manager->Update();
     }
     else
     {
@@ -1132,57 +910,8 @@ void Interface::StopStream()
     }
 
     playlist_Stop( p_playlist );
-    TogglePlayButton( PAUSE_S );
     vlc_object_release( p_playlist );
-}
-
-void Interface::OnSliderUpdate( wxScrollEvent& event )
-{
-    vlc_mutex_lock( &p_intf->change_lock );
-
-#ifdef WIN32
-    if( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE
-        || event.GetEventType() == wxEVT_SCROLL_ENDSCROLL )
-    {
-#endif
-        if( p_intf->p_sys->i_slider_pos != event.GetPosition()
-            && p_intf->p_sys->p_input )
-        {
-            vlc_value_t pos;
-            pos.f_float = (float)event.GetPosition() / (float)SLIDER_MAX_POS;
-
-            var_Set( p_intf->p_sys->p_input, "position", pos );
-        }
-
-#ifdef WIN32
-        p_intf->p_sys->b_slider_free = VLC_TRUE;
-    }
-    else
-    {
-        p_intf->p_sys->b_slider_free = VLC_FALSE;
-
-        if( p_intf->p_sys->p_input )
-        {
-            /* Update stream date */
-            char psz_time[ MSTRTIME_MAX_SIZE ], psz_total[ MSTRTIME_MAX_SIZE ];
-            mtime_t i_seconds;
-
-            i_seconds = var_GetTime( p_intf->p_sys->p_input, "length" ) /
-                        I64C(1000000 );
-            secstotimestr( psz_total, i_seconds );
-
-            i_seconds = var_GetTime( p_intf->p_sys->p_input, "time" ) /
-                        I64C(1000000 );
-            secstotimestr( psz_time, i_seconds );
-
-            statusbar->SetStatusText( wxU(psz_time) + wxString(wxT(" / ") ) +
-                                      wxU(psz_total), 0 );
-        }
-    }
-#endif
-
-#undef WIN32
-    vlc_mutex_unlock( &p_intf->change_lock );
+    input_manager->Update();
 }
 
 void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
@@ -1252,9 +981,6 @@ void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
 
 void Interface::TogglePlayButton( int i_playing_status )
 {
-    if( i_playing_status == i_old_playing_status )
-        return;
-
     wxToolBarToolBase *p_tool = (wxToolBarToolBase *)
         GetToolBar()->GetToolClientData( PlayStream_Event );
     if( !p_tool ) return;
@@ -1275,56 +1001,6 @@ void Interface::TogglePlayButton( int i_playing_status )
     GetToolBar()->Realize();
     GetToolBar()->ToggleTool( PlayStream_Event, true );
     GetToolBar()->ToggleTool( PlayStream_Event, false );
-
-    i_old_playing_status = i_playing_status;
-}
-
-void Interface::OnDiscMenu( wxCommandEvent& WXUNUSED(event) )
-{
-    input_thread_t *p_input =
-        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
-                                           FIND_ANYWHERE );
-    if( p_input )
-    {
-        vlc_value_t val; val.i_int = 2;
-
-        var_Set( p_input, "title  0", val);
-        vlc_object_release( p_input );
-    }
-}
-
-void Interface::OnDiscPrev( wxCommandEvent& WXUNUSED(event) )
-{
-    input_thread_t *p_input =
-        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
-                                           FIND_ANYWHERE );
-    if( p_input )
-    {
-        int i_type = var_Type( p_input, "prev-chapter" );
-        vlc_value_t val; val.b_bool = VLC_TRUE;
-
-        var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
-                 "prev-chapter" : "prev-title", val );
-
-        vlc_object_release( p_input );
-    }
-}
-
-void Interface::OnDiscNext( wxCommandEvent& WXUNUSED(event) )
-{
-    input_thread_t *p_input =
-        (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
-                                           FIND_ANYWHERE );
-    if( p_input )
-    {
-        int i_type = var_Type( p_input, "next-chapter" );
-        vlc_value_t val; val.b_bool = VLC_TRUE;
-
-        var_Set( p_input, ( i_type & VLC_VAR_TYPE ) != 0 ?
-                 "next-chapter" : "next-title", val );
-
-        vlc_object_release( p_input );
-    }
 }
 
 #if wxUSE_DRAG_AND_DROP
@@ -1494,6 +1170,12 @@ Systray::Systray( Interface *_p_main_interface, intf_thread_t *_p_intf )
 {
     p_main_interface = _p_main_interface;
     p_intf = _p_intf;
+
+    SetIcon( wxIcon( vlc16x16_xpm ), wxT("VLC media player") );
+    if( !IsOk() || !IsIconInstalled() )
+    {
+        msg_Warn(p_intf, "cannot set systray icon, weird things may happen");
+    }
 }
 
 /* Event handlers */
index c9e0b2b790eec2c22b9f49b1605de16944d3ec7d..ca359af76a3abe51dd27aee3ecc531d78441a952 100644 (file)
@@ -2,7 +2,7 @@
  * interface.hpp: Main interface headers
  *****************************************************************************
  * Copyright (C) 1999-2005 the VideoLAN team
- * $Id: wxwidgets.h 12670 2005-09-25 11:16:31Z zorglub $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
 #define _WXVLC_INTERFACE_H_
 
 #include "wxwidgets.hpp"
+#include "input_manager.hpp"
 
 #include <wx/dnd.h>
 #include <wx/accel.h>
 #include <wx/taskbar.h>
-//#include "vlc_keys.h"
 
 
 namespace wxvlc
@@ -91,30 +91,17 @@ namespace wxvlc
         void PrevStream();
         void NextStream();
 
-        wxBoxSizer  *frame_sizer;
-        wxStatusBar *statusbar;
-
-        void HideSlider(bool layout = true);
-        void ShowSlider(bool show = true, bool layout = true);
-
-        wxSlider    *slider;
-        wxWindow    *slider_frame;
-        wxBoxSizer  *slider_sizer;
-        wxPanel     *extra_frame;
+        wxBoxSizer  *main_sizer;
 
-        void HideDiscFrame(bool layout = true);
-        void ShowDiscFrame(bool show = true, bool layout = true);
+        wxPanel     *main_panel;
+        wxBoxSizer  *panel_sizer;
 
-        wxPanel         *disc_frame;
-        wxBoxSizer      *disc_sizer;
-        wxBitmapButton  *disc_menu_button;
-        wxBitmapButton  *disc_prev_button;
-        wxBitmapButton  *disc_next_button;
+        wxStatusBar *statusbar;
 
-        wxFrame    *extra_window;
+        InputManager *input_manager;
 
-        vlc_bool_t b_extra;
-        vlc_bool_t b_undock;
+        vlc_bool_t  b_extra;
+        wxPanel     *extra_frame;
 
         wxControl  *volctrl;
 
@@ -122,21 +109,18 @@ namespace wxvlc
         Systray     *p_systray;
     #endif
 
-        wxTimer m_controls_timer;
-        wxTimer m_slider_timer;
+        wxWindow *video_window;
 
     private:
         void SetupHotkeys();
         void CreateOurMenuBar();
         void CreateOurToolBar();
         void CreateOurExtendedPanel();
-        void CreateOurSlider();
         void Open( int i_access_method );
 
-        /* Event handlers (these functions should _not_ be virtual) */
-        void OnControlsTimer(wxTimerEvent& WXUNUSED(event));
-        void OnSliderTimer(wxTimerEvent& WXUNUSED(event));
+        void SetIntfMinSize();
 
+        /* Event handlers (these functions should _not_ be virtual) */
         void OnExit( wxCommandEvent& event );
         void OnAbout( wxCommandEvent& event );
 
@@ -148,22 +132,16 @@ namespace wxvlc
         void OnOpenSat( wxCommandEvent& event );
 
         void OnExtended( wxCommandEvent& event );
-        //void OnUndock( wxCommandEvent& event );
 
         void OnBookmarks( wxCommandEvent& event );
         void OnShowDialog( wxCommandEvent& event );
         void OnPlayStream( wxCommandEvent& event );
         void OnStopStream( wxCommandEvent& event );
-        void OnSliderUpdate( wxScrollEvent& event );
         void OnPrevStream( wxCommandEvent& event );
         void OnNextStream( wxCommandEvent& event );
         void OnSlowStream( wxCommandEvent& event );
         void OnFastStream( wxCommandEvent& event );
 
-        void OnDiscMenu( wxCommandEvent& event );
-        void OnDiscPrev( wxCommandEvent& event );
-        void OnDiscNext( wxCommandEvent& event );
-
         void OnMenuOpen( wxMenuEvent& event );
 
     #if defined( __WXMSW__ ) || defined( __WXMAC__ )
@@ -178,8 +156,6 @@ namespace wxvlc
         Timer *timer;
         intf_thread_t *p_intf;
 
-        wxWindow *video_window;
-
         int i_old_playing_status;
 
         /* For auto-generated menus */
@@ -188,10 +164,9 @@ namespace wxvlc
         wxMenu *p_video_menu;
         wxMenu *p_navig_menu;
 
-        /* utility dimensions */
-        wxSize default_size;
-        wxSize extended_size;
-        wxSize slider_size;
+        /* Utility dimensions */
+        wxSize main_min_size;
+        wxSize ext_min_size;
     };
 
 
@@ -247,12 +222,10 @@ namespace wxvlc
     };
 };
 
-/// \todo Move this to class
 void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
 wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
 wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
 wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
 wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
 
-
 #endif
diff --git a/modules/gui/wxwidgets/main_slider_manager.cpp b/modules/gui/wxwidgets/main_slider_manager.cpp
deleted file mode 100644 (file)
index 27fcbec..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*****************************************************************************
- * slider_manager.cpp : Manage an input slider
- *****************************************************************************
- * Copyright (C) 2000-2005 the VideoLAN team
- * $Id: timer.cpp 11981 2005-08-03 15:03:23Z xtophe $
- *
- * Authors: Clément Stenac <zorglub@videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#include "main_slider_manager.hpp"
-#include "interface.hpp"
-
-#include <vlc_meta.h>
-
-/*****************************************************************************
- * Constructor.
- *****************************************************************************/
-MainSliderManager::MainSliderManager( intf_thread_t *_p_intf,
-                                      Interface *_p_main_intf ) :
-        SliderManager( _p_intf )
-{
-    p_main_intf = _p_main_intf;
-    _slider = p_main_intf->slider;
-}
-
-MainSliderManager::~MainSliderManager()
-{
-    vlc_mutex_lock( &p_intf->change_lock );
-    if( p_intf->p_sys->p_input ) vlc_object_release( p_intf->p_sys->p_input );
-    p_intf->p_sys->p_input = NULL;
-    vlc_mutex_unlock( &p_intf->change_lock );
-}
-
-/*****************************************************************************
- * Private methods.
- *****************************************************************************/
-
-void MainSliderManager::UpdateInput()
-{
-    playlist_t *p_playlist =
-            (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
-                                                   FIND_ANYWHERE );
-    if( p_playlist != NULL )
-    {
-        LockPlaylist( p_intf->p_sys, p_playlist );
-        p_input = p_intf->p_sys->p_input = p_playlist->p_input;
-        if( p_intf->p_sys->p_input )
-             vlc_object_yield( p_intf->p_sys->p_input );
-        UnlockPlaylist( p_intf->p_sys, p_playlist );
-        vlc_object_release( p_playlist );
-    }
-}
-
-void MainSliderManager::UpdateNowPlaying()
-{
-    char *psz_now_playing = vlc_input_item_GetInfo(
-    p_intf->p_sys->p_input->input.p_item,
-                _("Meta-information"), _(VLC_META_NOW_PLAYING) );
-    if( psz_now_playing && *psz_now_playing )
-    {
-        p_main_intf->statusbar->SetStatusText(
-                    wxString(wxU(psz_now_playing)) + wxT( " - " ) +
-                    wxU(p_intf->p_sys->p_input->input.p_item->psz_name), 2 );
-    }
-    else
-    {
-        p_main_intf->statusbar->SetStatusText(
-                   wxU(p_intf->p_sys->p_input->input.p_item->psz_name), 2 );
-    }
-    free( psz_now_playing );
-}
-
-void MainSliderManager::UpdateButtons( vlc_bool_t b_play )
-{
-    if( b_play )
-    {
-        p_main_intf->TogglePlayButton( PLAYING_S );
-#ifdef wxHAS_TASK_BAR_ICON
-        if( p_main_intf->p_systray )
-        {
-            p_main_intf->p_systray->UpdateTooltip(
-                  wxU( p_intf->p_sys->p_input->input.p_item->psz_name ) +
-                  wxString(wxT(" - ")) + wxU(_("Playing")));
-        }
-#endif
-    }
-    else
-    {
-        p_main_intf->TogglePlayButton( PAUSE_S );
-        p_main_intf->statusbar->SetStatusText( wxT(""), 0 );
-        p_main_intf->statusbar->SetStatusText( wxT(""), 2 );
-#ifdef wxHAS_TASK_BAR_ICON
-        if( p_main_intf->p_systray )
-        {
-            p_main_intf->p_systray->UpdateTooltip( wxString(wxT("VLC media player - ")) + wxU(_("Stopped")) );
-        }
-#endif
-    }
-}
-
-void MainSliderManager::HideControls()
-{
-    p_main_intf->m_controls_timer.Start(200, wxTIMER_ONE_SHOT);
-}
-
-void MainSliderManager::DontHide()
-{
-    p_main_intf->m_controls_timer.Stop();
-
-    /* New input or stream map change */
-    p_intf->p_sys->b_playing = VLC_TRUE;
-}
-
-void MainSliderManager::UpdateDiscButtons()
-{
-    vlc_value_t val;
-    var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
-    if( val.i_int > 0 && !p_main_intf->disc_frame->IsShown() )
-    {
-        vlc_value_t val;
-
-        #define HELP_MENU N_("Menu")
-        #define HELP_PCH N_("Previous chapter")
-        #define HELP_NCH N_("Next chapter")
-        #define HELP_PTR N_("Previous track")
-        #define HELP_NTR N_("Next track")
-
-        var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
-
-        if( val.i_int > 0 )
-        {
-            p_main_intf->disc_menu_button->Show();
-            p_main_intf->disc_sizer->Show(
-                        p_main_intf->disc_menu_button );
-            p_main_intf->disc_sizer->Layout();
-            p_main_intf->disc_sizer->Fit(
-            p_main_intf->disc_frame );
-            p_main_intf->disc_menu_button->SetToolTip(
-                        wxU(_( HELP_MENU ) ) );
-            p_main_intf->disc_prev_button->SetToolTip(
-                        wxU(_( HELP_PCH ) ) );
-            p_main_intf->disc_next_button->SetToolTip(
-                        wxU(_( HELP_NCH ) ) );
-        }
-        else
-        {
-            p_main_intf->disc_menu_button->Hide();
-            p_main_intf->disc_sizer->Hide(
-                        p_main_intf->disc_menu_button );
-            p_main_intf->disc_prev_button->SetToolTip(
-                        wxU(_( HELP_PTR ) ) );
-            p_main_intf->disc_next_button->SetToolTip(
-                        wxU(_( HELP_NTR ) ) );
-        }
-
-        p_main_intf->ShowDiscFrame();
-    }
-    else if( val.i_int == 0 && p_main_intf->disc_frame->IsShown() )
-    {
-        p_main_intf->HideDiscFrame();
-    }
-}
-
-vlc_bool_t MainSliderManager::IsShown()
-{
-    return p_main_intf->slider_frame->IsShown();
-}
-
-void MainSliderManager::ShowSlider()
-{
-    p_main_intf->ShowSlider();
-}
-
-void MainSliderManager::HideSlider()
-{
-    p_main_intf->m_slider_timer.Start( 200, wxTIMER_ONE_SHOT );
-}
-
-vlc_bool_t MainSliderManager::IsFree()
-{
-    return p_intf->p_sys->b_slider_free;
-}
-
-vlc_bool_t MainSliderManager::IsPlaying()
-{
-    return p_intf->p_sys->b_playing;
-}
-
-void MainSliderManager::UpdateTime( char *psz_time, char *psz_total )
-{
-    p_main_intf->statusbar->SetStatusText(
-                 wxU(psz_time) + wxString(wxT(" / ")) +wxU(psz_total), 0 );
-}
diff --git a/modules/gui/wxwidgets/main_slider_manager.hpp b/modules/gui/wxwidgets/main_slider_manager.hpp
deleted file mode 100644 (file)
index bbb59e1..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************************
- * slider_manager.hpp: Header for slider_manager
- *****************************************************************************
- * Copyright (C) 1999-2005 the VideoLAN team
- * $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $
- *
- * Authors: Clément Stenac <zorglub@videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#ifndef _MAIN_SLIDER_MANAGER_H_
-#define _MAIN_SLIDER_MANAGER_H_
-
-#include "slider_manager.hpp"
-
-namespace wxvlc
-{
-    class Interface;
-    /**
-     * This class manages a slider corresponding to the main input
-     */
-    class MainSliderManager: public SliderManager
-    {
-    public:
-        MainSliderManager( intf_thread_t *p_intf, Interface * );
-        virtual ~MainSliderManager();
-
-    protected:
-        virtual void UpdateInput();
-        virtual void UpdateNowPlaying();
-        virtual void UpdateButtons( vlc_bool_t );
-        virtual void UpdateDiscButtons();
-        virtual void UpdateTime( char *, char *);
-
-        virtual vlc_bool_t IsShown();
-        virtual vlc_bool_t IsFree();
-        virtual vlc_bool_t IsPlaying();
-
-        virtual void HideSlider();
-        virtual void ShowSlider();
-
-        virtual void HideControls();
-         virtual void DontHide();
-
-        Interface * p_main_intf;
-    };
-};
-
-#endif
diff --git a/modules/gui/wxwidgets/slider_manager.cpp b/modules/gui/wxwidgets/slider_manager.cpp
deleted file mode 100644 (file)
index 7855408..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*****************************************************************************
- * slider_manager.cpp : Manage an input slider
- *****************************************************************************
- * Copyright (C) 2000-2005 the VideoLAN team
- * $Id: timer.cpp 11981 2005-08-03 15:03:23Z xtophe $
- *
- * Authors: Clément Stenac <zorglub@videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-/*****************************************************************************
- * Preamble
- *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <errno.h>                                                 /* ENOMEM */
-#include <string.h>                                            /* strerror() */
-#include <stdio.h>
-
-#include <vlc/vlc.h>
-#include <vlc/aout.h>
-#include <vlc/intf.h>
-
-#include "vlc_meta.h"
-
-#include "wxwidgets.hpp"
-
-#include "slider_manager.hpp"
-
-/*****************************************************************************
- * Constructor.
- *****************************************************************************/
-SliderManager::SliderManager( intf_thread_t *_p_intf )
-{
-    p_intf = _p_intf;
-    p_input = NULL;
-    i_old_playing_status = PAUSE_S;
-}
-
-SliderManager::~SliderManager()
-{
-    vlc_mutex_lock( &p_intf->change_lock );
-    if( p_intf->p_sys->p_input ) vlc_object_release( p_intf->p_sys->p_input );
-    p_intf->p_sys->p_input = NULL;
-    vlc_mutex_unlock( &p_intf->change_lock );
-}
-
-/*****************************************************************************
- * Private methods.
- *****************************************************************************/
-void SliderManager::Update()
-{
-    /* Update the input */
-    if( p_input == NULL )
-    {
-        UpdateInput();
-        if( p_input )
-        {
-            _slider->SetValue( 0 );
-            UpdateNowPlaying();
-
-            UpdateButtons( VLC_TRUE );
-
-            i_old_playing_status = PLAYING_S;
-        }
-    }
-    else if( p_input->b_dead )
-    {
-        HideControls();
-        HideSlider();
-
-        UpdateButtons( VLC_FALSE );
-
-        i_old_playing_status = PAUSE_S;
-
-        vlc_object_release( p_input );
-        p_input = NULL;
-    }
-
-    if( p_input )
-    {
-        if( !p_input->b_die )
-        {
-            vlc_value_t pos;
-
-            DontHide();
-
-            UpdateNowPlaying();
-
-            /* Really manage the slider */
-            var_Get( p_input, "position", &pos );
-
-            UpdateDiscButtons();
-
-            if( pos.f_float > 0.0 && ! IsShown() )
-            {
-                 ShowSlider();
-            }
-            else if( pos.f_float <= 0.0 )
-            {
-                HideSlider();
-            }
-
-            if( IsPlaying() && IsShown() )
-            {
-                /* Update the slider if the user isn't dragging it. */
-                if( IsFree() )
-                {
-                    char psz_time[ MSTRTIME_MAX_SIZE ];
-                    char psz_total[ MSTRTIME_MAX_SIZE ];
-                    vlc_value_t time;
-                    mtime_t i_seconds;
-
-                    /* Update the value */
-                    if( pos.f_float >= 0.0 )
-                    {
-                        i_slider_pos = (int)(SLIDER_MAX_POS * pos.f_float);
-
-                        _slider->SetValue( i_slider_pos );
-
-                        var_Get( p_input, "time", &time );
-                        i_seconds = time.i_time / 1000000;
-                        secstotimestr ( psz_time, i_seconds );
-
-                        var_Get( p_input, "length",  &time );
-                        i_seconds = time.i_time / 1000000;
-                        secstotimestr ( psz_total, i_seconds );
-
-                        UpdateTime( psz_time, psz_total );
-//                        p_main_interface->statusbar->SetStatusText(
-//                            wxU(psz_time) + wxString(wxT(" / ")) +
-//                            wxU(psz_total), 0 );
-                    }
-                }
-            }
-        }
-    }
-}
diff --git a/modules/gui/wxwidgets/slider_manager.hpp b/modules/gui/wxwidgets/slider_manager.hpp
deleted file mode 100644 (file)
index 16647e9..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************************
- * slider_manager.hpp: Header for slider_manager
- *****************************************************************************
- * Copyright (C) 1999-2005 the VideoLAN team
- * $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $
- *
- * Authors: Clément Stenac <zorglub@videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
- *****************************************************************************/
-
-#ifndef _SLIDER_MANAGER_H_
-#define _SLIDER_MANAGER_H_
-
-#include "wxwidgets.hpp"
-
-namespace wxvlc
-{
-    /**
-     * This class manages a slider corresponding to an input
-     * This class is abstract, it needs to be subclassed
-     */
-    class SliderManager
-    {
-    public:
-        SliderManager( intf_thread_t *p_intf );
-        virtual ~SliderManager();
-
-        void Update();
-
-    protected:
-        virtual void UpdateInput() = 0;
-        virtual void UpdateNowPlaying() {};
-        virtual void UpdateButtons( vlc_bool_t ) {};
-        virtual void UpdateDiscButtons() {}
-        virtual void UpdateTime( char *, char *)  = 0;
-
-        virtual vlc_bool_t IsShown() = 0;
-        virtual vlc_bool_t IsFree() = 0;
-        virtual vlc_bool_t IsPlaying() = 0;
-
-        virtual void HideSlider() {};
-        virtual void ShowSlider() {};
-
-        virtual void HideControls() {};
-        virtual void DontHide() {};
-
-        intf_thread_t * p_intf;
-        input_thread_t *p_input;
-        wxSlider *_slider;           ///< Slider for this input
-        int i_slider_pos;            ///< Current slider position
-
-    private:
-        int i_old_playing_status;    ///< Previous playing status
-
-
-    };
-};
-
-#endif
index 2544fb9ad5bff299f5c5fb633bbd0b56879c79d4..e8514be145c4c148b88a0d9ac7a4e151f2e55580 100644 (file)
@@ -25,7 +25,7 @@
  * Preamble
  *****************************************************************************/
 #include "timer.hpp"
-#include "main_slider_manager.hpp"
+#include "input_manager.hpp"
 #include "interface.hpp"
 #include "vlc_meta.h"
 
@@ -46,11 +46,6 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface )
     p_main_interface = _p_main_interface;
     b_init = 0;
 
-    msm = new MainSliderManager( p_intf, p_main_interface );
-
-    i_old_playing_status = PAUSE_S;
-    i_old_rate = INPUT_RATE_DEFAULT;
-
     /* Register callback for the intf-popupmenu variable */
     playlist_t *p_playlist =
         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
@@ -77,8 +72,6 @@ Timer::~Timer()
         var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
         vlc_object_release( p_playlist );
     }
-
-    delete msm;
 }
 
 /*****************************************************************************
@@ -104,61 +97,12 @@ void Timer::Notify()
     vlc_mutex_lock( &p_intf->change_lock );
 
     /* Call update */
-    msm->Update();
+    p_main_interface->input_manager->Update();
 
-    vlc_value_t val;
-    input_thread_t *p_input = p_intf->p_sys->p_input;
-    if( p_intf->p_sys->p_input )
-    {
-        if( !p_intf->p_sys->p_input->b_die )
-        {
-            /* Take care of the volume, etc... */
-            p_main_interface->Update();
-
-            /* Manage Playing status */
-            var_Get( p_input, "state", &val );
-            if( i_old_playing_status != val.i_int )
-            {
-                if( val.i_int == PAUSE_S )
-                {
-                    p_main_interface->TogglePlayButton( PAUSE_S );
-                }
-                else
-                {
-                    p_main_interface->TogglePlayButton( PLAYING_S );
-                }
-#ifdef wxHAS_TASK_BAR_ICON
-                if( p_main_interface->p_systray )
-                {
-                    if( val.i_int == PAUSE_S )
-                    {
-                        p_main_interface->p_systray->UpdateTooltip( wxU(p_intf->p_sys->p_input->input.p_item->psz_name) + wxString(wxT(" - ")) + wxU(_("Paused")));
-                    }
-                    else
-                    {
-                        p_main_interface->p_systray->UpdateTooltip( wxU(p_intf->p_sys->p_input->input.p_item->psz_name) + wxString(wxT(" - ")) + wxU(_("Playing")));
-                    }
-                }
-#endif
-                i_old_playing_status = val.i_int;
-            }
-
-            /* Manage Speed status */
-            var_Get( p_input, "rate", &val );
-            if( i_old_rate != val.i_int )
-            {
-                p_main_interface->statusbar->SetStatusText(
-                    wxString::Format(wxT("x%.2f"),
-                    (float)INPUT_RATE_DEFAULT / val.i_int ), 1 );
-                i_old_rate = val.i_int;
-            }
-        }
-    }
-    else if( p_intf->p_sys->b_playing && !p_intf->b_die )
+    if( p_main_interface->input_manager->IsPlaying() )
     {
-        p_intf->p_sys->b_playing = 0;
-        p_main_interface->TogglePlayButton( PAUSE_S );
-        i_old_playing_status = PAUSE_S;
+        /* Take care of the volume, etc... */
+        p_main_interface->Update();
     }
 
     /* Show the interface, if requested */
index 19fe7d8e00ea9d2e6c44ff49d15838b6d498c013..ea7e8c3ab6443963858fbb4db926bbae2634a05e 100644 (file)
@@ -2,7 +2,7 @@
  * timer.hpp: Timer headers
  *****************************************************************************
  * Copyright (C) 1999-2005 the VideoLAN team
- * $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
@@ -25,7 +25,7 @@
 
 namespace wxvlc
 {
-    class MainSliderManager;
+    class InputManager;
     class Interface;
 
     class Timer: public wxTimer
@@ -38,16 +38,13 @@ namespace wxvlc
         virtual void Notify();
 
     private:
-        //use wxWindow::IsShown instead
-        //vlc_bool_t b_slider_shown;
-        //vlc_bool_t b_disc_shown;
         intf_thread_t *p_intf;
         Interface *p_main_interface;
         vlc_bool_t b_init;
         int i_old_playing_status;
         int i_old_rate;
 
-        MainSliderManager *msm;
+        InputManager *msm;
     };
 
 }
index 09b64c48b1d860d5c7d9f7348f59c437d2e0ab93..fea7224614ecaee740688e2e2dc53c177c2ce722 100644 (file)
@@ -2,7 +2,7 @@
  * video.hpp: Embedded video management
  *****************************************************************************
  * Copyright (C) 1999-2005 the VideoLAN team
- * $Id: wxwidgets.h 12670 2005-09-25 11:16:31Z zorglub $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
index b90156802780c1172d67ef264012025080e009be..1ad5bf874b44fe376bef6fe4a04023fd42210495 100644 (file)
@@ -180,8 +180,6 @@ static int Open( vlc_object_t *p_this )
 
     p_intf->p_sys->p_input = NULL;
     p_intf->p_sys->i_playing = -1;
-    p_intf->p_sys->b_slider_free = 1;
-    p_intf->p_sys->i_slider_pos = p_intf->p_sys->i_slider_oldpos = 0;
 
     p_intf->p_sys->p_popup_menu = NULL;
     p_intf->p_sys->p_video_window = NULL;
index 4040cc9a0131aa3e7a485cf55ca0cdaf71009e15..212f0538c533cba74bf293fcfe16d853f9807390 100644 (file)
@@ -2,7 +2,7 @@
  * wxwidgets.hpp: Common headers for the wxwidges interface
  *****************************************************************************
  * Copyright (C) 1999-2005 the VideoLAN team
- * $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
  *
@@ -137,11 +137,6 @@ struct intf_sys_t
     /* The input thread */
     input_thread_t *    p_input;
 
-    /* The slider */
-    int                 i_slider_pos;                     /* slider position */
-    int                 i_slider_oldpos;                /* previous position */
-    vlc_bool_t          b_slider_free;                      /* slider status */
-
     /* The messages window */
     msg_subscription_t* p_sub;                  /* message bank subscription */