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__
MyGUI::types::TCoord
Definition: MyGUI_TCoord.h:35
MyGUI::Widget
Definition: MyGUI_Widget.h:41
MyGUI::Canvas::requestUpdateCanvas
EventHandle_CanvasPtrEvent requestUpdateCanvas
Definition: MyGUI_Canvas.h:175
MyGUI_Prerequest.h
MyGUI::Canvas::Event::widgetResized
bool widgetResized
Definition: MyGUI_Canvas.h:55
MyGUI::types::TSize< int >
MyGUI::Canvas::mFrameAdvise
bool mFrameAdvise
For updating once per frame. True state means updating before next frame starts.
Definition: MyGUI_Canvas.h:229
MyGUI::delegates::CDelegate2< Canvas *, Event >
MyGUI::TextureUsage::Write
Definition: MyGUI_RenderFormat.h:98
MyGUI::Canvas::eventPreTextureChanges
EventHandle_CanvasPtr eventPreTextureChanges
Definition: MyGUI_Canvas.h:168
MyGUI::Canvas::mTexture
ITexture * mTexture
Current texture.
Definition: MyGUI_Canvas.h:211
MyGUI::Canvas::Event::textureChanged
bool textureChanged
Definition: MyGUI_Canvas.h:54
MyGUI::TextureUsage
Definition: MyGUI_RenderFormat.h:89
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:88
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
MyGUI::types::TRect< float >
MyGUI::Canvas::EventHandle_CanvasPtr
delegates::CMultiDelegate1< Canvas * > EventHandle_CanvasPtr
Definition: MyGUI_Canvas.h:61
MyGUI::Canvas::mReqTexSize
IntSize mReqTexSize
Requested bu user sizes.
Definition: MyGUI_Canvas.h:214
MyGUI_ITexture.h
MyGUI::ITextureInvalidateListener
Definition: MyGUI_ITexture.h:34
MyGUI::Canvas::EventHandle_CanvasPtrEvent
delegates::CDelegate2< Canvas *, Event > EventHandle_CanvasPtrEvent
Definition: MyGUI_Canvas.h:62
MyGUI::ITexture
Definition: MyGUI_ITexture.h:41
MyGUI::Canvas::mTexResizeMode
TextureResizeMode mTexResizeMode
Texture resize mode.
Definition: MyGUI_Canvas.h:220
MyGUI::Canvas::Event::Event
Event(bool _textureChanged, bool _widgetResized, bool _requested)
Definition: MyGUI_Canvas.h:47
MyGUI::Canvas::Event
Definition: MyGUI_Canvas.h:45
MyGUI::Canvas::TextureResizeMode
TextureResizeMode
Definition: MyGUI_Canvas.h:69
MyGUI_Widget.h
MyGUI::PixelFormat
Definition: MyGUI_RenderFormat.h:59
MyGUI::Canvas::TRM_PT_CONST_SIZE
Definition: MyGUI_Canvas.h:72
MyGUI::Canvas
Definition: MyGUI_Canvas.h:36
MyGUI::Canvas::mTexManaged
bool mTexManaged
true if we own the texture (can delete it or replace by another instance), otherwise false ...
Definition: MyGUI_Canvas.h:226
MyGUI::Canvas::Event::requested
bool requested
This update was caused by calling updateTexture();.
Definition: MyGUI_Canvas.h:58
MyGUI::uint8
unsigned char uint8
Definition: MyGUI_Types.h:61
MyGUI::delegates::CMultiDelegate1< Canvas * >
MyGUI::Canvas::mGenTexName
std::string mGenTexName
Generated texture name.
Definition: MyGUI_Canvas.h:217
MyGUI::Canvas::mInvalidateData
bool mInvalidateData
Definition: MyGUI_Canvas.h:231
MyGUI::Canvas::mTexData
uint8 * mTexData
Saved pointer from last calling lock.
Definition: MyGUI_Canvas.h:223
MyGUI::Canvas::TRM_PT_VIEW_REQUESTED
Texture doesn&#39;t resizes and fills all widget space.
Definition: MyGUI_Canvas.h:73