4a7bdbc79f84d26669dfba1cd819e1f1f396073c
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / layouting / layout-controller-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H
2 #define DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
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-base-impl.h>
25 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Internal
32 {
33
34 /**
35  * @brief Layout controller handles measurement and layout of all
36  * controls that utilize Layouts.
37  */
38 class LayoutController : public Dali::BaseObject, public Integration::Processor
39 {
40 public:
41   /**
42    * Constructor
43    */
44   LayoutController();
45
46   /**
47    * Destructor
48    */
49   ~LayoutController();
50
51   /**
52    * Second stage initialization
53    */
54   void Initialize();
55
56   /**
57    * This marks the given layout and all its parents as dirty.
58    */
59   void RequestLayout( LayoutBase& layout );
60
61   /**
62    * Measures next level of layouts in the actor hierarchy.
63    */
64   void MeasureHierarchy( Actor root, MeasureSpec widthSpec, MeasureSpec heightSpec );
65
66   /**
67    * Perform layout of the hierarchy
68    */
69   void PerformLayout( Actor root, int left, int top, int right, int bottom );
70
71 protected: // Implementation of Processor
72
73   /**
74    * @copydoc Dali::Integration::Processor::Process()
75    */
76   virtual void Process();
77
78 private:
79   bool mLayoutRequested;
80 };
81
82 } // namespace Internal
83
84 inline Internal::LayoutController& GetImpl( Dali::Toolkit::LayoutController& handle )
85 {
86   DALI_ASSERT_ALWAYS(handle);
87   Dali::BaseObject& object = handle.GetBaseObject();
88   return static_cast<Internal::LayoutController&>(object);
89 }
90
91 inline const Internal::LayoutController& GetImpl( const Dali::Toolkit::LayoutController& handle )
92 {
93   DALI_ASSERT_ALWAYS(handle);
94   const Dali::BaseObject& object = handle.GetBaseObject();
95   return static_cast<const Internal::LayoutController&>(object);
96 }
97
98 } // namespace Toolkit
99 } // namespace Dali
100
101 #endif // DALI_TOOLKIT_INTERNAL_LAYOUT_CONTROLLER_H