From: Ferran Sole Date: Mon, 20 Apr 2015 13:35:58 +0000 (+0100) Subject: AlphaFunction refactoring X-Git-Tag: dali_1.0.40~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F12%2F38412%2F21;p=platform%2Fcore%2Fuifw%2Fdali-core.git AlphaFunction refactoring Removed all the alpha functions from public api. Alpha functions can now be defined using an enum to use one of the predefined alpha functions, a pointer, to define a custom alpha function, or two Vector2 which are used for cubic bezier alpha function. The new API is used as follows: //Using a predefined alpha function animation.AnimateTo( property, value, AlphaFunction::EASE_IN_OUT ); //Using a custom alpha function animation.AnimateTo( property, value, &my_alpha_function ); //Using a bezier alpha function animation.AnimateTo( property, value, AlphaFunction(Vector2(0.0f,1.0f),Vector2(1.0f,0.0f) ) ); Change-Id: I4051c752d826770447923b6e9a3215f2575d6370 --- diff --git a/automated-tests/src/dali/CMakeLists.txt b/automated-tests/src/dali/CMakeLists.txt index 9bc2e46..4619864 100644 --- a/automated-tests/src/dali/CMakeLists.txt +++ b/automated-tests/src/dali/CMakeLists.txt @@ -7,7 +7,7 @@ SET(CAPI_LIB "dali") SET(TC_SOURCES utc-Dali-Actor.cpp - utc-Dali-AlphaFunctions.cpp + utc-Dali-AlphaFunction.cpp utc-Dali-AngleAxis.cpp utc-Dali-AnimatableMesh.cpp utc-Dali-Animation.cpp diff --git a/automated-tests/src/dali/utc-Dali-AlphaFunction.cpp b/automated-tests/src/dali/utc-Dali-AlphaFunction.cpp new file mode 100644 index 0000000..858a3eb --- /dev/null +++ b/automated-tests/src/dali/utc-Dali-AlphaFunction.cpp @@ -0,0 +1,252 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include + +using namespace Dali; + +float customAlphaFunction( float progress ) +{ + return progress; +} + +void utc_dali_alpha_function_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_alpha_function_cleanup(void) +{ + test_return_value = TET_PASS; +} + +int UtcDaliAlphaFunctionDefaultConstructorP(void) +{ + TestApplication application; + AlphaFunction alpha; + + //Should return the default alpha function + DALI_TEST_EQUALS( alpha.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION); + + //Check the mode is BUILTIN_FUNCTION + DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAlphaFunctionConstructorFromBuiltinP(void) +{ + TestApplication application; + + //Construct the alpha function with a built-in function + AlphaFunction alpha( AlphaFunction::EASE_IN_OUT); + + //Check if the built-in alpha function is EASE_IN_OUT + DALI_TEST_EQUALS( alpha.GetBuiltinFunction(), AlphaFunction::EASE_IN_OUT, TEST_LOCATION); + + //Check the mode is BUILTIN_FUNCTION + DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAlphaFunctionConstructorFromFunctionPointerdP(void) +{ + TestApplication application; + + //Construct the alpha function with a function pointer + AlphaFunction alpha( &customAlphaFunction ); + + //Check that the custom function points to the custom alpha function + DALI_TEST_EQUALS( alpha.GetCustomFunction(), &customAlphaFunction, TEST_LOCATION); + + //Check the mode is CUSTOM_FUNCTION + DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION); + + + END_TEST; +} + +int UtcDaliAlphaFunctionConstructorFromControlPointsP(void) +{ + TestApplication application; + + //Construct the alpha function with two control points + Vector2 controlPoint0 = Vector2(0.0f,1.0f); + Vector2 controlPoint1 = Vector2(1.0f,0.0f); + AlphaFunction alpha(controlPoint0,controlPoint1); + + //Check if the control points have the correct value + Vector4 controlPoints = alpha.GetBezierControlPoints(); + DALI_TEST_EQUALS( Vector2(controlPoints.x,controlPoints.y), controlPoint0, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(controlPoints.z,controlPoints.w), controlPoint1, TEST_LOCATION); + + //Check the mode is BEZIER + DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAlphaFunctionConstructorFromControlPointsN(void) +{ + TestApplication application; + + //Construct the alpha function with two control points + Vector2 controlPoint0 = Vector2(-10.0f,1.0f); + Vector2 controlPoint1 = Vector2(10.0f,0.0f); + AlphaFunction alpha(controlPoint0,controlPoint1); + + //x components of the control points should have been clamped to [0,1] to ensure the curve is monotonic + Vector4 controlPoints = alpha.GetBezierControlPoints(); + DALI_TEST_EQUALS( Vector2(controlPoints.x,controlPoints.y), Vector2(0.0f,1.0f), TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(controlPoints.z,controlPoints.w), Vector2(1.0f,0.0f), TEST_LOCATION); + + //Check the mode is BEZIER + DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAlphaFunctionGetBuiltinFunctionP(void) +{ + TestApplication application; + AlphaFunction alpha( AlphaFunction::EASE_IN); + + //Check if the builtin alpha function is EASE_IN + DALI_TEST_EQUALS( alpha.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION); + + //Check the mode is BUILTIN_FUNCTION + DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAlphaFunctionGetCustomFunctionP(void) +{ + TestApplication application; + AlphaFunction alpha( &customAlphaFunction ); + + //Check that the custom function points to the custom alpha function + DALI_TEST_EQUALS( alpha.GetCustomFunction(), &customAlphaFunction, TEST_LOCATION); + + //Check the mode is CUSTOM_FUNCTION + DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAlphaFunctionGetControlPointsFunctionP(void) +{ + TestApplication application; + + Vector2 controlPoint0 = Vector2(0.0f,1.0f); + Vector2 controlPoint1 = Vector2(1.0f,0.0f); + AlphaFunction alpha( controlPoint0,controlPoint1 ); + + //Check if the control points have the correct value + Vector4 controlPoints = alpha.GetBezierControlPoints(); + DALI_TEST_EQUALS( Vector2(controlPoints.x,controlPoints.y), controlPoint0, TEST_LOCATION); + DALI_TEST_EQUALS( Vector2(controlPoints.z,controlPoints.w), controlPoint1, TEST_LOCATION); + + //Check the mode is BEZIER + DALI_TEST_EQUALS( alpha.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAlphaFunctionGetModeP(void) +{ + TestApplication application; + + //Create alpha function using a built-in function + AlphaFunction alphaBuiltin( AlphaFunction::EASE_IN); + + //Check the mode is BUILTIN_FUNCTION + DALI_TEST_EQUALS( alphaBuiltin.GetMode(), AlphaFunction::BUILTIN_FUNCTION, TEST_LOCATION); + + //Create alpha function with pointer to function + AlphaFunction alphaCustom( &customAlphaFunction ); + //Check the mode is CUSTOM_FUNCTION + DALI_TEST_EQUALS( alphaCustom.GetMode(), AlphaFunction::CUSTOM_FUNCTION, TEST_LOCATION); + + //Create alpha function with control points + Vector2 controlPoint0 = Vector2(0.0f,1.0f); + Vector2 controlPoint1 = Vector2(1.0f,0.0f); + AlphaFunction alphaBezier( controlPoint0,controlPoint1 ); + //Check the mode is BEZIER + DALI_TEST_EQUALS( alphaBezier.GetMode(), AlphaFunction::BEZIER, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAlphaFunctionBezier(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + // Register a float property + float startValue(0.0f); + Property::Index index = actor.RegisterProperty( "test-property", startValue ); + Stage::GetCurrent().Add(actor); + DALI_TEST_EQUALS( actor.GetProperty(index), startValue, TEST_LOCATION ); + + // Build the animation + float durationSeconds(1.0f); + Animation animation = Animation::New(durationSeconds); + float targetValue(1.0f); + + Vector2 controlPoint0 = Vector2(0.25f,0.5f); + Vector2 controlPoint1 = Vector2(0.75f,0.5f); + animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunction(controlPoint0,controlPoint1)); + + // Start the animation + animation.Play(); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f)/* 20% progress */); + application.SendNotification(); + float epsilon(0.01f); + DALI_TEST_EQUALS( actor.GetProperty(index), 0.271964f, epsilon, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*40% progress*/); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(index), 0.432387f, epsilon, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*60% progress*/); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(index), 0.567613f, epsilon, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*80% progress*/); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(index), 0.728037f, epsilon, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(durationSeconds*200.0f) + 1u/*just beyond the animation duration*/); + application.SendNotification(); + DALI_TEST_EQUALS( actor.GetProperty(index), targetValue, TEST_LOCATION ); + + END_TEST; +} + diff --git a/automated-tests/src/dali/utc-Dali-AlphaFunctions.cpp b/automated-tests/src/dali/utc-Dali-AlphaFunctions.cpp deleted file mode 100644 index 5148733..0000000 --- a/automated-tests/src/dali/utc-Dali-AlphaFunctions.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include - -using namespace Dali; - -void utc_dali_alpha_functions_startup(void) -{ - test_return_value = TET_UNDEF; -} - -void utc_dali_alpha_functions_cleanup(void) -{ - test_return_value = TET_PASS; -} - - -// Positive test case for a method -int UtcDaliAlphaFunctionsDefault(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::Default( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Default( 0.25f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Default( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Default( 0.75f ), 0.75f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Default( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsLinear(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::Linear( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Linear( 0.25f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Linear( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Linear( 0.75f ), 0.75f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Linear( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsReverse(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::Reverse( 0.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Reverse( 0.25f ), 0.75f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Reverse( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Reverse( 0.75f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Reverse( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseIn(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 0.25f ), 0.015625f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 0.5f ), 0.125f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 0.75f ), 0.421875f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseIn( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseOut(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 0.25f ), 0.578125f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 0.5f ), 0.875f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 0.75f ), 0.984375f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOut( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseInOut(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 0.25f ), 0.0625f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 0.75f ), 0.9375f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOut( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseInSine(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 0.25f ), 0.07612f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 0.5f ), 0.292893f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 0.75f ), 0.617317f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseOutSine(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 0.25f ), 0.382683f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 0.5f ), 0.707107f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 0.75f ), 0.92388f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseInOutSine(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 0.25f ), 0.146447f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 0.75f ), 0.853553f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsBounce(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::Bounce( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Bounce( 0.25f ), 0.707107f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Bounce( 0.5f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Bounce( 0.75f ), 0.707107f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Bounce( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsBounceBack(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 0.25f ), 0.900316f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 0.5f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 0.75f ), -0.300105f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::BounceBack( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseOutBack(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 0.25f ), 0.817410f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 0.5f ), 1.087698f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 0.75f ), 1.064137f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutBack( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsSin(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::Sin( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Sin( 0.25f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Sin( 0.5f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Sin( 0.75f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Sin( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsSin2x(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 0.25f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 0.5f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 0.75f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Sin2x( 1.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsSquare(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::Square( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Square( 0.25f ), 0.0625f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Square( 0.5f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Square( 0.75f ), 0.5625f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::Square( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseInSine33(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 0.25f ), 0.064146f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 0.5f ), 0.255256f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 0.75f ), 0.569374f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInSine33( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseOutSine33(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 0.25f ), 0.430626f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 0.5f ), 0.744744f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 0.75f ), 0.935854f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutSine33( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseInOutSineXX(void) -{ - TestApplication application; - - { - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 0.25f ), 0.239263f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 0.75f ), 0.760737f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine33( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - } - { - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 0.25f ), 0.224156f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 0.75f ), 0.775844f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine50( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - } - { - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 0.25f ), 0.211325f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 0.75f ), 0.788675f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine60( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - } - { - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 0.25f ), 0.194806f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 0.75f ), 0.805194f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine70( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - } - { - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 0.25f ), 0.173648f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 0.75f ), 0.826352f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine80( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - } - { - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 0.25f ), 0.146447f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 0.75f ), 0.853553f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutSine90( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - } - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsDoubleEaseInOutSine60(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 0.25f ), 0.25f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 0.75f ), 0.75f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::DoubleEaseInOutSine60( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseOutQuint50(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 0.25f ), 0.386797f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 0.5f ), 0.692214f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 0.75f ), 0.905268f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint50( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseOutQuint80(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 0.25f ), 0.484010f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 0.5f ), 0.796937f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 0.75f ), 0.958765f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseOutQuint80( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseInBack(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 0.25f ), -0.064137f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 0.5f ), -0.087698f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 0.75f ), 0.182590f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInBack( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} - -// Positive test case for a method -int UtcDaliAlphaFunctionsEaseInOutBack(void) -{ - TestApplication application; - - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 0.0f ), 0.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 0.25f ), -0.043849f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 0.5f ), 0.5f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 0.75f ), 1.043849f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - DALI_TEST_EQUALS( AlphaFunctions::EaseInOutBack( 1.0f ), 1.0f, Math::MACHINE_EPSILON_10, TEST_LOCATION); - END_TEST; -} diff --git a/automated-tests/src/dali/utc-Dali-Animation.cpp b/automated-tests/src/dali/utc-Dali-Animation.cpp index 9652797..8e8c79c 100644 --- a/automated-tests/src/dali/utc-Dali-Animation.cpp +++ b/automated-tests/src/dali/utc-Dali-Animation.cpp @@ -197,7 +197,7 @@ int UtcDaliAnimationSetDuratioN(void) // Start the animation Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); animation.Play(); bool signalReceived(false); @@ -283,7 +283,7 @@ int UtcDaliAnimationSetLoopingP(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.SetLooping(true); @@ -361,7 +361,7 @@ int UtcDaliAnimationSetEndActioN(void) DALI_TEST_CHECK(animation.GetEndAction() == Animation::Bake); Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -469,7 +469,7 @@ int UtcDaliAnimationSetDisconnectActioN(void) DALI_TEST_CHECK(animation.GetDisconnectAction() == Animation::BakeFinal); Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -496,7 +496,7 @@ int UtcDaliAnimationSetDisconnectActioN(void) animation.SetDisconnectAction( Animation::Bake ); Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -523,7 +523,7 @@ int UtcDaliAnimationSetDisconnectActioN(void) animation.SetDisconnectAction( Animation::Discard ); Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -549,7 +549,7 @@ int UtcDaliAnimationSetDisconnectActioN(void) Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(10.0f, 10.0f, 10.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); application.SendNotification(); application.Render(static_cast(durationSeconds*0.5f*1000.0f)/*Only half the animation*/); @@ -586,11 +586,11 @@ int UtcDaliAnimationSetDefaultAlphaFunctioN(void) Animation animation = Animation::New(1.0f); AlphaFunction func = animation.GetDefaultAlphaFunction(); - DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION); + DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION); - animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn); + animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN); AlphaFunction func2 = animation.GetDefaultAlphaFunction(); - DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in + DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION); END_TEST; } @@ -602,11 +602,11 @@ int UtcDaliAnimationGetDefaultAlphaFunctioN(void) AlphaFunction func = animation.GetDefaultAlphaFunction(); // Test that the default is linear - DALI_TEST_EQUALS(func(0.1f), AlphaFunctions::Linear(0.1f), TEST_LOCATION); + DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION); - animation.SetDefaultAlphaFunction(AlphaFunctions::EaseIn); + animation.SetDefaultAlphaFunction(AlphaFunction::EASE_IN); AlphaFunction func2 = animation.GetDefaultAlphaFunction(); - DALI_TEST_CHECK(func2(0.1f) < AlphaFunctions::Linear(0.1f)); // less progress when easing-in + DALI_TEST_EQUALS(func2.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION); END_TEST; } @@ -631,7 +631,7 @@ int UtcDaliAnimationSetCurrentProgressP(void) application.SendNotification(); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation from 40% progress animation.SetCurrentProgress( 0.4f ); @@ -694,7 +694,7 @@ int UtcDaliAnimationSetCurrentProgressN(void) application.SendNotification(); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); //Trying to set the current cursor outside the range [0..1] is ignored animation.SetCurrentProgress( -1.0f); @@ -739,7 +739,7 @@ int UtcDaliAnimationGetCurrentProgressP(void) application.SendNotification(); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation from 40% progress animation.SetCurrentProgress( 0.4f ); @@ -790,7 +790,7 @@ int UtcDaliAnimationSetSpeedFactorP(void) KeyFrames keyframes = KeyFrames::New(); keyframes.Add( 0.0f, initialPosition); keyframes.Add( 1.0f, targetPosition ); - animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunctions::Linear); + animation.AnimateBetween( Property(actor, Actor::Property::POSITION), keyframes, AlphaFunction::LINEAR); //Set speed to be x2 animation.SetSpeedFactor(2.0f); @@ -971,7 +971,7 @@ int UtcDaliAnimationSetPlayRangeP(void) DALI_TEST_EQUALS( Vector2( 0.4f, 0.9f ), animation.GetPlayRange(), TEST_LOCATION ); Vector3 targetPosition( 100.0f, 100.0f, 100.0f ); - animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunctions::Linear ); + animation.AnimateTo( Property( actor, Actor::Property::POSITION ), targetPosition, AlphaFunction::LINEAR ); // Start the animation from 40% progress animation.Play(); @@ -1061,7 +1061,7 @@ int UtcDaliAnimationPlayP(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -1140,7 +1140,7 @@ int UtcDaliAnimationPlayOffStageP(void) Animation animation = Animation::New(durationSeconds); animation.SetDisconnectAction( Animation::Discard ); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -1219,7 +1219,7 @@ int UtcDaliAnimationPlayDiscardHandleP(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); @@ -1292,7 +1292,7 @@ int UtcDaliAnimationPlayStopDiscardHandleP(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -1465,7 +1465,7 @@ int UtcDaliAnimationPlayFromP(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Start the animation from 40% progress animation.PlayFrom( 0.4f ); @@ -1516,7 +1516,7 @@ int UtcDaliAnimationPlayFromN(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); //PlayFrom with an argument outside the range [0..1] will be ignored animation.PlayFrom(-1.0f); @@ -1540,7 +1540,7 @@ int UtcDaliAnimationPauseP(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); Vector3 fiftyPercentProgress(targetPosition * 0.5f); @@ -1610,7 +1610,7 @@ int UtcDaliAnimationStoP(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); Vector3 fiftyPercentProgress(targetPosition * 0.5f); @@ -1660,7 +1660,7 @@ int UtcDaliAnimationStopSetPositioN(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); Vector3 fiftyPercentProgress(targetPosition * 0.5f); @@ -1709,7 +1709,7 @@ int UtcDaliAnimationClearP(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); Vector3 fiftyPercentProgress(targetPosition * 0.5f); @@ -1743,7 +1743,7 @@ int UtcDaliAnimationClearP(void) finishCheck.Reset(); actor.SetPosition(Vector3::ZERO); Vector3 targetScale(3.0f, 3.0f, 3.0f); - animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunctions::Linear ); + animation.AnimateTo( Property( actor, Actor::Property::SCALE ), targetScale, AlphaFunction::LINEAR ); animation.Play(); application.SendNotification(); @@ -1887,7 +1887,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); bool relativeValue(true); bool finalValue( false || relativeValue ); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseIn); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_IN); // Start the animation animation.Play(); @@ -1921,7 +1921,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctioN(void) // Repeat with relative value "false" - this should be an NOOP animation = Animation::New(durationSeconds); bool noOpValue(false); - animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunctions::EaseIn); + animation.AnimateBy(Property(actor, index), noOpValue, AlphaFunction::EASE_IN); // Start the animation animation.Play(); @@ -2030,7 +2030,7 @@ int UtcDaliAnimationAnimateByBooleanAlphaFunctionTimePeriodP(void) float animatorDurationSeconds(durationSeconds * 0.5f); animation.AnimateBy( Property(actor, index), relativeValue, - AlphaFunctions::EaseInOut, + AlphaFunction::EASE_IN_OUT, TimePeriod( animatorDurationSeconds ) ); // Start the animation @@ -2143,7 +2143,7 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); float targetValue(90.0f); float relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); float ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -2262,7 +2262,7 @@ int UtcDaliAnimationAnimateByFloatAlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -2373,7 +2373,7 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); int targetValue(90); int relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); @@ -2492,7 +2492,7 @@ int UtcDaliAnimationAnimateByIntegerAlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -2603,7 +2603,7 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Vector2 targetValue(20.0f, 20.0f); Vector2 relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -2723,7 +2723,7 @@ int UtcDaliAnimationAnimateByVector2AlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -2834,7 +2834,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Vector3 targetValue(20.0f, 20.0f, 20.0f); Vector3 relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -2955,7 +2955,7 @@ int UtcDaliAnimationAnimateByVector3AlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -3066,7 +3066,7 @@ int UtcDaliAnimationAnimateByVector4AlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Vector4 targetValue(20.0f, 20.0f, 20.0f, 20.0f); Vector4 relativeValue(targetValue - startValue); - animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunctions::EaseOut); + animation.AnimateBy(Property(actor, index), relativeValue, AlphaFunction::EASE_OUT); Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -3188,7 +3188,7 @@ int UtcDaliAnimationAnimateByVector4AlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateBy(Property(actor, index), relativeValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -3299,7 +3299,7 @@ int UtcDaliAnimationAnimateByActorPositionAlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(20.0f, 20.0f, 20.0f); Vector3 relativePosition(targetPosition - startPosition); - animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunctions::EaseOut); + animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, AlphaFunction::EASE_OUT); Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); @@ -3414,7 +3414,7 @@ int UtcDaliAnimationAnimateByActorPositionAlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateBy(Property(actor, Actor::Property::POSITION), relativePosition, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); Vector3 ninetyFivePercentProgress(startPosition + relativePosition*0.95f); @@ -3521,7 +3521,7 @@ int UtcDaliAnimationAnimateByActorOrientationAlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Degree relativeRotationDegrees(360.0f); Radian relativeRotationRadians(relativeRotationDegrees); - animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunctions::EaseIn ); + animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), AlphaFunction::EASE_IN ); // Start the animation animation.Play(); @@ -3536,7 +3536,7 @@ int UtcDaliAnimationAnimateByActorOrientationAlphaFunctioN(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); @@ -3544,7 +3544,7 @@ int UtcDaliAnimationAnimateByActorOrientationAlphaFunctioN(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); @@ -3552,7 +3552,7 @@ int UtcDaliAnimationAnimateByActorOrientationAlphaFunctioN(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -3580,7 +3580,7 @@ int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void) Radian relativeRotationRadians(relativeRotationDegrees); float delay = 0.3f; animation.AnimateBy( Property( actor, Actor::Property::ORIENTATION ), Quaternion( relativeRotationRadians, Vector3::YAXIS ), - AlphaFunctions::EaseIn, TimePeriod( delay, durationSeconds - delay ) ); + AlphaFunction::EASE_IN, TimePeriod( delay, durationSeconds - delay ) ); // Start the animation animation.Play(); @@ -3596,7 +3596,7 @@ int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); @@ -3605,7 +3605,7 @@ int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); @@ -3614,7 +3614,7 @@ int UtcDaliAnimationAnimateByActorOrientationAlphaFunctionTimePeriodP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(relativeRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -3675,7 +3675,7 @@ int UtcDaliAnimationAnimateByActorScaleP(void) // Repeat with a different (ease-in) alpha function animation = Animation::New(durationSeconds); - animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunctions::EaseIn ); + animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::EASE_IN ); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -3713,7 +3713,7 @@ int UtcDaliAnimationAnimateByActorScaleP(void) // Repeat with a delay float delay = 0.5f; animation = Animation::New(durationSeconds); - animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) ); + animation.AnimateBy( Property( actor, Actor::Property::SCALE ), relativeScale, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -3833,7 +3833,7 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunctioN(void) float durationSeconds(2.0f); Animation animation = Animation::New(durationSeconds); const bool targetValue( !startValue ); - animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut); + animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunction::EASE_OUT); // Start the animation animation.Play(); @@ -3867,7 +3867,7 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunctioN(void) // Repeat with target value "false" animation = Animation::New(durationSeconds); const bool finalValue( !targetValue ); - animation.AnimateTo(Property(actor, index), finalValue, AlphaFunctions::EaseOut); + animation.AnimateTo(Property(actor, index), finalValue, AlphaFunction::EASE_OUT); // Start the animation animation.Play(); @@ -3980,7 +3980,7 @@ int UtcDaliAnimationAnimateToBooleanAlphaFunctionTimePeriodP(void) float animatorDurationSeconds(durationSeconds * 0.5f); animation.AnimateTo( Property(actor, index), finalValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod( animatorDurationSeconds ) ); // Start the animation @@ -4087,7 +4087,7 @@ int UtcDaliAnimationAnimateToFloatAlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); float targetValue(90.0f); float relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); float ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -4194,7 +4194,7 @@ int UtcDaliAnimationAnimateToFloatAlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateTo(Property(actor, index), targetValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -4293,7 +4293,7 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); int targetValue(90); int relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); int ninetyFivePercentProgress(static_cast(startValue + relativeValue*0.95f + 0.5f)); @@ -4400,7 +4400,7 @@ int UtcDaliAnimationAnimateToIntegerAlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateTo(Property(actor, index), targetValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -4499,7 +4499,7 @@ int UtcDaliAnimationAnimateToVector2AlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Vector2 targetValue(9000.0f, 9000.0f); Vector2 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunctions::EaseOut); + animation.AnimateTo(Property(actor, "test-property"), targetValue, AlphaFunction::EASE_OUT); Vector2 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -4607,7 +4607,7 @@ int UtcDaliAnimationAnimateToVector2AlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateTo(Property(actor, index), targetValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -4706,7 +4706,7 @@ int UtcDaliAnimationAnimateToVector3AlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Vector3 targetValue(9000.0f, 9000.0f, 9000.0f); Vector3 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); Vector3 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -4815,7 +4815,7 @@ int UtcDaliAnimationAnimateToVector3AlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateTo(Property(actor, "test-property"), targetValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -4871,11 +4871,11 @@ int UtcDaliAnimationAnimateToVector3ComponentP(void) float delay = 0.5f; animation.AnimateTo(Property(actor, "test-property", 0), 30.0f, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); animation.AnimateTo(Property(actor, index, 1), 30.0f, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -4974,7 +4974,7 @@ int UtcDaliAnimationAnimateToVector4AlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Vector4 targetValue(9000.0f, 9000.0f, 9000.0f, 9000.0f); Vector4 relativeValue(targetValue - startValue); - animation.AnimateTo(Property(actor, index), targetValue, AlphaFunctions::EaseOut); + animation.AnimateTo(Property(actor, index), targetValue, AlphaFunction::EASE_OUT); Vector4 ninetyFivePercentProgress(startValue + relativeValue*0.95f); @@ -5084,7 +5084,7 @@ int UtcDaliAnimationAnimateToVector4AlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateTo(Property(actor, index), targetValue, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); // Start the animation @@ -5380,7 +5380,7 @@ int UtcDaliAnimationAnimateToActorSizeP(void) // Repeat with a different (ease-in) alpha function animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunctions::EaseIn); + animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::EASE_IN); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -5418,7 +5418,7 @@ int UtcDaliAnimationAnimateToActorSizeP(void) // Repeat with a delay float delay = 0.5f; animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); + animation.AnimateTo( Property(actor, Actor::Property::SIZE), targetSize, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -5623,8 +5623,8 @@ int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void) // Repeat with a different (ease-in) alpha function animation = Animation::New(durationSeconds); - animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunctions::EaseIn ); - animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunctions::EaseIn ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::EASE_IN ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::EASE_IN ); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -5661,8 +5661,8 @@ int UtcDaliAnimationAnimateToActorSizeWidthHeightP(void) // Repeat with a delay float delay = 0.5f; animation = Animation::New(durationSeconds); - animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) ); - animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_WIDTH ), targetSize.x, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); + animation.AnimateTo( Property( actor, Actor::Property::SIZE_HEIGHT ), targetSize.y, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -5891,7 +5891,7 @@ int UtcDaliAnimationAnimateToActorPositionAlphaFunctioN(void) float durationSeconds(1.0f); Animation animation = Animation::New(durationSeconds); Vector3 targetPosition(200.0f, 200.0f, 200.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::EaseIn); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::EASE_IN); Vector3 seventyFivePercentProgress(targetPosition * 0.75f); @@ -5995,7 +5995,7 @@ int UtcDaliAnimationAnimateToActorPositionAlphaFunctionTimePeriodP(void) float delay = 0.5f; animation.AnimateTo( Property(actor, Actor::Property::POSITION), targetPosition, - AlphaFunctions::Linear, + AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); Vector3 seventyFivePercentProgress(targetPosition * 0.75f); @@ -6162,7 +6162,7 @@ int UtcDaliAnimationAnimateToActorOrientationAlphaFunctioN(void) Animation animation = Animation::New(durationSeconds); Degree targetRotationDegrees(90.0f); Radian targetRotationRadians(targetRotationDegrees); - animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn); + animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN); // Start the animation animation.Play(); @@ -6177,7 +6177,7 @@ int UtcDaliAnimationAnimateToActorOrientationAlphaFunctioN(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.25f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.25f*0.25f*0.25f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); @@ -6185,7 +6185,7 @@ int UtcDaliAnimationAnimateToActorOrientationAlphaFunctioN(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.5f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.5f*0.5f*0.5f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); @@ -6193,7 +6193,7 @@ int UtcDaliAnimationAnimateToActorOrientationAlphaFunctioN(void) // We didn't expect the animation to finish yet application.SendNotification(); finishCheck.CheckSignalNotReceived(); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(0.75f), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * 0.75f*0.75f*0.75f, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -6281,7 +6281,7 @@ int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void) Degree targetRotationDegrees(90.0f); Radian targetRotationRadians(targetRotationDegrees); float delay(0.1f); - animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunctions::EaseIn, TimePeriod(delay, durationSeconds - delay)); + animation.AnimateTo( Property(actor, Actor::Property::ORIENTATION), AngleAxis(targetRotationDegrees, Vector3::YAXIS), AlphaFunction::EASE_IN, TimePeriod(delay, durationSeconds - delay)); // Start the animation animation.Play(); @@ -6297,7 +6297,7 @@ int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); float progress = max(0.0f, 0.25f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 50% progress */); @@ -6306,7 +6306,7 @@ int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); progress = max(0.0f, 0.5f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f)/* 75% progress */); @@ -6315,7 +6315,7 @@ int UtcDaliAnimationAnimateToActorOrientationAlphaFunctionTimePeriodP(void) application.SendNotification(); finishCheck.CheckSignalNotReceived(); progress = max(0.0f, 0.75f - delay) / (1.0f - delay); - DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * AlphaFunctions::EaseIn(progress), Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentOrientation(), Quaternion(targetRotationRadians * progress*progress*progress, Vector3::YAXIS), ROTATION_EPSILON, TEST_LOCATION ); application.SendNotification(); application.Render(static_cast(durationSeconds*250.0f) + 1u/*just beyond the animation duration*/); @@ -6375,7 +6375,7 @@ int UtcDaliAnimationAnimateToActorScaleP(void) // Repeat with a different (ease-in) alpha function animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunctions::EaseIn); + animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::EASE_IN); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -6413,7 +6413,7 @@ int UtcDaliAnimationAnimateToActorScaleP(void) // Repeat with a delay float delay = 0.5f; animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunctions::Linear, TimePeriod(delay, durationSeconds - delay)); + animation.AnimateTo( Property(actor, Actor::Property::SCALE), targetScale, AlphaFunction::LINEAR, TimePeriod(delay, durationSeconds - delay)); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -6637,7 +6637,7 @@ int UtcDaliAnimationAnimateToActorColorP(void) // Repeat with a different (ease-in) alpha function animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunctions::EaseIn); + animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::EASE_IN); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -6675,7 +6675,7 @@ int UtcDaliAnimationAnimateToActorColorP(void) // Repeat with a shorter animator duration float animatorDuration = 0.5f; animation = Animation::New(durationSeconds); - animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunctions::Linear, TimePeriod(animatorDuration)); + animation.AnimateTo( Property(actor, Actor::Property::COLOR), targetColor, AlphaFunction::LINEAR, TimePeriod(animatorDuration)); animation.FinishedSignal().Connect(&application, finishCheck); animation.Play(); @@ -7762,7 +7762,7 @@ int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctioN(void) keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f)); keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); - animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear ); + animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR ); // Start the animation animation.Play(); @@ -7837,7 +7837,7 @@ int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionCubicP(void) keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f)); keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); - animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear, Animation::Cubic ); + animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, Animation::Cubic ); // Start the animation animation.Play(); @@ -8067,7 +8067,7 @@ int UtcDaliAnimationAnimateBetweenActorColorAlphaFunctionTimePeriodP(void) keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f)); keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); - animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ) ); + animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ) ); // Start the animation animation.Play(); @@ -8144,7 +8144,7 @@ int P(void) keyFrames.Add(0.5f, Vector4(0.9f, 0.8f, 0.7f, 0.6f)); keyFrames.Add(1.0f, Vector4(1.0f, 1.0f, 1.0f, 1.0f)); - animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunctions::Linear, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic ); + animation.AnimateBetween( Property(actor, Actor::Property::COLOR), keyFrames, AlphaFunction::LINEAR, TimePeriod( delay, durationSeconds - delay ), Animation::Cubic ); // Start the animation animation.Play(); @@ -8303,7 +8303,7 @@ int UtcDaliAnimationAnimateAlphaFunctioN(void) // Build the animation float durationSeconds( 1.0f ); Animation animation = Animation::New(durationSeconds); - animation.Animate(actor, path, Vector3::XAXIS, AlphaFunctions::Linear); + animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR); // Start the animation animation.Play(); @@ -8461,7 +8461,7 @@ int UtcDaliAnimationAnimateAlphaFunctionTimePeriodP(void) // Build the animation float durationSeconds( 1.0f ); Animation animation = Animation::New(durationSeconds); - animation.Animate(actor, path, Vector3::XAXIS, AlphaFunctions::Linear, TimePeriod(0.0f, 1.0f)); + animation.Animate(actor, path, Vector3::XAXIS, AlphaFunction::LINEAR, TimePeriod(0.0f, 1.0f)); // Start the animation animation.Play(); @@ -8725,7 +8725,7 @@ int UtcDaliAnimationUpdateManagerP(void) constraint.Apply(); // Apply animation to actor - animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunctions::Linear ); + animation.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 100.f, 90.f, 80.f ), AlphaFunction::LINEAR ); animation.Play(); @@ -8759,9 +8759,9 @@ int UtcDaliAnimationSignalOrderP(void) animation2.FinishedSignal().Connect( &application, AnimationFinishCheck( signal2Received ) ); // Apply animations to actor - animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunctions::Linear ); + animation1.AnimateTo( Property(actor, Actor::Property::POSITION), Vector3( 3.0f, 2.0f, 1.0f ), AlphaFunction::LINEAR ); animation1.Play(); - animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunctions::Linear ); + animation2.AnimateTo( Property(actor, Actor::Property::SIZE ), Vector3( 10.0f, 20.0f, 30.0f ), AlphaFunction::LINEAR ); animation2.Play(); DALI_TEST_EQUALS( signal1Received, false, TEST_LOCATION ); diff --git a/automated-tests/src/dali/utc-Dali-BaseHandle.cpp b/automated-tests/src/dali/utc-Dali-BaseHandle.cpp index 1e2c4ee..74cdc23 100644 --- a/automated-tests/src/dali/utc-Dali-BaseHandle.cpp +++ b/automated-tests/src/dali/utc-Dali-BaseHandle.cpp @@ -341,7 +341,7 @@ int UtcDaliBaseHandleDoAction(void) DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Set the new duration to be 2 seconds float newDurationSeconds(2.0f); diff --git a/automated-tests/src/dali/utc-Dali-Constraint.cpp b/automated-tests/src/dali/utc-Dali-Constraint.cpp index 61016d1..c4c8106 100644 --- a/automated-tests/src/dali/utc-Dali-Constraint.cpp +++ b/automated-tests/src/dali/utc-Dali-Constraint.cpp @@ -2632,7 +2632,7 @@ int UtcDaliConstraintSetAlphaFunction(void) // Test the alpha-function itself AlphaFunction func = constraint.GetAlphaFunction(); - DALI_TEST_EQUALS(func(0.1f), 0.1f, TEST_LOCATION); // Default is Linear + DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION); // Default is Linear // Test that the alpha-function is used correctly @@ -2693,9 +2693,9 @@ int UtcDaliConstraintSetAlphaFunction(void) // Change to non-linear alpha and retest - constraint.SetAlphaFunction(AlphaFunctions::EaseIn); + constraint.SetAlphaFunction(AlphaFunction::EASE_IN); func = constraint.GetAlphaFunction(); - DALI_TEST_CHECK(func(0.1f) < 0.09f); + DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::EASE_IN, TEST_LOCATION); actor.ApplyConstraint( constraint ); @@ -2729,7 +2729,7 @@ int UtcDaliConstraintGetAlphaFunction(void) Constraint constraint = Constraint::New( Actor::Property::COLOR, TestConstraint() ); AlphaFunction func = constraint.GetAlphaFunction(); - DALI_TEST_EQUALS(func(0.5f), 0.5f, TEST_LOCATION); // Default is Linear + DALI_TEST_EQUALS(func.GetBuiltinFunction(), AlphaFunction::DEFAULT, TEST_LOCATION); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Handle.cpp b/automated-tests/src/dali/utc-Dali-Handle.cpp index 69d4990..648f618 100644 --- a/automated-tests/src/dali/utc-Dali-Handle.cpp +++ b/automated-tests/src/dali/utc-Dali-Handle.cpp @@ -489,7 +489,7 @@ int UtcDaliHandleNonAnimtableProperties(void) try { - animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunctions::EaseIn); + animation.AnimateBy(Property(actor, nonAnimStringIndex), relativeValue, AlphaFunction::EASE_IN); animation.Play(); application.SendNotification(); application.Render(static_cast(durationSeconds*0100.0f)/* some progress */); diff --git a/automated-tests/src/dali/utc-Dali-PropertyNotification.cpp b/automated-tests/src/dali/utc-Dali-PropertyNotification.cpp index 4a26a4a..867880a 100644 --- a/automated-tests/src/dali/utc-Dali-PropertyNotification.cpp +++ b/automated-tests/src/dali/utc-Dali-PropertyNotification.cpp @@ -861,7 +861,7 @@ int UtcDaliPropertyNotificationOrder(void) PropertyNotification notification2 = actor.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(150.0f) ); notification2.NotifySignal().Connect( &TestCallback2 ); Animation animation = Animation::New( 0.032f ); // finishes in 32 ms - animation.AnimateTo( Property(actor, Actor::Property::POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), AlphaFunctions::Linear ); + animation.AnimateTo( Property(actor, Actor::Property::POSITION ), Vector3( 200.0f, 0.0f, 0.0f ), AlphaFunction::LINEAR ); animation.Play(); // flush the queue diff --git a/automated-tests/src/dali/utc-Dali-RenderTask.cpp b/automated-tests/src/dali/utc-Dali-RenderTask.cpp index 7b22063..1f54e7f 100644 --- a/automated-tests/src/dali/utc-Dali-RenderTask.cpp +++ b/automated-tests/src/dali/utc-Dali-RenderTask.cpp @@ -1392,7 +1392,7 @@ int UtcDaliRenderTaskSetViewportPosition(void) Vector2 newPosition3(64.0f, 0.0f); Animation animation = Animation::New(1.0f); - animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunctions::Linear ); + animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_POSITION ), newPosition3, AlphaFunction::LINEAR ); animation.Play(); // Perform 1000ms worth of updates at which point animation should have completed. @@ -1440,7 +1440,7 @@ int UtcDaliRenderTaskSetViewportSize(void) Vector2 newSize3(10.0f, 10.0f); Animation animation = Animation::New(1.0f); - animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunctions::Linear ); + animation.AnimateTo( Property( task, RenderTask::Property::VIEWPORT_SIZE ), newSize3, AlphaFunction::LINEAR ); animation.Play(); // Perform 1000ms worth of updates at which point animation should have completed. diff --git a/dali/internal/event/animation/animation-impl.cpp b/dali/internal/event/animation/animation-impl.cpp index bf8075a..4834b66 100644 --- a/dali/internal/event/animation/animation-impl.cpp +++ b/dali/internal/event/animation/animation-impl.cpp @@ -23,7 +23,7 @@ // INTERNAL INCLUDES #include -#include +#include #include #include #include @@ -81,6 +81,7 @@ TypeAction action3( mType, ACTION_PAUSE, &Animation::DoAction ); const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::Bake ); const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BakeFinal ); const Dali::Animation::Interpolation DEFAULT_INTERPOLATION( Dali::Animation::Linear ); +const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION( Dali::AlphaFunction::DEFAULT ); } // anon namespace @@ -97,7 +98,7 @@ AnimationPtr Animation::New(float durationSeconds) durationSeconds = 0.0f; } - AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, Dali::AlphaFunctions::Linear ); + AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION ); // Second-phase construction animation->Initialize(); @@ -289,17 +290,17 @@ void Animation::Clear() void Animation::AnimateBy(Property& target, Property::Value& relativeValue) { - AnimateBy(target, relativeValue, AlphaFunctions::Default, mDurationSeconds); + AnimateBy(target, relativeValue, mDefaultAlpha, TimePeriod(mDurationSeconds)); } void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha) { - AnimateBy(target, relativeValue, alpha, mDurationSeconds); + AnimateBy(target, relativeValue, alpha, TimePeriod(mDurationSeconds)); } void Animation::AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period) { - AnimateBy(target, relativeValue, AlphaFunctions::Default, period); + AnimateBy(target, relativeValue, mDefaultAlpha, period); } void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period) @@ -408,17 +409,17 @@ void Animation::AnimateBy(Property& target, Property::Value& relativeValue, Alph void Animation::AnimateTo(Property& target, Property::Value& destinationValue) { - AnimateTo(target, destinationValue, AlphaFunctions::Default, mDurationSeconds); + AnimateTo(target, destinationValue, mDefaultAlpha, TimePeriod(mDurationSeconds)); } void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha) { - AnimateTo(target, destinationValue, alpha, mDurationSeconds); + AnimateTo(target, destinationValue, alpha, TimePeriod(mDurationSeconds)); } void Animation::AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period) { - AnimateTo(target, destinationValue, AlphaFunctions::Default, period); + AnimateTo(target, destinationValue, mDefaultAlpha, period); } void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period) @@ -553,12 +554,12 @@ void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIn void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames) { - AnimateBetween(target, keyFrames, mDefaultAlpha, mDurationSeconds, DEFAULT_INTERPOLATION ); + AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION ); } void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation ) { - AnimateBetween(target, keyFrames, mDefaultAlpha, mDurationSeconds, interpolation ); + AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), interpolation ); } void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period) @@ -573,12 +574,12 @@ void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Time void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha) { - AnimateBetween(target, keyFrames, alpha, mDurationSeconds, DEFAULT_INTERPOLATION); + AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION); } void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation) { - AnimateBetween(target, keyFrames, alpha, mDurationSeconds, interpolation); + AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), interpolation); } void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period) @@ -783,12 +784,12 @@ void Animation::AddAnimatorConnector( AnimatorConnectorBase* connector ) void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward ) { - Animate( actor, path, forward, mDefaultAlpha, TimePeriod(0.0f,GetDuration()) ); + Animate( actor, path, forward, mDefaultAlpha, TimePeriod(mDurationSeconds) ); } void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha ) { - Animate( actor, path, forward, alpha, TimePeriod(0.0f,GetDuration()) ); + Animate( actor, path, forward, alpha, TimePeriod(mDurationSeconds) ); } void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, TimePeriod period ) @@ -831,7 +832,7 @@ void Animation::Show(Actor& actor, float delaySeconds) Dali::Actor::Property::VISIBLE, Property::INVALID_COMPONENT_INDEX, new AnimateToBoolean(SHOW_VALUE), - AlphaFunctions::Default, + mDefaultAlpha, TimePeriod(delaySeconds, 0.0f/*immediate*/) ) ); } @@ -843,7 +844,7 @@ void Animation::Hide(Actor& actor, float delaySeconds) Dali::Actor::Property::VISIBLE, Property::INVALID_COMPONENT_INDEX, new AnimateToBoolean(HIDE_VALUE), - AlphaFunctions::Default, + mDefaultAlpha, TimePeriod(delaySeconds, 0.0f/*immediate*/) ) ); } diff --git a/dali/internal/event/animation/animator-connector-base.h b/dali/internal/event/animation/animator-connector-base.h index cbd4b86..90ff6f5 100644 --- a/dali/internal/event/animation/animator-connector-base.h +++ b/dali/internal/event/animation/animator-connector-base.h @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include #include #include diff --git a/dali/internal/event/animation/key-frames-impl.h b/dali/internal/event/animation/key-frames-impl.h index 4e42829..0a48c94 100644 --- a/dali/internal/event/animation/key-frames-impl.h +++ b/dali/internal/event/animation/key-frames-impl.h @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include diff --git a/dali/internal/update/animation/scene-graph-animation.cpp b/dali/internal/update/animation/scene-graph-animation.cpp index 0be315d..de9c793 100644 --- a/dali/internal/update/animation/scene-graph-animation.cpp +++ b/dali/internal/update/animation/scene-graph-animation.cpp @@ -33,10 +33,6 @@ namespace Internal namespace SceneGraph { -float DefaultAlphaFunc(float progress) -{ - return progress; // linear -} Animation::Animation( float durationSeconds, float speedFactor, const Vector2& playRange, bool isLooping, Dali::Animation::EndAction endAction, Dali::Animation::EndAction disconnectAction ) : mDurationSeconds(durationSeconds), diff --git a/dali/internal/update/animation/scene-graph-animator.h b/dali/internal/update/animation/scene-graph-animator.h index 9997d9d..6e46ebf 100644 --- a/dali/internal/update/animation/scene-graph-animator.h +++ b/dali/internal/update/animation/scene-graph-animator.h @@ -24,9 +24,10 @@ #include #include #include -#include +#include #include #include +#include #include #include #include @@ -67,7 +68,7 @@ public: AnimatorBase() : mDurationSeconds(1.0f), mInitialDelaySeconds(0.0f), - mAlphaFunc(AlphaFunctions::Linear), + mAlphaFunction(AlphaFunction::DEFAULT), mDisconnectAction(Dali::Animation::BakeFinal), mActive(false), mEnabled(true) @@ -125,18 +126,146 @@ public: * Set the alpha function for an animator. * @param [in] alphaFunc The alpha function to apply to the animation progress. */ - void SetAlphaFunc(AlphaFunc alphaFunc) + void SetAlphaFunction(const AlphaFunction& alphaFunction) { - mAlphaFunc = alphaFunc; + mAlphaFunction = alphaFunction; } /** * Retrieve the alpha function of an animator. * @return The function. */ - AlphaFunc GetAlphaFunc() const + AlphaFunction GetAlphaFunction() const { - return mAlphaFunc; + return mAlphaFunction; + } + + /* + * Applies the alpha function to the specified progress + * @param[in] Current progress + * @return The progress after the alpha function has been aplied + */ + float ApplyAlphaFunction( float progress ) const + { + float result = progress; + + AlphaFunction::Mode alphaFunctionMode( mAlphaFunction.GetMode() ); + if( alphaFunctionMode == AlphaFunction::BUILTIN_FUNCTION ) + { + switch(mAlphaFunction.GetBuiltinFunction()) + { + case AlphaFunction::DEFAULT: + case AlphaFunction::LINEAR: + { + break; + } + case AlphaFunction::REVERSE: + { + result = 1.0f-progress; + break; + } + case AlphaFunction::EASE_IN_SQUARE: + { + result = progress * progress; + break; + } + case AlphaFunction::EASE_OUT_SQUARE: + { + result = 1.0f - (1.0f-progress) * (1.0f-progress); + break; + } + case AlphaFunction::EASE_IN: + { + result = progress * progress * progress; + break; + } + case AlphaFunction::EASE_OUT: + { + result = (progress-1.0f) * (progress-1.0f) * (progress-1.0f) + 1.0f; + break; + } + case AlphaFunction::EASE_IN_OUT: + { + result = progress*progress*(3.0f-2.0f*progress); + break; + } + case AlphaFunction::EASE_IN_SINE: + { + result = -1.0f * cosf(progress * Math::PI_2) + 1.0f; + break; + } + case AlphaFunction::EASE_OUT_SINE: + { + result = sinf(progress * Math::PI_2); + break; + } + case AlphaFunction::EASE_IN_OUT_SINE: + { + result = -0.5f * (cosf(Math::PI * progress) - 1.0f); + break; + } + case AlphaFunction::BOUNCE: + { + result = sinf(progress * Math::PI); + break; + } + case AlphaFunction::SIN: + { + result = 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f; + break; + } + case AlphaFunction::EASE_OUT_BACK: + { + const float sqrt2 = 1.70158f; + progress -= 1.0f; + result = 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 ); + break; + } + default: + break; + } + } + else if( alphaFunctionMode == AlphaFunction::CUSTOM_FUNCTION ) + { + AlphaFunctionPrototype customFunction = mAlphaFunction.GetCustomFunction(); + if( customFunction ) + { + result = customFunction(progress); + } + } + else + { + //If progress is very close to 0 or very close to 1 we don't need to evaluate the curve as the result will + //be almost 0 or almost 1 respectively + if( ( progress > Math::MACHINE_EPSILON_1 ) && ((1.0f - progress) > Math::MACHINE_EPSILON_1) ) + { + Dali::Vector4 controlPoints = mAlphaFunction.GetBezierControlPoints(); + + static const float tolerance = 0.001f; //10 iteration max + + //Perform a binary search on the curve + float lowerBound(0.0f); + float upperBound(1.0f); + float currentT(0.5f); + float currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT); + while( fabs( progress - currentX ) > tolerance ) + { + if( progress > currentX ) + { + lowerBound = currentT; + } + else + { + upperBound = currentT; + } + currentT = (upperBound+lowerBound)*0.5f; + currentX = EvaluateCubicBezier( controlPoints.x, controlPoints.z, currentT); + } + result = EvaluateCubicBezier( controlPoints.y, controlPoints.w, currentT); + } + } + + return result; } /** @@ -204,10 +333,23 @@ public: protected: + /** + * Helper function to evaluate a cubic bezier curve assuming first point is at 0.0 and last point is at 1.0 + * @param[in] p0 First control point of the bezier curve + * @param[in] p1 Second control point of the bezier curve + * @param[in] t A floating point value between 0.0 and 1.0 + * @return Value of the curve at progress t + */ + inline float EvaluateCubicBezier( float p0, float p1, float t ) const + { + float tSquare = t*t; + return 3.0f*(1.0f-t)*(1.0f-t)*t*p0 + 3.0f*(1.0f-t)*tSquare*p1 + tSquare*t; + } + float mDurationSeconds; float mInitialDelaySeconds; - AlphaFunc mAlphaFunc; + AlphaFunction mAlphaFunction; Dali::Animation::EndAction mDisconnectAction; ///< EndAction to apply when target object gets disconnected from the stage. bool mActive:1; ///< Animator is "active" while it's running. @@ -243,7 +385,7 @@ public: const_cast( &property ), animatorFunction ); - animator->SetAlphaFunc( alphaFunction ); + animator->SetAlphaFunction( alphaFunction ); animator->SetInitialDelay( timePeriod.delaySeconds ); animator->SetDuration( timePeriod.durationSeconds ); @@ -305,7 +447,8 @@ public: */ virtual void Update( BufferIndex bufferIndex, float progress, bool bake ) { - float alpha = mAlphaFunc( progress ); + float alpha = ApplyAlphaFunction(progress); + const PropertyType& current = mPropertyAccessor.Get( bufferIndex ); const PropertyType result = (*mAnimatorFunction)( alpha, current ); diff --git a/dali/internal/update/animation/scene-graph-constraint.h b/dali/internal/update/animation/scene-graph-constraint.h index 14b83b8..ce934a4 100644 --- a/dali/internal/update/animation/scene-graph-constraint.h +++ b/dali/internal/update/animation/scene-graph-constraint.h @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include #include #include #include diff --git a/dali/public-api/animation/alpha-function.cpp b/dali/public-api/animation/alpha-function.cpp new file mode 100644 index 0000000..7ce7db5 --- /dev/null +++ b/dali/public-api/animation/alpha-function.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL INCLUDES + +namespace Dali +{ + +AlphaFunction::AlphaFunction() +:mBezierControlPoints(Vector4::ZERO), + mCustom(0), + mBuiltin(DEFAULT), + mMode(BUILTIN_FUNCTION) +{} + +AlphaFunction::AlphaFunction( BuiltinFunction function) +:mBezierControlPoints(Vector4::ZERO), + mCustom(0), + mBuiltin(function), + mMode(BUILTIN_FUNCTION) +{} + +AlphaFunction::AlphaFunction( AlphaFunctionPrototype function) +:mBezierControlPoints(Vector4::ZERO), + mCustom(function), + mBuiltin(DEFAULT), + mMode(CUSTOM_FUNCTION) +{} + +AlphaFunction::AlphaFunction( const Vector2& controlPoint0, const Vector2& controlPoint1 ) +:mBezierControlPoints(Vector4(Clamp(controlPoint0.x,0.0f,1.0f),controlPoint0.y, + Clamp(controlPoint1.x,0.0f,1.0f),controlPoint1.y)), + mCustom(0), + mBuiltin(DEFAULT), + mMode(BEZIER) +{ +} + +Vector4 AlphaFunction::GetBezierControlPoints() const +{ + return mBezierControlPoints; +} + +AlphaFunctionPrototype AlphaFunction::GetCustomFunction() const +{ + return mCustom; +} + +AlphaFunction::BuiltinFunction AlphaFunction::GetBuiltinFunction() const +{ + return mBuiltin; +} + +AlphaFunction::Mode AlphaFunction::GetMode() const +{ + return mMode; +} + +} // namespace Dali diff --git a/dali/public-api/animation/alpha-function.h b/dali/public-api/animation/alpha-function.h new file mode 100644 index 0000000..2e3bffa --- /dev/null +++ b/dali/public-api/animation/alpha-function.h @@ -0,0 +1,153 @@ +#ifndef __DALI_ALPHA_FUNCTION_H__ +#define __DALI_ALPHA_FUNCTION_H__ + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include + +namespace Dali +{ + +typedef float (*AlphaFunctionPrototype)(float progress); ///< Prototype of an alpha function + + /* + * @brief Alpha functions are used in animations to specify the rate of change of the animation parameter over time. + * Understanding an animation as a parametric function over time, the alpha function is applied to the parameter of + * the animation before computing the final animation value. + */ +class DALI_IMPORT_API AlphaFunction +{ +public: + + /** + * Built-in alpha functions + */ + enum BuiltinFunction + { + DEFAULT, ///< Linear + LINEAR, ///< No transformation + REVERSE, ///< Reverse linear + + EASE_IN_SQUARE, ///< Speeds up and comes to a sudden stop (Square) + EASE_OUT_SQUARE, ///< Sudden start and slows to a gradual stop (Square) + + EASE_IN, ///< Speeds up and comes to a sudden stop (Cubic) + EASE_OUT, ///< Sudden start and slows to a gradual stop (Cubic) + EASE_IN_OUT, ///< Speeds up and slows to a gradual stop (Cubic) + + EASE_IN_SINE, ///< Speeds up and comes to a sudden stop (sinusoidal) + EASE_OUT_SINE, ///< Sudden start and slows to a gradual stop (sinusoidal) + EASE_IN_OUT_SINE, ///< Speeds up and slows to a gradual stop (sinusoidal) + + BOUNCE, ///< Sudden start, loses momentum and returns to start position + SIN, ///< Single revolution + EASE_OUT_BACK, ///< Sudden start, exceed end position and return to a gradual stop + + COUNT + }; + + /** + * All possible functioning modes for the alpha function + */ + enum Mode + { + BUILTIN_FUNCTION, //< The user has specified a built-in function + CUSTOM_FUNCTION, //< The user has provided a custom function + BEZIER //< The user has provided the control points of a bezier curve + }; + + /** + * @brief Default constructor. + * Creates an alpha function object with the default built-in alpha function + * @return The alpha function + */ + AlphaFunction(); + + /** + * @brief Constructor. + * Creates an alpha function object with the built-in alpha function passed as a parameter + * to the constructor + * @param[in] function One of the built-in alpha functions + * @return The alpha function + */ + AlphaFunction( BuiltinFunction function); + + /** + * @brief Constructor. + * Creates an alpha function object using a pointer to an alpha function passed as a paramter + * to the constructor + * @param[in] function A pointer to an alpha function + * @return The alpha function + */ + AlphaFunction( AlphaFunctionPrototype function); + + /** + * @brief Constructor. + * Creates a bezier alpha function. The bezier will have the first point at (0,0) and + * the end point at (1,1). + * @note The x components of the control points will be clamped to the range [0,1] to prevent + * non monotonic curves. + * @param[in] controlPoint0 A Vector2 which will be used as the first control point of the curve + * @param[in] controlPoint1 A Vector2 which will be used as the second control point of the curve + * @return The alpha function + */ + AlphaFunction( const Dali::Vector2& controlPoint0, const Dali::Vector2& controlPoint1 ); + + /** + * @brief Return the control points of the alpha function + * @return Vector4 containing the two control points of the curve. + * (xy for the first point and zw for the second) + */ + Vector4 GetBezierControlPoints() const; + + /** + * @brief Returns the pointer to the custom function + * @return A pointer to a custom alpha function or 0 if not defined + */ + AlphaFunctionPrototype GetCustomFunction() const; + + /** + * @brief Returns the built0in function used by the alpha function + * @return One of the built-in alpha functions. In case no built-in function + * has been specified, it will return AlphaFunction::DEfAULT + */ + BuiltinFunction GetBuiltinFunction() const; + + /** + * @brief Returns the functioning mode of the alpha function + * @return The functioning mode of the alpha function + */ + Mode GetMode() const; + +private: + + Vector4 mBezierControlPoints; //< Control points for the bezier alpha function + AlphaFunctionPrototype mCustom; //< Pointer to an alpha function + BuiltinFunction mBuiltin : Log::value+1; //< Enum indicating the built-in alpha function + Mode mMode : 2; //< Enum indicating the functioning mode of the AlphaFunction +}; + +} // namespace Dali + +#endif // __DALI_ALPHA_FUNCTION_H__ diff --git a/dali/public-api/animation/alpha-functions.cpp b/dali/public-api/animation/alpha-functions.cpp deleted file mode 100644 index 44a9618..0000000 --- a/dali/public-api/animation/alpha-functions.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// CLASS HEADER -#include - -// INTERNAL INCLUDES - -namespace Dali -{ - -namespace AlphaFunctions -{ - - -} // AlphaFunctions - -} // namespace Dali diff --git a/dali/public-api/animation/alpha-functions.h b/dali/public-api/animation/alpha-functions.h deleted file mode 100644 index ed14196..0000000 --- a/dali/public-api/animation/alpha-functions.h +++ /dev/null @@ -1,222 +0,0 @@ -#ifndef __DALI_ALPHA_FUNCTIONS_H__ -#define __DALI_ALPHA_FUNCTIONS_H__ - -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// INTERNAL INCLUDES -#include -#include - -namespace Dali -{ - -typedef float (*AlphaFunction)(float progress); ///< Definition of an alpha function - -/** - * @brief Namespace containing a set of alpha functions. - */ -namespace AlphaFunctions -{ - -inline float Linear( float progress ) -{ - return progress; -} - -inline float Default( float progress ) -{ - return Linear( progress ); -} - -inline float Reverse( float progress ) ///< Reverse linear -{ - return 1.0f - progress; -} - -inline float Square( float progress ) ///< Square (x^2) -{ - return progress * progress; -} - -inline float EaseIn( float progress ) ///< Speeds up and comes to a sudden stop -{ - return progress * progress * progress; -} - -inline float EaseOut( float progress ) ///< Sudden start and slows to a gradual stop -{ - progress -= 1.0f; - - return progress * progress * progress + 1.0f; -} - -inline float EaseInOut( float progress ) ///< Speeds up and slows to a gradual stop -{ - if (progress > 0.5f) - { - return EaseOut((progress - 0.5f)*2.0f) * 0.5f + 0.5f; - } - else - { - return EaseIn(progress * 2.0f) * 0.5f; - } -} - -inline float EaseInSine( float progress ) ///< Speeds up and comes to a sudden stop -{ - return -1.0f * cosf(progress * Math::PI_2) + 1.0f; -} - -inline float EaseOutSine( float progress ) ///< Sudden start and slows to a gradual stop -{ - return sinf(progress * Math::PI_2); -} - -inline float EaseInOutSine( float progress ) ///< Speeds up and slows to a gradual stop -{ - return -0.5f * (cosf(Math::PI * progress) - 1.0f); -} - -inline float EaseInSine33( float progress ) ///< Speeds up and comes to a sudden stop -{ - float tmp = cosf(Math::PI_2 * 33.0f / 90.0f); - return -1.0f * (cosf(progress * Math::PI_2 * 33.0f / 90.0f) - tmp) / (1.0f - tmp) + 1.0f; -} - -inline float EaseOutSine33( float progress ) ///< Sudden start and slows to a gradual stop -{ - float tmp = cosf(Math::PI_2 * 33.0f / 90.0f); - return (cosf((1.0f - progress) * Math::PI_2 * 33.0f / 90.0f) - tmp) / (1.0f - tmp); -} - -inline float EaseInOutSine33( float progress ) ///< Speeds up and slows to a gradual stop -{ - float tmp = sinf(Math::PI_2 * 33.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 33.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -inline float EaseInOutSine50( float progress ) ///< Speeds up and slows to a gradual stop -{ - float tmp = sinf(Math::PI_2 * 50.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 50.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -inline float EaseInOutSine60( float progress ) ///< Speeds up and slows to a gradual stop -{ - float tmp = sinf(Math::PI_2 * 60.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 60.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -inline float EaseInOutSine70( float progress ) ///< Speeds up and slows to a gradual stop -{ - float tmp = sinf(Math::PI_2 * 70.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 70.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -inline float EaseInOutSine80( float progress ) ///< Speeds up and slows to a gradual stop -{ - float tmp = sinf(Math::PI_2 * 80.0f / 90.0f); - return (sinf((progress * Math::PI - Math::PI_2) * 80.0f / 90.0f) + tmp) / (2.0f * tmp); -} - -inline float EaseInOutSine90( float progress ) ///< Speeds up and slows to a gradual stop -{ - return EaseInOutSine(progress); -} - -inline float DoubleEaseInOutSine60( float progress ) ///< Speeds up and slows to a gradual stop, then speeds up again and slows to a gradual stop -{ - if (progress < 0.5f) - { - return EaseInOutSine60(progress * 2.0f) / 2.0f; - } - else - { - return EaseInOutSine60((progress - 0.5f) * 2.0f) / 2.0f + 0.5f; - } -} - -inline float EaseOutQuint50( float progress ) ///< Sudden start and slows to a gradual stop -{ - return 1.0f - powf(1.0f - progress, 1.7f); -} - -inline float EaseOutQuint80( float progress ) ///< Sudden start and slows to a gradual stop -{ - return 1.0f - powf(1.0f - progress, 2.3f); -} - -inline float Bounce( float progress ) ///< Sudden start, loses momentum and returns to start position -{ - return sinf(progress * Math::PI); -} - -inline float BounceBack( float progress ) ///< Sudden start, loses momentum and returns to exceed start position and gradual stop at start position -{ - if( progress > 0.0f ) - { - return (sinf(progress * 2.0f * Math::PI) * sinf(progress * Math::PI)) / (progress * Math::PI); - } - else - { - return 0; - } -} - -inline float EaseInBack( float progress ) ///< Slow start, exceed start position and quickly reach destination -{ - const float sqrt2 = 1.70158f; - - return progress * progress * ( ( sqrt2 + 1.0f ) * progress - sqrt2 ); -} - -inline float EaseOutBack( float progress ) ///< Sudden start, exceed end position and return to a gradual stop -{ - const float sqrt2 = 1.70158f; - progress -= 1.0f; - - return 1.0f + progress * progress * ( ( sqrt2 + 1.0f ) * progress + sqrt2 ); -} - -inline float EaseInOutBack( float progress ) ///< Slow start, exceed start position, fast middle, exceed end position and return to a gradual stop -{ - if (progress > 0.5f) - { - return EaseOutBack((progress - 0.5f)*2.0f) * 0.5f + 0.5f; - } - else - { - return EaseInBack(progress * 2.0f) * 0.5f; - } -} - -inline float Sin( float progress ) ///< Single revolution -{ - return 0.5f - cosf(progress * 2.0f * Math::PI) * 0.5f; -} - -inline float Sin2x( float progress ) ///< Two revolutions -{ - return 0.5f - cosf(progress * 4.0f * Math::PI) * 0.5f; -} - -} // namespace AlphaFunctions - -} // namespace Dali - -#endif // __DALI_ALPHA_FUNCTIONS_H__ diff --git a/dali/public-api/animation/animation.cpp b/dali/public-api/animation/animation.cpp index 5b65d5c..32c8ebe 100644 --- a/dali/public-api/animation/animation.cpp +++ b/dali/public-api/animation/animation.cpp @@ -19,7 +19,7 @@ #include // INTERNAL INCLUDES -#include +#include #include #include #include diff --git a/dali/public-api/animation/animation.h b/dali/public-api/animation/animation.h index 5238757..fbd4435 100644 --- a/dali/public-api/animation/animation.h +++ b/dali/public-api/animation/animation.h @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include #include #include #include diff --git a/dali/public-api/animation/key-frames.cpp b/dali/public-api/animation/key-frames.cpp index 873bb12..34148e9 100644 --- a/dali/public-api/animation/key-frames.cpp +++ b/dali/public-api/animation/key-frames.cpp @@ -19,7 +19,7 @@ #include // INTERNAL INCLUDES -#include +#include #include #include #include @@ -64,7 +64,7 @@ Property::Type KeyFrames::GetType() const void KeyFrames::Add(float time, Property::Value value) { - Add(time, value, AlphaFunctions::Linear); + Add(time, value, AlphaFunction::DEFAULT); } void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) diff --git a/dali/public-api/animation/key-frames.h b/dali/public-api/animation/key-frames.h index f1025f5..56a6679 100644 --- a/dali/public-api/animation/key-frames.h +++ b/dali/public-api/animation/key-frames.h @@ -19,7 +19,7 @@ */ // INTERNAL INCLUDES -#include +#include #include #include #include diff --git a/dali/public-api/animation/time-period.h b/dali/public-api/animation/time-period.h index 5ea5ccd..fe552ad 100644 --- a/dali/public-api/animation/time-period.h +++ b/dali/public-api/animation/time-period.h @@ -34,7 +34,7 @@ struct DALI_IMPORT_API TimePeriod * * @param [in] durationSeconds The duration of the time period in seconds. */ - TimePeriod(float durationSeconds); + explicit TimePeriod(float durationSeconds); /** * @brief Create a time period. diff --git a/dali/public-api/dali-core.h b/dali/public-api/dali-core.h index a6fca68..ebcd2f5 100644 --- a/dali/public-api/dali-core.h +++ b/dali/public-api/dali-core.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include diff --git a/dali/public-api/file.list b/dali/public-api/file.list index 376c97f..ee482d5 100644 --- a/dali/public-api/file.list +++ b/dali/public-api/file.list @@ -11,7 +11,7 @@ public_api_src_files = \ $(public_api_src_dir)/actors/mesh-actor.cpp \ $(public_api_src_dir)/actors/renderable-actor.cpp \ $(public_api_src_dir)/animation/animation.cpp \ - $(public_api_src_dir)/animation/alpha-functions.cpp \ + $(public_api_src_dir)/animation/alpha-function.cpp \ $(public_api_src_dir)/animation/constraint.cpp \ $(public_api_src_dir)/animation/constraint-source.cpp \ $(public_api_src_dir)/animation/key-frames.cpp \ @@ -122,7 +122,7 @@ public_api_core_actors_header_files = \ $(public_api_src_dir)/actors/sampling.h public_api_core_animation_header_files = \ - $(public_api_src_dir)/animation/alpha-functions.h \ + $(public_api_src_dir)/animation/alpha-function.h \ $(public_api_src_dir)/animation/animation.h \ $(public_api_src_dir)/animation/constraint.h \ $(public_api_src_dir)/animation/constraints.h \