// Confirm the final X coord has snapped to exactly one page ahead of the start page.
DALI_TEST_EQUALS( viewPageSize.width, scrollView.GetCurrentScrollPosition().x, Math::MACHINE_EPSILON_0, TEST_LOCATION );
+ // Change scroll mode during pan, should not crash
+ PerformGestureSwipe( application, startPos, direction, frames - 1, time, false );
+ try
+ {
+ scrollView.SetScrollSensitive(false);
+ DALI_TEST_CHECK(true);
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(false);
+ }
+
END_TEST;
}
application.SendNotification();
application.Render();
+ // Pan Press
+ TestGenerateMiniPan(application);
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
application.SendNotification();
application.Render();
+ // Pan the grab handle
+ uint32_t time = 100;
+ TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
+ TestMovePan( application, Vector2(10.0f, 30.0f), time );
+ TestEndPan( application, Vector2(10.0f, 50.0f), time);
+ application.SendNotification();
+ application.Render();
+
+
// Release the grab handle.
event = Dali::Integration::TouchEvent();
event.AddPoint( GetPointUpInside( touchPos ) );
#include <dali/devel-api/adaptor-framework/sound-player.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/devel-api/events/hit-test-algorithm.h>
+#include <dali/devel-api/events/pan-gesture-devel.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
Actor rootActor = Stage::GetCurrent().GetRootLayer();
- Dali::PanGesture pan( static_cast<Dali::Gesture::State>(panEvent.state) );
-
- pan.time = panEvent.time;
- pan.numberOfTouches = panEvent.numberOfTouches;
- pan.screenPosition = panEvent.currentPosition;
- pan.screenDisplacement = mPreviousPosition - panEvent.currentPosition;
- pan.screenVelocity.x = pan.screenDisplacement.x / panEvent.timeDelta;
- pan.screenVelocity.y = pan.screenDisplacement.y / panEvent.timeDelta;
+ Dali::PanGesture pan = DevelPanGesture::New( static_cast<Dali::Gesture::State>(panEvent.state) );
+ DevelPanGesture::SetTime( pan, panEvent.time );
+ DevelPanGesture::SetNumberOfTouches( pan, panEvent.numberOfTouches );
+ DevelPanGesture::SetScreenPosition( pan, panEvent.currentPosition );
+ DevelPanGesture::SetScreenDisplacement( pan, mPreviousPosition - panEvent.currentPosition );
+ DevelPanGesture::SetScreenVelocity( pan, Vector2( pan.GetScreenDisplacement().x / panEvent.timeDelta, pan.GetScreenDisplacement().y / panEvent.timeDelta ) );
// Only handle the pan gesture when the current focused actor is scrollable or within a scrollable actor
while(mCurrentGesturedActor && mCurrentGesturedActor != rootActor && !handled)
{
Vector2 localCurrent;
control.ScreenToLocal( localCurrent.x, localCurrent.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
- pan.position = localCurrent;
+ DevelPanGesture::SetPosition( pan, localCurrent );
Vector2 localPrevious;
control.ScreenToLocal( localPrevious.x, localPrevious.y, mPreviousPosition.x, mPreviousPosition.y );
- pan.displacement = localCurrent - localPrevious;
- pan.velocity.x = pan.displacement.x / panEvent.timeDelta;
- pan.velocity.y = pan.displacement.y / panEvent.timeDelta;
+ DevelPanGesture::SetDisplacement( pan, localCurrent - localPrevious );
+ DevelPanGesture::SetVelocity( pan, Vector2( pan.GetDisplacement().x / panEvent.timeDelta, pan.GetDisplacement().y / panEvent.timeDelta ));
handled = GetImplementation( control ).OnAccessibilityPan(pan);
}
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * 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.
void PageTurnView::OnPan( const PanGesture& gesture )
{
// the pan gesture is attached to control itself instead of each page
- switch( gesture.state )
+ switch( gesture.GetState() )
{
case Gesture::Started:
{
// check whether the undergoing turning page number already reaches the maximum allowed
if( mPageUpdated && mAnimatingCount< MAXIMUM_TURNING_NUM && mSlidingCount < 1 )
{
- SetPanActor( gesture.position ); // determine which page actor is panned
+ const Vector2& position = gesture.GetPosition();
+ SetPanActor( position ); // determine which page actor is panned
if( mTurningPageIndex != -1 && mPages[mTurningPageIndex % NUMBER_OF_CACHED_PAGES].actor.GetParent() != Self()) // if the page is added to turning layer,it is undergoing an animation currently
{
mTurningPageIndex = -1;
}
- PanStarted( SetPanPosition( gesture.position ) ); // pass in the pan position in the local page coordinate
+ PanStarted( SetPanPosition( position ) ); // pass in the pan position in the local page coordinate
}
else
{
}
case Gesture::Continuing:
{
- PanContinuing( SetPanPosition( gesture.position ) ); // pass in the pan position in the local page coordinate
+ PanContinuing( SetPanPosition( gesture.GetPosition() ) ); // pass in the pan position in the local page coordinate
break;
}
case Gesture::Finished:
case Gesture::Cancelled:
{
- PanFinished( SetPanPosition( gesture.position ), gesture.GetSpeed() );
+ PanFinished( SetPanPosition( gesture.GetPosition() ), gesture.GetSpeed() );
break;
}
case Gesture::Clear:
mIndicatorHideDuration(DEFAULT_INDICATOR_HIDE_DURATION),
mTransientIndicatorDuration(DEFAULT_INDICATOR_TRANSIENT_DURATION),
mScrollStart(0.0f),
- mGestureDisplacement( Vector3::ZERO ),
+ mGestureDisplacement( Vector2::ZERO ),
mCurrentScrollPosition(0.0f),
mIndicatorHeightPolicy(Toolkit::ScrollBar::VARIABLE),
mIndicatorFixedHeight(DEFAULT_INDICATOR_FIXED_HEIGHT),
{
Dali::Toolkit::ItemView itemView = Dali::Toolkit::ItemView::DownCast(scrollableHandle);
- switch(gesture.state)
+ switch(gesture.GetState())
{
- case Gesture::Started:
+ case Dali::Gesture::Started:
{
if( !mPanProcessTimer )
{
ShowIndicator();
mScrollStart = scrollableHandle.GetCurrentProperty< float >( mPropertyScrollPosition );
- mGestureDisplacement = Vector3::ZERO;
+ mGestureDisplacement = Vector2::ZERO;
mIsPanning = true;
break;
}
- case Gesture::Continuing:
+ case Dali::Gesture::Continuing:
{
- mGestureDisplacement.x += gesture.displacement.x;
- mGestureDisplacement.y += gesture.displacement.y;
+ mGestureDisplacement += gesture.GetDisplacement();
float minScrollPosition = scrollableHandle.GetCurrentProperty<float>( mPropertyMinScrollPosition );
float maxScrollPosition = scrollableHandle.GetCurrentProperty<float>( mPropertyMaxScrollPosition );
float mTransientIndicatorDuration; ///< The duration before hiding transient indicator
float mScrollStart; ///< Scroll Start position (start of drag)
- Vector3 mGestureDisplacement; ///< Gesture Displacement.
+ Vector2 mGestureDisplacement; ///< Gesture Displacement.
float mCurrentScrollPosition; ///< The current scroll position updated by the pan gesture
return;
}
- mGestureState = gesture.state;
+ mGestureState = gesture.GetState();
switch (mGestureState)
{
case Gesture::Continuing:
{
- mScrollDistance = CalculateScrollDistance(gesture.displacement, *mActiveLayout);
+ const Vector2& displacement = gesture.GetDisplacement();
+ mScrollDistance = CalculateScrollDistance(displacement, *mActiveLayout);
mScrollSpeed = Clamp((gesture.GetSpeed() * gesture.GetSpeed() * mActiveLayout->GetFlickSpeedFactor() * MILLISECONDS_PER_SECONDS), 0.0f, mActiveLayout->GetMaximumSwipeSpeed());
// Refresh order depends on the direction of the scroll; negative is towards the last item.
( firstItemScrollPosition <= mActiveLayout->GetMinimumLayoutPosition(mItemFactory.GetNumberOfItems(), layoutSize) &&
currentOvershoot > -1.0f ) )
{
- mTotalPanDisplacement += gesture.displacement;
+ mTotalPanDisplacement += displacement;
}
mScrollOvershoot = CalculateScrollOvershoot();
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/object/property-map.h>
#include <dali/devel-api/object/property-helper-devel.h>
+#include <dali/devel-api/events/pan-gesture-devel.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
// while the scroll view is panning, the state needs to be reset.
if ( mPanning )
{
- PanGesture cancelGesture( Gesture::Cancelled );
+ PanGesture cancelGesture = DevelPanGesture::New( Gesture::Cancelled );
OnPan( cancelGesture );
}
}
// translate Gesture input to get useful data...
- switch(gesture.state)
+ switch(gesture.GetState())
{
case Gesture::Started:
{
DALI_LOG_SCROLL_STATE("[0x%X] Pan Started", this);
- mPanStartPosition = gesture.position - gesture.displacement;
+ const Vector2& position = gesture.GetPosition();
+ mPanStartPosition = position - gesture.GetDisplacement();
UpdateLocalScrollProperties();
GestureStarted();
mPanning = true;
self.SetProperty( Toolkit::ScrollView::Property::PANNING, true );
- self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, Vector3(gesture.position.x, gesture.position.y, 0.0f) );
+ self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, Vector3(position.x, position.y, 0.0f) );
UpdateMainInternalConstraint();
Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle();
if ( mPanning )
{
DALI_LOG_SCROLL_STATE("[0x%X] Pan Continuing", this);
- GestureContinuing(gesture.screenDisplacement);
+ GestureContinuing(gesture.GetScreenDisplacement());
}
else
{
{
if ( mPanning )
{
- DALI_LOG_SCROLL_STATE("[0x%X] Pan %s", this, ( ( gesture.state == Gesture::Finished ) ? "Finished" : "Cancelled" ) );
+ DALI_LOG_SCROLL_STATE("[0x%X] Pan %s", this, ( ( gesture.GetState() == Gesture::Finished ) ? "Finished" : "Cancelled" ) );
UpdateLocalScrollProperties();
- mLastVelocity = gesture.velocity;
+ mLastVelocity = gesture.GetVelocity();
mPanning = false;
self.SetProperty( Toolkit::ScrollView::Property::PANNING, false );
} // end switch(gesture.state)
- OnGestureEx(gesture.state);
+ OnGestureEx(gesture.GetState());
}
void ScrollView::OnGestureEx(Gesture::State state)
// gesture.position is in local actor coordinates
if( mState != DISABLED )
{
- switch( gesture.state )
+ switch( gesture.GetState() )
{
case Gesture::Continuing:
{
if( mState == PRESSED )
{
- float value = MapBounds( MarkFilter ( MapPercentage( gesture.position ) ), GetLowerBound(), GetUpperBound() );
+ float value = MapBounds( MarkFilter ( MapPercentage( gesture.GetPosition() ) ), GetLowerBound(), GetUpperBound() );
SetValue( value );
DisplayPopup( value );
}
{
if( GetSnapToMarks() )
{
- float value = MapBounds( SnapToMark( MapPercentage( gesture.position ) ), GetLowerBound(), GetUpperBound() );
+ float value = MapBounds( SnapToMark( MapPercentage( gesture.GetPosition() ) ), GetLowerBound(), GetUpperBound() );
SetValue( value );
DisplayPopup( value );
}
// Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
Extents padding;
padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
- mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
+ const Vector2& localPoint = gesture.GetLocalPoint();
+ mController->TapEvent( gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top );
SetKeyInputFocus();
}
void TextEditor::OnPan( const PanGesture& gesture )
{
- mController->PanEvent( gesture.state, gesture.displacement );
+ mController->PanEvent( gesture.GetState(), gesture.GetDisplacement() );
}
void TextEditor::OnLongPress( const LongPressGesture& gesture )
}
Extents padding;
padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
- mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
+ const Vector2& localPoint = gesture.GetLocalPoint();
+ mController->LongPressEvent( gesture.GetState(), localPoint.x - padding.start, localPoint.y - padding.top );
SetKeyInputFocus();
}
// Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
Extents padding;
padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
- mController->TapEvent( gesture.numberOfTaps, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
+ const Vector2& localPoint = gesture.GetLocalPoint();
+ mController->TapEvent( gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top );
SetKeyInputFocus();
}
void TextField::OnPan( const PanGesture& gesture )
{
- mController->PanEvent( gesture.state, gesture.displacement );
+ mController->PanEvent( gesture.GetState(), gesture.GetDisplacement() );
}
void TextField::OnLongPress( const LongPressGesture& gesture )
}
Extents padding;
padding = Self().GetProperty<Extents>( Toolkit::Control::Property::PADDING );
- mController->LongPressEvent( gesture.state, gesture.localPoint.x - padding.start, gesture.localPoint.y - padding.top );
+ const Vector2& localPoint = gesture.GetLocalPoint();
+ mController->LongPressEvent( gesture.GetState(), localPoint.x - padding.start, localPoint.y - padding.top );
SetKeyInputFocus();
}
{
Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
- if(gesture.state == Gesture::Started)
+ Gesture::State state = gesture.GetState();
+
+ if(state == Gesture::Started)
{
- mDragLocalPosition = gesture.position;
+ mDragLocalPosition = gesture.GetPosition();
mPointDown = true;
mDragControl = control;
mFirstEnter.clear();
mShadowControl.SetProperty( Actor::Property::PARENT_ORIGIN, control.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ) );
mShadowControl.SetProperty( Actor::Property::ANCHOR_POINT,control.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ));
control.GetParent().Add(mShadowControl);
- SetPosition(gesture.screenPosition);
+ SetPosition(gesture.GetScreenPosition());
EmitStartedSignal(control);
}
- if(gesture.state == Gesture::Continuing)
+ if(state == Gesture::Continuing)
{
- Vector2 screenPosition = gesture.screenPosition;
+ Vector2 screenPosition = gesture.GetScreenPosition();
control.GetParent().ScreenToLocal(mLocalPosition.x, mLocalPosition.y, screenPosition.x, screenPosition.y);
mShadowControl.SetProperty( Actor::Property::POSITION, Vector2(mLocalPosition.x - mDragLocalPosition.x, mLocalPosition.y - mDragLocalPosition.y));
}
- if(gesture.state == Gesture::Finished)
+ if(state == Gesture::Finished)
{
mDragControl.GetParent().Remove(mShadowControl);
EmitEndedSignal(control);
void DoPan( HandleImpl& handle, HandleType type, const PanGesture& gesture )
{
- if( Gesture::Started == gesture.state )
+ Gesture::State state = gesture.GetState();
+ if( Gesture::Started == state )
{
handle.grabDisplacementX = handle.grabDisplacementY = 0.f;
handle.globalPosition.y = handle.position.y;
}
- handle.grabDisplacementX += gesture.displacement.x;
- handle.grabDisplacementY += ( handle.verticallyFlipped ? -gesture.displacement.y : gesture.displacement.y );
+ const Vector2& displacement = gesture.GetDisplacement();
+ handle.grabDisplacementX += displacement.x;
+ handle.grabDisplacementY += ( handle.verticallyFlipped ? -displacement.y : displacement.y );
const float x = handle.globalPosition.x + handle.grabDisplacementX;
const float y = handle.globalPosition.y + handle.grabDisplacementY + 0.5f * handle.lineHeight;
const float yVerticallyFlippedCorrected = y - ( handle.verticallyFlippedOnTouch ? handle.lineHeight : 0.f );
- if( ( Gesture::Started == gesture.state ) ||
- ( Gesture::Continuing == gesture.state ) )
+ if( ( Gesture::Started == state ) ||
+ ( Gesture::Continuing == state ) )
{
Vector2 targetSize;
mController.GetTargetSize( targetSize );
mIsHandlePanning = true;
}
- else if( ( Gesture::Finished == gesture.state ) ||
- ( Gesture::Cancelled == gesture.state ) )
+ else if( ( Gesture::Finished == state ) ||
+ ( Gesture::Cancelled == state ) )
{
if( mScrollTimer &&
( mScrollTimer.IsRunning() || mNotifyEndOfScroll ) )
mImpl->mStartingPinchScale = new Vector3;
}
- if( pinch.state == Gesture::Started )
+ if( pinch.GetState() == Gesture::Started )
{
*( mImpl->mStartingPinchScale ) = Self().GetCurrentProperty< Vector3 >( Actor::Property::SCALE );
}
- Self().SetProperty( Actor::Property::SCALE, *( mImpl->mStartingPinchScale ) * pinch.scale );
+ Self().SetProperty( Actor::Property::SCALE, *( mImpl->mStartingPinchScale ) * pinch.GetScale() );
}
void Control::OnPan( const PanGesture& pan )