Merge changes I2df640e0,Ia1188305,I7fae506e,I7967a7cc,Ib0fdcdf4, ... into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / alignment / alignment-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_ALIGNMENT_H
2 #define DALI_TOOLKIT_INTERNAL_ALIGNMENT_H
3
4 /*
5  * Copyright (c) 2019 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
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/devel-api/controls/alignment/alignment.h>
24 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Toolkit
30 {
31
32 class Alignment;
33
34 namespace Internal
35 {
36
37 /**
38  * Alignment is a control to position and resize actors inside other container actors.
39  * @see Dali::Toolkit::Alignment for more details.
40  */
41 class Alignment : public Control
42 {
43 public:
44
45   /**
46    * Create an initialized Alignment.
47    * @param type Type of alignment.
48    * @return A handle to a newly allocated Dali resource.
49    */
50   static Toolkit::Alignment New( Toolkit::Alignment::Type horizontal, Toolkit::Alignment::Type vertical );
51
52   /**
53    * @copydoc Dali::Toolkit::Alignment::SetAlignmentType()
54    */
55   void SetAlignmentType( Toolkit::Alignment::Type type );
56
57   /**
58    * @copydoc Dali::Toolkit::Alignment::GetAlignmentType()
59    */
60   Toolkit::Alignment::Type GetAlignmentType() const;
61
62   /**
63    * @copydoc Dali::Toolkit::Alignment::SetScaling()
64    */
65   void SetScaling( Toolkit::Alignment::Scaling scaling );
66
67   /**
68    * @copydoc Dali::Toolkit::Alignment::GetScaling()
69    */
70   Toolkit::Alignment::Scaling GetScaling() const;
71
72   /**
73    * @copydoc Dali::Toolkit::Alignment::SetPadding()
74    */
75   void SetPadding( const Toolkit::Alignment::Padding& padding );
76
77   /**
78    * @copydoc Dali::Toolkit::Alignment::GetPadding()
79    */
80   const Toolkit::Alignment::Padding& GetPadding() const;
81
82
83 private: // From Control
84
85   /**
86    * @copydoc Control::OnInitialize()
87    */
88   virtual void OnInitialize() override;
89
90   /**
91    * @copydoc Control::OnRelayout()
92    */
93   void OnRelayout( const Vector2& size, RelayoutContainer& container ) override;
94
95 private:
96
97   /**
98    * Constructor.
99    * It initializes Alignment members.
100    */
101   Alignment( Toolkit::Alignment::Type horizontal, Toolkit::Alignment::Type vertical );
102
103   /**
104    * A reference counted object may only be deleted by calling Unreference()
105    */
106   virtual ~Alignment();
107
108 private:
109
110   // Undefined
111   Alignment(const Alignment&);
112   Alignment& operator=(const Alignment&);
113
114 private:
115   Toolkit::Alignment::Type    mHorizontal; ///< Type of alignment.
116   Toolkit::Alignment::Type    mVertical;   ///< Type of alignment.
117   Toolkit::Alignment::Scaling mScaling;    ///< Stores the geometry scaling.
118   Toolkit::Alignment::Padding mPadding;    ///< Stores the padding values.
119 };
120
121 } // namespace Internal
122
123
124 // Helpers for public-api forwarding methods
125
126 inline Toolkit::Internal::Alignment& GetImpl( Toolkit::Alignment& alignment )
127 {
128   DALI_ASSERT_ALWAYS( alignment );
129
130   Dali::RefObject& handle = alignment.GetImplementation();
131
132   return static_cast<Toolkit::Internal::Alignment&>( handle );
133 }
134
135 inline const Toolkit::Internal::Alignment& GetImpl( const Toolkit::Alignment& alignment )
136 {
137   DALI_ASSERT_ALWAYS( alignment );
138
139   const Dali::RefObject& handle = alignment.GetImplementation();
140
141   return static_cast<const Toolkit::Internal::Alignment&>( handle );
142 }
143
144 } // namespace Toolkit
145
146 } // namespace Dali
147
148 #endif // DALI_TOOLKIT_INTERNAL_ALIGNMENT_H