1 #ifndef DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H
2 #define DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/internal/transition/transition-impl.h>
23 #include <dali-toolkit/public-api/transition/transition-set.h>
26 #include <dali/integration-api/processor-interface.h>
27 #include <dali/public-api/object/base-object.h>
28 #include <dali/public-api/signals/connection-tracker.h>
36 using TransitionSetPtr = IntrusivePtr<TransitionSet>;
38 class TransitionSet : public BaseObject, public ConnectionTracker, public Integration::Processor
42 * Create a new TransitionSet object.
43 * @return A smart-pointer to the newly allocated TransitionSet.
45 static TransitionSetPtr New();
48 * @copydoc Dali::Toolkit::TransitionSet::AddTransition(TransitionPtr transition)
50 void AddTransition(TransitionBasePtr transition);
53 * @copydoc Dali::Toolkit::TransitionSet::GetTransitionAt(uint32_t index)
55 TransitionBase* GetTransitionAt(uint32_t index) const;
58 * @copydoc Dali::Toolkit::TransitionSet::GetTransitionCount()
60 uint32_t GetTransitionCount() const;
63 * @brief Make ready this transition set to play.
64 * Transitions in this transition set will be create property animations at the end of this tick of main thread.
69 * @copydoc Dali::Toolkit::TransitionSet::FinishedSignal()
71 Dali::Toolkit::TransitionSet::TransitionSetSignalType& FinishedSignal();
74 * Connects a callback function with the object's signals.
75 * @param[in] object The object providing the signal.
76 * @param[in] tracker Used to disconnect the signal.
77 * @param[in] signalName The signal to connect to.
78 * @param[in] functor A newly allocated FunctorDelegate.
79 * @return True if the signal was connected.
80 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
82 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
86 * @brief Set pre process of each transition.
88 void TransitionPreProcess();
91 * @brief Start to play each of Transition.
92 * This method called at the end of event thread tick, and this method call OnPlay method of TransitionBase internally.
94 void TransitionStart();
97 * @brief Remove each finished TransitionBase from play list.
98 * If all transitions are finished emit Finished signal.
100 void TransitionFinished(Dali::Animation& source);
103 * Emit the Finished signal
105 void EmitFinishedSignal();
107 protected: // Implementation of Processor
109 * @copydoc Dali::Integration::Processor::Process()
111 void Process(bool postProcessor) override;
115 * Construct a new TransitionSet.
120 * A reference counted object may only be deleted by calling Unreference()
122 ~TransitionSet() override;
126 TransitionSet(const TransitionSet&);
129 TransitionSet& operator=(const TransitionSet& rhs);
132 Dali::Toolkit::TransitionSet::TransitionSetSignalType mFinishedSignal{};
133 std::vector<TransitionBasePtr> mTransitions;
134 Dali::Animation mAnimation;
137 } // namespace Internal
139 // Helpers for public-api forwarding methods
141 inline Internal::TransitionSet& GetImplementation(Dali::Toolkit::TransitionSet& transitionSet)
143 DALI_ASSERT_ALWAYS(transitionSet && "TransitionSet handle is empty");
145 BaseObject& handle = transitionSet.GetBaseObject();
147 return static_cast<Internal::TransitionSet&>(handle);
150 inline const Internal::TransitionSet& GetImplementation(const Dali::Toolkit::TransitionSet& transitionSet)
152 DALI_ASSERT_ALWAYS(transitionSet && "TransitionSet handle is empty");
154 const BaseObject& handle = transitionSet.GetBaseObject();
156 return static_cast<const Internal::TransitionSet&>(handle);
159 } // namespace Toolkit
163 #endif // DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H