Commit e3684cac authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/*: added a volume control.
parent c15d6f5e
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* interface.cpp : wxWindows plugin for vlc * interface.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: interface.cpp,v 1.37 2003/06/05 21:22:27 gbazin Exp $ * $Id: interface.cpp,v 1.38 2003/06/12 21:28:39 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdio.h> #include <stdio.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/aout.h>
#ifdef WIN32 /* mingw32 hack */ #ifdef WIN32 /* mingw32 hack */
#undef Yield #undef Yield
...@@ -92,6 +93,28 @@ private: ...@@ -92,6 +93,28 @@ private:
}; };
class wxVolCtrl: public wxGauge
{
public:
/* Constructor */
wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id );
virtual ~wxVolCtrl() {};
void Change( int i_volume );
void OnChange( wxMouseEvent& event );
private:
intf_thread_t *p_intf;
DECLARE_EVENT_TABLE();
};
BEGIN_EVENT_TABLE(wxVolCtrl, wxWindow)
/* Mouse events */
EVT_LEFT_DOWN(wxVolCtrl::OnChange)
END_EVENT_TABLE()
/***************************************************************************** /*****************************************************************************
* Event Table. * Event Table.
*****************************************************************************/ *****************************************************************************/
...@@ -219,6 +242,7 @@ Interface::~Interface() ...@@ -219,6 +242,7 @@ Interface::~Interface()
/* Clean up */ /* Clean up */
if( p_open_dialog ) delete p_open_dialog; if( p_open_dialog ) delete p_open_dialog;
if( p_prefs_dialog ) p_prefs_dialog->Destroy(); if( p_prefs_dialog ) p_prefs_dialog->Destroy();
if( p_intf->p_sys->p_icon ) delete p_intf->p_sys->p_icon;
} }
/***************************************************************************** /*****************************************************************************
...@@ -381,9 +405,11 @@ void Interface::CreateOurToolBar() ...@@ -381,9 +405,11 @@ void Interface::CreateOurToolBar()
void Interface::CreateOurSlider() void Interface::CreateOurSlider()
{ {
/* Create a new frame containing the slider */ /* Create a new frame and sizer containing the slider */
slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize ); slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxDefaultSize );
slider_frame->SetAutoLayout( TRUE ); slider_frame->SetAutoLayout( TRUE );
wxBoxSizer *frame_sizer =
new wxBoxSizer( wxHORIZONTAL );
/* Create static box to surround the slider */ /* Create static box to surround the slider */
slider_box = new wxStaticBox( slider_frame, -1, wxT("") ); slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
...@@ -391,15 +417,22 @@ void Interface::CreateOurSlider() ...@@ -391,15 +417,22 @@ void Interface::CreateOurSlider()
/* Create sizer for slider frame */ /* Create sizer for slider frame */
wxStaticBoxSizer *slider_sizer = wxStaticBoxSizer *slider_sizer =
new wxStaticBoxSizer( slider_box, wxHORIZONTAL ); new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
slider_frame->SetSizer( slider_sizer );
slider_sizer->SetMinSize( -1, 50 ); slider_sizer->SetMinSize( -1, 50 );
/* Create slider */ /* Create slider */
slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0, slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize ); SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
slider_sizer->Add( slider, 1, wxGROW | wxALL, 5 ); slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
slider_sizer->Layout();
slider_sizer->SetSizeHints(slider_frame);
volctrl = new wxVolCtrl( p_intf, slider_frame, -1 );
/* Add everything to the frame */
frame_sizer->Add( slider_sizer, 1, wxEXPAND | wxBOTTOM, 5 );
frame_sizer->Add( volctrl, 0, wxEXPAND | wxALL, 5 );
slider_frame->SetSizer( frame_sizer );
frame_sizer->Layout();
frame_sizer->SetSizeHints(slider_frame);
/* Hide the slider by default */ /* Hide the slider by default */
slider_frame->Hide(); slider_frame->Hide();
...@@ -851,3 +884,25 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord, ...@@ -851,3 +884,25 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
return TRUE; return TRUE;
} }
#endif #endif
/*****************************************************************************
* Definition of wxVolCtrl class.
*****************************************************************************/
wxVolCtrl::wxVolCtrl( intf_thread_t *_p_intf, wxWindow* parent, wxWindowID id )
: wxGauge( parent, id, 200, wxDefaultPosition, wxDefaultSize, wxGA_VERTICAL )
{
p_intf = _p_intf;
}
void wxVolCtrl::OnChange( wxMouseEvent& event )
{
int i_volume = (GetRect().height - event.GetY()) * 200 / GetRect().height;
Change( i_volume );
}
void wxVolCtrl::Change( int i_volume )
{
aout_VolumeSet( p_intf, i_volume * AOUT_VOLUME_MAX / 200 );
SetValue( i_volume );
SetToolTip( wxString::Format(wxU(_("Volume")) + wxT(" %d"), i_volume ) );
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* timer.cpp : wxWindows plugin for vlc * timer.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: timer.cpp,v 1.22 2003/06/05 21:22:28 gbazin Exp $ * $Id: timer.cpp,v 1.23 2003/06/12 21:28:39 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <stdio.h> #include <stdio.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/aout.h>
#ifdef WIN32 /* mingw32 hack */ #ifdef WIN32 /* mingw32 hack */
#undef Yield #undef Yield
...@@ -143,6 +144,12 @@ void Timer::Notify() ...@@ -143,6 +144,12 @@ void Timer::Notify()
p_main_interface->TogglePlayButton( PLAYING_S ); p_main_interface->TogglePlayButton( PLAYING_S );
i_old_playing_status = PLAYING_S; i_old_playing_status = PLAYING_S;
/* Take care of the volume */
audio_volume_t i_volume;
aout_VolumeGet( p_intf, &i_volume );
p_main_interface->volctrl->SetValue( i_volume * 200 /
AOUT_VOLUME_MAX );
} }
/* control buttons for free pace streams */ /* control buttons for free pace streams */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* wxwindows.h: private wxWindows interface description * wxwindows.h: private wxWindows interface description
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: wxwindows.h,v 1.35 2003/06/05 21:22:28 gbazin Exp $ * $Id: wxwindows.h,v 1.36 2003/06/12 21:28:39 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <wx/spinctrl.h> #include <wx/spinctrl.h>
#include <wx/dnd.h> #include <wx/dnd.h>
#include <wx/treectrl.h> #include <wx/treectrl.h>
#include <wx/gauge.h>
class Playlist; class Playlist;
class Messages; class Messages;
...@@ -123,6 +124,8 @@ public: ...@@ -123,6 +124,8 @@ public:
wxWindow *slider_frame; wxWindow *slider_frame;
wxStaticBox *slider_box; wxStaticBox *slider_box;
wxGauge *volctrl;
/* So we don't recreate the open dialog box each time /* So we don't recreate the open dialog box each time
* (and keep the last settings) */ * (and keep the last settings) */
OpenDialog *p_open_dialog; OpenDialog *p_open_dialog;
......
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