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;
125 /// Hide the given window
126 void hide( TopWindow &rWindow ) const { rWindow.hide(); }
128 /// Set/unset all the windows on top
129 void setOnTop( bool b_ontop );
131 /// Toggle all the windows on top
134 /// Set the magnetism of screen edges
135 void setMagnetValue( int magnet ) { m_magnet = magnet; }
137 /// Set the alpha value of the static windows
138 void setAlphaValue( int alpha ) { m_alpha = alpha; }
140 /// Set the alpha value of the moving windows
141 void setMoveAlphaValue( int moveAlpha ) { m_moveAlpha = moveAlpha; }
143 /// Create the tooltip window
144 void createTooltip( const GenericFont &rTipFont );
146 /// Show the tooltip window
149 /// Hide the tooltip window
152 /// Add a layout of the given window. This new layout will be the
154 void addLayout( TopWindow &rWindow, GenericLayout &rLayout );
156 /// Change the active layout of the given window
157 void setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout );
159 /// Mark the given popup as active
160 void setActivePopup( Popup &rPopup ) { m_pPopup = &rPopup; }
162 /// Return the active popup, or NULL if none is active
163 Popup * getActivePopup() const { return m_pPopup; }
165 /// getter to know whether opacity is needed
166 bool isOpacityNeeded() const
167 { return (m_OpacityEnabled && (m_alpha != 255 || m_moveAlpha != 255 )); }
170 /// Some useful typedefs for lazy people like me
171 typedef set<TopWindow*> WinSet_t;
172 typedef list<Anchor*> AncList_t;
176 * This map represents the graph of anchored windows: it associates
177 * to a given window all the windows that are directly anchored by it.
178 * This is not transitive, i.e. if a is in m_dep[b] and if b is in
179 * m_dep[c], it doesn't mean that a is in m_dep[c] (in fact, it
180 * would be extremely rare...)
182 map<TopWindow*, WinSet_t> m_dependencies;
183 /// Store all the windows
184 WinSet_t m_allWindows;
186 * Store the windows that were visible when saveVisibility() was
189 WinSet_t m_savedWindows;
190 /// Store the moving windows
192 * This set is updated at every start of move.
194 WinSet_t m_movingWindows;
196 * Store the moving windows in the context of resizing
197 * These sets are updated at every start of move
200 WinSet_t m_resizeMovingE;
201 WinSet_t m_resizeMovingS;
202 WinSet_t m_resizeMovingSE;
204 /// Indicate whether the windows are currently on top
205 VariablePtr m_cVarOnTop;
206 /// Magnetism of the screen edges (= scope of action)
208 /// Alpha value of the static windows
210 /// Alpha value of the moving windows
212 /// transparency set by user
213 bool m_OpacityEnabled;
214 /// Direction of the current resizing
215 Direction_t m_direction;
216 /// Rect of the last maximized window
217 SkinsRect m_maximizeRect;
220 /// Active popup, if any
223 /// Recursively build a set of windows anchored to the one given.
224 void buildDependSet( WinSet_t &rWinSet, TopWindow *pWindow );
228 * This function updates xOffset and yOffset, to take care of a new
231 void checkAnchors( TopWindow *pWindow, int &xOffset, int &yOffset ) const;