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-helper.h>
23 #include <dali/public-api/object/type-registry.h>
33 DALI_TYPE_REGISTRATION_BEGIN(Toolkit::PageTurnLandscapeView, Toolkit::PageTurnView, NULL)
34 DALI_TYPE_REGISTRATION_END()
38 PageTurnLandscapeView::PageTurnLandscapeView(PageFactory& pageFactory, const Vector2& viewPageSize)
39 : PageTurnView(pageFactory, viewPageSize)
43 PageTurnLandscapeView::~PageTurnLandscapeView()
47 Toolkit::PageTurnLandscapeView PageTurnLandscapeView::New(PageFactory& pageFactory, const Vector2& viewPageSize)
49 // Create the implementation, temporarily owned on stack
50 IntrusivePtr<PageTurnLandscapeView> internalPageTurnView = new PageTurnLandscapeView(pageFactory, viewPageSize);
52 // Pass ownership to CustomActor
53 Dali::Toolkit::PageTurnLandscapeView pageTurnView(*internalPageTurnView);
55 // Second-phase init of the implementation
56 // This can only be done after the CustomActor connection has been made...
57 internalPageTurnView->Initialize();
62 void PageTurnLandscapeView::OnPageTurnViewInitialize()
64 mTurnEffectShader.RegisterProperty(PROPERTY_TEXTURE_WIDTH, 2.f);
65 mSpineEffectShader.RegisterProperty(PROPERTY_TEXTURE_WIDTH, 2.f);
67 mControlSize = Vector2(mPageSize.width * 2.f, mPageSize.height);
68 Self().SetProperty(Actor::Property::SIZE, mControlSize);
69 mTurningPageLayer.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
72 void PageTurnLandscapeView::OnAddPage(Actor newPage, bool isLeftSide)
74 newPage.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
77 Vector2 PageTurnLandscapeView::SetPanPosition(const Vector2& gesturePosition)
79 if(mPages[mIndex].isTurnBack)
81 return Vector2(mPageSize.width - gesturePosition.x, gesturePosition.y);
85 return Vector2(gesturePosition.x - mPageSize.width, gesturePosition.y);
89 void PageTurnLandscapeView::SetPanActor(const Vector2& panPosition)
91 if(panPosition.x > mPageSize.width && mCurrentPageIndex < mTotalPageCount)
93 mTurningPageIndex = mCurrentPageIndex;
95 else if(panPosition.x <= mPageSize.width && mCurrentPageIndex > 0)
97 mTurningPageIndex = mCurrentPageIndex - 1;
101 mTurningPageIndex = -1;
105 } // namespace Internal
107 } // namespace Toolkit