1 #ifndef DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H
2 #define DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H
5 * Copyright (c) 2022 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/common/vector-wrapper.h>
28 #include <dali/public-api/object/base-object.h>
29 #include <dali/public-api/signals/connection-tracker.h>
37 using TransitionSetPtr = IntrusivePtr<TransitionSet>;
39 class TransitionSet : public BaseObject, public ConnectionTracker, public Integration::Processor
43 * Create a new TransitionSet object.
44 * @return A smart-pointer to the newly allocated TransitionSet.
46 static TransitionSetPtr New();
49 * @copydoc Dali::Toolkit::TransitionSet::AddTransition(TransitionPtr transition)
51 void AddTransition(TransitionBasePtr transition);
54 * @copydoc Dali::Toolkit::TransitionSet::GetTransitionAt(uint32_t index)
56 TransitionBase* GetTransitionAt(uint32_t index) const;
59 * @copydoc Dali::Toolkit::TransitionSet::GetTransitionCount()
61 uint32_t GetTransitionCount() const;
64 * @brief Make ready this transition set to play.
65 * Transitions in this transition set will be create property animations at the end of this tick of main thread.
70 * @copydoc Dali::Toolkit::TransitionSet::FinishedSignal()
72 Dali::Toolkit::TransitionSet::TransitionSetSignalType& FinishedSignal();
75 * Connects a callback function with the object's signals.
76 * @param[in] object The object providing the signal.
77 * @param[in] tracker Used to disconnect the signal.
78 * @param[in] signalName The signal to connect to.
79 * @param[in] functor A newly allocated FunctorDelegate.
80 * @return True if the signal was connected.
81 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
83 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
87 * @brief Set pre process of each transition.
89 void TransitionPreProcess();
92 * @brief Start to play each of Transition.
93 * This method called at the end of event thread tick, and this method call OnPlay method of TransitionBase internally.
95 void TransitionStart();
98 * @brief Remove each finished TransitionBase from play list.
99 * If all transitions are finished emit Finished signal.
101 void TransitionFinished(Dali::Animation& source);
104 * Emit the Finished signal
106 void EmitFinishedSignal();
108 protected: // Implementation of Processor
110 * @copydoc Dali::Integration::Processor::Process()
112 void Process(bool postProcessor) override;
116 * Construct a new TransitionSet.
121 * A reference counted object may only be deleted by calling Unreference()
123 ~TransitionSet() override;
127 TransitionSet(const TransitionSet&);
130 TransitionSet& operator=(const TransitionSet& rhs);
133 Dali::Toolkit::TransitionSet::TransitionSetSignalType mFinishedSignal{};
134 std::vector<TransitionBasePtr> mTransitions;
135 Dali::Animation mAnimation;
138 } // namespace Internal
140 // Helpers for public-api forwarding methods
142 inline Internal::TransitionSet& GetImplementation(Dali::Toolkit::TransitionSet& transitionSet)
144 DALI_ASSERT_ALWAYS(transitionSet && "TransitionSet handle is empty");
146 BaseObject& handle = transitionSet.GetBaseObject();
148 return static_cast<Internal::TransitionSet&>(handle);
151 inline const Internal::TransitionSet& GetImplementation(const Dali::Toolkit::TransitionSet& transitionSet)
153 DALI_ASSERT_ALWAYS(transitionSet && "TransitionSet handle is empty");
155 const BaseObject& handle = transitionSet.GetBaseObject();
157 return static_cast<const Internal::TransitionSet&>(handle);
160 } // namespace Toolkit
164 #endif // DALI_TOOLKIT_INTERNAL_TRANSITION_SET_H