1 #ifndef __DALI_TOOLKIT_INTERNAL_NAVIGATION_CONTROL_H__
2 #define __DALI_TOOLKIT_INTERNAL_NAVIGATION_CONTROL_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
26 #include <dali/dali.h>
27 #include <dali-toolkit/public-api/controls/control-impl.h>
28 #include <dali-toolkit/public-api/controls/navigation-frame/navigation-control.h>
29 #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
30 #include <dali-toolkit/internal/controls/navigation-frame/navigation-bar.h>
31 #include <dali-toolkit/public-api/controls/popup/popup.h>
39 class NavigationControl;
48 * NavigationControl implements a controller than manages the navigation of hierarchical contents.
49 * @see Dali::Toolkit::NavigationControl for more details.
51 class NavigationControl : public Control
56 * Create an initialized NavigationControl.
57 * @return A handle to a newly allocated Dali resource
59 static Toolkit::NavigationControl New();
62 * @copydoc Dali::Toolkit::NavigationControl::PushItem()
64 void PushItem( Toolkit::Page page );
67 * @copydoc Dali::Toolkit::NavigationControl::PopItem()
69 Toolkit::Page PopItem();
72 * @copydoc Dali::Toolkit::NavigationControl::GetItemCount()
74 size_t GetItemCount() const;
77 * @copydoc Dali::Toolkit::NavigationControl::GetItem()
79 Toolkit::Page GetItem(std::size_t index) const;
82 * @copydoc Dali::Toolkit::NavigationControl::GetCurrentItem()
84 Toolkit::Page GetCurrentItem() const;
87 * @copydoc Dali::Toolkit::NavigationControl::SetBackground()
89 void SetBackground( Actor background);
92 * @copydoc Dali::Toolkit::NavigationControl::CreateNavigationToolBar()
94 void CreateNavigationToolBar( Toolkit::NaviToolBarStyle toolBarStylePortrait,
95 Toolkit::NaviToolBarStyle toolBarStyleLandscape );
98 * @copydoc Dali::Toolkit::NavigationControl::CreateNavigationTitleBar()
100 void CreateNavigationTitleBar( Toolkit::NaviTitleBarStyle titleBarStylePortrait,
101 Toolkit::NaviTitleBarStyle titleBarStyleLandscape );
104 * @copydoc Dali::Toolkit::NavigationControl::OrientationChanged()
106 void OrientationChanged( int angle );
109 * @copydoc Dali::Toolkit::NavigationControl::SetOrientationRotateAnimation()
111 void SetOrientationRotateAnimation( float duration, AlphaFunction alphaFunc);
114 * Retrieve the layer for displaying navigation bar
115 * @return The layer for navigation bar
117 Layer GetBarLayer() const;
120 * Performs actions as requested using the action name.
121 * @param[in] object The object on which to perform the action.
122 * @param[in] actionName The action to perform.
123 * @param[in] attributes The attributes with which to perfrom this action.
124 * @return true if action has been accepted by this control
126 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
131 * @copydoc Dali::Toolkit::NavigatinControl::ItemPushedSignal()
133 Toolkit::NavigationControl::ItemPushedSignalV2& ItemPushedSignal();
136 * @copydoc Dali::Toolkit::NavigatinControl::ItemPoppedSignal()
138 Toolkit::NavigationControl::ItemPoppedSignalV2& ItemPoppedSignal();
140 private: // override functions from Control
143 * @copydoc Control::OnInitialize()
145 virtual void OnInitialize();
148 * From Control; called after a child has been added to the owning actor.
149 * @param[in] child The child which has been added.
151 virtual void OnControlChildAdd( Actor& child );
154 * @copydoc Control::OnStageConnection()
156 virtual void OnStageConnection();
159 * @copydoc Control::OnRelaidOut()
161 virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
164 * @copydoc Control::OnControlSizeSet
166 virtual void OnControlSizeSet( const Vector3& size );
169 * @copydoc Control::OnKeyEvent()
171 virtual bool OnKeyEvent( const KeyEvent& event );
177 * It initializes the NavigationControl members
182 * A reference counted object may only be deleted by calling Unreference()
184 virtual ~NavigationControl();
189 NavigationControl(const NavigationControl&);
192 NavigationControl& operator=(const NavigationControl& rhs);
195 * Create a Layer and add it to the navigation control
196 * @return The newly created layer
201 * Setup the pop up menu which would show when KEY_MENU is pressed
202 * This function is called when pushing/popping item
204 void SetupPopupMenu();
207 * Signal handler called when the user touches outside of pop up menu.
209 void OnPopupTouchedOutside();
212 std::list< Toolkit::Page > mUnpushedItems;
216 std::vector< Toolkit::Page > mItemStack;
217 Toolkit::Page mCurrentItem;
218 Vector2 mControlSize;
220 Layer mBackgroundLayer;
227 NavigationBar* mToolBar;
228 NavigationBar* mTitleBar;
230 int mOrientationAngle;
231 float mOrientationAnimationDuration;
232 AlphaFunction mOrientationAnimationAlphaFunc;
233 Vector3 mItemPositionCoefficient;
235 Toolkit::Popup mPopupMenu;
238 Toolkit::NavigationControl::ItemPushedSignalV2 mItemPushedSignal; ///< The signal to notify the item push
239 Toolkit::NavigationControl::ItemPoppedSignalV2 mItemPoppedSignal; ///< The signal to notify the item pop
242 } // namespace Internal
244 // Helpers for public-api forwarding methods
246 inline Toolkit::Internal::NavigationControl& GetImpl( Toolkit::NavigationControl& navigationControl )
248 DALI_ASSERT_ALWAYS( navigationControl );
250 Dali::RefObject& handle = navigationControl.GetImplementation();
252 return static_cast<Toolkit::Internal::NavigationControl&>( handle );
255 inline const Toolkit::Internal::NavigationControl& GetImpl( const Toolkit::NavigationControl& navigationControl )
257 DALI_ASSERT_ALWAYS( navigationControl );
259 const Dali::RefObject& handle = navigationControl.GetImplementation();
261 return static_cast<const Toolkit::Internal::NavigationControl&>( handle );
264 } // namespace Toolkit
268 #endif /* __DALI_TOOLKIT_INTERNAL_NAVIGATION_CONTROL_H__ */