X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fgestures%2Fgesture-example.cpp;h=bd32658356a9cd1631a7d97426cdab3c5f7710ef;hb=1a473d5189ca7e7d55aca3a64a8a4ff2dc3b6c67;hp=81cd2c774d6b63827a1d0372a8bdae52e758f89e;hpb=2b705324f68cae7b26e150aae9f8e8f12f3751d9;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/gestures/gesture-example.cpp b/examples/gestures/gesture-example.cpp index 81cd2c7..bd32658 100644 --- a/examples/gestures/gesture-example.cpp +++ b/examples/gestures/gesture-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -18,9 +18,6 @@ // EXTERNAL INCLUDES #include #include -#include -#include -#include using namespace Dali; using namespace Dali::Toolkit; @@ -81,10 +78,10 @@ const float ROTATE_BACK_ANIMATION_DURATION( 0.25f ); * @param[in] startTime When to start the animators * @param[in] endTime When to end the animators */ -void AddHelpInfo( const std::string&& string, Actor parent, Animation animation, float startTime, float endTime ) +void AddHelpInfo( const std::string&& string, const Vector2& windowSize, Actor parent, Animation animation, float startTime, float endTime ) { Actor text = TextLabel::New( std::move( string ) ); - Vector3 position( Stage::GetCurrent().GetSize() * HELP_TEXT_POSITION_MULTIPLIER ); + Vector3 position( windowSize * HELP_TEXT_POSITION_MULTIPLIER ); text.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER ); text.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); @@ -141,26 +138,27 @@ private: */ void Create( Application& application ) { - // Get a handle to the stage & connect to the key event signal - Stage stage = Stage::GetCurrent(); - stage.KeyEventSignal().Connect(this, &GestureExample::OnKeyEvent); + // Get a handle to the window & connect to the key event signal + auto window = application.GetWindow(); + Vector2 windowSize = window.GetSize(); + window.KeyEventSignal().Connect(this, &GestureExample::OnKeyEvent); // Create a background with a linear gradient which matches parent size & is placed in the center. Actor background = Control::New(); background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); background.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); background.SetProperty( Control::Property::BACKGROUND, BACKGROUND ); - stage.Add( background ); + window.Add( background ); - // Create a control with a circular gradient that we'll use for the gestures and be a quarter of the size of the stage. + // Create a control with a circular gradient that we'll use for the gestures and be a quarter of the size of the window. Actor touchControl = Control::New(); - touchControl.SetProperty( Actor::Property::SIZE, stage.GetSize() * 0.25f ); + touchControl.SetProperty( Actor::Property::SIZE, windowSize * 0.25f ); touchControl.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); touchControl.SetProperty( Control::Property::BACKGROUND, CONTROL_BACKGROUND ); background.Add( touchControl ); // Connect to the touch signal - touchControl.TouchSignal().Connect( this, &GestureExample::OnTouch ); + touchControl.TouchedSignal().Connect( this, &GestureExample::OnTouch ); touchControl.SetProperty( Actor::Property::LEAVE_REQUIRED, true ); // Create a long press gesture detector, attach the actor & connect @@ -206,10 +204,10 @@ private: float startTime( 0.0f ); float endTime( startTime + HELP_ANIMATION_SEGMENT_TIME ); - AddHelpInfo( "Tap image for animation", background, helpAnimation, startTime, endTime ); - AddHelpInfo( "Press & Hold image to drag", background, helpAnimation, startTime += HELP_ANIMATION_SEGMENT_TIME, endTime += HELP_ANIMATION_SEGMENT_TIME ); - AddHelpInfo( "Pinch image to resize", background, helpAnimation, startTime += HELP_ANIMATION_SEGMENT_TIME, endTime += HELP_ANIMATION_SEGMENT_TIME ); - AddHelpInfo( "Move fingers in a circular motion on image to rotate", background, helpAnimation, startTime += HELP_ANIMATION_SEGMENT_TIME, endTime += HELP_ANIMATION_SEGMENT_TIME ); + AddHelpInfo( "Tap image for animation", windowSize, background, helpAnimation, startTime, endTime ); + AddHelpInfo( "Press & Hold image to drag", windowSize, background, helpAnimation, startTime += HELP_ANIMATION_SEGMENT_TIME, endTime += HELP_ANIMATION_SEGMENT_TIME ); + AddHelpInfo( "Pinch image to resize", windowSize, background, helpAnimation, startTime += HELP_ANIMATION_SEGMENT_TIME, endTime += HELP_ANIMATION_SEGMENT_TIME ); + AddHelpInfo( "Move fingers in a circular motion on image to rotate", windowSize, background, helpAnimation, startTime += HELP_ANIMATION_SEGMENT_TIME, endTime += HELP_ANIMATION_SEGMENT_TIME ); helpAnimation.SetLooping( true ); helpAnimation.Play(); } @@ -220,7 +218,7 @@ private: * @param[in] actor The touched actor * @param[in] touch The touch event */ - bool OnTouch( Actor actor, const TouchData& touch ) + bool OnTouch( Actor actor, const TouchEvent& touch ) { switch( touch.GetState( 0 ) ) { @@ -257,7 +255,7 @@ private: break; } } - return true; + return false; } /** @@ -268,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 ); @@ -296,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; @@ -305,7 +303,7 @@ private: Vector3 newPosition = currentPosition + scaledDisplacement; actor.SetProperty( Actor::Property::POSITION, newPosition ); - switch( pan.state ) + switch( pan.GetState() ) { case Gesture::Started: { @@ -323,9 +321,9 @@ private: anim.AnimateTo( Property( actor, Actor::Property::SCALE ), actor.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ) * PAN_MODE_END_ANIMATION_SCALE, AlphaFunction::BOUNCE ); // Move actor back to center if we're out of bounds - Vector2 halfStageSize = Stage::GetCurrent().GetSize() * 0.5f; - if( ( abs( newPosition.x ) > halfStageSize.width ) || - ( abs( newPosition.y ) > halfStageSize.height ) ) + Vector2 halfWindowSize = Vector2(mApplication.GetWindow().GetSize()) * 0.5f; + if( ( abs( newPosition.x ) > halfWindowSize.width ) || + ( abs( newPosition.y ) > halfWindowSize.height ) ) { anim.AnimateTo( Property( actor, Actor::Property::POSITION ), Vector3::ZERO, AlphaFunction::EASE_IN ); } @@ -371,7 +369,7 @@ private: */ void OnPinch( Actor actor, const PinchGesture& pinch ) { - switch( pinch.state ) + switch( pinch.GetState() ) { case Gesture::Started: { @@ -408,7 +406,7 @@ private: } } - actor.SetProperty( Actor::Property::SCALE, mStartingScale * pinch.scale ); + actor.SetProperty( Actor::Property::SCALE, mStartingScale * pinch.GetScale() ); } /** @@ -419,7 +417,7 @@ private: */ void OnRotation( Actor actor, const RotationGesture& rotation ) { - switch( rotation.state ) + switch( rotation.GetState() ) { case Gesture::Started: { @@ -444,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 ) ) ); } /** @@ -455,7 +453,7 @@ private: */ void OnKeyEvent( const KeyEvent& event ) { - if( event.state == KeyEvent::Down ) + if( event.GetState() == KeyEvent::DOWN ) { if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) {