1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
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.
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.
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 *****************************************************************************/
25 #ifndef WINDOW_MANAGER_HPP
26 #define WINDOW_MANAGER_HPP
28 #include "skin_common.hpp"
29 #include "top_window.hpp"
30 #include "../utils/position.hpp"
44 /// Window manager for skin windows
45 class WindowManager: public SkinObject
48 /// Direction of the resizing
52 kResizeSE, // South-East
54 kNone // Reserved for internal use
56 WindowManager( intf_thread_t *pIntf );
57 virtual ~WindowManager();
60 * Add a window to the list of known windows. Necessary if you want
61 * your window to be movable...
63 void registerWindow( TopWindow &rWindow );
65 /// Remove a previously registered window
66 void unregisterWindow( TopWindow &rWindow );
68 /// Tell the window manager that a move is initiated for rWindow
69 void startMove( TopWindow &rWindow );
71 /// Tell the window manager that the current move ended
75 * Move the rWindow window to (left, top), and move all its
77 * If a new anchoring is detected, the windows will move accordingly.
79 void move( TopWindow &rWindow, int left, int top ) const;
81 /// Tell the window manager that a resize is initiated for rLayout
82 void startResize( GenericLayout &rLayout, Direction_t direction );
84 /// Tell the window manager that the current resizing ended
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)
93 void resize( GenericLayout &rLayout, int width, int height ) const;
95 /// Maximize the given window
96 void maximize( TopWindow &rWindow );
98 /// Unmaximize the given window
99 void unmaximize( TopWindow &rWindow );
101 /// Raise all the registered windows
102 void raiseAll() const;
104 /// Show all the registered windows
105 void showAll( bool firstTime = false ) const;
107 /// Hide all the registered windows
108 void hideAll() const;
110 /// Synchronize the windows with their visibility variable
111 void synchVisibility() const;
113 /// Save the current visibility of the windows
114 void saveVisibility();
116 /// Restore the saved visibility of the windows
117 void restoreVisibility() const;
119 /// Raise the given window
120 void raise( TopWindow &rWindow ) const { rWindow.raise(); }
122 /// Show the given window
123 void show( TopWindow &rWindow ) const { rWindow.show(); }
125 /// Hide the given window
126 void hide( TopWindow &rWindow ) const { rWindow.hide(); }
128 /// Toggle all the windows on top
131 /// Set the magnetism of screen edges
132 void setMagnetValue( int magnet ) { m_magnet = magnet; }
134 /// Set the alpha value of the static windows
135 void setAlphaValue( int alpha ) { m_alpha = alpha; }
137 /// Set the alpha value of the moving windows
138 void setMoveAlphaValue( int moveAlpha ) { m_moveAlpha = moveAlpha; }
140 /// Create the tooltip window
141 void createTooltip( const GenericFont &rTipFont );
143 /// Show the tooltip window
146 /// Hide the tooltip window
149 /// Add a layout of the given window. This new layout will be the
151 void addLayout( TopWindow &rWindow, GenericLayout &rLayout );
153 /// Change the active layout of the given window
154 void setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout );
156 /// Mark the given popup as active
157 void setActivePopup( Popup &rPopup ) { m_pPopup = &rPopup; }
159 /// Return the active popup, or NULL if none is active
160 Popup * getActivePopup() const { return m_pPopup; }
163 /// Some useful typedefs for lazy people like me
164 typedef set<TopWindow*> WinSet_t;
165 typedef list<Anchor*> AncList_t;
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...)
175 map<TopWindow*, WinSet_t> m_dependencies;
176 /// Store all the windows
177 WinSet_t m_allWindows;
179 * Store the windows that were visible when saveVisibility() was
182 WinSet_t m_savedWindows;
183 /// Store the moving windows
185 * This set is updated at every start of move.
187 WinSet_t m_movingWindows;
189 * Store the moving windows in the context of resizing
190 * These sets are updated at every start of move
193 WinSet_t m_resizeMovingE;
194 WinSet_t m_resizeMovingS;
195 WinSet_t m_resizeMovingSE;
197 /// Indicate whether the windows are currently on top
198 VariablePtr m_cVarOnTop;
199 /// Magnetism of the screen edges (= scope of action)
201 /// Alpha value of the static windows
203 /// Alpha value of the moving windows
205 /// Direction of the current resizing
206 Direction_t m_direction;
207 /// Rect of the last maximized window
208 SkinsRect m_maximizeRect;
211 /// Active popup, if any
214 /// Recursively build a set of windows anchored to the one given.
215 void buildDependSet( WinSet_t &rWinSet, TopWindow *pWindow );
219 * This function updates xOffset and yOffset, to take care of a new
222 void checkAnchors( TopWindow *pWindow, int &xOffset, int &yOffset ) const;