From: Adeel Kazmi Date: Fri, 27 May 2016 16:07:19 +0000 (+0100) Subject: Use new TouchData API X-Git-Tag: dali_1.1.37~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F34%2F71934%2F2;p=platform%2Fcore%2Fuifw%2Fdali-demo.git Use new TouchData API Change-Id: Ia8cc676eeb95ec2673995026cddca8850693d04e --- diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index 00e1c7f..04cfaa3 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -241,7 +241,7 @@ void DaliTableView::Initialize( Application& application ) mScrollView.SetAxisAutoLock( true ); mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); - mScrollView.TouchedSignal().Connect( this, &DaliTableView::OnScrollTouched ); + mScrollView.TouchSignal().Connect( this, &DaliTableView::OnScrollTouched ); mScrollViewLayer = Layer::New(); @@ -476,7 +476,7 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit content.SetKeyboardFocusable(true); // connect to the touch events - content.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed ); + content.TouchSignal().Connect( this, &DaliTableView::OnTilePressed ); content.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered ); return content; @@ -496,12 +496,16 @@ Toolkit::ImageView DaliTableView::NewStencilImage() return stencil; } -bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event ) +bool DaliTableView::OnTilePressed( Actor actor, const TouchData& event ) +{ + return DoTilePress( actor, event.GetState( 0 ) ); +} + +bool DaliTableView::DoTilePress( Actor actor, PointState::Type pointState ) { bool consumed = false; - const TouchPoint& point = event.GetPoint( 0 ); - if( TouchPoint::Down == point.state ) + if( PointState::DOWN == pointState ) { mPressedActor = actor; consumed = true; @@ -509,7 +513,7 @@ bool DaliTableView::OnTilePressed( Actor actor, const TouchEvent& event ) // A button press is only valid if the Down & Up events // both occurred within the button. - if( ( TouchPoint::Up == point.state ) && + if( ( PointState::UP == pointState ) && ( mPressedActor == actor ) ) { // ignore Example button presses when scrolling or button animating. @@ -581,10 +585,9 @@ void DaliTableView::OnScrollComplete( const Dali::Vector2& position ) accessibilityManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) ); } -bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event ) +bool DaliTableView::OnScrollTouched( Actor actor, const TouchData& event ) { - const TouchPoint& point = event.GetPoint( 0 ); - if( TouchPoint::Down == point.state ) + if( PointState::DOWN == event.GetState( 0 ) ) { mPressedActor = actor; } @@ -901,9 +904,7 @@ void DaliTableView::OnFocusedActorActivated( Dali::Actor activatedActor ) mPressedActor = activatedActor; // Activate the current focused actor; - TouchEvent touchEventUp; - touchEventUp.points.push_back( TouchPoint ( 0, TouchPoint::Up, 0.0f, 0.0f ) ); - OnTilePressed(mPressedActor, touchEventUp); + DoTilePress( mPressedActor, PointState::UP ); } } diff --git a/demo/dali-table-view.h b/demo/dali-table-view.h index aa2a469..d4b0946 100644 --- a/demo/dali-table-view.h +++ b/demo/dali-table-view.h @@ -163,7 +163,17 @@ private: // Application callbacks & implementation * * @return Consume flag */ - bool OnTilePressed( Dali::Actor actor, const Dali::TouchEvent& event ); + bool OnTilePressed( Dali::Actor actor, const Dali::TouchData& event ); + + /** + * Called by OnTilePressed & Accessibility to do the appropriate action. + * + * @param[in] actor The Actor representing this tile. + * @param[in] state The Touch state + * + * @return Consume flag + */ + bool DoTilePress( Dali::Actor actor, Dali::PointState::Type state ); /** * Signal emitted when any tile has been hovered @@ -214,7 +224,7 @@ private: // Application callbacks & implementation * * @return Consume flag */ - bool OnScrollTouched( Dali::Actor actor, const Dali::TouchEvent& event ); + bool OnScrollTouched( Dali::Actor actor, const Dali::TouchData& event ); /** * Setup the effect on the scroll view diff --git a/examples/benchmark/benchmark.cpp b/examples/benchmark/benchmark.cpp index 3824de8..e9fed0e 100644 --- a/examples/benchmark/benchmark.cpp +++ b/examples/benchmark/benchmark.cpp @@ -285,7 +285,7 @@ public: mSize = Vector3( stageSize.x / mColumnsPerPage, stageSize.y / mRowsPerPage, 0.0f ); // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchedSignal().Connect( this, &Benchmark::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &Benchmark::OnTouch ); if( gUseMesh ) { @@ -303,7 +303,7 @@ public: ShowAnimation(); } - bool OnTouch( Actor actor, const TouchEvent& touch ) + bool OnTouch( Actor actor, const TouchData& touch ) { // quit the application mApplication.Quit(); diff --git a/examples/blocks/blocks-example.cpp b/examples/blocks/blocks-example.cpp index 61aed74..a308be3 100644 --- a/examples/blocks/blocks-example.cpp +++ b/examples/blocks/blocks-example.cpp @@ -289,8 +289,8 @@ private: mPaddle.SetPosition( stageSize * Vector3( PADDLE_START_POSITION ) ); mContentLayer.Add(mPaddle); - mPaddle.TouchedSignal().Connect(this, &ExampleController::OnTouchPaddle); - mContentLayer.TouchedSignal().Connect(this, &ExampleController::OnTouchLayer); + mPaddle.TouchSignal().Connect(this, &ExampleController::OnTouchPaddle); + mContentLayer.TouchSignal().Connect(this, &ExampleController::OnTouchLayer); const float margin(BALL_SIZE.width * stageSize.width * 0.5f); @@ -579,15 +579,15 @@ private: * @param[in] actor The actor touched * @param[in] event The touch event */ - bool OnTouchPaddle(Actor actor, const TouchEvent& event) + bool OnTouchPaddle(Actor actor, const TouchData& event) { if(event.GetPointCount()>0) { - const TouchPoint& point = event.GetPoint(0); - if(point.state==TouchPoint::Down) // Commence dragging + if( event.GetState( 0 ) == PointState::DOWN ) // Commence dragging { // Get point where user touched paddle (relative to paddle's center) - mRelativeDragPoint = Vector3(point.screen.x, point.screen.y, 0.0f); + Vector2 screenPoint = event.GetScreenPosition( 0 ); + mRelativeDragPoint = screenPoint; mRelativeDragPoint -= actor.GetCurrentPosition(); mDragActor = actor; @@ -605,17 +605,16 @@ private: * @param[in] actor The actor touched * @param[in] event The touch event */ - bool OnTouchLayer(Actor actor, const TouchEvent& event) + bool OnTouchLayer(Actor actor, const TouchData& event) { if(event.GetPointCount()>0) { - const TouchPoint& point = event.GetPoint(0); if(mDragActor) { - Vector3 position(point.screen.x, point.screen.y, 0.0f); + Vector3 position( event.GetScreenPosition( 0 ) ); mPaddle.SetPosition( position - mRelativeDragPoint ); - if(point.state==TouchPoint::Up) // Stop dragging + if( event.GetState( 0 ) == PointState::UP ) // Stop dragging { mDragAnimation = Animation::New(0.25f); mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::SCALE), Vector3(1.0f, 1.0f, 1.0f), AlphaFunction::EASE_IN); diff --git a/examples/bubble-effect/bubble-effect-example.cpp b/examples/bubble-effect/bubble-effect-example.cpp index 7127ba4..fbd83db 100644 --- a/examples/bubble-effect/bubble-effect-example.cpp +++ b/examples/bubble-effect/bubble-effect-example.cpp @@ -150,7 +150,7 @@ private: mTimerForBubbleEmission.TickSignal().Connect(this, &BubbleEffectExample::OnTimerTick); // Connect the callback to the touch signal on the background - mBackground.TouchedSignal().Connect( this, &BubbleEffectExample::OnTouch ); + mBackground.TouchSignal().Connect( this, &BubbleEffectExample::OnTouch ); } @@ -205,24 +205,22 @@ private: } // Callback function of the touch signal on the background - bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& event) + bool OnTouch(Dali::Actor actor, const Dali::TouchData& event) { - const TouchPoint &point = event.GetPoint(0); - switch(point.state) + switch( event.GetState( 0 ) ) { - case TouchPoint::Down: + case PointState::DOWN: { - mCurrentTouchPosition = point.screen; - mEmitPosition = point.screen; + mCurrentTouchPosition = mEmitPosition = event.GetScreenPosition( 0 ); mTimerForBubbleEmission.Start(); mNonMovementCount = 0; break; } - case TouchPoint::Motion: + case PointState::MOTION: { - Vector2 displacement = point.screen - mCurrentTouchPosition; - mCurrentTouchPosition = point.screen; + Vector2 displacement = event.GetScreenPosition( 0 ) - mCurrentTouchPosition; + mCurrentTouchPosition = event.GetScreenPosition( 0 ); //emit multiple bubbles along the moving direction when the finger moves quickly float step = std::min(5.f, displacement.Length()); for( float i=0.25f; i( static_cast( event.GetPoint( 0 ).local.y ) ); - - if( TouchPoint::Down == state ) - { - mLastPoint = localPoint; - mAnimation = Animation::New( 0.25f ); - } - else if( TouchPoint::Motion == state ) - { - if( mAnimation ) - { - mAnimation.AnimateBy( Property(actor, Actor::Property::POSITION), Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunction::LINEAR ); - mAnimation.Play(); - mLastPoint = localPoint; - } - } - } - - return true; - } - - private: +private: Application& mApplication; Toolkit::Control mView; ///< The View instance. diff --git a/examples/compressed-texture-formats/compressed-texture-formats-example.cpp b/examples/compressed-texture-formats/compressed-texture-formats-example.cpp index 7fed128..a55f69a 100644 --- a/examples/compressed-texture-formats/compressed-texture-formats-example.cpp +++ b/examples/compressed-texture-formats/compressed-texture-formats-example.cpp @@ -108,10 +108,10 @@ public: stage.Add( table ); // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchedSignal().Connect( this, &CompressedTextureFormatsController::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &CompressedTextureFormatsController::OnTouch ); } - bool OnTouch( Actor actor, const TouchEvent& touch ) + bool OnTouch( Actor actor, const TouchData& touch ) { // quit the application mApplication.Quit(); diff --git a/examples/hello-world/hello-world-example.cpp b/examples/hello-world/hello-world-example.cpp index 2c5763a..89670a1 100644 --- a/examples/hello-world/hello-world-example.cpp +++ b/examples/hello-world/hello-world-example.cpp @@ -51,10 +51,10 @@ public: stage.Add( textLabel ); // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchedSignal().Connect( this, &HelloWorldController::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &HelloWorldController::OnTouch ); } - bool OnTouch( Actor actor, const TouchEvent& touch ) + bool OnTouch( Actor actor, const TouchData& touch ) { // quit the application mApplication.Quit(); diff --git a/examples/homescreen-benchmark/homescreen-benchmark.cpp b/examples/homescreen-benchmark/homescreen-benchmark.cpp index a35919a..da33200 100644 --- a/examples/homescreen-benchmark/homescreen-benchmark.cpp +++ b/examples/homescreen-benchmark/homescreen-benchmark.cpp @@ -438,10 +438,10 @@ public: stage.Add(mScrollParent); // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchedSignal().Connect( this, &HomescreenBenchmark::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &HomescreenBenchmark::OnTouch ); } - bool OnTouch( Actor actor, const TouchEvent& touch ) + bool OnTouch( Actor actor, const TouchData& touch ) { // quit the application mApplication.Quit(); 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 index a5782ef..042ce7a 100644 --- a/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp +++ b/examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp @@ -295,7 +295,7 @@ public: imagePrevious.SetOpacity( 0.6f ); controlsLayer.Add( imagePrevious ); imagePrevious.SetName( PREVIOUS_BUTTON_ID ); - imagePrevious.TouchedSignal().Connect( this, &ImageScalingAndFilteringController::OnControlTouched ); + imagePrevious.TouchSignal().Connect( this, &ImageScalingAndFilteringController::OnControlTouched ); // Next image button: Toolkit::ImageView imageNext = Toolkit::ImageView::New( playImage ); @@ -305,7 +305,7 @@ public: imageNext.SetOpacity( 0.6f ); controlsLayer.Add( imageNext ); imageNext.SetName( NEXT_BUTTON_ID ); - imageNext.TouchedSignal().Connect( this, &ImageScalingAndFilteringController::OnControlTouched ); + imageNext.TouchSignal().Connect( this, &ImageScalingAndFilteringController::OnControlTouched ); // Buttons to popup selectors for fitting and sampling modes: @@ -535,14 +535,13 @@ public: } } - bool OnControlTouched( Actor actor, const TouchEvent& event ) + bool OnControlTouched( Actor actor, const TouchData& event ) { if(event.GetPointCount() > 0) { - const TouchPoint& point = event.GetPoint(0); - switch(point.state) + switch( event.GetState( 0 ) ) { - case TouchPoint::Up: + case PointState::UP: { const std::string & name = actor.GetName(); if( name == NEXT_BUTTON_ID ) diff --git a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp index dc982f8..51482d4 100644 --- a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp +++ b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp @@ -461,7 +461,7 @@ public: ImageView image = CreateImageView( imageSource.configuration.path, imageSize.x, imageSize.y, fittingMode ); image.SetPosition( Vector3( imagePosition.x, imagePosition.y, 0 ) ); image.SetSize( imageSize ); - image.TouchedSignal().Connect( this, &ImageScalingIrregularGridController::OnTouchImage ); + image.TouchSignal().Connect( this, &ImageScalingIrregularGridController::OnTouchImage ); mFittingModes[image.GetId()] = fittingMode; mResourceUrls[image.GetId()] = imageSource.configuration.path; mSizes[image.GetId()] = imageSize; @@ -477,12 +477,11 @@ public: * @param[in] actor The actor touched * @param[in] event The TouchEvent. */ - bool OnTouchImage( Actor actor, const TouchEvent& event ) + bool OnTouchImage( Actor actor, const TouchData& event ) { - if( (event.points.size() > 0) && (!mScrolling) ) + if( ( event.GetPointCount() > 0 ) && ( !mScrolling ) ) { - TouchPoint point = event.points[0]; - if(point.state == TouchPoint::Up) + if( event.GetState( 0 ) == PointState::UP ) { // Spin the image a few times: Animation animation = Animation::New(SPIN_DURATION); diff --git a/examples/image-view-pixel-area/image-view-pixel-area-example.cpp b/examples/image-view-pixel-area/image-view-pixel-area-example.cpp index 69a8c54..55ac6b6 100644 --- a/examples/image-view-pixel-area/image-view-pixel-area-example.cpp +++ b/examples/image-view-pixel-area/image-view-pixel-area-example.cpp @@ -74,13 +74,12 @@ private: animation.Play(); // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchedSignal().Connect( this, &ImageViewPixelAreaApp::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &ImageViewPixelAreaApp::OnTouch ); } - bool OnTouch( Actor actor, const TouchEvent& touch ) + bool OnTouch( Actor actor, const TouchData& touch ) { - const TouchPoint &point = touch.GetPoint(0); - if(point.state == TouchPoint::Down) + if( touch.GetState( 0 ) == PointState::DOWN ) { mIndex++; for( int i=0; i<3;i++ ) diff --git a/examples/logging/logging-example.cpp b/examples/logging/logging-example.cpp index 9abef21..31af882 100644 --- a/examples/logging/logging-example.cpp +++ b/examples/logging/logging-example.cpp @@ -174,7 +174,6 @@ class LoggingController: public ConnectionTracker contentTable.SetAnchorPoint( AnchorPoint::TOP_LEFT ); contentTable.SetParentOrigin( ParentOrigin::TOP_LEFT ); contentTable.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE * 0.5f ) ); -// contentTable.TouchedSignal().Connect( this, &LoggingController::OnTouchEvent ); for( unsigned int i = 0; i < contentTable.GetRows(); ++i ) { @@ -639,35 +638,7 @@ class LoggingController: public ConnectionTracker return true; } - bool OnTouchEvent( Actor actor, const TouchEvent& event ) - { - if( 1u == event.GetPointCount() ) - { - const TouchPoint::State state = event.GetPoint(0u).state; - - // Clamp to integer values; this is to reduce flicking due to pixel misalignment - const float localPoint = static_cast( static_cast( event.GetPoint( 0 ).local.y ) ); - - if( TouchPoint::Down == state ) - { - mLastPoint = localPoint; - mAnimation = Animation::New( 0.25f ); - } - else if( TouchPoint::Motion == state ) - { - if( mAnimation ) - { - mAnimation.AnimateBy( Property(actor, Actor::Property::POSITION), Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunction::LINEAR ); - mAnimation.Play(); - mLastPoint = localPoint; - } - } - } - - return true; - } - - private: +private: struct LoggerState { diff --git a/examples/magnifier/magnifier-example.cpp b/examples/magnifier/magnifier-example.cpp index 279713d..fb461b5 100644 --- a/examples/magnifier/magnifier-example.cpp +++ b/examples/magnifier/magnifier-example.cpp @@ -213,7 +213,7 @@ public: APPLICATION_TITLE ); mContent.SetLeaveRequired(true); - mContent.TouchedSignal().Connect( this, &ExampleController::OnTouched ); + mContent.TouchSignal().Connect( this, &ExampleController::OnTouched ); // Create magnifier (controlled by human touch) Layer overlay = Layer::New(); @@ -300,33 +300,32 @@ public: * @param[in] actor The actor that received the touch * @param[in] event The touch-event information */ - bool OnTouched( Actor actor, const TouchEvent& event ) + bool OnTouched( Actor actor, const TouchData& event ) { if(event.GetPointCount() > 0) { - const TouchPoint& point = event.GetPoint(0); - switch(point.state) + switch( event.GetState( 0 ) ) { - case TouchPoint::Down: - case TouchPoint::Motion: + case PointState::DOWN: + case PointState::MOTION: { ShowMagnifier(); break; } - case TouchPoint::Up: - case TouchPoint::Leave: - case TouchPoint::Interrupted: + case PointState::UP: + case PointState::LEAVE: + case PointState::INTERRUPTED: { HideMagnifier(); break; } - default: + case PointState::STATIONARY: { break; } } // end switch - Vector3 touchPoint(point.screen); + Vector3 touchPoint( event.GetScreenPosition( 0 ) ); SetMagnifierPosition(touchPoint - mStageSize * 0.5f); } diff --git a/examples/mesh-sorting/mesh-sorting-example.cpp b/examples/mesh-sorting/mesh-sorting-example.cpp index 28d7f9f..b521708 100644 --- a/examples/mesh-sorting/mesh-sorting-example.cpp +++ b/examples/mesh-sorting/mesh-sorting-example.cpp @@ -187,7 +187,7 @@ public: meshActor.RegisterProperty("uHue", i/(float)NUMBER_OF_SAMPLES); - meshActor.TouchedSignal().Connect(this, &ExampleController::OnTouched); + meshActor.TouchSignal().Connect(this, &ExampleController::OnTouched); std::ostringstream oss; oss << "Mesh Actor " << i; meshActor.SetName(oss.str()); @@ -196,7 +196,7 @@ public: mActors[NUMBER_OF_SAMPLES-2].GetRendererAt(0).SetTextures( firstTextureSet ); - stage.GetRootLayer().TouchedSignal().Connect(this, &ExampleController::OnStageTouched); + stage.GetRootLayer().TouchSignal().Connect(this, &ExampleController::OnStageTouched); } void PrintDepths() @@ -227,9 +227,9 @@ public: printf("\n"); } - bool OnTouched( Actor actor, const TouchEvent& event ) + bool OnTouched( Actor actor, const TouchData& event ) { - if( event.GetPoint(0).state == TouchPoint::Finished ) + if( event.GetState( 0 ) == PointState::UP ) { int index = actor.GetProperty(actor.GetPropertyIndex("index")); @@ -244,9 +244,9 @@ public: return true; } - bool OnStageTouched( Actor rootLayer, const TouchEvent& event ) + bool OnStageTouched( Actor rootLayer, const TouchData& event ) { - if( event.GetPoint(0).state == TouchPoint::Finished ) + if( event.GetState( 0 ) == PointState::UP ) { switch( mZMode ) { diff --git a/examples/metaball-explosion/metaball-explosion-example.cpp b/examples/metaball-explosion/metaball-explosion-example.cpp index 231d778..166f8e2 100644 --- a/examples/metaball-explosion/metaball-explosion-example.cpp +++ b/examples/metaball-explosion/metaball-explosion-example.cpp @@ -192,7 +192,7 @@ public: /** * Touch event function */ - bool OnTouch( Actor actor, const TouchEvent& touch ); + bool OnTouch( Actor actor, const TouchData& touch ); /** * Key event function @@ -344,7 +344,7 @@ void MetaballExplosionController::Create( Application& app ) mTimerDispersion.TickSignal().Connect(this, &MetaballExplosionController::OnTimerDispersionTick); // Connect the callback to the touch signal on the mesh actor - stage.GetRootLayer().TouchedSignal().Connect( this, &MetaballExplosionController::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &MetaballExplosionController::OnTouch ); } Geometry MetaballExplosionController::CreateGeometry() @@ -681,31 +681,32 @@ void MetaballExplosionController::SetPositionToMetaballs(Vector2 & metaballCente mCompositionActor.SetProperty( mPositionIndex, metaballCenter ); } -bool MetaballExplosionController::OnTouch( Actor actor, const TouchEvent& touch ) +bool MetaballExplosionController::OnTouch( Actor actor, const TouchData& touch ) { - const TouchPoint &point = touch.GetPoint(0); float aspectR = mScreenSize.y / mScreenSize.x; - switch( point.state ) + switch( touch.GetState( 0 ) ) { - case TouchPoint::Down: + case PointState::DOWN: { ResetMetaballs(true); - Vector2 metaballCenter = Vector2((point.screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - point.screen.y) / mScreenSize.y) - 0.5) * 2.0; + const Vector2 screen = touch.GetScreenPosition( 0 ); + Vector2 metaballCenter = Vector2((screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - screen.y) / mScreenSize.y) - 0.5) * 2.0; SetPositionToMetaballs(metaballCenter); break; } - case TouchPoint::Motion: + case PointState::MOTION: { - Vector2 metaballCenter = Vector2((point.screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - point.screen.y) / mScreenSize.y) - 0.5) * 2.0; + const Vector2 screen = touch.GetScreenPosition( 0 ); + Vector2 metaballCenter = Vector2((screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - screen.y) / mScreenSize.y) - 0.5) * 2.0; SetPositionToMetaballs(metaballCenter); break; } - case TouchPoint::Up: - case TouchPoint::Leave: - case TouchPoint::Interrupted: + case PointState::UP: + case PointState::LEAVE: + case PointState::INTERRUPTED: { mTimerDispersion.Start(); break; diff --git a/examples/metaball-refrac/metaball-refrac-example.cpp b/examples/metaball-refrac/metaball-refrac-example.cpp index a1382b3..b55515a 100644 --- a/examples/metaball-refrac/metaball-refrac-example.cpp +++ b/examples/metaball-refrac/metaball-refrac-example.cpp @@ -164,7 +164,7 @@ public: ~MetaballRefracController(); void Create( Application& app ); - bool OnTouch( Actor actor, const TouchEvent& touch ); + bool OnTouch( Actor actor, const TouchData& touch ); void OnKeyEvent(const KeyEvent& event); void SetGravity(const Vector2 & gravity); @@ -283,7 +283,7 @@ void MetaballRefracController::Create( Application& app ) CreateAnimations(); // Connect the callback to the touch signal on the mesh actor - stage.GetRootLayer().TouchedSignal().Connect( this, &MetaballRefracController::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &MetaballRefracController::OnTouch ); } /** @@ -759,13 +759,12 @@ void MetaballRefracController::SetPositionToMetaballs(Vector2 & metaballCenter) } } -bool MetaballRefracController::OnTouch( Actor actor, const TouchEvent& touch ) +bool MetaballRefracController::OnTouch( Actor actor, const TouchData& touch ) { - const TouchPoint &point = touch.GetPoint(0); float aspectR = mScreenSize.y / mScreenSize.x; - switch(point.state) + switch( touch.GetState( 0 ) ) { - case TouchPoint::Down: + case PointState::DOWN: { StopAfterClickAnimations(); for (int i = 0 ; i < METABALL_NUMBER ; i++) @@ -776,17 +775,18 @@ bool MetaballRefracController::OnTouch( Actor actor, const TouchEvent& touch ) //We draw with the refraction-composition shader mRendererRefraction.SetTextures(mTextureSetRefraction); mRendererRefraction.SetShader( mShaderRefraction ); - mCurrentTouchPosition = point.screen; + mCurrentTouchPosition = touch.GetScreenPosition( 0 ); //we use the click position for the metaballs - Vector2 metaballCenter = Vector2((point.screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - point.screen.y) / mScreenSize.y) - 0.5) * 2.0; + Vector2 metaballCenter = Vector2((mCurrentTouchPosition.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - mCurrentTouchPosition.y) / mScreenSize.y) - 0.5) * 2.0; SetPositionToMetaballs(metaballCenter); break; } - case TouchPoint::Motion: + case PointState::MOTION: { - Vector2 displacement = point.screen - mCurrentTouchPosition; - mCurrentTouchPosition = point.screen; + Vector2 screen = touch.GetScreenPosition( 0 ); + Vector2 displacement = screen - mCurrentTouchPosition; + mCurrentTouchPosition = screen; mMetaballPosVariationTo.x += (displacement.x / mScreenSize.x) * 2.2; mMetaballPosVariationTo.y += (- displacement.y / mScreenSize.y) * 2.2; @@ -803,13 +803,13 @@ bool MetaballRefracController::OnTouch( Actor actor, const TouchEvent& touch ) mPositionVarAnimation[1].Play(); //we use the click position for the metaballs - Vector2 metaballCenter = Vector2((point.screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - point.screen.y) / mScreenSize.y) - 0.5) * 2.0; + Vector2 metaballCenter = Vector2((screen.x / mScreenSize.x) - 0.5, (aspectR * (mScreenSize.y - screen.y) / mScreenSize.y) - 0.5) * 2.0; SetPositionToMetaballs(metaballCenter); break; } - case TouchPoint::Up: - case TouchPoint::Leave: - case TouchPoint::Interrupted: + case PointState::UP: + case PointState::LEAVE: + case PointState::INTERRUPTED: { //Stop click animations StopClickAnimations(); diff --git a/examples/perf-scroll/perf-scroll.cpp b/examples/perf-scroll/perf-scroll.cpp index 78ca137..bdf2195 100644 --- a/examples/perf-scroll/perf-scroll.cpp +++ b/examples/perf-scroll/perf-scroll.cpp @@ -284,7 +284,7 @@ public: mSize = Vector3( stageSize.x / mColumnsPerPage, stageSize.y / mRowsPerPage, 0.0f ); // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchedSignal().Connect( this, &PerfScroll::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &PerfScroll::OnTouch ); mParent = Actor::New(); mParent.SetAnchorPoint( AnchorPoint::TOP_LEFT ); @@ -302,7 +302,7 @@ public: ShowAnimation(); } - bool OnTouch( Actor actor, const TouchEvent& touch ) + bool OnTouch( Actor actor, const TouchData& touch ) { // quit the application mApplication.Quit(); diff --git a/examples/refraction-effect/refraction-effect-example.cpp b/examples/refraction-effect/refraction-effect-example.cpp index ea8bb6b..189a7c7 100644 --- a/examples/refraction-effect/refraction-effect-example.cpp +++ b/examples/refraction-effect/refraction-effect-example.cpp @@ -294,7 +294,7 @@ private: mContent.Add( mMeshActor ); // Connect the callback to the touch signal on the mesh actor - mContent.TouchedSignal().Connect( this, &RefractionEffectExample::OnTouch ); + mContent.TouchSignal().Connect( this, &RefractionEffectExample::OnTouch ); // shader used when the finger is touching the screen. render refraction effect mShaderRefraction = Shader::New( VERTEX_SHADER_REFRACTION, FRAGMENT_SHADER_REFRACTION ); @@ -348,16 +348,15 @@ private: return true; } - bool OnTouch( Actor actor , const TouchEvent& event ) + bool OnTouch( Actor actor, const TouchData& event ) { - const TouchPoint &point = event.GetPoint(0); - switch(point.state) + switch( event.GetState( 0 ) ) { - case TouchPoint::Down: + case PointState::DOWN: { mRenderer.SetShader( mShaderRefraction ); - SetLightXYOffset( point.screen ); + SetLightXYOffset( event.GetScreenPosition( 0 ) ); mLightAnimation.Play(); @@ -372,15 +371,15 @@ private: break; } - case TouchPoint::Motion: + case PointState::MOTION: { // make the light position following the finger movement - SetLightXYOffset( point.screen ); + SetLightXYOffset( event.GetScreenPosition( 0 ) ); break; } - case TouchPoint::Up: - case TouchPoint::Leave: - case TouchPoint::Interrupted: + case PointState::UP: + case PointState::LEAVE: + case PointState::INTERRUPTED: { mLightAnimation.Pause(); @@ -394,9 +393,7 @@ private: mStrenghAnimation.Play(); break; } - case TouchPoint::Stationary: - case TouchPoint::Last: - default: + case PointState::STATIONARY: { break; } diff --git a/examples/scroll-view/scroll-view-example.cpp b/examples/scroll-view/scroll-view-example.cpp index 259024b..1a8d12a 100644 --- a/examples/scroll-view/scroll-view-example.cpp +++ b/examples/scroll-view/scroll-view-example.cpp @@ -459,7 +459,7 @@ private: actor.SetParentOrigin(ParentOrigin::CENTER); actor.SetAnchorPoint(AnchorPoint::CENTER); - actor.TouchedSignal().Connect( this, &ExampleController::OnTouchImage ); + actor.TouchSignal().Connect( this, &ExampleController::OnTouchImage ); return actor; } @@ -489,12 +489,11 @@ private: * @param[in] actor The actor touched * @param[in] event The TouchEvent. */ - bool OnTouchImage( Actor actor, const TouchEvent& event ) + bool OnTouchImage( Actor actor, const TouchData& event ) { - if( (event.points.size() > 0) && (!mScrolling) ) + if( (event.GetPointCount() > 0) && (!mScrolling) ) { - TouchPoint point = event.points[0]; - if(point.state == TouchPoint::Up) + if( event.GetState( 0 ) == PointState::UP ) { // Spin the Image a few times. Animation animation = Animation::New(SPIN_DURATION); diff --git a/examples/super-blur-bloom/super-blur-bloom-example.cpp b/examples/super-blur-bloom/super-blur-bloom-example.cpp index 7c4ed43..3196a3b 100644 --- a/examples/super-blur-bloom/super-blur-bloom-example.cpp +++ b/examples/super-blur-bloom/super-blur-bloom-example.cpp @@ -130,17 +130,16 @@ private: mBloomView.Add( mBloomActor ); // Connect the callback to the touch signal on the background - mSuperBlurView.TouchedSignal().Connect( this, &BlurExample::OnTouch ); - mBloomView.TouchedSignal().Connect( this, &BlurExample::OnTouch ); + mSuperBlurView.TouchSignal().Connect( this, &BlurExample::OnTouch ); + mBloomView.TouchSignal().Connect( this, &BlurExample::OnTouch ); } // Callback function of the touch signal on the background - bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& event) + bool OnTouch(Dali::Actor actor, const Dali::TouchData& event) { - const TouchPoint &point = event.GetPoint(0); - switch(point.state) + switch( event.GetState( 0 ) ) { - case TouchPoint::Down: + case PointState::DOWN: { if( mAnimation ) { @@ -159,9 +158,9 @@ private: mAnimation.Play(); break; } - case TouchPoint::Up: - case TouchPoint::Leave: - case TouchPoint::Interrupted: + case PointState::UP: + case PointState::LEAVE: + case PointState::INTERRUPTED: { if( mAnimation ) { @@ -180,10 +179,8 @@ private: mAnimation.Play(); break; } - case TouchPoint::Motion: - case TouchPoint::Stationary: - case TouchPoint::Last: - default: + case PointState::MOTION: + case PointState::STATIONARY: { break; } diff --git a/examples/text-field/text-field-example.cpp b/examples/text-field/text-field-example.cpp index 8b611b2..2a60569 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -136,7 +136,7 @@ public: popup.SetSize( width, 0.0f ); popup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); popup.SetSizeModeFactor( POPUP_SIZE_FACTOR_TO_PARENT ); - popup.TouchedSignal().Connect( this, &TextFieldExample::OnPopupTouched ); + popup.TouchSignal().Connect( this, &TextFieldExample::OnPopupTouched ); return popup; } @@ -159,15 +159,14 @@ public: mField.Reset(); } - bool OnPopupTouched( Actor actor, const TouchEvent& event ) + bool OnPopupTouched( Actor actor, const TouchData& event ) { // End edit mode for TextField if parent Popup touched. if(event.GetPointCount() > 0) { - const TouchPoint& point = event.GetPoint(0); - switch(point.state) + switch( event.GetState( 0 ) ) { - case TouchPoint::Down: + case PointState::DOWN: { // Update the folder text and lose focus for Key events if( mButton && mField ) diff --git a/examples/text-label-emojis/text-label-emojis.cpp b/examples/text-label-emojis/text-label-emojis.cpp index f2af26d..f5415b2 100644 --- a/examples/text-label-emojis/text-label-emojis.cpp +++ b/examples/text-label-emojis/text-label-emojis.cpp @@ -63,7 +63,7 @@ public: mTableView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); mTableView.SetParentOrigin( ParentOrigin::TOP_LEFT ); mTableView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mTableView.TouchedSignal().Connect( this, &EmojiExample::OnTouchEvent ); + mTableView.TouchSignal().Connect( this, &EmojiExample::OnTouch ); stage.Add( mTableView ); for( unsigned int index = 0u; index < NUMBER_OF_EMOJIS; ++index ) @@ -81,21 +81,21 @@ public: } } - bool OnTouchEvent( Actor actor, const TouchEvent& event ) + bool OnTouch( Actor actor, const TouchData& event ) { if( 1u == event.GetPointCount() ) { - const TouchPoint::State state = event.GetPoint(0u).state; + const PointState::Type state = event.GetState( 0 ); // Clamp to integer values; this is to reduce flicking due to pixel misalignment - const float localPoint = static_cast( static_cast( event.GetPoint( 0 ).local.y ) ); + const float localPoint = static_cast( static_cast( event.GetLocalPosition( 0 ).y ) ); - if( TouchPoint::Down == state ) + if( PointState::DOWN == state ) { mLastPoint = localPoint; mAnimation = Animation::New( 0.25f ); } - else if( TouchPoint::Motion == state ) + else if( PointState::MOTION == state ) { if( mAnimation ) { diff --git a/examples/text-label-multi-language/text-label-multi-language-example.cpp b/examples/text-label-multi-language/text-label-multi-language-example.cpp index 95ebacf..8005b58 100644 --- a/examples/text-label-multi-language/text-label-multi-language-example.cpp +++ b/examples/text-label-multi-language/text-label-multi-language-example.cpp @@ -66,7 +66,7 @@ public: mTableView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT ); mTableView.SetParentOrigin( ParentOrigin::TOP_LEFT ); mTableView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mTableView.TouchedSignal().Connect( this, &TextLabelMultiLanguageExample::OnTouchEvent ); + mTableView.TouchSignal().Connect( this, &TextLabelMultiLanguageExample::OnTouch ); stage.Add( mTableView ); for( unsigned int index = 0u; index < NUMBER_OF_LANGUAGES; ++index ) @@ -84,21 +84,21 @@ public: } } - bool OnTouchEvent( Actor actor, const TouchEvent& event ) + bool OnTouch( Actor actor, const TouchData& event ) { if( 1u == event.GetPointCount() ) { - const TouchPoint::State state = event.GetPoint(0u).state; + const PointState::Type state = event.GetState( 0 ); // Clamp to integer values; this is to reduce flicking due to pixel misalignment - const float localPoint = static_cast( static_cast( event.GetPoint( 0 ).local.y ) ); + const float localPoint = static_cast( static_cast( event.GetLocalPosition( 0 ).y ) ); - if( TouchPoint::Down == state ) + if( PointState::DOWN == state ) { mLastPoint = localPoint; mAnimation = Animation::New( 0.25f ); } - else if( TouchPoint::Motion == state ) + else if( PointState::MOTION == state ) { if( mAnimation ) { diff --git a/examples/tilt/tilt-example.cpp b/examples/tilt/tilt-example.cpp index 08d6fd6..0adc72e 100644 --- a/examples/tilt/tilt-example.cpp +++ b/examples/tilt/tilt-example.cpp @@ -56,7 +56,7 @@ public: stage.Add( mTextLabel ); // Respond to a click anywhere on the stage - stage.GetRootLayer().TouchedSignal().Connect( this, &TiltController::OnTouch ); + stage.GetRootLayer().TouchSignal().Connect( this, &TiltController::OnTouch ); CreateSensor(); } @@ -71,7 +71,7 @@ public: } } - bool OnTouch( Actor actor, const TouchEvent& touch ) + bool OnTouch( Actor actor, const TouchData& touch ) { // quit the application mApplication.Quit();