From: Adeel Kazmi Date: Fri, 9 Nov 2018 10:29:40 +0000 (+0000) Subject: Merge "Parent of TextLabel does not resize when text changes" into devel/master X-Git-Tag: dali_1.3.50~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=c021084d852437ece9f71cce1feab7933bc839da;hp=c50913a6361a4ba502d4d248bf59e1efb867b2ab Merge "Parent of TextLabel does not resize when text changes" into devel/master --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingAnimation.cpp b/automated-tests/src/dali-toolkit/utc-Dali-LayoutingAnimation.cpp index ead839d..c7e2e4f 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-LayoutingAnimation.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-LayoutingAnimation.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -56,7 +57,7 @@ struct LayoutTransitionFinishCheck { } - void operator()( LayoutTransitionData::LayoutTransitionType type, LayoutTransitionData& layoutTransitionData ) + void operator()( LayoutTransitionData::Type type, LayoutTransitionData& layoutTransitionData ) { mSignalReceived = true; } @@ -153,22 +154,44 @@ int UtcDaliLayouting_LayoutTransitionDataSetGetTransition(void) auto layout = LinearLayout::New(); auto layoutTransitionData = LayoutTransitionData::New(); - layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); - - layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, LayoutTransitionData() ); layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == layoutTransitionData ); DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() ); layout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, LayoutTransitionData() ); layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, layoutTransitionData ); - DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == layoutTransitionData ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() ); + + layout.SetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE, LayoutTransitionData() ); + layout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == layoutTransitionData ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() ); + + layout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, LayoutTransitionData() ); + layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == layoutTransitionData ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == LayoutTransitionData() ); + + layout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, LayoutTransitionData() ); + layout.SetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE, layoutTransitionData ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_ADD ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_REMOVE ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_OWNER_SET ) == LayoutTransitionData() ); + DALI_TEST_CHECK( layout.GetTransitionData( LayoutTransitionData::ON_LAYOUT_CHANGE ) == layoutTransitionData ); END_TEST; } @@ -181,11 +204,11 @@ int UtcDaliLayouting_SetLayoutTransition01(void) Stage stage = Stage::GetCurrent(); auto container = Control::New(); auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( true ); + horizontalLayout.SetAnimateLayout( false ); horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); auto verticalLayout = LinearLayout::New(); - verticalLayout.SetAnimateLayout( true ); + verticalLayout.SetAnimateLayout( false ); verticalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); DevelControl::SetLayout( container, horizontalLayout ); @@ -198,9 +221,6 @@ int UtcDaliLayouting_SetLayoutTransition01(void) { container.Add( iter ); } - - container.SetParentOrigin( ParentOrigin::CENTER ); - container.SetAnchorPoint( AnchorPoint::CENTER ); stage.Add( container ); auto layoutTransitionData = LayoutTransitionData::New(); @@ -257,12 +277,11 @@ int UtcDaliLayouting_SetLayoutTransition01(void) application.Render(); // First round, no animation - // TODO: container size (0, 0) after it is added to the stage should be fixed with HQ patch soon 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, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); @@ -270,6 +289,9 @@ int UtcDaliLayouting_SetLayoutTransition01(void) LayoutTransitionFinishCheck finishCheck(signalReceived); layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); + horizontalLayout.SetAnimateLayout( true ); + verticalLayout.SetAnimateLayout( true ); + // Change a layout, start transition verticalLayout.SetTransitionData( LayoutTransitionData::ON_OWNER_SET, layoutTransitionData ); DevelControl::SetLayout( container, verticalLayout ); @@ -373,8 +395,6 @@ int UtcDaliLayouting_AddChildLayoutTransition01(void) std::vector< Control > controls; controls.push_back( CreateLeafControl( 100, 100 ) ); - container.SetParentOrigin( ParentOrigin::CENTER ); - container.SetAnchorPoint( AnchorPoint::CENTER ); stage.Add( container ); auto layoutTransitionData = LayoutTransitionData::New(); @@ -393,6 +413,7 @@ int UtcDaliLayouting_AddChildLayoutTransition01(void) { // Instant position for a child Property::Map map; + map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::NONE; map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "position"; map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") @@ -404,6 +425,7 @@ int UtcDaliLayouting_AddChildLayoutTransition01(void) { // Grow a child from (0,0) size to full size (captured) Property::Map map; + map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_ADD; map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = "size"; map[ LayoutTransitionData::AnimatorKey::INITIAL_VALUE ] = Vector3( 0.0f, 0.0f, 0 ); map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() @@ -411,7 +433,7 @@ int UtcDaliLayouting_AddChildLayoutTransition01(void) .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( controls[0], map ); + layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to an added child } horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); @@ -462,17 +484,16 @@ int UtcDaliLayouting_RemoveChildLayoutTransition01(void) Stage stage = Stage::GetCurrent(); auto container = Control::New(); auto horizontalLayout = LinearLayout::New(); - horizontalLayout.SetAnimateLayout( true ); + horizontalLayout.SetAnimateLayout( false ); horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); DevelControl::SetLayout( container, horizontalLayout ); - container.SetName( "Container"); + container.SetName( "Container" ); std::vector< Control > controls; controls.push_back( CreateLeafControl( 100, 100 ) ); controls.push_back( CreateLeafControl( 100, 100 ) ); - container.SetParentOrigin( ParentOrigin::CENTER ); - container.SetAnchorPoint( AnchorPoint::CENTER ); + stage.Add( container ); container.Add( controls[0] ); container.Add( controls[1] ); @@ -481,6 +502,8 @@ int UtcDaliLayouting_RemoveChildLayoutTransition01(void) application.SendNotification(); application.Render(); + horizontalLayout.SetAnimateLayout( true ); + auto layoutTransitionData = LayoutTransitionData::New(); { // Instant resize for parent width @@ -561,7 +584,21 @@ int UtcDaliLayouting_RemoveChildLayoutTransition01(void) layoutTransitionData.AddPropertyAnimator( Actor(), map ); } { - // Instant position for a child + // Shrink the removed child + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_REMOVE; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Size( 0.0f, 0.0f ); + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_TO" ) + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); + layoutTransitionData.AddPropertyAnimator( Actor(), map ); + } + { + // Instant position for children Property::Map map; map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_X; map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() @@ -573,7 +610,7 @@ int UtcDaliLayouting_RemoveChildLayoutTransition01(void) layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent } { - // Instant position for a child + // Instant position for children Property::Map map; map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION_Y; map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() @@ -602,7 +639,7 @@ int UtcDaliLayouting_RemoveChildLayoutTransition01(void) DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); // this control is already removed from the tree. DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); @@ -613,7 +650,7 @@ int UtcDaliLayouting_RemoveChildLayoutTransition01(void) DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // this control is already removed from the tree. - DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION ); DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 0.0f, 0.0f, 0.0f ), 1.0f, TEST_LOCATION ); @@ -627,13 +664,153 @@ int UtcDaliLayouting_RemoveChildLayoutTransition01(void) 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, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); // this control is already removed from the tree. + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 1.0f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + // this control is already removed from the tree. + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); + + finishCheck.CheckSignalReceived(); + + END_TEST; +} + +int UtcDaliLayouting_FocusChildLayoutTransition01(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliLayouting_FocusChildLayoutTransition01"); + + Stage stage = Stage::GetCurrent(); + auto container = Control::New(); + auto horizontalLayout = LinearLayout::New(); + horizontalLayout.SetAnimateLayout( false ); + horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); + + DevelControl::SetLayout( container, horizontalLayout ); + container.SetName( "Container" ); + + std::vector< Control > controls; + controls.push_back( CreateLeafControl( 100, 100 ) ); + controls.push_back( CreateLeafControl( 100, 100 ) ); + + stage.Add( container ); + container.Add( controls[0] ); + container.Add( controls[1] ); + + KeyInputFocusManager manager = KeyInputFocusManager::Get(); + manager.SetFocus( controls[0] ); + + // Initial rendering done + 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, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); - // this control is already removed from the tree. DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + horizontalLayout.SetAnimateLayout( true ); + + auto layoutTransitionData = LayoutTransitionData::New(); + { + // Instant resize for parent + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR" ) + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); + layoutTransitionData.AddPropertyAnimator( container, map ); + } + { + // Instant position for parent + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); + layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to all children except parent + } + { + // Shrink the lost focus child + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; + map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_LOST; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 80.0f, 80.0f, 0 ); + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); + layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus lost child + } + { + // Grow the gained focus child + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; + map[ LayoutTransitionData::AnimatorKey::CONDITION ] = LayoutTransitionData::Condition::ON_FOCUS_GAINED; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Vector3( 120.0f, 120.0f, 0 ); + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); + layoutTransitionData.AddPropertyAnimator( Actor(), map ); // apply to on focus gained child + } + + horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_FOCUS, layoutTransitionData ); + + bool signalReceived(false); + LayoutTransitionFinishCheck finishCheck(signalReceived); + layoutTransitionData.FinishedSignal().Connect(&application, finishCheck); + manager.SetFocus( controls[1] ); + + application.SendNotification(); + application.Render( 1u /*just very beginning of the animation*/ ); + + finishCheck.CheckSignalNotReceived(); + // Animation just started + DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast( 0.5f * 1000.0f ) + 1u /*just after the end of the animation*/ ); + + // Animation just finished + DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 80.0f, 80.0f, 0.0f ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetCurrentSize(), Vector3( 120.0f, 120.0f, 0.0f ), 1.0f, TEST_LOCATION ); + + application.SendNotification(); + application.Render( 10u /* wait a bit more for a signal */ ); + + // Now sizes and positions are finally set + 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, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 80.0f, 80.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 120.0f, 120.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + finishCheck.CheckSignalReceived(); END_TEST; @@ -655,8 +832,6 @@ int UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames(void) std::vector< Control > controls; controls.push_back( CreateLeafControl( 100, 100 ) ); - container.SetParentOrigin( ParentOrigin::CENTER ); - container.SetAnchorPoint( AnchorPoint::CENTER ); stage.Add( container ); auto layoutTransitionData = LayoutTransitionData::New(); @@ -690,14 +865,15 @@ int UtcDaliLayouting_AddChildLayoutTransition02_KeyFrames(void) keyFrames.Add( 0.5f, Vector3( 100.0f, 100.0f, 0 ) ); Property::Map map; - map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; - map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() - .Add( LayoutTransitionData::AnimatorKey::TYPE, "ANIMATE_BETWEEN") - .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, "LINEAR") - .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() - .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f) - .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.5f)); - layoutTransitionData.AddPropertyAnimator( controls[0], map, keyFrames, Animation::Interpolation::Linear ); + map[ "property" ] = Actor::Property::SIZE; + map[ "condition" ] = LayoutTransitionData::Condition::ON_ADD; + map[ "animator" ] = Property::Map() + .Add( "type", "ANIMATE_BETWEEN") + .Add( "alphaFunction", "LINEAR") + .Add( "timePeriod", Property::Map() + .Add( "delay", 0.0f) + .Add( "duration", 0.5f)); + layoutTransitionData.AddPropertyAnimator( Actor(), map, keyFrames, Animation::Interpolation::Linear ); } horizontalLayout.SetTransitionData( LayoutTransitionData::ON_CHILD_ADD, layoutTransitionData ); @@ -756,8 +932,6 @@ int UtcDaliLayouting_AddChildLayoutTransition03_Path(void) std::vector< Control > controls; controls.push_back( CreateLeafControl( 100, 100 ) ); - container.SetParentOrigin( ParentOrigin::CENTER ); - container.SetAnchorPoint( AnchorPoint::CENTER ); stage.Add( container ); auto layoutTransitionData = LayoutTransitionData::New(); @@ -886,8 +1060,6 @@ int UtcDaliLayouting_AddChildLayoutTransition04_AnimateBy(void) std::vector< Control > controls; controls.push_back( CreateLeafControl( 100, 100 ) ); - container.SetParentOrigin( ParentOrigin::CENTER ); - container.SetAnchorPoint( AnchorPoint::CENTER ); stage.Add( container ); auto layoutTransitionData = LayoutTransitionData::New(); @@ -983,8 +1155,6 @@ int UtcDaliLayouting_AddChildLayoutTransition05(void) std::vector< Control > controls; controls.push_back( CreateLeafControl( 100, 100 ) ); - container.SetParentOrigin( ParentOrigin::CENTER ); - container.SetAnchorPoint( AnchorPoint::CENTER ); stage.Add( container ); auto layoutTransitionData = LayoutTransitionData::New(); @@ -1209,3 +1379,119 @@ int UtcDaliLayouting_AddChildLayoutTransition05(void) END_TEST; } +int UtcDaliLayouting_DefaultTransition01(void) +{ + ToolkitTestApplication application; + tet_infoline(" UtcDaliLayouting_DefaultTransition01"); + + Stage stage = Stage::GetCurrent(); + auto container = Control::New(); + auto horizontalLayout = LinearLayout::New(); + horizontalLayout.SetAnimateLayout( false ); + horizontalLayout.SetOrientation( LinearLayout::Orientation::HORIZONTAL ); + + DevelControl::SetLayout( container, horizontalLayout ); + container.SetName( "Container" ); + + std::vector< Control > controls; + controls.push_back( CreateLeafControl( 100, 100 ) ); + controls.push_back( CreateLeafControl( 100, 100 ) ); + + stage.Add( container ); + container.Add( controls[0] ); + container.Add( controls[1] ); + + // Initial rendering done + 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, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 100.0f, 350.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + horizontalLayout.SetAnimateLayout( true ); + + auto layoutTransitionData0 = LayoutTransitionData::New(); + { + // Default instant resize + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); + layoutTransitionData0.AddPropertyAnimator( controls[0], map ); + } + { + // Instant instant position + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); + layoutTransitionData0.AddPropertyAnimator( controls[0], map ); + } + DevelControl::GetLayout( controls[0] ).SetTransitionData(LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData0 ); + + auto layoutTransitionData1 = LayoutTransitionData::New(); + { + // Default instant resize + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::SIZE; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); + layoutTransitionData1.AddPropertyAnimator( controls[1], map ); + } + { + // Instant instant position + Property::Map map; + map[ LayoutTransitionData::AnimatorKey::PROPERTY ] = Actor::Property::POSITION; + map[ LayoutTransitionData::AnimatorKey::TARGET_VALUE ] = Property::Value(); // capture from layout update + map[ LayoutTransitionData::AnimatorKey::ANIMATOR ] = Property::Map() + .Add( LayoutTransitionData::AnimatorKey::ALPHA_FUNCTION, AlphaFunction::LINEAR ) + .Add( LayoutTransitionData::AnimatorKey::TIME_PERIOD, Property::Map() + .Add( LayoutTransitionData::AnimatorKey::DELAY, 0.0f ) + .Add( LayoutTransitionData::AnimatorKey::DURATION, 0.0f ) ); + layoutTransitionData0.AddPropertyAnimator( controls[1], map ); + } + DevelControl::GetLayout( controls[1] ).SetTransitionData(LayoutTransitionData::Type::ON_LAYOUT_CHANGE, layoutTransitionData1 ); + + horizontalLayout.SetOrientation( LinearLayout::Orientation::VERTICAL ); + + application.SendNotification(); + application.Render( 10u /*just very beginning of the animation*/ ); + + // Animation just finished + DALI_TEST_EQUALS( container.GetCurrentPosition(), Vector3( 0.0f, 0.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetCurrentPosition(), Vector3( 0.0f, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetCurrentPosition(), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetCurrentSize(), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetCurrentSize(), Vector3( 100.0f, 100.0f, 0.0f ), 1.0f, TEST_LOCATION ); + + // Now sizes and positions are set + 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, 300.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::POSITION ), Vector3( 0.0f, 400.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + DALI_TEST_EQUALS( container.GetProperty( Actor::Property::SIZE ), Vector3( 480.0f, 800.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[0].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + DALI_TEST_EQUALS( controls[1].GetProperty( Actor::Property::SIZE ), Vector3( 100.0f, 100.0f, 0.0f ), 0.0001f, TEST_LOCATION ); + + END_TEST; +} + diff --git a/dali-toolkit/devel-api/layouting/layout-controller.cpp b/dali-toolkit/devel-api/layouting/layout-controller.cpp index ba87af2..95a2619 100644 --- a/dali-toolkit/devel-api/layouting/layout-controller.cpp +++ b/dali-toolkit/devel-api/layouting/layout-controller.cpp @@ -68,12 +68,17 @@ LayoutController LayoutController::Get() void LayoutController::RequestLayout( LayoutItem layout ) { - GetImpl( *this ).RequestLayout( GetImplementation( layout ), -1 ); + GetImpl( *this ).RequestLayout( GetImplementation( layout ), -1, Actor(), Actor() ); } -void LayoutController::RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::LayoutTransitionType layoutTransitionType ) +void LayoutController::RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::Type layoutTransitionType ) { - GetImpl( *this ).RequestLayout( GetImplementation( layout ), layoutTransitionType ); + GetImpl( *this ).RequestLayout( GetImplementation( layout ), layoutTransitionType, Actor(), Actor() ); +} + +void LayoutController::RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::Type layoutTransitionType, Actor gainedChild, Actor lostChild ) +{ + GetImpl( *this ).RequestLayout( GetImplementation( layout ), layoutTransitionType, gainedChild, lostChild ); } LayoutController::LayoutController( Internal::LayoutController *impl ) diff --git a/dali-toolkit/devel-api/layouting/layout-controller.h b/dali-toolkit/devel-api/layouting/layout-controller.h index 062793d..951a4fc 100755 --- a/dali-toolkit/devel-api/layouting/layout-controller.h +++ b/dali-toolkit/devel-api/layouting/layout-controller.h @@ -74,7 +74,17 @@ public: * @param[in] layout The layout to measure & relayout. * @param[in] layoutTransitionType The layout transition type. */ - void RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::LayoutTransitionType layoutTransitionType ); + void RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::Type layoutTransitionType ); + + /** + * @brief Request for a particular layout (wrapping a control or a visual) to be measured and laid out. A specified layout transition + * will be triggered during the layout. + * @param[in] layout The layout to measure & relayout. + * @param[in] layoutTransitionType The layout transition type. + * @param[in] gainedChild The gained layout owner's child. + * @param[in] lostChild The lost layout owner's child. + */ + void RequestLayout( LayoutItem layout, Dali::Toolkit::LayoutTransitionData::Type layoutTransitionType, Actor gainedChild, Actor lostChild ); public: /// @cond internal diff --git a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp index 304cec5..8ddc819 100644 --- a/dali-toolkit/devel-api/layouting/layout-group-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-group-impl.cpp @@ -552,7 +552,7 @@ void LayoutGroup::OnInitialize() } } - RequestLayout( Dali::Toolkit::LayoutTransitionData::LayoutTransitionType::ON_OWNER_SET ); + RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_OWNER_SET ); } } @@ -585,7 +585,7 @@ void LayoutGroup::RemoveChild( LayoutItem& item ) void LayoutGroup::ChildAddedToOwner( Actor child ) { ChildAddedToOwnerImpl( child ); - RequestLayout( Dali::Toolkit::LayoutTransitionData::LayoutTransitionType::ON_CHILD_ADD ); + RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_CHILD_ADD, child, Actor() ); } void LayoutGroup::ChildAddedToOwnerImpl( Actor child ) @@ -670,7 +670,7 @@ void LayoutGroup::ChildRemovedFromOwner( Actor child ) if( childLayout ) { Remove( *childLayout.Get() ); - RequestLayout( Dali::Toolkit::LayoutTransitionData::LayoutTransitionType::ON_CHILD_REMOVE ); + RequestLayout( Dali::Toolkit::LayoutTransitionData::Type::ON_CHILD_REMOVE, child, Actor() ); } } } diff --git a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp index cd4cf40..0b638de 100644 --- a/dali-toolkit/devel-api/layouting/layout-item-impl.cpp +++ b/dali-toolkit/devel-api/layouting/layout-item-impl.cpp @@ -152,9 +152,15 @@ void LayoutItem::SetTransitionData( int layoutTransitionType, Internal::LayoutTr case Dali::Toolkit::LayoutTransitionData::ON_CHILD_REMOVE: mImpl->mOnChildRemoveTransitionData = layoutTransitionDataPtr; break; + case Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS: + mImpl->mOnChildFocusTransitionData = layoutTransitionDataPtr; + break; case Dali::Toolkit::LayoutTransitionData::ON_OWNER_SET: mImpl->mOnOwnerSetTransitionData = layoutTransitionDataPtr; break; + case Dali::Toolkit::LayoutTransitionData::ON_LAYOUT_CHANGE: + mImpl->mOnLayoutChangeTransitionData = layoutTransitionDataPtr; + break; default: break; } @@ -168,8 +174,12 @@ Internal::LayoutTransitionDataPtr LayoutItem::GetTransitionData( int layoutTrans return mImpl->mOnChildAddTransitionData.Get(); case Dali::Toolkit::LayoutTransitionData::ON_CHILD_REMOVE: return mImpl->mOnChildRemoveTransitionData.Get(); + case Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS: + return mImpl->mOnChildFocusTransitionData.Get(); case Dali::Toolkit::LayoutTransitionData::ON_OWNER_SET: return mImpl->mOnOwnerSetTransitionData.Get(); + case Dali::Toolkit::LayoutTransitionData::ON_LAYOUT_CHANGE: + return mImpl->mOnLayoutChangeTransitionData.Get(); default: return LayoutTransitionDataPtr(); } @@ -417,7 +427,7 @@ void LayoutItem::RequestLayout() layoutController.RequestLayout( Toolkit::LayoutItem( this ) ); } -void LayoutItem::RequestLayout( Dali::Toolkit::LayoutTransitionData::LayoutTransitionType layoutAnimationType ) +void LayoutItem::RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutAnimationType ) { Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner ); if ( control ) @@ -431,6 +441,20 @@ void LayoutItem::RequestLayout( Dali::Toolkit::LayoutTransitionData::LayoutTrans layoutController.RequestLayout( Toolkit::LayoutItem(this), layoutAnimationType ); } +void LayoutItem::RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutAnimationType, Actor gainedChild, Actor lostChild ) +{ + Toolkit::Control control = Toolkit::Control::DownCast( mImpl->mOwner ); + if ( control ) + { + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::RequestLayout control(%s) layoutTranstionType(%d)\n", + control.GetName().c_str(), (int)layoutAnimationType ); + } + // @todo Enforce failure if called in Measure/Layout passes. + mImpl->SetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); + Toolkit::LayoutController layoutController = Toolkit::LayoutController::Get(); + layoutController.RequestLayout( Toolkit::LayoutItem(this), layoutAnimationType, gainedChild, lostChild ); +} + bool LayoutItem::IsLayoutRequested() const { return mImpl->GetPrivateFlag( Impl::PRIVATE_FLAG_FORCE_LAYOUT ); @@ -579,7 +603,6 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig { if( mImpl->mAnimated && !layoutData.speculativeLayout ) { - LayoutItem* transitionOwner = layoutData.layoutTransition.layoutItem.Get(); LayoutTransitionDataPtr layoutTransitionDataPtr = GetTransitionData( layoutData.layoutTransition.layoutTransitionType ); @@ -595,9 +618,25 @@ bool LayoutItem::SetFrame( LayoutLength left, LayoutLength top, LayoutLength rig { if( changed ) { - DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame apply default transition to (%s), transition type (%d)\n", actor.GetName().c_str(), layoutData.layoutTransition.layoutTransitionType ); + layoutTransitionDataPtr = GetTransitionData( Dali::Toolkit::LayoutTransitionData::ON_LAYOUT_CHANGE ); + if ( layoutTransitionDataPtr ) + { + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame apply custom default transition to (%s), transition type (%d)\n", actor.GetName().c_str(), Dali::Toolkit::LayoutTransitionData::ON_LAYOUT_CHANGE ); + layoutData.layoutPositionDataArray.push_back( LayoutPositionData( actor, left.AsDecimal(), top.AsDecimal(), right.AsDecimal(), bottom.AsDecimal(), true ) ); + layoutTransitionDataPtr->ConvertToLayoutDataElements( actor, layoutData ); + } + else + { + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame apply default transition to (%s), transition type (%d)\n", actor.GetName().c_str(), layoutData.layoutTransition.layoutTransitionType ); + layoutData.layoutPositionDataArray.push_back( LayoutPositionData( actor, left.AsDecimal(), top.AsDecimal(), right.AsDecimal(), bottom.AsDecimal(), true ) ); + GetDefaultTransition()->ConvertToLayoutDataElements( actor, layoutData ); + } + } + else + { + DALI_LOG_INFO( gLayoutFilter, Debug::Verbose, "LayoutItem::SetFrame apply children animators to (%s), transition type (%d)\n", actor.GetName().c_str(), layoutData.layoutTransition.layoutTransitionType ); layoutData.layoutPositionDataArray.push_back( LayoutPositionData( actor, left.AsDecimal(), top.AsDecimal(), right.AsDecimal(), bottom.AsDecimal(), true ) ); - GetDefaultTransition()->ConvertToLayoutDataElements( actor, layoutData ); + LayoutTransitionData::ConvertChildrenAnimatorsToLayoutDataElements( actor, layoutData ); } } } diff --git a/dali-toolkit/devel-api/layouting/layout-item-impl.h b/dali-toolkit/devel-api/layouting/layout-item-impl.h index 19b61d5..47d65cc 100644 --- a/dali-toolkit/devel-api/layouting/layout-item-impl.h +++ b/dali-toolkit/devel-api/layouting/layout-item-impl.h @@ -209,7 +209,17 @@ public: * * This will make this layout and all it's parent layouts dirty and set the transition queued. */ - void RequestLayout( Dali::Toolkit::LayoutTransitionData::LayoutTransitionType layoutTranstionType ); + void RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutTranstionType ); + + /** + * @brief Request that this layout is re-laid out with particular transition. + * @param[in] layoutTranstionType The transition type + * @param[in] gainedChild The gained owners's child due to add/remove or focus gained/lost + * @param[in] lostChild The lost owners's child due to add/remove or focus gained/lost + * + * This will make this layout and all it's parent layouts dirty and set the transition queued. + */ + void RequestLayout( Dali::Toolkit::LayoutTransitionData::Type layoutTranstionType, Actor gainedChild, Actor lostChild ); /** * @brief Predicate to determine if this layout has been requested to re-layout diff --git a/dali-toolkit/devel-api/layouting/layout-item.cpp b/dali-toolkit/devel-api/layouting/layout-item.cpp index a84b45d..315faa4 100644 --- a/dali-toolkit/devel-api/layouting/layout-item.cpp +++ b/dali-toolkit/devel-api/layouting/layout-item.cpp @@ -55,7 +55,7 @@ bool LayoutItem::IsLayoutAnimated() const return GetImplementation( *this ).IsLayoutAnimated(); } -void LayoutItem::SetTransitionData( LayoutTransitionData::LayoutTransitionType layoutTransitionType, LayoutTransitionData layoutTransitionData ) +void LayoutItem::SetTransitionData( LayoutTransitionData::Type layoutTransitionType, LayoutTransitionData layoutTransitionData ) { Toolkit::Internal::LayoutTransitionDataPtr layoutTransitionDataPtr = Toolkit::Internal::LayoutTransitionDataPtr(); if ( layoutTransitionData ) @@ -65,7 +65,7 @@ void LayoutItem::SetTransitionData( LayoutTransitionData::LayoutTransitionType l GetImplementation( *this ).SetTransitionData( layoutTransitionType, layoutTransitionDataPtr ); } -LayoutTransitionData LayoutItem::GetTransitionData( LayoutTransitionData::LayoutTransitionType layoutTransitionType ) const +LayoutTransitionData LayoutItem::GetTransitionData( LayoutTransitionData::Type layoutTransitionType ) const { return LayoutTransitionData( GetImplementation( *this ).GetTransitionData( layoutTransitionType ).Get() ); } diff --git a/dali-toolkit/devel-api/layouting/layout-item.h b/dali-toolkit/devel-api/layouting/layout-item.h index 1ad32ed..3513182 100755 --- a/dali-toolkit/devel-api/layouting/layout-item.h +++ b/dali-toolkit/devel-api/layouting/layout-item.h @@ -123,7 +123,7 @@ public: * @param[in] layoutTransitionType The type of the layout transition * @param[in] layoutTransitionData The layout transition data */ - void SetTransitionData( LayoutTransitionData::LayoutTransitionType layoutTransitionType, LayoutTransitionData layoutTransitionData ); + void SetTransitionData( LayoutTransitionData::Type layoutTransitionType, LayoutTransitionData layoutTransitionData ); /** * @brief Get the layout transition data @@ -132,7 +132,7 @@ public: * * @return The layout transition data */ - LayoutTransitionData GetTransitionData( LayoutTransitionData::LayoutTransitionType layoutTransitionType ) const; + LayoutTransitionData GetTransitionData( LayoutTransitionData::Type layoutTransitionType ) const; public: /// @cond internal diff --git a/dali-toolkit/devel-api/layouting/layout-transition-data.cpp b/dali-toolkit/devel-api/layouting/layout-transition-data.cpp index c01b2dd..ad36ca8 100644 --- a/dali-toolkit/devel-api/layouting/layout-transition-data.cpp +++ b/dali-toolkit/devel-api/layouting/layout-transition-data.cpp @@ -48,7 +48,7 @@ void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map ) GetImplementation( *this ).AddPropertyAnimator( actor, map ); } -void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ) +void LayoutTransitionData::AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ) { GetImplementation( *this ).AddPropertyAnimator( actor, map, keyFrames, interpolation ); } diff --git a/dali-toolkit/devel-api/layouting/layout-transition-data.h b/dali-toolkit/devel-api/layouting/layout-transition-data.h index 5bd509a..d51d28a 100644 --- a/dali-toolkit/devel-api/layouting/layout-transition-data.h +++ b/dali-toolkit/devel-api/layouting/layout-transition-data.h @@ -36,6 +36,9 @@ namespace Internal class LayoutTransitionData; } +/** + * @brief The LayoutTransitionData class to collect the actors properties animators for layout transitions. + */ class DALI_TOOLKIT_API LayoutTransitionData final : public BaseHandle { public: @@ -47,6 +50,7 @@ public: { enum Type { + CONDITION, ///< A condition triggering the transition animation (the actor is added/removed/focus gained/focus lost) PROPERTY, ///< A property to animate INITIAL_VALUE, ///< Initial value of an animated property TARGET_VALUE, ///< Target value of an animated property @@ -60,14 +64,30 @@ public: }; }; - enum LayoutTransitionType + struct Condition + { + enum Type + { + NONE, ///< Default, no conditions to animate property. The property is animated for all relevant animations related to a control + ON_ADD, ///< A condition to animate property when a control is added to the container + ON_REMOVE, ///< A condition to animate property when a control is removed from the container + ON_FOCUS_GAINED, ///< A condition to animate property when a control focus is gained + ON_FOCUS_LOST, ///< A condition to animate property when a control focus is lost + }; + }; + + enum Type { - ON_CHILD_ADD, - ON_CHILD_REMOVE, - ON_OWNER_SET + // Children related transitions + ON_CHILD_ADD, ///< A transition is triggered when a control is added to the container + ON_CHILD_REMOVE, ///< A transition is triggered when a control is removed from the container + ON_CHILD_FOCUS, ///< A transition is triggered when a control focus is changed in the container + // Layout related transitions + ON_OWNER_SET, ///< A transition is triggered when a layout is set to a new container + ON_LAYOUT_CHANGE, ///< A transition is triggered when a layout geometry is changed }; - typedef Signal< void (LayoutTransitionData::LayoutTransitionType, LayoutTransitionData&) > LayoutTransitionSignalType; ///< Transition finished signal + typedef Signal< void (LayoutTransitionData::Type, LayoutTransitionData&) > LayoutTransitionSignalType; ///< Transition finished signal /** * Create an uninitialized handle @@ -102,7 +122,8 @@ public: /** * @brief Add a property animator for an actor * - * @param[in] actor An owner of the animated property + * @param[in] actor An owner of the animated property. + * If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met. * @param[in] map The animated property map including animator map */ void AddPropertyAnimator( Actor actor, Property::Map map ); @@ -111,6 +132,7 @@ public: * @brief Add a property animator for an actor * * @param[in] actor An owner of the animated property + * If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met. * @param[in] map The properties map * @param[in] keyFrames key frames * @param[in] interpolation An interpolation @@ -121,6 +143,7 @@ public: * @brief Add a property animator for an actor * * @param[in] actor An owner of the animated property + * If actor is empty then the property animator is generic and apply to all children excluding the parent if the condition is met. * @param[in] map A properties map * @param[in] path An animation path * @param[in] forward A forward vector for the path diff --git a/dali-toolkit/internal/layouting/layout-controller-impl.cpp b/dali-toolkit/internal/layouting/layout-controller-impl.cpp index 17a75a6..d2e0119 100644 --- a/dali-toolkit/internal/layouting/layout-controller-impl.cpp +++ b/dali-toolkit/internal/layouting/layout-controller-impl.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace Dali; @@ -44,6 +45,7 @@ namespace Internal LayoutController::LayoutController() : mLayoutRequested( false ), + mFocusChangedFunctor( *this ), mSlotDelegate( this ) { } @@ -55,14 +57,32 @@ LayoutController::~LayoutController() void LayoutController::Initialize() { mAnimation = Animation::New( 0.0f ); + + Dali::Toolkit::KeyInputFocusManager manager = Dali::Toolkit::KeyInputFocusManager::Get(); + manager.KeyInputFocusChangedSignal().Connect( mSlotDelegate.GetConnectionTracker(), mFocusChangedFunctor ); +} + +void LayoutController::FocusChangedFunctor::operator() ( Dali::Toolkit::Control gainingControl, Dali::Toolkit::Control lostControl ) +{ + Toolkit::LayoutItem layoutItem = Toolkit::DevelControl::GetLayout( gainingControl ); + if( layoutItem ) + { + Toolkit::Internal::LayoutItem& layoutItemImpl = GetImplementation( layoutItem ); + LayoutParent* layoutParent = layoutItemImpl.GetParent(); + if( layoutParent ) + { + LayoutGroup* layoutGroup = static_cast< LayoutGroup* >( layoutParent ); + layoutController.RequestLayout( dynamic_cast< Toolkit::Internal::LayoutItem& >( *layoutGroup ), Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS, gainingControl, lostControl ); + } + } } -void LayoutController::RequestLayout( LayoutItem& layoutItem, int layoutTransitionType ) +void LayoutController::RequestLayout( LayoutItem& layoutItem, int layoutTransitionType, Actor gainedChild, Actor lostChild ) { auto actor = Actor::DownCast( layoutItem.GetOwner() ); if ( actor ) { - DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::RequestLayout owner[%s] layoutItem[%p] layoutAnimationType(%d)\n", actor.GetName().c_str(), &layoutItem, layoutTransitionType ); + DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::RequestLayout owner[%s] layoutItem[%p] layoutTransitionType(%d)\n", actor.GetName().c_str(), &layoutItem, layoutTransitionType ); } else { @@ -72,9 +92,10 @@ void LayoutController::RequestLayout( LayoutItem& layoutItem, int layoutTransiti mLayoutRequested = true; if( layoutTransitionType != -1 ) { - LayoutTransition layoutTransition = LayoutTransition( layoutItem, layoutTransitionType ); + LayoutTransition layoutTransition = LayoutTransition( layoutItem, layoutTransitionType, gainedChild, lostChild ); if( std::find( mLayoutTransitions.begin(), mLayoutTransitions.end(), layoutTransition ) == mLayoutTransitions.end() && layoutItem.GetTransitionData( layoutTransitionType ).Get() ) { + DALI_LOG_INFO( gLogFilter, Debug::Concise, "LayoutController::RequestLayout Add transition layoutTransitionType(%d)\n", layoutTransitionType ); mLayoutTransitions.push_back( layoutTransition ); } } @@ -215,8 +236,16 @@ void LayoutController::PerformLayoutPositioning( LayoutPositionDataArray& layout if( actor && ( !layoutPositionData.animated || all ) ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "LayoutController::PerformLayoutPositioning %s\n", actor.GetName().c_str() ); - actor.SetPosition( layoutPositionData.left, layoutPositionData.top ); - actor.SetSize( layoutPositionData.right - layoutPositionData.left, layoutPositionData.bottom - layoutPositionData.top ); + if ( !layoutPositionData.animated ) + { + actor.SetPosition( layoutPositionData.left, layoutPositionData.top ); + actor.SetSize( layoutPositionData.right - layoutPositionData.left, layoutPositionData.bottom - layoutPositionData.top ); + } + else + { + actor.SetPosition( actor.GetCurrentPosition() ); + actor.SetSize( actor.GetCurrentSize() ); + } } } } @@ -328,13 +357,8 @@ void LayoutController::PerformLayoutAnimation( LayoutTransition& layoutTransitio { if( mAnimation.GetState() == Animation::PLAYING ) { - mAnimation.Clear(); - if( mAnimationFinishedFunctors.size() != 0 ) - { - mAnimationFinishedFunctors.front()( mAnimation ); - } + mAnimation.SetCurrentProgress( 1.0f ); } - mAnimation = animation; mAnimationFinishedFunctors.push_back( AnimationFinishedFunctor( *this, layoutTransition, layoutPositionDataArray ) ); mAnimation.FinishedSignal().Connect( mSlotDelegate.GetConnectionTracker(), mAnimationFinishedFunctors.back() ); diff --git a/dali-toolkit/internal/layouting/layout-controller-impl.h b/dali-toolkit/internal/layouting/layout-controller-impl.h index 1c3130d..71c947c 100644 --- a/dali-toolkit/internal/layouting/layout-controller-impl.h +++ b/dali-toolkit/internal/layouting/layout-controller-impl.h @@ -57,7 +57,7 @@ public: /** * This marks the given layout and all its parents as dirty and triggers a transition if set. */ - void RequestLayout( LayoutItem& layout, int layoutTransitionType ); + void RequestLayout( LayoutItem& layout, int layoutTransitionType, Actor gainedChild, Actor lostChild ); /** * Measures next level of layouts in the actor hierarchy. @@ -79,6 +79,11 @@ public: */ void PerformLayoutAnimation( LayoutTransition& layoutTransition, LayoutPositionDataArray& layoutPositionDataArray, LayoutDataArray& layoutDataArray, LayoutAnimatorArray& layoutAnimatorArray ); + /** + * Focus change callback. + */ + void KeyInputFocusChangedCallback( Control gainingActor, Control lostActor ); + protected: // Implementation of Processor /** @@ -120,6 +125,18 @@ private: Animation mAnimation; std::list< AnimationFinishedFunctor > mAnimationFinishedFunctors; + struct FocusChangedFunctor + { + FocusChangedFunctor( LayoutController& layoutController ) + : layoutController( layoutController ) + { + } + + void operator() ( Dali::Toolkit::Control gainingControl, Dali::Toolkit::Control lostActor ); + LayoutController& layoutController; + }; + FocusChangedFunctor mFocusChangedFunctor; + SlotDelegate mSlotDelegate; }; diff --git a/dali-toolkit/internal/layouting/layout-item-data-impl.h b/dali-toolkit/internal/layouting/layout-item-data-impl.h index 0e68977..0b415ad 100644 --- a/dali-toolkit/internal/layouting/layout-item-data-impl.h +++ b/dali-toolkit/internal/layouting/layout-item-data-impl.h @@ -80,9 +80,13 @@ public: static bool sUseZeroUnspecifiedMeasureSpec; + // Custom transitions LayoutTransitionDataPtr mOnChildAddTransitionData; LayoutTransitionDataPtr mOnChildRemoveTransitionData; + LayoutTransitionDataPtr mOnChildFocusTransitionData; LayoutTransitionDataPtr mOnOwnerSetTransitionData; + LayoutTransitionDataPtr mOnLayoutChangeTransitionData; + // Default transition LayoutTransitionDataPtr mDefaultTransitionData; // To pass layout data during perform layout diff --git a/dali-toolkit/internal/layouting/layout-transition-data-impl.cpp b/dali-toolkit/internal/layouting/layout-transition-data-impl.cpp index f43ee79..f65f874 100644 --- a/dali-toolkit/internal/layouting/layout-transition-data-impl.cpp +++ b/dali-toolkit/internal/layouting/layout-transition-data-impl.cpp @@ -30,7 +30,12 @@ namespace { +#if defined(DEBUG_ENABLED) +Debug::Filter* gLayoutFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT" ); +#endif + // Key tokens +const char* TOKEN_CONDITION("condition"); const char* TOKEN_PROPERTY("property"); const char* TOKEN_INITIAL_VALUE("initialValue"); const char* TOKEN_TARGET_VALUE("targetValue"); @@ -209,6 +214,10 @@ bool LayoutTransitionData::ConvertToLayoutAnimator( const Property::Map& animato Vector2 controlPoint2( controlPoints.z, controlPoints.w ); layoutDataAnimator.alphaFunction = AlphaFunction( controlPoint1, controlPoint2 ); } + else if ( value.GetType() == Property::INTEGER ) + { + layoutDataAnimator.alphaFunction = AlphaFunction( static_cast( value.Get() ) ); + } else if ( value.GetType() == Property::STRING ) { std::string alphaFunctionValue = value.Get(); @@ -371,6 +380,10 @@ bool LayoutTransitionData::ConvertToLayoutDataElement( const PropertyAnimator& p if ( pair.first.type == Property::Key::STRING ) { const std::string& key( pair.first.stringKey ); + if ( key == TOKEN_CONDITION ) + { + indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::CONDITION; + } if ( key == TOKEN_PROPERTY ) { indexKey = Dali::Toolkit::LayoutTransitionData::AnimatorKey::PROPERTY; @@ -393,7 +406,11 @@ bool LayoutTransitionData::ConvertToLayoutDataElement( const PropertyAnimator& p indexKey = pair.first.indexKey; } - if( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::PROPERTY ) + if( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::CONDITION ) + { + layoutDataElement.condition = value.Get(); + } + else if( indexKey == Dali::Toolkit::LayoutTransitionData::AnimatorKey::PROPERTY ) { if( value.GetType() == Property::STRING ) { @@ -449,21 +466,63 @@ bool LayoutTransitionData::ConvertToLayoutDataElement( const PropertyAnimator& p return propertyFound; } -void LayoutTransitionData::ConvertToLayoutDataElements( Actor owner, LayoutData& layoutData ) +void LayoutTransitionData::ConvertChildrenAnimatorsToLayoutDataElements( Actor child, LayoutData& layoutData ) { LayoutDataArray& layoutDataArray = layoutData.layoutDataArray; // Add the children animators for( const PropertyAnimator& iter : layoutData.childrenPropertyAnimators ) { LayoutDataElement layoutDataElement; - layoutDataElement.handle = owner; + layoutDataElement.handle = child; layoutDataElement.positionDataIndex = layoutData.layoutPositionDataArray.size() - 1; if( ConvertToLayoutDataElement( iter, layoutDataElement, layoutData ) ) { + switch ( layoutDataElement.condition ) + { + case Dali::Toolkit::LayoutTransitionData::Condition::ON_ADD: + if ( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_ADD + || layoutData.layoutTransition.gainedChild != child ) + { + continue; + } + break; + case Dali::Toolkit::LayoutTransitionData::Condition::ON_REMOVE: + if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_REMOVE + || layoutData.layoutTransition.lostChild != child ) + { + continue; + } + break; + case Dali::Toolkit::LayoutTransitionData::Condition::ON_FOCUS_GAINED: + if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS + || layoutData.layoutTransition.gainedChild != child ) + { + continue; + } + break; + case Dali::Toolkit::LayoutTransitionData::Condition::ON_FOCUS_LOST: + if( layoutData.layoutTransition.layoutTransitionType != Dali::Toolkit::LayoutTransitionData::ON_CHILD_FOCUS + || layoutData.layoutTransition.lostChild != child ) + { + continue; + } + break; + default: + break; + } + layoutDataArray.push_back( layoutDataElement ); } } +} + +void LayoutTransitionData::ConvertToLayoutDataElements( Actor owner, LayoutData& layoutData ) +{ + LayoutDataArray& layoutDataArray = layoutData.layoutDataArray; + + // Add the children animators + ConvertChildrenAnimatorsToLayoutDataElements( owner, layoutData ); // Add the transition animators for( const PropertyAnimator& iter : mPropertyAnimators ) @@ -493,7 +552,7 @@ void LayoutTransitionData::EmitSignalFinish( int layoutTransitionType ) if ( !mFinishedSignal.Empty() ) { Dali::Toolkit::LayoutTransitionData handle( this ); - mFinishedSignal.Emit( static_cast(layoutTransitionType), handle ); + mFinishedSignal.Emit( static_cast(layoutTransitionType), handle ); } } diff --git a/dali-toolkit/internal/layouting/layout-transition-data-impl.h b/dali-toolkit/internal/layouting/layout-transition-data-impl.h index eb9e9d9..dec0b76 100644 --- a/dali-toolkit/internal/layouting/layout-transition-data-impl.h +++ b/dali-toolkit/internal/layouting/layout-transition-data-impl.h @@ -37,9 +37,11 @@ namespace Internal struct LayoutTransition { - LayoutTransition( LayoutItem& layoutItem, int layoutTransitionType ) + LayoutTransition( LayoutItem& layoutItem, int layoutTransitionType, Actor gainedChild, Actor lostChild ) : layoutItem( &layoutItem ) , layoutTransitionType( layoutTransitionType ) + , gainedChild( gainedChild ) + , lostChild( lostChild ) { } @@ -50,11 +52,16 @@ struct LayoutTransition bool operator==( const LayoutTransition& rhs ) { - return ( ( layoutItem.Get() == rhs.layoutItem.Get() ) && layoutTransitionType == rhs.layoutTransitionType ); + return ( layoutItem.Get() == rhs.layoutItem.Get() + && layoutTransitionType == rhs.layoutTransitionType + && gainedChild == rhs.gainedChild + && lostChild == rhs.lostChild ); } LayoutItemPtr layoutItem; int layoutTransitionType; + Actor gainedChild; + Actor lostChild; }; const float DEFAULT_TRANSITION_DURATION( 0.5f ); @@ -111,16 +118,10 @@ using LayoutPositionDataArray = std::vector< LayoutPositionData >; struct LayoutDataElement { LayoutDataElement() - : propertyIndex( Property::INVALID_KEY ), animatorIndex( -1 ), positionDataIndex(-1 ) - { - }; - - LayoutDataElement( Actor actor, Property::Index propertyIndex, Property::Value value ) - : handle( actor ), - propertyIndex( propertyIndex ), - targetValue( value ), + : propertyIndex( Property::INVALID_KEY ), animatorIndex( -1 ), - positionDataIndex( -1 ) + positionDataIndex(-1 ), + condition( Dali::Toolkit::LayoutTransitionData::Condition::NONE ) { }; @@ -130,6 +131,7 @@ struct LayoutDataElement Property::Value targetValue; int animatorIndex; int positionDataIndex; + int condition; }; class LayoutTransitionData; @@ -166,22 +168,86 @@ public: LayoutTransitionData( const LayoutTransitionData& ) = delete; LayoutTransitionData& operator=( const LayoutTransitionData& ) = delete; + /** + * @brief Add a property animator for an actor in the transition + * @param[in] actor The actor + * @param[in] map The map containing the transition animator keys + * + * This will add the property animator to the list of animators related to this transition + */ void AddPropertyAnimator( Actor actor, Property::Map map ); + + /** + * @brief Add a property animator for an actor in the transition + * @param[in] actor The actor + * @param[in] map The map containing the transition animator keys + * @param[in] keyFrames The key frames used by the property animator + * @param[in] interpolation The interpolation used by the property animator + * + * This will add the property animator to the list of animators related to this transition + */ void AddPropertyAnimator( Actor actor, Property::Map map, KeyFrames keyFrames, Animation::Interpolation interpolation ); + + /** + * @brief Add a property animator for an actor in the transition + * @param[in] actor The actor + * @param[in] map The map containing the transition animator keys + * @param[in] path The path for the property animator + * @param[in] forward The forward vector for the property animator + * + * This will add the property animator to the list of animators related to this transition + */ void AddPropertyAnimator( Actor actor, Property::Map map, Path path, Vector3 forward ); + /** + * @brief Convert the transition property animators to the layout data elements + * @param[in] actor The actor the transition property animators are applied to + * @param[in] layoutData The layout data containing layout data elements array for the layout update + * + * This will parse the property animators and add the layout data elements to the layout data elements array + */ void ConvertToLayoutDataElements( Actor, LayoutData& layoutData ); /** - * @copydoc Dali::Animation::FinishedSignal() + * @brief Convert the transition children property animators to the layout data elements + * @param[in] actor The actor the transition property animators are applied to + * @param[in] layoutData The layout data containing layout data elements array for the layout update + * + * This will parse the children property animators and add the layout data elements to the layout data elements array + */ + static void ConvertChildrenAnimatorsToLayoutDataElements( Actor, LayoutData& layoutData ); + + /** + * @copydoc Dali::Toolkit::LayoutTransitionData::FinishedSignal() */ Dali::Toolkit::LayoutTransitionData::LayoutTransitionSignalType& FinishedSignal(); + /** + * @brief Emit the transition finish signal + * @param[in] layoutTransitionType The transition type + */ void EmitSignalFinish( int layoutTransitionType ); private: - bool ConvertToLayoutAnimator( const Property::Map& animatorData, const PropertyAnimator& propertyAnimator, LayoutDataAnimator& layoutAnimator ); - bool ConvertToLayoutDataElement( const PropertyAnimator& propertyAnimator, LayoutDataElement& layoutDataElement, LayoutData& layoutData ); + /** + * @brief Convert the property animator data to the layout data animator + * @param[in] animatorData The animator data map + * @param[in] propertyAnimator The property animator + * @param[in] layoutAnimator The layout animator + * + * This will parse the property animator data and add the layout data element animator + */ + static bool ConvertToLayoutAnimator( const Property::Map& animatorData, const PropertyAnimator& propertyAnimator, LayoutDataAnimator& layoutAnimator ); + + /** + * @brief Convert the property animator to the layout data element + * @param[in] propertyAnimator The property animator + * @param[in] layoutDataElement The layout data element + * @param[in] layoutDataElement The layout data + * + * This will parse the children property animators and add the layout data elements to the layout data elements array + */ + static bool ConvertToLayoutDataElement( const PropertyAnimator& propertyAnimator, LayoutDataElement& layoutDataElement, LayoutData& layoutData ); PropertyAnimatorArray mPropertyAnimators; diff --git a/dali-toolkit/public-api/dali-toolkit-version.cpp b/dali-toolkit/public-api/dali-toolkit-version.cpp index 245d4b7..fdfca42 100644 --- a/dali-toolkit/public-api/dali-toolkit-version.cpp +++ b/dali-toolkit/public-api/dali-toolkit-version.cpp @@ -31,7 +31,7 @@ namespace Toolkit const unsigned int TOOLKIT_MAJOR_VERSION = 1; const unsigned int TOOLKIT_MINOR_VERSION = 3; -const unsigned int TOOLKIT_MICRO_VERSION = 48; +const unsigned int TOOLKIT_MICRO_VERSION = 49; const char * const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED diff --git a/packaging/dali-toolkit.spec b/packaging/dali-toolkit.spec index 77a78bf..a3b4879 100644 --- a/packaging/dali-toolkit.spec +++ b/packaging/dali-toolkit.spec @@ -1,6 +1,6 @@ Name: dali-toolkit Summary: Dali 3D engine Toolkit -Version: 1.3.48 +Version: 1.3.49 Release: 1 Group: System/Libraries License: Apache-2.0 and BSD-3-Clause and MIT