]> git.sesse.net Git - vlc/commitdiff
* modules/gui/wxwindows/*: added a volume control.
authorGildas Bazin <gbazin@videolan.org>
Thu, 12 Jun 2003 21:28:39 +0000 (21:28 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 12 Jun 2003 21:28:39 +0000 (21:28 +0000)
modules/gui/wxwindows/interface.cpp
modules/gui/wxwindows/timer.cpp
modules/gui/wxwindows/wxwindows.h

index fba0f13e24f2c2e7d918f6d4030071677dfed056..a5360b006017804a415d0fe67fa51431763fd586 100644 (file)
@@ -2,7 +2,7 @@
  * interface.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * 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>
  *
@@ -30,6 +30,7 @@
 #include <stdio.h>
 
 #include <vlc/vlc.h>
+#include <vlc/aout.h>
 
 #ifdef WIN32                                                 /* mingw32 hack */
 #undef Yield
@@ -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.
  *****************************************************************************/
@@ -219,6 +242,7 @@ Interface::~Interface()
     /* Clean up */
     if( p_open_dialog ) delete p_open_dialog;
     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()
 
 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->SetAutoLayout( TRUE );
+    wxBoxSizer *frame_sizer =
+        new wxBoxSizer( wxHORIZONTAL );
 
     /* Create static box to surround the slider */
     slider_box = new wxStaticBox( slider_frame, -1, wxT("") );
@@ -391,15 +417,22 @@ void Interface::CreateOurSlider()
     /* Create sizer for slider frame */
     wxStaticBoxSizer *slider_sizer =
         new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
-    slider_frame->SetSizer( slider_sizer );
     slider_sizer->SetMinSize( -1, 50 );
 
     /* Create slider */
     slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
                            SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
-    slider_sizer->Add( slider, 1, wxGROW | wxALL, 5 );
-    slider_sizer->Layout();
-    slider_sizer->SetSizeHints(slider_frame);
+    slider_sizer->Add( slider, 1, wxEXPAND | wxALL, 5 );
+
+
+    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 */
     slider_frame->Hide();
@@ -851,3 +884,25 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
     return TRUE;
 }
 #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 ) );
+}
index 20f8c06ac7b4c69db0b0fbad6240e08f62c37fe8..319166b997509f2f082d6a7da441899ca6c4ed6e 100644 (file)
@@ -2,7 +2,7 @@
  * timer.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * 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>
  *
@@ -30,6 +30,7 @@
 #include <stdio.h>
 
 #include <vlc/vlc.h>
+#include <vlc/aout.h>
 
 #ifdef WIN32                                                 /* mingw32 hack */
 #undef Yield
@@ -143,6 +144,12 @@ void Timer::Notify()
 
             p_main_interface->TogglePlayButton( 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 */
index 4c4df1ba97c3dcf57e182597ef9dbefe2bb80bbb..d31deae7b1269aecf31074adc1ae8c7626d476be 100644 (file)
@@ -2,7 +2,7 @@
  * wxwindows.h: private wxWindows interface description
  *****************************************************************************
  * 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>
  *
@@ -27,6 +27,7 @@
 #include <wx/spinctrl.h>
 #include <wx/dnd.h>
 #include <wx/treectrl.h>
+#include <wx/gauge.h>
 
 class Playlist;
 class Messages;
@@ -123,6 +124,8 @@ public:
     wxWindow    *slider_frame;
     wxStaticBox *slider_box;
 
+    wxGauge     *volctrl;
+
     /* So we don't recreate the open dialog box each time
      * (and keep the last settings) */
     OpenDialog  *p_open_dialog;