MyGUI: MyGUI_Canvas.h Source File

MyGUI 3.4.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
14namespace 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 void setSize(const IntSize& _value) override;
143 void setCoord(const IntCoord& _value) override;
144
145 using Widget::setPosition;
146 using Widget::setSize;
147 using Widget::setCoord;
148
150 TextureResizeMode getResizeMode() const;
151
153 void setResizeMode(TextureResizeMode _value);
154
156 bool isTextureSrcSize() const;
157
159 bool isTextureCreated() const;
160
162 bool isTextureManaged() const;
163
165 ITexture* getTexture() const;
166
168 void setTextureManaged(bool _value);
169
171 static TextureUsage getDefaultTextureUsage();
172
174 static PixelFormat getDefaultTextureFormat();
175
176 /*events:*/
181 EventHandle_CanvasPtr eventPreTextureChanges;
182
188 EventHandle_CanvasPtrEvent requestUpdateCanvas;
189
190 protected:
191 void shutdownOverride() override;
192 void initialiseOverride() override;
193
195 void _destroyTexture(bool _sendEvent);
196
198 void validate(int& _width, int& _height, TextureUsage& _usage, PixelFormat& _format) const;
199
201 void createExactTexture(int _width, int _height, TextureUsage _usage, PixelFormat _format);
202
204 bool checkCreate(int _width, int _height) const;
205
207 void resize(const IntSize& _size);
208
210 void correctUV();
211
213 void frameAdvise(bool _advise);
214
216 void frameEntered(float _time);
217
218 void textureInvalidate(ITexture* _texture) override;
219
220 void _setUVSet(const FloatRect& _rect);
221
222 protected:
224 ITexture* mTexture;
225
227 IntSize mReqTexSize;
228
230 std::string mGenTexName;
231
233 TextureResizeMode mTexResizeMode;
234
236 uint8* mTexData;
237
239 bool mTexManaged;
240
242 bool mFrameAdvise;
243
244 bool mInvalidateData;
245 };
246
247} // namespace MyGUI
248
249#endif // MYGUI_CANVAS_H_
MyGUI_ITexture.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MYGUI_RTTI_DERIVED
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:48
MyGUI_Widget.h
MyGUI::Canvas
wrapper over Texture - shows the texture. Implemented: resizing of texture (see TextureResizeMode); r...
Definition MyGUI_Canvas.h:24
MyGUI::Canvas::mReqTexSize
IntSize mReqTexSize
Requested bu user sizes.
Definition MyGUI_Canvas.h:227
MyGUI::Canvas::mFrameAdvise
bool mFrameAdvise
For updating once per frame. True state means updating before next frame starts.
Definition MyGUI_Canvas.h:242
MyGUI::Canvas::requestUpdateCanvas
EventHandle_CanvasPtrEvent requestUpdateCanvas
Definition MyGUI_Canvas.h:188
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:239
MyGUI::Canvas::mTexResizeMode
TextureResizeMode mTexResizeMode
Texture resize mode.
Definition MyGUI_Canvas.h:233
MyGUI::Canvas::mTexData
uint8 * mTexData
Saved pointer from last calling lock.
Definition MyGUI_Canvas.h:236
MyGUI::Canvas::mInvalidateData
bool mInvalidateData
Definition MyGUI_Canvas.h:244
MyGUI::Canvas::mTexture
ITexture * mTexture
Current texture.
Definition MyGUI_Canvas.h:224
MyGUI::Canvas::eventPreTextureChanges
EventHandle_CanvasPtr eventPreTextureChanges
Definition MyGUI_Canvas.h:181
MyGUI::Canvas::TextureResizeMode
TextureResizeMode
Definition MyGUI_Canvas.h:54
MyGUI::Canvas::TRM_PT_VIEW_REQUESTED
@ TRM_PT_VIEW_REQUESTED
Definition MyGUI_Canvas.h:75
MyGUI::Canvas::TRM_PT_CONST_SIZE
@ TRM_PT_CONST_SIZE
Definition MyGUI_Canvas.h:61
MyGUI::Canvas::mGenTexName
std::string mGenTexName
Generated texture name.
Definition MyGUI_Canvas.h:230
MyGUI::Canvas::EventHandle_CanvasPtrEvent
delegates::CDelegate2< Canvas *, Event > EventHandle_CanvasPtrEvent
Definition MyGUI_Canvas.h:47
MyGUI::Canvas::EventHandle_CanvasPtr
delegates::CMultiDelegate1< Canvas * > EventHandle_CanvasPtr
Definition MyGUI_Canvas.h:46
MyGUI::ITexture
Definition MyGUI_ITexture.h:28
MyGUI::ITextureInvalidateListener
Definition MyGUI_ITexture.h:20
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:37
MyGUI::delegates::Delegate
Definition MyGUI_Delegate.h:136
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:200
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::uint8
uint8_t uint8
Definition MyGUI_Types.h:46
MyGUI::Canvas::Event
Definition MyGUI_Canvas.h:31
MyGUI::Canvas::Event::Event
Event(bool _textureChanged, bool _widgetResized, bool _requested)
Definition MyGUI_Canvas.h:32
MyGUI::Canvas::Event::widgetResized
bool widgetResized
Definition MyGUI_Canvas.h:40
MyGUI::Canvas::Event::textureChanged
bool textureChanged
Definition MyGUI_Canvas.h:39
MyGUI::Canvas::Event::requested
bool requested
This update was caused by calling updateTexture();.
Definition MyGUI_Canvas.h:43
MyGUI::PixelFormat
Definition MyGUI_RenderFormat.h:50
MyGUI::TextureUsage
Definition MyGUI_RenderFormat.h:103
MyGUI::types::TCoord< int >
MyGUI::types::TRect< float >
MyGUI::types::TSize< int >