f0a733b6bffed3869f77b7812960f3c1c05418f6
[platform/core/uifw/dali-core.git] / dali / internal / event / events / gesture-impl.h
1 #ifndef DALI_INTERNAL_GESTURE_H
2 #define DALI_INTERNAL_GESTURE_H
3
4 /*
5  * Copyright (c) 2020 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/events/gesture.h>
23 #include <dali/integration-api/events/event.h>
24 #include <dali/public-api/object/base-object.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class Gesture;
33 typedef IntrusivePtr<Gesture> GesturePtr;
34
35 /**
36  * This is the abstract base structure for any gestures that the adaptor detects and wishes to send
37  * to the Core.
38  */
39 class Gesture : public BaseObject
40 {
41 public:
42
43   using State = Dali::Gesture::State;
44   using Type = Dali::Gesture::Type;
45
46 public:
47
48   /**
49    * @brief Get the gesture type.
50    *
51    * @return The gesture type.
52    */
53   inline Type GetType() const
54   {
55     return mGestureType;
56   }
57
58   /**
59    * @brief Set the state of the gesture.
60    * @param[in] state The state of the gesture to set
61    */
62   inline void SetState( State state )
63   {
64     mState = state;
65   }
66
67    /**
68    * @brief Get the state of the gesture.
69    *
70    * @return The state of the gesture.
71    */
72   inline State GetState() const
73   {
74     return mState;
75   }
76
77   /**
78    * @brief Set The time the gesture took place.
79    * @param[in] time The time the gesture took place. to set
80    */
81   inline void SetTime( uint32_t time )
82   {
83     mTime = time;
84   }
85
86   /**
87    * @brief Get the time the gesture took place.
88    *
89    * @return The time the gesture took place.
90    */
91   inline uint32_t GetTime() const
92   {
93     return mTime;
94   }
95
96   Gesture(const Gesture&) = delete; ///< Deleted copy constructor
97   Gesture(Gesture&&) = delete; ///< Deleted move constructor
98   Gesture& operator=(const Gesture&) = delete; ///< Deleted copy assignment operator
99   Gesture& operator=(Gesture&&) = delete; ///< Deleted move assignment operator
100
101 protected:
102
103   /**
104    * This constructor is only used by derived classes.
105    * @param[in] gestureType   The type of gesture event.
106    * @param[in] gestureState  The state of the gesture event.
107    */
108   Gesture(Type gestureType, State gestureState)
109   : mGestureType( gestureType ),
110     mState( gestureState )
111   {
112   }
113
114   /**
115    * @brief Virtual destructor.
116    *
117    * A reference counted object may only be deleted by calling Unreference()
118    */
119   virtual ~Gesture() = default;
120
121 private:
122   Type mGestureType;
123   State mState;
124   uint32_t mTime{0u};
125 };
126
127 } // namespace Internal
128
129 /**
130  * Helper methods for public API.
131  */
132 inline Internal::Gesture& GetImplementation(Dali::Gesture& gesture)
133 {
134   DALI_ASSERT_ALWAYS( gesture && "gesture handle is empty" );
135
136   BaseObject& handle = gesture.GetBaseObject();
137
138   return static_cast<Internal::Gesture&>(handle);
139 }
140
141 inline const Internal::Gesture& GetImplementation(const Dali::Gesture& gesture)
142 {
143   DALI_ASSERT_ALWAYS( gesture && "gesture handle is empty" );
144
145   const BaseObject& handle = gesture.GetBaseObject();
146
147   return static_cast<const Internal::Gesture&>(handle);
148 }
149
150 } // namespace Dali
151
152 #endif // DALI_INTERNAL_GESTURE_H