2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/controls/page-turn-view/page-turn-landscape-view-impl.h>
22 #include <dali/public-api/object/type-registry.h>
23 #include <dali/devel-api/object/type-registry-helper.h>
24 #include <dali/devel-api/rendering/cull-face.h>
39 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::PageTurnLandscapeView, Toolkit::PageTurnView, NULL )
40 DALI_TYPE_REGISTRATION_END()
44 PageTurnLandscapeView::PageTurnLandscapeView( PageFactory& pageFactory, const Vector2& pageSize )
45 : PageTurnView( pageFactory, pageSize )
49 PageTurnLandscapeView::~PageTurnLandscapeView()
52 Toolkit::PageTurnLandscapeView PageTurnLandscapeView::New( PageFactory& pageFactory, const Vector2& pageSize )
54 // Create the implementation, temporarily owned on stack
55 IntrusivePtr< PageTurnLandscapeView > internalPageTurnView = new PageTurnLandscapeView( pageFactory, pageSize );
57 // Pass ownership to CustomActor
58 Dali::Toolkit::PageTurnLandscapeView pageTurnView( *internalPageTurnView );
60 // Second-phase init of the implementation
61 // This can only be done after the CustomActor connection has been made...
62 internalPageTurnView->Initialize();
67 void PageTurnLandscapeView::OnPageTurnViewInitialize()
69 mControlSize = Vector2( mPageSize.width * 2.f, mPageSize.height );
70 Self().SetSize( mControlSize );
71 mTurningPageLayer.SetParentOrigin( ParentOrigin::CENTER );
74 void PageTurnLandscapeView::OnAddPage( ImageActor newPage, bool isLeftSide )
76 newPage.SetParentOrigin( ParentOrigin::CENTER );
77 SetCullFace( newPage, CullBack );
79 if( 0 < newPage.GetChildCount() )
81 ImageActor backImage = ImageActor::DownCast( newPage.GetChildAt( 0 ) );
82 backImage.SetParentOrigin( ParentOrigin::CENTER );
83 backImage.SetSize( mPageSize );
84 SetCullFace( backImage, CullFront );
85 backImage.SetZ( 0.25f * STATIC_PAGE_INTERVAL_DISTANCE );
89 SetShaderEffect( newPage, mSpineEffectBack );
93 Vector2 PageTurnLandscapeView::SetPanPosition( const Vector2& gesturePosition )
95 if( mIsTurnBack[mPanActor] )
97 return Vector2( mPageSize.width - gesturePosition.x, gesturePosition.y );
101 return Vector2( gesturePosition.x - mPageSize.width, gesturePosition.y );
105 void PageTurnLandscapeView::SetPanActor( const Vector2& panPosition )
107 if( panPosition.x > mPageSize.width && mCurrentPageIndex < mTotalPageCount-1 )
109 mPanActor = mPageActors[mCurrentPageIndex%NUMBER_OF_CACHED_PAGES]; // right side page
110 mTurningPageIndex = mCurrentPageIndex;
112 else if( panPosition.x <= mPageSize.width && mCurrentPageIndex > 0 )
114 mPanActor = mPageActors[ (mCurrentPageIndex-1)%NUMBER_OF_CACHED_PAGES ]; // left side page
115 mTurningPageIndex = mCurrentPageIndex - 1;
123 void PageTurnLandscapeView::SetSpineEffect(ImageActor actor, bool isLeftSide)
127 SetShaderEffect( actor, mSpineEffectBack );
131 SetShaderEffect( actor, mSpineEffectFront );
135 } // namespace Internal
137 } // namespace Toolkit