2 * Copyright (c) 2015 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 <dali-toolkit/public-api/focus-manager/focus-manager.h>
22 #include <dali/public-api/adaptor-framework/singleton-service.h>
25 #include <dali-toolkit/internal/focus-manager/focus-manager-impl.h>
33 FocusManager::FocusManager()
37 FocusManager::~FocusManager()
41 FocusManager FocusManager::Get()
45 // Check whether the focus manager is already created
46 SingletonService singletonService( SingletonService::Get() );
47 if ( singletonService )
49 Dali::BaseHandle handle = singletonService.GetSingleton(typeid(FocusManager));
52 // If so, downcast the handle of singleton to focus manager
53 manager = FocusManager(dynamic_cast<Internal::FocusManager*>(handle.GetObjectPtr()));
58 // If not, create the focus manager and register it as a singleton
59 manager = FocusManager(new Internal::FocusManager());
60 singletonService.Register(typeid(manager), manager);
67 FocusManager::FocusManager(Internal::FocusManager *impl)
72 void FocusManager::SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text)
74 GetImpl(*this).SetAccessibilityAttribute(actor, type, text);
77 std::string FocusManager::GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const
79 return GetImpl(*this).GetAccessibilityAttribute(actor, type);
82 void FocusManager::SetFocusOrder(Actor actor, const unsigned int order)
84 GetImpl(*this).SetFocusOrder(actor, order);
87 unsigned int FocusManager::GetFocusOrder(Actor actor) const
89 return GetImpl(*this).GetFocusOrder(actor);
92 unsigned int FocusManager::GenerateNewFocusOrder() const
94 return GetImpl(*this).GenerateNewFocusOrder();
97 Actor FocusManager::GetActorByFocusOrder(const unsigned int order)
99 return GetImpl(*this).GetActorByFocusOrder(order);
102 bool FocusManager::SetCurrentFocusActor(Actor actor)
104 return GetImpl(*this).SetCurrentFocusActor(actor);
107 Actor FocusManager::GetCurrentFocusActor()
109 return GetImpl(*this).GetCurrentFocusActor();
112 Actor FocusManager::GetCurrentFocusGroup()
114 return GetImpl(*this).GetCurrentFocusGroup();
117 unsigned int FocusManager::GetCurrentFocusOrder()
119 return GetImpl(*this).GetCurrentFocusOrder();
122 bool FocusManager::MoveFocusForward()
124 return GetImpl(*this).MoveFocusForward();
127 bool FocusManager::MoveFocusBackward()
129 return GetImpl(*this).MoveFocusBackward();
132 void FocusManager::ClearFocus()
134 GetImpl(*this).ClearFocus();
137 void FocusManager::Reset()
139 GetImpl(*this).Reset();
142 void FocusManager::SetFocusGroup(Actor actor, bool isFocusGroup)
144 GetImpl(*this).SetFocusGroup(actor, isFocusGroup);
147 bool FocusManager::IsFocusGroup(Actor actor) const
149 return GetImpl(*this).IsFocusGroup(actor);
152 void FocusManager::SetGroupMode(bool enabled)
154 GetImpl(*this).SetGroupMode(enabled);
157 bool FocusManager::GetGroupMode() const
159 return GetImpl(*this).GetGroupMode();
162 void FocusManager::SetWrapMode(bool wrapped)
164 GetImpl(*this).SetWrapMode(wrapped);
167 bool FocusManager::GetWrapMode() const
169 return GetImpl(*this).GetWrapMode();
172 void FocusManager::SetFocusIndicatorActor(Actor indicator)
174 GetImpl(*this).SetFocusIndicatorActor(indicator);
177 Actor FocusManager::GetFocusIndicatorActor()
179 return GetImpl(*this).GetFocusIndicatorActor();
182 Actor FocusManager::GetFocusGroup(Actor actor)
184 return GetImpl(*this).GetFocusGroup(actor);
187 FocusManager::FocusChangedSignalType& FocusManager::FocusChangedSignal()
189 return GetImpl(*this).FocusChangedSignal();
192 FocusManager::FocusOvershotSignalType& FocusManager::FocusOvershotSignal()
194 return GetImpl(*this).FocusOvershotSignal();
197 FocusManager::FocusedActorActivatedSignalType& FocusManager::FocusedActorActivatedSignal()
199 return GetImpl(*this).FocusedActorActivatedSignal();
202 } // namespace Toolkit