It may be outside the range of type int.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / focus-manager / keyinput-focus-manager.cpp
1 /*
2  * Copyright (c) 2020 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 #include "keyinput-focus-manager.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/common/singleton-service.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 KeyInputFocusManager::KeyInputFocusManager()
32 {
33 }
34
35 KeyInputFocusManager::~KeyInputFocusManager()
36 {
37 }
38
39 KeyInputFocusManager KeyInputFocusManager::Get()
40 {
41   KeyInputFocusManager manager;
42
43   // Check whether the focus manager is already created
44   SingletonService singletonService(SingletonService::Get());
45   if(singletonService)
46   {
47     Dali::BaseHandle handle = singletonService.GetSingleton(typeid(KeyInputFocusManager));
48     if(handle)
49     {
50       // If so, downcast the handle of singleton to focus manager
51       manager = KeyInputFocusManager(dynamic_cast<Internal::KeyInputFocusManager*>(handle.GetObjectPtr()));
52     }
53
54     if(!manager)
55     {
56       // If not, create the focus manager and register it as a singleton
57       manager = KeyInputFocusManager(new Internal::KeyInputFocusManager());
58       singletonService.Register(typeid(manager), manager);
59     }
60   }
61
62   return manager;
63 }
64
65 KeyInputFocusManager::KeyInputFocusManager(Internal::KeyInputFocusManager* impl)
66 : BaseHandle(impl)
67 {
68 }
69
70 void KeyInputFocusManager::SetFocus(Control control)
71 {
72   GetImpl(*this).SetFocus(control);
73 }
74
75 Control KeyInputFocusManager::GetCurrentFocusControl() const
76 {
77   return GetImpl(*this).GetCurrentFocusControl();
78 }
79
80 void KeyInputFocusManager::RemoveFocus(Control control)
81 {
82   GetImpl(*this).RemoveFocus(control);
83 }
84
85 KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusManager::KeyInputFocusChangedSignal()
86 {
87   return GetImpl(*this).KeyInputFocusChangedSignal();
88 }
89
90 } // namespace Toolkit
91
92 } // namespace Dali