Purge underscored header file barriers
[platform/core/uifw/dali-core.git] / dali / internal / update / gestures / gesture-properties.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_GESTURE_PROPERTIES_H
2 #define DALI_INTERNAL_SCENE_GRAPH_GESTURE_PROPERTIES_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/public-api/object/property-types.h>
23 #include <dali/internal/common/buffer-index.h>
24 #include <dali/internal/event/common/property-input-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace SceneGraph
33 {
34
35 /**
36  * A template for a read only properties used by Gestures.
37  */
38 template < class T >
39 class GestureProperty : public PropertyInputImpl
40 {
41 public:
42
43   /**
44    * Create a read-only gesture property.
45    * @param [in] initialValue The initial value of the property.
46    */
47   GestureProperty( const T& initialValue )
48   : mValue( initialValue ),
49     mInputChanged( false )
50   {
51   }
52
53   /**
54    * Create a read-only gesture property.
55    */
56   GestureProperty()
57   : mValue(),
58     mInputChanged( false )
59   {
60   }
61
62   /**
63    * Virtual destructor.
64    */
65   virtual ~GestureProperty()
66   {
67   }
68
69   /**
70    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
71    */
72   virtual Dali::Property::Type GetType() const
73   {
74     return Dali::PropertyTypes::Get< T >();
75   }
76
77   /**
78    * @copydoc Dali::Internal::SceneGraph::PropertyBase::IsClean()
79    */
80   virtual bool IsClean() const
81   {
82     return !InputChanged();
83   }
84
85   /**
86    * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized()
87    */
88   virtual bool InputInitialized() const
89   {
90     // A constraint cannot use the property until it has been inherited (at least once).
91     return true;
92   }
93
94   /**
95    * @copydoc Dali::Internal::PropertyInputImpl::InputChanged()
96    * @note A constraint can only receive the inherited property from the previous frame.
97    */
98   virtual bool InputChanged() const
99   {
100     return mInputChanged;
101   }
102
103   /**
104    * @brief Resets mInputChanged back to false
105    */
106   void Reset()
107   {
108     mInputChanged = false;
109   }
110
111   /**
112    * Set the property value.
113    * @param[in] value The new property value.
114    */
115   void Set(const T& value)
116   {
117     mValue = value;
118     mInputChanged = true;
119   }
120
121   /**
122    * Get the property value.
123    * @return The property value.
124    */
125   const T& Get() const
126   {
127     return mValue;
128   }
129
130 private:
131
132   // Undefined
133   GestureProperty(const GestureProperty& property);
134
135   // Undefined
136   GestureProperty& operator=(const GestureProperty& rhs);
137
138 protected:
139
140   T mValue;             ///< The property value
141   bool mInputChanged:1; ///< Whether the property has been modified
142 };
143
144 /**
145  * A read only Vector2 property used by Gestures.
146  */
147 class GesturePropertyVector2 : public GestureProperty< Vector2 >
148 {
149 public:
150
151   /**
152    * Virtual destructor.
153    */
154   virtual ~GesturePropertyVector2()
155   {
156   }
157
158   /**
159    * @copydoc Dali::PropertyInput::GetVector2()
160    */
161   virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
162   {
163     return mValue;
164   }
165 };
166
167 /**
168  * A read only bool property used by Gestures.
169  */
170 class GesturePropertyBool : public GestureProperty< bool >
171 {
172 public:
173
174   /**
175    * Virtual destructor.
176    */
177   virtual ~GesturePropertyBool()
178   {
179   }
180
181   /**
182    * @copydoc Dali::PropertyInput::GetBoolean()
183    */
184   virtual const bool& GetBoolean( BufferIndex bufferIndex ) const
185   {
186     return mValue;
187   }
188 };
189
190 } // namespace SceneGraph
191
192 } // namespace Internal
193
194 } // namespace Dali
195
196 #endif // DALI_INTERNAL_SCENE_GRAPH_GESTURE_PROPERTIES_H