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