]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/window_manager.hpp
skins(Win32): add hotkeys support in fullscreen mode
[vlc] / modules / gui / skins2 / src / window_manager.hpp
1 /*****************************************************************************
2  * window_manager.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef WINDOW_MANAGER_HPP
26 #define WINDOW_MANAGER_HPP
27
28 #include "skin_common.hpp"
29 #include "top_window.hpp"
30 #include "../utils/position.hpp"
31 #include <list>
32 #include <map>
33 #include <set>
34 #include <utility>
35
36
37 class GenericFont;
38 class GenericLayout;
39 class Anchor;
40 class Tooltip;
41 class Popup;
42
43
44 /// Window manager for skin windows
45 class WindowManager: public SkinObject
46 {
47 public:
48     /// Direction of the resizing
49     enum Direction_t
50     {
51         kResizeE,   // East
52         kResizeSE,  // South-East
53         kResizeS,   // South
54         kNone       // Reserved for internal use
55     };
56     WindowManager( intf_thread_t *pIntf );
57     virtual ~WindowManager();
58
59     /**
60      * Add a window to the list of known windows. Necessary if you want
61      * your window to be movable...
62      */
63     void registerWindow( TopWindow &rWindow );
64
65     /// Remove a previously registered window
66     void unregisterWindow( TopWindow &rWindow );
67
68     /// Tell the window manager that a move is initiated for rWindow
69     void startMove( TopWindow &rWindow );
70
71     /// Tell the window manager that the current move ended
72     void stopMove();
73
74     /**
75      * Move the rWindow window to (left, top), and move all its
76      * anchored windows.
77      * If a new anchoring is detected, the windows will move accordingly.
78      */
79     void move( TopWindow &rWindow, int left, int top ) const;
80
81     /// Tell the window manager that a resize is initiated for rLayout
82     void startResize( GenericLayout &rLayout, Direction_t direction );
83
84     /// Tell the window manager that the current resizing ended
85     void stopResize();
86
87     /**
88      * Resize the rLayout layout to (width, height), and move all its
89      * anchored windows, if some anchors are moved during the resizing.
90      * If a new anchoring is detected, the windows will move (or resize)
91      * accordingly.
92      */
93     void resize( GenericLayout &rLayout, int width, int height ) const;
94
95     /// Maximize the given window
96     void maximize( TopWindow &rWindow );
97
98     /// Unmaximize the given window
99     void unmaximize( TopWindow &rWindow );
100
101     /// Raise all the registered windows
102     void raiseAll() const;
103
104     /// Show all the registered windows
105     void showAll( bool firstTime = false ) const;
106
107     /// Hide all the registered windows
108     void hideAll() const;
109
110     /// Synchronize the windows with their visibility variable
111     void synchVisibility() const;
112
113     /// Save the current visibility of the windows
114     void saveVisibility();
115
116     /// Restore the saved visibility of the windows
117     void restoreVisibility() const;
118
119     /// Raise the given window
120     void raise( TopWindow &rWindow ) const { rWindow.raise(); }
121
122     /// Show the given window
123     void show( TopWindow &rWindow ) const { rWindow.show(); }
124
125     /// Hide the given window
126     void hide( TopWindow &rWindow ) const { rWindow.hide(); }
127
128     /// Toggle all the windows on top
129     void toggleOnTop();
130
131     /// Set the magnetism of screen edges
132     void setMagnetValue( int magnet ) { m_magnet = magnet; }
133
134     /// Set the alpha value of the static windows
135     void setAlphaValue( int alpha ) { m_alpha = alpha; }
136
137     /// Set the alpha value of the moving windows
138     void setMoveAlphaValue( int moveAlpha ) { m_moveAlpha = moveAlpha; }
139
140     /// Create the tooltip window
141     void createTooltip( const GenericFont &rTipFont );
142
143     /// Show the tooltip window
144     void showTooltip();
145
146     /// Hide the tooltip window
147     void hideTooltip();
148
149     /// Add a layout of the given window. This new layout will be the
150     /// active one.
151     void addLayout( TopWindow &rWindow, GenericLayout &rLayout );
152
153     /// Change the active layout of the given window
154     void setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout );
155
156     /// Mark the given popup as active
157     void setActivePopup( Popup &rPopup ) { m_pPopup = &rPopup; }
158
159     /// Return the active popup, or NULL if none is active
160     Popup * getActivePopup() const { return m_pPopup; }
161
162 private:
163     /// Some useful typedefs for lazy people like me
164     typedef set<TopWindow*> WinSet_t;
165     typedef list<Anchor*> AncList_t;
166
167     /// Dependencies map
168     /**
169      * This map represents the graph of anchored windows: it associates
170      * to a given window all the windows that are directly anchored by it.
171      * This is not transitive, i.e. if a is in m_dep[b] and if b is in
172      * m_dep[c], it doesn't mean that a is in m_dep[c] (in fact, it
173      * would be extremely rare...)
174      */
175     map<TopWindow*, WinSet_t> m_dependencies;
176     /// Store all the windows
177     WinSet_t m_allWindows;
178     /**
179      * Store the windows that were visible when saveVisibility() was
180      * last called.
181      */
182     WinSet_t m_savedWindows;
183     /// Store the moving windows
184     /**
185      * This set is updated at every start of move.
186      */
187     WinSet_t m_movingWindows;
188     /**
189      * Store the moving windows in the context of resizing
190      * These sets are updated at every start of move
191      */
192     //@{
193     WinSet_t m_resizeMovingE;
194     WinSet_t m_resizeMovingS;
195     WinSet_t m_resizeMovingSE;
196     //@}
197     /// Indicate whether the windows are currently on top
198     VariablePtr m_cVarOnTop;
199     /// Magnetism of the screen edges (= scope of action)
200     int m_magnet;
201     /// Alpha value of the static windows
202     int m_alpha;
203     /// Alpha value of the moving windows
204     int m_moveAlpha;
205     /// Direction of the current resizing
206     Direction_t m_direction;
207     /// Rect of the last maximized window
208     SkinsRect m_maximizeRect;
209     /// Tooltip
210     Tooltip *m_pTooltip;
211     /// Active popup, if any
212     Popup *m_pPopup;
213
214     /// Recursively build a set of windows anchored to the one given.
215     void buildDependSet( WinSet_t &rWinSet, TopWindow *pWindow );
216
217     /// Check anchoring
218     /**
219      * This function updates xOffset and yOffset, to take care of a new
220      * anchoring (if any)
221      */
222     void checkAnchors( TopWindow *pWindow, int &xOffset, int &yOffset ) const;
223 };
224
225
226 #endif