From ca99959003c0445d5afb437e2be26361dff51623 Mon Sep 17 00:00:00 2001 From: "adam.b" Date: Thu, 3 Sep 2020 17:11:02 +0100 Subject: [PATCH] Removed On(...)Event() Change-Id: I09dcd36368f97c03cfda6d004e240df4dc13264b --- .../dali-toolkit-test-utils/dummy-control.cpp | 4 +- .../dali-toolkit-test-utils/dummy-control.h | 4 +- .../dali-toolkit-test-utils/test-button.cpp | 2 +- .../src/dali-toolkit/utc-Dali-ControlImpl.cpp | 121 --------------------- .../scrollable/item-view/item-view-impl.cpp | 7 +- .../controls/scrollable/item-view/item-view-impl.h | 5 +- .../scrollable/scroll-view/scroll-view-impl.cpp | 7 +- .../scrollable/scroll-view/scroll-view-impl.h | 5 +- dali-toolkit/public-api/controls/control-impl.cpp | 10 -- dali-toolkit/public-api/controls/control-impl.h | 24 ++-- 10 files changed, 28 insertions(+), 161 deletions(-) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp index 66e0bcc..7ca109c 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp @@ -93,7 +93,7 @@ DummyControl DummyControlImpl::New() } DummyControlImpl::DummyControlImpl() -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_HOVER_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ), +: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ), mCustomSlot1Called(false) { } @@ -267,8 +267,6 @@ void Impl::DummyControl::OnChildAdd(Actor& child) { childAddCalled = true; } void Impl::DummyControl::OnChildRemove(Actor& child) { childRemoveCalled = true; } void Impl::DummyControl::OnSizeSet(const Vector3& targetSize) { Control::OnSizeSet( targetSize ); sizeSetCalled = true; } void Impl::DummyControl::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { Control::OnSizeAnimation( animation, targetSize ); sizeAnimationCalled = true; } -bool Impl::DummyControl::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; } -bool Impl::DummyControl::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; } bool Impl::DummyControl::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;} void Impl::DummyControl::OnKeyInputFocusGained() { keyInputFocusGained = true; } void Impl::DummyControl::OnKeyInputFocusLost() { keyInputFocusLost = true; } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h index 6321c1e..0b257a1 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/dummy-control.h @@ -162,6 +162,7 @@ private: // From Internal::Control virtual void OnTap(const TapGesture& tap); virtual void OnLongPress(const LongPressGesture& longPress); virtual Vector3 GetNaturalSize(); + virtual bool OnKeyEvent(const KeyEvent& event); private: // From CustomActorImpl @@ -171,9 +172,6 @@ private: // From CustomActorImpl virtual void OnChildRemove(Actor& child); virtual void OnSizeSet(const Vector3& targetSize); virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize); - virtual bool OnHoverEvent(const HoverEvent& event); - virtual bool OnWheelEvent(const WheelEvent& event); - virtual bool OnKeyEvent(const KeyEvent& event); virtual void OnKeyInputFocusGained(); virtual void OnKeyInputFocusLost(); virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp index 3d25205..69b60b5 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-button.cpp @@ -57,7 +57,7 @@ Test::TestButton TestButton::New() } TestButton::TestButton() -: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS|REQUIRES_STYLE_CHANGE_SIGNALS ) ) +: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ) { } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index baa6b9e..a3ed827 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -465,65 +465,6 @@ int UtcDaliControlImplSizeAnimation(void) /////////////////////////////////////////////////////////////////////////////////////////////////// -int UtcDaliControlImplHoverEvent(void) -{ - ToolkitTestApplication application; - - { - DummyControl dummy = DummyControl::New( true ); - Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); - - dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); - dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); - application.GetScene().Add(dummy); - - application.Render(); - application.SendNotification(); - application.Render(); - application.SendNotification(); - - DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, false, TEST_LOCATION ); - Integration::HoverEvent event(1); - Integration::Point point; - point.SetDeviceId( 1 ); - point.SetState( PointState::MOTION ); - point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); - event.AddPoint(point); - application.ProcessEvent( event ); - DALI_TEST_EQUALS( dummyImpl.hoverEventCalled, true, TEST_LOCATION ); - - application.GetScene().Remove(dummy); - } - - // Ensure full code coverage - { - DummyControl dummy = DummyControl::New(); - - dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); - dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); - application.GetScene().Add(dummy); - - application.Render(); - application.SendNotification(); - application.Render(); - application.SendNotification(); - - Integration::HoverEvent event(1); - Integration::Point point; - point.SetDeviceId( 1 ); - point.SetState( PointState::MOTION ); - point.SetScreenPosition( Vector2( 20.0f, 20.0f ) ); - event.AddPoint(point); - application.ProcessEvent( event ); - - application.GetScene().Remove(dummy); - } - END_TEST; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////// - - int UtcDaliControlImplKeyEvent(void) { ToolkitTestApplication application; @@ -654,68 +595,6 @@ int UtcDaliControlImplTypeRegistry(void) /////////////////////////////////////////////////////////////////////////////////////////////////// -namespace -{ -static bool WheelEventCallback(Actor actor, const WheelEvent& event) -{ - return false; -} -} - -int UtcDaliControlImplWheelEvent(void) -{ - ToolkitTestApplication application; - - { - DummyControl dummy = DummyControl::New( true ); - Impl::DummyControl& dummyImpl = static_cast(dummy.GetImplementation()); - - dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); - dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); - application.GetScene().Add(dummy); - - dummy.WheelEventSignal().Connect(&WheelEventCallback); - - application.Render(); - application.SendNotification(); - application.Render(); - application.SendNotification(); - - DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION ); - - // simulate a wheel event - Vector2 screenCoordinates( 10.0f, 10.0f ); - Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u ); - application.ProcessEvent( event ); - DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION ); - - application.GetScene().Remove(dummy); - } - - // Ensure full code coverage - { - DummyControl dummy = DummyControl::New(); - - dummy.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) ); - dummy.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); - application.GetScene().Add(dummy); - - dummy.WheelEventSignal().Connect(&WheelEventCallback); - - application.Render(); - application.SendNotification(); - application.Render(); - application.SendNotification(); - - // simulate a wheel event - Vector2 screenCoordinates( 20.0f, 20.0f ); - Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u ); - application.ProcessEvent( event ); - - application.GetScene().Remove(dummy); - } - END_TEST; -} int UtcDaliControlImplSetStyleName(void) { diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp index dc329ed..c442fb8 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp @@ -333,7 +333,7 @@ Dali::Toolkit::ItemView ItemView::New(ItemFactory& factory) } ItemView::ItemView(ItemFactory& factory) -: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS | REQUIRES_WHEEL_EVENTS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ), +: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | DISABLE_STYLE_CHANGE_SIGNALS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ), mItemFactory(factory), mItemsParentOrigin(ParentOrigin::CENTER), mItemsAnchorPoint(AnchorPoint::CENTER), @@ -374,6 +374,9 @@ void ItemView::OnInitialize() mWheelEventFinishedTimer.TickSignal().Connect( this, &ItemView::OnWheelEventFinished ); SetRefreshInterval(DEFAULT_REFRESH_INTERVAL_LAYOUT_POSITIONS); + + // Connect wheel event + self.WheelEventSignal().Connect( this, &ItemView::OnWheelEvent ); } ItemView::~ItemView() @@ -1022,7 +1025,7 @@ void ItemView::OnChildAdd(Actor& child) Scrollable::OnChildAdd( child ); } -bool ItemView::OnWheelEvent(const WheelEvent& event) +bool ItemView::OnWheelEvent(Actor actor, const WheelEvent& event) { // Respond the wheel event to scroll if (mActiveLayout) diff --git a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h index 0cfa9ab..12894af 100755 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h @@ -412,11 +412,12 @@ private: // From CustomActorImpl virtual void OnChildAdd(Actor& child); /** - * From CustomActorImpl; called after a wheel-event is received by the owning actor. + * Called after a wheel-event is received by the owning actor. + * @param[in] actor Actor associated with the wheel event. * @param[in] event The wheel event. * @return True if the event should be consumed. */ - virtual bool OnWheelEvent(const WheelEvent& event); + bool OnWheelEvent(Actor actor, const WheelEvent& event); private: // From Control diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index c0fb772..1273cd1 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -629,7 +629,7 @@ Dali::Toolkit::ScrollView ScrollView::New() } ScrollView::ScrollView() -: ScrollBase( ControlBehaviour( REQUIRES_WHEEL_EVENTS | DISABLE_STYLE_CHANGE_SIGNALS ) ), // Enable size negotiation +: ScrollBase( ControlBehaviour( DISABLE_STYLE_CHANGE_SIGNALS ) ), // Enable size negotiation mTouchDownTime(0u), mGestureStackDepth(0), mScrollStateFlags(0), @@ -703,6 +703,9 @@ void ScrollView::OnInitialize() UpdatePropertyDomain(); SetInternalConstraints(); + + // Connect wheel event + self.WheelEventSignal().Connect( this, &ScrollView::OnWheelEvent ); } void ScrollView::OnSceneConnection( int depth ) @@ -2129,7 +2132,7 @@ bool ScrollView::OnTouch( Actor actor, const TouchEvent& touch ) return false; } -bool ScrollView::OnWheelEvent(const WheelEvent& event) +bool ScrollView::OnWheelEvent( Actor actor, const WheelEvent& event) { if(!mSensitive) { diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h index d85a156..ec7b893 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h @@ -566,11 +566,12 @@ private: // private overridden functions from CustomActorImpl and Controls virtual void OnChildRemove(Actor& child); /** - * From CustomActorImpl; called after a wheelEvent is received by the owning actor. + * Called after a wheelEvent is received by the owning actor. + * @param[in] actor Actor associated with the event. * @param[in] event The wheel event. * @return True if the event should be consumed. */ - virtual bool OnWheelEvent(const WheelEvent& event); + bool OnWheelEvent(Actor actor, const WheelEvent& event); /** * @copydoc Toolkit::Control::OnInitialize() diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 506b833..4916474 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -622,21 +622,11 @@ void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize) // @todo size negotiate background to new size, animate as well? } -bool Control::OnHoverEvent(const HoverEvent& event) -{ - return false; // Do not consume -} - bool Control::OnKeyEvent(const KeyEvent& event) { return false; // Do not consume } -bool Control::OnWheelEvent(const WheelEvent& event) -{ - return false; // Do not consume -} - void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) { for( unsigned int i = 0, numChildren = Self().GetChildCount(); i < numChildren; ++i ) diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index 237c462..745d444 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -339,21 +339,6 @@ protected: // From CustomActorImpl virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize ) override; /** - * @copydoc CustomActorImpl::OnHoverEvent() - */ - virtual bool OnHoverEvent( const HoverEvent& event ) override; - - /** - * @copydoc CustomActorImpl::OnKeyEvent() - */ - virtual bool OnKeyEvent( const KeyEvent& event ) override; - - /** - * @copydoc CustomActorImpl::OnWheelEvent() - */ - virtual bool OnWheelEvent( const WheelEvent& event ) override; - - /** * @copydoc CustomActorImpl::OnRelayout() */ virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) override; @@ -546,6 +531,15 @@ public: // API for derived classes to override */ virtual bool OnKeyboardEnter(); + /** + * @brief Called after a key-event is received by the actor that has had its focus set. + * + * @SINCE_1_0.0 + * @param[in] event The Key Event + * @return True if the event should be consumed + */ + virtual bool OnKeyEvent( const KeyEvent& event ); + // Gestures /** -- 2.7.4