MyGUI 3.4.3
MyGUI_SubSkin.cpp
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#include "MyGUI_Precompiled.h"
8#include "MyGUI_SubSkin.h"
9#include "MyGUI_RenderItem.h"
10#include "MyGUI_SkinManager.h"
12#include "MyGUI_LayerNode.h"
14#include "MyGUI_RenderManager.h"
16
17namespace MyGUI
18{
19
21 {
22 mVertexFormat = RenderManager::getInstance().getVertexFormat();
23 }
24
26 {
27 if (mVisible == _visible)
28 return;
30
31 if (nullptr != mNode)
33 }
34
36 {
37 uint32 alpha = ((uint8)(_alpha * 255) << 24);
38 mCurrentColour = (mCurrentColour & 0x00FFFFFF) | (alpha & 0xFF000000);
39
40 if (nullptr != mNode)
42 }
43
45 {
46 if (nullptr != mNode)
48 }
49
51 {
52 // первоначальное выравнивание
53 if (mAlign.isHStretch())
54 {
55 // растягиваем
57 mIsMargin = true; // при изменении размеров все пересчитывать
58 }
59 else if (mAlign.isRight())
60 {
61 // двигаем по правому краю
63 }
64 else if (mAlign.isHCenter())
65 {
66 // выравнивание по горизонтали без растяжения
68 }
69
70 if (mAlign.isVStretch())
71 {
72 // растягиваем
74 mIsMargin = true; // при изменении размеров все пересчитывать
75 }
76 else if (mAlign.isBottom())
77 {
78 // двигаем по нижнему краю
80 }
81 else if (mAlign.isVCenter())
82 {
83 // выравнивание по вертикали без растяжения
85 }
86
89 }
90
92 {
93 //mAbsolutePosition = mCroppedParent->getAbsolutePosition() + mCoord.point();
94 bool margin = _checkMargin();
95
96 mEmptyView = ((0 >= _getViewWidth()) || (0 >= _getViewHeight()));
97
100
101 // вьюпорт стал битым
102 if (margin)
103 {
104 // проверка на полный выход за границу
105 if (_checkOutside())
106 {
107 // запоминаем текущее состояние
109
110 // обновить перед выходом
111 if (nullptr != mNode)
113 return;
114 }
115 }
116
117 // мы обрезаны или были обрезаны
118 if (mIsMargin || margin)
119 {
122
123 if ((mCurrentCoord.width > 0) && (mCurrentCoord.height > 0))
124 {
125 // теперь смещаем текстуру
126 float UV_lft = mMargin.left / (float)mCoord.width;
127 float UV_top = mMargin.top / (float)mCoord.height;
128 float UV_rgt = (mCoord.width - mMargin.right) / (float)mCoord.width;
129 float UV_btm = (mCoord.height - mMargin.bottom) / (float)mCoord.height;
130
133
138
140 }
141 }
142
143 if (mIsMargin && !margin)
144 {
145 // мы не обрезаны, но были, ставим базовые координаты
147 }
148
149 // запоминаем текущее состояние
151
152 if (nullptr != mNode)
154 }
155
157 {
158 MYGUI_ASSERT(!mRenderItem, "mRenderItem must be nullptr");
159
160 mNode = _node;
163 }
164
166 {
167 MYGUI_ASSERT(mRenderItem, "mRenderItem must be not nullptr");
168
169 mNode = nullptr;
171 mRenderItem = nullptr;
172 }
173
175 {
176 if (mRectTexture == _rect)
177 return;
179
180 // если обрезаны, то просчитываем с учето обрезки
181 if (mIsMargin)
182 {
183 float UV_lft = mMargin.left / (float)mCoord.width;
184 float UV_top = mMargin.top / (float)mCoord.height;
185 float UV_rgt = (mCoord.width - mMargin.right) / (float)mCoord.width;
186 float UV_btm = (mCoord.height - mMargin.bottom) / (float)mCoord.height;
187
190
195
197 }
198 // мы не обрезаны, базовые координаты
199 else
200 {
202 }
203
204 if (nullptr != mNode)
206 }
207
209 {
210 if (!mVisible || mEmptyView)
211 return;
212
214
216
217 float vertex_z = mNode->getNodeDepth();
218
219 float vertex_left =
220 ((info.pixScaleX * (float)(mCurrentCoord.left + mCroppedParent->getAbsoluteLeft() - info.leftOffset) +
221 info.hOffset) *
222 2) -
223 1;
224 float vertex_right = vertex_left + (info.pixScaleX * (float)mCurrentCoord.width * 2);
225 float vertex_top =
226 -(((info.pixScaleY * (float)(mCurrentCoord.top + mCroppedParent->getAbsoluteTop() - info.topOffset) +
227 info.vOffset) *
228 2) -
229 1);
230 float vertex_bottom = vertex_top - (info.pixScaleY * (float)mCurrentCoord.height * 2);
231
232 quad->set(
237 vertex_z,
243
245 }
246
248 {
250 mCurrentColour = (colour & 0x00FFFFFF) | (mCurrentColour & 0xFF000000);
251
252 if (nullptr != mNode)
254 }
255
257 {
258 _setUVSet(_data->castType<SubSkinStateInfo>()->getRect());
259 }
260
261} // namespace MyGUI
#define MYGUI_ASSERT(exp, dest)
virtual float getNodeDepth() const =0
virtual void outOfDate(RenderItem *_item)=0
virtual RenderItem * addToRenderItem(ITexture *_texture, bool _firstQueue, bool _separate)=0
virtual const RenderTargetInfo & getInfo() const =0
void addDrawItem(ISubWidget *_item, size_t _count)
IRenderTarget * getRenderTarget()
void removeDrawItem(ISubWidget *_item)
Vertex * getCurrentVertexBuffer() const
void setLastVertexCount(size_t _count)
static RenderManager & getInstance()
void destroyDrawItem() override
void setVisible(bool _visible) override
FloatRect mCurrentTexture
IntCoord mCurrentCoord
ILayerNode * mNode
void setStateData(IStateInfo *_data) override
void _updateView() override
VertexColourType mVertexFormat
void doRender() override
void _setUVSet(const FloatRect &_rect) override
void _setColour(const Colour &_value) override
void _correctView() override
RenderItem * mRenderItem
FloatRect mRectTexture
void setAlpha(float _alpha) override
uint32 mCurrentColour
void createDrawItem(ITexture *_texture, ILayerNode *_node) override
void _setAlign(const IntSize &_oldsize) override
const FloatRect & getRect() const
uint32 toNativeColour(const Colour &_colour, VertexColourType _format)
Convert Colour to 32-bit representation.
uint8_t uint8
Definition MyGUI_Types.h:46
bool isHStretch() const
Definition MyGUI_Align.h:69
bool isVCenter() const
Definition MyGUI_Align.h:49
bool isVStretch() const
Definition MyGUI_Align.h:84
bool isRight() const
Definition MyGUI_Align.h:64
bool isHCenter() const
Definition MyGUI_Align.h:44
bool isBottom() const
Definition MyGUI_Align.h:79
void set(T const &_left, T const &_top, T const &_right, T const &_bottom)
Definition MyGUI_TRect.h:98