2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "navigation-view-impl.h"
22 #include <dali/public-api/object/type-registry-helper.h>
35 namespace // to register type
40 return Toolkit::NavigationView::New();
43 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::NavigationView, Toolkit::Control, Create )
44 DALI_TYPE_REGISTRATION_END()
48 NavigationView::NavigationView()
49 : Control(ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) )
53 NavigationView::~NavigationView()
55 // Clear all the items in the stack, forces their destruction before NavigationView is destroyed.
56 mContentStack.clear();
59 Toolkit::NavigationView NavigationView::New()
61 // Create the implementation, temporarily owned by this handle on stack
62 IntrusivePtr< NavigationView > internalNavigationView = new NavigationView();
64 // Pass ownership to CustomActor handle
65 Toolkit::NavigationView navigationView( *internalNavigationView );
67 // Second-phase init of the implementation
68 // This can only be done after the CustomActor connection has been made...
69 internalNavigationView->Initialize();
71 return navigationView;
74 void NavigationView::OnStageConnection( int depth )
76 Self().SetSensitive(true);
78 Control::OnStageConnection( depth );
81 void NavigationView::Push( Actor& actor )
83 // check the uninitialized item
84 // check the duplicated push for the top item
90 if( mContentStack.size() > 0 )
92 Self().Remove( mContentStack.back() );
95 //push the new item into the stack and show it
96 mContentStack.push_back(actor);
100 Actor NavigationView::Pop()
102 // cannot pop out the bottom-most item
104 if( mContentStack.size() > 1 )
106 // pop out the top item of the stack and show the new item right under the old one.
107 Self().Remove(mContentStack.back());
108 poppedItem = mContentStack.back();
109 mContentStack.pop_back();
110 Self().Add(mContentStack.back());
116 } // namespace Internal
118 } // namespace Toolkit