MyGUI 3.2.2

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

- File List
- Globals

MyGUI_Canvas.h
Go to the documentation of this file.
1 /*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7 #ifndef MYGUI_CANVAS_H_
8 #define MYGUI_CANVAS_H_
9
10 #include "MyGUI_Prerequest.h"
11 #include "MyGUI_Widget.h"
12 #include "MyGUI_ITexture.h"
13
14 namespace MyGUI
15 {
16
21 class MYGUI_EXPORT Canvas :
22 public Widget,
23 public ITextureInvalidateListener
24 {
25 MYGUI_RTTI_DERIVED( Canvas )
26
27 public:
28 Canvas();
29
30 struct Event
31 {
32 Event( bool _textureChanged, bool _widgetResized, bool _requested ) :
33 textureChanged( _textureChanged ),
34 widgetResized( _widgetResized ),
35 requested( _requested )
36 {
37 }
38
39 bool textureChanged;
40 bool widgetResized;
41
43 bool requested;
44 };
45
46 typedef delegates::CMultiDelegate1<Canvas*> EventHandle_CanvasPtr;
47 typedef delegates::CDelegate2<Canvas*, Event> EventHandle_CanvasPtrEvent;
48
53 enum TextureResizeMode
54 {
59 // Размер указаный при создании текстуры увеличиваеться до степени двойки и больше не меняется.
60 // Текстура всегда растягиваеться во весь виджет.
61 TRM_PT_CONST_SIZE,
62
71 // Размер указаный при создании текстуры игнорируется.
72 // Текстура всегда больше размера окна и кратна степени двойки.
73 // Если размер виджета становится больше чем размер текстуры, текстура пересоздается.
74 // Текстура всегда отображатся пиксель в пиксель на виджет, образуя рабочую область текстуры.
75 TRM_PT_VIEW_REQUESTED,
76
84 // Размер указаный при создании текстуры игнорируется.
85 // Текстура всегда больше размера окна и кратна степени двойки.
86 // Если размер виджета становится больше чем размер текстуры, текстура пересоздается.
87 // Текстура всегда растягиваеться во весь виджет.
88 TRM_PT_VIEW_ALL
89 };
90
91 public:
93 void createTexture(TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
94
96 void createTexture(int _width, int _height, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
97
99 void createTexture(const IntSize& _size, TextureResizeMode _resizeMode, TextureUsage _usage = getDefaultTextureUsage(), PixelFormat _format = getDefaultTextureFormat());
100
102 void destroyTexture();
103
105 void updateTexture();
106
108 void* lock(TextureUsage _usage = TextureUsage::Write);
109
111 void unlock();
112
114 bool isLocked() const;
115
117 int getTextureRealWidth() const;
118
120 int getTextureRealHeight() const;
121
123 IntSize getTextureRealSize() const;
124
126 int getTextureSrcWidth() const;
127
129 int getTextureSrcHeight() const;
130
132 IntSize getTextureSrcSize() const;
133
135 PixelFormat getTextureFormat() const;
136
138 const std::string& getTextureName() const;
139
141 virtual void setSize(const IntSize& _value);
143 virtual void setCoord(const IntCoord& _value);
144
146 void setSize(int _width, int _height);
148 void setCoord(int _left, int _top, int _width, int _height);
149
151 TextureResizeMode getResizeMode() const;
152
154 void setResizeMode(TextureResizeMode _value);
155
157 bool isTextureSrcSize() const;
158
160 bool isTextureCreated() const;
161
163 bool isTextureManaged() const;
164
166 ITexture* getTexture() const;
167
169 void setTextureManaged(bool _value);
170
172 static TextureUsage getDefaultTextureUsage();
173
175 static PixelFormat getDefaultTextureFormat();
176
177 /*events:*/
182 EventHandle_CanvasPtr eventPreTextureChanges;
183
189 EventHandle_CanvasPtrEvent requestUpdateCanvas;
190
191 protected:
192 virtual void shutdownOverride();
193 virtual void initialiseOverride();
194
196 void _destroyTexture(bool _sendEvent);
197
199 void validate(int& _width, int& _height, TextureUsage& _usage, PixelFormat& _format) const;
200
202 void createExactTexture(int _width, int _height, TextureUsage _usage, PixelFormat _format);
203
205 bool checkCreate(int _width, int _height) const;
206
208 void resize(const IntSize& _size);
209
211 void correctUV();
212
214 void frameAdvise(bool _advise);
215
217 void frameEntered(float _time);
218
219 virtual void textureInvalidate(ITexture* _texture);
220
221 void _setUVSet(const FloatRect& _rect);
222
223 protected:
225 ITexture* mTexture;
226
228 IntSize mReqTexSize;
229
231 std::string mGenTexName;
232
234 TextureResizeMode mTexResizeMode;
235
237 uint8* mTexData;
238
240 bool mTexManaged;
241
243 bool mFrameAdvise;
244
245 bool mInvalidateData;
246 };
247
248 } // namespace MyGUI
249
250 #endif // MYGUI_CANVAS_H_
MyGUI::types::TCoord
Definition: MyGUI_TCoord.h:20
MyGUI::Widget
Widget properties. Widget_skin_childs Skin childs. Widget widget description should be here...
Definition: MyGUI_Widget.h:29
MyGUI::Canvas::requestUpdateCanvas
EventHandle_CanvasPtrEvent requestUpdateCanvas
Definition: MyGUI_Canvas.h:189
MyGUI_Prerequest.h
MyGUI::Canvas::Event::widgetResized
bool widgetResized
Definition: MyGUI_Canvas.h:40
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:243
MyGUI::delegates::CDelegate2< Canvas *, Event >
MyGUI::TextureUsage::Write
Definition: MyGUI_RenderFormat.h:93
MyGUI::Canvas::eventPreTextureChanges
EventHandle_CanvasPtr eventPreTextureChanges
Definition: MyGUI_Canvas.h:182
MyGUI::Canvas::mTexture
ITexture * mTexture
Current texture.
Definition: MyGUI_Canvas.h:225
MyGUI::Canvas::Event::textureChanged
bool textureChanged
Definition: MyGUI_Canvas.h:39
MyGUI
Definition: MyGUI_ActionController.h:14
MyGUI::TextureUsage
Definition: MyGUI_RenderFormat.h:84
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition: MyGUI_RTTI.h:65
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:103
MyGUI::types::TRect< float >
MyGUI::Canvas::EventHandle_CanvasPtr
delegates::CMultiDelegate1< Canvas * > EventHandle_CanvasPtr
Definition: MyGUI_Canvas.h:46
MyGUI::Canvas::mReqTexSize
IntSize mReqTexSize
Requested bu user sizes.
Definition: MyGUI_Canvas.h:228
MyGUI_ITexture.h
MyGUI::ITextureInvalidateListener
Definition: MyGUI_ITexture.h:19
MyGUI::Canvas::EventHandle_CanvasPtrEvent
delegates::CDelegate2< Canvas *, Event > EventHandle_CanvasPtrEvent
Definition: MyGUI_Canvas.h:47
MyGUI::ITexture
Definition: MyGUI_ITexture.h:26
MyGUI::Canvas::mTexResizeMode
TextureResizeMode mTexResizeMode
Texture resize mode.
Definition: MyGUI_Canvas.h:234
MyGUI::Canvas::Event::Event
Event(bool _textureChanged, bool _widgetResized, bool _requested)
Definition: MyGUI_Canvas.h:32
MyGUI::Canvas::Event
Definition: MyGUI_Canvas.h:30
MyGUI::Canvas::TextureResizeMode
TextureResizeMode
Definition: MyGUI_Canvas.h:53
MyGUI_Widget.h
MyGUI::PixelFormat
Definition: MyGUI_RenderFormat.h:49
MyGUI::Canvas::TRM_PT_CONST_SIZE
Definition: MyGUI_Canvas.h:61
MyGUI::Canvas
Canvas properties. Canvas_skin_childs Skin childs. Widget wrapper over Texture - shows the texture...
Definition: MyGUI_Canvas.h:21
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:240
MyGUI::Canvas::Event::requested
bool requested
This update was caused by calling updateTexture();.
Definition: MyGUI_Canvas.h:43
MyGUI::uint8
unsigned char uint8
Definition: MyGUI_Types.h:46
MyGUI::delegates::CMultiDelegate1< Canvas * >
MyGUI::Canvas::mGenTexName
std::string mGenTexName
Generated texture name.
Definition: MyGUI_Canvas.h:231
MyGUI::Canvas::mInvalidateData
bool mInvalidateData
Definition: MyGUI_Canvas.h:245
MyGUI::Canvas::mTexData
uint8 * mTexData
Saved pointer from last calling lock.
Definition: MyGUI_Canvas.h:237
MyGUI::Canvas::TRM_PT_VIEW_REQUESTED
Definition: MyGUI_Canvas.h:75