[dali_1.3.42] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / layout-size.h
1 #ifndef DALI_TOOLKIT_DEVEL_LAYOUT_SIZE_H
2 #define DALI_TOOLKIT_DEVEL_LAYOUT_SIZE_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-toolkit/devel-api/layouting/layout-length.h>
21
22 namespace Dali
23 {
24 namespace Toolkit
25 {
26
27 /**
28  * This class represents a layout size (width and height)
29  */
30 class LayoutSize
31 {
32 public:
33   LayoutSize()
34   : x(0u),
35     y(0u)
36   {
37   }
38
39   LayoutSize( LayoutLength::IntType anX, LayoutLength::IntType aY )
40   : x( anX ),
41     y( aY )
42   {
43   }
44
45   LayoutSize( LayoutLength anX, LayoutLength aY )
46   : x( anX.mValue ),
47     y( aY.mValue )
48   {
49   }
50
51   LayoutSize( const LayoutSize& layoutSize )
52   : x( layoutSize.x ),
53     y( layoutSize.y )
54   {
55   }
56
57   LayoutSize& operator=(const LayoutSize& rhs)
58   {
59     x = rhs.x;
60     y = rhs.y;
61     return *this;
62   }
63
64   LayoutLength::IntType GetWidth()
65   {
66     return width;
67   }
68
69   LayoutLength::IntType GetHeight()
70   {
71     return height;
72   }
73
74   void SetWidth(LayoutLength::IntType value)
75   {
76     width=value;
77   }
78   void SetHeight(LayoutLength::IntType value)
79   {
80     height=value;
81   }
82   void SetWidth(LayoutLength value)
83   {
84     width=value.mValue;
85   }
86   void SetHeight(LayoutLength value)
87   {
88     height=value.mValue;
89   }
90
91   bool operator==( const LayoutSize& rhs )
92   {
93     return x==rhs.x && y==rhs.y;
94   }
95
96   bool operator!=( const LayoutSize& rhs )
97   {
98     return !( *this==rhs );
99   }
100
101   union
102   {
103     LayoutLength::IntType x;
104     LayoutLength::IntType width;
105   };
106
107   union
108   {
109     LayoutLength::IntType y;
110     LayoutLength::IntType height;
111   };
112 };
113
114 /**
115  * @brief Prints a LayoutSize
116  *
117  * @param[in] o The output stream operator
118  * @param[in] layoutSize the layout size to print
119  * @return The output stream operator
120  */
121 inline std::ostream& operator<< (std::ostream& o, const LayoutSize& layoutSize)
122 {
123   return o << "[" << layoutSize.x << ", " << layoutSize.y << "]";
124 }
125
126 } // namespace Toolkit
127
128 } // namespace Dali
129
130 #endif //DALI_TOOLKIT_DEVEL_LAYOUT_SIZE_H