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.
20 #include <dali-toolkit/public-api/focus-manager/focus-manager.h>
26 #include <dali-toolkit/internal/focus-manager/focus-manager-impl.h>
34 const char* const FocusManager::SIGNAL_FOCUS_CHANGED = "focus-changed";
35 const char* const FocusManager::SIGNAL_FOCUS_OVERSHOT = "focus-overshot";
36 const char* const FocusManager::SIGNAL_FOCUSED_ACTOR_ACTIVATED = "focused-actor-activated";
38 FocusManager::FocusManager()
42 FocusManager::~FocusManager()
46 FocusManager FocusManager::Get()
50 // Check whether the focus manager is already created
51 SingletonService singletonService( SingletonService::Get() );
52 if ( singletonService )
54 Dali::BaseHandle handle = singletonService.GetSingleton(typeid(FocusManager));
57 // If so, downcast the handle of singleton to focus manager
58 manager = FocusManager(dynamic_cast<Internal::FocusManager*>(handle.GetObjectPtr()));
63 // If not, create the focus manager and register it as a singleton
64 manager = FocusManager(new Internal::FocusManager());
65 singletonService.Register(typeid(manager), manager);
72 FocusManager::FocusManager(Internal::FocusManager *impl)
77 void FocusManager::SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text)
79 GetImpl(*this).SetAccessibilityAttribute(actor, type, text);
82 std::string FocusManager::GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const
84 return GetImpl(*this).GetAccessibilityAttribute(actor, type);
87 void FocusManager::SetFocusOrder(Actor actor, const unsigned int order)
89 GetImpl(*this).SetFocusOrder(actor, order);
92 unsigned int FocusManager::GetFocusOrder(Actor actor) const
94 return GetImpl(*this).GetFocusOrder(actor);
97 unsigned int FocusManager::GenerateNewFocusOrder() const
99 return GetImpl(*this).GenerateNewFocusOrder();
102 Actor FocusManager::GetActorByFocusOrder(const unsigned int order)
104 return GetImpl(*this).GetActorByFocusOrder(order);
107 bool FocusManager::SetCurrentFocusActor(Actor actor)
109 return GetImpl(*this).SetCurrentFocusActor(actor);
112 Actor FocusManager::GetCurrentFocusActor()
114 return GetImpl(*this).GetCurrentFocusActor();
117 Actor FocusManager::GetCurrentFocusGroup()
119 return GetImpl(*this).GetCurrentFocusGroup();
122 unsigned int FocusManager::GetCurrentFocusOrder()
124 return GetImpl(*this).GetCurrentFocusOrder();
127 bool FocusManager::MoveFocusForward()
129 return GetImpl(*this).MoveFocusForward();
132 bool FocusManager::MoveFocusBackward()
134 return GetImpl(*this).MoveFocusBackward();
137 void FocusManager::ClearFocus()
139 GetImpl(*this).ClearFocus();
142 void FocusManager::Reset()
144 GetImpl(*this).Reset();
147 void FocusManager::SetFocusGroup(Actor actor, bool isFocusGroup)
149 GetImpl(*this).SetFocusGroup(actor, isFocusGroup);
152 bool FocusManager::IsFocusGroup(Actor actor) const
154 return GetImpl(*this).IsFocusGroup(actor);
157 void FocusManager::SetGroupMode(bool enabled)
159 GetImpl(*this).SetGroupMode(enabled);
162 bool FocusManager::GetGroupMode() const
164 return GetImpl(*this).GetGroupMode();
167 void FocusManager::SetWrapMode(bool wrapped)
169 GetImpl(*this).SetWrapMode(wrapped);
172 bool FocusManager::GetWrapMode() const
174 return GetImpl(*this).GetWrapMode();
177 void FocusManager::SetFocusIndicatorActor(Actor indicator)
179 GetImpl(*this).SetFocusIndicatorActor(indicator);
182 Actor FocusManager::GetFocusIndicatorActor()
184 return GetImpl(*this).GetFocusIndicatorActor();
187 Actor FocusManager::GetFocusGroup(Actor actor)
189 return GetImpl(*this).GetFocusGroup(actor);
192 FocusManager::FocusChangedSignalV2& FocusManager::FocusChangedSignal()
194 return GetImpl(*this).FocusChangedSignal();
197 FocusManager::FocusOvershotSignalV2& FocusManager::FocusOvershotSignal()
199 return GetImpl(*this).FocusOvershotSignal();
202 FocusManager::FocusedActorActivatedSignalV2& FocusManager::FocusedActorActivatedSignal()
204 return GetImpl(*this).FocusedActorActivatedSignal();
207 } // namespace Toolkit