ea009aea0615040aa27270577e2190c6b0837a25
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / layouting / hbox-layout-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_LAYOUT_H
2 #define DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_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/hbox-layout.h>
24
25 namespace Dali
26 {
27 namespace Toolkit
28 {
29 namespace Internal
30 {
31
32 class HboxLayout;
33 using HboxLayoutPtr = IntrusivePtr<HboxLayout>;
34
35 class HboxLayout final : public LayoutGroup
36 {
37 public:
38   static HboxLayoutPtr New();
39
40 public:
41   void SetCellPadding( LayoutSize size );
42   LayoutSize GetCellPadding();
43
44 protected:
45   HboxLayout();
46   virtual ~HboxLayout();
47
48   /**
49    * @copydoc LayoutBase::DoInitialize
50    */
51   virtual void DoInitialize() override;
52
53   /**
54    * @copydoc LayoutBase::DoRegisterChildProperties()
55    */
56   virtual void DoRegisterChildProperties( const std::string& containerType ) override;
57
58   /**
59    * @copydoc LayoutBase::OnChildAdd
60    */
61   virtual void OnChildAdd( LayoutBase& child ) override;
62
63   /**
64    * @copydoc LayoutBase::OnMeasure
65    */
66   virtual void OnMeasure( MeasureSpec widthMeasureSpec, MeasureSpec heightMeasureSpec ) override;
67
68   /**
69    * @copydoc LayoutBase::OnLayout
70    */
71   virtual void OnLayout( bool changed, LayoutLength l, LayoutLength t, LayoutLength r, LayoutLength b ) override;
72
73 private:
74   HboxLayout( const HboxLayout& other ) = delete;
75   HboxLayout& operator=( const HboxLayout& other ) = delete;
76
77   void ForceUniformHeight( int count, MeasureSpec widthMeasureSpec );
78
79 private:
80   LayoutSize mCellPadding;
81   LayoutLength mTotalLength;
82 };
83
84 } // namespace Internal
85
86 inline Internal::HboxLayout& GetImplementation( Dali::Toolkit::HboxLayout& handle )
87 {
88   DALI_ASSERT_ALWAYS( handle && "HboxLayout handle is empty" );
89   BaseObject& object = handle.GetBaseObject();
90   return static_cast<Internal::HboxLayout&>( object );
91 }
92
93 inline const Internal::HboxLayout& GetImplementation( const Dali::Toolkit::HboxLayout& handle )
94 {
95   DALI_ASSERT_ALWAYS( handle && "HboxLayout handle is empty" );
96   const BaseObject& object = handle.GetBaseObject();
97   return static_cast<const Internal::HboxLayout&>( object );
98 }
99
100 } // namespace Toolkit
101 } // namespace Dali
102
103 #endif // DALI_TOOLKIT_INTERNAL_LAYOUTING_HBOX_LAYOUT_H