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.h;h=1f4bc167a777b787787fcde29375e0cf3e3f93fc;hp=c09250f8dfe17638c7005acff75d0ea681a63666;hb=a2de9cf491172cd5da9dc9ed60b17683dab6d7bc;hpb=a76cdbc69caa7c0c52b2f4b235560cca6db69c2a diff --git a/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.h b/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.h index c09250f..1f4bc16 100644 --- a/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.h +++ b/dali-toolkit/internal/controls/page-turn-view/page-turn-view-impl.h @@ -21,17 +21,12 @@ // EXTERNAL INCLUDES #include #include -#include -#include -#include +#include // INTERNAL INCLUDES #include -#include -#include -#include -#include -#include +#include +#include #include namespace Dali @@ -48,6 +43,83 @@ class PageTurnView : public Control protected: /** + * The book page class + */ + struct Page + { + /** + * Constructor + */ + Page(); + /** + * Destructor + */ + ~Page(){}; + + /** + * Set the page image content + * @param[in] image The content of the page. + */ + void SetImage( Image image ); + + /** + * Apply an effect onto the page actor. + * @param[in] newShader The shader for rendering effect. + */ + void UseEffect(Shader newShader); + + /** + * Apply an effect onto the page actor. + * @param[in] newShader The shader for rendering effect. + * @param[in] geometry The geometry for rendering effect. + */ + void UseEffect(Shader newShader, Geometry geometry); + + /** + * Change the page turning direction. + */ + void ChangeTurnDirection(); + + /** + * Set the pan displacement property + * @param[in] value The property value + */ + void SetPanDisplacement(float value); + + /** + * Set the pan center property + * @param[in] value The property value + */ + void SetPanCenter( const Vector2& value ); + + /** + * Set the original center property to be used by shader + * @param[in] value The property value + */ + void SetOriginalCenter( const Vector2& value ); + + /** + * Set the current center property to be used by shader + * @param[in] value The property value + */ + void SetCurrentCenter( const Vector2& value ); + + Actor actor; ///< The page actor + Shader shader; ///< The shader used by the actor + TextureSet textureSet; ///< The set of textures used by the actor + Renderer renderer; ///< The renderer of the actor + bool isTurnBack; ///< The turning direction + Property::Index propertyPanDisplacement; ///< The horizontal displacement of the pan + Property::Index propertyPanCenter; ///< The current pan position + Property::Index propertyOriginalCenter; ///< The original center to be used by the shader + Property::Index propertyCurrentCenter; ///< The current center to be used by the shader + Property::Index propertyTurnDirection; ///< The turning direction property + }; + + +protected: + + /** * Constructor. * It initializes the PageTurnView members */ @@ -61,49 +133,42 @@ protected: public: /** - * @copydoc Toolkit::PageTurnView::SetSpineShadowParameter - */ - void SetSpineShadowParameter( const Vector2& spineShadowParameter ); - - /** - * @copydoc Toolkit::PageTurnView::GetSpineShadowParameter - */ - Vector2 GetSpineShadowParameter(); - - /** - * @copydoc Toolkit::PageTurnView::GoToPage - */ - void GoToPage( unsigned int pageId ); - - /** - * @copydoc Toolkit::PageTurnView::GetCurrentPage + * Set the page size + * @param[in] pageSize The size of pages */ - unsigned int GetCurrentPage(); + void SetPageSize( const Vector2& pageSize ); /** - * @copydoc Toolkit::PageTurnView::EnterEditMode + * Retrieve the page size. + * @return The page size. */ - Actor EnterEditMode(); + Vector2 GetPageSize(); /** - * @copydoc Toolkit::PageTurnView::LeaveEditMode + * Set the spine shadow parameter to the shader effects. + * The two parameters are the major&minor radius (in pixels) to form an ellipse shape. + * The top-left quarter of this ellipse is used to calculate spine normal for simulating shadow. + * @param [in] spineShadowParameter The major&minor ellipse radius for the simulated spine shadow. */ - void LeaveEditMode(); + void SetSpineShadowParameter( const Vector2& spineShadowParameter ); /** - * @copydoc Toolkit::PageTurnView::GetHitActor + * Retrieve the spine shadow parameter of the shader effects. + * @return The spine shadow parameter. */ - Actor GetHitActor( Vector2& screenCoordinates, Vector2& actorCoordinates ); + Vector2 GetSpineShadowParameter(); - /** - * @copydoc Toolkit::PageTurnView::RefreshAll + /* + * Jump to a given page. + * @param[in] pageId The new current page id. */ - void RefreshAll(); + void GoToPage( unsigned int pageId ); /** - * @copydoc Toolkit::PageTurnView::RefreshCurrentPage + * Retrieve the id of the current Page. + * @return The current page id. */ - void RefreshCurrentPage(); + unsigned int GetCurrentPage(); protected: @@ -134,20 +199,14 @@ protected: */ void OrganizePageDepth(); - /** - * Set shader Effect to the actor. - * If the actor has children, the shader effect is also applied to its first child - * @param[in] actor The actor which the shader effect would be applied onto - * @param[in] shaderEffect The shader effect to be set to the actor - */ - void SetShaderEffect( ImageActor actor, ShaderEffect shaderEffect ); - private: /** - * Set up the render tasks for rendering the page actor to off-screen image + * Create shader from a property map. + * @param[in] shaderMap The shader property map; + * @return The created shader. */ - void SetupRenderTasks(); + Shader CreateShader( const Property::Map& shaderMap ); /** * Set up the shadow view control to cast shadow @@ -181,10 +240,10 @@ private: void SliddenBack( Animation& animation ); /** - * Refresh the given page. - @param[in] the page index. + * Stop the page turning animation and contraint. + * This method should be called when taking off stage or jump to a specified page. */ - void RenderPage( int pageIndex ); + void StopTurning(); private: // from Control @@ -201,7 +260,7 @@ private: // from Control /** * @copydoc CustomActorImpl::OnStageConnection() */ - virtual void OnStageConnection(); + virtual void OnStageConnection( int depth ); /** * @copydoc CustomActorImpl::OnStageDisconnection() @@ -218,18 +277,12 @@ private: // implemented differently by PageTurnLandscapeView and PageTurnPortrai virtual void OnPageTurnViewInitialize() = 0; /** - * Create the page actor from off screen buffer - * @param[in] The index of the page to be added - */ - virtual ImageActor NewPageFromRenderBuffer( int pageIndex ) = 0; - - /** * This method is called after the a new page is added to the stage. * Could be re-implemented in subclasses to provide specific behaviour * @param[in] newPage The added page actor * @param[in] isLeftSide Which side the new page is added to */ - virtual void OnAddPage( ImageActor newPage, bool isLeftSide ) { } + virtual void OnAddPage( Actor newPage, bool isLeftSide ) { } /** * This method is called when pan started or continuing @@ -248,15 +301,6 @@ private: // implemented differently by PageTurnLandscapeView and PageTurnPortrai virtual void SetPanActor( const Vector2& panPosition ) = 0; /** - * This method is called when a page is turned over or slidden back - * Remove PageTurnEffect and use a proper PageTurnBookSpineEffect - * Implemented in subclasses to provide specific behaviour. - * @param[in] actor The current page actor - * @param[in] isLeftSide Which side the current page is located - */ - virtual void SetSpineEffect(ImageActor actor, bool isLeftSide) = 0; - - /** * This method is called when pan finished to detect outwards flick * In portrait view, start an animation of turning previous page back when outwards flick is detected * In landscape view, nothing to do @@ -265,7 +309,15 @@ private: // implemented differently by PageTurnLandscapeView and PageTurnPortrai */ virtual void OnPossibleOutwardsFlick( const Vector2& panPosition, float gestureSpeed ) { } -public: //signal + /** + * This method is called when page is turned over + * In portrait view, the page on the left side is not rendered + * @param[in] actor The page actor + * @param[in] isLeftSide Which side the page is turned to + */ + virtual void OnTurnedOver( Actor actor, bool isLeftSide ) { } + +public: //signal and property /** * @copydoc Toolkit::PageTurnView::PageTurnStartedSignal() @@ -287,6 +339,35 @@ public: //signal */ Toolkit::PageTurnView::PagePanSignal& PagePanFinishedSignal(); + /** + * Connects a callback function with the object's signals. + * @param[in] object The object providing the signal. + * @param[in] tracker Used to disconnect the signal. + * @param[in] signalName The signal to connect to. + * @param[in] functor A newly allocated FunctorDelegate. + * @return True if the signal was connected. + * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor. + */ + static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); + + // Properties + + /** + * Called when a property of an object of this type is set. + * @param[in] object The object whose property is set. + * @param[in] index The property index. + * @param[in] value The new property value. + */ + static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ); + + /** + * Called to retrieve a property of an object of this type. + * @param[in] object The object whose property is to be retrieved. + * @param[in] index The property index. + * @return The current value of the property. + */ + static Property::Value GetProperty( BaseObject* object, Property::Index index ); + private: //Undefined @@ -297,62 +378,50 @@ private: protected: - Actor mRootOnScreen; - - Vector2 mControlSize; ///< The size of the control, it is decided by the page size, the SetSize from application can not change it Layer mTurningPageLayer; ///< The layer for the turning page, to avoid possible depth conflict Toolkit::ShadowView mShadowView; ///< The shadow view control for shadow casting - ImageActor mShadowPlane; ///< The plane for the shadow to cast on + Actor mShadowPlaneBackground; ///< The plane for the shadow to cast on Actor mPointLight; ///< The point light used for shadow casting - Layer mShadowLayer; ///< The layer to display the shadow - - PageFactory& mPageFactory; ///< The page factory which provides the page actors - Vector2 mPageSize; ///< The page size - int mTotalPageCount; ///< The total number of pages provided by the page factory - bool mIsEditMode; ///< The boolean to indicate the current page content is edit-able or not + PageFactory* const mPageFactory; ///< The factory which provides the page actors + Shader mTurnEffectShader; ///< The group of PageTurnEffects + Shader mSpineEffectShader; ///< The book spine shader effect + Geometry mGeometry; ///< The grid geometry for pages - bool mNeedOffscreenRendering; ///< The boolean to indicate whether off screen rendering is required for creating page image - std::vector mOffscreenTask; ///< The vector of off screen rendering tasks - std::vector mPageSourceActor; ///< The vector of page source actor - std::vector mRenderedPage; ///< The vector of off screen buffers - CameraActor mCameraActor; ///< The camera actor attached to the off screen tasks - bool mPanning; ///< The boolean to indicate whether the pan gesture is continuing + std::vector mPages; ///< The vector of pages on stage + std::map mAnimationPageIdPair; ///< The map to keep track which page actor is the animation act on - std::vector mTurnEffect; ///< The group of PageTurnEffects - PageTurnBookSpineEffect mSpineEffectFront; ///< The book spine shader effect without flipping image content - PageTurnBookSpineEffect mSpineEffectBack; ///< The book spine shader effect with image content flipped + Vector2 mPageSize; ///< The page size + Vector2 mControlSize; ///< The size of the control, it is decided by the page size, the SetSize from application can not change it Vector2 mSpineShadowParameter; ///< The spine shadow parameter for all the above shader effects Vector2 mOriginalCenter; ///< The original center set to the PageTurnEffect Vector2 mCurrentCenter; ///< The current center set to the PageTurnEffect - - std::vector mPageActors; ///< The vector of pages on stage - int mCurrentPageIndex; ///< The index of the current page, between 0 ~ mTotalPageCount-1 - std::map mIsTurnBack; ///< The map to keep track the page actor's turning direction - std::map mAnimationActorPair; ///< The map to keep track which page actor is the animation act on - std::map mAnimationIndexPair; ///< The map to keep track which PageTurnEffect, PanDisplacementProperty, CurrentCenterProperty is used for the animation - int mIndex; ///< The index to keep track which PageTurnEffect, PanDisplacementProperty, CurrentCenterProperty is used for the current panning page - std::vector mIsAnimating; ///< The boolean vector to keep track which PageTurnEffect, PanDisplacementProperty, CurrentCenterProperty is available for using - std::vector mIsSliding; ///< The boolean vector to keep track whether there are animating pages sliding back - - ImageActor mPanActor; ///< The page being panned by the pan gesture Vector2 mPressDownPosition; ///< The first press down position of the pan gesture - bool mPress; ///< The boolean to keep track the state of the pageTurnEffect is activated or not - bool mPageUpdated; ///< The boolean to keep track whether is page is updated after any turning activity float mDistanceUpCorner; ///< The distance between the original center of PageTurnEffect and the top-left corner of the page float mDistanceBottomCorner; ///< The distance between the original center of PageTurnEffect and the bottom-left corner of the page - - std::vector mPropertyPanDisplacement; ///< The pan displacement property group - std::vector mPropertyCurrentCenter; ///< The current center property group float mPanDisplacement; ///< The displacement of the pan after the constrains are applied + + int mTotalPageCount; ///< The total number of pages provided by the page factory + int mCurrentPageIndex; ///< The index of the current page, between 0 ~ mTotalPageCount-1 + int mTurningPageIndex; ///< The index of the turning page + int mIndex; ///< The index to keep track which PanDisplacementProperty, CurrentCenterProperty is used for the current panning page + int mSlidingCount; ///< The boolean vector to keep track whether there are animating pages sliding back + int mAnimatingCount; ///< The boolean vector to keep track which PageTurnEffect, PanDisplacementProperty, CurrentCenterProperty is available for using + bool mConstraints; ///< The boolean to keep track the constrains are applied or not + bool mPress; ///< The boolean to keep track the state of the pageTurnEffect is activated or not + bool mPageUpdated; ///< The boolean to keep track whether is page is updated after any turning activity Toolkit::PageTurnView::PageTurnSignal mPageTurnStartedSignal; ///< The signal to notify that a page has started turning Toolkit::PageTurnView::PageTurnSignal mPageTurnFinishedSignal; ///< The signal to notify that a page has finished turning Toolkit::PageTurnView::PagePanSignal mPagePanStartedSignal; ///< The signal to notify that a page has started panning Toolkit::PageTurnView::PagePanSignal mPagePanFinishedSignal; ///< The signal to notify that a page has finished panning + static const char * const PROPERTY_TEXTURE_WIDTH; ///< The uniform name of texture width + static const char * const PROPERTY_ORIGINAL_CENTER; ///< The property name of original center, which is used to constrain the uniforms + static const char * const PROPERTY_CURRENT_CENTER; ///< The property name of current center, which is used to constrain the uniforms + static const int MAXIMUM_TURNING_NUM; ///< How many pages are allowed to animating in the same time static const int NUMBER_OF_CACHED_PAGES_EACH_SIDE; ///< The maximum number of pages kept, (MAXIMUM_ANIMATION_NUM+1) pages for each side static const int NUMBER_OF_CACHED_PAGES; ///< The maximum number of pages kept, (MAXIMUM_ANIMATION_NUM+1)*2 pages in total