MCPcopy Create free account
hub / github.com/MyGUI/mygui / snapToParent

Method snapToParent

Common/BaseLayout/BaseLayout.h:200–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198 }
199
200 void snapToParent(MyGUI::Widget* _child)
201 {
202 if (_child->isUserString("SnapTo"))
203 {
204 MyGUI::Align align = MyGUI::Align::parse(_child->getUserString("SnapTo"));
205
206 MyGUI::IntCoord coord = _child->getCoord();
207 MyGUI::IntSize size = _child->getParentSize();
208
209 if (align.isHStretch())
210 {
211 coord.left = 0;
212 coord.width = size.width;
213 }
214 else if (align.isLeft())
215 {
216 coord.left = 0;
217 }
218 else if (align.isRight())
219 {
220 coord.left = size.width - coord.width;
221 }
222 else
223 {
224 coord.left = (size.width - coord.width) / 2;
225 }
226
227 if (align.isVStretch())
228 {
229 coord.top = 0;
230 coord.height = size.height;
231 }
232 else if (align.isTop())
233 {
234 coord.top = 0;
235 }
236 else if (align.isBottom())
237 {
238 coord.top = size.height - coord.height;
239 }
240 else
241 {
242 coord.top = (size.height - coord.height) / 2;
243 }
244
245 _child->setCoord(coord);
246 }
247 }
248
249 template<typename T>
250 T* _createFakeWidget(MyGUI::Widget* _parent)

Callers

nothing calls this directly

Calls 5

isUserStringMethod · 0.80
getUserStringMethod · 0.80
getParentSizeMethod · 0.80
parseFunction · 0.50
setCoordMethod · 0.45

Tested by

no test coverage detected