]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vout_manager.hpp
Use _WIN32 rather than WIN32 (same for WIN64)
[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 <vlc_keys.h>
32 #include "../utils/position.hpp"
33 #include "../commands/cmd_generic.hpp"
34 #include "../controls/ctrl_video.hpp"
35 #include "../events/evt_key.hpp"
36 #include "../events/evt_scroll.hpp"
37 #include "../src/fsc_window.hpp"
38
39 class VarBool;
40 class GenericWindow;
41 class FscWindow;
42
43 #include <stdio.h>
44
45 class SavedWnd
46 {
47 public:
48     SavedWnd( vout_window_t* pWnd, VoutWindow* pVoutWindow = NULL,
49                CtrlVideo* pCtrlVideo = NULL, int height = -1, int width = -1 )
50             : pWnd( pWnd ), pVoutWindow( pVoutWindow ),
51               pCtrlVideo( pCtrlVideo ), height( height ), width( width ) { }
52     ~SavedWnd() { }
53
54     vout_window_t* pWnd;
55     VoutWindow *pVoutWindow;
56     CtrlVideo *pCtrlVideo;
57     int height;
58     int width;
59 };
60
61 class VoutMainWindow: public GenericWindow
62 {
63 public:
64
65     VoutMainWindow( intf_thread_t *pIntf, int left = 0, int top = 0 ) :
66             GenericWindow( pIntf, left, top, false, false, NULL,
67                            GenericWindow::FullscreenWindow )
68     {
69         resize( 10, 10 );
70         move( -50, -50 );
71     }
72     virtual ~VoutMainWindow() { }
73
74 #if defined( _WIN32 ) || defined( __OS2__ )
75
76     virtual void processEvent( EvtKey &rEvtKey )
77     {
78         // Only do the action when the key is down
79         if( rEvtKey.getKeyState() == EvtKey::kDown )
80             var_SetInteger( getIntf()->p_libvlc, "key-pressed",
81                              rEvtKey.getModKey() );
82     }
83
84     virtual void processEvent( EvtScroll &rEvtScroll )
85     {
86         // scroll events sent to core as hotkeys
87         int i_vlck = 0;
88         i_vlck |= rEvtScroll.getMod();
89         i_vlck |= ( rEvtScroll.getDirection() == EvtScroll::kUp ) ?
90                   KEY_MOUSEWHEELUP : KEY_MOUSEWHEELDOWN;
91
92         var_SetInteger( getIntf()->p_libvlc, "key-pressed", i_vlck );
93     }
94
95 #endif
96 };
97
98
99 /// Singleton object handling VLC internal state and playlist
100 class VoutManager: public SkinObject, public Observer<VarBool>
101 {
102 public:
103     /// Get the instance of VoutManager
104     /// Returns NULL if the initialization of the object failed
105     static VoutManager *instance( intf_thread_t *pIntf );
106
107     /// Delete the instance of VoutManager
108     static void destroy( intf_thread_t *pIntf );
109
110     /// accept window request (vout window provider)
111     void acceptWnd( vout_window_t *pWnd, int width, int height );
112
113     // release window (vout window provider)
114     void releaseWnd( vout_window_t *pWnd );
115
116     /// set window size (vout window provider)
117     void setSizeWnd( vout_window_t* pWnd, int width, int height );
118
119     /// set fullscreen mode (vout window provider)
120     void setFullscreenWnd( vout_window_t* pWnd, bool b_fullscreen );
121
122     // Register Video Controls (when building theme)
123     void registerCtrlVideo( CtrlVideo* p_CtrlVideo );
124
125     // Register Video Controls (when building theme)
126     void registerFSC( FscWindow* p_Win );
127
128     // get the fullscreen controller window
129     FscWindow* getFscWindow( ) { return m_pFscWindow; }
130
131     // save and restore vouts (when changing theme)
132     void saveVoutConfig( );
133     void restoreVoutConfig( bool b_success );
134
135     // save and restore vouts (when swapping Layout)
136     void discardVout( CtrlVideo* pCtrlVideo );
137     void requestVout( CtrlVideo* pCtrlVideo );
138
139     // get a useable video Control
140     CtrlVideo* getBestCtrlVideo( );
141
142     // get the VoutMainWindow
143     VoutMainWindow* getVoutMainWindow() { return m_pVoutMainWindow; }
144
145     // test if vout are running
146     bool hasVout() { return ( m_SavedWndVec.size() != 0 ) ; }
147
148     /// called when fullscreen variable changed
149     virtual void onUpdate( Subject<VarBool> &rVariable , void* );
150
151     /// reconfigure fullscreen (multiple screens)
152     virtual void configureFullscreen( VoutWindow& rWindow );
153
154 protected:
155     // Protected because it is a singleton
156     VoutManager( intf_thread_t *pIntf );
157     virtual ~VoutManager();
158
159 private:
160
161     vector<CtrlVideo *> m_pCtrlVideoVec;
162     vector<CtrlVideo *> m_pCtrlVideoVecBackup;
163     vector<SavedWnd> m_SavedWndVec;
164
165     VoutMainWindow* m_pVoutMainWindow;
166
167     FscWindow* m_pFscWindow;
168 };
169
170
171 #endif