Conversion to Apache 2.0 license
[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) 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/internal/event/events/touch-event-processor.h>
23 #include <dali/internal/event/events/key-event-processor.h>
24 #include <dali/internal/event/events/mouse-wheel-event-processor.h>
25 #include <dali/internal/common/message-buffer.h>
26
27 namespace Dali
28 {
29
30 namespace Integration
31 {
32 struct Event;
33 struct GestureEvent;
34 }
35
36 namespace Internal
37 {
38
39 class Stage;
40 class GestureEventProcessor;
41 class NotificationManager;
42
43 /**
44  * The EventProcessor processes any events that are received by Dali.  Such events include
45  * touch events, key events, mouse wheel events, and notification events.
46  *
47  * When the EventProcessor receives an event, it determines its type and passes it on to the
48  * appropriate processor.
49  */
50 class EventProcessor
51 {
52 public:
53
54   /**
55    * Constructor
56    * @param[in] stage                  The stage.
57    * @param[in] notificationManager    The Notification Manager.
58    * @param[in] gestureEventProcessor  The gesture event processor.
59    */
60   EventProcessor(Stage& stage, NotificationManager& notificationManager, GestureEventProcessor& gestureEventProcessor);
61
62   /**
63    * Destructor
64    */
65   virtual ~EventProcessor();
66
67 public:
68
69   /**
70    * This function is called by Core when an event is queued.
71    * @param[in] event A event to queue.
72    */
73   void QueueEvent( const Integration::Event& event );
74
75   /**
76    * This function is called by Core when events are processed.
77    */
78   void ProcessEvents();
79
80 private:
81
82   /**
83    * Helper for QueueEvent()
84    */
85   void QueueGestureEvent(const Integration::GestureEvent& event);
86
87 private:
88
89   TouchEventProcessor      mTouchEventProcessor;        ///< Processes touch events.
90   GestureEventProcessor&   mGestureEventProcessor;      ///< Processes gesture events.
91   KeyEventProcessor        mKeyEventProcessor;          ///< Processes key events.
92   MouseWheelEventProcessor mMouseWheelEventProcessor;   ///< Processes mouse wheel events.
93
94   // Allow messages to be added safely to one queue, while processing (iterating through) the second queue.
95   MessageBuffer mEventQueue0;        ///< An event queue.
96   MessageBuffer mEventQueue1;        ///< Another event queue.
97   MessageBuffer* mCurrentEventQueue; ///< QueueEvent() will queue here.
98 };
99
100 } // namespace Internal
101
102 } // namespace Dali
103
104 #endif // __DALI_INTERNAL_EVENT_PROCESSOR_H__
105