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

Method _setAlign

MyGUIEngine/src/MyGUI_Widget.cpp:612–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610 }
611
612 void Widget::_setAlign(const IntSize& _oldsize, const IntSize& _newSize)
613 {
614 const IntSize& size = _newSize; //getParentSize();
615
616 bool need_move = false;
617 bool need_size = false;
618 IntCoord coord = mCoord;
619
620 // первоначальное выравнивание
621 if (mAlign.isHStretch())
622 {
623 // растягиваем
624 coord.width = mCoord.width + (size.width - _oldsize.width);
625 need_size = true;
626 }
627 else if (mAlign.isRight())
628 {
629 // двигаем по правому краю
630 coord.left = mCoord.left + (size.width - _oldsize.width);
631 need_move = true;
632 }
633 else if (mAlign.isHCenter())
634 {
635 // выравнивание по горизонтали без растяжения
636 coord.left = (size.width - mCoord.width) / 2;
637 need_move = true;
638 }
639
640 if (mAlign.isVStretch())
641 {
642 // растягиваем
643 coord.height = mCoord.height + (size.height - _oldsize.height);
644 need_size = true;
645 }
646 else if (mAlign.isBottom())
647 {
648 // двигаем по нижнему краю
649 coord.top = mCoord.top + (size.height - _oldsize.height);
650 need_move = true;
651 }
652 else if (mAlign.isVCenter())
653 {
654 // выравнивание по вертикали без растяжения
655 coord.top = (size.height - mCoord.height) / 2;
656 need_move = true;
657 }
658
659 if (need_move)
660 {
661 if (need_size)
662 setCoord(coord);
663 else
664 setPosition(coord.point());
665 }
666 else if (need_size)
667 {
668 setSize(coord.size());
669 }

Callers 3

setSizeMethod · 0.45
setCoordMethod · 0.45
_setSkinItemAlignMethod · 0.45

Calls 6

setCoordFunction · 0.85
setPositionFunction · 0.85
setSizeFunction · 0.85
_updateViewFunction · 0.85
pointMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected