Split dali-toolkit into Base & Optional
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / controls / page-turn-view / page-turn-view.h
1 #ifndef __DALI_TOOLKIT_PAGE_TURN_VIEW_H__
2 #define __DALI_TOOLKIT_PAGE_TURN_VIEW_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //     http://floralicense.org/license/
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19
20 // EXTERNAL INCLUDES
21 #include <boost/function.hpp>
22
23 // INTERNAL INCLUDES
24 #include <dali-toolkit/public-api/controls/control.h>
25
26 namespace Dali DALI_IMPORT_API
27 {
28
29 namespace Toolkit
30 {
31
32 // Forward declarations
33 class PageFactory;
34
35 namespace Internal DALI_INTERNAL
36 {
37 class PageTurnView;
38 }
39
40 /**
41  * PageTurnView is a base class of different mode of pageTurnViews ( portrait or landscape )
42  * Page actors are provided from an external PageFactory
43  * PanGesture is used to activate the page bending, streching and tuning forward/backward
44  *
45  * Signal usage: There are four signals. Two matching pairs for panning and page turning:
46  * PagePanStarted/PagePanFinished and PageTurnStarted/PageTurnFinished. Panning relates to user interaction with
47  * the screen while page turning refers to animation of the page. There are three scenarios for these
48  * events: normal page turn (forwards or backwards), aborted page turn (forwards or backwards)
49  * and pan with no animation. The order of events is as follows:
50  * 1) Normal page turn: PagePanStarted -> PageTurnStarted direction -> PagePanFinished -> PageTurnFinished direction
51  * 2) Aborted page turn: PagePanStarted -> PageTurnStarted direction -> PageTurnStarted opposite direction
52  *                       -> PagePanFinished -> PageTurnFinished opposite direction
53  * 3) Pan with no animation: PagePanStarted -> PagePanFinished
54  * Pan with no animation will occur when the user touches the page in an area that does not start the
55  * page turning.
56  */
57 class PageTurnView : public Control
58 {
59 public:
60
61   /**
62    * Creates an empty PageTurnView handle. Only derived versions can be instantiated.
63    * Calling member function with an uninitialized handle is not allowed.
64    */
65   PageTurnView();
66
67   /**
68    * Copy constructor. Creates another handle that points to the same real object
69    * @param[in] handle Handle to copy from
70    */
71   PageTurnView( const PageTurnView& handle );
72
73   /**
74    * Assignment operator. Changes this handle to point to another real object
75    */
76   PageTurnView& operator=( const PageTurnView& handle );
77
78   /**
79    * Virtual destructor.
80    */
81   virtual ~PageTurnView();
82
83   /**
84    * Downcast an Object handle to PageTurnView.
85    * If handle points to an PageTurnView the downcast produces valid handle.
86    * If not the returned handle is left uninitialized.
87    * @param[in] handle Handle to an object
88    * @return handle to a PageTurnView or an uninitialized handle
89    */
90   static PageTurnView DownCast( BaseHandle handle );
91
92   /**
93    * Set the spine shadow parameter to the shader effects
94    * The two parameters are the major&minor radius (in pixels) to form an ellipse shape
95    * The top-left quarter of this ellipse is used to calculate spine normal for simulating shadow
96    * @param [in] spineShadowParameter The major&minor ellipse radius for the simulated spine shadow
97    */
98   void SetSpineShadowParameter( const Vector2& spineShadowParameter );
99
100   /**
101    * Retrieve the spine shadow parameter of the shader effects
102    * @return The major&minor ellipse radius for the simulated spine shadow
103    */
104   Vector2 GetSpineShadowParameter();
105
106   /*
107    * Go to a specific page
108    * @param[in] pageId The new current page index
109    */
110   void GoToPage( unsigned int pageId );
111
112   /**
113    * Retrieve the index of the current Page
114    * @return The index of the current page
115    */
116   unsigned int GetCurrentPage();
117
118   /**
119    * Enter edit mode
120    * Case 1, the page factory passes image actor into the view as page content, do nothing.
121    * Case 2, the page factory passes an actor tree into the view as page content,
122    *    the actor tree will receive the touch event in edit mode, and set the refresh rate of the off screen render task to always
123    * @return an empty actor in case 1; the actor tree root of the current page
124    */
125   Actor EnterEditMode();
126
127   /**
128    * Leave edit mode
129    * Case 1, the page factory passes image actor into the view as page content, do nothing.
130    * Case 2, the page factory passes an actor tree into the view as page content,
131    *   the page actor will receive all the touch event, and set the refresh rage of the off screen render task to once.
132    */
133   void LeaveEditMode();
134
135   /**
136    * Return the actor get hit in the actor tree of the current page by given the touch position on the PageTurnView
137    * @param[in] screenCoordinates The hit position of the PageTurnView
138    * @param[out] actorCoordinates The local hit position of the hitted actor
139    * @return the hitted actor
140    */
141   Actor GetHitActor( Vector2& screenCoordinates, Vector2& actorCoordinates );
142
143   /**
144    * Refresh all the cached pages by calling the render task to refresh.
145    */
146   void RefreshAll();
147
148   /**
149    * Refresh current page by calling the render task to refresh
150    */
151   void RefreshCurrentPage();
152
153 public: //Signal
154
155   // Page Turned signal, with page index and boolean turning direction (true = forward, false = backward)
156   typedef SignalV2< void ( PageTurnView, unsigned int, bool ) > PageTurnSignal;
157   typedef SignalV2< void ( PageTurnView ) > PagePanSignal;
158
159   /**
160    * Signal emitted when a page has started to turn over.
161    * A callback of the following type may be connected:
162    * @code
163    *   void YourCallBackName( PageTurnView pageTurnView, unsigned int pageIndex, bool isTurningForward );
164    * @endcode
165    * @return The signal to connect to
166    */
167   PageTurnSignal& PageTurnStartedSignal();
168
169   /**
170    * Signal emitted when a page has finished turning over.
171    * A callback of the following type may be connected:
172    * @code
173    *   void YourCallBackName( PageTurnView pageTurnView, unsigned int pageIndex, bool isTurningForward );
174    * @endcode
175    * @return The signal to connect to
176    */
177   PageTurnSignal& PageTurnFinishedSignal();
178
179   /**
180    * Signal emitted when a page pan has commenced
181    * A callback of the following type may be connected:
182    * @code
183    *   void YourCallBackName( PageTurnView pageTurnView );
184    * @endcode
185    * @return The signal to connect to
186    */
187   PagePanSignal& PagePanStartedSignal();
188
189   /**
190    * Signal emitted when a page pan has finished
191    * A callback of the following type may be connected:
192    * @code
193    *   void YourCallBackName( PageTurnView pageTurnView );
194    * @endcode
195    * @return The signal to connect to
196    */
197   PagePanSignal& PagePanFinishedSignal();
198
199 public: // Not intended for application developers
200
201   /**
202    * Creates a handle using the Toolkit::Internal implementation.
203    * @param[in]  implementation  The Control implementation.
204    */
205   DALI_INTERNAL PageTurnView(Internal::PageTurnView& implementation);
206
207   /**
208    * Allows the creation of this Control from an Internal::CustomActor pointer.
209    * @param[in]  internal  A pointer to the internal CustomActor.
210    */
211   DALI_INTERNAL PageTurnView(Dali::Internal::CustomActor* internal);
212 };
213
214 } // namespace Toolkit
215
216 } // namespace Dali
217
218 #endif /* __DALI_TOOLKIT_PAGE_TURN_VIEW_H__ */