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

Method relocateContainer

extensions/GUI/src/GUI/ScrollView/ScrollView.cpp:381–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381void ScrollView::relocateContainer(bool animated)
382{
383 Vec2 oldPoint, min, max;
384 float newX, newY;
385
386 min = this->minContainerOffset();
387 max = this->maxContainerOffset();
388
389 oldPoint = _container->getPosition();
390
391 newX = oldPoint.x;
392 newY = oldPoint.y;
393 if (_direction == Direction::BOTH || _direction == Direction::HORIZONTAL)
394 {
395 newX = MAX(newX, min.x);
396 newX = MIN(newX, max.x);
397 }
398
399 if (_direction == Direction::BOTH || _direction == Direction::VERTICAL)
400 {
401 newY = MIN(newY, max.y);
402 newY = MAX(newY, min.y);
403 }
404
405 if (newY != oldPoint.y || newX != oldPoint.x)
406 {
407 this->setContentOffset(Vec2(newX, newY), animated);
408 }
409}
410
411Vec2 ScrollView::maxContainerOffset()
412{

Callers 1

deaccelerateScrollingMethod · 0.95

Calls 5

minContainerOffsetMethod · 0.95
maxContainerOffsetMethod · 0.95
setContentOffsetMethod · 0.95
Vec2Function · 0.50
getPositionMethod · 0.45

Tested by

no test coverage detected