]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/window_manager.hpp
* skins2: support for custom popup menus, and win32 implementation.
[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., 59 Temple Place - Suite 330, Boston, MA  02111, 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 <list>
31 #include <map>
32 #include <set>
33 #include <utility>
34
35
36 class GenericFont;
37 class GenericLayout;
38 class Anchor;
39 class Tooltip;
40 class Popup;
41
42
43 /// Window manager for skin windows
44 class WindowManager: public SkinObject
45 {
46     public:
47         /// Constructor
48         WindowManager( intf_thread_t *pIntf);
49
50         /// Destructor
51         virtual ~WindowManager();
52
53         /// Add a window to the list of known windows. Necessary if you want
54         /// your window to be movable...
55         void registerWindow( TopWindow &rWindow );
56
57         /// Remove a previously registered window
58         void unregisterWindow( TopWindow &rWindow );
59
60         /// Tell the window manager that a move is initiated for pWindow.
61         void startMove( TopWindow &rWindow );
62
63         /// Tell the window manager that the current move ended.
64         void stopMove();
65
66         /// Move the pWindow window to (left, top), and move all its
67         /// anchored windows.
68         /// If a new anchoring is detected, the windows will move accordingly.
69         void move( TopWindow &rWindow, int left, int top ) const;
70
71         /// Raise all the registered windows
72         void raiseAll() const;
73
74         /// Show all the registered windows
75         void showAll(bool firstTime = false) const;
76
77         /// Hide all the registered windows
78         void hideAll() const;
79
80         /// Synchronize the windows with their visibility variable
81         void synchVisibility() const;
82
83         /// Raise the given window
84         void raise( TopWindow &rWindow ) const { rWindow.raise(); }
85
86         /// Show the given window
87         void show( TopWindow &rWindow ) const { rWindow.show(); }
88
89         /// Hide the given window
90         void hide( TopWindow &rWindow ) const { rWindow.hide(); }
91
92         /// Toggle all the windows on top
93         void toggleOnTop();
94
95         /// Set the magnetism of screen edges
96         void setMagnetValue( int magnet ) { m_magnet = magnet; }
97
98         /// Set the alpha value of the static windows
99         void setAlphaValue( int alpha ) { m_alpha = alpha; }
100
101         /// Set the alpha value of the moving windows
102         void setMoveAlphaValue( int moveAlpha ) { m_moveAlpha = moveAlpha; }
103
104         /// Create the tooltip window
105         void createTooltip( const GenericFont &rTipFont );
106
107         /// Show the tooltip window
108         void showTooltip();
109
110         /// Hide the tooltip window
111         void hideTooltip();
112
113         /// Add a layout of the given window. This new layout will be the
114         /// active one.
115         void addLayout( TopWindow &rWindow, GenericLayout &rLayout );
116
117         /// Change the active layout of the given window
118         void setActiveLayout( TopWindow &rWindow, GenericLayout &rLayout );
119
120         /// Mark the given popup as active
121         void setActivePopup( Popup &rPopup ) { m_pPopup = &rPopup; }
122
123         /// Return the active popup, or NULL if none is active
124         Popup * getActivePopup() const { return m_pPopup; }
125
126     private:
127         /// Some useful typedefs for lazy people like me
128         typedef set<TopWindow*> WinSet_t;
129         typedef list<Anchor*> AncList_t;
130
131         /// Dependencies map
132         /**
133          * This map represents the graph of anchored windows: it associates
134          * to a given window all the windows that are directly anchored by it.
135          * This is not transitive, i.e. if a is in m_dep[b] and if b is in
136          * m_dep[c], it doesn't mean that a is in m_dep[c] (in fact, it
137          * would be extremely rare...)
138          */
139         map<TopWindow*, WinSet_t> m_dependencies;
140         /// Store all the windows
141         WinSet_t m_allWindows;
142         /// Store the moving windows; this set is updated at every start of
143         /// move.
144         WinSet_t m_movingWindows;
145         /// Indicate whether the windows are currently on top
146         VariablePtr m_cVarOnTop;
147         /// Magnetism of the screen edges (= scope of action)
148         int m_magnet;
149         /// Alpha value of the static windows
150         int m_alpha;
151         /// Alpha value of the moving windows
152         int m_moveAlpha;
153         /// Tooltip
154         Tooltip *m_pTooltip;
155         /// Active popup, if any
156         Popup *m_pPopup;
157
158         /// Recursively build a set of windows anchored to the one given.
159         void buildDependSet( WinSet_t &rWinSet, TopWindow *pWindow );
160
161         /// Check anchoring
162         /**
163          * This function updates xOffset and yOffset, to take care of a new
164          * anchoring (if any)
165          */
166         void checkAnchors( TopWindow *pWindow,
167                            int &xOffset, int &yOffset ) const;
168 };
169
170
171 #endif