Commit a644825a authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwidgets: massive cleanup and simplification of the main interface code.

parent 70e52acc
...@@ -8,8 +8,7 @@ SOURCES_wxwidgets = \ ...@@ -8,8 +8,7 @@ SOURCES_wxwidgets = \
menus.cpp \ menus.cpp \
timer.cpp \ timer.cpp \
video.cpp \ video.cpp \
slider_manager.cpp \ input_manager.cpp \
main_slider_manager.cpp \
dialogs.cpp \ dialogs.cpp \
dialogs/open.cpp \ dialogs/open.cpp \
dialogs/streamout.cpp \ dialogs/streamout.cpp \
...@@ -41,8 +40,7 @@ EXTRA_DIST += \ ...@@ -41,8 +40,7 @@ EXTRA_DIST += \
extrapanel.hpp \ extrapanel.hpp \
timer.hpp \ timer.hpp \
video.hpp \ video.hpp \
slider_manager.hpp \ input_manager.hpp \
main_slider_manager.hpp \
dialogs/fileinfo.hpp \ dialogs/fileinfo.hpp \
dialogs/preferences.hpp \ dialogs/preferences.hpp \
dialogs/wizard.hpp \ dialogs/wizard.hpp \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlm_slider_manager.cpp : Manage an input slider for a VLM stream * vlm_slider_manager.cpp : Manage an input slider for a VLM stream
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team * Copyright (C) 2000-2005 the VideoLAN team
* $Id: timer.cpp 11981 2005-08-03 15:03:23Z xtophe $ * $Id$
* *
* Authors: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
...@@ -32,11 +32,13 @@ ...@@ -32,11 +32,13 @@
* Constructor. * Constructor.
*****************************************************************************/ *****************************************************************************/
VLMSliderManager::VLMSliderManager( intf_thread_t *_p_intf, VLMSliderManager::VLMSliderManager( intf_thread_t *_p_intf,
VLMBroadcastStreamPanel *_p_sp ) : VLMBroadcastStreamPanel *_p_sp )
SliderManager( _p_intf )
{ {
p_intf = _p_intf;
p_input = NULL;
p_sp = _p_sp; p_sp = _p_sp;
_slider = p_sp->p_slider; slider = p_sp->p_slider;
b_slider_free = VLC_TRUE; b_slider_free = VLC_TRUE;
time_string = wxU( "0:00:00 / 0:00:00"); time_string = wxU( "0:00:00 / 0:00:00");
...@@ -47,9 +49,75 @@ VLMSliderManager::~VLMSliderManager() ...@@ -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() void VLMSliderManager::UpdateInput()
{ {
if( p_sp->GetStream()->p_media->i_instance == 0 ) if( p_sp->GetStream()->p_media->i_instance == 0 )
...@@ -75,18 +143,18 @@ void VLMSliderManager::UpdateButtons( vlc_bool_t b_play ) ...@@ -75,18 +143,18 @@ void VLMSliderManager::UpdateButtons( vlc_bool_t b_play )
vlc_bool_t VLMSliderManager::IsShown() vlc_bool_t VLMSliderManager::IsShown()
{ {
return _slider->IsEnabled(); return slider->IsEnabled();
} }
void VLMSliderManager::ShowSlider() void VLMSliderManager::ShowSlider()
{ {
_slider->Enable(); slider->Enable();
} }
void VLMSliderManager::HideSlider() void VLMSliderManager::HideSlider()
{ {
_slider->SetValue( 0 ); slider->SetValue( 0 );
_slider->Disable(); slider->Disable();
UpdateTime( "0:00:00", "0:00:00" ); UpdateTime( "0:00:00", "0:00:00" );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vlm_slider_manager.hpp: Header for slider_manager * vlm_slider_manager.hpp: Header for slider_manager
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team * Copyright (C) 1999-2005 the VideoLAN team
* $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $ * $Id$
* *
* Authors: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#ifndef _VLM_SLIDER_MANAGER_H_ #ifndef _VLM_SLIDER_MANAGER_H_
#define _VLM_SLIDER_MANAGER_H_ #define _VLM_SLIDER_MANAGER_H_
#include "slider_manager.hpp" #include "wxwidgets.hpp"
namespace wxvlc namespace wxvlc
{ {
...@@ -32,7 +32,7 @@ namespace wxvlc ...@@ -32,7 +32,7 @@ namespace wxvlc
/** /**
* This class manages a slider corresponding to the main input * This class manages a slider corresponding to the main input
*/ */
class VLMSliderManager: public SliderManager class VLMSliderManager
{ {
public: public:
VLMSliderManager( intf_thread_t *, VLMBroadcastStreamPanel * ); VLMSliderManager( intf_thread_t *, VLMBroadcastStreamPanel * );
...@@ -40,6 +40,7 @@ namespace wxvlc ...@@ -40,6 +40,7 @@ namespace wxvlc
wxString time_string; wxString time_string;
void Update();
void ProcessUpdate( wxScrollEvent & ); void ProcessUpdate( wxScrollEvent & );
protected: protected:
...@@ -56,6 +57,11 @@ namespace wxvlc ...@@ -56,6 +57,11 @@ namespace wxvlc
virtual void ShowSlider(); virtual void ShowSlider();
VLMBroadcastStreamPanel * p_sp; 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
}; };
}; };
......
...@@ -150,7 +150,6 @@ static const struct filter vfilters[] = ...@@ -150,7 +150,6 @@ static const struct filter vfilters[] =
{ "clone", N_("Image clone"), N_("Creates several clones of the image") }, { "clone", N_("Image clone"), N_("Creates several clones of the image") },
{ "distort", N_("Distortion"), N_("Adds distorsion effects") }, { "distort", N_("Distortion"), N_("Adds distorsion effects") },
{ "invert", N_("Image inversion") , N_("Inverts the image colors") }, { "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") }, { "motionblur", N_("Blurring"), N_("Creates a motion blurring on the image") },
{ "transform", N_("Transformation"), N_("Rotates or flips the image") }, { "transform", N_("Transformation"), N_("Rotates or flips the image") },
{ "magnify", N_("Magnify"), N_("Magnifies part of the image") }, { "magnify", N_("Magnify"), N_("Magnifies part of the image") },
...@@ -311,7 +310,7 @@ wxPanel *ExtraPanel::VideoPanel( wxWindow *parent ) ...@@ -311,7 +310,7 @@ wxPanel *ExtraPanel::VideoPanel( wxWindow *parent )
{ {
wxCheckBox *box = new wxCheckBox( panel, Filter0_Event + i, wxCheckBox *box = new wxCheckBox( panel, Filter0_Event + i,
wxU( _( vfilters[i].psz_name ) ) ); 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 ) ) ); box->SetToolTip( wxU( _( vfilters[i].psz_help ) ) );
} }
...@@ -1215,13 +1214,11 @@ ExtraWindow::ExtraWindow( intf_thread_t *_p_intf, wxWindow *p_parent, ...@@ -1215,13 +1214,11 @@ ExtraWindow::ExtraWindow( intf_thread_t *_p_intf, wxWindow *p_parent,
wxFrame( p_parent, -1, wxU(_("Extended controls")), wxDefaultPosition, wxFrame( p_parent, -1, wxU(_("Extended controls")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_FRAME_STYLE ) wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{ {
fprintf(stderr,"Creating extrawindow\n");
p_intf = _p_intf; p_intf = _p_intf;
SetIcon( *p_intf->p_sys->p_icon ); SetIcon( *p_intf->p_sys->p_icon );
wxBoxSizer *window_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *window_sizer = new wxBoxSizer( wxVERTICAL );
SetSizer( window_sizer ); SetSizer( window_sizer );
// panel = new ExtraPanel( p_intf, this );//_extra_panel;
panel = _extra_panel; panel = _extra_panel;
window_sizer->Add( panel ); window_sizer->Add( panel );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* extrapanel.hpp: Headers for the extra panel window * extrapanel.hpp: Headers for the extra panel window
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team * Copyright (C) 1999-2005 the VideoLAN team
* $Id: wxwidgets.h 12670 2005-09-25 11:16:31Z zorglub $ * $Id$
* *
* Authors: Clment Stenac <zorglub@videolan.org> * Authors: Clment Stenac <zorglub@videolan.org>
* *
......
/*****************************************************************************
* slider_manager.cpp : Manage an input slider
*****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Clment 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 );
}
/***************************************************************************** /*****************************************************************************
* slider_manager.hpp: Header for slider_manager * input_manager.hpp: Header for input_manager
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team * 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> * Authors: Gildas Bazin <gbazin@videolan.org>
* Clment Stenac <zorglub@videolan.org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -21,50 +22,67 @@ ...@@ -21,50 +22,67 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
#ifndef _SLIDER_MANAGER_H_ #ifndef _INPUT_MANAGER_H_
#define _SLIDER_MANAGER_H_ #define _INPUT_MANAGER_H_
#include "wxwidgets.hpp" #include "wxwidgets.hpp"
namespace wxvlc namespace wxvlc
{ {
class Interface;
/** /**
* This class manages a slider corresponding to an input * This class manages all the controls related to the input
* This class is abstract, it needs to be subclassed
*/ */
class SliderManager class InputManager : public wxPanel
{ {
public: public:
SliderManager( intf_thread_t *p_intf ); InputManager( intf_thread_t *, Interface *, wxWindow * );
virtual ~SliderManager(); virtual ~InputManager();
void Update(); void Update();
vlc_bool_t IsPlaying();
protected: protected:
virtual void UpdateInput() = 0; void UpdateInput();
virtual void UpdateNowPlaying() {}; void UpdateNowPlaying();
virtual void UpdateButtons( vlc_bool_t ) {}; void UpdateButtons( vlc_bool_t );
virtual void UpdateDiscButtons() {} void UpdateDiscButtons();
virtual void UpdateTime( char *, char *) = 0; void UpdateTime();
void HideSlider();
void ShowSlider( bool show = true );
virtual vlc_bool_t IsShown() = 0; void OnSliderUpdate( wxScrollEvent& event );
virtual vlc_bool_t IsFree() = 0;
virtual vlc_bool_t IsPlaying() = 0;
virtual void HideSlider() {}; void OnDiscMenu( wxCommandEvent& event );
virtual void ShowSlider() {}; void OnDiscPrev( wxCommandEvent& event );
void OnDiscNext( wxCommandEvent& event );
virtual void HideControls() {}; void HideDiscFrame();
virtual void DontHide() {}; 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; intf_thread_t * p_intf;
input_thread_t *p_input; input_thread_t *p_input;
wxSlider *_slider; ///< Slider for this input Interface * p_main_intf;
wxSlider *slider; ///< Slider for this input
int i_slider_pos; ///< Current slider position int i_slider_pos; ///< Current slider position
vlc_bool_t b_slider_free; ///< Slider status
wxBoxSizer *sizer;
private: private:
int i_old_playing_status; ///< Previous playing status DECLARE_EVENT_TABLE();
int i_old_playing_status; ///< Previous playing status
int i_old_rate; ///< Previous playing rate
}; };
}; };
......
...@@ -102,7 +102,7 @@ public: ...@@ -102,7 +102,7 @@ public:
}; };
BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl) BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
EVT_PAINT(VLCVolCtrl::OnPaint) EVT_PAINT(VLCVolCtrl::OnPaint)
/* Mouse events */ /* Mouse events */
EVT_LEFT_UP(VLCVolCtrl::OnChange) EVT_LEFT_UP(VLCVolCtrl::OnChange)
...@@ -139,11 +139,9 @@ enum ...@@ -139,11 +139,9 @@ enum
Prefs_Event, Prefs_Event,
Extended_Event, Extended_Event,
// Undock_Event,
Bookmarks_Event, Bookmarks_Event,
Skins_Event, Skins_Event,
SliderScroll_Event,
StopStream_Event, StopStream_Event,
PlayStream_Event, PlayStream_Event,
PrevStream_Event, PrevStream_Event,
...@@ -151,10 +149,6 @@ enum ...@@ -151,10 +149,6 @@ enum
SlowStream_Event, SlowStream_Event,
FastStream_Event, FastStream_Event,
DiscMenu_Event,
DiscPrev_Event,
DiscNext_Event,
/* it is important for the id corresponding to the "About" command to have /* 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 * this standard value as otherwise it won't be handled properly under Mac
* (where it is special and put into the "Apple" menu) */ * (where it is special and put into the "Apple" menu) */
...@@ -180,7 +174,6 @@ BEGIN_EVENT_TABLE(Interface, wxFrame) ...@@ -180,7 +174,6 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
EVT_MENU_OPEN(Interface::OnMenuOpen) EVT_MENU_OPEN(Interface::OnMenuOpen)
EVT_MENU( Extended_Event, Interface::OnExtended ) EVT_MENU( Extended_Event, Interface::OnExtended )
// EVT_MENU( Undock_Event, Interface::OnUndock )
EVT_MENU( Bookmarks_Event, Interface::OnShowDialog) EVT_MENU( Bookmarks_Event, Interface::OnShowDialog)
...@@ -206,20 +199,9 @@ BEGIN_EVENT_TABLE(Interface, wxFrame) ...@@ -206,20 +199,9 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
EVT_MENU(SlowStream_Event, Interface::OnSlowStream) EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
EVT_MENU(FastStream_Event, Interface::OnFastStream) 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 */ /* Custom events */
EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent) EVT_COMMAND(0, wxEVT_INTF, Interface::OnControlEvent)
EVT_COMMAND(1, 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() END_EVENT_TABLE()
/***************************************************************************** /*****************************************************************************
...@@ -231,43 +213,36 @@ Interface::Interface( intf_thread_t *_p_intf, long style ): ...@@ -231,43 +213,36 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
{ {
/* Initializations */ /* Initializations */
p_intf = _p_intf; p_intf = _p_intf;
i_old_playing_status = PAUSE_S;
b_extra = VLC_FALSE; b_extra = VLC_FALSE;
// b_undock = VLC_FALSE; extra_frame = 0;
extra_window = NULL;
/* Give our interface a nice little icon */ /* Give our interface a nice little icon */
SetIcon( wxIcon( vlc_xpm ) ); SetIcon( wxIcon( vlc_xpm ) );
/* Create a sizer for the main frame */ /* Create a main panel that will fill in the interface window */
frame_sizer = new wxBoxSizer( wxVERTICAL ); main_sizer = new wxBoxSizer( wxVERTICAL );
SetSizer( frame_sizer ); 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) #if defined(__WXGTK20__) && wxCHECK_VERSION(2,5,6)
/* As ugly as your butt! Please remove when wxWidgets 2.6 fixed their /* As ugly as your butt! Please remove when wxWidgets 2.6 fixed their
* Accelerators bug. */ * Accelerators bug. */
p_dummy->m_imData = 0; main_panel->m_imData = 0;
m_imData = 0; m_imData = 0;
#endif #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 #ifdef wxHAS_TASK_BAR_ICON
/* Systray integration */ /* Systray integration */
p_systray = NULL; 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 = 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");
}
} }
#endif #endif
...@@ -277,11 +252,6 @@ Interface::Interface( intf_thread_t *_p_intf, long style ): ...@@ -277,11 +252,6 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
/* Creation of the tool bar */ /* Creation of the tool bar */
CreateOurToolBar(); 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 /* Creation of the status bar
* Helptext for menu items and toolbar tools will automatically get * Helptext for menu items and toolbar tools will automatically get
* displayed here. */ * displayed here. */
...@@ -294,21 +264,19 @@ Interface::Interface( intf_thread_t *_p_intf, long style ): ...@@ -294,21 +264,19 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
video_window = 0; video_window = 0;
if( config_GetInt( p_intf, "wx-embed" ) ) if( config_GetInt( p_intf, "wx-embed" ) )
{ {
video_window = CreateVideoWindow( p_intf, this ); video_window = CreateVideoWindow( p_intf, main_panel );
frame_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND, 0 ); panel_sizer->Add( p_intf->p_sys->p_video_sizer, 1, wxEXPAND, 0 );
} }
/* Creation of the slider sub-window */ /* Creation of the input manager panel */
CreateOurSlider(); input_manager = new InputManager( p_intf, this, main_panel );
frame_sizer->Add( slider_frame, 0, wxEXPAND , 0 ); panel_sizer->Add( input_manager, 0, wxEXPAND , 0 );
frame_sizer->Hide( slider_frame );
/* Make sure we've got the right background colour */
SetBackgroundColour( slider_frame->GetBackgroundColour() );
/* Layout everything */ /* Layout everything */
frame_sizer->Layout(); panel_sizer->Layout();
frame_sizer->Fit(this); panel_sizer->Fit( main_panel );
main_sizer->Layout();
main_sizer->Fit( this );
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
/* Associate drop targets with the main interface */ /* Associate drop targets with the main interface */
...@@ -317,60 +285,31 @@ Interface::Interface( intf_thread_t *_p_intf, long style ): ...@@ -317,60 +285,31 @@ Interface::Interface( intf_thread_t *_p_intf, long style ):
SetupHotkeys(); SetupHotkeys();
m_controls_timer.SetOwner(this, ID_CONTROLS_TIMER);
m_slider_timer.SetOwner(this, ID_SLIDER_TIMER);
/* Start timer */ /* Start timer */
timer = new Timer( p_intf, this ); timer = new Timer( p_intf, this );
/* */ /* Restore previous position / settings */
WindowSettings *ws = p_intf->p_sys->p_window_settings; WindowSettings *ws = p_intf->p_sys->p_window_settings;
wxPoint p; wxPoint p;
wxSize s; wxSize s;
bool b_shown; bool b_shown;
ws->SetScreen( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ), ws->SetScreen( wxSystemSettings::GetMetric( wxSYS_SCREEN_X ),
wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) ); wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ) );
if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) ) if( ws->GetSettings( WindowSettings::ID_MAIN, b_shown, p, s ) ) Move( p );
Move( p );
/* Set minimum window size to prevent user from glitching it */ /* Get minimum window size to prevent user from glitching it */
wxSize s2;
s = GetSize(); s = GetSize();
if( video_window && video_window->IsShown() )
/* save smallest possible default minimum size */ s.SetHeight( s.GetHeight() - video_window->GetSize().GetHeight() );
default_size = GetSize(); main_min_size = s;
/* 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
/* Show extended GUI if requested */ /* Show extended GUI if requested */
if( ( b_extra = config_GetInt( p_intf, "wx-extended" ) ) ) wxCommandEvent dummy;
frame_sizer->Show( extra_frame ); if( config_GetInt( p_intf, "wx-extended" ) ) OnExtended( dummy );
SetIntfMinSize();
} }
Interface::~Interface() Interface::~Interface()
...@@ -414,12 +353,10 @@ void Interface::OnControlEvent( wxCommandEvent& event ) ...@@ -414,12 +353,10 @@ void Interface::OnControlEvent( wxCommandEvent& event )
switch( event.GetId() ) switch( event.GetId() )
{ {
case 0: case 0:
if( p_intf->p_sys->b_video_autosize )
{ {
if( p_intf->p_sys->b_video_autosize ) main_sizer->Layout();
{ main_sizer->Fit(this);
frame_sizer->Layout();
frame_sizer->Fit(this);
}
} }
break; break;
...@@ -536,7 +473,7 @@ void Interface::CreateOurMenuBar() ...@@ -536,7 +473,7 @@ void Interface::CreateOurMenuBar()
#endif #endif
/* End patch by zcot */ /* 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 */ /* Intercept all menu events in our custom event handler */
PushEventHandler( new MenuEvtHandler( p_intf, this ) ); PushEventHandler( new MenuEvtHandler( p_intf, this ) );
...@@ -618,53 +555,6 @@ void Interface::CreateOurToolBar() ...@@ -618,53 +555,6 @@ void Interface::CreateOurToolBar()
#endif #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 ) static int ConvertHotkeyModifiers( int i_hotkey )
{ {
int i_accel_flags = 0; int i_accel_flags = 0;
...@@ -758,118 +648,27 @@ void Interface::SetupHotkeys() ...@@ -758,118 +648,27 @@ void Interface::SetupHotkeys()
delete [] p_entries; 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( extra_frame && extra_frame->IsShown() )
{
if( show )
{ {
//prevent the hide timers from hiding it now ms.SetHeight( ms.GetHeight() + ext_min_size.GetHeight() );
m_slider_timer.Stop(); if( ext_min_size.GetWidth() > ms.GetWidth() )
m_controls_timer.Stop(); ms.SetWidth( ext_min_size.GetWidth() );
//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
} }
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 ) ) #if ( wxCHECK_VERSION( 2,5,4 ) )
SetMinSize( ms ); SetMinSize( ms );
#else #else
frame_sizer->SetMinSize( ms ); main_sizer->SetMinSize( ms );
#endif #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. * 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 ) void Interface::OnMenuOpen( wxMenuEvent& event )
{ {
#if defined( __WXMSW__ ) #if defined( __WXMSW__ )
...@@ -884,11 +683,6 @@ void Interface::OnMenuOpen( wxMenuEvent& event ) ...@@ -884,11 +683,6 @@ void Interface::OnMenuOpen( wxMenuEvent& event )
p_settings_menu->AppendCheckItem( Extended_Event, p_settings_menu->AppendCheckItem( Extended_Event,
wxU(_("Extended &GUI\tCtrl-G") ) ); wxU(_("Extended &GUI\tCtrl-G") ) );
if( b_extra ) p_settings_menu->Check( Extended_Event, TRUE ); 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, p_settings_menu->Append( Bookmarks_Event,
wxU(_("&Bookmarks...\tCtrl-B") ) ); wxU(_("&Bookmarks...\tCtrl-B") ) );
p_settings_menu->Append( Prefs_Event, p_settings_menu->Append( Prefs_Event,
...@@ -1028,38 +822,23 @@ void Interface::OnShowDialog( wxCommandEvent& 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( !extra_frame )
if( b_extra == VLC_FALSE )
{ {
extra_frame->Hide(); /* Create the extra panel */
frame_sizer->Hide( extra_frame ); extra_frame = new ExtraPanel( p_intf, main_panel );
wxSize ms = GetMinSize(); panel_sizer->Add( extra_frame, 0, wxEXPAND , 0 );
ms.SetHeight( ms.GetHeight() - extended_size.GetHeight() ); ext_min_size = extra_frame->GetBestSize();
ms.SetWidth( default_size.GetWidth() );
#if ( wxCHECK_VERSION( 2,5,4 ) )
SetMinSize( ms );
#else
frame_sizer->SetMinSize( ms );
#endif
} }
else
{ b_extra = !b_extra;
extra_frame->Show();
frame_sizer->Show( extra_frame ); panel_sizer->Show( extra_frame, b_extra );
wxSize ms = GetMinSize();
ms.SetHeight( ms.GetHeight() + extended_size.GetHeight() ); SetIntfMinSize();
ms.SetWidth( extended_size.GetWidth() ); main_sizer->Layout();
#if ( wxCHECK_VERSION( 2,5,4 ) ) main_sizer->Fit( this );
SetMinSize( ms );
#else
frame_sizer->SetMinSize( ms );
#endif
}
frame_sizer->Layout();
frame_sizer->Fit(this);
} }
void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) ) void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) )
...@@ -1086,13 +865,12 @@ void Interface::PlayStream() ...@@ -1086,13 +865,12 @@ void Interface::PlayStream()
{ {
/* No stream was playing, start one */ /* No stream was playing, start one */
playlist_Play( p_playlist ); playlist_Play( p_playlist );
TogglePlayButton( PLAYING_S );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
input_manager->Update();
return; return;
} }
var_Get( p_input, "state", &state ); var_Get( p_input, "state", &state );
if( state.i_int != PAUSE_S ) if( state.i_int != PAUSE_S )
{ {
/* A stream is being played, pause it */ /* A stream is being played, pause it */
...@@ -1105,9 +883,9 @@ void Interface::PlayStream() ...@@ -1105,9 +883,9 @@ void Interface::PlayStream()
} }
var_Set( p_input, "state", state ); var_Set( p_input, "state", state );
TogglePlayButton( state.i_int );
vlc_object_release( p_input ); vlc_object_release( p_input );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
input_manager->Update();
} }
else else
{ {
...@@ -1132,57 +910,8 @@ void Interface::StopStream() ...@@ -1132,57 +910,8 @@ void Interface::StopStream()
} }
playlist_Stop( p_playlist ); playlist_Stop( p_playlist );
TogglePlayButton( PAUSE_S );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} input_manager->Update();
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 );
} }
void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) ) void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) )
...@@ -1252,9 +981,6 @@ void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) ) ...@@ -1252,9 +981,6 @@ void Interface::OnFastStream( wxCommandEvent& WXUNUSED(event) )
void Interface::TogglePlayButton( int i_playing_status ) void Interface::TogglePlayButton( int i_playing_status )
{ {
if( i_playing_status == i_old_playing_status )
return;
wxToolBarToolBase *p_tool = (wxToolBarToolBase *) wxToolBarToolBase *p_tool = (wxToolBarToolBase *)
GetToolBar()->GetToolClientData( PlayStream_Event ); GetToolBar()->GetToolClientData( PlayStream_Event );
if( !p_tool ) return; if( !p_tool ) return;
...@@ -1275,56 +1001,6 @@ void Interface::TogglePlayButton( int i_playing_status ) ...@@ -1275,56 +1001,6 @@ void Interface::TogglePlayButton( int i_playing_status )
GetToolBar()->Realize(); GetToolBar()->Realize();
GetToolBar()->ToggleTool( PlayStream_Event, true ); GetToolBar()->ToggleTool( PlayStream_Event, true );
GetToolBar()->ToggleTool( PlayStream_Event, false ); 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 #if wxUSE_DRAG_AND_DROP
...@@ -1494,6 +1170,12 @@ Systray::Systray( Interface *_p_main_interface, intf_thread_t *_p_intf ) ...@@ -1494,6 +1170,12 @@ Systray::Systray( Interface *_p_main_interface, intf_thread_t *_p_intf )
{ {
p_main_interface = _p_main_interface; p_main_interface = _p_main_interface;
p_intf = _p_intf; 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 */ /* Event handlers */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* interface.hpp: Main interface headers * interface.hpp: Main interface headers
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team * 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> * Authors: Gildas Bazin <gbazin@videolan.org>
* *
...@@ -25,11 +25,11 @@ ...@@ -25,11 +25,11 @@
#define _WXVLC_INTERFACE_H_ #define _WXVLC_INTERFACE_H_
#include "wxwidgets.hpp" #include "wxwidgets.hpp"
#include "input_manager.hpp"
#include <wx/dnd.h> #include <wx/dnd.h>
#include <wx/accel.h> #include <wx/accel.h>
#include <wx/taskbar.h> #include <wx/taskbar.h>
//#include "vlc_keys.h"
namespace wxvlc namespace wxvlc
...@@ -91,30 +91,17 @@ namespace wxvlc ...@@ -91,30 +91,17 @@ namespace wxvlc
void PrevStream(); void PrevStream();
void NextStream(); void NextStream();
wxBoxSizer *frame_sizer; wxBoxSizer *main_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;
void HideDiscFrame(bool layout = true); wxPanel *main_panel;
void ShowDiscFrame(bool show = true, bool layout = true); wxBoxSizer *panel_sizer;
wxPanel *disc_frame; wxStatusBar *statusbar;
wxBoxSizer *disc_sizer;
wxBitmapButton *disc_menu_button;
wxBitmapButton *disc_prev_button;
wxBitmapButton *disc_next_button;
wxFrame *extra_window; InputManager *input_manager;
vlc_bool_t b_extra; vlc_bool_t b_extra;
vlc_bool_t b_undock; wxPanel *extra_frame;
wxControl *volctrl; wxControl *volctrl;
...@@ -122,21 +109,18 @@ namespace wxvlc ...@@ -122,21 +109,18 @@ namespace wxvlc
Systray *p_systray; Systray *p_systray;
#endif #endif
wxTimer m_controls_timer; wxWindow *video_window;
wxTimer m_slider_timer;
private: private:
void SetupHotkeys(); void SetupHotkeys();
void CreateOurMenuBar(); void CreateOurMenuBar();
void CreateOurToolBar(); void CreateOurToolBar();
void CreateOurExtendedPanel(); void CreateOurExtendedPanel();
void CreateOurSlider();
void Open( int i_access_method ); void Open( int i_access_method );
/* Event handlers (these functions should _not_ be virtual) */ void SetIntfMinSize();
void OnControlsTimer(wxTimerEvent& WXUNUSED(event));
void OnSliderTimer(wxTimerEvent& WXUNUSED(event));
/* Event handlers (these functions should _not_ be virtual) */
void OnExit( wxCommandEvent& event ); void OnExit( wxCommandEvent& event );
void OnAbout( wxCommandEvent& event ); void OnAbout( wxCommandEvent& event );
...@@ -148,22 +132,16 @@ namespace wxvlc ...@@ -148,22 +132,16 @@ namespace wxvlc
void OnOpenSat( wxCommandEvent& event ); void OnOpenSat( wxCommandEvent& event );
void OnExtended( wxCommandEvent& event ); void OnExtended( wxCommandEvent& event );
//void OnUndock( wxCommandEvent& event );
void OnBookmarks( wxCommandEvent& event ); void OnBookmarks( wxCommandEvent& event );
void OnShowDialog( wxCommandEvent& event ); void OnShowDialog( wxCommandEvent& event );
void OnPlayStream( wxCommandEvent& event ); void OnPlayStream( wxCommandEvent& event );
void OnStopStream( wxCommandEvent& event ); void OnStopStream( wxCommandEvent& event );
void OnSliderUpdate( wxScrollEvent& event );
void OnPrevStream( wxCommandEvent& event ); void OnPrevStream( wxCommandEvent& event );
void OnNextStream( wxCommandEvent& event ); void OnNextStream( wxCommandEvent& event );
void OnSlowStream( wxCommandEvent& event ); void OnSlowStream( wxCommandEvent& event );
void OnFastStream( wxCommandEvent& event ); void OnFastStream( wxCommandEvent& event );
void OnDiscMenu( wxCommandEvent& event );
void OnDiscPrev( wxCommandEvent& event );
void OnDiscNext( wxCommandEvent& event );
void OnMenuOpen( wxMenuEvent& event ); void OnMenuOpen( wxMenuEvent& event );
#if defined( __WXMSW__ ) || defined( __WXMAC__ ) #if defined( __WXMSW__ ) || defined( __WXMAC__ )
...@@ -178,8 +156,6 @@ namespace wxvlc ...@@ -178,8 +156,6 @@ namespace wxvlc
Timer *timer; Timer *timer;
intf_thread_t *p_intf; intf_thread_t *p_intf;
wxWindow *video_window;
int i_old_playing_status; int i_old_playing_status;
/* For auto-generated menus */ /* For auto-generated menus */
...@@ -188,10 +164,9 @@ namespace wxvlc ...@@ -188,10 +164,9 @@ namespace wxvlc
wxMenu *p_video_menu; wxMenu *p_video_menu;
wxMenu *p_navig_menu; wxMenu *p_navig_menu;
/* utility dimensions */ /* Utility dimensions */
wxSize default_size; wxSize main_min_size;
wxSize extended_size; wxSize ext_min_size;
wxSize slider_size;
}; };
...@@ -247,12 +222,10 @@ namespace wxvlc ...@@ -247,12 +222,10 @@ namespace wxvlc
}; };
}; };
/// \todo Move this to class
void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& ); void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL ); wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL ); wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL ); wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL ); wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
#endif #endif
/*****************************************************************************
* 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: Clment 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 );
}
/*****************************************************************************
* 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
/*****************************************************************************
* 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: Clment 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 );
}
}
}
}
}
}
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include "timer.hpp" #include "timer.hpp"
#include "main_slider_manager.hpp" #include "input_manager.hpp"
#include "interface.hpp" #include "interface.hpp"
#include "vlc_meta.h" #include "vlc_meta.h"
...@@ -46,11 +46,6 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface ) ...@@ -46,11 +46,6 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface )
p_main_interface = _p_main_interface; p_main_interface = _p_main_interface;
b_init = 0; 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 */ /* Register callback for the intf-popupmenu variable */
playlist_t *p_playlist = playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
...@@ -77,8 +72,6 @@ Timer::~Timer() ...@@ -77,8 +72,6 @@ Timer::~Timer()
var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf ); var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
delete msm;
} }
/***************************************************************************** /*****************************************************************************
...@@ -104,61 +97,12 @@ void Timer::Notify() ...@@ -104,61 +97,12 @@ void Timer::Notify()
vlc_mutex_lock( &p_intf->change_lock ); vlc_mutex_lock( &p_intf->change_lock );
/* Call update */ /* Call update */
msm->Update(); p_main_interface->input_manager->Update();
vlc_value_t val; if( p_main_interface->input_manager->IsPlaying() )
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 )
{ {
p_intf->p_sys->b_playing = 0; /* Take care of the volume, etc... */
p_main_interface->TogglePlayButton( PAUSE_S ); p_main_interface->Update();
i_old_playing_status = PAUSE_S;
} }
/* Show the interface, if requested */ /* Show the interface, if requested */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* timer.hpp: Timer headers * timer.hpp: Timer headers
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team * 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> * Authors: Gildas Bazin <gbazin@videolan.org>
* *
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
namespace wxvlc namespace wxvlc
{ {
class MainSliderManager; class InputManager;
class Interface; class Interface;
class Timer: public wxTimer class Timer: public wxTimer
...@@ -38,16 +38,13 @@ namespace wxvlc ...@@ -38,16 +38,13 @@ namespace wxvlc
virtual void Notify(); virtual void Notify();
private: private:
//use wxWindow::IsShown instead
//vlc_bool_t b_slider_shown;
//vlc_bool_t b_disc_shown;
intf_thread_t *p_intf; intf_thread_t *p_intf;
Interface *p_main_interface; Interface *p_main_interface;
vlc_bool_t b_init; vlc_bool_t b_init;
int i_old_playing_status; int i_old_playing_status;
int i_old_rate; int i_old_rate;
MainSliderManager *msm; InputManager *msm;
}; };
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video.hpp: Embedded video management * video.hpp: Embedded video management
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team * 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> * Authors: Gildas Bazin <gbazin@videolan.org>
* *
......
...@@ -180,8 +180,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -180,8 +180,6 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_input = NULL; p_intf->p_sys->p_input = NULL;
p_intf->p_sys->i_playing = -1; 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_popup_menu = NULL;
p_intf->p_sys->p_video_window = NULL; p_intf->p_sys->p_video_window = NULL;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* wxwidgets.hpp: Common headers for the wxwidges interface * wxwidgets.hpp: Common headers for the wxwidges interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team * 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> * Authors: Gildas Bazin <gbazin@videolan.org>
* *
...@@ -137,11 +137,6 @@ struct intf_sys_t ...@@ -137,11 +137,6 @@ struct intf_sys_t
/* The input thread */ /* The input thread */
input_thread_t * p_input; 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 */ /* The messages window */
msg_subscription_t* p_sub; /* message bank subscription */ msg_subscription_t* p_sub; /* message bank subscription */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment