1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2009 the VideoLAN team
7 * Authors: Erwan Tulou < brezhoneg1 at yahoo.fr r>
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.
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.
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 *****************************************************************************/
24 #ifndef VOUTMANAGER_HPP
25 #define VOUTMANAGER_HPP
30 #include <vlc_vout_window.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"
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 ) { }
55 VoutWindow *pVoutWindow;
56 CtrlVideo *pCtrlVideo;
61 class VoutMainWindow: public GenericWindow
65 VoutMainWindow( intf_thread_t *pIntf, int left = 0, int top = 0 ) :
66 GenericWindow( pIntf, left, top, false, false, NULL,
67 GenericWindow::FullscreenWindow )
72 virtual ~VoutMainWindow() { }
74 #if defined( _WIN32 ) || defined( __OS2__ )
76 virtual void processEvent( EvtKey &rEvtKey )
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() );
84 virtual void processEvent( EvtScroll &rEvtScroll )
86 // scroll events sent to core as hotkeys
88 i_vlck |= rEvtScroll.getMod();
89 i_vlck |= ( rEvtScroll.getDirection() == EvtScroll::kUp ) ?
90 KEY_MOUSEWHEELUP : KEY_MOUSEWHEELDOWN;
92 var_SetInteger( getIntf()->p_libvlc, "key-pressed", i_vlck );
99 /// Singleton object handling VLC internal state and playlist
100 class VoutManager: public SkinObject, public Observer<VarBool>
103 /// Get the instance of VoutManager
104 /// Returns NULL if the initialization of the object failed
105 static VoutManager *instance( intf_thread_t *pIntf );
107 /// Delete the instance of VoutManager
108 static void destroy( intf_thread_t *pIntf );
110 /// accept window request (vout window provider)
111 void acceptWnd( vout_window_t *pWnd, int width, int height );
113 // release window (vout window provider)
114 void releaseWnd( vout_window_t *pWnd );
116 /// set window size (vout window provider)
117 void setSizeWnd( vout_window_t* pWnd, int width, int height );
119 /// set fullscreen mode (vout window provider)
120 void setFullscreenWnd( vout_window_t* pWnd, bool b_fullscreen );
122 // Register Video Controls (when building theme)
123 void registerCtrlVideo( CtrlVideo* p_CtrlVideo );
125 // Register Video Controls (when building theme)
126 void registerFSC( FscWindow* p_Win );
128 // get the fullscreen controller window
129 FscWindow* getFscWindow( ) { return m_pFscWindow; }
131 // save and restore vouts (when changing theme)
132 void saveVoutConfig( );
133 void restoreVoutConfig( bool b_success );
135 // save and restore vouts (when swapping Layout)
136 void discardVout( CtrlVideo* pCtrlVideo );
137 void requestVout( CtrlVideo* pCtrlVideo );
139 // get a useable video Control
140 CtrlVideo* getBestCtrlVideo( );
142 // get the VoutMainWindow
143 VoutMainWindow* getVoutMainWindow() { return m_pVoutMainWindow; }
145 // test if vout are running
146 bool hasVout() { return ( m_SavedWndVec.size() != 0 ) ; }
148 /// called when fullscreen variable changed
149 virtual void onUpdate( Subject<VarBool> &rVariable , void* );
151 /// reconfigure fullscreen (multiple screens)
152 virtual void configureFullscreen( VoutWindow& rWindow );
155 // Protected because it is a singleton
156 VoutManager( intf_thread_t *pIntf );
157 virtual ~VoutManager();
161 vector<CtrlVideo *> m_pCtrlVideoVec;
162 vector<CtrlVideo *> m_pCtrlVideoVecBackup;
163 vector<SavedWnd> m_SavedWndVec;
165 VoutMainWindow* m_pVoutMainWindow;
167 FscWindow* m_pFscWindow;