From: Seoyeon Kim Date: Tue, 21 Nov 2017 04:47:27 +0000 (+0900) Subject: [4.0] Fix the child position when Parent sets Padding X-Git-Tag: accepted/tizen/4.0/unified/20171129.150245~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F67%2F161867%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [4.0] Fix the child position when Parent sets Padding Change-Id: I40015356186292f42ec2358fdfc1346623d2884e Signed-off-by: Seoyeon Kim --- diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index cba5308..47a12b1 100755 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -657,11 +657,13 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) newChildSize.width = size.width - ( padding.start + padding.end ); newChildSize.height = size.height - ( padding.top + padding.bottom ); - Vector3 childPosition = child.GetTargetSize(); - childPosition.x += ( mImpl->mMargin.start + padding.start ); - childPosition.y += ( mImpl->mMargin.top + padding.top ); + // Cannot use childs Position property as it can already have padding and margin applied on it, + // so we end up cumulatively applying them over and over again. + Vector2 childOffset( 0.f, 0.f ); + childOffset.x += ( mImpl->mMargin.start + padding.start ); + childOffset.y += ( mImpl->mMargin.top + padding.top ); - child.SetPosition( childPosition ); + child.SetPosition( childOffset.x, childOffset.y ); } container.Add( child, newChildSize );