MyGUI 3.4.3
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
22 {
24
25 public:
26 Canvas();
27
28 struct Event
29 {
30 Event(bool _textureChanged, bool _widgetResized, bool _requested) :
31 textureChanged(_textureChanged),
32 widgetResized(_widgetResized),
33 requested(_requested)
34 {
35 }
36
39
42 };
43
46
52 {
57 // Размер указаный при создании текстуры увеличиваеться до степени двойки и больше не меняется.
58 // Текстура всегда растягиваеться во весь виджет.
60
69 // Размер указаный при создании текстуры игнорируется.
70 // Текстура всегда больше размера окна и кратна степени двойки.
71 // Если размер виджета становится больше чем размер текстуры, текстура пересоздается.
72 // Текстура всегда отображатся пиксель в пиксель на виджет, образуя рабочую область текстуры.
74
82 // Размер указаный при создании текстуры игнорируется.
83 // Текстура всегда больше размера окна и кратна степени двойки.
84 // Если размер виджета становится больше чем размер текстуры, текстура пересоздается.
85 // Текстура всегда растягиваеться во весь виджет.
86 TRM_PT_VIEW_ALL
87 };
88
89 public:
91 void createTexture(
92 TextureResizeMode _resizeMode,
93 TextureUsage _usage = getDefaultTextureUsage(),
94 PixelFormat _format = getDefaultTextureFormat());
95
97 void createTexture(
98 int _width,
99 int _height,
100 TextureResizeMode _resizeMode,
101 TextureUsage _usage = getDefaultTextureUsage(),
102 PixelFormat _format = getDefaultTextureFormat());
103
105 void createTexture(
106 const IntSize& _size,
107 TextureResizeMode _resizeMode,
108 TextureUsage _usage = getDefaultTextureUsage(),
109 PixelFormat _format = getDefaultTextureFormat());
110
112 void destroyTexture();
113
115 void updateTexture();
116
118 void* lock(TextureUsage _usage = TextureUsage::Write);
119
121 void unlock();
122
124 bool isLocked() const;
125
127 int getTextureRealWidth() const;
128
130 int getTextureRealHeight() const;
131
133 IntSize getTextureRealSize() const;
134
136 int getTextureSrcWidth() const;
137
139 int getTextureSrcHeight() const;
140
142 IntSize getTextureSrcSize() const;
143
145 PixelFormat getTextureFormat() const;
146
148 const std::string& getTextureName() const;
149
151 void setSize(const IntSize& _size) override;
153 void setCoord(const IntCoord& _coord) override;
154
155 using Widget::setPosition;
156 using Widget::setSize;
157 using Widget::setCoord;
158
160 TextureResizeMode getResizeMode() const;
161
163 void setResizeMode(TextureResizeMode _value);
164
166 bool isTextureSrcSize() const;
167
169 bool isTextureCreated() const;
170
172 bool isTextureManaged() const;
173
175 ITexture* getTexture() const;
176
178 void setTextureManaged(bool _value);
179
181 static TextureUsage getDefaultTextureUsage();
182
184 static PixelFormat getDefaultTextureFormat();
185
186 /*events:*/
192
199
200 protected:
201 void shutdownOverride() override;
202 void initialiseOverride() override;
203
205 void _destroyTexture(bool _sendEvent);
206
208 void validate(int& _width, int& _height, TextureUsage& _usage, PixelFormat& _format) const;
209
211 void createExactTexture(int _width, int _height, TextureUsage _usage, PixelFormat _format);
212
214 bool checkCreate(int _width, int _height) const;
215
217 void resize(const IntSize& _size);
218
220 void correctUV();
221
223 void frameAdvise(bool _advise);
224
226 void frameEntered(float _time);
227
228 void textureInvalidate(ITexture* _texture) override;
229
230 void _setUVSet(const FloatRect& _rect);
231
232 protected:
234 ITexture* mTexture{nullptr};
235
238
240 std::string mGenTexName;
241
243 TextureResizeMode mTexResizeMode{TRM_PT_CONST_SIZE};
244
246 uint8* mTexData{nullptr};
247
249 bool mTexManaged{true};
250
252 bool mFrameAdvise{false};
253
254 bool mInvalidateData{false};
255 };
256
257} // namespace MyGUI
258
259#endif // MYGUI_CANVAS_H_
#define MYGUI_EXPORT
#define MYGUI_RTTI_DERIVED(DerivedType)
Definition MyGUI_RTTI.h:69
wrapper over Texture - shows the texture. Implemented: resizing of texture (see TextureResizeMode); r...
IntSize mReqTexSize
Requested bu user sizes.
EventHandle_CanvasPtrEvent requestUpdateCanvas
EventHandle_CanvasPtr eventPreTextureChanges
std::string mGenTexName
Generated texture name.
widget description should be here.
uint8_t uint8
Definition MyGUI_Types.h:46
Event(bool _textureChanged, bool _widgetResized, bool _requested)
bool requested
This update was caused by calling updateTexture();.