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 = \
menus.cpp \
timer.cpp \
video.cpp \
slider_manager.cpp \
main_slider_manager.cpp \
input_manager.cpp \
dialogs.cpp \
dialogs/open.cpp \
dialogs/streamout.cpp \
......@@ -41,8 +40,7 @@ EXTRA_DIST += \
extrapanel.hpp \
timer.hpp \
video.hpp \
slider_manager.hpp \
main_slider_manager.hpp \
input_manager.hpp \
dialogs/fileinfo.hpp \
dialogs/preferences.hpp \
dialogs/wizard.hpp \
......
......@@ -2,7 +2,7 @@
* vlm_slider_manager.cpp : Manage an input slider for a VLM stream
*****************************************************************************
* Copyright (C) 2000-2005 the VideoLAN team
* $Id: timer.cpp 11981 2005-08-03 15:03:23Z xtophe $
* $Id$
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
......@@ -32,11 +32,13 @@
* Constructor.
*****************************************************************************/
VLMSliderManager::VLMSliderManager( intf_thread_t *_p_intf,
VLMBroadcastStreamPanel *_p_sp ) :
SliderManager( _p_intf )
VLMBroadcastStreamPanel *_p_sp )
{
p_intf = _p_intf;
p_input = NULL;
p_sp = _p_sp;
_slider = p_sp->p_slider;
slider = p_sp->p_slider;
b_slider_free = VLC_TRUE;
time_string = wxU( "0:00:00 / 0:00:00");
......@@ -47,9 +49,75 @@ VLMSliderManager::~VLMSliderManager()
}
/*****************************************************************************
* Private methods.
* Public methods.
*****************************************************************************/
void VLMSliderManager::Update()
{
/* Update the input */
if( p_input == NULL )
{
UpdateInput();
if( p_input )
{
slider->SetValue( 0 );
UpdateButtons( VLC_TRUE );
}
}
else if( p_input->b_dead )
{
HideSlider();
UpdateButtons( VLC_FALSE );
vlc_object_release( p_input );
p_input = NULL;
}
if( p_input && !p_input->b_die )
{
vlc_value_t pos;
/* Really manage the slider */
var_Get( p_input, "position", &pos );
if( pos.f_float > 0.0 && ! IsShown() ) ShowSlider();
else if( pos.f_float <= 0.0 ) HideSlider();
if( IsPlaying() && IsShown() )
{
/* Update the slider if the user isn't dragging it. */
if( IsFree() )
{
char psz_time[ MSTRTIME_MAX_SIZE ];
char psz_total[ MSTRTIME_MAX_SIZE ];
vlc_value_t time;
mtime_t i_seconds;
/* Update the value */
if( pos.f_float >= 0.0 )
{
i_slider_pos = (int)(SLIDER_MAX_POS * pos.f_float);
slider->SetValue( i_slider_pos );
var_Get( p_input, "time", &time );
i_seconds = time.i_time / 1000000;
secstotimestr ( psz_time, i_seconds );
var_Get( p_input, "length", &time );
i_seconds = time.i_time / 1000000;
secstotimestr ( psz_total, i_seconds );
UpdateTime( psz_time, psz_total );
}
}
}
}
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
void VLMSliderManager::UpdateInput()
{
if( p_sp->GetStream()->p_media->i_instance == 0 )
......@@ -75,18 +143,18 @@ void VLMSliderManager::UpdateButtons( vlc_bool_t b_play )
vlc_bool_t VLMSliderManager::IsShown()
{
return _slider->IsEnabled();
return slider->IsEnabled();
}
void VLMSliderManager::ShowSlider()
{
_slider->Enable();
slider->Enable();
}
void VLMSliderManager::HideSlider()
{
_slider->SetValue( 0 );
_slider->Disable();
slider->SetValue( 0 );
slider->Disable();
UpdateTime( "0:00:00", "0:00:00" );
}
......
......@@ -2,7 +2,7 @@
* vlm_slider_manager.hpp: Header for slider_manager
*****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team
* $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $
* $Id$
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
......@@ -24,7 +24,7 @@
#ifndef _VLM_SLIDER_MANAGER_H_
#define _VLM_SLIDER_MANAGER_H_
#include "slider_manager.hpp"
#include "wxwidgets.hpp"
namespace wxvlc
{
......@@ -32,7 +32,7 @@ namespace wxvlc
/**
* This class manages a slider corresponding to the main input
*/
class VLMSliderManager: public SliderManager
class VLMSliderManager
{
public:
VLMSliderManager( intf_thread_t *, VLMBroadcastStreamPanel * );
......@@ -40,6 +40,7 @@ namespace wxvlc
wxString time_string;
void Update();
void ProcessUpdate( wxScrollEvent & );
protected:
......@@ -56,6 +57,11 @@ namespace wxvlc
virtual void ShowSlider();
VLMBroadcastStreamPanel * p_sp;
intf_thread_t * p_intf;
input_thread_t *p_input;
wxSlider *slider; ///< Slider for this input
int i_slider_pos; ///< Current slider position
};
};
......
......@@ -150,7 +150,6 @@ static const struct filter vfilters[] =
{ "clone", N_("Image clone"), N_("Creates several clones of the image") },
{ "distort", N_("Distortion"), N_("Adds distorsion effects") },
{ "invert", N_("Image inversion") , N_("Inverts the image colors") },
{ "crop", N_("Image cropping"), N_("Crops the image") },
{ "motionblur", N_("Blurring"), N_("Creates a motion blurring on the image") },
{ "transform", N_("Transformation"), N_("Rotates or flips the image") },
{ "magnify", N_("Magnify"), N_("Magnifies part of the image") },
......@@ -311,7 +310,7 @@ wxPanel *ExtraPanel::VideoPanel( wxWindow *parent )
{
wxCheckBox *box = new wxCheckBox( panel, Filter0_Event + i,
wxU( _( vfilters[i].psz_name ) ) );
t_col_sizer->Add( box, 0, wxALL, 4 );
t_col_sizer->Add( box, 0, wxALL, 2 );
box->SetToolTip( wxU( _( vfilters[i].psz_help ) ) );
}
......@@ -1215,13 +1214,11 @@ ExtraWindow::ExtraWindow( intf_thread_t *_p_intf, wxWindow *p_parent,
wxFrame( p_parent, -1, wxU(_("Extended controls")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_FRAME_STYLE )
{
fprintf(stderr,"Creating extrawindow\n");
p_intf = _p_intf;
SetIcon( *p_intf->p_sys->p_icon );
wxBoxSizer *window_sizer = new wxBoxSizer( wxVERTICAL );
SetSizer( window_sizer );
// panel = new ExtraPanel( p_intf, this );//_extra_panel;
panel = _extra_panel;
window_sizer->Add( panel );
......
......@@ -2,7 +2,7 @@
* extrapanel.hpp: Headers for the extra panel window
*****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team
* $Id: wxwidgets.h 12670 2005-09-25 11:16:31Z zorglub $
* $Id$
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
......
This diff is collapsed.
/*****************************************************************************
* slider_manager.hpp: Header for slider_manager
* input_manager.hpp: Header for input_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>
* 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
......@@ -21,50 +22,67 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef _SLIDER_MANAGER_H_
#define _SLIDER_MANAGER_H_
#ifndef _INPUT_MANAGER_H_
#define _INPUT_MANAGER_H_
#include "wxwidgets.hpp"
namespace wxvlc
{
class Interface;
/**
* This class manages a slider corresponding to an input
* This class is abstract, it needs to be subclassed
* This class manages all the controls related to the input
*/
class SliderManager
class InputManager : public wxPanel
{
public:
SliderManager( intf_thread_t *p_intf );
virtual ~SliderManager();
InputManager( intf_thread_t *, Interface *, wxWindow * );
virtual ~InputManager();
void Update();
vlc_bool_t IsPlaying();
protected:
virtual void UpdateInput() = 0;
virtual void UpdateNowPlaying() {};
virtual void UpdateButtons( vlc_bool_t ) {};
virtual void UpdateDiscButtons() {}
virtual void UpdateTime( char *, char *) = 0;
void UpdateInput();
void UpdateNowPlaying();
void UpdateButtons( vlc_bool_t );
void UpdateDiscButtons();
void UpdateTime();
void HideSlider();
void ShowSlider( bool show = true );
virtual vlc_bool_t IsShown() = 0;
virtual vlc_bool_t IsFree() = 0;
virtual vlc_bool_t IsPlaying() = 0;
void OnSliderUpdate( wxScrollEvent& event );
virtual void HideSlider() {};
virtual void ShowSlider() {};
void OnDiscMenu( wxCommandEvent& event );
void OnDiscPrev( wxCommandEvent& event );
void OnDiscNext( wxCommandEvent& event );
virtual void HideControls() {};
virtual void DontHide() {};
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;
wxSlider *_slider; ///< Slider for this 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:
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
};
};
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* interface.hpp: Main interface headers
*****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team
* $Id: wxwidgets.h 12670 2005-09-25 11:16:31Z zorglub $
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
......@@ -25,11 +25,11 @@
#define _WXVLC_INTERFACE_H_
#include "wxwidgets.hpp"
#include "input_manager.hpp"
#include <wx/dnd.h>
#include <wx/accel.h>
#include <wx/taskbar.h>
//#include "vlc_keys.h"
namespace wxvlc
......@@ -91,30 +91,17 @@ namespace wxvlc
void PrevStream();
void NextStream();
wxBoxSizer *frame_sizer;
wxStatusBar *statusbar;
void HideSlider(bool layout = true);
void ShowSlider(bool show = true, bool layout = true);
wxSlider *slider;
wxWindow *slider_frame;
wxBoxSizer *slider_sizer;
wxPanel *extra_frame;
wxBoxSizer *main_sizer;
void HideDiscFrame(bool layout = true);
void ShowDiscFrame(bool show = true, bool layout = true);
wxPanel *main_panel;
wxBoxSizer *panel_sizer;
wxPanel *disc_frame;
wxBoxSizer *disc_sizer;
wxBitmapButton *disc_menu_button;
wxBitmapButton *disc_prev_button;
wxBitmapButton *disc_next_button;
wxStatusBar *statusbar;
wxFrame *extra_window;
InputManager *input_manager;
vlc_bool_t b_extra;
vlc_bool_t b_undock;
vlc_bool_t b_extra;
wxPanel *extra_frame;
wxControl *volctrl;
......@@ -122,21 +109,18 @@ namespace wxvlc
Systray *p_systray;
#endif
wxTimer m_controls_timer;
wxTimer m_slider_timer;
wxWindow *video_window;
private:
void SetupHotkeys();
void CreateOurMenuBar();
void CreateOurToolBar();
void CreateOurExtendedPanel();
void CreateOurSlider();
void Open( int i_access_method );
/* Event handlers (these functions should _not_ be virtual) */
void OnControlsTimer(wxTimerEvent& WXUNUSED(event));
void OnSliderTimer(wxTimerEvent& WXUNUSED(event));
void SetIntfMinSize();
/* Event handlers (these functions should _not_ be virtual) */
void OnExit( wxCommandEvent& event );
void OnAbout( wxCommandEvent& event );
......@@ -148,22 +132,16 @@ namespace wxvlc
void OnOpenSat( wxCommandEvent& event );
void OnExtended( wxCommandEvent& event );
//void OnUndock( wxCommandEvent& event );
void OnBookmarks( wxCommandEvent& event );
void OnShowDialog( wxCommandEvent& event );
void OnPlayStream( wxCommandEvent& event );
void OnStopStream( wxCommandEvent& event );
void OnSliderUpdate( wxScrollEvent& event );
void OnPrevStream( wxCommandEvent& event );
void OnNextStream( wxCommandEvent& event );
void OnSlowStream( wxCommandEvent& event );
void OnFastStream( wxCommandEvent& event );
void OnDiscMenu( wxCommandEvent& event );
void OnDiscPrev( wxCommandEvent& event );
void OnDiscNext( wxCommandEvent& event );
void OnMenuOpen( wxMenuEvent& event );
#if defined( __WXMSW__ ) || defined( __WXMAC__ )
......@@ -178,8 +156,6 @@ namespace wxvlc
Timer *timer;
intf_thread_t *p_intf;
wxWindow *video_window;
int i_old_playing_status;
/* For auto-generated menus */
......@@ -188,10 +164,9 @@ namespace wxvlc
wxMenu *p_video_menu;
wxMenu *p_navig_menu;
/* utility dimensions */
wxSize default_size;
wxSize extended_size;
wxSize slider_size;
/* Utility dimensions */
wxSize main_min_size;
wxSize ext_min_size;
};
......@@ -247,12 +222,10 @@ namespace wxvlc
};
};
/// \todo Move this to class
void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
#endif
/*****************************************************************************
* 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 @@
* Preamble
*****************************************************************************/
#include "timer.hpp"
#include "main_slider_manager.hpp"
#include "input_manager.hpp"
#include "interface.hpp"
#include "vlc_meta.h"
......@@ -46,11 +46,6 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface )
p_main_interface = _p_main_interface;
b_init = 0;
msm = new MainSliderManager( p_intf, p_main_interface );
i_old_playing_status = PAUSE_S;
i_old_rate = INPUT_RATE_DEFAULT;
/* Register callback for the intf-popupmenu variable */
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
......@@ -77,8 +72,6 @@ Timer::~Timer()
var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
vlc_object_release( p_playlist );
}
delete msm;
}
/*****************************************************************************
......@@ -104,61 +97,12 @@ void Timer::Notify()
vlc_mutex_lock( &p_intf->change_lock );
/* Call update */
msm->Update();
p_main_interface->input_manager->Update();
vlc_value_t val;
input_thread_t *p_input = p_intf->p_sys->p_input;
if( p_intf->p_sys->p_input )
{
if( !p_intf->p_sys->p_input->b_die )
{
/* Take care of the volume, etc... */
p_main_interface->Update();
/* Manage Playing status */
var_Get( p_input, "state", &val );
if( i_old_playing_status != val.i_int )
{
if( val.i_int == PAUSE_S )
{
p_main_interface->TogglePlayButton( PAUSE_S );
}
else
{
p_main_interface->TogglePlayButton( PLAYING_S );
}
#ifdef wxHAS_TASK_BAR_ICON
if( p_main_interface->p_systray )
{
if( val.i_int == PAUSE_S )
{
p_main_interface->p_systray->UpdateTooltip( wxU(p_intf->p_sys->p_input->input.p_item->psz_name) + wxString(wxT(" - ")) + wxU(_("Paused")));
}
else
{
p_main_interface->p_systray->UpdateTooltip( wxU(p_intf->p_sys->p_input->input.p_item->psz_name) + wxString(wxT(" - ")) + wxU(_("Playing")));
}
}
#endif
i_old_playing_status = val.i_int;
}
/* Manage Speed status */
var_Get( p_input, "rate", &val );
if( i_old_rate != val.i_int )
{
p_main_interface->statusbar->SetStatusText(
wxString::Format(wxT("x%.2f"),
(float)INPUT_RATE_DEFAULT / val.i_int ), 1 );
i_old_rate = val.i_int;
}
}
}
else if( p_intf->p_sys->b_playing && !p_intf->b_die )
if( p_main_interface->input_manager->IsPlaying() )
{
p_intf->p_sys->b_playing = 0;
p_main_interface->TogglePlayButton( PAUSE_S );
i_old_playing_status = PAUSE_S;
/* Take care of the volume, etc... */
p_main_interface->Update();
}
/* Show the interface, if requested */
......
......@@ -2,7 +2,7 @@
* timer.hpp: Timer headers
*****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team
* $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
......@@ -25,7 +25,7 @@
namespace wxvlc
{
class MainSliderManager;
class InputManager;
class Interface;
class Timer: public wxTimer
......@@ -38,16 +38,13 @@ namespace wxvlc
virtual void Notify();
private:
//use wxWindow::IsShown instead
//vlc_bool_t b_slider_shown;
//vlc_bool_t b_disc_shown;
intf_thread_t *p_intf;
Interface *p_main_interface;
vlc_bool_t b_init;
int i_old_playing_status;
int i_old_rate;
MainSliderManager *msm;
InputManager *msm;
};
}
......@@ -2,7 +2,7 @@
* video.hpp: Embedded video management
*****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team
* $Id: wxwidgets.h 12670 2005-09-25 11:16:31Z zorglub $
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
......
......@@ -180,8 +180,6 @@ static int Open( vlc_object_t *p_this )
p_intf->p_sys->p_input = NULL;
p_intf->p_sys->i_playing = -1;
p_intf->p_sys->b_slider_free = 1;
p_intf->p_sys->i_slider_pos = p_intf->p_sys->i_slider_oldpos = 0;
p_intf->p_sys->p_popup_menu = NULL;
p_intf->p_sys->p_video_window = NULL;
......
......@@ -2,7 +2,7 @@
* wxwidgets.hpp: Common headers for the wxwidges interface
*****************************************************************************
* Copyright (C) 1999-2005 the VideoLAN team
* $Id: wxwidgets.h 12502 2005-09-09 19:38:01Z gbazin $
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
*
......@@ -137,11 +137,6 @@ struct intf_sys_t
/* The input thread */
input_thread_t * p_input;
/* The slider */
int i_slider_pos; /* slider position */
int i_slider_oldpos; /* previous position */
vlc_bool_t b_slider_free; /* slider status */
/* The messages window */
msg_subscription_t* p_sub; /* message bank subscription */
......
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