MCPcopy Create free account
hub / github.com/axmolengine/axmol / calculateFinalPositionWithRelativeAlign

Method calculateFinalPositionWithRelativeAlign

core/ui/UILayoutManager.cpp:555–648  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555void RelativeLayoutManager::calculateFinalPositionWithRelativeAlign()
556{
557 RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(_widget->getLayoutParameter());
558
559 Margin mg = layoutParameter->getMargin();
560
561 RelativeLayoutParameter::RelativeAlign align = layoutParameter->getAlign();
562
563 // handle margin
564 switch (align)
565 {
566 case RelativeLayoutParameter::RelativeAlign::NONE:
567 case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT:
568 _finalPositionX += mg.left;
569 _finalPositionY -= mg.top;
570 break;
571 case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL:
572 _finalPositionY -= mg.top;
573 break;
574 case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT:
575 _finalPositionX -= mg.right;
576 _finalPositionY -= mg.top;
577 break;
578 case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL:
579 _finalPositionX += mg.left;
580 break;
581 case RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT:
582 break;
583 case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL:
584 _finalPositionX -= mg.right;
585 break;
586 case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM:
587 _finalPositionX += mg.left;
588 _finalPositionY += mg.bottom;
589 break;
590 case RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL:
591 _finalPositionY += mg.bottom;
592 break;
593 case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM:
594 _finalPositionX -= mg.right;
595 _finalPositionY += mg.bottom;
596 break;
597
598 case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_LEFTALIGN:
599 _finalPositionY += mg.bottom;
600 _finalPositionX += mg.left;
601 break;
602 case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_RIGHTALIGN:
603 _finalPositionY += mg.bottom;
604 _finalPositionX -= mg.right;
605 break;
606 case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_CENTER:
607 _finalPositionY += mg.bottom;
608 break;
609
610 case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_TOPALIGN:
611 _finalPositionX -= mg.right;
612 _finalPositionY -= mg.top;

Callers 1

doLayoutMethod · 0.95

Calls 3

getLayoutParameterMethod · 0.80
getMarginMethod · 0.45
getAlignMethod · 0.45

Tested by

no test coverage detected