]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/generic_layout.hpp
* generic_layout.cpp: don't draw controls of an invisible layout
[vlc] / modules / gui / skins2 / src / generic_layout.hpp
1 /*****************************************************************************
2  * generic_layout.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 GENERIC_LAYOUT_HPP
26 #define GENERIC_LAYOUT_HPP
27
28 #include "skin_common.hpp"
29 #include "top_window.hpp"
30 #include "../utils/pointer.hpp"
31 #include "../utils/position.hpp"
32
33 #include <list>
34
35 class Anchor;
36 class OSGraphics;
37 class CtrlGeneric;
38 class CtrlVideo;
39
40
41 /// Control and its associated layer
42 struct LayeredControl
43 {
44     LayeredControl( CtrlGeneric *pControl, int layer ):
45         m_pControl( pControl ), m_layer( layer ) {}
46
47     /// Pointer on the control
48     CtrlGeneric *m_pControl;
49     /// Layer number
50     int m_layer;
51 };
52
53
54 /// Base class for layouts
55 class GenericLayout: public SkinObject, public Box
56 {
57     public:
58         GenericLayout( intf_thread_t *pIntf, int width, int height,
59                        int minWidth, int maxWidth, int minHeight,
60                        int maxHeight );
61
62         virtual ~GenericLayout();
63
64         /// Attach the layout to a window
65         virtual void setWindow( TopWindow *pWindow );
66
67         /// Get the associated window, if any
68         virtual TopWindow *getWindow() const { return m_pWindow; }
69
70         /// Called by a control which wants to capture the mouse
71         virtual void onControlCapture( const CtrlGeneric &rCtrl );
72
73         /// Called by a control which wants to release the mouse
74         virtual void onControlRelease( const CtrlGeneric &rCtrl );
75
76         /// Refresh the window
77         virtual void refreshAll();
78
79         /// Refresh a rectangular portion of the window
80         virtual void refreshRect( int x, int y, int width, int height );
81
82         /// Get the image of the layout
83         virtual OSGraphics *getImage() const { return m_pImage; }
84
85         /// Get the position of the layout (relative to the screen)
86         virtual int getLeft() const { return m_pWindow->getLeft(); }
87         virtual int getTop() const { return m_pWindow->getTop(); }
88
89         /// Get the size of the layout
90         virtual int getWidth() const { return m_width; }
91         virtual int getHeight() const { return m_height; }
92
93         /// Get the minimum and maximum size of the layout
94         virtual int getMinWidth() const { return m_minWidth; }
95         virtual int getMaxWidth() const { return m_maxWidth; }
96         virtual int getMinHeight() const { return m_minHeight; }
97         virtual int getMaxHeight() const { return m_maxHeight; }
98
99         /// Resize the layout
100         virtual void resize( int width, int height );
101
102         /// Add a control in the layout at the given position, and
103         /// the optional given layer
104         virtual void addControl( CtrlGeneric *pControl,
105                                  const Position &rPosition,
106                                  int layer );
107
108         /// Get the list of the controls in this layout, by layer order
109         virtual const list<LayeredControl> &getControlList() const;
110
111         /// Called by a control when its image has changed
112         /// The arguments indicate the size of the rectangle to refresh,
113         /// and the offset (from the control position) of this rectangle.
114         /// Use a negative width or height to refresh the layout completely
115         virtual void onControlUpdate( const CtrlGeneric &rCtrl,
116                                       int width, int height,
117                                       int xOffSet, int yOffSet );
118
119         /// Get the list of the anchors of this layout
120         virtual const list<Anchor*>& getAnchorList() const;
121
122         /// Add an anchor to this layout
123         virtual void addAnchor( Anchor *pAnchor );
124
125         /// Called when the layout is shown
126         virtual void onShow();
127
128         /// Called when the layout is hidden
129         virtual void onHide();
130
131     private:
132         /// Parent window of the layout
133         TopWindow *m_pWindow;
134         /// Layout size
135         int m_width, m_height;
136         int m_minWidth, m_maxWidth;
137         int m_minHeight, m_maxHeight;
138         /// Image of the layout
139         OSGraphics *m_pImage;
140         /// List of the controls in the layout
141         list<LayeredControl> m_controlList;
142         //// Video control
143         CtrlVideo *m_pVideoControl;
144         /// List of the anchors in the layout
145         list<Anchor*> m_anchorList;
146         /// Flag to know if the layout is visible
147         bool m_visible;
148 };
149
150
151 typedef CountedPtr<GenericLayout> GenericLayoutPtr;
152
153
154 #endif