-const int PageTurnView::MAXIMUM_TURNING_NUM = 4;
-const int PageTurnView::NUMBER_OF_CACHED_PAGES_EACH_SIDE = MAXIMUM_TURNING_NUM + 1;
-const int PageTurnView::NUMBER_OF_CACHED_PAGES = NUMBER_OF_CACHED_PAGES_EACH_SIDE*2;
-const float PageTurnView::STATIC_PAGE_INTERVAL_DISTANCE = 1.0f;
-
-PageTurnView::PageTurnView( PageFactory& pageFactory, const Vector2& pageSize )
-: Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS ) ),
- mPageFactory( pageFactory ),
- mPageSize( pageSize ),
- mTotalPageCount( 0 ),
- mPanning( false ),
- mSpineShadowParameter( DEFAULT_SPINE_SHADOW_PARAMETER ),
- mCurrentPageIndex( 0 ),
- mTurningPageIndex( 0 ),
- mIndex( 0 ),
- mPress( false ),
- mPageUpdated( true ),
- mDistanceUpCorner( 0.f ),
- mDistanceBottomCorner( 0.f ),
- mPanDisplacement( 0.f ),
- mConstraints( false ),
+const char* const PageTurnView::PROPERTY_TEXTURE_WIDTH("uTextureWidth"); // uniform name
+const char* const PageTurnView::PROPERTY_ORIGINAL_CENTER("originalCenter"); // property used to constrain the uniform
+const char* const PageTurnView::PROPERTY_CURRENT_CENTER("currentCenter"); // property used to constrain the uniform
+const int PageTurnView::MAXIMUM_TURNING_NUM = 4;
+const int PageTurnView::NUMBER_OF_CACHED_PAGES_EACH_SIDE = MAXIMUM_TURNING_NUM + 1;
+const int PageTurnView::NUMBER_OF_CACHED_PAGES = NUMBER_OF_CACHED_PAGES_EACH_SIDE * 2;
+const float PageTurnView::STATIC_PAGE_INTERVAL_DISTANCE = 1.0f;
+
+PageTurnView::Page::Page()
+: isTurnBack(false)
+{
+ actor = Actor::New();
+ 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);
+
+ propertyOriginalCenter = actor.RegisterProperty(PROPERTY_ORIGINAL_CENTER, Vector2::ZERO);
+ propertyCurrentCenter = actor.RegisterProperty(PROPERTY_CURRENT_CENTER, Vector2::ZERO);
+ Matrix zeroMatrix(true);
+ actor.RegisterProperty(PROPERTY_COMMON_PARAMETERS, zeroMatrix);
+ propertyTurnDirection = actor.RegisterProperty(PROPERTY_TURN_DIRECTION, -1.f);
+}
+
+void PageTurnView::Page::SetTexture(Texture texture)
+{
+ if(!textureSet)
+ {
+ textureSet = TextureSet::New();
+ }
+ textureSet.SetTexture(0u, texture);
+}
+
+void PageTurnView::Page::UseEffect(Shader newShader)
+{
+ shader = newShader;
+ if(renderer)
+ {
+ renderer.SetShader(shader);
+ }
+}
+
+void PageTurnView::Page::UseEffect(Shader newShader, Geometry geometry)
+{
+ UseEffect(newShader);
+
+ if(!renderer)
+ {
+ renderer = Renderer::New(geometry, shader);
+
+ if(!textureSet)
+ {
+ textureSet = TextureSet::New();
+ }
+
+ renderer.SetTextures(textureSet);
+ renderer.SetProperty(Renderer::Property::DEPTH_WRITE_MODE, DepthWriteMode::ON);
+ actor.AddRenderer(renderer);
+ }
+}
+
+void PageTurnView::Page::ChangeTurnDirection()
+{
+ isTurnBack = !isTurnBack;
+ actor.SetProperty(propertyTurnDirection, isTurnBack ? 1.f : -1.f);
+}
+
+void PageTurnView::Page::SetPanDisplacement(float value)
+{
+ actor.SetProperty(propertyPanDisplacement, value);
+}
+
+void PageTurnView::Page::SetPanCenter(const Vector2& value)
+{
+ actor.SetProperty(propertyPanCenter, value);
+}
+
+void PageTurnView::Page::SetOriginalCenter(const Vector2& value)
+{
+ actor.SetProperty(propertyOriginalCenter, value);
+}
+
+void PageTurnView::Page::SetCurrentCenter(const Vector2& value)
+{
+ actor.SetProperty(propertyCurrentCenter, value);
+}
+
+PageTurnView::PageTurnView(PageFactory& pageFactory, const Vector2& viewPageSize)
+: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
+ mPageFactory(&pageFactory),
+ mPageSize(viewPageSize),
+ mSpineShadowParameter(DEFAULT_SPINE_SHADOW_PARAMETER),
+ mDistanceUpCorner(0.f),
+ mDistanceBottomCorner(0.f),
+ mPanDisplacement(0.f),
+ mTotalPageCount(0),
+ mCurrentPageIndex(0),
+ mTurningPageIndex(0),
+ mIndex(0),
+ mSlidingCount(0),
+ mAnimatingCount(0),
+ mConstraints(false),
+ mPress(false),
+ mPageUpdated(true),