2 * Copyright (c) 2021 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/devel-api/controls/control-devel.h>
33 namespace // to register type
37 return Toolkit::NavigationView::New();
40 DALI_TYPE_REGISTRATION_BEGIN(Toolkit::NavigationView, Toolkit::Control, Create)
41 DALI_TYPE_REGISTRATION_END()
45 NavigationView::NavigationView()
46 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT))
50 NavigationView::~NavigationView()
52 // Clear all the items in the stack, forces their destruction before NavigationView is destroyed.
53 mContentStack.clear();
56 Toolkit::NavigationView NavigationView::New()
58 // Create the implementation, temporarily owned by this handle on stack
59 IntrusivePtr<NavigationView> internalNavigationView = new NavigationView();
61 // Pass ownership to CustomActor handle
62 Toolkit::NavigationView navigationView(*internalNavigationView);
64 // Second-phase init of the implementation
65 // This can only be done after the CustomActor connection has been made...
66 internalNavigationView->Initialize();
68 return navigationView;
71 void NavigationView::OnInitialize()
73 DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) {
74 return std::unique_ptr<Dali::Accessibility::Accessible>(
75 new DevelControl::AccessibleImpl(actor, Dali::Accessibility::Role::FILLER));
79 void NavigationView::OnSceneConnection(int depth)
81 Self().SetProperty(Actor::Property::SENSITIVE, true);
83 Control::OnSceneConnection(depth);
86 void NavigationView::Push(Actor& actor)
88 // check the uninitialized item
89 // check the duplicated push for the top item
95 if(mContentStack.size() > 0)
97 Self().Remove(mContentStack.back());
100 //push the new item into the stack and show it
101 mContentStack.push_back(actor);
105 Actor NavigationView::Pop()
107 // cannot pop out the bottom-most item
109 if(mContentStack.size() > 1)
111 // pop out the top item of the stack and show the new item right under the old one.
112 Self().Remove(mContentStack.back());
113 poppedItem = mContentStack.back();
114 mContentStack.pop_back();
115 Self().Add(mContentStack.back());
121 } // namespace Internal
123 } // namespace Toolkit