Conversion to Apache 2.0 license
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / public-api / controls / navigation-frame / navigation-control.h
1 #ifndef __DALI_TOOLKIT_NAVIGATION_CONTROL_H__
2 #define __DALI_TOOLKIT_NAVIGATION_CONTROL_H__
3
4 /*
5  * Copyright (c) 2014 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 #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
24 #include <dali-toolkit/public-api/controls/navigation-frame/navigation-bar-style.h>
25
26 namespace Dali DALI_IMPORT_API
27 {
28
29 namespace Toolkit
30 {
31
32 namespace Internal DALI_INTERNAL
33 {
34 // Forward declarations
35 class NavigationControl;
36 }
37
38 /**
39  * NavigationControl implements a controller than manages the navigation of hierarchical contents.
40  * NavigationControl holds views as its item which are organized in a stack.
41  * New items get pushed on the top of the old. Only the topmost item is displayed in the view area at one time.
42  * Its layout contains a title bar on the top, a tool bar in the bottom, and the content of top item in the middle.
43  * The top item carries title/subtitle/buttons/icon information,
44  * so with new item on the top, the NavigationControl will update the bars accordingly.
45  * if no component is needed to place on the bar for the current item, the bar is hidden
46  *                 +----------------------------------------+
47  *                 |                                        |
48  *                 | +-+ Title                   +-+  +-+   |  title bar
49  *                 | +-+ Subtitle                +-+  +-+   |
50  *                 +----------------------------------------+
51  *                 |                                        |
52  *                 |                                        |
53  *                 |                                        |
54  *                 |                                        |
55  *                 |                                        |
56  *                 |                                        |
57  *                 |                                        |
58  *                 |                                        |
59  *                 |                                        |
60  *                 |              View Area                 |
61  *                 |                                        |
62  *                 |                                        |
63  *                 |                                        |
64  *                 |                                        |
65  *                 |                                        |
66  *                 |                                        |
67  *                 |                                        |
68  *                 |                                        |
69  *                 |                                        |
70  *                 |                                        |
71  *                 |                                        |
72  *                 +----------------------------------------+
73  *                 | +-+        +-----+  +-----+        +-+ |
74  *                 | +-+        +-----+  +-----+        +-+ |  tool bar
75  *                 +----------------------------------------+
76  */
77
78 class NavigationControl : public Control
79 {
80
81 public:
82   //Action Names
83   static const char* const ACTION_PUSH;
84   static const char* const ACTION_POP;
85
86 public:
87
88   /**
89    * Create a NavigationControl handle; this can be initialize with NavigationControl::New().
90    * Calling member function with an uninitialized handle is not allowed.
91    */
92   NavigationControl();
93
94   /**
95    * Copy Constructor.
96    */
97   NavigationControl( const NavigationControl& handle );
98
99  /**
100   * Assignment operator.
101   */
102   NavigationControl& operator=( const NavigationControl& handle );
103
104   /**
105    * virtual Destructor.
106    */
107   virtual ~NavigationControl();
108
109   /**
110    * Create an initialized NavigationControl.
111    * @return A handle to a newly allocated Dali resource.
112    */
113   static NavigationControl New();
114
115   /**
116    * Downcast an object handle to NavigationControl.
117    * If handle points to a NavigationControl, the downcast produces valid handle.
118    * If not, the returned handle is left uninitialized.
119    * @param[in] handle Handle to an object.
120    * @return handle to a NavigationControl of an uninitialized handle.
121    */
122   static NavigationControl DownCast( BaseHandle handle );
123
124   /**
125    * Push a new item to the top of the NavigationControl stack and show it.
126    * @param[in] item A Page object.
127    */
128   void PushItem( Page item );
129
130   /**
131    * Pop an item that is on the top of the NavigationControl stack and make it disappear.
132    * It doesnot pop out the last item in the stack.
133    * It returns an uninitialized item handle if there is no item or only one item in the stack.
134    * @return The Page popped out.
135    */
136   Page PopItem();
137
138   /**
139    * Query the number of items in the stack.
140    * @return the number of items in the stack.
141    */
142   std::size_t GetItemCount() const;
143
144   /**
145    * Retrieve the index-th item in the stack
146    * Here, the index is from zero to stack size minus one, the bottom-most item is with index zero
147    * @pre There are more items in the stack than the parameter index plus one
148    * @param[in] index The location index of the item in the stack
149    * @return The index-th item in the navigation stack
150    */
151   Page GetItem(std::size_t index) const;
152
153   /**
154    * Retrieve the current top item.
155    * @return the Page object which is on the top of the stack.
156    */
157   Page GetCurrentItem() const;
158
159   /**
160    * Sets a background image.
161    * @param[in] background Actor with the navigation control background.
162    */
163   void SetBackground( Actor background);
164
165   /**
166    *Create a tool bar at the bottom of the navigation control.
167    *@param[in] toolBarStylePortrait the given navigation tool bar style of Portrait orientation.
168    *@param[in] toolBarStyleLandscape the given navigation tool bar style of Landscape orientation.
169    */
170   void CreateNavigationToolBar( NaviToolBarStyle toolBarStylePortrait, NaviToolBarStyle toolBarStyleLandscape );
171
172   /**
173    * Create a title bar at the top of the navigation control.
174    * @param[in] titleBarStylePortrait the given navigation title bar style of Portrait orientation.
175    * @param[in] titleBarStyleLandscape the given navigation title bar style of Landscape orientation.
176    */
177   void CreateNavigationTitleBar( NaviTitleBarStyle titleBarStylePortrait, NaviTitleBarStyle titleBarStyleLandscape);
178
179   /**
180    * Rotate all the contents to the new given orientation. This rotation is animated.
181    * Also change the bar style from portrait to landscape style, or vice versa.
182    * The application should invoke this function in call back of the orientation change signal if different orientations are required.
183    * @param[in] angle The angle degree of the new orientation, this is one of four discrete values, in degrees clockwise: 0, 90, 180, & 270
184    */
185   void OrientationChanged( int angle );
186
187   /**
188    * Set the duration and the alpha function for the rotating animation in OrientationChanged function above.
189    * Without calling this function, the default values are 1.0 and EaseOut respectively.
190    * @param[in] duration The duration of the rotating animation when orientation changed.
191    * @param[in] alphaFunc The alpha function of the rotating animation when orientation changed.
192    */
193   void SetOrientationRotateAnimation( float duration, AlphaFunction alphaFunc);
194
195 public: //Signal
196
197   typedef SignalV2< void( NavigationControl, Page ) > ItemPushedSignalV2;
198   typedef SignalV2< void( NavigationControl, Page ) > ItemPoppedSignalV2;
199
200   /**
201    * Signal emitted right after a new item is pushed into the navigation stack.
202    * A callback of the following type may be connected:
203    * @code
204    *   void YourCallBackName(NavigationControl controller, Page pushedItem);
205    * @endcode
206    * @return The signal to connect to.
207    */
208   ItemPushedSignalV2& ItemPushedSignal();
209
210   /**
211    * Signal emitted right after an item is popped out from the navigation stack.
212    * A callback of the following type may be connected:
213    * @code
214    *   void YourCallBackName(NavigationControl controller, Page poppedItem);
215    * @endcode
216    * If attempt to pop the bottom-most item, the poppedItem in the callback will receive an uninitialized handle
217    * The app can use this signal and check the poppedItem to be uninitialized to know the app window should be lower
218    * @return The signal to connect to.
219    */
220   ItemPoppedSignalV2& ItemPoppedSignal();
221
222
223
224 public: // Not intended for application developers
225
226   /**
227    * Creates a handle using the Toolkit::Internal implementation.
228    * @param[in]  implementation  The Control implementation.
229    */
230   NavigationControl( Internal::NavigationControl& implementation );
231
232   /**
233    * Allows the creation of this Control from an Internal::CustomActor pointer.
234    * @param[in]  internal  A pointer to the internal CustomActor.
235    */
236   NavigationControl( Dali::Internal::CustomActor* internal );
237
238 }; // class NavigationControl
239
240 } // namespace Toolkit
241
242 } // namespace Dali
243
244 #endif /* __DALI_TOOLKIT_NAVIGATION_CONTROL_H__ */