[SRUK] Initial copy from Tizen 2.2 version
[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    * Set the property value.
104    * @param[in] value The new property value.
105    */
106   void Set(const T& value)
107   {
108     mValue = value;
109     mInputChanged = true;
110   }
111
112   /**
113    * Get the property value.
114    * @return The property value.
115    */
116   const T& Get() const
117   {
118     return mValue;
119   }
120
121 private:
122
123   // Undefined
124   GestureProperty(const GestureProperty& property);
125
126   // Undefined
127   GestureProperty& operator=(const GestureProperty& rhs);
128
129 protected:
130
131   T mValue;             ///< The property value
132   bool mInputChanged:1; ///< Whether the property has been modified
133 };
134
135 /**
136  * A read only Vector2 property used by Gestures.
137  */
138 class GesturePropertyVector2 : public GestureProperty< Vector2 >
139 {
140 public:
141
142   /**
143    * Virtual destructor.
144    */
145   virtual ~GesturePropertyVector2()
146   {
147   }
148
149   /**
150    * @copydoc Dali::PropertyInput::GetVector2()
151    */
152   virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
153   {
154     return mValue;
155   }
156 };
157
158 } // namespace SceneGraph
159
160 } // namespace Internal
161
162 } // namespace Dali
163
164 #endif // __DALI_INTERNAL_SCENE_GRAPH_GESTURE_PROPERTIES_H__