2 * Copyright (c) 2014 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 const char* const FocusManager::SIGNAL_FOCUS_CHANGED = "focus-changed";
34 const char* const FocusManager::SIGNAL_FOCUS_OVERSHOT = "focus-overshot";
35 const char* const FocusManager::SIGNAL_FOCUSED_ACTOR_ACTIVATED = "focused-actor-activated";
37 FocusManager::FocusManager()
41 FocusManager::~FocusManager()
45 FocusManager FocusManager::Get()
49 // Check whether the focus manager is already created
50 SingletonService singletonService( SingletonService::Get() );
51 if ( singletonService )
53 Dali::BaseHandle handle = singletonService.GetSingleton(typeid(FocusManager));
56 // If so, downcast the handle of singleton to focus manager
57 manager = FocusManager(dynamic_cast<Internal::FocusManager*>(handle.GetObjectPtr()));
62 // If not, create the focus manager and register it as a singleton
63 manager = FocusManager(new Internal::FocusManager());
64 singletonService.Register(typeid(manager), manager);
71 FocusManager::FocusManager(Internal::FocusManager *impl)
76 void FocusManager::SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text)
78 GetImpl(*this).SetAccessibilityAttribute(actor, type, text);
81 std::string FocusManager::GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const
83 return GetImpl(*this).GetAccessibilityAttribute(actor, type);
86 void FocusManager::SetFocusOrder(Actor actor, const unsigned int order)
88 GetImpl(*this).SetFocusOrder(actor, order);
91 unsigned int FocusManager::GetFocusOrder(Actor actor) const
93 return GetImpl(*this).GetFocusOrder(actor);
96 unsigned int FocusManager::GenerateNewFocusOrder() const
98 return GetImpl(*this).GenerateNewFocusOrder();
101 Actor FocusManager::GetActorByFocusOrder(const unsigned int order)
103 return GetImpl(*this).GetActorByFocusOrder(order);
106 bool FocusManager::SetCurrentFocusActor(Actor actor)
108 return GetImpl(*this).SetCurrentFocusActor(actor);
111 Actor FocusManager::GetCurrentFocusActor()
113 return GetImpl(*this).GetCurrentFocusActor();
116 Actor FocusManager::GetCurrentFocusGroup()
118 return GetImpl(*this).GetCurrentFocusGroup();
121 unsigned int FocusManager::GetCurrentFocusOrder()
123 return GetImpl(*this).GetCurrentFocusOrder();
126 bool FocusManager::MoveFocusForward()
128 return GetImpl(*this).MoveFocusForward();
131 bool FocusManager::MoveFocusBackward()
133 return GetImpl(*this).MoveFocusBackward();
136 void FocusManager::ClearFocus()
138 GetImpl(*this).ClearFocus();
141 void FocusManager::Reset()
143 GetImpl(*this).Reset();
146 void FocusManager::SetFocusGroup(Actor actor, bool isFocusGroup)
148 GetImpl(*this).SetFocusGroup(actor, isFocusGroup);
151 bool FocusManager::IsFocusGroup(Actor actor) const
153 return GetImpl(*this).IsFocusGroup(actor);
156 void FocusManager::SetGroupMode(bool enabled)
158 GetImpl(*this).SetGroupMode(enabled);
161 bool FocusManager::GetGroupMode() const
163 return GetImpl(*this).GetGroupMode();
166 void FocusManager::SetWrapMode(bool wrapped)
168 GetImpl(*this).SetWrapMode(wrapped);
171 bool FocusManager::GetWrapMode() const
173 return GetImpl(*this).GetWrapMode();
176 void FocusManager::SetFocusIndicatorActor(Actor indicator)
178 GetImpl(*this).SetFocusIndicatorActor(indicator);
181 Actor FocusManager::GetFocusIndicatorActor()
183 return GetImpl(*this).GetFocusIndicatorActor();
186 Actor FocusManager::GetFocusGroup(Actor actor)
188 return GetImpl(*this).GetFocusGroup(actor);
191 FocusManager::FocusChangedSignalType& FocusManager::FocusChangedSignal()
193 return GetImpl(*this).FocusChangedSignal();
196 FocusManager::FocusOvershotSignalType& FocusManager::FocusOvershotSignal()
198 return GetImpl(*this).FocusOvershotSignal();
201 FocusManager::FocusedActorActivatedSignalType& FocusManager::FocusedActorActivatedSignal()
203 return GetImpl(*this).FocusedActorActivatedSignal();
206 } // namespace Toolkit