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::OnMeasure
100 virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) override;
103 * @copydoc LayoutItem::OnLayout
105 virtual void OnLayout( bool changed, LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) override;
108 LinearLayout( const LinearLayout& other ) = delete;
109 LinearLayout& operator=( const LinearLayout& other ) = delete;
112 * Measure children for horizontal orientation
114 void MeasureHorizontal( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec );
117 * Apply a uniform height to the children
119 void ForceUniformHeight( int count, MeasureSpec widthMeasureSpec );
122 * Layout the children horizontally
124 void LayoutHorizontal( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b );
127 * Measure children for horizontal orientation
129 void MeasureVertical( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec );
132 * Apply a uniform width to the children
134 void ForceUniformWidth( int count, MeasureSpec heightMeasureSpec );
137 * Layout the children vertically
139 void LayoutVertical( LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b );
142 LayoutSize mCellPadding;
143 Dali::Toolkit::LinearLayout::Orientation mOrientation;
144 unsigned int mAlignment;
145 LayoutLength mTotalLength;
148 } // namespace Internal
150 inline Internal::LinearLayout& GetImplementation( Dali::Toolkit::LinearLayout& handle )
152 DALI_ASSERT_ALWAYS( handle && "LinearLayout handle is empty" );
153 BaseObject& object = handle.GetBaseObject();
154 return static_cast<Internal::LinearLayout&>( object );
157 inline const Internal::LinearLayout& GetImplementation( const Dali::Toolkit::LinearLayout& handle )
159 DALI_ASSERT_ALWAYS( handle && "LinearLayout handle is empty" );
160 const BaseObject& object = handle.GetBaseObject();
161 return static_cast<const Internal::LinearLayout&>( object );
164 } // namespace Toolkit
167 #endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_LINEAR_LAYOUT_H