Merge "Discard fragments out of corner radius" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 18 Jun 2021 14:33:35 +0000 (14:33 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 18 Jun 2021 14:33:35 +0000 (14:33 +0000)
16 files changed:
automated-tests/src/dali-toolkit/CMakeLists.txt
automated-tests/src/dali-toolkit/utc-Dali-Fade.cpp [new file with mode: 0755]
dali-toolkit/internal/file.list
dali-toolkit/internal/transition/fade-impl.cpp [new file with mode: 0644]
dali-toolkit/internal/transition/fade-impl.h [new file with mode: 0644]
dali-toolkit/internal/transition/transition-base-impl.cpp
dali-toolkit/internal/transition/transition-base-impl.h
dali-toolkit/internal/transition/transition-impl.cpp
dali-toolkit/internal/transition/transition-impl.h
dali-toolkit/public-api/dali-toolkit-version.cpp
dali-toolkit/public-api/file.list
dali-toolkit/public-api/transition/fade.cpp [new file with mode: 0644]
dali-toolkit/public-api/transition/fade.h [new file with mode: 0644]
dali-toolkit/public-api/transition/transition-base.cpp
dali-toolkit/public-api/transition/transition-base.h
packaging/dali-toolkit.spec

index 2b73142..9b2691c 100755 (executable)
@@ -19,6 +19,7 @@ SET(TC_SOURCES
   utc-Dali-ConfirmationPopup.cpp
   utc-Dali-CubeTransitionEffect.cpp
   utc-Dali-EffectsView.cpp
+  utc-Dali-Fade.cpp
   utc-Dali-FlexContainer.cpp
   utc-Dali-FlexNode.cpp
   utc-Dali-GaussianBlurView.cpp
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Fade.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Fade.cpp
new file mode 100755 (executable)
index 0000000..8fc8fba
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2021 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 <iostream>
+#include <stdlib.h>
+#include <dali-toolkit-test-suite-utils.h>
+#include <dali-toolkit/dali-toolkit.h>
+#include <dali/devel-api/actors/actor-devel.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/public-api/transition/transition-set.h>
+#include <dali-toolkit/public-api/transition/transition-base.h>
+#include <dali-toolkit/public-api/transition/fade.h>
+
+using namespace Dali;
+using namespace Dali::Toolkit;
+
+// Functor to test whether a Finish signal is emitted
+struct TransitionFinishCheck
+{
+  TransitionFinishCheck(bool& signalReceived)
+  : mSignalReceived(signalReceived)
+  {
+  }
+
+  void operator()(TransitionSet& transitionSet)
+  {
+    mSignalReceived = true;
+  }
+
+  void Reset()
+  {
+    mSignalReceived = false;
+  }
+
+  void CheckSignalReceived()
+  {
+    if(!mSignalReceived)
+    {
+      tet_printf("Expected Finish signal was not received\n");
+      tet_result(TET_FAIL);
+    }
+    else
+    {
+      tet_result(TET_PASS);
+    }
+  }
+
+  void CheckSignalNotReceived()
+  {
+    if(mSignalReceived)
+    {
+      tet_printf("Unexpected Finish signal was received\n");
+      tet_result(TET_FAIL);
+    }
+    else
+    {
+      tet_result(TET_PASS);
+    }
+  }
+
+  bool& mSignalReceived; // owned by individual tests
+};
+
+int UtcDaliFadeSetGetProperty(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliFadeSetGetProperty");
+
+  Control control = Control::New();
+
+  Fade fade = Fade::New(control, 0.5, TimePeriod(-0.5f, -0.5f));
+
+  TimePeriod timePeriod = fade.GetTimePeriod();
+  DALI_TEST_EQUALS(0.0f, timePeriod.delaySeconds, TEST_LOCATION);
+  DALI_TEST_EQUALS(0.0f, timePeriod.durationSeconds, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliFadeWithOffScene(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliFadeWithOffScene");
+
+  Control control = Control::New();
+  control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  control.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
+  control.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
+  control.SetProperty(Actor::Property::OPACITY, 1.0f);
+  Property::Map controlProperty;
+  controlProperty.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+  controlProperty.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+  control.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty);
+
+  application.SendNotification();
+  application.Render(20);
+
+  DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+
+  Fade fade = Fade::New(control, 0.5, TimePeriod(0.5f));
+  fade.SetAppearingTransition(false); // set fade out
+  TransitionSet transitionSet = TransitionSet::New();
+  transitionSet.AddTransition(fade);
+  transitionSet.Play();
+
+  bool signalReceived(false);
+  TransitionFinishCheck finishCheck(signalReceived);
+  transitionSet.FinishedSignal().Connect(&application, finishCheck);
+
+  application.SendNotification();
+  application.Render(400);
+
+  // We didn't expect the animation to finish yet
+  application.SendNotification();
+  finishCheck.CheckSignalNotReceived();
+
+  DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+  
+  application.SendNotification();
+  application.Render(200);
+
+  // We did expect the animation to finish
+  application.SendNotification();
+  finishCheck.CheckSignalReceived();
+
+  application.SendNotification();
+  application.Render(20);
+
+  DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliFadeOut(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliFadeOut");
+
+  Control control = Control::New();
+  control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  control.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
+  control.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
+  control.SetProperty(Actor::Property::OPACITY, 1.0f);
+  Property::Map controlProperty;
+  controlProperty.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+  controlProperty.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+  control.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty);
+
+  application.GetScene().Add(control);
+
+  application.SendNotification();
+  application.Render(20);
+
+  DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+
+  Fade fade = Fade::New(control, 0.5, TimePeriod(0.5f));
+  fade.SetAppearingTransition(false); // set fade out
+  TransitionSet transitionSet = TransitionSet::New();
+  transitionSet.AddTransition(fade);
+  transitionSet.Play();
+
+  bool signalReceived(false);
+  TransitionFinishCheck finishCheck(signalReceived);
+  transitionSet.FinishedSignal().Connect(&application, finishCheck);
+
+  application.SendNotification();
+  application.Render(400);
+
+  // We didn't expect the animation to finish yet
+  application.SendNotification();
+  finishCheck.CheckSignalNotReceived();
+
+  float currentOpacity = control.GetCurrentProperty<float>(Actor::Property::OPACITY);
+  DALI_TEST_CHECK(currentOpacity <= 0.7 && currentOpacity >= 0.5);
+  
+  application.SendNotification();
+  application.Render(200);
+
+  // We did expect the animation to finish
+  application.SendNotification();
+  finishCheck.CheckSignalReceived();
+
+  application.SendNotification();
+  application.Render(20);
+
+  // Property is reset after animation.
+  DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliFadeIn(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliFadeIn");
+
+  Control control = Control::New();
+  control.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  control.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  control.SetProperty(Actor::Property::POSITION, Vector3(100, 200, 0));
+  control.SetProperty(Actor::Property::SIZE, Vector3(150, 150, 0));
+  control.SetProperty(Actor::Property::OPACITY, 1.0f);
+  Property::Map controlProperty;
+  controlProperty.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::COLOR);
+  controlProperty.Insert(Toolkit::ColorVisual::Property::MIX_COLOR, Vector4(1.0f, 0.0f, 0.0f, 1.0f));
+  control.SetProperty(Toolkit::Control::Property::BACKGROUND, controlProperty);
+
+  application.GetScene().Add(control);
+
+  application.SendNotification();
+  application.Render(20);
+
+  DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+
+  Fade fade = Fade::New(control, 0.5, TimePeriod(0.5f));
+  fade.SetAppearingTransition(true); // set fade in
+  TransitionSet transitionSet = TransitionSet::New();
+  transitionSet.AddTransition(fade);
+  transitionSet.Play();
+
+  bool signalReceived(false);
+  TransitionFinishCheck finishCheck(signalReceived);
+  transitionSet.FinishedSignal().Connect(&application, finishCheck);
+
+  application.SendNotification();
+  application.Render(400);
+
+  // We didn't expect the animation to finish yet
+  application.SendNotification();
+  finishCheck.CheckSignalNotReceived();
+
+  float currentOpacity = control.GetCurrentProperty<float>(Actor::Property::OPACITY);
+  DALI_TEST_CHECK(currentOpacity <= 1.0 && currentOpacity >= 0.8);
+  
+  application.SendNotification();
+  application.Render(200);
+
+  // We did expect the animation to finish
+  application.SendNotification();
+  finishCheck.CheckSignalReceived();
+
+  application.SendNotification();
+  application.Render(20);
+
+  DALI_TEST_EQUALS(1.0f, control.GetCurrentProperty<float>(Actor::Property::OPACITY), TEST_LOCATION);
+
+  END_TEST;
+}
index aabd0c0..30435f8 100644 (file)
@@ -178,6 +178,7 @@ SET( toolkit_src_files
    ${toolkit_src_dir}/text/rendering/text-backend-impl.cpp
    ${toolkit_src_dir}/text/rendering/text-typesetter.cpp
    ${toolkit_src_dir}/text/rendering/view-model.cpp
+   ${toolkit_src_dir}/transition/fade-impl.cpp
    ${toolkit_src_dir}/transition/transition-base-impl.cpp
    ${toolkit_src_dir}/transition/transition-impl.cpp
    ${toolkit_src_dir}/transition/transition-lifecycle-controller.cpp
diff --git a/dali-toolkit/internal/transition/fade-impl.cpp b/dali-toolkit/internal/transition/fade-impl.cpp
new file mode 100644 (file)
index 0000000..30edc3e
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2021 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 <dali-toolkit/internal/transition/fade-impl.h>
+
+// EXTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali/devel-api/actors/actor-devel.h>
+#include <dali/integration-api/debug.h>
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/object/type-registry.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+namespace
+{
+const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION(Dali::AlphaFunction::DEFAULT);
+
+} // anonymous namespace
+
+FadePtr Fade::New(Dali::Toolkit::Control control, float opacity, TimePeriod timePeriod)
+{
+  float delaySeconds = timePeriod.delaySeconds;
+  if(delaySeconds < 0.0f)
+  {
+    DALI_LOG_WARNING("delay should be greater than 0.0f.\n");
+    delaySeconds = 0.0f;
+  }
+
+  float durationSeconds = timePeriod.durationSeconds;
+  if(durationSeconds < 0.0f)
+  {
+    DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
+    durationSeconds = 0.0f;
+  }
+
+  FadePtr fade = new Fade(control, Dali::Clamp(opacity, 0.0f, 1.0f), TimePeriod(delaySeconds, durationSeconds));
+
+  // Second-phase construction
+  fade->Initialize();
+
+  return fade;
+}
+
+Fade::Fade(Dali::Toolkit::Control control, float opacity, TimePeriod timePeriod)
+: TransitionBase(),
+  mTargetControl(control),
+  mOpacity(opacity)
+{
+  SetTarget(control);
+  SetTimePeriod(timePeriod);
+}
+
+Fade::~Fade()
+{
+}
+
+void Fade::OnPlay()
+{
+  Dali::Toolkit::Control targetControl = mTargetControl.GetHandle();
+  if(!targetControl || !targetControl[Dali::Actor::Property::CONNECTED_TO_SCENE])
+  {
+    DALI_LOG_ERROR("The Control is not added on the window\n");
+    return;
+  }
+
+  Property::Map initialPropertyMap;
+  Property::Map startPropertyMap;
+  Property::Map finishPropertyMap;
+
+  if(IsAppearingTransition())
+  {
+    initialPropertyMap.Insert(Dali::Actor::Property::OPACITY, 0.0f);
+    startPropertyMap.Insert(Dali::Actor::Property::OPACITY, mOpacity);
+    finishPropertyMap.Insert(Dali::Actor::Property::OPACITY, targetControl[Dali::Actor::Property::OPACITY]);
+  }
+  else
+  {
+    initialPropertyMap.Insert(Dali::Actor::Property::OPACITY, targetControl[Dali::Actor::Property::OPACITY]);
+    startPropertyMap.Insert(Dali::Actor::Property::OPACITY, targetControl[Dali::Actor::Property::OPACITY]);
+    finishPropertyMap.Insert(Dali::Actor::Property::OPACITY, mOpacity);
+  }
+
+  SetInitialPropertyMap(initialPropertyMap);
+  SetStartPropertyMap(startPropertyMap);
+  SetFinishPropertyMap(finishPropertyMap);
+}
+
+} // namespace Internal
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/internal/transition/fade-impl.h b/dali-toolkit/internal/transition/fade-impl.h
new file mode 100644 (file)
index 0000000..0ac5c73
--- /dev/null
@@ -0,0 +1,106 @@
+#ifndef DALI_TOOLKIT_INTERNAL_FADE_H
+#define DALI_TOOLKIT_INTERNAL_FADE_H
+
+/*
+ * Copyright (c) 2021 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 <dali-toolkit/internal/transition/transition-base-impl.h>
+#include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/transition/fade.h>
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/weak-handle.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal
+{
+using FadePtr = IntrusivePtr<Fade>;
+
+class Fade : public TransitionBase
+{
+public:
+  /**
+   * @brief Create a new Fade object.
+   * @param[in] control A control of this transition.
+   * @param[in] opacity opacity value the control Opacity property will be changed from/to.
+   * @param[in] timePeriod The duration of the animation.
+   * @return A smart-pointer to the newly allocated Fade.
+   */
+  static FadePtr New(Dali::Toolkit::Control control, float opacity, TimePeriod timePeriod);
+
+protected:
+  /**
+   * @copydoc Dali::Toolkit::Fade::OnPlay()
+   */
+  void OnPlay() override;
+
+protected:
+  /**
+   * @brief Construct a new Fade.
+   */
+  Fade(Dali::Toolkit::Control control,
+       float                  opacity,
+       TimePeriod             timePeriod);
+
+  /**
+   * @brief A reference counted object may only be deleted by calling Unreference()
+   */
+  ~Fade() override;
+
+private:
+  // Undefined
+  Fade(const Fade&);
+
+  // Undefined
+  Fade& operator=(const Fade& rhs);
+
+private:
+  WeakHandle<Dali::Toolkit::Control> mTargetControl;
+  float mOpacity;
+};
+
+} // namespace Internal
+
+// Helpers for public-api forwarding methods
+
+inline Internal::Fade& GetImplementation(Dali::Toolkit::Fade& fade)
+{
+  DALI_ASSERT_ALWAYS(fade && "Fade handle is empty");
+
+  BaseObject& handle = fade.GetBaseObject();
+
+  return static_cast<Internal::Fade&>(handle);
+}
+
+inline const Internal::Fade& GetImplementation(const Dali::Toolkit::Fade& fade)
+{
+  DALI_ASSERT_ALWAYS(fade && "Fade handle is empty");
+
+  const BaseObject& handle = fade.GetBaseObject();
+
+  return static_cast<const Internal::Fade&>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_INTERNAL_FADE_H
index 42fb10d..241eb06 100644 (file)
@@ -104,7 +104,8 @@ TransitionBase::TransitionBase()
 : mAlphaFunction(DEFAULT_ALPHA_FUNCTION),
   mTimePeriod(TimePeriod(0.0f)),
   mTransitionWithChild(false),
-  mMoveTargetChildren(false)
+  mMoveTargetChildren(false),
+  mIsAppearingTransition(true)
 {
 }
 
index 84ef316..b3289ec 100644 (file)
@@ -92,6 +92,15 @@ public:
    */
   void TransitionFinished();
 
+  /**
+   * @brief Set this transition is appearing transition or not.
+   * @param[in] appearingTransition True if this transition is appearing transition.
+   */
+  void SetAppearingTransition(bool appearingTransition)
+  {
+    mIsAppearingTransition = appearingTransition;
+  }
+
 protected:
   /**
    * @brief Set property map which will be used as a initial properties.
@@ -151,11 +160,19 @@ protected:
   /**
    * @brief Returns whether this transition will be applied to children of target or not.
    */
-  bool IsTransitionWithChild()
+  bool IsTransitionWithChild() const
   {
     return mTransitionWithChild;
   }
 
+  /**
+   * @brief Returns whether this transition is appearing transition or not
+   */
+  bool IsAppearingTransition() const
+  {
+    return mIsAppearingTransition;
+  }
+
 protected:
   /**
    * Construct a new TransitionBase.
@@ -234,6 +251,7 @@ private:
   bool                         mTransitionWithChild; ///< True, if mTarget transition is inherit to its child Actors.
                                                      ///< If this is false, the child Actors are moved to the child of mCopiedActor that will have original properties of target Actor during Transition.
   bool mMoveTargetChildren;                          ///< Flag, if mTransitionWithChild is false and mTarget has children than True.
+  bool mIsAppearingTransition;                       ///< True, if this transition is appearing transition.
 };
 
 } // namespace Internal
index ef193f6..a465433 100644 (file)
@@ -79,37 +79,39 @@ Transition::~Transition()
 
 void Transition::OnPlay()
 {
-  if(!mSourceControl[Dali::Actor::Property::CONNECTED_TO_SCENE] ||
-     !mDestinationControl[Dali::Actor::Property::CONNECTED_TO_SCENE])
+  Dali::Toolkit::Control sourceControl = mSourceControl.GetHandle();
+  Dali::Toolkit::Control destinationControl = mDestinationControl.GetHandle();
+  if(!sourceControl || !sourceControl[Dali::Actor::Property::CONNECTED_TO_SCENE] ||
+     !destinationControl || !destinationControl[Dali::Actor::Property::CONNECTED_TO_SCENE])
   {
     DALI_LOG_ERROR("The source or destination is not added on the window\n");
     return;
   }
 
   //Make startPropertyMap and finishPropertyMap to use for property animation.
-  Matrix     sourceWorldTransform = mSourceControl[Dali::Actor::Property::WORLD_MATRIX];
+  Matrix     sourceWorldTransform = sourceControl[Dali::Actor::Property::WORLD_MATRIX];
   Vector3    sourcePosition, sourceScale;
   Quaternion sourceOrientation;
   sourceWorldTransform.GetTransformComponents(sourcePosition, sourceOrientation, sourceScale);
 
-  Matrix     destinationWorldTransform = GetWorldTransform(mDestinationControl);
+  Matrix     destinationWorldTransform = GetWorldTransform(destinationControl);
   Vector3    destinationPosition, destinationScale;
   Quaternion destinationOrientation;
   destinationWorldTransform.GetTransformComponents(destinationPosition, destinationOrientation, destinationScale);
 
-  Vector3       targetSize  = mDestinationControl[Dali::Actor::Property::SIZE];
-  Vector4       targetColor = GetWorldColor(mDestinationControl);
+  Vector3       targetSize  = destinationControl[Dali::Actor::Property::SIZE];
+  Vector4       targetColor = GetWorldColor(destinationControl);
   Property::Map startPropertyMap;
   Property::Map finishPropertyMap;
 
   // Use world transform if this transition requires animation of transform.
-  mDestinationControl[Dali::Actor::Property::ANCHOR_POINT]               = AnchorPoint::CENTER;
-  mDestinationControl[Dali::Actor::Property::PARENT_ORIGIN]              = ParentOrigin::CENTER;
-  mDestinationControl[Dali::Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
-  mDestinationControl[Dali::Actor::Property::INHERIT_POSITION]           = false;
-  mDestinationControl[Dali::Actor::Property::INHERIT_ORIENTATION]        = false;
-  mDestinationControl[Dali::Actor::Property::INHERIT_SCALE]              = false;
-  mDestinationControl[Dali::Actor::Property::COLOR_MODE]                 = Dali::ColorMode::USE_OWN_COLOR;
+  destinationControl[Dali::Actor::Property::ANCHOR_POINT]               = AnchorPoint::CENTER;
+  destinationControl[Dali::Actor::Property::PARENT_ORIGIN]              = ParentOrigin::CENTER;
+  destinationControl[Dali::Actor::Property::POSITION_USES_ANCHOR_POINT] = true;
+  destinationControl[Dali::Actor::Property::INHERIT_POSITION]           = false;
+  destinationControl[Dali::Actor::Property::INHERIT_ORIENTATION]        = false;
+  destinationControl[Dali::Actor::Property::INHERIT_SCALE]              = false;
+  destinationControl[Dali::Actor::Property::COLOR_MODE]                 = Dali::ColorMode::USE_OWN_COLOR;
 
   // Set animation of Transform
   startPropertyMap.Insert(Dali::Actor::Property::POSITION, sourcePosition);
@@ -121,12 +123,12 @@ void Transition::OnPlay()
   startPropertyMap.Insert(Dali::Actor::Property::SCALE, sourceScale);
   finishPropertyMap.Insert(Dali::Actor::Property::SCALE, destinationScale);
 
-  Vector4 sourceColor = mSourceControl.GetCurrentProperty<Vector4>(Dali::Actor::Property::WORLD_COLOR);
+  Vector4 sourceColor = sourceControl.GetCurrentProperty<Vector4>(Dali::Actor::Property::WORLD_COLOR);
   startPropertyMap.Insert(Dali::Actor::Property::COLOR, sourceColor);
   finishPropertyMap.Insert(Dali::Actor::Property::COLOR, targetColor);
 
   // Set animation for other properties if source and destination is different.
-  Vector3 sourceSize = mSourceControl.GetCurrentProperty<Vector3>(Dali::Actor::Property::SIZE);
+  Vector3 sourceSize = sourceControl.GetCurrentProperty<Vector3>(Dali::Actor::Property::SIZE);
   if(sourceSize != targetSize)
   {
     startPropertyMap.Insert(Dali::Actor::Property::SIZE, sourceSize);
@@ -139,11 +141,11 @@ void Transition::OnPlay()
   // source View becomes transparent during transition.
   if(IsTransitionWithChild())
   {
-    mSourceControl[Dali::Actor::Property::VISIBLE] = false;
+    sourceControl[Dali::Actor::Property::VISIBLE] = false;
   }
   else
   {
-    GetImplementation(mSourceControl).SetTransparent(true);
+    GetImplementation(sourceControl).SetTransparent(true);
   }
 
   Dali::Animation animation = GetAnimation();
@@ -152,18 +154,24 @@ void Transition::OnPlay()
     DALI_LOG_ERROR("animation is still not initialized\n");
     return;
   }
-  Dali::Toolkit::DevelControl::CreateTransitions(mDestinationControl, animation, mSourceControl, GetAlphaFunction(), GetTimePeriod());
+  Dali::Toolkit::DevelControl::CreateTransitions(destinationControl, animation, sourceControl, GetAlphaFunction(), GetTimePeriod());
 }
 
 void Transition::OnFinished()
 {
+  Dali::Toolkit::Control sourceControl = mSourceControl.GetHandle();
+  if(!sourceControl)
+  {
+    return;
+  }
+
   if(IsTransitionWithChild())
   {
-    mSourceControl[Dali::Actor::Property::VISIBLE] = true;
+    sourceControl[Dali::Actor::Property::VISIBLE] = true;
   }
   else
   {
-    GetImplementation(mSourceControl).SetTransparent(false);
+    GetImplementation(sourceControl).SetTransparent(false);
   }
 }
 
index d9120bf..6aa1374 100644 (file)
@@ -23,6 +23,9 @@
 #include <dali-toolkit/public-api/controls/control.h>
 #include <dali-toolkit/public-api/transition/transition.h>
 
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/weak-handle.h>
+
 namespace Dali
 {
 namespace Toolkit
@@ -38,7 +41,7 @@ public:
    * @brief Create a new Transition object.
    * @param[in] source A source control of this transition.
    * @param[in] destination A destination control of this transition.
-   * @param[in] durationSeconds The duration of the animation.
+   * @param[in] timePeriod The timePeriod of the animation.
    * @return A smart-pointer to the newly allocated Transition.
    */
   static TransitionPtr New(Dali::Toolkit::Control source, Dali::Toolkit::Control destination, TimePeriod timePeriod);
@@ -75,8 +78,8 @@ private:
   Transition& operator=(const Transition& rhs);
 
 private:
-  Dali::Toolkit::Control mSourceControl;
-  Dali::Toolkit::Control mDestinationControl;
+  WeakHandle<Dali::Toolkit::Control> mSourceControl;
+  WeakHandle<Dali::Toolkit::Control> mDestinationControl;
 };
 
 } // namespace Internal
index 89f0ec4..abb7fa8 100644 (file)
@@ -29,7 +29,7 @@ namespace Toolkit
 {
 const unsigned int TOOLKIT_MAJOR_VERSION = 2;
 const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 30;
+const unsigned int TOOLKIT_MICRO_VERSION = 31;
 const char* const  TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 071b602..895bfc7 100644 (file)
@@ -31,6 +31,7 @@ SET( public_api_src_files
   ${public_api_src_dir}/image-loader/async-image-loader.cpp
   ${public_api_src_dir}/image-loader/sync-image-loader.cpp
   ${public_api_src_dir}/styling/style-manager.cpp
+  ${public_api_src_dir}/transition/fade.cpp
   ${public_api_src_dir}/transition/transition-base.cpp
   ${public_api_src_dir}/transition/transition-set.cpp
   ${public_api_src_dir}/transition/transition.cpp
@@ -147,6 +148,7 @@ SET( public_api_visuals_header_files
 )
 
 SET( public_api_transition_header_files
+  ${public_api_src_dir}/transition/fade.h
   ${public_api_src_dir}/transition/transition-base.h
   ${public_api_src_dir}/transition/transition-set.h
   ${public_api_src_dir}/transition/transition.h
diff --git a/dali-toolkit/public-api/transition/fade.cpp b/dali-toolkit/public-api/transition/fade.cpp
new file mode 100644 (file)
index 0000000..b5e54dc
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2021 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 <dali-toolkit/public-api/transition/fade.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/transition/fade-impl.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+Fade::Fade() = default;
+
+Fade::Fade(Internal::Fade* fade)
+: TransitionBase(fade)
+{
+}
+
+Fade Fade::New(Dali::Toolkit::Control control, float opacity, TimePeriod timePeriod)
+{
+  Internal::FadePtr internal = Dali::Toolkit::Internal::Fade::New(control, opacity, timePeriod);
+
+  return Fade(internal.Get());
+}
+
+Fade Fade::DownCast(BaseHandle handle)
+{
+  return Fade(dynamic_cast<Dali::Toolkit::Internal::Fade*>(handle.GetObjectPtr()));
+}
+
+Fade::~Fade() = default;
+
+Fade::Fade(const Fade& handle) = default;
+
+Fade& Fade::operator=(const Fade& rhs) = default;
+
+Fade::Fade(Fade&& rhs) = default;
+
+Fade& Fade::operator=(Fade&& rhs) = default;
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/public-api/transition/fade.h b/dali-toolkit/public-api/transition/fade.h
new file mode 100644 (file)
index 0000000..dbafb7b
--- /dev/null
@@ -0,0 +1,119 @@
+#ifndef DALI_TOOLKIT_FADE_H
+#define DALI_TOOLKIT_FADE_H
+
+/*
+ * Copyright (c) 2021 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 <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/transition/transition-base.h>
+
+namespace Dali
+{
+namespace Toolkit
+{
+namespace Internal DALI_INTERNAL
+{
+class Fade;
+}
+
+/**
+ * @brief Fade provides smoothly appearing/disappearing effects for target Control.
+ */
+class DALI_TOOLKIT_API Fade : public TransitionBase
+{
+public:
+  /**
+   * @brief Creates an uninitialized Fade; this can be initialized with Fade::New().
+   *
+   * Calling member functions with an uninitialized Fade handle is not allowed.
+   */
+  Fade();
+
+  /**
+   * @brief Creates an initialized Fade.
+   *
+   * @param[in] control A control of this transition.
+   * @param[in] opacity opacity value the control Opacity property will be changed from/to. Opacity must be between [0, 1].
+   * @param[in] timePeriod The duration of the animation.
+   * @return A handle to a newly allocated Dali resource
+   */
+  static Fade New(Dali::Toolkit::Control control, float opacity, TimePeriod timePeriod);
+
+  /**
+   * @brief Downcasts a handle to Fade handle.
+   *
+   * If handle points to an Fade object, the downcast produces valid handle.
+   * If not, the returned handle is left uninitialized.
+   *
+   * @param[in] handle Handle to an object
+   * @return Handle to an Fade object or an uninitialized handle
+   */
+  static Fade DownCast(BaseHandle handle);
+
+  /**
+   * @brief Destructor.
+   *
+   * This is non-virtual since derived Handle types must not contain data or virtual methods.
+   */
+  ~Fade();
+
+  /**
+   * @brief This copy constructor is required for (smart) pointer semantics.
+   *
+   * @param[in] handle A reference to the copied handle
+   */
+  Fade(const Fade& handle);
+
+  /**
+   * @brief This assignment operator is required for (smart) pointer semantics.
+   *
+   * @param[in] rhs A reference to the copied handle
+   * @return A reference to this
+   */
+  Fade& operator=(const Fade& rhs);
+
+  /**
+   * @brief Move constructor.
+   *
+   * @param[in] rhs A reference to the moved handle
+   */
+  Fade(Fade&& rhs);
+
+  /**
+   * @brief Move assignment operator.
+   *
+   * @param[in] rhs A reference to the moved handle
+   * @return A reference to this handle
+   */
+  Fade& operator=(Fade&& rhs);
+
+public: // Not intended for use by Application developers
+  /// @cond internal
+  /**
+   * @brief This constructor is used by Fade::New() methods.
+   * @param[in] fade A pointer to a newly allocated Dali resource
+   */
+  explicit DALI_INTERNAL Fade(Internal::Fade* fade);
+  /// @endcond
+};
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_FADE_H
index 5e70e21..6b88c84 100644 (file)
@@ -76,7 +76,12 @@ AlphaFunction TransitionBase::GetAlphaFunction() const
 
 void TransitionBase::TransitionWithChild(bool transitionWithChild)
 {
-  return GetImplementation(*this).TransitionWithChild(transitionWithChild);
+  GetImplementation(*this).TransitionWithChild(transitionWithChild);
+}
+
+void TransitionBase::SetAppearingTransition(bool appearingTransition)
+{
+  GetImplementation(*this).SetAppearingTransition(appearingTransition);
 }
 
 } // namespace Toolkit
index 9a274ac..6deaeff 100644 (file)
@@ -131,10 +131,17 @@ public:
   AlphaFunction GetAlphaFunction() const;
 
   /**
-   * @brief A View could be transition with its child Views or without them.
+   * @brief A Control could be transition with its child Controls or without them.
+   * @param[in] transitionWithChild True if the Control is transitioned with children.
    */
   void TransitionWithChild(bool transitionWithChild);
 
+  /**
+   * @brief Set this transition is appearing transition or not.
+   * @param[in] appearingTransition True if this transition is appearing transition.
+   */
+  void SetAppearingTransition(bool appearingTransition);
+
 public: // Not intended for use by Application developers
   /// @cond internal
   /**
index 7609a2c..7c53805 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    2.0.30
+Version:    2.0.31
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT