From: David Steele Date: Wed, 5 Sep 2018 10:04:28 +0000 (+0000) Subject: Merge "Actor's position and size is not updated after DevelControl::SetLayout." into... X-Git-Tag: dali_1.3.40~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=636f1454804a1566e47c968e7810c7080fc7b180;hp=70ca72bbf8864314c389eb0268406dd68a811da1 Merge "Actor's position and size is not updated after DevelControl::SetLayout." into devel/master --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp index f93257a..28ada5a 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Layouting.cpp @@ -3003,3 +3003,89 @@ int UtcDaliLayouting_LayoutGroupWithChildMargin01(void) END_TEST; } + +int UtcDaliLayouting_SetLayout(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliLayouting_SetLayout - Test reusing layouts"); + + Control rootControl; + SetupRootLayoutControl( rootControl ); + + auto container = Control::New(); + auto horizontalLayout = LinearLayout::New(); + horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); + DevelControl::SetLayout( container, horizontalLayout ); + container.SetName( "Container" ); + rootControl.Add( container ); + + std::vector< Control > controls; + controls.push_back( CreateLeafControl( 40, 40 ) ); + controls.push_back( CreateLeafControl( 60, 60 ) ); + + for( auto&& iter : controls ) + { + container.Add( iter ); + } + + container.SetParentOrigin( ParentOrigin::CENTER ); + container.SetAnchorPoint( AnchorPoint::CENTER ); + + // Ensure layouting happens + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + // Change a layout + auto verticalLayout = LinearLayout::New(); + verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); + DevelControl::SetLayout( container, verticalLayout ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + // Second round + DevelControl::SetLayout( container, horizontalLayout ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 10.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 40.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + // Change a layout + DevelControl::SetLayout( container, verticalLayout ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 40.0f, 40.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 60.0f, 60.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + END_TEST; +} diff --git a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp index 20e23f3..85fab8a 100644 --- a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp @@ -314,6 +314,10 @@ void LayoutItem::OnLayout( bool changed, LayoutLength left, LayoutLength top, La void LayoutItem::SetParent( LayoutParent* parent ) { mImpl->mLayoutParent = parent; + if ( parent == nullptr ) + { + mImpl->ClearPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ); + } } LayoutParent* LayoutItem::GetParent() @@ -441,7 +445,7 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame enter(%d, %d, %d, %d)\n", left.mValue, top.mValue, right.mValue, bottom.mValue ); - if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom ) + if( mImpl->mLeft != left || mImpl->mRight != right || mImpl->mTop != top || mImpl->mBottom != bottom || !mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ) ) { changed = true; @@ -456,7 +460,7 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig mImpl->mRight = right; mImpl->mBottom = bottom; - mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_HAS_BOUNDS ); + mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_SET_FRAME ); // Reflect up to parent control diff --git a/dali-toolkit/internal/layouting/layout-item-data-impl.h b/dali-toolkit/internal/layouting/layout-item-data-impl.h index 0e5c0e7..a2d2855 100644 --- a/dali-toolkit/internal/layouting/layout-item-data-impl.h +++ b/dali-toolkit/internal/layouting/layout-item-data-impl.h @@ -51,39 +51,12 @@ public: LayoutLength mTop; LayoutLength mBottom; - /** - * This view is visible. - * Use with {@link #setVisibility} and {@code - * android:visibility}. - */ - static const int VISIBLE = 0x00000000; - - /** - * This view is invisible, but it still takes up space for layout purposes. - * Use with {@link #setVisibility} and {@code - * android:visibility}. - */ - static const int INVISIBLE = 0x00000004; - - /** - * This view is invisible, and it doesn't take any space for layout - * purposes. Use with {@link #setVisibility} and {@code - * android:visibility}. - */ - static const int GONE = 0x00000008; - - /** - * Mask for use with setFlags indicating bits used for visibility. - * {@hide} - */ - static const int VISIBILITY_MASK = 0x0000000C; - static const int PRIVATE_FLAG_MEASURED_DIMENSION_SET = 0x00000001; static const int PRIVATE_FLAG_FORCE_LAYOUT = 0x00000002; static const int PRIVATE_FLAG_LAYOUT_REQUIRED = 0x00000004; static const int PRIVATE_FLAG_IS_LAID_OUT = 0x00000008; static const int PRIVATE_FLAG_MEASURE_NEEDED_BEFORE_LAYOUT = 0x00000010; ///< Flag indicating that a call to measure() was skipped and should be done instead when layout() is invoked. - static const int PRIVATE_FLAG_HAS_BOUNDS = 0x00000020; + static const int PRIVATE_FLAG_FORCE_SET_FRAME = 0x00000020; int mViewFlags; int mPrivateFlags;