Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / events / event-processor.cpp
index 1b5b952..d19ff67 100644 (file)
@@ -1,18 +1,19 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // CLASS HEADER
 #include <dali/internal/event/events/event-processor.h>
@@ -22,8 +23,9 @@
 #include <dali/integration-api/events/event.h>
 #include <dali/integration-api/events/gesture-event.h>
 #include <dali/integration-api/events/key-event-integ.h>
-#include <dali/integration-api/events/mouse-wheel-event-integ.h>
+#include <dali/integration-api/events/wheel-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/events/hover-event-integ.h>
 #include <dali/integration-api/events/pinch-gesture-event.h>
 #include <dali/integration-api/events/pan-gesture-event.h>
 #include <dali/integration-api/events/tap-gesture-event.h>
@@ -45,20 +47,21 @@ namespace // unnamed namespace
 
 static const std::size_t MAX_MESSAGE_SIZE = std::max( sizeof(Integration::TouchEvent),
                                                       std::max( sizeof(Integration::KeyEvent),
-                                                                std::max( sizeof(Integration::MouseWheelEvent), sizeof(Integration::GestureEvent) ) ) );
+                                                                std::max( sizeof(Integration::WheelEvent), sizeof(Integration::GestureEvent) ) ) );
 
-static const std::size_t INITIAL_MIN_CAPICITY = 4;
+static const std::size_t INITIAL_MIN_CAPACITY = 4;
 
-static const std::size_t INITIAL_BUFFER_SIZE = MAX_MESSAGE_SIZE * INITIAL_MIN_CAPICITY;
+static const std::size_t INITIAL_BUFFER_SIZE = MAX_MESSAGE_SIZE * INITIAL_MIN_CAPACITY;
 
 } // unnamed namespace
 
-EventProcessor::EventProcessor(Stage& stage, NotificationManager& notificationManager, GestureEventProcessor& gestureEventProcessor)
-: mNotificationManager(notificationManager),
-  mTouchEventProcessor(stage),
-  mGestureEventProcessor(gestureEventProcessor),
-  mKeyEventProcessor(stage),
-  mMouseWheelEventProcessor(stage),
+EventProcessor::EventProcessor( Scene& scene, GestureEventProcessor& gestureEventProcessor )
+: mScene( scene ),
+  mTouchEventProcessor( scene ),
+  mHoverEventProcessor( scene ),
+  mGestureEventProcessor( gestureEventProcessor ),
+  mKeyEventProcessor( scene ),
+  mWheelEventProcessor( scene ),
   mEventQueue0( INITIAL_BUFFER_SIZE ),
   mEventQueue1( INITIAL_BUFFER_SIZE ),
   mCurrentEventQueue( &mEventQueue0 )
@@ -91,7 +94,7 @@ void EventProcessor::QueueEvent( const Event& event )
       typedef Integration::TouchEvent DerivedType;
 
       // Reserve some memory inside the message queue
-      unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+      uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
 
       // Construct message in the message queue memory; note that delete should not be called on the return value
       new (slot) DerivedType( static_cast<const DerivedType&>(event) );
@@ -99,12 +102,12 @@ void EventProcessor::QueueEvent( const Event& event )
       break;
     }
 
-    case Event::Key:
+    case Event::Hover:
     {
-      typedef Integration::KeyEvent DerivedType;
+      typedef Integration::HoverEvent DerivedType;
 
       // Reserve some memory inside the message queue
-      unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+      uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
 
       // Construct message in the message queue memory; note that delete should not be called on the return value
       new (slot) DerivedType( static_cast<const DerivedType&>(event) );
@@ -112,12 +115,12 @@ void EventProcessor::QueueEvent( const Event& event )
       break;
     }
 
-    case Event::MouseWheel:
+    case Event::Key:
     {
-      typedef Integration::MouseWheelEvent DerivedType;
+      typedef Integration::KeyEvent DerivedType;
 
       // Reserve some memory inside the message queue
-      unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+      uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
 
       // Construct message in the message queue memory; note that delete should not be called on the return value
       new (slot) DerivedType( static_cast<const DerivedType&>(event) );
@@ -125,9 +128,16 @@ void EventProcessor::QueueEvent( const Event& event )
       break;
     }
 
-    case Event::Notification:
+    case Event::Wheel:
     {
-      // TODO - Remove this deprecated event
+      typedef Integration::WheelEvent DerivedType;
+
+      // Reserve some memory inside the message queue
+      uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+
+      // Construct message in the message queue memory; note that delete should not be called on the return value
+      new (slot) DerivedType( static_cast<const DerivedType&>(event) );
+
       break;
     }
 
@@ -137,11 +147,6 @@ void EventProcessor::QueueEvent( const Event& event )
       break;
     }
 
-    default:
-    {
-      DALI_ASSERT_ALWAYS( false && "Invalid event sent from Integration\n" );
-      break;
-    }
   }
 }
 
@@ -154,7 +159,7 @@ void EventProcessor::QueueGestureEvent(const Integration::GestureEvent& event)
       typedef Integration::PinchGestureEvent DerivedType;
 
       // Reserve some memory inside the message queue
-      unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+      uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
 
       // Construct message in the message queue memory; note that delete should not be called on the return value
       new (slot) DerivedType( static_cast<const DerivedType&>(event) );
@@ -167,7 +172,7 @@ void EventProcessor::QueueGestureEvent(const Integration::GestureEvent& event)
       typedef Integration::PanGestureEvent DerivedType;
 
       // Reserve some memory inside the message queue
-      unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+      uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
 
       // Construct message in the message queue memory; note that delete should not be called on the return value
       new (slot) DerivedType( static_cast<const DerivedType&>(event) );
@@ -180,7 +185,7 @@ void EventProcessor::QueueGestureEvent(const Integration::GestureEvent& event)
       typedef Integration::TapGestureEvent DerivedType;
 
       // Reserve some memory inside the message queue
-      unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+      uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
 
       // Construct message in the message queue memory; note that delete should not be called on the return value
       new (slot) DerivedType( static_cast<const DerivedType&>(event) );
@@ -193,19 +198,13 @@ void EventProcessor::QueueGestureEvent(const Integration::GestureEvent& event)
       typedef Integration::LongPressGestureEvent DerivedType;
 
       // Reserve some memory inside the message queue
-      unsigned int* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
+      uint32_t* slot = mCurrentEventQueue->ReserveMessageSlot( sizeof( DerivedType ) );
 
       // Construct message in the message queue memory; note that delete should not be called on the return value
       new (slot) DerivedType( static_cast<const DerivedType&>(event) );
 
       break;
     }
-
-    default:
-    {
-      DALI_ASSERT_ALWAYS( false && "Invalid event sent from Integration\n" );
-      break;
-    }
   }
 }
 
@@ -214,7 +213,7 @@ void EventProcessor::ProcessEvents()
   MessageBuffer* queueToProcess = mCurrentEventQueue;
 
   // Switch current queue; events can be added safely while iterating through the other queue.
-  mCurrentEventQueue = (&mEventQueue0 == mCurrentEventQueue) ? &mEventQueue1 : &mEventQueue0;
+  mCurrentEventQueue = ( &mEventQueue0 == mCurrentEventQueue ) ? &mEventQueue1 : &mEventQueue0;
 
   for( MessageBuffer::Iterator iter = queueToProcess->Begin(); iter.IsValid(); iter.Next() )
   {
@@ -228,33 +227,33 @@ void EventProcessor::ProcessEvents()
         break;
       }
 
-      case Event::Key:
+      case Event::Hover:
       {
-        mKeyEventProcessor.ProcessKeyEvent( static_cast<const Integration::KeyEvent&>(*event) );
+        mHoverEventProcessor.ProcessHoverEvent( static_cast<const Integration::HoverEvent&>(*event) );
         break;
       }
 
-      case Event::MouseWheel:
+      case Event::Key:
       {
-        mMouseWheelEventProcessor.ProcessMouseWheelEvent( static_cast<const Integration::MouseWheelEvent&>(*event) );
+        mKeyEventProcessor.ProcessKeyEvent( static_cast<const Integration::KeyEvent&>(*event) );
         break;
       }
 
-      case Event::Gesture:
+      case Event::Wheel:
       {
-        mGestureEventProcessor.ProcessGestureEvent( static_cast<const Integration::GestureEvent&>(*event) );
+        mWheelEventProcessor.ProcessWheelEvent( static_cast<const Integration::WheelEvent&>(*event) );
         break;
       }
 
-      default:
+      case Event::Gesture:
       {
-        DALI_ASSERT_ALWAYS( false && "Invalid event sent from Integration\n" );
+        mGestureEventProcessor.ProcessGestureEvent( mScene, static_cast<const Integration::GestureEvent&>(*event) );
         break;
       }
 
-      // Call virtual destructor explictly; since delete will not be called after placement new
-      event->~Event();
     }
+    // Call virtual destructor explictly; since delete will not be called after placement new
+    event->~Event();
   }
 
   queueToProcess->Reset();