1 #ifndef __DALI_TOOLKIT_NAVIGATION_CONTROL_H__
2 #define __DALI_TOOLKIT_NAVIGATION_CONTROL_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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
11 // http://floralicense.org/license/
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.
21 #include <boost/function.hpp>
24 #include <dali-toolkit/public-api/controls/control.h>
25 #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
26 #include <dali-toolkit/public-api/controls/navigation-frame/navigation-bar-style.h>
28 namespace Dali DALI_IMPORT_API
34 namespace Internal DALI_INTERNAL
36 // Forward declarations
37 class NavigationControl;
41 * NavigationControl implements a controller than manages the navigation of hierarchical contents.
42 * NavigationControl holds views as its item which are organized in a stack.
43 * New items get pushed on the top of the old. Only the topmost item is displayed in the view area at one time.
44 * Its layout contains a title bar on the top, a tool bar in the bottom, and the content of top item in the middle.
45 * The top item carries title/subtitle/buttons/icon information,
46 * so with new item on the top, the NavigationControl will update the bars accordingly.
47 * if no component is needed to place on the bar for the current item, the bar is hidden
48 * +----------------------------------------+
50 * | +-+ Title +-+ +-+ | title bar
51 * | +-+ Subtitle +-+ +-+ |
52 * +----------------------------------------+
74 * +----------------------------------------+
75 * | +-+ +-----+ +-----+ +-+ |
76 * | +-+ +-----+ +-----+ +-+ | tool bar
77 * +----------------------------------------+
80 class NavigationControl : public Control
85 static const char* const ACTION_PUSH;
86 static const char* const ACTION_POP;
91 * Create a NavigationControl handle; this can be initialize with NavigationControl::New().
92 * Calling member function with an uninitialized handle is not allowed.
99 NavigationControl( const NavigationControl& handle );
102 * Assignment operator.
104 NavigationControl& operator=( const NavigationControl& handle );
107 * virtual Destructor.
109 virtual ~NavigationControl();
112 * Create an initialized NavigationControl.
113 * @return A handle to a newly allocated Dali resource.
115 static NavigationControl New();
118 * Downcast an object handle to NavigationControl.
119 * If handle points to a NavigationControl, 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 NavigationControl of an uninitialized handle.
124 static NavigationControl DownCast( BaseHandle handle );
127 * Push a new item to the top of the NavigationControl stack and show it.
128 * @param[in] item A Page object.
130 void PushItem( Page item );
133 * Pop an item that is on the top of the NavigationControl stack and make it disappear.
134 * It doesnot pop out the last item in the stack.
135 * It returns an uninitialized item handle if there is no item or only one item in the stack.
136 * @return The Page popped out.
141 * Query the number of items in the stack.
142 * @return the number of items in the stack.
144 std::size_t GetItemCount() const;
147 * Retrieve the index-th item in the stack
148 * Here, the index is from zero to stack size minus one, the bottom-most item is with index zero
149 * @pre There are more items in the stack than the parameter index plus one
150 * @param[in] index The location index of the item in the stack
151 * @return The index-th item in the navigation stack
153 Page GetItem(std::size_t index) const;
156 * Retrieve the current top item.
157 * @return the Page object which is on the top of the stack.
159 Page GetCurrentItem() const;
162 * Sets a background image.
163 * @param[in] background Actor with the navigation control background.
165 void SetBackground( Actor background);
168 *Create a tool bar at the bottom of the navigation control.
169 *@param[in] toolBarStylePortrait the given navigation tool bar style of Portrait orientation.
170 *@param[in] toolBarStyleLandscape the given navigation tool bar style of Landscape orientation.
172 void CreateNavigationToolBar( NaviToolBarStyle toolBarStylePortrait, NaviToolBarStyle toolBarStyleLandscape );
175 * Create a title bar at the top of the navigation control.
176 * @param[in] titleBarStylePortrait the given navigation title bar style of Portrait orientation.
177 * @param[in] titleBarStyleLandscape the given navigation title bar style of Landscape orientation.
179 void CreateNavigationTitleBar( NaviTitleBarStyle titleBarStylePortrait, NaviTitleBarStyle titleBarStyleLandscape);
182 * Rotate all the contents to the new given orientation. This rotation is animated.
183 * Also change the bar style from portrait to landscape style, or vice versa.
184 * The application should invoke this function in call back of the orientation change signal if different orientations are required.
185 * @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 void OrientationChanged( int angle );
190 * Set the duration and the alpha function for the rotating animation in OrientationChanged function above.
191 * Without calling this function, the default values are 1.0 and EaseOut respectively.
192 * @param[in] duration The duration of the rotating animation when orientation changed.
193 * @param[in] alphaFunc The alpha function of the rotating animation when orientation changed.
195 void SetOrientationRotateAnimation( float duration, AlphaFunction alphaFunc);
199 typedef SignalV2< void( NavigationControl, Page ) > ItemPushedSignalV2;
200 typedef SignalV2< void( NavigationControl, Page ) > ItemPoppedSignalV2;
203 * Signal emitted right after a new item is pushed into the navigation stack.
204 * A callback of the following type may be connected:
206 * void YourCallBackName(NavigationControl controller, Page pushedItem);
208 * @return The signal to connect to.
210 ItemPushedSignalV2& ItemPushedSignal();
213 * Signal emitted right after an item is popped out from the navigation stack.
214 * A callback of the following type may be connected:
216 * void YourCallBackName(NavigationControl controller, Page poppedItem);
218 * If attempt to pop the bottom-most item, the poppedItem in the callback will receive an uninitialized handle
219 * The app can use this signal and check the poppedItem to be uninitialized to know the app window should be lower
220 * @return The signal to connect to.
222 ItemPoppedSignalV2& ItemPoppedSignal();
226 public: // Not intended for application developers
229 * Creates a handle using the Toolkit::Internal implementation.
230 * @param[in] implementation The Control implementation.
232 NavigationControl( Internal::NavigationControl& implementation );
235 * Allows the creation of this Control from an Internal::CustomActor pointer.
236 * @param[in] internal A pointer to the internal CustomActor.
238 NavigationControl( Dali::Internal::CustomActor* internal );
240 }; // class NavigationControl
242 } // namespace Toolkit
246 #endif /* __DALI_TOOLKIT_NAVIGATION_CONTROL_H__ */