1 #ifndef DALI_TOOLKIT_INTERNAL_SCROLL_BASE_H
2 #define DALI_TOOLKIT_INTERNAL_SCROLL_BASE_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 // TODO - Replace list with dali-vector.h
23 #include <dali/public-api/animation/constraint.h>
28 #include <dali-toolkit/internal/controls/scrollable/scrollable-impl.h>
29 #include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
39 typedef IntrusivePtr<Actor> ActorPtr;
40 typedef std::list<Constraint> ConstraintStack;
43 * ScrollBase represents a set of properties (time, position
44 * scale etc.) that constrain a set of actors.
46 class ScrollBase : public Scrollable
49 struct ActorInfo : public Dali::RefObject
52 * ActorInfo constructor
53 * @param[in] actor The actor that this ActorInfo represents.
55 ActorInfo(Actor actor)
61 * ActorInfo destructor
62 * removes scrollview-related constraints only.
70 * Apply a constraint to this actor
71 * The constraint will be applied to the actor,
72 * and the ActorInfo will keep track of this constraint.
73 * @param[in] constraint The constraint to apply to the actor
75 void ApplyConstraint(Constraint constraint)
77 Constraint clone = constraint.Clone(mActor);
79 mConstraints.push_back(clone);
83 * Remove constraints from this actor.
84 * All of the constraints that have been applied to the
85 * actor via this ActorInfo will be removed.
87 void RemoveConstraints()
89 std::vector<Constraint>::iterator it = mConstraints.begin();
90 std::vector<Constraint>::iterator end = mConstraints.end();
91 for(; it != end; ++it)
98 Actor mActor; ///< The Actor that this ActorInfo represents.
99 std::vector<Constraint> mConstraints; ///< A list keeping track of constraints applied to the actor via this delegate.
102 typedef IntrusivePtr<ActorInfo> ActorInfoPtr;
103 typedef std::vector<ActorInfoPtr> ActorInfoContainer;
104 typedef ActorInfoContainer::iterator ActorInfoIter;
105 typedef ActorInfoContainer::const_iterator ActorInfoConstIter;
109 * Sets the delay in seconds.
110 * This delay affects the animation timing for all
113 * @param[in] delay The delay in seconds.
115 void SetDelay(float delay)
121 * Gets the current delay in seconds.
123 * @return The delay in seconds.
125 float GetDelay() const
132 * Sets ScrollBase Parent
134 * @param[in] parent The parent that this ScrollBase belongs to.
136 void SetParent(ScrollBase* parent);
139 * Bind Actor to this scroll view/group.
140 * Once Bound, this scroll view/group will affect the actor (child)
142 * @param[in] child The actor to be bound.
144 void BindActor(Actor child);
147 * Unbind Actor from this scroll view/group
148 * Once Unbound, this scroll view/group will not affect the actor
150 * @note this does not remove the child from the ScrollView container
152 * @param[in] child The actor to be unbound
154 void UnbindActor(Actor child);
157 * Searches associated ScrollBases for the Actor, and attempts to Unbind
158 * systematically this Actor from the ScrollView or Groups attached.
160 * @param[in] child The actor to be unbound.
162 virtual void FindAndUnbindActor(Actor child);
165 * Applies constraint to the bound actors within this ScrollView/Group only.
167 * @param[in] constraint, the constraint to apply to these bound actors and future
170 void ApplyConstraintToBoundActors(Constraint constraint);
173 * Removes all constraints from the bound actors within this ScrollView/Group only.
175 void RemoveConstraintsFromBoundActors();
178 static const char* const SCROLL_DOMAIN_OFFSET_PROPERTY_NAME;
182 * Removed default costructor.
184 ScrollBase() = delete;
187 * @brief Construct a new ScrollBase.
189 * @param[in] behaviourFlags Flags to enable
191 ScrollBase(ControlBehaviour behaviourFlags);
194 ScrollBase* mParent; ///< Pointer to ScrollBase parent, if exists.
197 float mDelay; ///< delay in seconds.
198 ConstraintStack mConstraintStack; ///< The list of constraints to apply to any actors
199 ActorInfoContainer mBoundActors; ///< The list of actors that have been bound to this ScrollBase.
202 } // namespace Internal
204 } // namespace Toolkit
208 #endif // DALI_TOOLKIT_INTERNAL_SCROLL_BASE_H