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