X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Fevents%2Fevent-processor.cpp;h=fed209a6769d92156153c6c90e1ebcbdfd0a08c1;hb=de93b2d9023b5e53eef090ae1235b3d367cd455b;hp=29753bc5637e536fa18f858d98e8ec6f032030f0;hpb=8f2c5571c924479b6a07a2c2187dedd9c685baf0;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/events/event-processor.cpp b/dali/internal/event/events/event-processor.cpp index 29753bc..fed209a 100644 --- a/dali/internal/event/events/event-processor.cpp +++ b/dali/internal/event/events/event-processor.cpp @@ -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) 2020 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 @@ -20,14 +21,10 @@ // INTERNAL INCLUDES #include #include -#include #include -#include +#include #include -#include -#include -#include -#include +#include #include #include #include @@ -44,20 +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) -: 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 ) @@ -90,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(event) ); @@ -98,64 +96,12 @@ void EventProcessor::QueueEvent( const Event& event ) break; } - case Event::Key: - { - typedef Integration::KeyEvent 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(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(event) ); - - break; - } - - case Event::Gesture: - { - QueueGestureEvent( static_cast(event) ); - 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(event) ); - - break; - } - - case Gesture::Pan: + case Event::Hover: { - typedef Integration::PanGestureEvent 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(event) ); @@ -163,12 +109,12 @@ void EventProcessor::QueueGestureEvent(const Integration::GestureEvent& 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(event) ); @@ -176,12 +122,12 @@ 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(event) ); @@ -196,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() ) { @@ -206,28 +152,38 @@ void EventProcessor::ProcessEvents() { case Event::Touch: { - mTouchEventProcessor.ProcessTouchEvent( static_cast(*event) ); + Integration::TouchEvent& touchEvent = static_cast(*event); + const bool consumed = mTouchEventProcessor.ProcessTouchEvent( touchEvent ); + + // If touch is consumed, then gestures should be cancelled + // Do this by sending an interrupted event to the GestureEventProcessor + if( consumed ) + { + Integration::Point& point = touchEvent.GetPoint(0); + point.SetState( PointState::INTERRUPTED ); + } + + mGestureEventProcessor.ProcessTouchEvent(mScene, touchEvent); break; } - case Event::Key: + case Event::Hover: { - mKeyEventProcessor.ProcessKeyEvent( static_cast(*event) ); + mHoverEventProcessor.ProcessHoverEvent( static_cast(*event) ); break; } - case Event::MouseWheel: + case Event::Key: { - mMouseWheelEventProcessor.ProcessMouseWheelEvent( static_cast(*event) ); + mKeyEventProcessor.ProcessKeyEvent( static_cast(*event) ); break; } - case Event::Gesture: + case Event::Wheel: { - mGestureEventProcessor.ProcessGestureEvent( static_cast(*event) ); + mWheelEventProcessor.ProcessWheelEvent( static_cast(*event) ); break; } - } // Call virtual destructor explictly; since delete will not be called after placement new event->~Event();