X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fdrag-drop-detector%2Fdrag-and-drop-detector-impl.cpp;h=994932e175d5b8c637863fdfdd7be75dd648d21d;hp=ed1d2b344ca87475c3f3e9cbc435def58d09069f;hb=0e1683ef848d1d877e26633609fa95e0d2ab36b5;hpb=5e937a6322849b76d49d5b3f41cb5d91c94acd3e diff --git a/dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp b/dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp old mode 100755 new mode 100644 index ed1d2b3..994932e --- a/dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp +++ b/dali-toolkit/internal/drag-drop-detector/drag-and-drop-detector-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 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. @@ -19,7 +19,7 @@ #include #include -#include +#include namespace Dali { @@ -50,8 +50,8 @@ void DragAndDropDetector::Attach(Dali::Toolkit::Control& control) } } mControls.push_back(control); - control.TouchSignal().Connect(this, &DragAndDropDetector::OnDrag); - mFirstEnter.push_back(control.GetId()); + control.TouchedSignal().Connect(this, &DragAndDropDetector::OnDrag); + mFirstEnter.push_back(control.GetProperty< int >( Actor::Property::ID )); mPanGestureDetector.Attach(control); mPanGestureDetector.DetectedSignal().Connect(this, &DragAndDropDetector::OnPan); } @@ -71,9 +71,9 @@ void DragAndDropDetector::Detach(Dali::Toolkit::Control& control) if(match != mControls.end()) { - match->TouchSignal().Disconnect(this, &DragAndDropDetector::OnDrag); + match->TouchedSignal().Disconnect(this, &DragAndDropDetector::OnDrag); mPanGestureDetector.Detach(*match); - mFirstEnter.erase(std::find(mFirstEnter.begin(), mFirstEnter.end(), control.GetId())); + mFirstEnter.erase(std::find(mFirstEnter.begin(), mFirstEnter.end(), control.GetProperty< int >( Actor::Property::ID ))); mControls.erase(match); } } @@ -86,7 +86,7 @@ void DragAndDropDetector::DetachAll() auto iter = mControls.begin(); for(;iter != mControls.end();) { - iter->TouchSignal().Disconnect(this, &DragAndDropDetector::OnDrag); + iter->TouchedSignal().Disconnect(this, &DragAndDropDetector::OnDrag); mPanGestureDetector.Detach(*iter); iter = mControls.erase(iter); } @@ -123,44 +123,46 @@ void DragAndDropDetector::OnPan(Dali::Actor actor, const PanGesture& gesture) { Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); - if(gesture.state == Gesture::Started) + GestureState state = gesture.GetState(); + + if(state == GestureState::STARTED) { - mDragLocalPosition = gesture.position; + mDragLocalPosition = gesture.GetPosition(); mPointDown = true; mDragControl = control; mFirstEnter.clear(); for( auto&& control : mControls) { - mFirstEnter.push_back(control.GetId()); + mFirstEnter.push_back(control.GetProperty< int >( Actor::Property::ID )); } float width = control.GetProperty(Dali::Actor::Property::SIZE_WIDTH); float height = control.GetProperty(Dali::Actor::Property::SIZE_HEIGHT); Vector3 actorPos = control.GetProperty(Dali::Actor::Property::POSITION); mShadowControl = Dali::Toolkit::Control::New(); - mShadowControl.SetPosition(actorPos); - mShadowControl.SetSize(width, height); + mShadowControl.SetProperty( Actor::Property::POSITION, actorPos ); + mShadowControl.SetProperty( Actor::Property::SIZE, Vector2( width, height ) ); mShadowControl.SetBackgroundColor(Vector4(0.3f, 0.3f, 0.3f, 0.7f)); 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 == GestureState::CONTINUING) { - Vector2 screenPosition = gesture.screenPosition; + Vector2 screenPosition = gesture.GetScreenPosition(); control.GetParent().ScreenToLocal(mLocalPosition.x, mLocalPosition.y, screenPosition.x, screenPosition.y); - mShadowControl.SetPosition(mLocalPosition.x - mDragLocalPosition.x, mLocalPosition.y - mDragLocalPosition.y); + mShadowControl.SetProperty( Actor::Property::POSITION, Vector2(mLocalPosition.x - mDragLocalPosition.x, mLocalPosition.y - mDragLocalPosition.y)); } - if(gesture.state == Gesture::Finished) + if(state == GestureState::FINISHED) { mDragControl.GetParent().Remove(mShadowControl); EmitEndedSignal(control); } } -bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchData& data) +bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchEvent& data) { Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor); PointState::Type type = data.GetState(0); @@ -169,7 +171,7 @@ bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchData& data) { if(mDragControl != control && mPointDown) { - auto found = std::find(mFirstEnter.begin(), mFirstEnter.end(), control.GetId()); + auto found = std::find(mFirstEnter.begin(), mFirstEnter.end(), control.GetProperty< int >( Actor::Property::ID )); if(mFirstEnter.end() != found) { SetPosition(data.GetScreenPosition(0)); @@ -188,7 +190,7 @@ bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchData& data) { if(mDragControl != control && mPointDown) { - mFirstEnter.push_back(control.GetId()); + mFirstEnter.push_back(control.GetProperty< int >( Actor::Property::ID )); EmitExitedSignal(control); } } @@ -209,7 +211,7 @@ bool DragAndDropDetector::OnDrag(Dali::Actor actor, const Dali::TouchData& data) } mPointDown = false; } - return true; + return false; } const std::string& DragAndDropDetector::GetContent() const