1 #ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_LINEAR_LAYOUT_H
2 #define DALI_TOOLKIT_INTERNAL_LAYOUTING_LINEAR_LAYOUT_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/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/linear-layout.h>
33 using LinearLayoutPtr = IntrusivePtr<LinearLayout>;
35 class LinearLayout final : public LayoutGroup
39 * Creates a pointer to a LinearLayout implementation.
41 static LinearLayoutPtr New();
45 * @brief Set the padding between cells in the layout
47 * @param[in] size The padding between cells.
49 void SetCellPadding( LayoutSize size );
52 * @brief Get the padding between cells in the layout
54 * @return The padding between cells.
56 LayoutSize GetCellPadding() const;
59 * @brief Set the orientation in the layout
61 * @param[in] orientation The orientation.
63 void SetOrientation( Dali::Toolkit::LinearLayout::Orientation orientation );
66 * @brief Get the orientation in the layout
68 * @return The orientation.
70 Dali::Toolkit::LinearLayout::Orientation GetOrientation() const;
73 * @brief Set the alignment in the layout
75 * @param[in] alignment The alignment.
77 void SetAlignment( unsigned int alignment );
80 * @brief Get the alignment in the layout
82 * @return The alignment.
84 unsigned int GetAlignment() const;
95 virtual ~LinearLayout();
98 * @copydoc LayoutItem::DoRegisterChildProperties()
100 virtual void DoRegisterChildProperties( const std::string& containerType ) override;
103 * @copydoc LayoutItem::OnChildAdd
105 virtual void OnChildAdd( LayoutItem& child ) override;
108 * @copydoc LayoutItem::OnMeasure
110 virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) override;
113 * @copydoc LayoutItem::OnLayout
115 virtual void OnLayout( bool changed, LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) override;
118 LinearLayout( const LinearLayout& other ) = delete;
119 LinearLayout& operator=( const LinearLayout& other ) = delete;
122 * Measure children for horizontal orientation
124 void MeasureHorizontal( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec );
127 * Apply a uniform height to the children
129 void ForceUniformHeight( int count, MeasureSpec widthMeasureSpec );
132 * Layout the children horizontally
134 void LayoutHorizontal( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b );
137 * Measure children for horizontal orientation
139 void MeasureVertical( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec );
142 * Apply a uniform width to the children
144 void ForceUniformWidth( int count, MeasureSpec heightMeasureSpec );
147 * Layout the children vertically
149 void LayoutVertical( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b );
152 LayoutSize mCellPadding;
153 Dali::Toolkit::LinearLayout::Orientation mOrientation;
154 unsigned int mAlignment;
155 LayoutLength mTotalLength;
158 } // namespace Internal
160 inline Internal::LinearLayout& GetImplementation( Dali::Toolkit::LinearLayout& handle )
162 DALI_ASSERT_ALWAYS( handle && "LinearLayout handle is empty" );
163 BaseObject& object = handle.GetBaseObject();
164 return static_cast<Internal::LinearLayout&>( object );
167 inline const Internal::LinearLayout& GetImplementation( const Dali::Toolkit::LinearLayout& handle )
169 DALI_ASSERT_ALWAYS( handle && "LinearLayout handle is empty" );
170 const BaseObject& object = handle.GetBaseObject();
171 return static_cast<const Internal::LinearLayout&>( object );
174 } // namespace Toolkit
177 #endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_LINEAR_LAYOUT_H