e64bb164b1291aa35b35ebc2d4f043993f8fc502
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / layouting / vbox-layout-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_VBOX_LAYOUT_H
2 #define DALI_TOOLKIT_INTERNAL_LAYOUTING_VBOX_LAYOUT_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/common/intrusive-ptr.h>
21 #include <dali/public-api/object/base-object.h>
22 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
23 #include <dali-toolkit/devel-api/layouting/vbox-layout.h>
24
25 namespace Dali
26 {
27 namespace Toolkit
28 {
29 namespace Internal
30 {
31
32 class VboxLayout;
33 using VboxLayoutPtr = IntrusivePtr<VboxLayout>;
34
35 class VboxLayout final : public LayoutGroup
36 {
37 public:
38   static VboxLayoutPtr New();
39
40 public:
41
42   /**
43    * Set the inter-cell padding
44    * @param[in] size The size of the inter-cell padding
45    */
46   void SetCellPadding( LayoutSize size );
47
48   /**
49    * Get the inter-cell padding
50    * @return The size of the inter-cell padding
51    */
52   LayoutSize GetCellPadding();
53
54 protected:
55   /**
56    * Constructor
57    */
58   VboxLayout();
59
60   /**
61    * Virtual destructor
62    */
63   virtual ~VboxLayout();
64
65   /**
66    * @copydoc LayoutBase::DoInitialize
67    */
68   virtual void DoInitialize() override;
69
70   /**
71    * @copydoc LayoutBase::DoRegisterChildProperties()
72    */
73   virtual void DoRegisterChildProperties( const std::string& containerType ) override;
74
75   /**
76    * @copydoc LayoutBase::OnChildAdd
77    */
78   virtual void OnChildAdd( LayoutBase& child ) override;
79
80   /**
81    * @copydoc LayoutBase::OnMeasure
82    */
83   virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) override;
84
85   /**
86    * @copydoc LayoutBase::OnLayout
87    */
88   virtual void OnLayout( bool changed, LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) override;
89
90 private:
91   VboxLayout( const VboxLayout& other ) = delete;
92   VboxLayout& operator=( const VboxLayout& other ) = delete;
93
94   /**
95    * Apply a uniform width to the children
96    */
97   void ForceUniformWidth( int count, MeasureSpec heightMeasureSpec );
98
99 private:
100   LayoutSize mCellPadding;
101   LayoutLength mTotalLength;
102 };
103
104 } // namespace Internal
105
106 inline Internal::VboxLayout& GetImplementation( Dali::Toolkit::VboxLayout& handle )
107 {
108   DALI_ASSERT_ALWAYS( handle && "VboxLayout handle is empty" );
109   BaseObject& object = handle.GetBaseObject();
110   return static_cast<Internal::VboxLayout&>( object );
111 }
112
113 inline const Internal::VboxLayout& GetImplementation( const Dali::Toolkit::VboxLayout& handle )
114 {
115   DALI_ASSERT_ALWAYS( handle && "VboxLayout handle is empty" );
116   const BaseObject& object = handle.GetBaseObject();
117   return static_cast<const Internal::VboxLayout&>( object );
118 }
119
120 } // namespace Toolkit
121 } // namespace Dali
122
123 #endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_VBOX_LAYOUT_H