]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vout_manager.hpp
skins(Win32): add hotkeys support in fullscreen mode
[vlc] / modules / gui / skins2 / src / vout_manager.hpp
1 /*****************************************************************************
2  * vout_manager.hpp
3  *****************************************************************************
4  * Copyright (C) 2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Erwan Tulou < brezhoneg1 at yahoo.fr r>
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 along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef VOUTMANAGER_HPP
25 #define VOUTMANAGER_HPP
26
27 #include <vector>
28
29 #include <vlc_vout.h>
30 #include <vlc_vout_window.h>
31 #include "../utils/position.hpp"
32 #include "../commands/cmd_generic.hpp"
33 #include "../controls/ctrl_video.hpp"
34 #include "../events/evt_key.hpp"
35
36 class VarBool;
37 class GenericWindow;
38
39 #include <stdio.h>
40
41 class SavedWnd
42 {
43 public:
44     SavedWnd( vout_window_t* pWnd, VoutWindow* pVoutWindow = NULL,
45                CtrlVideo* pCtrlVideo = NULL, int height = 0, int width = 0 )
46             : pWnd( pWnd ), pVoutWindow( pVoutWindow ),
47               pCtrlVideo( pCtrlVideo ), height( height ), width( width ) { }
48     ~SavedWnd() { }
49
50     vout_window_t* pWnd;
51     VoutWindow *pVoutWindow;
52     CtrlVideo *pCtrlVideo;
53     int height;
54     int width;
55 };
56
57 class VoutMainWindow: public GenericWindow
58 {
59 public:
60
61     VoutMainWindow( intf_thread_t *pIntf, int left = 0, int top = 0 ) :
62             GenericWindow( pIntf, left, top, false, false, NULL,
63                            GenericWindow::FullscreenWindow )
64     {
65         resize( 10, 10 );
66         move( -50, -50 );
67     }
68     virtual ~VoutMainWindow() { }
69
70     virtual void processEvent( EvtKey &rEvtKey )
71     {
72         // Only do the action when the key is down
73         if( rEvtKey.getKeyState() == EvtKey::kDown )
74             var_SetInteger( getIntf()->p_libvlc, "key-pressed",
75                              rEvtKey.getModKey() );
76     }
77 };
78
79
80 /// Singleton object handling VLC internal state and playlist
81 class VoutManager: public SkinObject
82 {
83 public:
84     /// Get the instance of VoutManager
85     /// Returns NULL if the initialization of the object failed
86     static VoutManager *instance( intf_thread_t *pIntf );
87
88     /// Delete the instance of VoutManager
89     static void destroy( intf_thread_t *pIntf );
90
91     /// Accept Wnd
92     void* acceptWnd( vout_window_t* pWnd );
93
94     /// Release Wnd
95     void releaseWnd( vout_window_t* pWnd );
96
97     /// set size Wnd
98     void setSizeWnd( vout_window_t* pWnd, int width, int height );
99
100     /// set fullscreen Wnd
101     void setFullscreenWnd( vout_window_t* pWnd, bool b_fullscreen );
102
103     /// Callback to request a vout window
104     static void *getWindow( intf_thread_t *pIntf, vout_window_t *pWnd );
105
106     // Window provider (release)
107     static void releaseWindow( intf_thread_t *pIntf, vout_window_t *pWnd  );
108
109     /// Callback to change a vout window
110     static int controlWindow( struct vout_window_t *pWnd,
111                               int query, va_list args );
112
113     // Register Video Controls (when building theme)
114     void registerCtrlVideo( CtrlVideo* p_CtrlVideo );
115
116     // Register Video Controls (when building theme)
117     void registerFSC( TopWindow* p_Win );
118
119     // save and restore vouts (when changing theme)
120     void saveVoutConfig( );
121     void restoreVoutConfig( bool b_success );
122
123     // save and restore vouts (when swapping Layout)
124     void discardVout( CtrlVideo* pCtrlVideo );
125     void requestVout( CtrlVideo* pCtrlVideo );
126
127     // get a useable video Control
128     CtrlVideo* getBestCtrlVideo( );
129
130     // get the VoutMainWindow
131     VoutMainWindow* getVoutMainWindow() { return m_pVoutMainWindow; }
132
133     // test if vout are running
134     bool hasVout() { return ( m_SavedWndVec.size() != 0 ) ; }
135
136 protected:
137     // Protected because it is a singleton
138     VoutManager( intf_thread_t *pIntf );
139     virtual ~VoutManager();
140
141 private:
142
143     vector<CtrlVideo *> m_pCtrlVideoVec;
144     vector<CtrlVideo *> m_pCtrlVideoVecBackup;
145     vector<SavedWnd> m_SavedWndVec;
146
147     VoutMainWindow* m_pVoutMainWindow;
148
149     TopWindow* m_pFscWindow;
150 };
151
152
153 #endif