1 #ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_FLEX_LAYOUT_H
2 #define DALI_TOOLKIT_INTERNAL_LAYOUTING_FLEX_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.
21 #include <dali/public-api/common/intrusive-ptr.h>
22 #include <dali/public-api/object/base-object.h>
25 #include <dali-toolkit/devel-api/layouting/flex-layout.h>
26 #include <dali-toolkit/devel-api/layouting/layout-group-impl.h>
27 #include <dali-toolkit/third-party/yoga/Yoga.h>
37 using FlexLayoutPtr = IntrusivePtr<FlexLayout>;
39 class FlexLayout final : public LayoutGroup
42 static FlexLayoutPtr New();
46 * @copydoc FlexLayout::SetFlexDirection
48 void SetFlexDirection( Dali::Toolkit::FlexLayout::FlexDirection flexDirection );
51 * @copydoc FlexLayout::GetFlexDirection
53 Dali::Toolkit::FlexLayout::FlexDirection GetFlexDirection() const;
56 * @copydoc FlexLayout::SetFlexJustification
58 void SetFlexJustification( Dali::Toolkit::FlexLayout::Justification flexJustification );
61 * @copydoc FlexLayout::GetFlexJustification
63 Dali::Toolkit::FlexLayout::Justification GetFlexJustification() const;
66 * @copydoc FlexLayout::SetFlexWrap
68 void SetFlexWrap( Dali::Toolkit::FlexLayout::WrapType wrap );
71 * @copydoc FlexLayout::GetFlexWrap
73 Dali::Toolkit::FlexLayout::WrapType GetFlexWrap() const;
76 * @copydoc FlexLayout::SetFlexAlignment
78 void SetFlexAlignment( Dali::Toolkit::FlexLayout::Alignment::Type flexAlignment );
80 * @copydoc FlexLayout::GetFlexAlignment
82 Dali::Toolkit::FlexLayout::Alignment::Type GetFlexAlignment() const;
85 * @copydoc FlexLayout::SetFlexItemsAlignment
87 void SetFlexItemsAlignment( Dali::Toolkit::FlexLayout::Alignment::Type flexAlignment );
90 * @copydoc FlexLayout::GetFlexItemsAlignment
92 Dali::Toolkit::FlexLayout::Alignment::Type GetFlexItemsAlignment() const;
103 virtual ~FlexLayout();
106 * @copydoc LayoutItem::DoInitialize
108 virtual void DoInitialize() override;
111 * @copydoc LayoutItem::DoRegisterChildProperties()
113 virtual void DoRegisterChildProperties( const std::string& containerType ) override;
116 * @copydoc LayoutItem::OnChildAdd
118 virtual void OnChildAdd( LayoutItem& child ) override;
121 * @copydoc LayoutItem::OnChildRemove
123 virtual void OnChildRemove( LayoutItem& child ) override;
126 * @copydoc LayoutItem::OnMeasure
128 virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) override;
131 * @copydoc LayoutItem::OnLayout
133 virtual void OnLayout( bool changed, LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) override;
136 FlexLayout( const FlexLayout& other ) = delete;
137 FlexLayout& operator=( const FlexLayout& other ) = delete;
139 static YGSize OnChildMeasure( YGNodeRef node, float width, YGMeasureMode widthMode, float height, YGMeasureMode heightMode );
140 void SetChildrenStyle();
146 } // namespace Internal
148 inline Internal::FlexLayout& GetImplementation( Dali::Toolkit::FlexLayout& handle )
150 DALI_ASSERT_ALWAYS( handle && "FboxLayout handle is empty" );
151 BaseObject& object = handle.GetBaseObject();
152 return static_cast<Internal::FlexLayout&>( object );
155 inline const Internal::FlexLayout& GetImplementation( const Dali::Toolkit::FlexLayout& handle )
157 DALI_ASSERT_ALWAYS( handle && "FboxLayout handle is empty" );
158 const BaseObject& object = handle.GetBaseObject();
159 return static_cast<const Internal::FlexLayout&>( object );
162 } // namespace Toolkit
165 #endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_FLEX_LAYOUT_H