menus.cpp \
timer.cpp \
video.cpp \
- slider_manager.cpp \
- main_slider_manager.cpp \
+ input_manager.cpp \
dialogs.cpp \
dialogs/open.cpp \
dialogs/streamout.cpp \
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 \
* 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");
}
/*****************************************************************************
- * 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 )
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" );
}
* 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>
*
#ifndef _VLM_SLIDER_MANAGER_H_
#define _VLM_SLIDER_MANAGER_H_
-#include "slider_manager.hpp"
+#include "wxwidgets.hpp"
namespace wxvlc
{
/**
* This class manages a slider corresponding to the main input
*/
- class VLMSliderManager: public SliderManager
+ class VLMSliderManager
{
public:
VLMSliderManager( intf_thread_t *, VLMBroadcastStreamPanel * );
wxString time_string;
+ void Update();
void ProcessUpdate( wxScrollEvent & );
protected:
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
};
};
{ "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") },
{
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 ) ) );
}
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 );
* 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>
*
--- /dev/null
+/*****************************************************************************
+ * 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 );
+}
--- /dev/null
+/*****************************************************************************
+ * 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
};
BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
- EVT_PAINT(VLCVolCtrl::OnPaint)
+ EVT_PAINT(VLCVolCtrl::OnPaint)
/* Mouse events */
EVT_LEFT_UP(VLCVolCtrl::OnChange)
Prefs_Event,
Extended_Event,
-// Undock_Event,
Bookmarks_Event,
Skins_Event,
- SliderScroll_Event,
StopStream_Event,
PlayStream_Event,
PrevStream_Event,
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) */
EVT_MENU_OPEN(Interface::OnMenuOpen)
EVT_MENU( Extended_Event, Interface::OnExtended )
-// EVT_MENU( Undock_Event, Interface::OnUndock )
EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
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()
/*****************************************************************************
{
/* 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
/* 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. */
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 */
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()
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;
#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 ) );
#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;
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__ )
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,
}
}
-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) )
{
/* 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 */
}
var_Set( p_input, "state", state );
- TogglePlayButton( state.i_int );
vlc_object_release( p_input );
vlc_object_release( p_playlist );
+ input_manager->Update();
}
else
{
}
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) )
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;
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
{
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 */
* 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
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;
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 );
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__ )
Timer *timer;
intf_thread_t *p_intf;
- wxWindow *video_window;
-
int i_old_playing_status;
/* For auto-generated menus */
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;
};
};
};
-/// \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
+++ /dev/null
-/*****************************************************************************
- * 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 );
-}
+++ /dev/null
-/*****************************************************************************
- * 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
+++ /dev/null
-/*****************************************************************************
- * 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 );
- }
- }
- }
- }
- }
-}
+++ /dev/null
-/*****************************************************************************
- * 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
* Preamble
*****************************************************************************/
#include "timer.hpp"
-#include "main_slider_manager.hpp"
+#include "input_manager.hpp"
#include "interface.hpp"
#include "vlc_meta.h"
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,
var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
vlc_object_release( p_playlist );
}
-
- delete msm;
}
/*****************************************************************************
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 */
* 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>
*
namespace wxvlc
{
- class MainSliderManager;
+ class InputManager;
class Interface;
class Timer: public wxTimer
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;
};
}
* 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>
*
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;
* 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>
*
/* 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 */