[Tizen] Initialize MeasureSize memeber variable
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / layouting / measured-size.h
1 #ifndef DALI_TOOLKIT_LAYOUTING_MEASURED_SIZE_H
2 #define DALI_TOOLKIT_LAYOUTING_MEASURED_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/public-api/common/dali-common.h>
21 #include <dali-toolkit/devel-api/layouting/layout-length.h>
22 #include <dali-toolkit/public-api/dali-toolkit-common.h>
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28
29 /**
30  * Class that encodes a measurement and a measure state, which is set if the measured size is too small.
31  */
32 class DALI_TOOLKIT_API MeasuredSize
33 {
34 public:
35
36   enum State
37   {
38     MEASURED_SIZE_OK, ///< The measured size is good
39     MEASURED_SIZE_TOO_SMALL ///< The measured size is too small
40   };
41
42   MeasuredSize()
43   : mMeasuredSize( 0u ),
44     mState ( MeasuredSize::State::MEASURED_SIZE_OK )
45   {
46   }
47
48   MeasuredSize( LayoutLength measuredSize )
49   : mMeasuredSize( measuredSize ),
50     mState ( MeasuredSize::State::MEASURED_SIZE_OK )
51   {
52   }
53
54   MeasuredSize( LayoutLength measuredSize, MeasuredSize::State state )
55   : mMeasuredSize( measuredSize ),
56     mState( state )
57   {
58   }
59
60   ~MeasuredSize() = default;
61
62   MeasuredSize& operator=( const MeasuredSize& rhs )
63   {
64     this->mMeasuredSize = rhs.mMeasuredSize;
65     this->mState = rhs.mState;
66     return *this;
67   }
68
69   MeasuredSize& operator=( LayoutLength::IntType rhs )
70   {
71     this->mMeasuredSize = rhs;
72     this->mState = State::MEASURED_SIZE_OK;
73     return *this;
74   }
75
76   inline bool operator==( MeasuredSize value )
77   {
78     return mMeasuredSize == value.mMeasuredSize;
79   }
80
81   inline bool operator!=( MeasuredSize value )
82   {
83     return mMeasuredSize != value.mMeasuredSize;
84   }
85
86   inline operator LayoutLength::IntType()
87   {
88     return mMeasuredSize.mValue;
89   }
90
91   inline void SetState( MeasuredSize::State state )
92   {
93     mState = state;
94   }
95
96   inline MeasuredSize::State GetState()
97   {
98     return mState;
99   }
100
101   inline void SetSize( LayoutLength size )
102   {
103     mMeasuredSize = size;
104   }
105   inline LayoutLength GetSize()
106   {
107     return mMeasuredSize;
108   }
109
110 private:
111   LayoutLength mMeasuredSize; ///< The measured size
112   State mState; ///< The measured state
113 };
114
115 } //namespace Toolkit
116 } //namespace Dali
117
118
119 #endif // DALI_TOOLKIT_LAYOUTING_MEASURED_SIZE_H