]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/window_manager.hpp
Removed unused defined.
[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
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 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
57         /// Constructor
58         WindowManager( intf_thread_t *pIntf);
59
60         /// Destructor
61         virtual ~WindowManager();
62
63         /**
64          * Add a window to the list of known windows. Necessary if you want
65          * your window to be movable...
66          */
67         void registerWindow( TopWindow &rWindow );
68
69         /// Remove a previously registered window
70         void unregisterWindow( TopWindow &rWindow );
71
72         /// Tell the window manager that a move is initiated for rWindow
73         void startMove( TopWindow &rWindow );
74
75         /// Tell the window manager that the current move ended
76         void stopMove();
77
78         /**
79          * Move the rWindow window to (left, top), and move all its
80          * anchored windows.
81          * If a new anchoring is detected, the windows will move accordingly.
82          */
83         void move( TopWindow &rWindow, int left, int top ) const;
84
85         /// Tell the window manager that a resize is initiated for rLayout
86         void startResize( GenericLayout &rLayout, Direction_t direction );
87
88         /// Tell the window manager that the current resizing ended
89         void stopResize();
90
91         /**
92          * Resize the rLayout layout to (width, height), and move all its
93          * anchored windows, if some anchors are moved during the resizing.
94          * If a new anchoring is detected, the windows will move (or resize)
95          * accordingly.
96          */
97         void resize( GenericLayout &rLayout, int width, int height ) const;
98
99         /// Maximize the given window
100         void maximize( TopWindow &rWindow );
101
102         /// Unmaximize the given window
103         void unmaximize( TopWindow &rWindow );
104
105         /// Raise all the registered windows
106         void raiseAll() const;
107
108         /// Show all the registered windows
109         void showAll( bool firstTime = false ) const;
110
111         /// Hide all the registered windows
112         void hideAll() const;
113
114         /// Synchronize the windows with their visibility variable
115         void synchVisibility() const;
116
117         /// Save the current visibility of the windows
118         void saveVisibility();
119
120         /// Restore the saved visibility of the windows
121         void restoreVisibility() const;
122
123         /// Raise the given window
124         void raise( TopWindow &rWindow ) const { rWindow.raise(); }
125
126         /// Show the given window
127         void show( TopWindow &rWindow ) const { rWindow.show(); }
128
129         /// Hide the given window
130         void hide( TopWindow &rWindow ) const { rWindow.hide(); }
131
132         /// Toggle all the windows on top
133         void toggleOnTop();
134
135         /// Set the magnetism of screen edges
136         void setMagnetValue( int magnet ) { m_magnet = magnet; }
137
138         /// Set the alpha value of the static windows
139         void setAlphaValue( int alpha ) { m_alpha = alpha; }
140
141         /// Set the alpha value of the moving windows
142         void setMoveAlphaValue( int moveAlpha ) { m_moveAlpha = moveAlpha; }
143
144         /// Create the tooltip window
145         void createTooltip( const GenericFont &rTipFont );
146
147         /// Show the tooltip window
148         void showTooltip();
149
150         /// Hide the tooltip window
151         void hideTooltip();
152
153         /// Add a layout of the given window. This new layout will be the
154         /// active one.
155         void addLayout( TopWindow &rWindow, GenericLayout &rLayout );
156
157         /// Change the active layout of the given window
158         void setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout );
159
160         /// Mark the given popup as active
161         void setActivePopup( Popup &rPopup ) { m_pPopup = &rPopup; }
162
163         /// Return the active popup, or NULL if none is active
164         Popup * getActivePopup() const { return m_pPopup; }
165
166     private:
167         /// Some useful typedefs for lazy people like me
168         typedef set<TopWindow*> WinSet_t;
169         typedef list<Anchor*> AncList_t;
170
171         /// Dependencies map
172         /**
173          * This map represents the graph of anchored windows: it associates
174          * to a given window all the windows that are directly anchored by it.
175          * This is not transitive, i.e. if a is in m_dep[b] and if b is in
176          * m_dep[c], it doesn't mean that a is in m_dep[c] (in fact, it
177          * would be extremely rare...)
178          */
179         map<TopWindow*, WinSet_t> m_dependencies;
180         /// Store all the windows
181         WinSet_t m_allWindows;
182         /**
183          * Store the windows that were visible when saveVisibility() was
184          * last called.
185          */
186         WinSet_t m_savedWindows;
187         /// Store the moving windows
188         /**
189          * This set is updated at every start of move.
190          */
191         WinSet_t m_movingWindows;
192         /**
193          * Store the moving windows in the context of resizing
194          * These sets are updated at every start of move
195          */
196         //@{
197         WinSet_t m_resizeMovingE;
198         WinSet_t m_resizeMovingS;
199         WinSet_t m_resizeMovingSE;
200         //@}
201         /// Indicate whether the windows are currently on top
202         VariablePtr m_cVarOnTop;
203         /// Magnetism of the screen edges (= scope of action)
204         int m_magnet;
205         /// Alpha value of the static windows
206         int m_alpha;
207         /// Alpha value of the moving windows
208         int m_moveAlpha;
209         /// Direction of the current resizing
210         Direction_t m_direction;
211         /// Rect of the last maximized window
212         SkinsRect m_maximizeRect;
213         /// Tooltip
214         Tooltip *m_pTooltip;
215         /// Active popup, if any
216         Popup *m_pPopup;
217
218         /// Recursively build a set of windows anchored to the one given.
219         void buildDependSet( WinSet_t &rWinSet, TopWindow *pWindow );
220
221         /// Check anchoring
222         /**
223          * This function updates xOffset and yOffset, to take care of a new
224          * anchoring (if any)
225          */
226         void checkAnchors( TopWindow *pWindow,
227                            int &xOffset, int &yOffset ) const;
228 };
229
230
231 #endif