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/public-api/object/type-registry-helper.h>
37 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::PageTurnLandscapeView, Toolkit::PageTurnView, NULL )
38 DALI_TYPE_REGISTRATION_END()
42 PageTurnLandscapeView::PageTurnLandscapeView( PageFactory& pageFactory, const Vector2& pageSize )
43 : PageTurnView( pageFactory, pageSize )
47 PageTurnLandscapeView::~PageTurnLandscapeView()
50 Toolkit::PageTurnLandscapeView PageTurnLandscapeView::New( PageFactory& pageFactory, const Vector2& pageSize )
52 // Create the implementation, temporarily owned on stack
53 IntrusivePtr< PageTurnLandscapeView > internalPageTurnView = new PageTurnLandscapeView( pageFactory, pageSize );
55 // Pass ownership to CustomActor
56 Dali::Toolkit::PageTurnLandscapeView pageTurnView( *internalPageTurnView );
58 // Second-phase init of the implementation
59 // This can only be done after the CustomActor connection has been made...
60 internalPageTurnView->Initialize();
65 void PageTurnLandscapeView::OnPageTurnViewInitialize()
67 mTurnEffectShader.RegisterProperty(PROPERTY_TEXTURE_WIDTH, 2.f );
68 mSpineEffectShader.RegisterProperty(PROPERTY_TEXTURE_WIDTH, 2.f );
70 mControlSize = Vector2( mPageSize.width * 2.f, mPageSize.height );
71 Self().SetSize( mControlSize );
72 mTurningPageLayer.SetParentOrigin( ParentOrigin::CENTER );
75 void PageTurnLandscapeView::OnAddPage( Actor newPage, bool isLeftSide )
77 newPage.SetParentOrigin( ParentOrigin::CENTER );
80 Vector2 PageTurnLandscapeView::SetPanPosition( const Vector2& gesturePosition )
82 if( mPages[mIndex].isTurnBack )
84 return Vector2( mPageSize.width - gesturePosition.x, gesturePosition.y );
88 return Vector2( gesturePosition.x - mPageSize.width, gesturePosition.y );
92 void PageTurnLandscapeView::SetPanActor( const Vector2& panPosition )
94 if( panPosition.x > mPageSize.width && mCurrentPageIndex < mTotalPageCount )
96 mTurningPageIndex = mCurrentPageIndex;
98 else if( panPosition.x <= mPageSize.width && mCurrentPageIndex > 0 )
100 mTurningPageIndex = mCurrentPageIndex - 1;
104 mTurningPageIndex = -1;
108 } // namespace Internal
110 } // namespace Toolkit