Commit 6e006c8a authored by Antoine Cellerier's avatar Antoine Cellerier

change the speaker into a mute/unmute button

(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)
parent 2ecc8ed4
/* 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$% ",
" .. "};
......@@ -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.
......
......@@ -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 );
......
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