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