From 3818d79b8ecc810cca0300c83c49de0363582849 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Tue, 23 Jun 2020 15:25:53 +0900 Subject: [PATCH] Refactoring Gestures Class --- examples/cube-transition-effect/cube-transition-effect-example.cpp | 9 +++++---- examples/deferred-shading/deferred-shading.cpp | 5 +++-- examples/dissolve-effect/dissolve-effect-example.cpp | 7 ++++--- examples/gestures/gesture-example.cpp | 14 +++++++------- examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp | 12 +++++++----- examples/image-view-svg/image-view-svg-example.cpp | 10 +++++----- examples/item-view/item-view-example.cpp | 4 ++-- examples/model3d-view/model3d-view-example.cpp | 5 +++-- examples/motion-blur/motion-blur-example.cpp | 5 +++-- examples/motion-stretch/motion-stretch-example.cpp | 5 +++-- examples/primitive-shapes/primitive-shapes-example.cpp | 7 ++++--- examples/reflection-demo/reflection-example.cpp | 2 +- examples/shadows-and-lights/shadows-and-lights-example.cpp | 21 +++++++++++---------- examples/sparkle/sparkle-effect-example.cpp | 4 ++-- examples/styling/styling-application.cpp | 2 +- examples/text-label/text-label-example.cpp | 10 ++++++---- examples/text-overlap/text-overlap-example.cpp | 14 +++++++++----- examples/text-scrolling/text-scrolling-example.cpp | 5 ++--- examples/video-view/video-view-example.cpp | 11 ++++++----- 19 files changed, 84 insertions(+), 68 deletions(-) mode change 100644 => 100755 examples/cube-transition-effect/cube-transition-effect-example.cpp mode change 100644 => 100755 examples/deferred-shading/deferred-shading.cpp mode change 100644 => 100755 examples/dissolve-effect/dissolve-effect-example.cpp mode change 100644 => 100755 examples/gestures/gesture-example.cpp mode change 100644 => 100755 examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp mode change 100644 => 100755 examples/image-view-svg/image-view-svg-example.cpp mode change 100644 => 100755 examples/item-view/item-view-example.cpp mode change 100644 => 100755 examples/model3d-view/model3d-view-example.cpp mode change 100644 => 100755 examples/motion-blur/motion-blur-example.cpp mode change 100644 => 100755 examples/motion-stretch/motion-stretch-example.cpp mode change 100644 => 100755 examples/primitive-shapes/primitive-shapes-example.cpp mode change 100644 => 100755 examples/reflection-demo/reflection-example.cpp mode change 100644 => 100755 examples/shadows-and-lights/shadows-and-lights-example.cpp mode change 100644 => 100755 examples/sparkle/sparkle-effect-example.cpp mode change 100644 => 100755 examples/styling/styling-application.cpp mode change 100644 => 100755 examples/text-label/text-label-example.cpp mode change 100644 => 100755 examples/text-overlap/text-overlap-example.cpp mode change 100644 => 100755 examples/text-scrolling/text-scrolling-example.cpp mode change 100644 => 100755 examples/video-view/video-view-example.cpp diff --git a/examples/cube-transition-effect/cube-transition-effect-example.cpp b/examples/cube-transition-effect/cube-transition-effect-example.cpp old mode 100644 new mode 100755 index e9fddc8..ecf01c1 --- a/examples/cube-transition-effect/cube-transition-effect-example.cpp +++ b/examples/cube-transition-effect/cube-transition-effect-example.cpp @@ -296,9 +296,10 @@ void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture ) 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; } @@ -307,8 +308,8 @@ void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture ) mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES; } - mPanPosition = gesture.position; - mPanDisplacement = gesture.displacement; + mPanPosition = gesture.GetPosition(); + mPanDisplacement = displacement; GoToNextImage(); } } diff --git a/examples/deferred-shading/deferred-shading.cpp b/examples/deferred-shading/deferred-shading.cpp old mode 100644 new mode 100755 index 7a1920f..4221187 --- a/examples/deferred-shading/deferred-shading.cpp +++ b/examples/deferred-shading/deferred-shading.cpp @@ -770,8 +770,9 @@ private: void OnPan(Actor, PanGesture const& gesture) { Quaternion q = mAxis.GetProperty(Actor::Property::ORIENTATION).Get(); - 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); } diff --git a/examples/dissolve-effect/dissolve-effect-example.cpp b/examples/dissolve-effect/dissolve-effect-example.cpp old mode 100644 new mode 100755 index 4d9138f..77cd84b --- a/examples/dissolve-effect/dissolve-effect-example.cpp +++ b/examples/dissolve-effect/dissolve-effect-example.cpp @@ -276,9 +276,10 @@ void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) 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; } @@ -294,7 +295,7 @@ void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) 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)); } } diff --git a/examples/gestures/gesture-example.cpp b/examples/gestures/gesture-example.cpp old mode 100644 new mode 100755 index e2d8e8a..884c3f9 --- a/examples/gestures/gesture-example.cpp +++ b/examples/gestures/gesture-example.cpp @@ -266,7 +266,7 @@ private: */ 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 ); @@ -294,7 +294,7 @@ private: // 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; @@ -303,7 +303,7 @@ private: Vector3 newPosition = currentPosition + scaledDisplacement; actor.SetProperty( Actor::Property::POSITION, newPosition ); - switch( pan.state ) + switch( pan.GetState() ) { case Gesture::Started: { @@ -369,7 +369,7 @@ private: */ void OnPinch( Actor actor, const PinchGesture& pinch ) { - switch( pinch.state ) + switch( pinch.GetState() ) { case Gesture::Started: { @@ -406,7 +406,7 @@ private: } } - actor.SetProperty( Actor::Property::SCALE, mStartingScale * pinch.scale ); + actor.SetProperty( Actor::Property::SCALE, mStartingScale * pinch.GetScale() ); } /** @@ -417,7 +417,7 @@ private: */ void OnRotation( Actor actor, const RotationGesture& rotation ) { - switch( rotation.state ) + switch( rotation.GetState() ) { case Gesture::Started: { @@ -442,7 +442,7 @@ private: } } - actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( mStartingOrientation * Quaternion( rotation.rotation, Vector3::ZAXIS ) ) ); + actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( mStartingOrientation * Quaternion( rotation.GetRotation(), Vector3::ZAXIS ) ) ); } /** diff --git a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp old mode 100644 new mode 100755 index d79a272..8ffb9a8 --- a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp +++ b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp @@ -530,11 +530,11 @@ public: 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 ) ) { @@ -557,9 +557,11 @@ public: { 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(); } diff --git a/examples/image-view-svg/image-view-svg-example.cpp b/examples/image-view-svg/image-view-svg-example.cpp old mode 100644 new mode 100755 index bfbe038..05eae9a --- a/examples/image-view-svg/image-view-svg-example.cpp +++ b/examples/image-view-svg/image-view-svg-example.cpp @@ -153,11 +153,11 @@ public: // 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())); } } } @@ -165,14 +165,14 @@ public: // 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++ ) @@ -186,7 +186,7 @@ public: { // 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++ ) diff --git a/examples/item-view/item-view-example.cpp b/examples/item-view/item-view-example.cpp old mode 100644 new mode 100755 index f205377..237c807 --- a/examples/item-view/item-view-example.cpp +++ b/examples/item-view/item-view-example.cpp @@ -549,7 +549,7 @@ public: void OnLongPress( Actor actor, const LongPressGesture& gesture ) { - switch( gesture.state ) + switch( gesture.GetState() ) { case Gesture::Started: { @@ -558,7 +558,7 @@ public: 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; diff --git a/examples/model3d-view/model3d-view-example.cpp b/examples/model3d-view/model3d-view-example.cpp old mode 100644 new mode 100755 index 7021e55..2b1c08a --- a/examples/model3d-view/model3d-view-example.cpp +++ b/examples/model3d-view/model3d-view-example.cpp @@ -179,9 +179,10 @@ public: 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; diff --git a/examples/motion-blur/motion-blur-example.cpp b/examples/motion-blur/motion-blur-example.cpp old mode 100644 new mode 100755 index 186db1a..5f82eba --- a/examples/motion-blur/motion-blur-example.cpp +++ b/examples/motion-blur/motion-blur-example.cpp @@ -285,8 +285,9 @@ public: 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; diff --git a/examples/motion-stretch/motion-stretch-example.cpp b/examples/motion-stretch/motion-stretch-example.cpp old mode 100644 new mode 100755 index 7b8c0bd..8167dfc --- a/examples/motion-stretch/motion-stretch-example.cpp +++ b/examples/motion-stretch/motion-stretch-example.cpp @@ -257,8 +257,9 @@ public: 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; diff --git a/examples/primitive-shapes/primitive-shapes-example.cpp b/examples/primitive-shapes/primitive-shapes-example.cpp old mode 100644 new mode 100755 index 54fffa1..675e076 --- a/examples/primitive-shapes/primitive-shapes-example.cpp +++ b/examples/primitive-shapes/primitive-shapes-example.cpp @@ -631,7 +631,7 @@ public: //Panning around the shape rotates it. void OnPan( Actor actor, const PanGesture& gesture ) { - switch( gesture.state ) + switch( gesture.GetState() ) { case Gesture::Started: { @@ -643,8 +643,9 @@ public: 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); diff --git a/examples/reflection-demo/reflection-example.cpp b/examples/reflection-demo/reflection-example.cpp old mode 100644 new mode 100755 index 4dff874..1f91e21 --- a/examples/reflection-demo/reflection-example.cpp +++ b/examples/reflection-demo/reflection-example.cpp @@ -610,7 +610,7 @@ private: 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; diff --git a/examples/shadows-and-lights/shadows-and-lights-example.cpp b/examples/shadows-and-lights/shadows-and-lights-example.cpp old mode 100644 new mode 100755 index cc2b2bb..157dcbc --- a/examples/shadows-and-lights/shadows-and-lights-example.cpp +++ b/examples/shadows-and-lights/shadows-and-lights-example.cpp @@ -335,17 +335,18 @@ public: 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; @@ -353,16 +354,16 @@ public: 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; @@ -370,8 +371,8 @@ public: 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; } @@ -390,11 +391,11 @@ public: 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 ) ); } diff --git a/examples/sparkle/sparkle-effect-example.cpp b/examples/sparkle/sparkle-effect-example.cpp old mode 100644 new mode 100755 index d3c0bc0..08227b4 --- a/examples/sparkle/sparkle-effect-example.cpp +++ b/examples/sparkle/sparkle-effect-example.cpp @@ -263,7 +263,7 @@ private: void OnTap( Actor actor, const TapGesture& tap ) { { - PlayTapAnimation(5.f, tap.localPoint); + PlayTapAnimation(5.f, tap.GetLocalPoint()); } } @@ -272,7 +272,7 @@ private: */ void OnPan( Actor actor, const PanGesture& gesture ) { - if( gesture.state == Gesture::Finished ) + if( gesture.GetState() == Gesture::Finished ) { switch(mAnimationIndex) { diff --git a/examples/styling/styling-application.cpp b/examples/styling/styling-application.cpp old mode 100644 new mode 100755 index d50b731..197d559 --- a/examples/styling/styling-application.cpp +++ b/examples/styling/styling-application.cpp @@ -628,7 +628,7 @@ void StylingApplication::PopupHidden() 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 ) diff --git a/examples/text-label/text-label-example.cpp b/examples/text-label/text-label-example.cpp old mode 100644 new mode 100755 index f432bd2..8874fcb --- a/examples/text-label/text-label-example.cpp +++ b/examples/text-label/text-label-example.cpp @@ -572,7 +572,8 @@ public: 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 ) { @@ -590,8 +591,9 @@ public: 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 ) @@ -606,7 +608,7 @@ public: 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 ); diff --git a/examples/text-overlap/text-overlap-example.cpp b/examples/text-overlap/text-overlap-example.cpp old mode 100644 new mode 100755 index 05f5e65..bbd7c0f --- a/examples/text-overlap/text-overlap-example.cpp +++ b/examples/text-overlap/text-overlap-example.cpp @@ -75,25 +75,29 @@ void TextOverlapController::Create( Application& app ) 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( 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 diff --git a/examples/text-scrolling/text-scrolling-example.cpp b/examples/text-scrolling/text-scrolling-example.cpp old mode 100644 new mode 100755 index 4144687..c660ef4 --- a/examples/text-scrolling/text-scrolling-example.cpp +++ b/examples/text-scrolling/text-scrolling-example.cpp @@ -377,10 +377,9 @@ public: 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 )); diff --git a/examples/video-view/video-view-example.cpp b/examples/video-view/video-view-example.cpp old mode 100644 new mode 100755 index fb5b5a3..7f56b19 --- a/examples/video-view/video-view-example.cpp +++ b/examples/video-view/video-view-example.cpp @@ -221,22 +221,23 @@ class VideoViewController: public ConnectionTracker 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 ); } } -- libgit2 0.21.4