]> git.sesse.net Git - vlc/blob - modules/gui/skins2/commands/cmd_callbacks.hpp
skins2: replace polling with callbacks
[vlc] / modules / gui / skins2 / commands / cmd_callbacks.hpp
1 /*****************************************************************************
2  * cmd_callbacks.hpp
3  *****************************************************************************
4  * Copyright (C) 2009 the VideoLAN team
5  * $Id$
6  *
7  * Author: Erwan Tulou      <erwan10 aT videolan doT org >
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef CMD_CALLBACKS_HPP
25 #define CMD_CALLBACKS_HPP
26
27 #include "cmd_generic.hpp"
28 #include "../src/vlcproc.hpp"
29
30
31 #define ADD_COMMAND( label )                                           \
32 class Cmd_##label : public CmdGeneric                                  \
33 {                                                                      \
34     public:                                                            \
35         Cmd_##label( intf_thread_t *pIntf,                             \
36             vlc_object_t *pObj, vlc_value_t newVal )                   \
37             : CmdGeneric( pIntf ), m_pObj( pObj ), m_newVal( newVal )  \
38         {                                                              \
39             if( m_pObj )                                               \
40                 vlc_object_hold( m_pObj );                             \
41         }                                                              \
42         virtual ~Cmd_##label()                                         \
43         {                                                              \
44             if( m_pObj )                                               \
45                 vlc_object_release( m_pObj );                          \
46         }                                                              \
47                                                                        \
48         virtual void execute()                                         \
49         {                                                              \
50             if( !m_pObj )                                              \
51                 return;                                                \
52                                                                        \
53             VlcProc* p_VlcProc = VlcProc::instance( getIntf() );       \
54             p_VlcProc->on_##label( m_pObj, m_newVal );                 \
55                                                                        \
56             vlc_object_release( m_pObj );                              \
57             m_pObj =  NULL;                                            \
58         }                                                              \
59                                                                        \
60         virtual string getType() const { return #label ; }              \
61                                                                        \
62     private:                                                           \
63         vlc_object_t* m_pObj;                                          \
64         vlc_value_t   m_newVal;                                        \
65 };
66
67
68 ADD_COMMAND( item_current_changed )
69 ADD_COMMAND( intf_event_changed )
70 ADD_COMMAND( bit_rate_changed )
71 ADD_COMMAND( sample_rate_changed )
72
73 ADD_COMMAND( random_changed )
74 ADD_COMMAND( loop_changed )
75 ADD_COMMAND( repeat_changed )
76
77 ADD_COMMAND( volume_changed )
78
79 ADD_COMMAND( audio_filter_changed )
80
81 #undef ADD_COMMAND
82
83 #endif