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>
25 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
36 namespace // to register type
41 return Toolkit::NavigationView::New();
44 DALI_TYPE_REGISTRATION_BEGIN( Toolkit::NavigationView, Toolkit::Control, Create )
45 DALI_TYPE_REGISTRATION_END()
49 NavigationView::NavigationView()
50 : Control(ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) )
54 NavigationView::~NavigationView()
56 // Clear all the items in the stack, forces their destruction before NavigationView is destroyed.
57 mContentStack.clear();
60 Toolkit::NavigationView NavigationView::New()
62 // Create the implementation, temporarily owned by this handle on stack
63 IntrusivePtr< NavigationView > internalNavigationView = new NavigationView();
65 // Pass ownership to CustomActor handle
66 Toolkit::NavigationView navigationView( *internalNavigationView );
68 // Second-phase init of the implementation
69 // This can only be done after the CustomActor connection has been made...
70 internalNavigationView->Initialize();
72 return navigationView;
75 void NavigationView::OnInitialize()
77 DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) {
78 return std::unique_ptr< Dali::Accessibility::Accessible >(
79 new Control::Impl::AccessibleImpl( actor, Dali::Accessibility::Role::FILLER ) );
83 void NavigationView::OnSceneConnection( int depth )
85 Self().SetProperty( Actor::Property::SENSITIVE,true);
87 Control::OnSceneConnection( depth );
90 void NavigationView::Push( Actor& actor )
92 // check the uninitialized item
93 // check the duplicated push for the top item
99 if( mContentStack.size() > 0 )
101 Self().Remove( mContentStack.back() );
104 //push the new item into the stack and show it
105 mContentStack.push_back(actor);
109 Actor NavigationView::Pop()
111 // cannot pop out the bottom-most item
113 if( mContentStack.size() > 1 )
115 // pop out the top item of the stack and show the new item right under the old one.
116 Self().Remove(mContentStack.back());
117 poppedItem = mContentStack.back();
118 mContentStack.pop_back();
119 Self().Add(mContentStack.back());
125 } // namespace Internal
127 } // namespace Toolkit