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

Method scrollChildren

core/ui/UIScrollView.cpp:666–742  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

664}
665
666void ScrollView::scrollChildren(const Vec2& deltaMove)
667{
668 Vec2 realMove = deltaMove;
669 if (_bounceEnabled)
670 {
671 // If the position of the inner container is out of the boundary, the offsets should be divided by two.
672 Vec2 outOfBoundary = getHowMuchOutOfBoundary();
673 realMove.x *= (outOfBoundary.x == 0 ? 1 : 0.5f);
674 realMove.y *= (outOfBoundary.y == 0 ? 1 : 0.5f);
675 }
676
677 if (!_bounceEnabled)
678 {
679 Vec2 outOfBoundary = getHowMuchOutOfBoundary(realMove);
680 realMove += outOfBoundary;
681 }
682
683 bool scrolledToLeft = false;
684 bool scrolledToRight = false;
685 bool scrolledToTop = false;
686 bool scrolledToBottom = false;
687 if (realMove.y > 0.0f) // up
688 {
689 float icBottomPos = _innerContainer->getBottomBoundary();
690 if (icBottomPos + realMove.y >= _bottomBoundary)
691 {
692 scrolledToBottom = true;
693 }
694 }
695 else if (realMove.y < 0.0f) // down
696 {
697 float icTopPos = _innerContainer->getTopBoundary();
698 if (icTopPos + realMove.y <= _topBoundary)
699 {
700 scrolledToTop = true;
701 }
702 }
703
704 if (realMove.x < 0.0f) // left
705 {
706 float icRightPos = _innerContainer->getRightBoundary();
707 if (icRightPos + realMove.x <= _rightBoundary)
708 {
709 scrolledToRight = true;
710 }
711 }
712 else if (realMove.x > 0.0f) // right
713 {
714 float icLeftPos = _innerContainer->getLeftBoundary();
715 if (icLeftPos + realMove.x >= _leftBoundary)
716 {
717 scrolledToLeft = true;
718 }
719 }
720 moveInnerContainer(realMove, false);
721
722 if (realMove.x != 0 || realMove.y != 0)
723 {

Callers

nothing calls this directly

Calls 4

getBottomBoundaryMethod · 0.80
getTopBoundaryMethod · 0.80
getRightBoundaryMethod · 0.80
getLeftBoundaryMethod · 0.80

Tested by

no test coverage detected