1 #ifndef DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H
2 #define DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H
5 * Copyright (c) 2018 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.
20 #include <dali/public-api/object/base-object.h>
21 #include <dali/integration-api/core.h>
22 #include <dali-toolkit/public-api/controls/control.h>
23 #include <dali-toolkit/devel-api/layouting/layout-controller.h>
24 #include <dali-toolkit/devel-api/layouting/layout-item-impl.h>
25 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
26 #include <dali-toolkit/internal/layouting/layout-transition-data-impl.h>
36 * @brief Layout controller handles measurement and layout of all
37 * controls that utilize Layouts.
39 class LayoutController : public Dali::BaseObject, public Integration::Processor
53 * Second stage initialization
58 * This marks the given layout and all its parents as dirty and triggers a transition if set.
60 void RequestLayout( LayoutItem& layout, int layoutTransitionType, Actor gainedChild, Actor lostChild );
63 * Measures next level of layouts in the actor hierarchy.
65 void MeasureHierarchy( Actor root, MeasureSpec widthSpec, MeasureSpec heightSpec );
68 * Perform layout of the hierarchy
70 void PerformLayout( Actor root, int left, int top, int right, int bottom );
73 * Perform positioning of actors after layout update
75 void PerformLayoutPositioning( LayoutPositionDataArray& layoutPositionDataArray, bool all ) const;
78 * Perform animation of actors properties after layout update
80 void PerformLayoutAnimation( LayoutTransition& layoutTransition, LayoutPositionDataArray& layoutPositionDataArray, LayoutDataArray& layoutDataArray, LayoutAnimatorArray& layoutAnimatorArray );
83 * Focus change callback.
85 void KeyInputFocusChangedCallback( Control gainingActor, Control lostActor );
87 protected: // Implementation of Processor
90 * @copydoc Dali::Integration::Processor::Process()
92 virtual void Process();
97 ActorSizeSpec(Actor actor)
99 , widthSpec( actor.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::WIDTH_SPECIFICATION ) )
100 , heightSpec( actor.GetProperty<int>( Toolkit::LayoutItem::ChildProperty::HEIGHT_SPECIFICATION ) )
104 WeakHandle<Actor> actor;
108 std::vector<ActorSizeSpec> mActorSizeSpecs;
110 void UpdateMeasureHierarchyForAnimation( LayoutData& layoutData );
112 void UpdateMeasureHierarchyForAnimation( Actor root, LayoutData& layoutData );
114 void RestoreActorsSpecs();
116 std::list< LayoutTransition > mLayoutTransitions;
117 struct AnimationFinishedFunctor
119 AnimationFinishedFunctor( LayoutController& layoutController, LayoutTransition& layoutTransition, LayoutPositionDataArray& array )
120 : layoutController( layoutController ),
121 layoutDataPositionArray(),
122 layoutItem( layoutTransition.layoutItem ),
123 layoutTransitionType( layoutTransition.layoutTransitionType )
125 layoutDataPositionArray.swap( array );
128 void operator()( Animation& animation )
130 layoutController.PerformLayoutPositioning( layoutDataPositionArray, true );
131 layoutController.mAnimationFinishedFunctors.pop_front();
132 if( layoutTransitionType != -1 )
134 LayoutTransitionDataPtr layoutTransitionDataPtr = layoutItem->GetTransitionData( layoutTransitionType );
135 layoutTransitionDataPtr->EmitSignalFinish( layoutTransitionType );
139 LayoutController& layoutController;
140 LayoutPositionDataArray layoutDataPositionArray;
141 LayoutItemPtr layoutItem;
142 int layoutTransitionType;
145 bool mLayoutRequested;
146 Animation mAnimation;
147 std::list< AnimationFinishedFunctor > mAnimationFinishedFunctors;
149 struct FocusChangedFunctor
151 FocusChangedFunctor( LayoutController& layoutController )
152 : layoutController( layoutController )
156 void operator() ( Dali::Toolkit::Control gainingControl, Dali::Toolkit::Control lostActor );
157 LayoutController& layoutController;
159 FocusChangedFunctor mFocusChangedFunctor;
161 SlotDelegate<LayoutController> mSlotDelegate;
164 } // namespace Internal
166 inline Internal::LayoutController& GetImpl( Dali::Toolkit::LayoutController& handle )
168 DALI_ASSERT_ALWAYS(handle);
169 Dali::BaseObject& object = handle.GetBaseObject();
170 return static_cast<Internal::LayoutController&>(object);
173 inline const Internal::LayoutController& GetImpl( const Dali::Toolkit::LayoutController& handle )
175 DALI_ASSERT_ALWAYS(handle);
176 const Dali::BaseObject& object = handle.GetBaseObject();
177 return static_cast<const Internal::LayoutController&>(object);
180 } // namespace Toolkit
183 #endif // DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H