Merge "(Vector) Replace std::chrono::system_clock with chrono::steady_clock" into...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / transition / fade-transition-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_FADE_TRANSITION_H
2 #define DALI_TOOLKIT_INTERNAL_FADE_TRANSITION_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/transition/transition-base-impl.h>
23 #include <dali-toolkit/public-api/controls/control.h>
24 #include <dali-toolkit/public-api/transition/fade-transition.h>
25
26 // EXTERNAL INCLUDES
27 #include <dali/public-api/object/weak-handle.h>
28
29 namespace Dali
30 {
31 namespace Toolkit
32 {
33 namespace Internal
34 {
35 using FadeTransitionPtr = IntrusivePtr<FadeTransition>;
36
37 class FadeTransition : public TransitionBase
38 {
39 public:
40   /**
41    * @brief Create a new FadeTransition object.
42    * @param[in] control A control of this transition.
43    * @param[in] opacity opacity value the control Opacity property will be changed from/to.
44    * @param[in] timePeriod The duration of the animation.
45    * @return A smart-pointer to the newly allocated FadeTransition.
46    */
47   static FadeTransitionPtr New(Dali::Toolkit::Control control, float opacity, TimePeriod timePeriod);
48
49 protected:
50   /**
51    * @copydoc Dali::Toolkit::FadeTransition::OnPlay()
52    */
53   void OnPlay() override;
54
55 protected:
56   /**
57    * @brief Construct a new FadeTransition.
58    */
59   FadeTransition(Dali::Toolkit::Control control,
60                  float                  opacity,
61                  TimePeriod             timePeriod);
62
63   /**
64    * @brief A reference counted object may only be deleted by calling Unreference()
65    */
66   ~FadeTransition() override;
67
68 private:
69   // Undefined
70   FadeTransition(const FadeTransition&);
71
72   // Undefined
73   FadeTransition& operator=(const FadeTransition& rhs);
74
75 private:
76   WeakHandle<Dali::Toolkit::Control> mTargetControl;
77   float                              mOpacity;
78 };
79
80 } // namespace Internal
81
82 // Helpers for public-api forwarding methods
83
84 inline Internal::FadeTransition& GetImplementation(Dali::Toolkit::FadeTransition& fade)
85 {
86   DALI_ASSERT_ALWAYS(fade && "FadeTransition handle is empty");
87
88   BaseObject& handle = fade.GetBaseObject();
89
90   return static_cast<Internal::FadeTransition&>(handle);
91 }
92
93 inline const Internal::FadeTransition& GetImplementation(const Dali::Toolkit::FadeTransition& fade)
94 {
95   DALI_ASSERT_ALWAYS(fade && "FadeTransition handle is empty");
96
97   const BaseObject& handle = fade.GetBaseObject();
98
99   return static_cast<const Internal::FadeTransition&>(handle);
100 }
101
102 } // namespace Toolkit
103
104 } // namespace Dali
105
106 #endif // DALI_TOOLKIT_INTERNAL_FADE_TRANSITION_H