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 void ScrollBase::SetParent(ScrollBase *parent)
48 void ScrollBase::BindActor(Actor child)
50 FindAndUnbindActor(child);
52 ActorInfoPtr actorInfo(new ActorInfo(child));
53 mBoundActors.push_back(actorInfo);
55 // Apply all our constraints to this new child.
56 ConstraintStack::iterator i;
58 for(i = mConstraintStack.begin();i!=mConstraintStack.end();i++)
60 actorInfo->ApplyConstraint(*i);
64 void ScrollBase::UnbindActor(Actor child)
66 // Find the child in mBoundActors, and unparent it
67 for (ActorInfoIter iter = mBoundActors.begin(); iter != mBoundActors.end(); ++iter)
69 ActorInfoPtr actorInfo = *iter;
71 if( actorInfo->mActor == child )
73 mBoundActors.erase(iter);
79 void ScrollBase::FindAndUnbindActor(Actor child)
81 // Since we don't know if and where child may have been bound
82 // (as we cannot store such information inside the Actor), we
83 // perform a search on all associated ScrollBases
84 // This is done by recursively calling the parent of this ScrollBase
85 // until reaching the top (at which point implementation may be
86 // different as this is virtual)
88 if(mParent) // continuously ascend until reaches root ScrollBase.
90 mParent->FindAndUnbindActor(child);
94 void ScrollBase::ApplyConstraintToBoundActors(Constraint constraint)
96 mConstraintStack.push_back(constraint);
98 for(ActorInfoIter i = mBoundActors.begin();i != mBoundActors.end(); ++i)
100 (*i)->ApplyConstraint(constraint);
104 void ScrollBase::RemoveConstraintsFromBoundActors()
106 mConstraintStack.clear();
108 for(ActorInfoIter i = mBoundActors.begin();i != mBoundActors.end(); ++i)
110 (*i)->RemoveConstraints();
114 } // namespace Internal
116 } // namespace Toolkit