[dali_2.3.33] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / events / event-processor.h
1 #ifndef DALI_INTERNAL_EVENT_PROCESSOR_H
2 #define DALI_INTERNAL_EVENT_PROCESSOR_H
3
4 /*
5  * Copyright (c) 2021 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 // EXTERNAL INCLUDES
22 #include <unordered_map>
23
24 // INTERNAL INCLUDES
25 #include <dali/integration-api/events/point.h>
26 #include <dali/internal/common/message-buffer.h>
27 #include <dali/internal/event/events/hover-event-processor.h>
28 #include <dali/internal/event/events/key-event-processor.h>
29 #include <dali/internal/event/events/touch-event-processor.h>
30 #include <dali/internal/event/events/wheel-event-processor.h>
31
32 namespace Dali
33 {
34 namespace Integration
35 {
36 struct Event;
37 }
38
39 namespace Internal
40 {
41 class Scene;
42 class GestureEventProcessor;
43 class NotificationManager;
44
45 using TouchPointsContainer          = std::list<Integration::Point>;
46 using ActorTouchPointsContainer     = std::unordered_map<uint32_t, TouchPointsContainer>;
47
48 using TouchEventProcessorsContainer = std::unordered_map<uint32_t, IntrusivePtr<TouchEventProcessor>>;
49 using ActorIdDeviceIdContainer      = std::unordered_map<uint32_t, uint32_t>;
50 /**
51  * The EventProcessor processes any events that are received by Dali.  Such events include
52  * touch events, key events, wheel events, and notification events.
53  *
54  * When the EventProcessor receives an event, it determines its type and passes it on to the
55  * appropriate processor.
56  */
57 class EventProcessor
58 {
59 public:
60   /**
61    * Constructor
62    * @param[in] scene                  The scene.
63    * @param[in] gestureEventProcessor  The gesture event processor.
64    */
65   EventProcessor(Scene& scene, GestureEventProcessor& gestureEventProcessor);
66
67   /**
68    * Destructor
69    */
70   virtual ~EventProcessor();
71
72 public:
73   /**
74    * This function is called when an event is queued.
75    * @param[in] event A event to queue.
76    */
77   void QueueEvent(const Integration::Event& event);
78
79   /**
80    * This function is called when events are processed.
81    */
82   void ProcessEvents();
83
84   /**
85    * This function is called when sending a interrupted event to a specific actor.
86    * @param[in] actor The actor on which the event should occur.
87    */
88   void SendInterruptedEvents(Dali::Internal::Actor *actor);
89
90 private:
91   Scene&                         mScene;                 ///< The Scene events are processed for.
92   TouchEventProcessor            mTouchEventProcessor;   ///< Processes touch events.
93   HoverEventProcessor            mHoverEventProcessor;   ///< Processes hover events.
94   GestureEventProcessor&         mGestureEventProcessor; ///< Processes gesture events.
95   KeyEventProcessor              mKeyEventProcessor;     ///< Processes key events.
96   WheelEventProcessor            mWheelEventProcessor;   ///< Processes wheel events.
97
98   // Allow messages to be added safely to one queue, while processing (iterating through) the second queue.
99   MessageBuffer                  mEventQueue0;       ///< An event queue.
100   MessageBuffer                  mEventQueue1;       ///< Another event queue.
101   MessageBuffer*                 mCurrentEventQueue; ///< QueueEvent() will queue here.
102
103   TouchEventProcessorsContainer  mTouchEventProcessors;  ///< List of touch processors by actor
104   ActorTouchPointsContainer      mActorTouchPoints;      ///< List of touch events by actor
105   ActorIdDeviceIdContainer       mActorIdDeviceId;       ///< List of actor id by touch device id
106 };
107
108 } // namespace Internal
109
110 } // namespace Dali
111
112 #endif // DALI_INTERNAL_EVENT_PROCESSOR_H