From fd1a47af0ac56d63622dcef32fade5c3b90957d0 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Fri, 29 May 2015 17:35:59 +0900 Subject: [PATCH] Change WheelEvent - Replace MouseWheelEvent with WheelEvent - Add custom wheel event type Change-Id: I29bb34e45fb2c2b6764652ab631b86f8534772a5 --- .../dali-toolkit-test-utils/dummy-control.cpp | 4 +-- .../dali-toolkit-test-utils/dummy-control.h | 4 +-- .../src/dali-toolkit/utc-Dali-ControlImpl.cpp | 26 +++++++------- .../src/dali-toolkit/utc-Dali-ItemView.cpp | 8 ++--- .../src/dali-toolkit/utc-Dali-ScrollView.cpp | 12 +++---- .../internal/controls/popup/popup-impl.cpp | 6 ++-- dali-toolkit/internal/controls/popup/popup-impl.h | 8 ++--- .../scrollable/item-view/item-view-impl.cpp | 40 +++++++++++----------- .../controls/scrollable/item-view/item-view-impl.h | 22 ++++++------ .../scrollable/scroll-view/scroll-view-impl.cpp | 26 +++++++------- .../scrollable/scroll-view/scroll-view-impl.h | 16 ++++----- dali-toolkit/public-api/controls/control-impl.cpp | 2 +- dali-toolkit/public-api/controls/control-impl.h | 4 +-- .../controls/scrollable/item-view/item-view.cpp | 8 ++--- .../controls/scrollable/item-view/item-view.h | 8 ++--- .../scrollable/scroll-view/scroll-view.cpp | 8 ++--- .../controls/scrollable/scroll-view/scroll-view.h | 10 +++--- .../src/events/event-object-generator.cpp | 11 ++++-- .../src/events/event-object-generator.h | 4 +-- .../src/signals/dali-any-javascript-converter.cpp | 4 +-- .../dali-script-v8/src/signals/signal-manager.cpp | 10 +++--- 21 files changed, 123 insertions(+), 118 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 e6f1b50..b6b80a2 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 @@ -101,7 +101,7 @@ DummyControlImplOverride::DummyControlImplOverride() sizeAnimationCalled(false), touchEventCalled(false), hoverEventCalled(false), - mouseWheelEventCalled(false), + wheelEventCalled(false), keyEventCalled(false), keyInputFocusGained(false), keyInputFocusLost(false) @@ -130,7 +130,7 @@ void DummyControlImplOverride::OnSizeSet(const Vector3& targetSize) { sizeSetCal void DummyControlImplOverride::OnSizeAnimation(Animation& animation, const Vector3& targetSize) { sizeAnimationCalled = true; } bool DummyControlImplOverride::OnTouchEvent(const TouchEvent& event) { touchEventCalled = true; return false; } bool DummyControlImplOverride::OnHoverEvent(const HoverEvent& event) { hoverEventCalled = true; return false; } -bool DummyControlImplOverride::OnMouseWheelEvent(const MouseWheelEvent& event) { mouseWheelEventCalled = true; return false; } +bool DummyControlImplOverride::OnWheelEvent(const WheelEvent& event) { wheelEventCalled = true; return false; } bool DummyControlImplOverride::OnKeyEvent(const KeyEvent& event) { keyEventCalled = true; return false;} void DummyControlImplOverride::OnKeyInputFocusGained() { keyInputFocusGained = true; } void DummyControlImplOverride::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 7791006..bcef6d1 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 @@ -119,7 +119,7 @@ private: // From CustomActorImpl virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize); virtual bool OnTouchEvent(const TouchEvent& event); virtual bool OnHoverEvent(const HoverEvent& event); - virtual bool OnMouseWheelEvent(const MouseWheelEvent& event); + virtual bool OnWheelEvent(const WheelEvent& event); virtual bool OnKeyEvent(const KeyEvent& event); virtual void OnKeyInputFocusGained(); virtual void OnKeyInputFocusLost(); @@ -142,7 +142,7 @@ public: bool sizeAnimationCalled; bool touchEventCalled; bool hoverEventCalled; - bool mouseWheelEventCalled; + bool wheelEventCalled; bool keyEventCalled; bool keyInputFocusGained; bool keyInputFocusLost; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp index 92b7ff4..23b0a94 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ControlImpl.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -780,13 +780,13 @@ int UtcDaliControlImplTypeRegistry(void) /////////////////////////////////////////////////////////////////////////////////////////////////// namespace { -static bool MouseWheelEventCallback(Actor actor, const MouseWheelEvent& event) +static bool WheelEventCallback(Actor actor, const WheelEvent& event) { return false; } } -int UtcDaliControlImplMouseWheelEvent(void) +int UtcDaliControlImplWheelEvent(void) { ToolkitTestApplication application; @@ -798,20 +798,20 @@ int UtcDaliControlImplMouseWheelEvent(void) dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); - dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback); + dummy.WheelEventSignal().Connect(&WheelEventCallback); application.Render(); application.SendNotification(); application.Render(); application.SendNotification(); - DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, false, TEST_LOCATION ); + DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, false, TEST_LOCATION ); - // simulate a mouse wheel event + // simulate a wheel event Vector2 screenCoordinates( 10.0f, 10.0f ); - Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u); - application.ProcessEvent(event); - DALI_TEST_EQUALS( dummyImpl.mouseWheelEventCalled, true, TEST_LOCATION ); + Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u ); + application.ProcessEvent( event ); + DALI_TEST_EQUALS( dummyImpl.wheelEventCalled, true, TEST_LOCATION ); Stage::GetCurrent().Remove(dummy); } @@ -824,17 +824,17 @@ int UtcDaliControlImplMouseWheelEvent(void) dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT); Stage::GetCurrent().Add(dummy); - dummy.MouseWheelEventSignal().Connect(&MouseWheelEventCallback); + dummy.WheelEventSignal().Connect(&WheelEventCallback); application.Render(); application.SendNotification(); application.Render(); application.SendNotification(); - // simulate a mouse wheel event + // simulate a wheel event Vector2 screenCoordinates( 20.0f, 20.0f ); - Integration::MouseWheelEvent event(0, 0u, screenCoordinates, 1, 1000u); - application.ProcessEvent(event); + Integration::WheelEvent event( Integration::WheelEvent::MOUSE_WHEEL, 0, 0u, screenCoordinates, 1, 1000u ); + application.ProcessEvent( event ); Stage::GetCurrent().Remove(dummy); } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp index 3dcc6e8..82527f4 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ItemView.cpp @@ -525,7 +525,7 @@ int UtcDaliItemViewScrollToItem(void) END_TEST; } -int UtcDaliItemViewSetAndGetMouseWheelScrollDistanceStep(void) +int UtcDaliItemViewSetAndGetWheelScrollDistanceStep(void) { ToolkitTestApplication application; @@ -533,11 +533,11 @@ int UtcDaliItemViewSetAndGetMouseWheelScrollDistanceStep(void) TestItemFactory factory; ItemView view = ItemView::New(factory); - // Set the scroll distance step for the mouse wheel event to be 100.0f - view.SetMouseWheelScrollDistanceStep(100.0f); + // Set the scroll distance step for the wheel event to be 100.0f + view.SetWheelScrollDistanceStep(100.0f); // Check the scroll distance step is 100.0f - DALI_TEST_EQUALS(view.GetMouseWheelScrollDistanceStep(), 100.0f, TEST_LOCATION ); + DALI_TEST_EQUALS(view.GetWheelScrollDistanceStep(), 100.0f, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp index 6d38d5e..f2f0461 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ScrollView.cpp @@ -1511,17 +1511,17 @@ int UtcDaliToolkitScrollViewSetMinimumDistanceForFlickP(void) END_TEST; } -int UtcDaliToolkitScrollViewSetMouseWheelScrollDistanceStepP(void) +int UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP(void) { ToolkitTestApplication application; - tet_infoline(" UtcDaliToolkitScrollViewSetMouseWheelScrollDistanceStepP"); + tet_infoline(" UtcDaliToolkitScrollViewSetWheelScrollDistanceStepP"); ScrollView scrollView = ScrollView::New(); // Disable Refresh signal (TET environment cannot use adaptor's Timer) - scrollView.SetMouseWheelScrollDistanceStep(Vector2(30.0f, 15.0f)); - DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION ); - scrollView.SetMouseWheelScrollDistanceStep(Vector2(60.0f, 30.0f)); - DALI_TEST_EQUALS( scrollView.GetMouseWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION); + scrollView.SetWheelScrollDistanceStep(Vector2(30.0f, 15.0f)); + DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(30.0f, 15.0f), TEST_LOCATION ); + scrollView.SetWheelScrollDistanceStep(Vector2(60.0f, 30.0f)); + DALI_TEST_EQUALS( scrollView.GetWheelScrollDistanceStep(), Vector2(60.0f, 30.0f), TEST_LOCATION); END_TEST; } diff --git a/dali-toolkit/internal/controls/popup/popup-impl.cpp b/dali-toolkit/internal/controls/popup/popup-impl.cpp index 0a58b7c..dd4c3d5 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.cpp +++ b/dali-toolkit/internal/controls/popup/popup-impl.cpp @@ -423,7 +423,7 @@ void Popup::CreateBacking() mLayer.Add( mBacking ); mBacking.SetOpacity(0.0f); mBacking.TouchedSignal().Connect( this, &Popup::OnBackingTouched ); - mBacking.MouseWheelEventSignal().Connect(this, &Popup::OnBackingMouseWheelEvent); + mBacking.WheelEventSignal().Connect(this, &Popup::OnBackingWheelEvent); } void Popup::CreateDialog() @@ -611,9 +611,9 @@ bool Popup::OnBackingTouched(Actor actor, const TouchEvent& event) return true; } -bool Popup::OnBackingMouseWheelEvent(Actor actor, const MouseWheelEvent& event) +bool Popup::OnBackingWheelEvent(Actor actor, const WheelEvent& event) { - // consume mouse wheel event in dimmed backing actor + // consume wheel event in dimmed backing actor return true; } diff --git a/dali-toolkit/internal/controls/popup/popup-impl.h b/dali-toolkit/internal/controls/popup/popup-impl.h index ccf7ebb..3d361fe 100755 --- a/dali-toolkit/internal/controls/popup/popup-impl.h +++ b/dali-toolkit/internal/controls/popup/popup-impl.h @@ -215,12 +215,12 @@ private: bool OnBackingTouched(Actor actor, const TouchEvent& event); /** - * Signal occurs when the mouse wheel event is occured on dimmed backing for the Popup. - * @param[in] actor The Actor got mouse wheel - * @param[in] event The Mouse Wheel Event. + * Signal occurs when the wheel event is occured on dimmed backing for the Popup. + * @param[in] actor The Actor got wheel + * @param[in] event The Wheel Event. * @return Whether to consume event or not. */ - bool OnBackingMouseWheelEvent(Actor actor, const MouseWheelEvent& event); + bool OnBackingWheelEvent(Actor actor, const WheelEvent& event); /** * Signal occurs when the dialog has been touched. 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 ddf9427..972d04f 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 @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -57,13 +57,13 @@ DALI_TYPE_REGISTRATION_END() const float DEFAULT_MINIMUM_SWIPE_SPEED = 1.0f; const float DEFAULT_MINIMUM_SWIPE_DISTANCE = 3.0f; -const float DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION = 0.1f; +const float DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION = 0.1f; const float DEFAULT_MINIMUM_SWIPE_DURATION = 0.45f; const float DEFAULT_MAXIMUM_SWIPE_DURATION = 2.6f; const float DEFAULT_REFRESH_INTERVAL_LAYOUT_POSITIONS = 20.0f; // 1 updates per 20 items -const int MOUSE_WHEEL_EVENT_FINISHED_TIME_OUT = 500; // 0.5 second +const int WHEEL_EVENT_FINISHED_TIME_OUT = 500; // 0.5 second const float DEFAULT_ANCHORING_DURATION = 1.0f; // 1 second @@ -276,7 +276,7 @@ Dali::Toolkit::ItemView ItemView::New(ItemFactory& factory) } ItemView::ItemView(ItemFactory& factory) -: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | REQUIRES_MOUSE_WHEEL_EVENTS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ), +: Scrollable( ControlBehaviour( DISABLE_SIZE_NEGOTIATION | REQUIRES_WHEEL_EVENTS | REQUIRES_KEYBOARD_NAVIGATION_SUPPORT ) ), mItemFactory(factory), mActiveLayout(NULL), mAnimatingOvershootOn(false), @@ -287,7 +287,7 @@ ItemView::ItemView(ItemFactory& factory) mRefreshOrderHint(true/*Refresh item 0 first*/), mMinimumSwipeSpeed(DEFAULT_MINIMUM_SWIPE_SPEED), mMinimumSwipeDistance(DEFAULT_MINIMUM_SWIPE_DISTANCE), - mMouseWheelScrollDistanceStep(0.0f), + mWheelScrollDistanceStep(0.0f), mScrollDistance(0.0f), mScrollSpeed(0.0f), mTotalPanDisplacement(Vector2::ZERO), @@ -308,12 +308,12 @@ void ItemView::OnInitialize() SetOvershootEnabled(true); Vector2 stageSize = Stage::GetCurrent().GetSize(); - mMouseWheelScrollDistanceStep = stageSize.y * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION; + mWheelScrollDistanceStep = stageSize.y * DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION; EnableGestureDetection(Gesture::Type(Gesture::Pan)); - mMouseWheelEventFinishedTimer = Timer::New( MOUSE_WHEEL_EVENT_FINISHED_TIME_OUT ); - mMouseWheelEventFinishedTimer.TickSignal().Connect( this, &ItemView::OnMouseWheelEventFinished ); + mWheelEventFinishedTimer = Timer::New( WHEEL_EVENT_FINISHED_TIME_OUT ); + mWheelEventFinishedTimer.TickSignal().Connect( this, &ItemView::OnWheelEventFinished ); SetRefreshInterval(DEFAULT_REFRESH_INTERVAL_LAYOUT_POSITIONS); } @@ -500,14 +500,14 @@ float ItemView::GetMinimumSwipeDistance() const return mMinimumSwipeDistance; } -void ItemView::SetMouseWheelScrollDistanceStep(float step) +void ItemView::SetWheelScrollDistanceStep(float step) { - mMouseWheelScrollDistanceStep = step; + mWheelScrollDistanceStep = step; } -float ItemView::GetMouseWheelScrollDistanceStep() const +float ItemView::GetWheelScrollDistanceStep() const { - return mMouseWheelScrollDistanceStep; + return mWheelScrollDistanceStep; } void ItemView::SetAnchoring(bool enabled) @@ -986,14 +986,14 @@ bool ItemView::OnTouchEvent(const TouchEvent& event) return true; // consume since we're potentially scrolling } -bool ItemView::OnMouseWheelEvent(const MouseWheelEvent& event) +bool ItemView::OnWheelEvent(const WheelEvent& event) { - // Respond the mouse wheel event to scroll + // Respond the wheel event to scroll if (mActiveLayout) { Actor self = Self(); const Vector3 layoutSize = Self().GetCurrentSize(); - float layoutPositionDelta = GetCurrentLayoutPosition(0) - (event.z * mMouseWheelScrollDistanceStep * mActiveLayout->GetScrollSpeedFactor()); + float layoutPositionDelta = GetCurrentLayoutPosition(0) - (event.z * mWheelScrollDistanceStep * mActiveLayout->GetScrollSpeedFactor()); float firstItemScrollPosition = ClampFirstItemPosition(layoutPositionDelta, layoutSize, *mActiveLayout); self.SetProperty(Toolkit::ItemView::Property::LAYOUT_POSITION, firstItemScrollPosition ); @@ -1002,23 +1002,23 @@ bool ItemView::OnMouseWheelEvent(const MouseWheelEvent& event) mRefreshEnabled = true; } - if (mMouseWheelEventFinishedTimer.IsRunning()) + if (mWheelEventFinishedTimer.IsRunning()) { - mMouseWheelEventFinishedTimer.Stop(); + mWheelEventFinishedTimer.Stop(); } - mMouseWheelEventFinishedTimer.Start(); + mWheelEventFinishedTimer.Start(); return true; } -bool ItemView::OnMouseWheelEventFinished() +bool ItemView::OnWheelEventFinished() { if (mActiveLayout) { RemoveAnimation(mScrollAnimation); - // No more mouse wheel events coming. Do the anchoring if enabled. + // No more wheel events coming. Do the anchoring if enabled. mScrollAnimation = DoAnchoring(); if (mScrollAnimation) { 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 5260c5c..995e4eb 100644 --- a/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h +++ b/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.h @@ -121,14 +121,14 @@ public: float GetMinimumSwipeDistance() const; /** - * @copydoc Toolkit::ItemView::SetMouseWheelScrollDistanceStep + * @copydoc Toolkit::ItemView::SetWheelScrollDistanceStep */ - void SetMouseWheelScrollDistanceStep(float step); + void SetWheelScrollDistanceStep(float step); /** - * @copydoc Toolkit::ItemView::GetMouseWheelScrollDistanceStep + * @copydoc Toolkit::ItemView::GetWheelScrollDistanceStep */ - float GetMouseWheelScrollDistanceStep() const; + float GetWheelScrollDistanceStep() const; /** * @copydoc Toolkit::ItemView::SetAnchoring @@ -343,11 +343,11 @@ private: // From CustomActorImpl virtual bool OnTouchEvent(const TouchEvent& event); /** - * From CustomActorImpl; called after a mouse-wheel-event is received by the owning actor. - * @param[in] event The mouse wheel event. + * From CustomActorImpl; called after a wheel-event is received by the owning actor. + * @param[in] event The wheel event. * @return True if the event should be consumed. */ - virtual bool OnMouseWheelEvent(const MouseWheelEvent& event); + virtual bool OnWheelEvent(const WheelEvent& event); private: // From Control @@ -477,10 +477,10 @@ private: void OnOvershootOnFinished(Animation& animation); /** - * This is called after a timeout when no new mouse wheel event is received for a certain period of time. + * This is called after a timeout when no new wheel event is received for a certain period of time. * @return will return false; one-shot timer. */ - bool OnMouseWheelEventFinished(); + bool OnWheelEventFinished(); /** * Stops and removes animation if exists. @@ -572,7 +572,7 @@ private: float mMinimumSwipeSpeed; float mMinimumSwipeDistance; - float mMouseWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates for each mouse wheel event received. + float mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates for each wheel event received. float mScrollDistance; float mScrollSpeed; @@ -581,7 +581,7 @@ private: float mScrollOvershoot; bool mIsFlicking; - Timer mMouseWheelEventFinishedTimer; ///< The timer to determine whether there is no mouse wheel event received for a certain period of time. + Timer mWheelEventFinishedTimer; ///< The timer to determine whether there is no wheel event received for a certain period of time. Dali::Gesture::State mGestureState; 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 57e7e75..ba36907 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 @@ -22,7 +22,7 @@ #include // for strcmp #include #include -#include +#include #include #include #include @@ -69,7 +69,7 @@ const float DEFAULT_MIN_FLICK_SPEED_THRESHOLD(500.0f); ///< Minimum const float FREE_FLICK_SPEED_THRESHOLD = 200.0f; ///< Free-Flick threshold in pixels/ms const float AUTOLOCK_AXIS_MINIMUM_DISTANCE2 = 100.0f; ///< Auto-lock axis after minimum distance squared. const float FLICK_ORTHO_ANGLE_RANGE = 75.0f; ///< degrees. (if >45, then supports diagonal flicking) -const Vector2 DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION = Vector2(0.17f, 0.1f); ///< The step of horizontal scroll distance in the proportion of stage size for each mouse wheel event received. +const Vector2 DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION = Vector2(0.17f, 0.1f); ///< The step of horizontal scroll distance in the proportion of stage size for each wheel event received. const unsigned long MINIMUM_TIME_BETWEEN_DOWN_AND_UP_FOR_RESET( 150u ); const float TOUCH_DOWN_TIMER_INTERVAL = 100.0f; const float DEFAULT_SCROLL_UPDATE_DISTANCE( 30.0f ); ///< Default distance to travel in pixels for scroll update signal @@ -578,7 +578,7 @@ Dali::Toolkit::ScrollView ScrollView::New() } ScrollView::ScrollView() -: ScrollBase( ControlBehaviour( REQUIRES_MOUSE_WHEEL_EVENTS ) ), // Enable size negotiation +: ScrollBase( ControlBehaviour( REQUIRES_WHEEL_EVENTS ) ), // Enable size negotiation mTouchDownTime(0u), mGestureStackDepth(0), mScrollStateFlags(0), @@ -598,7 +598,7 @@ ScrollView::ScrollView() mFrictionCoefficient(DEFAULT_FRICTION_COEFFICIENT), mFlickSpeedCoefficient(DEFAULT_FLICK_SPEED_COEFFICIENT), mMaxFlickSpeed(DEFAULT_MAX_FLICK_SPEED), - mMouseWheelScrollDistanceStep(Vector2::ZERO), + mWheelScrollDistanceStep(Vector2::ZERO), mInAccessibilityPan(false), mInitialized(false), mScrolling(false), @@ -635,7 +635,7 @@ void ScrollView::OnInitialize() mScrollPostPosition = mScrollPrePosition = Vector2::ZERO; - mMouseWheelScrollDistanceStep = Stage::GetCurrent().GetSize() * DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION; + mWheelScrollDistanceStep = Stage::GetCurrent().GetSize() * DEFAULT_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION; mInitialized = true; @@ -1083,14 +1083,14 @@ void ScrollView::SetMaxFlickSpeed(float speed) mMaxFlickSpeed = speed; } -void ScrollView::SetMouseWheelScrollDistanceStep(Vector2 step) +void ScrollView::SetWheelScrollDistanceStep(Vector2 step) { - mMouseWheelScrollDistanceStep = step; + mWheelScrollDistanceStep = step; } -Vector2 ScrollView::GetMouseWheelScrollDistanceStep() const +Vector2 ScrollView::GetWheelScrollDistanceStep() const { - return mMouseWheelScrollDistanceStep; + return mWheelScrollDistanceStep; } unsigned int ScrollView::GetCurrentPage() const @@ -2042,11 +2042,11 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event) return true; } -bool ScrollView::OnMouseWheelEvent(const MouseWheelEvent& event) +bool ScrollView::OnWheelEvent(const WheelEvent& event) { if(!mSensitive) { - // Ignore this mouse wheel event, if scrollview is insensitive. + // Ignore this wheel event, if scrollview is insensitive. return false; } @@ -2058,7 +2058,7 @@ bool ScrollView::OnMouseWheelEvent(const MouseWheelEvent& event) if(mRulerX->GetType() == Ruler::Free) { // Free panning mode - targetScrollPosition.x += event.z * mMouseWheelScrollDistanceStep.x; + targetScrollPosition.x += event.z * mWheelScrollDistanceStep.x; ClampPosition(targetScrollPosition); ScrollTo(-targetScrollPosition); } @@ -2074,7 +2074,7 @@ bool ScrollView::OnMouseWheelEvent(const MouseWheelEvent& event) if(mRulerY->GetType() == Ruler::Free) { // Free panning mode - targetScrollPosition.y += event.z * mMouseWheelScrollDistanceStep.y; + targetScrollPosition.y += event.z * mWheelScrollDistanceStep.y; ClampPosition(targetScrollPosition); ScrollTo(-targetScrollPosition); } 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 be978a7..86577c7 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 @@ -323,14 +323,14 @@ public: void SetMaxFlickSpeed(float speed); /** - * @copydoc Toolkit::ScrollView::GetMouseWheelScrollDistanceStep + * @copydoc Toolkit::ScrollView::GetWheelScrollDistanceStep */ - Vector2 GetMouseWheelScrollDistanceStep() const; + Vector2 GetWheelScrollDistanceStep() const; /** - * @copydoc Toolkit::ScrollView::SetMouseWheelScrollDistanceStep + * @copydoc Toolkit::ScrollView::SetWheelScrollDistanceStep */ - void SetMouseWheelScrollDistanceStep(Vector2 step); + void SetWheelScrollDistanceStep(Vector2 step); /** * @copydoc Toolkit::ScrollView::GetCurrentPage @@ -535,11 +535,11 @@ private: // private overriden functions from CustomActorImpl and Controls virtual bool OnTouchEvent(const TouchEvent& event); /** - * From CustomActorImpl; called after a mouse-wheel-event is received by the owning actor. - * @param[in] event The mouse wheel event. + * From CustomActorImpl; called after a wheel-event is received by the owning actor. + * @param[in] event The wheel event. * @return True if the event should be consumed. */ - virtual bool OnMouseWheelEvent(const MouseWheelEvent& event); + virtual bool OnWheelEvent(const WheelEvent& event); /** * @copydoc Toolkit::Control::OnInitialize() @@ -883,7 +883,7 @@ private: float mFlickSpeedCoefficient; ///< Flick velocity coefficient. Input touch velocity is multiplied by this. float mMaxFlickSpeed; ///< Maximum flick speed. Maximum speed of flick in stage.lengths/sec. - Vector2 mMouseWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each mouse wheel event received. + Vector2 mWheelScrollDistanceStep; ///< The step of scroll distance in actor coordinates in X and Y axes for each wheel event received. //ScrollInternalConstraintsPtr mScrollInternalConstraints; Constraint mScrollMainInternalPrePositionConstraint; diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 7393a3a..eb7c14b 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -947,7 +947,7 @@ bool Control::OnKeyEvent(const KeyEvent& event) return false; // Do not consume } -bool Control::OnMouseWheelEvent(const MouseWheelEvent& event) +bool Control::OnWheelEvent(const WheelEvent& event) { return false; // Do not consume } diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index 8ffcbda..ce46319 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -316,9 +316,9 @@ protected: // From CustomActorImpl, not to be used by application developers virtual bool OnKeyEvent( const KeyEvent& event ); /** - * @copydoc CustomActorImpl::OnMouseWheelEvent() + * @copydoc CustomActorImpl::OnWheelEvent() */ - virtual bool OnMouseWheelEvent( const MouseWheelEvent& event ); + virtual bool OnWheelEvent( const WheelEvent& event ); /** * @copydoc CustomActorImpl::OnRelayout() diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp index 1ee9b3d..6daa933 100644 --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.cpp @@ -128,14 +128,14 @@ float ItemView::GetMinimumSwipeDistance() const return GetImpl(*this).GetMinimumSwipeDistance(); } -void ItemView::SetMouseWheelScrollDistanceStep(float step) +void ItemView::SetWheelScrollDistanceStep(float step) { - GetImpl(*this).SetMouseWheelScrollDistanceStep(step); + GetImpl(*this).SetWheelScrollDistanceStep(step); } -float ItemView::GetMouseWheelScrollDistanceStep() const +float ItemView::GetWheelScrollDistanceStep() const { - return GetImpl(*this).GetMouseWheelScrollDistanceStep(); + return GetImpl(*this).GetWheelScrollDistanceStep(); } void ItemView::SetAnchoring(bool enabled) diff --git a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h index 60a2312..ca51a44 100644 --- a/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h +++ b/dali-toolkit/public-api/controls/scrollable/item-view/item-view.h @@ -217,18 +217,18 @@ public: float GetMinimumSwipeDistance() const; /** - * @brief Set the step of scroll distance in actor coordinates for each mouse wheel event received. + * @brief Set the step of scroll distance in actor coordinates for each wheel event received. * * @param[in] step The step of scroll distance(pixel). */ - void SetMouseWheelScrollDistanceStep(float step); + void SetWheelScrollDistanceStep(float step); /** - * @brief Get the step of scroll distance in actor coordinates for each mouse wheel event received. + * @brief Get the step of scroll distance in actor coordinates for each wheel event received. * * @return The step of scroll distance(pixel) */ - float GetMouseWheelScrollDistanceStep() const; + float GetWheelScrollDistanceStep() const; /** * @brief Set whether to enable the animation for the layout to diff --git a/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp b/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp index 08bd1ff..398939e 100644 --- a/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp +++ b/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp @@ -486,14 +486,14 @@ void ScrollView::SetMaxFlickSpeed(float speed) GetImpl(*this).SetMaxFlickSpeed(speed); } -Vector2 ScrollView::GetMouseWheelScrollDistanceStep() const +Vector2 ScrollView::GetWheelScrollDistanceStep() const { - return GetImpl(*this).GetMouseWheelScrollDistanceStep(); + return GetImpl(*this).GetWheelScrollDistanceStep(); } -void ScrollView::SetMouseWheelScrollDistanceStep(Vector2 step) +void ScrollView::SetWheelScrollDistanceStep(Vector2 step) { - GetImpl(*this).SetMouseWheelScrollDistanceStep(step); + GetImpl(*this).SetWheelScrollDistanceStep(step); } Vector2 ScrollView::GetCurrentScrollPosition() const diff --git a/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h b/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h index 11f166a..fb9d5cb 100644 --- a/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h +++ b/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h @@ -840,24 +840,24 @@ public: /** * @brief Gets the step of scroll distance in actor coordinates for - * each mouse wheel event received in free panning mode. + * each wheel event received in free panning mode. * * @return The step of scroll distance(pixel) in X and Y axes. */ - Vector2 GetMouseWheelScrollDistanceStep() const; + Vector2 GetWheelScrollDistanceStep() const; /** * @brief Sets the step of scroll distance in actor coordinates for - * each mouse wheel event received in free panning mode. + * each wheel event received in free panning mode. * * @param[in] step The step of scroll distance(pixel) in X and Y axes. * * @note: If snap points are defined in the rulers, it will always * scroll to the next snap point towards the scroll direction while - * receiving the mouse wheel events. + * receiving the wheel events. * */ - void SetMouseWheelScrollDistanceStep(Vector2 step); + void SetWheelScrollDistanceStep(Vector2 step); /** * @brief Retrieves current scroll position. diff --git a/plugins/dali-script-v8/src/events/event-object-generator.cpp b/plugins/dali-script-v8/src/events/event-object-generator.cpp index f41f5ac..28837ab 100644 --- a/plugins/dali-script-v8/src/events/event-object-generator.cpp +++ b/plugins/dali-script-v8/src/events/event-object-generator.cpp @@ -231,23 +231,28 @@ v8::Handle EventObjectGenerator::CreateHoverEvent( v8::Isolate* isol return handleScope.Escape( hoverObject ); } -v8::Handle EventObjectGenerator::CreateMouseWheelEvent( v8::Isolate* isolate, const MouseWheelEvent& wheelEvent) +v8::Handle EventObjectGenerator::CreateWheelEvent( v8::Isolate* isolate, const WheelEvent& wheelEvent) { - // we are creating a mouse wheel event object that looks like this + // we are creating a wheel event object that looks like this // + // event.type = "mouseWheel" or "customWheel" type of the wheel event // event.direction = "vertical" or "horizontal" direction the wheel is being rolled // event.shiftPressed = boolean, shift key is held // event.ctrlPressed = boolean, ctrl key is held // event.altPressed = boolean, alt key is held // event.keyModifiers = bitmask of keys pressed // event.point {x,y} = The co-ordinates of the mouse cursor relative to the top-left of the screen when the wheel is being rolled. - // event.rolled = offset of mouse wheel rolling, positive = rolling down, negative = rolling up + // event.rolled = offset of wheel rolling, positive = rolling down or clockwise, negative = rolling up or counter-clockwise // event.timestamp = The time (in ms) that the touch event occurred v8::EscapableHandleScope handleScope( isolate ); v8::Local wheelObject = v8::Object::New( isolate ); + // Set the type + std::string type = wheelEvent.type ? "mouseWheel" : "customWheel"; + wheelObject->Set( v8::String::NewFromUtf8( isolate, "type" ), v8::String::NewFromUtf8( isolate, type.c_str() ) ); + // Set the direction std::string direction = wheelEvent.direction ? "vertical" : "horizontal"; wheelObject->Set( v8::String::NewFromUtf8( isolate, "direction" ), v8::String::NewFromUtf8( isolate, direction.c_str() ) ); diff --git a/plugins/dali-script-v8/src/events/event-object-generator.h b/plugins/dali-script-v8/src/events/event-object-generator.h index 8083255..d1d6296 100644 --- a/plugins/dali-script-v8/src/events/event-object-generator.h +++ b/plugins/dali-script-v8/src/events/event-object-generator.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -44,7 +44,7 @@ namespace EventObjectGenerator v8::Handle CreateTouchEvent( v8::Isolate* isolate, const TouchEvent& touchEvent); v8::Handle CreateHoverEvent( v8::Isolate* isolate, const HoverEvent& hoverEvent); - v8::Handle CreateMouseWheelEvent( v8::Isolate* isolate, const MouseWheelEvent& wheelEvent); + v8::Handle CreateWheelEvent( v8::Isolate* isolate, const WheelEvent& wheelEvent); v8::Handle CreateKeyEvent( v8::Isolate* isolate, const KeyEvent& keyEvent); v8::Handle CreatePanGesture( v8::Isolate* isolate, const PanGesture& panGesture); diff --git a/plugins/dali-script-v8/src/signals/dali-any-javascript-converter.cpp b/plugins/dali-script-v8/src/signals/dali-any-javascript-converter.cpp index 883fcbe..faeaf25 100644 --- a/plugins/dali-script-v8/src/signals/dali-any-javascript-converter.cpp +++ b/plugins/dali-script-v8/src/signals/dali-any-javascript-converter.cpp @@ -74,9 +74,9 @@ v8::Local DaliAnyConverter::ConvertToJavaScriptObject(v8::Isolate* is { returnValue = EventObjectGenerator::CreateHoverEvent( isolate, value.Get() ); } - else if( typeInfo == typeid( Dali::MouseWheelEvent ) ) + else if( typeInfo == typeid( Dali::WheelEvent ) ) { - returnValue = EventObjectGenerator::CreateMouseWheelEvent( isolate, value.Get() ); + returnValue = EventObjectGenerator::CreateWheelEvent( isolate, value.Get() ); } else if( typeInfo == typeid( Dali::KeyEvent ) ) { diff --git a/plugins/dali-script-v8/src/signals/signal-manager.cpp b/plugins/dali-script-v8/src/signals/signal-manager.cpp index d8359e2..8adcabd 100644 --- a/plugins/dali-script-v8/src/signals/signal-manager.cpp +++ b/plugins/dali-script-v8/src/signals/signal-manager.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include @@ -55,7 +55,7 @@ namespace // un-named namespace { const char* const SIGNAL_TOUCHED = "touched"; const char* const SIGNAL_HOVERED = "hovered"; -const char* const SIGNAL_MOUSE_WHEEL_EVENT = "mouse-wheel-event"; +const char* const SIGNAL_WHEEL_EVENT = "wheel-event"; const char* const SIGNAL_ON_STAGE = "on-stage"; const char* const SIGNAL_OFF_STAGE = "off-stage"; const char* const ANIMATION_SIGNAL_FINISHED = "finished"; @@ -205,7 +205,7 @@ public: returnValue.Get(ret); return ret; } - bool OnMouseWheel( Actor actor, const MouseWheelEvent& event) + bool OnWheel( Actor actor, const WheelEvent& event) { std::vector< Dali::Any > arguments; Dali::Any returnValue(false); @@ -390,9 +390,9 @@ void ActorConnection( v8::Isolate* isolate, { actor.HoveredSignal().Connect( callback, &ActorCallback::OnHover ); } - else if ( strcmp( signalName.c_str(), SIGNAL_MOUSE_WHEEL_EVENT ) == 0 ) + else if ( strcmp( signalName.c_str(), SIGNAL_WHEEL_EVENT ) == 0 ) { - actor.MouseWheelEventSignal().Connect( callback, &ActorCallback::OnMouseWheel ); + actor.WheelEventSignal().Connect( callback, &ActorCallback::OnWheel ); } else if ( strcmp( signalName.c_str(), SIGNAL_ON_STAGE ) == 0 ) { -- 2.7.4