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