MyGUI 3.2.0

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_Canvas.h
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_CANVAS_H__
23 #define __MYGUI_CANVAS_H__
24
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Widget.h"
27 #include "MyGUI_ITexture.h"
28
29 namespace MyGUI
30 {
31
36 class MYGUI_EXPORT Canvas :
37 public Widget,
38 public ITextureInvalidateListener
39 {
40 MYGUI_RTTI_DERIVED( Canvas )
41
42 public:
43 Canvas();
44
45 struct Event
46 {
47 Event( bool _textureChanged, bool _widgetResized, bool _requested ) :
48 textureChanged( _textureChanged ),
49 widgetResized( _widgetResized ),
50 requested( _requested )
51 {
52 }
53
54 bool textureChanged;
55 bool widgetResized;
56
58 bool requested;
59 };
60
61 typedef delegates::CMultiDelegate1<Canvas*> EventHandle_CanvasPtr;
62 typedef delegates::CDelegate2<Canvas*, Event> EventHandle_CanvasPtrEvent;
63
64 //FIXME
69 enum TextureResizeMode
70 {
71 //
72 TRM_PT_CONST_SIZE,
73 TRM_PT_VIEW_REQUESTED,
74 TRM_PT_VIEW_ALL
75 };
76
77 public:
79 void createTexture(TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
80
82 void createTexture(int _width, int _height, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
83
85 void createTexture(const IntSize& _size, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
86
88 void destroyTexture();
89
91 void updateTexture();
92
94 void* lock(TextureUsage _usage = TextureUsage::Write);
95
97 void unlock();
98
100 bool isLocked() const;
101
103 int getTextureRealWidth() const;
104
106 int getTextureRealHeight() const;
107
109 IntSize getTextureRealSize() const;
110
112 int getTextureSrcWidth() const;
113
115 int getTextureSrcHeight() const;
116
118 IntSize getTextureSrcSize() const;
119
121 PixelFormat getTextureFormat() const;
122
124 const std::string& getTextureName() const;
125
127 virtual void setSize(const IntSize& _value);
129 virtual void setCoord(const IntCoord& _value);
130
132 void setSize(int _width, int _height);
134 void setCoord(int _left, int _top, int _width, int _height);
135
137 TextureResizeMode getResizeMode() const;
138
140 void setResizeMode(TextureResizeMode _value);
141
143 bool isTextureSrcSize() const;
144
146 bool isTextureCreated() const;
147
149 bool isTextureManaged() const;
150
152 ITexture* getTexture() const;
153
155 void setTextureManaged(bool _value);
156
158 static TextureUsage getDefaultTextureUsage();
159
161 static PixelFormat getDefaultTextureFormat();
162
163 /*events:*/
168 EventHandle_CanvasPtr eventPreTextureChanges;
169
175 EventHandle_CanvasPtrEvent requestUpdateCanvas;
176
177 protected:
178 virtual void shutdownOverride();
179 virtual void initialiseOverride();
180
182 void _destroyTexture(bool _sendEvent);
183
185 void validate(int& _width, int& _height, TextureUsage& _usage, PixelFormat& _format) const;
186
188 void createExactTexture(int _width, int _height, TextureUsage _usage, PixelFormat _format);
189
191 bool checkCreate(int _width, int _height) const;
192
194 void resize(const IntSize& _size);
195
197 void correctUV();
198
200 void frameAdvise(bool _advise);
201
203 void frameEntered(float _time);
204
205 virtual void textureInvalidate(ITexture* _texture);
206
207 void _setUVSet(const FloatRect& _rect);
208
209 protected:
211 ITexture* mTexture;
212
214 IntSize mReqTexSize;
215
217 std::string mGenTexName;
218
220 TextureResizeMode mTexResizeMode;
221
223 uint8* mTexData;
224
226 bool mTexManaged;
227
229 bool mFrameAdvise;
230
231 bool mInvalidateData;
232 };
233
234 } // namespace MyGUI
235
236 #endif // __MYGUI_CANVAS_H__