return;
}
- if( gesture.state == Gesture::Continuing )
+ if( gesture.GetState() == Gesture::Continuing )
{
- if( gesture.displacement.x < 0)
+ const Vector2& displacement = gesture.GetDisplacement();
+ if( displacement.x < 0)
{
mIndex = (mIndex + 1)%NUM_IMAGES;
}
mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES;
}
- mPanPosition = gesture.position;
- mPanDisplacement = gesture.displacement;
+ mPanPosition = gesture.GetPosition();
+ mPanDisplacement = displacement;
GoToNextImage();
}
}
void OnPan(Actor, PanGesture const& gesture)
{
Quaternion q = mAxis.GetProperty(Actor::Property::ORIENTATION).Get<Quaternion>();
- Quaternion qx(Radian(Degree(gesture.screenDisplacement.y) * -.5f), Vector3::XAXIS);
- Quaternion qy(Radian(Degree(gesture.screenDisplacement.x) * .5f), Vector3::YAXIS);
+ const Vector2& displacement = gesture.GetScreenDisplacement();
+ Quaternion qx(Radian(Degree(displacement.y) * -.5f), Vector3::XAXIS);
+ Quaternion qy(Radian(Degree(displacement.x) * .5f), Vector3::YAXIS);
mAxis.SetProperty(Actor::Property::ORIENTATION, qy * qx * q);
}
return;
}
- if( gesture.state == Gesture::Continuing )
+ if( gesture.GetState() == Gesture::Continuing )
{
- if( gesture.displacement.x < 0)
+ const Vector2& displacement = gesture.GetDisplacement();
+ if( displacement.x < 0)
{
mIndex = (mIndex + 1)%NUM_IMAGES;
}
mNextImage.SetProperty( Actor::Property::POSITION_Z, INITIAL_DEPTH);
mParent.Add( mNextImage );
Vector2 size = Vector2( mCurrentImage.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ) );
- StartTransition( gesture.position / size, gesture.displacement * Vector2(1.0, size.x/size.y));
+ StartTransition( gesture.GetPosition() / size, displacement * Vector2(1.0, size.x/size.y));
}
}
*/
void OnLongPress( Actor actor, const LongPressGesture& longPress )
{
- if( longPress.state == Gesture::Started )
+ if( longPress.GetState() == Gesture::Started )
{
// When we first receive a long press, attach the actor to the pan detector.
mPanDetector.Attach( actor );
// As the displacement is in local actor coords, we will have to multiply the displacement by the
// actor's scale so that it moves the correct amount in the parent's coordinate system.
- Vector3 scaledDisplacement( pan.displacement );
+ Vector3 scaledDisplacement( pan.GetDisplacement() );
scaledDisplacement *= actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE );
Vector3 currentPosition;
Vector3 newPosition = currentPosition + scaledDisplacement;
actor.SetProperty( Actor::Property::POSITION, newPosition );
- switch( pan.state )
+ switch( pan.GetState() )
{
case Gesture::Started:
{
*/
void OnPinch( Actor actor, const PinchGesture& pinch )
{
- switch( pinch.state )
+ switch( pinch.GetState() )
{
case Gesture::Started:
{
}
}
- actor.SetProperty( Actor::Property::SCALE, mStartingScale * pinch.scale );
+ actor.SetProperty( Actor::Property::SCALE, mStartingScale * pinch.GetScale() );
}
/**
*/
void OnRotation( Actor actor, const RotationGesture& rotation )
{
- switch( rotation.state )
+ switch( rotation.GetState() )
{
case Gesture::Started:
{
}
}
- actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( mStartingOrientation * Quaternion( rotation.rotation, Vector3::ZAXIS ) ) );
+ actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( mStartingOrientation * Quaternion( rotation.GetRotation(), Vector3::ZAXIS ) ) );
}
/**
void OnPinch( Actor actor, const PinchGesture& pinch )
{
- if( pinch.state == Gesture::Started )
+ if( pinch.GetState() == Gesture::Started )
{
- mLastPinchScale = pinch.scale;
+ mLastPinchScale = pinch.GetScale();
}
- const float scale = pinch.scale;
+ const float scale = pinch.GetScale();
if( ! Equals( scale, mLastPinchScale ) )
{
{
Window window = mApplication.GetWindow();
Vector2 windowSize = window.GetSize();
+ const Vector2& displacement = gesture.GetDisplacement();
+
// 1.0f and 0.75f are the maximum size caps of the resized image, as a factor of window-size.
- mImageWindowScale.x = std::max( 0.05f, std::min( 0.95f, mImageWindowScale.x + ( gesture.displacement.x * 2.0f / windowSize.width ) ) );
- mImageWindowScale.y = std::max( 0.05f, std::min( 0.70f, mImageWindowScale.y + ( gesture.displacement.y * 2.0f / windowSize.height ) ) );
+ mImageWindowScale.x = std::max( 0.05f, std::min( 0.95f, mImageWindowScale.x + ( displacement.x * 2.0f / windowSize.width ) ) );
+ mImageWindowScale.y = std::max( 0.05f, std::min( 0.70f, mImageWindowScale.y + ( displacement.y * 2.0f / windowSize.height ) ) );
ResizeImage();
}
// Callback of pan gesture, for moving the actors
void OnPanGesture( Actor actor, const PanGesture& gesture )
{
- if( gesture.state == Gesture::Continuing )
+ if( gesture.GetState() == Gesture::Continuing )
{
for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ )
{
- mSvgActor[i].TranslateBy(Vector3(gesture.displacement));
+ mSvgActor[i].TranslateBy(Vector3(gesture.GetDisplacement()));
}
}
}
// Callback of pinch gesture, for resizing the actors
void OnPinch(Actor actor, const PinchGesture& gesture)
{
- switch( gesture.state )
+ switch( gesture.GetState() )
{
// Only scale the image when we start or continue pinching
case Gesture::Started:
case Gesture::Continuing:
{
- float scale = std::max( gesture.scale, MIN_SCALE / mScale );
+ float scale = std::max( gesture.GetScale(), MIN_SCALE / mScale );
scale = std::min( MAX_SCALE / mScale, scale );
for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ )
{
// Resize the image when pinching is complete, this will rasterize the SVG to the new size
- mScale = mScale * gesture.scale;
+ mScale = mScale * gesture.GetScale();
mScale = mScale > MAX_SCALE ? MAX_SCALE : mScale;
mScale = mScale < MIN_SCALE ? MIN_SCALE : mScale;
for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ )
void OnLongPress( Actor actor, const LongPressGesture& gesture )
{
- switch( gesture.state )
+ switch( gesture.GetState() )
{
case Gesture::Started:
{
ItemRange range( 0u, 0u );
mItemView.GetItemsRange( range );
- const unsigned int item = ( gesture.screenPoint.y < 0.5f * size.height ) ? range.begin : range.end;
+ const unsigned int item = ( gesture.GetScreenPoint().y < 0.5f * size.height ) ? range.begin : range.end;
mItemView.ScrollToItem( item, SCROLL_TO_ITEM_ANIMATION_TIME );
break;
Window window = mApplication.GetWindow();
Vector2 screenSize = window.GetSize();
+ const Vector2& screenPoint = tap.GetScreenPoint();
Vector2 position;
- position.x = tap.screenPoint.x - screenSize.x * 0.5;
- position.y = tap.screenPoint.y - screenSize.y * 0.5;
+ position.x = screenPoint.x - screenSize.x * 0.5;
+ position.y = screenPoint.y - screenSize.y * 0.5;
float size = 2.5;
actor.ScreenToLocal(originOffsetX, originOffsetY, windowSize.width * 0.5f, windowSize.height * 0.5f);
// get dest point in local actor space
- destPos.x = tapGesture.localPoint.x - originOffsetX;
- destPos.y = tapGesture.localPoint.y - originOffsetY;
+ const Vector2& localPoint = tapGesture.GetLocalPoint();
+ destPos.x = localPoint.x - originOffsetX;
+ destPos.y = localPoint.y - originOffsetY;
destPos.z = 0.0f;
float animDuration = 0.5f;
actor.ScreenToLocal(originOffsetX, originOffsetY, windowSize.width * 0.5f, windowSize.height * 0.5f);
// get dest point in local actor space
- destPos.x = tapGesture.localPoint.x - originOffsetX;
- destPos.y = tapGesture.localPoint.y - originOffsetY;
+ const Vector2& localPoint = tapGesture.GetLocalPoint();
+ destPos.x = localPoint.x - originOffsetX;
+ destPos.y = localPoint.y - originOffsetY;
destPos.z = 0.0f;
float animDuration = 0.5f;
//Panning around the shape rotates it.
void OnPan( Actor actor, const PanGesture& gesture )
{
- switch( gesture.state )
+ switch( gesture.GetState() )
{
case Gesture::Started:
{
case Gesture::Continuing:
{
//Rotate based off the gesture.
- mRotation.x -= gesture.displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
- mRotation.y += gesture.displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
+ const Vector2& displacement = gesture.GetDisplacement();
+ mRotation.x -= displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
+ mRotation.y += displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
Quaternion rotation = Quaternion( Radian( mRotation.x ), Vector3::XAXIS) *
Quaternion( Radian( mRotation.y ), Vector3::YAXIS);
void OnPan( Actor actor, const PanGesture& panGesture )
{
- auto displacement = panGesture.screenDisplacement;
+ const auto& displacement = panGesture.GetScreenDisplacement();
mCenterActor.RotateBy( Degree( displacement.y *0.1f ), Vector3( 0.0, 0.0, 1.0) );
mCenterActor.RotateBy( Degree( displacement.x *0.1f ), Vector3( 0.0, 1.0, 0.0) );
Quaternion q;
void OnPan(Actor actor, const PanGesture& gesture)
{
- switch (gesture.state)
+ switch (gesture.GetState())
{
case Gesture::Continuing:
{
+ const Vector2& displacement = gesture.GetDisplacement();
switch(mPanState)
{
case PAN_LIGHT:
{
- mLightXRotation = mLightXRotation - gesture.displacement.y * LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
+ mLightXRotation = mLightXRotation - displacement.y * LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
mLightXRotation = Clamp(mLightXRotation, -Dali::ANGLE_45, Dali::ANGLE_45 );
- mLightYRotation = mLightYRotation + gesture.displacement.x * LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
+ mLightYRotation = mLightYRotation + displacement.x * LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
mLightYRotation = Clamp(mLightYRotation, -Dali::ANGLE_45, Dali::ANGLE_45 );
mLightAnchor.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mLightXRotation, mLightYRotation ) );
break;
case PAN_SCENE:
{
- mTranslation += Vector3(gesture.displacement.x, gesture.displacement.y, 0.f);
+ mTranslation += Vector3(displacement.x, displacement.y, 0.f);
mContents.SetProperty( Actor::Property::POSITION, mTranslation );
break;
}
case ROTATE_SCENE:
{
- mSceneXRotation = mSceneXRotation - gesture.displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
+ mSceneXRotation = mSceneXRotation - displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
mSceneXRotation = Clamp( mSceneXRotation, -Dali::ANGLE_90, Dali::ANGLE_90 );
- mSceneYRotation = mSceneYRotation + gesture.displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
+ mSceneYRotation = mSceneYRotation + displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
mSceneYRotation = Clamp( mSceneYRotation, -Dali::ANGLE_90, Dali::ANGLE_90 );
mContents.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
break;
case ROTATE_OBJECT:
{
- mObjectXRotation = mObjectXRotation - gesture.displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
- mObjectYRotation = mObjectYRotation + gesture.displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
+ mObjectXRotation = mObjectXRotation - displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
+ mObjectYRotation = mObjectYRotation + displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
mSceneActor.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mObjectXRotation, mObjectYRotation ) );
break;
}
void OnPinch(Actor actor, const PinchGesture& gesture)
{
- if (gesture.state == Gesture::Started)
+ if (gesture.GetState() == Gesture::Started)
{
mScaleAtPinchStart = mContents.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x;
}
- mPinchScale = Clamp(mScaleAtPinchStart * gesture.scale, MIN_PINCH_SCALE, MAX_PINCH_SCALE);
+ mPinchScale = Clamp(mScaleAtPinchStart * gesture.GetScale(), MIN_PINCH_SCALE, MAX_PINCH_SCALE);
mContents.SetProperty( Actor::Property::SCALE, Vector3( mPinchScale, mPinchScale, mPinchScale ) );
}
void OnTap( Actor actor, const TapGesture& tap )
{
{
- PlayTapAnimation(5.f, tap.localPoint);
+ PlayTapAnimation(5.f, tap.GetLocalPoint());
}
}
*/
void OnPan( Actor actor, const PanGesture& gesture )
{
- if( gesture.state == Gesture::Finished )
+ if( gesture.GetState() == Gesture::Finished )
{
switch(mAnimationIndex)
{
void StylingApplication::OnPan( Actor actor, const PanGesture& gesture )
{
Vector3 size = mContentPane.GetTargetSize();
- mContentPane.SetProperty( Actor::Property::SIZE, Vector2( size.GetVectorXY() + gesture.displacement * 2.0f ) );
+ mContentPane.SetProperty( Actor::Property::SIZE, Vector2( size.GetVectorXY() + gesture.GetDisplacement() * 2.0f ) );
}
void StylingApplication::OnKeyEvent( const KeyEvent& keyEvent )
void OnPan( Actor actor, const PanGesture& gesture )
{
// Reset mLayoutSize when the pan starts
- if( gesture.state == Gesture::Started )
+ Gesture::State state = gesture.GetState();
+ if( state == Gesture::Started )
{
if( mLayoutSize.x < 2.0f )
{
HideStyleAndColorButtons();
}
- mLayoutSize.x += gesture.displacement.x * 2.0f;
- mLayoutSize.y += gesture.displacement.y * 2.0f;
+ const Vector2& displacement = gesture.GetDisplacement();
+ mLayoutSize.x += displacement.x * 2.0f;
+ mLayoutSize.y += displacement.y * 2.0f;
if( mLayoutSize.x >= 2.0f ||
mLayoutSize.y >= 2.0f )
mContainer.SetProperty( Actor::Property::SIZE, clampedSize );
}
- if( gesture.state == Gesture::Cancelled || gesture.state == Gesture::Finished )
+ if( state == Gesture::Cancelled || state == Gesture::Finished )
{
// Resize the text label to match the container size when panning is finished
mLabel.SetProperty( Actor::Property::SIZE, mLayoutSize );
void TextOverlapController::OnPan( Actor actor, const PanGesture& gesture )
{
- if( ! mGrabbedActor || gesture.state == PanGesture::Started )
+ const Gesture::State state = gesture.GetState();
+ if( ! mGrabbedActor || state == PanGesture::Started )
{
+ const Vector2& gesturePosition = gesture.GetPosition();
for( int i=0; i<NUMBER_OF_LABELS; ++i )
{
Vector3 position = mLabels[i].GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
Vector3 size = mLabels[i].GetCurrentProperty< Vector3 >( Actor::Property::SIZE );
- if( gesture.position.y > position.y - size.y * 0.5f &&
- gesture.position.y <= position.y + size.y * 0.5f )
+ if( gesturePosition.y > position.y - size.y * 0.5f &&
+ gesturePosition.y <= position.y + size.y * 0.5f )
{
mGrabbedActor = mLabels[i];
break;
}
}
}
- else if( mGrabbedActor && gesture.state == PanGesture::Continuing )
+ else if( mGrabbedActor && state == PanGesture::Continuing )
{
Vector2 windowSize = mApplication.GetWindow().GetSize();
Vector3 size = mGrabbedActor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE );
- float y = Clamp( gesture.position.y, size.y * 0.5f, windowSize.y - size.y*0.5f );
+ const Vector2& gesturePosition = gesture.GetPosition();
+
+ float y = Clamp( gesturePosition.y, size.y * 0.5f, windowSize.y - size.y*0.5f );
mGrabbedActor.SetProperty( Actor::Property::POSITION, Vector2( 0, y ));
}
else
void OnPanGesture( Actor actor, const PanGesture& gesture )
{
- if( gesture.state == Gesture::Continuing )
+ if( gesture.GetState() == Gesture::Continuing )
{
- Vector2 position = Vector2( gesture.displacement );
- mTargetActorPosition.y = mTargetActorPosition.y + position.y;
+ mTargetActorPosition.y = mTargetActorPosition.y + gesture.GetDisplacement().y;
mTargetActorPosition.y = std::min( mTargetActorPosition.y, -mTargetActorSize.height );
mTargetActorPosition.y = std::max( mTargetActorPosition.y, ( mTargetActorSize.height - mWindowSize.height*0.25f ) );
actor.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, mTargetActorPosition.y ));
void OnPan( Actor actor, const PanGesture& gesture )
{
- if( !mIsFullScreen && gesture.state == Gesture::Continuing )
+ if( !mIsFullScreen && gesture.GetState() == Gesture::Continuing )
{
- mVideoView.TranslateBy( Vector3( gesture.displacement ) );
+ mVideoView.TranslateBy( Vector3( gesture.GetDisplacement() ) );
}
}
void OnPinch( Actor actor, const PinchGesture& gesture )
{
- if( gesture.state == Gesture::Started )
+ Gesture::State state = gesture.GetState();
+ if( state == Gesture::Started )
{
mPinchStartScale = mScale;
}
- if( gesture.state == Gesture::Finished )
+ if( state == Gesture::Finished )
{
- mScale = mPinchStartScale * gesture.scale;
+ mScale = mPinchStartScale * gesture.GetScale();
mVideoView.SetProperty( Actor::Property::SCALE, mScale );
}
}