ScrollView - Overshoot Fix
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / focus-manager / focus-manager.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19
20 #include <dali-toolkit/public-api/focus-manager/focus-manager.h>
21
22 // EXTERNAL INCLUDES
23
24 // INTERNAL INCLUDES
25
26 #include <dali-toolkit/internal/focus-manager/focus-manager-impl.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
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";
37
38 FocusManager::FocusManager()
39 {
40 }
41
42 FocusManager::~FocusManager()
43 {
44 }
45
46 FocusManager FocusManager::Get()
47 {
48   FocusManager manager;
49
50   // Check whether the focus manager is already created
51   Dali::Adaptor& adaptor = Dali::Adaptor::Get();
52   Dali::BaseHandle handle = adaptor.GetSingleton(typeid(FocusManager));
53   if(handle)
54   {
55     // If so, downcast the handle of singleton to focus manager
56     manager = FocusManager(dynamic_cast<Internal::FocusManager*>(handle.GetObjectPtr()));
57   }
58
59   if(!manager)
60   {
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);
64   }
65
66   return manager;
67 }
68
69 FocusManager::FocusManager(Internal::FocusManager *impl)
70   : BaseHandle(impl)
71 {
72 }
73
74 void FocusManager::SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text)
75 {
76   GetImpl(*this).SetAccessibilityAttribute(actor, type, text);
77 }
78
79 std::string FocusManager::GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const
80 {
81   return GetImpl(*this).GetAccessibilityAttribute(actor, type);
82 }
83
84 void FocusManager::SetFocusOrder(Actor actor, const unsigned int order)
85 {
86   GetImpl(*this).SetFocusOrder(actor, order);
87 }
88
89 unsigned int FocusManager::GetFocusOrder(Actor actor) const
90 {
91   return GetImpl(*this).GetFocusOrder(actor);
92 }
93
94 unsigned int FocusManager::GenerateNewFocusOrder() const
95 {
96   return GetImpl(*this).GenerateNewFocusOrder();
97 }
98
99 Actor FocusManager::GetActorByFocusOrder(const unsigned int order)
100 {
101   return GetImpl(*this).GetActorByFocusOrder(order);
102 }
103
104 bool FocusManager::SetCurrentFocusActor(Actor actor)
105 {
106   return GetImpl(*this).SetCurrentFocusActor(actor);
107 }
108
109 Actor FocusManager::GetCurrentFocusActor()
110 {
111   return GetImpl(*this).GetCurrentFocusActor();
112 }
113
114 Actor FocusManager::GetCurrentFocusGroup()
115 {
116   return GetImpl(*this).GetCurrentFocusGroup();
117 }
118
119 unsigned int FocusManager::GetCurrentFocusOrder()
120 {
121   return GetImpl(*this).GetCurrentFocusOrder();
122 }
123
124 bool FocusManager::MoveFocusForward()
125 {
126   return GetImpl(*this).MoveFocusForward();
127 }
128
129 bool FocusManager::MoveFocusBackward()
130 {
131   return GetImpl(*this).MoveFocusBackward();
132 }
133
134 void FocusManager::ClearFocus()
135 {
136   GetImpl(*this).ClearFocus();
137 }
138
139 void FocusManager::Reset()
140 {
141   GetImpl(*this).Reset();
142 }
143
144 void FocusManager::SetFocusGroup(Actor actor, bool isFocusGroup)
145 {
146   GetImpl(*this).SetFocusGroup(actor, isFocusGroup);
147 }
148
149 bool FocusManager::IsFocusGroup(Actor actor) const
150 {
151   return GetImpl(*this).IsFocusGroup(actor);
152 }
153
154 void FocusManager::SetGroupMode(bool enabled)
155 {
156   GetImpl(*this).SetGroupMode(enabled);
157 }
158
159 bool FocusManager::GetGroupMode() const
160 {
161   return GetImpl(*this).GetGroupMode();
162 }
163
164 void FocusManager::SetWrapMode(bool wrapped)
165 {
166   GetImpl(*this).SetWrapMode(wrapped);
167 }
168
169 bool FocusManager::GetWrapMode() const
170 {
171   return GetImpl(*this).GetWrapMode();
172 }
173
174 void FocusManager::SetFocusIndicatorActor(Actor indicator)
175 {
176   GetImpl(*this).SetFocusIndicatorActor(indicator);
177 }
178
179 Actor FocusManager::GetFocusIndicatorActor()
180 {
181   return GetImpl(*this).GetFocusIndicatorActor();
182 }
183
184 Actor FocusManager::GetFocusGroup(Actor actor)
185 {
186   return GetImpl(*this).GetFocusGroup(actor);
187 }
188
189 FocusManager::FocusChangedSignalV2& FocusManager::FocusChangedSignal()
190 {
191   return GetImpl(*this).FocusChangedSignal();
192 }
193
194 FocusManager::FocusOvershotSignalV2& FocusManager::FocusOvershotSignal()
195 {
196   return GetImpl(*this).FocusOvershotSignal();
197 }
198
199 FocusManager::FocusedActorActivatedSignalV2& FocusManager::FocusedActorActivatedSignal()
200 {
201   return GetImpl(*this).FocusedActorActivatedSignal();
202 }
203
204 } // namespace Toolkit
205
206 } // namespace Dali