2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-base-impl.h>
29 ///////////////////////////////////////////////////////////////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////////////////////////////////////
33 ScrollBase::ScrollBase(ControlBehaviour behaviourFlags)
34 : Scrollable(behaviourFlags),
40 void ScrollBase::SetParent(ScrollBase* parent)
45 void ScrollBase::BindActor(Actor child)
47 FindAndUnbindActor(child);
49 ActorInfoPtr actorInfo(new ActorInfo(child));
50 mBoundActors.push_back(actorInfo);
52 // Apply all our constraints to this new child.
53 ConstraintStack::iterator i;
55 for(i = mConstraintStack.begin(); i != mConstraintStack.end(); i++)
57 actorInfo->ApplyConstraint(*i);
61 void ScrollBase::UnbindActor(Actor child)
63 // Find the child in mBoundActors, and unparent it
64 for(ActorInfoIter iter = mBoundActors.begin(); iter != mBoundActors.end(); ++iter)
66 ActorInfoPtr actorInfo = *iter;
68 if(actorInfo->mActor == child)
70 mBoundActors.erase(iter);
76 void ScrollBase::FindAndUnbindActor(Actor child)
78 // Since we don't know if and where child may have been bound
79 // (as we cannot store such information inside the Actor), we
80 // perform a search on all associated ScrollBases
81 // This is done by recursively calling the parent of this ScrollBase
82 // until reaching the top (at which point implementation may be
83 // different as this is virtual)
85 if(mParent) // continuously ascend until reaches root ScrollBase.
87 mParent->FindAndUnbindActor(child);
91 void ScrollBase::ApplyConstraintToBoundActors(Constraint constraint)
93 mConstraintStack.push_back(constraint);
95 for(ActorInfoIter i = mBoundActors.begin(); i != mBoundActors.end(); ++i)
97 (*i)->ApplyConstraint(constraint);
101 void ScrollBase::RemoveConstraintsFromBoundActors()
103 mConstraintStack.clear();
105 for(ActorInfoIter i = mBoundActors.begin(); i != mBoundActors.end(); ++i)
107 (*i)->RemoveConstraints();
111 } // namespace Internal
113 } // namespace Toolkit