a4705e46cfc0d5006a341fd4db51ca14f657dee2
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-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) 2018 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 // Forward declarations
31 class PageFactory;
32
33 namespace Internal DALI_INTERNAL
34 {
35 class PageTurnView;
36 }
37
38 /**
39  * @brief PageTurnView is a base class of different mode of pageTurnViews ( portrait or landscape )
40  *
41  * Page actors are provided from an external PageFactory
42  * PanGesture is used to activate the page bending, streching and tuning forward/backward
43  *
44  * Signal usage: There are four signals. Two matching pairs for panning and page turning:
45  * PagePanStarted/PagePanFinished and PageTurnStarted/PageTurnFinished. Panning relates to user interaction with
46  * the screen while page turning refers to animation of the page. There are three scenarios for these
47  * events: normal page turn (forwards or backwards), aborted page turn (forwards or backwards)
48  * and pan with no animation. The order of events is as follows:
49  * 1) Normal page turn: PagePanStarted -> PageTurnStarted direction -> PagePanFinished -> PageTurnFinished direction
50  * 2) Aborted page turn: PagePanStarted -> PageTurnStarted direction -> PageTurnStarted opposite direction
51  *                       -> PagePanFinished -> PageTurnFinished opposite direction
52  * 3) Pan with no animation: PagePanStarted -> PagePanFinished
53  * Pan with no animation will occur when the user touches the page in an area that does not start the
54  * page turning.
55  *
56  *  Signals
57  * | %Signal Name     | Method                        |
58  * |------------------|-------------------------------|
59  * | pageTurnStarted  | @ref PageTurnStartedSignal()  |
60  * | pageTurnFinished | @ref PageTurnFinishedSignal() |
61  * | pagePanStarted   | @ref PagePanStartedSignal()   |
62  * | pagePanFinished  | @ref PagePanFinishedSignal()  |
63  *
64  * @SINCE_1_1.4
65  */
66 class DALI_TOOLKIT_API PageTurnView : public Control
67 {
68 public:
69
70   /**
71    * @brief The start and end property ranges for this control.
72    * @SINCE_1_1.4
73    */
74   enum PropertyRange
75   {
76     PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_1.4
77     PROPERTY_END_INDEX =   PROPERTY_START_INDEX + 1000              ///< Reserve property indices @SINCE_1_1.4
78   };
79
80   struct Property
81   {
82     enum
83     {
84       PAGE_SIZE = PROPERTY_START_INDEX, ///< name "pageSize",        type Vector2 @SINCE_1_1.4
85       CURRENT_PAGE_ID,                  ///< name "currentPageId",   type Integer @SINCE_1_1.4
86
87       /**
88        * The two values are the major&minor radius (in pixels) to form an ellipse shape.
89        * The top-left quarter of this ellipse is used to calculate spine normal for simulating shadow.
90        */
91       SPINE_SHADOW,                     ///< name "spineShadow",     type Vector2 @SINCE_1_1.4
92     };
93   };
94
95   /**
96    * @brief Creates an empty PageTurnView handle. Only derived versions can be instantiated.
97    * Calling member function with an uninitialized handle is not allowed.
98    * @SINCE_1_1.4
99    */
100   PageTurnView();
101
102   /**
103    * @brief Copy constructor. Creates another handle that points to the same real object
104    * @SINCE_1_1.4
105    * @param[in] handle Handle to copy from
106    */
107   PageTurnView( const PageTurnView& handle );
108
109   /**
110    * @brief Assignment operator. Changes this handle to point to another real object
111    * @SINCE_1_1.4
112    */
113   PageTurnView& operator=( const PageTurnView& handle );
114
115   /**
116    * @brief Destructor
117    *
118    * This is non-virtual since derived Handle types must not contain data or virtual methods.
119    * @SINCE_1_1.4
120    */
121   ~PageTurnView();
122
123   /**
124    * @brief Downcast an Object handle to PageTurnView.
125    * If handle points to an PageTurnView the downcast produces valid handle.
126    * If not the returned handle is left uninitialized.
127    * @SINCE_1_1.4
128    * @param[in] handle Handle to an object
129    * @return handle to a PageTurnView or an uninitialized handle
130    */
131   static PageTurnView DownCast( BaseHandle handle );
132
133 public: //Signal
134
135   // Page Turned signal, with page index and boolean turning direction (true = forward, false = backward)
136   typedef Signal< void ( PageTurnView, unsigned int, bool ) > PageTurnSignal;
137   typedef Signal< void ( PageTurnView ) > PagePanSignal;
138
139   /**
140    * @brief Signal emitted when a page has started to turn over.
141    * A callback of the following type may be connected:
142    * @code
143    *   void YourCallBackName( PageTurnView pageTurnView, unsigned int pageIndex, bool isTurningForward );
144    * @endcode
145    * @SINCE_1_1.4
146    * @return The signal to connect to
147    */
148   PageTurnSignal& PageTurnStartedSignal();
149
150   /**
151    * @brief Signal emitted when a page has finished turning over.
152    * A callback of the following type may be connected:
153    * @code
154    *   void YourCallBackName( PageTurnView pageTurnView, unsigned int pageIndex, bool isTurningForward );
155    * @endcode
156    * @SINCE_1_1.4
157    * @return The signal to connect to
158    */
159   PageTurnSignal& PageTurnFinishedSignal();
160
161   /**
162    * @brief Signal emitted when a page pan has commenced
163    * A callback of the following type may be connected:
164    * @code
165    *   void YourCallBackName( PageTurnView pageTurnView );
166    * @endcode
167    * @SINCE_1_1.4
168    * @return The signal to connect to
169    */
170   PagePanSignal& PagePanStartedSignal();
171
172   /**
173    * @brief Signal emitted when a page pan has finished
174    * A callback of the following type may be connected:
175    * @code
176    *   void YourCallBackName( PageTurnView pageTurnView );
177    * @endcode
178    * @SINCE_1_1.4
179    * @return The signal to connect to
180    */
181   PagePanSignal& PagePanFinishedSignal();
182
183 public: // Not intended for application developers
184
185   /// @cond internal
186   /**
187    * @brief Creates a handle using the Toolkit::Internal implementation.
188    * @SINCE_1_1.4
189    * @param[in]  implementation  The Control implementation.
190    */
191   DALI_INTERNAL PageTurnView(Internal::PageTurnView& implementation);
192
193   /**
194    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
195    * @SINCE_1_1.4
196    * @param[in]  internal  A pointer to the internal CustomActor.
197    */
198   explicit DALI_INTERNAL PageTurnView(Dali::Internal::CustomActor* internal);
199   /// @endcond
200 };
201
202 } // namespace Toolkit
203
204 } // namespace Dali
205
206 #endif /* __DALI_TOOLKIT_PAGE_TURN_VIEW_H__ */