[SRUK] Initial copy from Tizen 2.2 version
[platform/core/uifw/dali-core.git] / dali / internal / event / events / touch-event-processor.h
1 #ifndef __DALI_INTERNAL_TOUCH_EVENT_PROCESSOR_H__
2 #define __DALI_INTERNAL_TOUCH_EVENT_PROCESSOR_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/render-tasks/render-task.h>
22 #include <dali/internal/event/common/proxy-object.h>
23
24 namespace Dali
25 {
26
27 class Actor;
28 struct Vector2;
29 struct Vector4;
30
31 namespace Integration
32 {
33 struct TouchEvent;
34 }
35
36 namespace Internal
37 {
38
39 class Actor;
40 class Stage;
41
42 /**
43  * <h3>Multi-Touch Event Processing:</h3>
44  *
45  * The TouchEventProcessor processes touch events and emits the Touched signal on the hit actor (and
46  * its parents).
47  *
48  * - Hit Testing & Touch Event Delivery are described in Dali::Actor.
49  */
50 class TouchEventProcessor
51 {
52 public:
53
54   /**
55    * Create an event processor.
56    * @param[in] stage The stage.
57    */
58   TouchEventProcessor( Stage& stage );
59
60   /**
61    * Non-virtual destructor; TouchEventProcessor is not a base class
62    */
63   ~TouchEventProcessor();
64
65   /**
66    * This function is called by the event processor whenever a touch event occurs.
67    * @param[in] event The touch event that has occurred.
68    */
69   void ProcessTouchEvent( const Integration::TouchEvent& event );
70
71 private:
72
73   // Undefined
74   TouchEventProcessor(const TouchEventProcessor&);
75
76   // Undefined
77   TouchEventProcessor& operator=(const TouchEventProcessor& rhs);
78
79 private:
80
81   /**
82    * Stores an actor pointer and connects/disconnects to any required signals appropriately when set/unset.
83    */
84   struct ActorObserver : public ProxyObject::Observer
85   {
86   public:
87
88     // Construction & Destruction
89
90     /**
91      * Constructor.
92      */
93     ActorObserver();
94
95     /**
96      * Non virtual destructor
97      */
98     ~ActorObserver();
99
100     // Methods
101
102     /**
103      * Return the stored Actor pointer.
104      * @return The Actor pointer.
105      */
106     Actor* GetActor();
107
108     /**
109      * Assignment operator.
110      * This disconnects the required signals from the currently set actor and connects to the required
111      * signals for the the actor specified (if set).
112      */
113     void SetActor( Actor* actor );
114
115   private:
116
117     // Undefined
118     ActorObserver( const ActorObserver& );
119     ActorObserver& operator=( const ActorObserver& );
120
121   private:
122
123     /**
124      * This will never get called as we do not observe objects that have not been added to the scene.
125      * @param[in] proxy The proxy object.
126      * @see ProxyObject::Observer::SceneObjectAdded()
127      */
128     virtual void SceneObjectAdded(ProxyObject& proxy) { }
129
130     /**
131      * This will be called when the actor is removed from the stage, we should clear and stop
132      * observing it.
133      * @param[in] proxy The proxy object.
134      * @see ProxyObject::Observer::SceneObjectRemoved()
135      */
136     virtual void SceneObjectRemoved(ProxyObject& proxy);
137
138     /**
139      * This will be called when the actor is destroyed. We should clear the actor.
140      * No need to stop observing as the object is being destroyed anyway.
141      * @see ProxyObject::Observer::ProxyDestroyed()
142      */
143     virtual void ProxyDestroyed(ProxyObject& proxy);
144
145   private:
146     Actor* mActor; ///< Raw pointer to an Actor.
147   };
148
149   Stage& mStage; ///< Used to deliver touch events
150   ActorObserver mLastPrimaryHitActor; ///< Stores the last primary point hit actor
151   ActorObserver mLastConsumedActor; ///< Stores the last consumed actor
152   Dali::RenderTask mLastRenderTask; ///< The RenderTask used for the last hit actor
153 };
154
155 } // namespace Internal
156
157 } // namespace Dali
158
159 #endif // __DALI_INTERNAL_TOUCH_EVENT_PROCESSOR_H__