Support animation of Visual transform properties 91/250191/2
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 22 Dec 2020 01:05:34 +0000 (10:05 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 23 Dec 2020 04:16:44 +0000 (13:16 +0900)
Change-Id: I95cc81b6e0e0a545d18db480a715afb9660851b1

automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.cpp
dali-toolkit/internal/visuals/visual-base-data-impl.h
dali-toolkit/internal/visuals/visual-base-impl.cpp
dali-toolkit/public-api/visuals/visual-properties.h

index c135c9f..6f3fa6a 100644 (file)
@@ -3959,6 +3959,8 @@ int UtcDaliVisualGetVisualProperty01(void)
   application.Render();
 
   Vector3 targetColor(1.0f, 1.0f, 1.0f);
   application.Render();
 
   Vector3 targetColor(1.0f, 1.0f, 1.0f);
+  Vector2 targetOffset(0.05f, 0.05f);
+  Vector2 targetSize(1.1f, 1.1f);
   float targetOpacity = 0.5f;
   float targetCornerRadius = 20.0f;
   float targetBlurRadius = 10.0f;
   float targetOpacity = 0.5f;
   float targetCornerRadius = 20.0f;
   float targetBlurRadius = 10.0f;
@@ -3966,6 +3968,8 @@ int UtcDaliVisualGetVisualProperty01(void)
   Animation animation = Animation::New(1.0f);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::MIX_COLOR), targetColor);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
   Animation animation = Animation::New(1.0f);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::MIX_COLOR), targetColor);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::OPACITY), targetOpacity);
+  animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Transform::Property::OFFSET), targetOffset);
+  animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Transform::Property::SIZE), targetSize);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), targetCornerRadius);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelColorVisual::Property::BLUR_RADIUS), targetBlurRadius);
   animation.Play();
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelVisual::Property::CORNER_RADIUS), targetCornerRadius);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, DevelColorVisual::Property::BLUR_RADIUS), targetBlurRadius);
   animation.Play();
@@ -3982,6 +3986,18 @@ int UtcDaliVisualGetVisualProperty01(void)
   DALI_TEST_CHECK(colorValue);
   DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
 
   DALI_TEST_CHECK(colorValue);
   DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
 
+  Property::Value* transformValue = resultMap.Find(Dali::Toolkit::Visual::Property::TRANSFORM);
+  Dali::Property::Map* transformMap = transformValue->GetMap();
+  DALI_TEST_CHECK(transformMap);
+
+  Property::Value* offsetValue = transformMap->Find(Toolkit::Visual::Transform::Property::OFFSET);
+  DALI_TEST_CHECK(offsetValue);
+  DALI_TEST_EQUALS(offsetValue->Get<Vector2>(), targetOffset, TEST_LOCATION);
+
+  Property::Value* sizeValue = transformMap->Find(Toolkit::Visual::Transform::Property::SIZE);
+  DALI_TEST_CHECK(sizeValue);
+  DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
+
   Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
   DALI_TEST_CHECK(cornerRadiusValue);
   DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
   Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
   DALI_TEST_CHECK(cornerRadiusValue);
   DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
@@ -3992,6 +4008,8 @@ int UtcDaliVisualGetVisualProperty01(void)
 
   // Test uniform values
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
 
   // Test uniform values
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
 
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
 
@@ -4040,6 +4058,8 @@ int UtcDaliVisualGetVisualProperty02(void)
   application.Render();
 
   Vector3 targetColor(1.0f, 1.0f, 1.0f);
   application.Render();
 
   Vector3 targetColor(1.0f, 1.0f, 1.0f);
+  Vector2 targetOffset(0.05f, 0.05f);
+  Vector2 targetSize(1.1f, 1.1f);
   float targetOpacity = 0.5f;
   float targetCornerRadius = 20.0f;
   float targetBlurRadius = 10.0f;
   float targetOpacity = 0.5f;
   float targetCornerRadius = 20.0f;
   float targetBlurRadius = 10.0f;
@@ -4048,6 +4068,8 @@ int UtcDaliVisualGetVisualProperty02(void)
   Animation animation = Animation::New(1.0f);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "mixColor"), targetColor);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "opacity"), targetOpacity);
   Animation animation = Animation::New(1.0f);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "mixColor"), targetColor);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "opacity"), targetOpacity);
+  animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "offset"), targetOffset);
+  animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "size"), targetSize);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "cornerRadius"), targetCornerRadius);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "blurRadius"), targetBlurRadius);
   animation.Play();
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "cornerRadius"), targetCornerRadius);
   animation.AnimateTo(DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, "blurRadius"), targetBlurRadius);
   animation.Play();
@@ -4064,6 +4086,18 @@ int UtcDaliVisualGetVisualProperty02(void)
   DALI_TEST_CHECK(colorValue);
   DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
 
   DALI_TEST_CHECK(colorValue);
   DALI_TEST_EQUALS(colorValue->Get<Vector4>(), Vector4(targetColor.r, targetColor.g, targetColor.b, targetOpacity), TEST_LOCATION);
 
+  Property::Value* transformValue = resultMap.Find(Dali::Toolkit::Visual::Property::TRANSFORM);
+  Dali::Property::Map* transformMap = transformValue->GetMap();
+  DALI_TEST_CHECK(transformMap);
+
+  Property::Value* offsetValue = transformMap->Find(Toolkit::Visual::Transform::Property::OFFSET);
+  DALI_TEST_CHECK(offsetValue);
+  DALI_TEST_EQUALS(offsetValue->Get<Vector2>(), targetOffset, TEST_LOCATION);
+
+  Property::Value* sizeValue = transformMap->Find(Toolkit::Visual::Transform::Property::SIZE);
+  DALI_TEST_CHECK(sizeValue);
+  DALI_TEST_EQUALS(sizeValue->Get<Vector2>(), targetSize, TEST_LOCATION);
+
   Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
   DALI_TEST_CHECK(cornerRadiusValue);
   DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
   Property::Value* cornerRadiusValue = resultMap.Find(DevelVisual::Property::CORNER_RADIUS, Property::FLOAT);
   DALI_TEST_CHECK(cornerRadiusValue);
   DALI_TEST_EQUALS(cornerRadiusValue->Get< float >(), targetCornerRadius, TEST_LOCATION);
@@ -4074,6 +4108,8 @@ int UtcDaliVisualGetVisualProperty02(void)
 
   // Test uniform values
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
 
   // Test uniform values
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", targetColor), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("offset", targetOffset), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector2>("size", targetSize), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
 
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("cornerRadius", targetCornerRadius), true, TEST_LOCATION);
   DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<float>("blurRadius", targetBlurRadius), true, TEST_LOCATION);
 
index fc962bd..67ab688 100644 (file)
@@ -242,12 +242,14 @@ void Internal::Visual::Base::Impl::CustomShader::CreatePropertyMap( Property::Ma
 }
 
 Internal::Visual::Base::Impl::Transform::Transform()
 }
 
 Internal::Visual::Base::Impl::Transform::Transform()
-: mOffset( 0.0f,0.0f ),
-  mSize( 1.0f,1.0f ),
-  mExtraSize( 0.0f,0.0f ),
-  mOffsetSizeMode( 0.0f,0.0f,0.0f,0.0f ),
-  mOrigin( Toolkit::Align::TOP_BEGIN ),
-  mAnchorPoint( Toolkit::Align::TOP_BEGIN )
+: mOffset(0.0f, 0.0f),
+  mSize(1.0f, 1.0f),
+  mExtraSize(0.0f, 0.0f),
+  mOffsetSizeMode(0.0f, 0.0f, 0.0f, 0.0f),
+  mOrigin(Toolkit::Align::TOP_BEGIN),
+  mAnchorPoint(Toolkit::Align::TOP_BEGIN),
+  mOffsetIndex(Property::INVALID_INDEX),
+  mSizeIndex(Property::INVALID_INDEX)
 {
 }
 
 {
 }
 
@@ -378,8 +380,8 @@ void Internal::Visual::Base::Impl::Transform::GetPropertyMap( Property::Map& map
 
 void Internal::Visual::Base::Impl::Transform::RegisterUniforms( Dali::Renderer renderer, Toolkit::Direction::Type direction )
 {
 
 void Internal::Visual::Base::Impl::Transform::RegisterUniforms( Dali::Renderer renderer, Toolkit::Direction::Type direction )
 {
-  renderer.RegisterProperty( SIZE, mSize );
-  renderer.RegisterProperty( OFFSET, direction == Toolkit::Direction::LEFT_TO_RIGHT ? mOffset : mOffset * Vector2(-1.0f,1.0f));
+  mSizeIndex   = renderer.RegisterProperty(SIZE, mSize);
+  mOffsetIndex = renderer.RegisterProperty(OFFSET, direction == Toolkit::Direction::LEFT_TO_RIGHT ? mOffset : mOffset * Vector2(-1.0f, 1.0f));
   renderer.RegisterProperty( OFFSET_SIZE_MODE, mOffsetSizeMode );
   renderer.RegisterProperty( ORIGIN, PointToVector2( mOrigin, direction ) - Vector2(0.5,0.5) );
   renderer.RegisterProperty( ANCHOR_POINT, Vector2(0.5,0.5) - PointToVector2( mAnchorPoint, direction ) );
   renderer.RegisterProperty( OFFSET_SIZE_MODE, mOffsetSizeMode );
   renderer.RegisterProperty( ORIGIN, PointToVector2( mOrigin, direction ) - Vector2(0.5,0.5) );
   renderer.RegisterProperty( ANCHOR_POINT, Vector2(0.5,0.5) - PointToVector2( mAnchorPoint, direction ) );
index a1056ac..718b5e4 100644 (file)
@@ -116,6 +116,8 @@ struct Base::Impl
     Vector4 mOffsetSizeMode;
     Toolkit::Align::Type mOrigin;
     Toolkit::Align::Type mAnchorPoint;
     Vector4 mOffsetSizeMode;
     Toolkit::Align::Type mOrigin;
     Toolkit::Align::Type mAnchorPoint;
+    Property::Index      mOffsetIndex;
+    Property::Index      mSizeIndex;
   };
 
   Renderer        mRenderer;
   };
 
   Renderer        mRenderer;
index 6e04f0a..e8e984f 100755 (executable)
@@ -345,6 +345,14 @@ void Visual::Base::SetOffScene( Actor& actor )
       // Update values from Renderer
       mImpl->mMixColor   = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
       mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
       // Update values from Renderer
       mImpl->mMixColor   = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
       mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
+      if(mImpl->mTransform.mOffsetIndex != Property::INVALID_INDEX)
+      {
+        mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mOffsetIndex);
+      }
+      if(mImpl->mTransform.mSizeIndex != Property::INVALID_INDEX)
+      {
+        mImpl->mTransform.mSize = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mSizeIndex);
+      }
       if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
       {
         mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
       if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
       {
         mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
@@ -365,6 +373,14 @@ void Visual::Base::CreatePropertyMap( Property::Map& map ) const
     // Update values from Renderer
     mImpl->mMixColor   = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
     mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
     // Update values from Renderer
     mImpl->mMixColor   = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
     mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
+    if(mImpl->mTransform.mOffsetIndex != Property::INVALID_INDEX)
+    {
+      mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mOffsetIndex);
+    }
+    if(mImpl->mTransform.mSizeIndex != Property::INVALID_INDEX)
+    {
+      mImpl->mTransform.mSize = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mSizeIndex);
+    }
     if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
     {
       mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
     if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
     {
       mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
@@ -777,6 +793,14 @@ Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
     {
       return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
     }
     {
       return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
     }
+    else if(key.indexKey == Toolkit::Visual::Transform::Property::OFFSET)
+    {
+      return Dali::Property(mImpl->mRenderer, OFFSET);
+    }
+    else if(key.indexKey == Toolkit::Visual::Transform::Property::SIZE)
+    {
+      return Dali::Property(mImpl->mRenderer, SIZE);
+    }
   }
   else
   {
   }
   else
   {
@@ -788,6 +812,14 @@ Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
     {
       return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
     }
     {
       return Dali::Property(mImpl->mRenderer, DevelRenderer::Property::OPACITY);
     }
+    else if(key.stringKey == OFFSET)
+    {
+      return Dali::Property(mImpl->mRenderer, OFFSET);
+    }
+    else if(key.stringKey == SIZE)
+    {
+      return Dali::Property(mImpl->mRenderer, SIZE);
+    }
   }
 
   // Other cases
   }
 
   // Other cases
@@ -799,8 +831,10 @@ Dali::Property Visual::Base::GetPropertyObject(Dali::Property::Key key)
       // Register CORNER_RADIUS property
       mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
       mImpl->mRenderer.RegisterProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
       // Register CORNER_RADIUS property
       mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
       mImpl->mRenderer.RegisterProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
-      index = mImpl->mCornerRadiusIndex;
 
 
+      mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+
+      index = mImpl->mCornerRadiusIndex;
       mImpl->mNeedCornerRadius = true;
 
       // Change shader
       mImpl->mNeedCornerRadius = true;
 
       // Change shader
index bea661d..6f19efc 100644 (file)
@@ -163,7 +163,7 @@ enum Type
 {
   /**
    * @brief Offset of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
 {
   /**
    * @brief Offset of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
-   * @details Name "offset", type Property::VECTOR2.
+   * @details Name "offset", type Property::VECTOR2, animatable.
    * @SINCE_1_2.60
    *
    * @see OFFSET_POLICY
    * @SINCE_1_2.60
    *
    * @see OFFSET_POLICY
@@ -172,7 +172,7 @@ enum Type
 
   /**
    * @brief Size of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
 
   /**
    * @brief Size of the visual, which can be either relative (percentage [0.0f to 1.0f] of the parent) or absolute (in world units).
-   * @details Name "size", type Property::VECTOR2.
+   * @details Name "size", type Property::VECTOR2, animatable.
    * @see SIZE_POLICY
    */
   SIZE,
    * @see SIZE_POLICY
    */
   SIZE,