]> git.sesse.net Git - vlc/commitdiff
change the speaker into a mute/unmute button
authorAntoine Cellerier <dionoea@videolan.org>
Thu, 31 Mar 2005 17:02:44 +0000 (17:02 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Thu, 31 Mar 2005 17:02:44 +0000 (17:02 +0000)
(only works if something is playing ... and we have to fix the bug where
the image doesn't get updated like for the play/pause button)

modules/gui/wxwindows/bitmaps/speaker_mute.xpm [new file with mode: 0644]
modules/gui/wxwindows/interface.cpp
modules/gui/wxwindows/wxwindows.h

diff --git a/modules/gui/wxwindows/bitmaps/speaker_mute.xpm b/modules/gui/wxwindows/bitmaps/speaker_mute.xpm
new file mode 100644 (file)
index 0000000..90cc73b
--- /dev/null
@@ -0,0 +1,69 @@
+/* XPM */
+static char * speaker_mute_xpm[] = {
+"16 16 50 1",
+"      c None",
+".     c #000000",
+"+     c #FF0000",
+"@     c #FB0400",
+"#     c #E81717",
+"$     c #880000",
+"%     c #8D7272",
+"&     c #966900",
+"*     c #FFF700",
+"=     c #837B7B",
+"-     c #966969",
+";     c #FF1B1B",
+">     c #DA2400",
+",     c #FFFF00",
+"'     c #FFFFFF",
+")     c #FFF3F3",
+"!     c #D22D2D",
+"~     c #808000",
+"{     c #B64800",
+"]     c #FF2424",
+"^     c #FFDF00",
+"/     c #808080",
+"(     c #A55900",
+"_     c #FF9797",
+":     c #FF0300",
+"<     c #FF3939",
+"[     c #230000",
+"}     c #867800",
+"|     c #FF9999",
+"1     c #FF0900",
+"2     c #DD0000",
+"3     c #FF9292",
+"4     c #D82727",
+"5     c #807E7E",
+"6     c #4C0000",
+"7     c #650000",
+"8     c #DB0000",
+"9     c #FF6D6D",
+"0     c #FF5454",
+"a     c #FF6565",
+"b     c #817D7D",
+"c     c #FFFBFB",
+"d     c #FF7474",
+"e     c #E11D1D",
+"f     c #2D0000",
+"g     c #837B00",
+"h     c #FF8A8A",
+"i     c #FA0404",
+"j     c #F70000",
+"k     c #E81700",
+"         ..     ",
+"     +++@#$%    ",
+"    ++++++++    ",
+"   +++&*=- ;+   ",
+"  +++>,'. ')!+  ",
+" ++~{+]^. ''/++ ",
+" +(' _:<[.''/ + ",
+" +}, ,|12 .'/ + ",
+" +}, ',3+45'/ + ",
+" +6~/,',789'/ + ",
+" ++..~,'. 0ab++ ",
+"  ++ .~,. cde+  ",
+"   ++ fg=-h;+   ",
+"    +++++++i    ",
+"     +++jk$%    ",
+"         ..     "};
index 4072b125599b14a7b8ec21654da03223b9f3e40f..92536ca05b3ecd6d5d554f0858d6324c89356b06 100644 (file)
@@ -43,6 +43,7 @@
 #include "bitmaps/fast.xpm"
 #include "bitmaps/playlist.xpm"
 #include "bitmaps/speaker.xpm"
+#include "bitmaps/speaker_mute.xpm"
 
 #define TOOLBAR_BMP_WIDTH 16
 #define TOOLBAR_BMP_HEIGHT 16
@@ -142,6 +143,7 @@ enum
     NextStream_Event,
     SlowStream_Event,
     FastStream_Event,
+    Mute_Event,
 
     DiscMenu_Event,
     DiscPrev_Event,
@@ -192,6 +194,7 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
     EVT_MENU(NextStream_Event, Interface::OnNextStream)
     EVT_MENU(SlowStream_Event, Interface::OnSlowStream)
     EVT_MENU(FastStream_Event, Interface::OnFastStream)
+    EVT_MENU(Mute_Event, Interface::OnMute)
 
     /* Disc Buttons events */
     EVT_BUTTON(DiscMenu_Event, Interface::OnDiscMenu)
@@ -433,15 +436,12 @@ public:
     VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent, wxGauge ** );
     virtual ~VLCVolCtrl() {};
 
-    virtual void OnPaint( wxPaintEvent &event );
-
   private:
     DECLARE_EVENT_TABLE()
     int i_y_offset;
 };
 
 BEGIN_EVENT_TABLE(VLCVolCtrl, wxControl)
-   EVT_PAINT(VLCVolCtrl::OnPaint)
 END_EVENT_TABLE()
 
 #if defined(__WXGTK__)
@@ -459,13 +459,6 @@ VLCVolCtrl::VLCVolCtrl( intf_thread_t *p_intf, wxWindow *p_parent,
                                  wxSize( 44, TOOLBAR_BMP_HEIGHT ) );
 }
 
-void VLCVolCtrl::OnPaint( wxPaintEvent &evt )
-{
-    wxPaintDC dc( this );
-    wxBitmap mPlayBitmap( speaker_xpm );
-    dc.DrawBitmap( mPlayBitmap, 0, i_y_offset, TRUE );
-}
-
 void Interface::CreateOurToolBar()
 {
 #define HELP_OPEN N_("Open")
@@ -477,6 +470,7 @@ void Interface::CreateOurToolBar()
 #define HELP_PLN N_("Next playlist item")
 #define HELP_SLOW N_("Play slower")
 #define HELP_FAST N_("Play faster")
+#define HELP_MUTE N_("Toggle mute")
 
     wxLogNull LogDummy; /* Hack to suppress annoying log message on the win32
                          * version because we don't include wx.rc */
@@ -515,6 +509,8 @@ void Interface::CreateOurToolBar()
 
     toolbar->AddControl( p_dummy_ctrl );
 
+    toolbar->AddTool( Mute_Event, wxT(""), wxBitmap( speaker_xpm ),
+                      wxU(_(HELP_MUTE)) );
     VLCVolCtrl *sound_control = new VLCVolCtrl( p_intf, toolbar, &volctrl );
     toolbar->AddControl( sound_control );
 
@@ -1201,6 +1197,31 @@ void Interface::OnDiscNext( wxCommandEvent& WXUNUSED(event) )
     }
 }
 
+void Interface::OnMute( wxCommandEvent& WXUNUSED(event) )
+{
+    int i_volume = 1;
+    aout_VolumeMute( p_intf, (audio_volume_t *)&i_volume );
+
+    wxToolBarToolBase *p_tool = (wxToolBarToolBase *)
+        GetToolBar()->GetToolClientData( Mute_Event );
+    if( !p_tool ) return;
+
+    if( i_volume >= 0 )
+    {
+        p_tool->SetNormalBitmap( wxBitmap( speaker_xpm ) );
+        p_tool->SetLabel( wxU(_("")) );
+        p_tool->SetShortHelp( wxU(_(HELP_MUTE)) );
+    }
+    else
+    {
+        p_tool->SetNormalBitmap( wxBitmap( speaker_mute_xpm ) );
+        p_tool->SetLabel( wxU(_("")) );
+        p_tool->SetShortHelp( wxU(_(HELP_MUTE)) );
+    }
+
+    GetToolBar()->Realize();
+}
+
 #if wxUSE_DRAG_AND_DROP
 /*****************************************************************************
  * Definition of DragAndDrop class.
index 8cadcece5d33e4a464c9930e90f9e6ad8fa88182..1614a1778ecf503c346449beb431f8b9aeb630a6 100644 (file)
@@ -376,6 +376,7 @@ private:
     void OnNextStream( wxCommandEvent& event );
     void OnSlowStream( wxCommandEvent& event );
     void OnFastStream( wxCommandEvent& event );
+    void OnMute( wxCommandEvent& event );
 
     void OnDiscMenu( wxCommandEvent& event );
     void OnDiscPrev( wxCommandEvent& event );