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

Method getSnappedCoord

MyGUIEngine/src/MyGUI_Window.cpp:372–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370 }
371
372 void Window::getSnappedCoord(IntCoord& _coord, Snap snapMode) const
373 {
374 const IntSize view_size = getParentSize();
375 bool nearLeftSide = abs(_coord.left) <= WINDOW_SNAP_DISTANSE;
376 bool nearTopSide = abs(_coord.top) <= WINDOW_SNAP_DISTANSE;
377 bool nearRightSide = abs(_coord.left + _coord.width - view_size.width) <= WINDOW_SNAP_DISTANSE;
378 bool nearBottomSide = abs(_coord.top + _coord.height - view_size.height) <= WINDOW_SNAP_DISTANSE;
379
380 switch (snapMode)
381 {
382 case Snap::Position:
383 if (nearLeftSide)
384 _coord.left = 0;
385 if (nearTopSide)
386 _coord.top = 0;
387
388 if (nearRightSide)
389 _coord.left = view_size.width - _coord.width;
390 if (nearBottomSide)
391 _coord.top = view_size.height - _coord.height;
392 break;
393 case Snap::Size:
394 if (nearLeftSide)
395 {
396 _coord.width = _coord.right();
397 _coord.left = 0;
398 }
399 if (nearTopSide)
400 {
401 _coord.height = _coord.bottom();
402 _coord.top = 0;
403 }
404
405 if (nearRightSide)
406 _coord.width = view_size.width - _coord.left;
407 if (nearBottomSide)
408 _coord.height = view_size.height - _coord.top;
409 break;
410 }
411 }
412
413 void Window::setVisibleSmooth(bool _visible)
414 {

Callers

nothing calls this directly

Calls 2

rightMethod · 0.80
bottomMethod · 0.80

Tested by

no test coverage detected