[Tizen] Revert "Use touch consumed return to set whether we process a gesture or...
[platform/core/uifw/dali-core.git] / dali / internal / event / events / event-processor.cpp
index 1b5b952..06250ba 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) 2019 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>
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 #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/pinch-gesture-event.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
+#include <dali/integration-api/events/hover-event-integ.h>
 #include <dali/internal/event/events/gesture-event-processor.h>
 #include <dali/internal/common/core-impl.h>
 #include <dali/internal/event/common/notification-manager.h>
@@ -44,21 +41,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::KeyEvent), sizeof(Integration::WheelEvent) ) );
 
-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 +88,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 +96,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,75 +109,12 @@ void EventProcessor::QueueEvent( const Event& event )
       break;
     }
 
-    case Event::MouseWheel:
-    {
-      typedef Integration::MouseWheelEvent DerivedType;
-
-      // Reserve some memory inside the message queue
-      unsigned int* 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;
-    }
-
-    case Event::Notification:
-    {
-      // TODO - Remove this deprecated event
-      break;
-    }
-
-    case Event::Gesture:
-    {
-      QueueGestureEvent( static_cast<const Integration::GestureEvent&>(event) );
-      break;
-    }
-
-    default:
-    {
-      DALI_ASSERT_ALWAYS( false && "Invalid event sent from Integration\n" );
-      break;
-    }
-  }
-}
-
-void EventProcessor::QueueGestureEvent(const Integration::GestureEvent& event)
-{
-  switch( event.gestureType )
-  {
-    case Gesture::Pinch:
-    {
-      typedef Integration::PinchGestureEvent DerivedType;
-
-      // Reserve some memory inside the message queue
-      unsigned int* 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;
-    }
-
-    case Gesture::Pan:
-    {
-      typedef Integration::PanGestureEvent DerivedType;
-
-      // Reserve some memory inside the message queue
-      unsigned int* 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;
-    }
-
-    case Gesture::Tap:
+    case Event::Key:
     {
-      typedef Integration::TapGestureEvent 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) );
@@ -188,24 +122,18 @@ void EventProcessor::QueueGestureEvent(const Integration::GestureEvent& event)
       break;
     }
 
-    case Gesture::LongPress:
+    case Event::Wheel:
     {
-      typedef Integration::LongPressGestureEvent DerivedType;
+      typedef Integration::WheelEvent 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 +142,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() )
   {
@@ -225,36 +153,30 @@ void EventProcessor::ProcessEvents()
       case Event::Touch:
       {
         mTouchEventProcessor.ProcessTouchEvent( static_cast<const Integration::TouchEvent&>(*event) );
+        mGestureEventProcessor.ProcessTouchEvent(mScene, static_cast<const Integration::TouchEvent&>(*event));
         break;
       }
 
-      case Event::Key:
-      {
-        mKeyEventProcessor.ProcessKeyEvent( static_cast<const Integration::KeyEvent&>(*event) );
-        break;
-      }
-
-      case Event::MouseWheel:
+      case Event::Hover:
       {
-        mMouseWheelEventProcessor.ProcessMouseWheelEvent( static_cast<const Integration::MouseWheelEvent&>(*event) );
+        mHoverEventProcessor.ProcessHoverEvent( static_cast<const Integration::HoverEvent&>(*event) );
         break;
       }
 
-      case Event::Gesture:
+      case Event::Key:
       {
-        mGestureEventProcessor.ProcessGestureEvent( static_cast<const Integration::GestureEvent&>(*event) );
+        mKeyEventProcessor.ProcessKeyEvent( static_cast<const Integration::KeyEvent&>(*event) );
         break;
       }
 
-      default:
+      case Event::Wheel:
       {
-        DALI_ASSERT_ALWAYS( false && "Invalid event sent from Integration\n" );
+        mWheelEventProcessor.ProcessWheelEvent( static_cast<const Integration::WheelEvent&>(*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();