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