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