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