|
|
@@ -425,6 +425,8 @@ const Vector2& Container::getScrollPosition() const
|
|
|
void Container::setScrollPosition(const Vector2& scrollPosition)
|
|
|
{
|
|
|
_scrollPosition = scrollPosition;
|
|
|
+ setDirty(DIRTY_BOUNDS);
|
|
|
+ setChildrenDirty(DIRTY_BOUNDS, true);
|
|
|
}
|
|
|
|
|
|
Animation* Container::getAnimation(const char* id) const
|
|
|
@@ -542,9 +544,6 @@ void Container::updateState(State state)
|
|
|
|
|
|
void Container::updateBounds()
|
|
|
{
|
|
|
- // Compute total bounds of container
|
|
|
- Control::updateBounds();
|
|
|
-
|
|
|
// Handle automatically sizing based on our children
|
|
|
if (_autoSize != AUTO_SIZE_NONE)
|
|
|
{
|
|
|
@@ -557,7 +556,7 @@ void Container::updateBounds()
|
|
|
Control* ctrl = _controls[i];
|
|
|
if (ctrl->isVisible() && !ctrl->isWidthPercentage())
|
|
|
{
|
|
|
- float w = ctrl->getWidth();
|
|
|
+ float w = ctrl->getWidth() + ctrl->getMargin().right;
|
|
|
if (!ctrl->isXPercentage())
|
|
|
w += ctrl->getX();
|
|
|
if (width < w)
|
|
|
@@ -577,7 +576,7 @@ void Container::updateBounds()
|
|
|
Control* ctrl = _controls[i];
|
|
|
if (ctrl->isVisible() && !ctrl->isHeightPercentage())
|
|
|
{
|
|
|
- float h = ctrl->getHeight();
|
|
|
+ float h = ctrl->getHeight() + ctrl->getMargin().bottom;
|
|
|
if (!ctrl->isYPercentage())
|
|
|
h += ctrl->getY();
|
|
|
if (height < h)
|
|
|
@@ -589,6 +588,9 @@ void Container::updateBounds()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Compute total bounds of container
|
|
|
+ Control::updateBounds();
|
|
|
+
|
|
|
// Update layout to position children correctly within us
|
|
|
GP_ASSERT(_layout);
|
|
|
_layout->update(this);
|
|
|
@@ -636,7 +638,7 @@ bool Container::updateChildBounds()
|
|
|
if (changed)
|
|
|
{
|
|
|
Control* parent = this;
|
|
|
- while (parent && parent->_autoSize != AUTO_SIZE_NONE)
|
|
|
+ while (parent && (parent->_autoSize != AUTO_SIZE_NONE || static_cast<Container *>(parent)->getLayout()->getType() != Layout::LAYOUT_ABSOLUTE))
|
|
|
{
|
|
|
parent->setDirty(DIRTY_BOUNDS);
|
|
|
parent = parent->_parent;
|
|
|
@@ -1086,6 +1088,9 @@ void Container::updateScroll()
|
|
|
{
|
|
|
Control* control = _controls[i];
|
|
|
|
|
|
+ if (!control->isVisible())
|
|
|
+ continue;
|
|
|
+
|
|
|
const Rectangle& bounds = control->getBounds();
|
|
|
const Theme::Margin& margin = control->getMargin();
|
|
|
|
|
|
@@ -1134,34 +1139,35 @@ void Container::updateScroll()
|
|
|
}
|
|
|
|
|
|
// Stop scrolling when the far edge is reached.
|
|
|
+ Vector2 lastScrollPosition(_scrollPosition);
|
|
|
+
|
|
|
if (-_scrollPosition.x > _totalWidth - clipWidth)
|
|
|
{
|
|
|
_scrollPosition.x = -(_totalWidth - clipWidth);
|
|
|
_scrollingVelocity.x = 0;
|
|
|
- dirty = true;
|
|
|
}
|
|
|
|
|
|
if (-_scrollPosition.y > _totalHeight - clipHeight)
|
|
|
{
|
|
|
_scrollPosition.y = -(_totalHeight - clipHeight);
|
|
|
_scrollingVelocity.y = 0;
|
|
|
- dirty = true;
|
|
|
}
|
|
|
|
|
|
if (_scrollPosition.x > 0)
|
|
|
{
|
|
|
_scrollPosition.x = 0;
|
|
|
_scrollingVelocity.x = 0;
|
|
|
- dirty = true;
|
|
|
}
|
|
|
|
|
|
if (_scrollPosition.y > 0)
|
|
|
{
|
|
|
_scrollPosition.y = 0;
|
|
|
_scrollingVelocity.y = 0;
|
|
|
- dirty = true;
|
|
|
}
|
|
|
|
|
|
+ if (_scrollPosition != lastScrollPosition)
|
|
|
+ dirty = true;
|
|
|
+
|
|
|
float scrollWidth = 0;
|
|
|
if (clipWidth < _totalWidth)
|
|
|
scrollWidth = (clipWidth / _totalWidth) * clipWidth;
|
|
|
@@ -1291,6 +1297,7 @@ bool Container::touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned i
|
|
|
_scrollingLastTime = gameTime;
|
|
|
setDirty(DIRTY_BOUNDS);
|
|
|
setChildrenDirty(DIRTY_BOUNDS, true);
|
|
|
+ updateScroll();
|
|
|
return false;
|
|
|
}
|
|
|
break;
|