X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fpage-turn-view%2Fpage-turn-view-impl.cpp;h=a8be341b60634b7284571281ba1ef26ac8550207;hp=7a00f877f30bc33ed5c61e0c01c6ecb5ecfefe36;hb=8a647e87a01c5c78451653c1264a9eea81ac9b20;hpb=6d96d7c0b6a74a5fe927dcaa2d9b1fae932af08d diff --git a/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp b/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp index 7a00f87..a8be341 100644 --- a/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp +++ b/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 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. @@ -32,6 +32,7 @@ #include #include #include +#include using namespace Dali; @@ -263,9 +264,9 @@ PageTurnView::Page::Page() : isTurnBack( false ) { actor = Actor::New(); - actor.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); - actor.SetParentOrigin( ParentOrigin::CENTER_LEFT ); - actor.SetVisible( false ); + actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT ); + actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER_LEFT ); + actor.SetProperty( Actor::Property::VISIBLE, false ); propertyPanDisplacement = actor.RegisterProperty( PROPERTY_PAN_DISPLACEMENT, 0.f ); propertyPanCenter = actor.RegisterProperty(PROPERTY_PAN_CENTER, Vector2::ZERO); @@ -362,6 +363,10 @@ PageTurnView::PageTurnView( PageFactory& pageFactory, const Vector2& viewPageSiz mPagePanStartedSignal(), mPagePanFinishedSignal() { + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::PAGE_TAB_LIST ) ); + } ); } PageTurnView::~PageTurnView() @@ -388,14 +393,14 @@ void PageTurnView::OnInitialize() for( int i = 0; i < NUMBER_OF_CACHED_PAGES; i++ ) { mPages.push_back( Page() ); - mPages[i].actor.SetSize( mPageSize ); + mPages[i].actor.SetProperty( Actor::Property::SIZE, mPageSize ); Self().Add( mPages[i].actor ); } // create the layer for turning pages mTurningPageLayer = Layer::New(); - mTurningPageLayer.SetAnchorPoint( AnchorPoint::CENTER_LEFT ); - mTurningPageLayer.SetBehavior(Layer::LAYER_3D); + mTurningPageLayer.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER_LEFT ); + mTurningPageLayer.SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D ); mTurningPageLayer.Raise(); // Set control size and the parent origin of page layers @@ -408,12 +413,12 @@ void PageTurnView::OnInitialize() for( int i = 0; i < NUMBER_OF_CACHED_PAGES_EACH_SIDE; i++ ) { AddPage( i ); - mPages[i].actor.SetZ( -static_cast( i )*STATIC_PAGE_INTERVAL_DISTANCE ); + mPages[i].actor.SetProperty( Actor::Property::POSITION_Z, -static_cast( i )*STATIC_PAGE_INTERVAL_DISTANCE ); } - mPages[0].actor.SetVisible(true); + mPages[0].actor.SetProperty( Actor::Property::VISIBLE,true); // enable the pan gesture which is attached to the control - EnableGestureDetection(Gesture::Type(Gesture::Pan)); + EnableGestureDetection(GestureType::Value(GestureType::PAN)); } Shader PageTurnView::CreateShader( const Property::Map& shaderMap ) @@ -448,22 +453,22 @@ Shader PageTurnView::CreateShader( const Property::Map& shaderMap ) void PageTurnView::SetupShadowView() { mShadowView = Toolkit::ShadowView::New( 0.25f, 0.25f ); - Vector3 origin = mTurningPageLayer.GetCurrentParentOrigin(); - mShadowView.SetParentOrigin( origin ); - mShadowView.SetAnchorPoint( origin ); + Vector3 origin = mTurningPageLayer.GetCurrentProperty< Vector3 >( Actor::Property::PARENT_ORIGIN ); + mShadowView.SetProperty( Actor::Property::PARENT_ORIGIN, origin ); + mShadowView.SetProperty( Actor::Property::ANCHOR_POINT, origin ); mShadowView.SetPointLightFieldOfView( Math::PI / 2.0f); mShadowView.SetShadowColor(DEFAULT_SHADOW_COLOR); mShadowPlaneBackground = Actor::New(); - mShadowPlaneBackground.SetParentOrigin( ParentOrigin::CENTER ); - mShadowPlaneBackground.SetSize( mControlSize ); + mShadowPlaneBackground.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + mShadowPlaneBackground.SetProperty( Actor::Property::SIZE, mControlSize ); Self().Add( mShadowPlaneBackground ); mShadowView.SetShadowPlaneBackground( mShadowPlaneBackground ); mPointLight = Actor::New(); - mPointLight.SetAnchorPoint( origin ); - mPointLight.SetParentOrigin( origin ); - mPointLight.SetPosition( 0.f, 0.f, mPageSize.width*POINT_LIGHT_HEIGHT_RATIO ); + mPointLight.SetProperty( Actor::Property::ANCHOR_POINT, origin ); + mPointLight.SetProperty( Actor::Property::PARENT_ORIGIN, origin ); + mPointLight.SetProperty( Actor::Property::POSITION, Vector3( 0.f, 0.f, mPageSize.width*POINT_LIGHT_HEIGHT_RATIO )); Self().Add( mPointLight ); mShadowView.SetPointLight( mPointLight ); @@ -471,14 +476,14 @@ void PageTurnView::SetupShadowView() mShadowView.Activate(); } -void PageTurnView::OnStageConnection( int depth ) +void PageTurnView::OnSceneConnection( int depth ) { SetupShadowView(); - Control::OnStageConnection( depth ); + Control::OnSceneConnection( depth ); } -void PageTurnView::OnStageDisconnection() +void PageTurnView::OnSceneDisconnection() { if(mShadowView) { @@ -491,7 +496,7 @@ void PageTurnView::OnStageDisconnection() // make sure the status of the control is updated correctly when the pan gesture is interrupted StopTurning(); - Control::OnStageDisconnection(); + Control::OnSceneDisconnection(); } void PageTurnView::SetPageSize( const Vector2& viewPageSize ) @@ -500,19 +505,19 @@ void PageTurnView::SetPageSize( const Vector2& viewPageSize ) if( mPointLight ) { - mPointLight.SetPosition( 0.f, 0.f, mPageSize.width*POINT_LIGHT_HEIGHT_RATIO ); + mPointLight.SetProperty( Actor::Property::POSITION, Vector3( 0.f, 0.f, mPageSize.width*POINT_LIGHT_HEIGHT_RATIO )); } for( size_t i=0; i 0 ) { - mPages[(pageId-1)%NUMBER_OF_CACHED_PAGES].actor.SetVisible(true); + mPages[(pageId-1)%NUMBER_OF_CACHED_PAGES].actor.SetProperty( Actor::Property::VISIBLE,true); } // set ordered depth to the stacked pages OrganizePageDepth(); @@ -589,8 +594,8 @@ void PageTurnView::AddPage( int pageIndex ) } float degree = isLeftSide ? 180.f :0.f; - mPages[index].actor.SetOrientation( Degree( degree ), Vector3::YAXIS ); - mPages[index].actor.SetVisible( false ); + mPages[index].actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree( degree ), Vector3::YAXIS ) ); + mPages[index].actor.SetProperty( Actor::Property::VISIBLE, false ); mPages[index].UseEffect( mSpineEffectShader, mGeometry ); mPages[index].SetTexture( newPage ); @@ -605,26 +610,27 @@ void PageTurnView::RemovePage( int pageIndex ) if( pageIndex > -1 && pageIndex < mTotalPageCount) { int index = pageIndex % NUMBER_OF_CACHED_PAGES; - mPages[index].actor.SetVisible(false); + mPages[index].actor.SetProperty( Actor::Property::VISIBLE,false); } } void PageTurnView::OnPan( const PanGesture& gesture ) { // the pan gesture is attached to control itself instead of each page - switch( gesture.state ) + switch( gesture.GetState() ) { - case Gesture::Started: + case GestureState::STARTED: { // check whether the undergoing turning page number already reaches the maximum allowed if( mPageUpdated && mAnimatingCount< MAXIMUM_TURNING_NUM && mSlidingCount < 1 ) { - SetPanActor( gesture.position ); // determine which page actor is panned + const Vector2& position = gesture.GetPosition(); + SetPanActor( position ); // determine which page actor is panned if( mTurningPageIndex != -1 && mPages[mTurningPageIndex % NUMBER_OF_CACHED_PAGES].actor.GetParent() != Self()) // if the page is added to turning layer,it is undergoing an animation currently { mTurningPageIndex = -1; } - PanStarted( SetPanPosition( gesture.position ) ); // pass in the pan position in the local page coordinate + PanStarted( SetPanPosition( position ) ); // pass in the pan position in the local page coordinate } else { @@ -632,19 +638,19 @@ void PageTurnView::OnPan( const PanGesture& gesture ) } break; } - case Gesture::Continuing: + case GestureState::CONTINUING: { - PanContinuing( SetPanPosition( gesture.position ) ); // pass in the pan position in the local page coordinate + PanContinuing( SetPanPosition( gesture.GetPosition() ) ); // pass in the pan position in the local page coordinate break; } - case Gesture::Finished: - case Gesture::Cancelled: + case GestureState::FINISHED: + case GestureState::CANCELLED: { - PanFinished( SetPanPosition( gesture.position ), gesture.GetSpeed() ); + PanFinished( SetPanPosition( gesture.GetPosition() ), gesture.GetSpeed() ); break; } - case Gesture::Clear: - case Gesture::Possible: + case GestureState::CLEAR: + case GestureState::POSSIBLE: default: { break; @@ -712,7 +718,7 @@ void PageTurnView::PanContinuing( const Vector2& gesturePosition ) int id = mTurningPageIndex + (mPages[mIndex].isTurnBack ? -1 : 1); if( id >=0 && id < mTotalPageCount ) { - mPages[id%NUMBER_OF_CACHED_PAGES].actor.SetVisible(true); + mPages[id%NUMBER_OF_CACHED_PAGES].actor.SetProperty( Actor::Property::VISIBLE,true); } mShadowView.RemoveConstraints(); @@ -904,13 +910,13 @@ void PageTurnView::TurnedOver( Animation& animation ) mAnimationPageIdPair.erase( animation ); float degree = mPages[index].isTurnBack ? 180.f : 0.f; - mPages[index].actor.SetOrientation( Degree(degree), Vector3::YAXIS ); + mPages[index].actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree(degree), Vector3::YAXIS ) ); mPages[index].UseEffect( mSpineEffectShader ); int id = pageId + (mPages[index].isTurnBack ? -1 : 1); if( id >=0 && id < mTotalPageCount ) { - mPages[id%NUMBER_OF_CACHED_PAGES].actor.SetVisible(false); + mPages[id%NUMBER_OF_CACHED_PAGES].actor.SetProperty( Actor::Property::VISIBLE,false); } OnTurnedOver( mPages[index].actor, mPages[index].isTurnBack ); @@ -934,7 +940,7 @@ void PageTurnView::SliddenBack( Animation& animation ) int id = pageId + (mPages[index].isTurnBack ? -1 : 1); if( id >=0 && id < mTotalPageCount ) { - mPages[id%NUMBER_OF_CACHED_PAGES].actor.SetVisible(false); + mPages[id%NUMBER_OF_CACHED_PAGES].actor.SetProperty( Actor::Property::VISIBLE,false); } // Guard against destruction during signal emission @@ -948,11 +954,11 @@ void PageTurnView::OrganizePageDepth() { if(mCurrentPageIndex+i < mTotalPageCount) { - mPages[( mCurrentPageIndex+i )%NUMBER_OF_CACHED_PAGES].actor.SetZ( -static_cast( i )*STATIC_PAGE_INTERVAL_DISTANCE ); + mPages[( mCurrentPageIndex+i )%NUMBER_OF_CACHED_PAGES].actor.SetProperty( Actor::Property::POSITION_Z, -static_cast( i )*STATIC_PAGE_INTERVAL_DISTANCE ); } if( mCurrentPageIndex >= i + 1 ) { - mPages[( mCurrentPageIndex-i-1 )%NUMBER_OF_CACHED_PAGES].actor.SetZ( -static_cast( i )*STATIC_PAGE_INTERVAL_DISTANCE ); + mPages[( mCurrentPageIndex-i-1 )%NUMBER_OF_CACHED_PAGES].actor.SetProperty( Actor::Property::POSITION_Z, -static_cast( i )*STATIC_PAGE_INTERVAL_DISTANCE ); } } } @@ -969,7 +975,7 @@ void PageTurnView::StopTurning() mPages[ index ].actor.RemoveConstraints(); mPages[ index ].UseEffect( mSpineEffectShader ); float degree = mTurningPageIndex==mCurrentPageIndex ? 0.f :180.f; - mPages[index].actor.SetOrientation( Degree(degree), Vector3::YAXIS ); + mPages[index].actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Degree(degree), Vector3::YAXIS ) ); mPageUpdated = true; }