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.
23 #include <dali/public-api/actors/layer.h>
26 #include <dali-toolkit/public-api/controls/control-impl.h>
27 #include <dali-toolkit/public-api/controls/navigation-frame/navigation-control.h>
28 #include <dali-toolkit/public-api/controls/navigation-frame/page.h>
29 #include <dali-toolkit/internal/controls/navigation-frame/navigation-bar.h>
30 #include <dali-toolkit/public-api/controls/popup/popup.h>
38 class NavigationControl;
47 * NavigationControl implements a controller than manages the navigation of hierarchical contents.
48 * @see Dali::Toolkit::NavigationControl for more details.
50 class NavigationControl : public Control
55 * Create an initialized NavigationControl.
56 * @return A handle to a newly allocated Dali resource
58 static Toolkit::NavigationControl New();
61 * @copydoc Dali::Toolkit::NavigationControl::PushItem()
63 void PushItem( Toolkit::Page page );
66 * @copydoc Dali::Toolkit::NavigationControl::PopItem()
68 Toolkit::Page PopItem();
71 * @copydoc Dali::Toolkit::NavigationControl::GetItemCount()
73 size_t GetItemCount() const;
76 * @copydoc Dali::Toolkit::NavigationControl::GetItem()
78 Toolkit::Page GetItem(std::size_t index) const;
81 * @copydoc Dali::Toolkit::NavigationControl::GetCurrentItem()
83 Toolkit::Page GetCurrentItem() const;
86 * @copydoc Dali::Toolkit::NavigationControl::SetBackground()
88 void SetBackground( Actor background);
91 * @copydoc Dali::Toolkit::NavigationControl::CreateNavigationToolBar()
93 void CreateNavigationToolBar( Toolkit::NaviToolBarStyle toolBarStylePortrait,
94 Toolkit::NaviToolBarStyle toolBarStyleLandscape );
97 * @copydoc Dali::Toolkit::NavigationControl::CreateNavigationTitleBar()
99 void CreateNavigationTitleBar( Toolkit::NaviTitleBarStyle titleBarStylePortrait,
100 Toolkit::NaviTitleBarStyle titleBarStyleLandscape );
103 * @copydoc Dali::Toolkit::NavigationControl::OrientationChanged()
105 void OrientationChanged( int angle );
108 * @copydoc Dali::Toolkit::NavigationControl::SetOrientationRotateAnimation()
110 void SetOrientationRotateAnimation( float duration, AlphaFunction alphaFunc);
113 * Retrieve the layer for displaying navigation bar
114 * @return The layer for navigation bar
116 Layer GetBarLayer() const;
119 * Performs actions as requested using the action name.
120 * @param[in] object The object on which to perform the action.
121 * @param[in] actionName The action to perform.
122 * @param[in] attributes The attributes with which to perfrom this action.
123 * @return true if action has been accepted by this control
125 static bool DoAction(BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes);
130 * @copydoc Dali::Toolkit::NavigatinControl::ItemPushedSignal()
132 Toolkit::NavigationControl::ItemPushedSignalType& ItemPushedSignal();
135 * @copydoc Dali::Toolkit::NavigatinControl::ItemPoppedSignal()
137 Toolkit::NavigationControl::ItemPoppedSignalType& ItemPoppedSignal();
139 private: // override functions from Control
142 * @copydoc Control::OnInitialize()
144 virtual void OnInitialize();
147 * From Control; called after a child has been added to the owning actor.
148 * @param[in] child The child which has been added.
150 virtual void OnControlChildAdd( Actor& child );
153 * @copydoc Control::OnStageConnection()
155 virtual void OnStageConnection();
158 * @copydoc Control::OnRelayout()
160 virtual void OnRelayout( const Vector2& size, ActorSizeContainer& container );
163 * @copydoc Control::OnControlSizeSet
165 virtual void OnControlSizeSet( const Vector3& size );
168 * @copydoc Control::OnKeyEvent()
170 virtual bool OnKeyEvent( const KeyEvent& event );
176 * It initializes the NavigationControl members
181 * A reference counted object may only be deleted by calling Unreference()
183 virtual ~NavigationControl();
188 NavigationControl(const NavigationControl&);
191 NavigationControl& operator=(const NavigationControl& rhs);
194 * Create a Layer and add it to the navigation control
195 * @return The newly created layer
200 * Setup the pop up menu which would show when KEY_MENU is pressed
201 * This function is called when pushing/popping item
203 void SetupPopupMenu();
206 * Signal handler called when the user touches outside of pop up menu.
208 void OnPopupTouchedOutside();
211 std::list< Toolkit::Page > mUnpushedItems;
215 std::vector< Toolkit::Page > mItemStack;
216 Toolkit::Page mCurrentItem;
217 Vector2 mControlSize;
219 Layer mBackgroundLayer;
226 NavigationBar* mToolBar;
227 NavigationBar* mTitleBar;
229 int mOrientationAngle;
230 float mOrientationAnimationDuration;
231 AlphaFunction mOrientationAnimationAlphaFunc;
232 Vector3 mItemPositionCoefficient;
234 Toolkit::Popup mPopupMenu;
237 Toolkit::NavigationControl::ItemPushedSignalType mItemPushedSignal; ///< The signal to notify the item push
238 Toolkit::NavigationControl::ItemPoppedSignalType mItemPoppedSignal; ///< The signal to notify the item pop
241 } // namespace Internal
243 // Helpers for public-api forwarding methods
245 inline Toolkit::Internal::NavigationControl& GetImpl( Toolkit::NavigationControl& navigationControl )
247 DALI_ASSERT_ALWAYS( navigationControl );
249 Dali::RefObject& handle = navigationControl.GetImplementation();
251 return static_cast<Toolkit::Internal::NavigationControl&>( handle );
254 inline const Toolkit::Internal::NavigationControl& GetImpl( const Toolkit::NavigationControl& navigationControl )
256 DALI_ASSERT_ALWAYS( navigationControl );
258 const Dali::RefObject& handle = navigationControl.GetImplementation();
260 return static_cast<const Toolkit::Internal::NavigationControl&>( handle );
263 } // namespace Toolkit
267 #endif /* __DALI_TOOLKIT_INTERNAL_NAVIGATION_CONTROL_H__ */