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 Dali::Adaptor& adaptor = Dali::Adaptor::Get();
52 Dali::BaseHandle handle = adaptor.GetSingleton(typeid(FocusManager));
55 // If so, downcast the handle of singleton to focus manager
56 manager = FocusManager(dynamic_cast<Internal::FocusManager*>(handle.GetObjectPtr()));
61 // If not, create the focus manager and register it as a singleton
62 manager = FocusManager(new Internal::FocusManager());
63 adaptor.RegisterSingleton(typeid(manager), manager);
69 FocusManager::FocusManager(Internal::FocusManager *impl)
74 void FocusManager::SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text)
76 GetImpl(*this).SetAccessibilityAttribute(actor, type, text);
79 std::string FocusManager::GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const
81 return GetImpl(*this).GetAccessibilityAttribute(actor, type);
84 void FocusManager::SetFocusOrder(Actor actor, const unsigned int order)
86 GetImpl(*this).SetFocusOrder(actor, order);
89 unsigned int FocusManager::GetFocusOrder(Actor actor) const
91 return GetImpl(*this).GetFocusOrder(actor);
94 unsigned int FocusManager::GenerateNewFocusOrder() const
96 return GetImpl(*this).GenerateNewFocusOrder();
99 Actor FocusManager::GetActorByFocusOrder(const unsigned int order)
101 return GetImpl(*this).GetActorByFocusOrder(order);
104 bool FocusManager::SetCurrentFocusActor(Actor actor)
106 return GetImpl(*this).SetCurrentFocusActor(actor);
109 Actor FocusManager::GetCurrentFocusActor()
111 return GetImpl(*this).GetCurrentFocusActor();
114 Actor FocusManager::GetCurrentFocusGroup()
116 return GetImpl(*this).GetCurrentFocusGroup();
119 unsigned int FocusManager::GetCurrentFocusOrder()
121 return GetImpl(*this).GetCurrentFocusOrder();
124 bool FocusManager::MoveFocusForward()
126 return GetImpl(*this).MoveFocusForward();
129 bool FocusManager::MoveFocusBackward()
131 return GetImpl(*this).MoveFocusBackward();
134 void FocusManager::ClearFocus()
136 GetImpl(*this).ClearFocus();
139 void FocusManager::Reset()
141 GetImpl(*this).Reset();
144 void FocusManager::SetFocusGroup(Actor actor, bool isFocusGroup)
146 GetImpl(*this).SetFocusGroup(actor, isFocusGroup);
149 bool FocusManager::IsFocusGroup(Actor actor) const
151 return GetImpl(*this).IsFocusGroup(actor);
154 void FocusManager::SetGroupMode(bool enabled)
156 GetImpl(*this).SetGroupMode(enabled);
159 bool FocusManager::GetGroupMode() const
161 return GetImpl(*this).GetGroupMode();
164 void FocusManager::SetWrapMode(bool wrapped)
166 GetImpl(*this).SetWrapMode(wrapped);
169 bool FocusManager::GetWrapMode() const
171 return GetImpl(*this).GetWrapMode();
174 void FocusManager::SetFocusIndicatorActor(Actor indicator)
176 GetImpl(*this).SetFocusIndicatorActor(indicator);
179 Actor FocusManager::GetFocusIndicatorActor()
181 return GetImpl(*this).GetFocusIndicatorActor();
184 Actor FocusManager::GetFocusGroup(Actor actor)
186 return GetImpl(*this).GetFocusGroup(actor);
189 FocusManager::FocusChangedSignalV2& FocusManager::FocusChangedSignal()
191 return GetImpl(*this).FocusChangedSignal();
194 FocusManager::FocusOvershotSignalV2& FocusManager::FocusOvershotSignal()
196 return GetImpl(*this).FocusOvershotSignal();
199 FocusManager::FocusedActorActivatedSignalV2& FocusManager::FocusedActorActivatedSignal()
201 return GetImpl(*this).FocusedActorActivatedSignal();
204 } // namespace Toolkit