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>
32 ///////////////////////////////////////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////////////////////////////
36 ScrollBase::ScrollBase()
43 ScrollBase::ScrollBase( ControlBehaviour behaviourFlags )
44 : Scrollable( behaviourFlags ),
50 void ScrollBase::SetParent(ScrollBase *parent)
55 void ScrollBase::BindActor(Actor child)
57 FindAndUnbindActor(child);
59 ActorInfoPtr actorInfo(new ActorInfo(child));
60 mBoundActors.push_back(actorInfo);
62 // Apply all our constraints to this new child.
63 ConstraintStack::iterator i;
65 for(i = mConstraintStack.begin();i!=mConstraintStack.end();i++)
67 actorInfo->ApplyConstraint(*i);
71 void ScrollBase::UnbindActor(Actor child)
73 // Find the child in mBoundActors, and unparent it
74 for (ActorInfoIter iter = mBoundActors.begin(); iter != mBoundActors.end(); ++iter)
76 ActorInfoPtr actorInfo = *iter;
78 if( actorInfo->mActor == child )
80 mBoundActors.erase(iter);
86 void ScrollBase::FindAndUnbindActor(Actor child)
88 // Since we don't know if and where child may have been bound
89 // (as we cannot store such information inside the Actor), we
90 // perform a search on all associated ScrollBases
91 // This is done by recursively calling the parent of this ScrollBase
92 // until reaching the top (at which point implementation may be
93 // different as this is virtual)
95 if(mParent) // continuously ascend until reaches root ScrollBase.
97 mParent->FindAndUnbindActor(child);
101 void ScrollBase::ApplyConstraintToBoundActors(Constraint constraint)
103 mConstraintStack.push_back(constraint);
105 for(ActorInfoIter i = mBoundActors.begin();i != mBoundActors.end(); ++i)
107 (*i)->ApplyConstraint(constraint);
111 void ScrollBase::RemoveConstraintsFromBoundActors()
113 mConstraintStack.clear();
115 for(ActorInfoIter i = mBoundActors.begin();i != mBoundActors.end(); ++i)
117 (*i)->RemoveConstraints();
121 } // namespace Internal
123 } // namespace Toolkit