Moved ControlImpl to Internal namespace & renamed to Control
[platform/core/uifw/dali-toolkit.git] / optional / dali-toolkit / internal / controls / navigation-frame / navigation-control-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_NAVIGATION_CONTROL_H__
2 #define __DALI_TOOLKIT_INTERNAL_NAVIGATION_CONTROL_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
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
10 //
11 //     http://floralicense.org/license/
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 //EXTERNAL INCLUDES
21
22 #include <list>
23
24 // INTERNAL INCLUDES
25 #include <dali/dali.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>
31
32 namespace Dali
33 {
34
35 namespace Toolkit
36 {
37
38 class NavigationControl;
39 class Page;
40
41 namespace Internal
42 {
43
44 class NavigationBar;
45
46 /**
47  * NavigationControl implements a controller than manages the navigation of hierarchical contents.
48  * @see Dali::Toolkit::NavigationControl for more details.
49  */
50 class NavigationControl : public Control
51 {
52 public:
53
54   /**
55    * Create an initialized NavigationControl.
56    * @return A handle to a newly allocated Dali resource
57    */
58   static Toolkit::NavigationControl New();
59
60   /**
61    * @copydoc Dali::Toolkit::NavigationControl::PushItem()
62    */
63   void PushItem( Toolkit::Page page );
64
65   /**
66    * @copydoc Dali::Toolkit::NavigationControl::PopItem()
67    */
68   Toolkit::Page PopItem();
69
70   /**
71    * @copydoc Dali::Toolkit::NavigationControl::GetItemCount()
72    */
73   size_t GetItemCount() const;
74
75   /**
76    * @copydoc Dali::Toolkit::NavigationControl::GetItem()
77    */
78   Toolkit::Page GetItem(std::size_t index) const;
79
80   /**
81    * @copydoc Dali::Toolkit::NavigationControl::GetCurrentItem()
82    */
83   Toolkit::Page GetCurrentItem() const;
84
85   /**
86    * @copydoc Dali::Toolkit::NavigationControl::SetBackground()
87    */
88   void SetBackground( Actor background);
89
90   /**
91    * @copydoc Dali::Toolkit::NavigationControl::CreateNavigationToolBar()
92    */
93   void CreateNavigationToolBar( Toolkit::NaviToolBarStyle toolBarStylePortrait,
94                                 Toolkit::NaviToolBarStyle toolBarStyleLandscape );
95
96   /**
97    * @copydoc Dali::Toolkit::NavigationControl::CreateNavigationTitleBar()
98    */
99   void CreateNavigationTitleBar( Toolkit::NaviTitleBarStyle titleBarStylePortrait,
100                                  Toolkit::NaviTitleBarStyle titleBarStyleLandscape );
101
102   /**
103    * @copydoc Dali::Toolkit::NavigationControl::OrientationChanged()
104    */
105   void OrientationChanged( int angle );
106
107   /**
108    * @copydoc Dali::Toolkit::NavigationControl::SetOrientationRotateAnimation()
109    */
110   void SetOrientationRotateAnimation( float duration, AlphaFunction alphaFunc);
111
112   /**
113    * Retrieve the layer for displaying navigation bar
114    * @return The layer for navigation bar
115    */
116   Layer GetBarLayer() const;
117
118   /**
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
124    */
125   static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
126
127 public:
128
129   /**
130    * @copydoc Dali::Toolkit::NavigatinControl::ItemPushedSignal()
131    */
132   Toolkit::NavigationControl::ItemPushedSignalV2& ItemPushedSignal();
133
134   /**
135    * @copydoc Dali::Toolkit::NavigatinControl::ItemPoppedSignal()
136    */
137   Toolkit::NavigationControl::ItemPoppedSignalV2& ItemPoppedSignal();
138
139 private: // override functions from Control
140
141   /**
142    * @copydoc Control::OnInitialize()
143    */
144   virtual void OnInitialize();
145
146   /**
147    * From Control; called after a child has been added to the owning actor.
148    * @param[in] child The child which has been added.
149    */
150   virtual void OnControlChildAdd( Actor& child );
151
152   /**
153    * @copydoc Control::OnStageConnection()
154    */
155   virtual void OnStageConnection();
156
157   /**
158    * @copydoc Control::OnRelaidOut()
159    */
160   virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
161
162   /**
163    * @copydoc Control::OnControlSizeSet
164    */
165   virtual void OnControlSizeSet( const Vector3& size );
166
167   /**
168    * @copydoc Control::OnKeyEvent()
169    */
170   virtual bool OnKeyEvent( const KeyEvent& event );
171
172 protected:
173
174   /**
175    * Constructor.
176    * It initializes the NavigationControl members
177    */
178   NavigationControl();
179
180   /**
181    * A reference counted object may only be deleted by calling Unreference()
182    */
183   virtual ~NavigationControl();
184
185 private:
186
187   // Undefined
188   NavigationControl(const NavigationControl&);
189
190   // Undefined
191   NavigationControl& operator=(const NavigationControl& rhs);
192
193   /**
194    * Create a Layer and add it to the navigation control
195    * @return The newly created layer
196    */
197   Layer CreateLayer();
198
199   /**
200    * Setup the pop up menu which would show when KEY_MENU is pressed
201    * This function is called when pushing/popping item
202    */
203   void SetupPopupMenu();
204
205   /**
206    * Signal handler called when the user touches outside of pop up menu.
207    */
208   void OnPopupTouchedOutside();
209
210 public:
211   std::list< Toolkit::Page >           mUnpushedItems;
212
213 private:
214
215   std::vector< Toolkit::Page > mItemStack;
216   Toolkit::Page                mCurrentItem;
217   Vector2                      mControlSize;
218
219   Layer                        mBackgroundLayer;
220   Layer                        mBarLayer;
221   Layer                        mContentLayer;
222   Layer                        mPopupLayer;
223
224   Actor                        mBackground;
225
226   NavigationBar*               mToolBar;
227   NavigationBar*               mTitleBar;
228
229   int                          mOrientationAngle;
230   float                        mOrientationAnimationDuration;
231   AlphaFunction                mOrientationAnimationAlphaFunc;
232   Vector3                      mItemPositionCoefficient;
233
234   Toolkit::Popup               mPopupMenu;
235
236 private:
237   Toolkit::NavigationControl::ItemPushedSignalV2 mItemPushedSignal;   ///< The signal to notify the item push
238   Toolkit::NavigationControl::ItemPoppedSignalV2 mItemPoppedSignal;   ///< The signal to notify the item pop
239 };
240
241 } // namespace Internal
242
243 // Helpers for public-api forwarding methods
244
245 inline Toolkit::Internal::NavigationControl& GetImpl( Toolkit::NavigationControl& navigationControl )
246 {
247   DALI_ASSERT_ALWAYS( navigationControl );
248
249   Dali::RefObject& handle = navigationControl.GetImplementation();
250
251   return static_cast<Toolkit::Internal::NavigationControl&>( handle );
252 }
253
254 inline const Toolkit::Internal::NavigationControl& GetImpl( const Toolkit::NavigationControl& navigationControl )
255 {
256   DALI_ASSERT_ALWAYS( navigationControl );
257
258   const Dali::RefObject& handle = navigationControl.GetImplementation();
259
260   return static_cast<const Toolkit::Internal::NavigationControl&>( handle );
261 }
262
263 } // namespace Toolkit
264
265 } // namespace Dali
266
267 #endif /* __DALI_TOOLKIT_INTERNAL_NAVIGATION_CONTROL_H__ */