2 * Copyright (c) 2020 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.
19 #include "keyinput-focus-manager.h"
22 #include <dali/devel-api/common/singleton-service.h>
25 #include <dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h>
31 KeyInputFocusManager::KeyInputFocusManager()
35 KeyInputFocusManager::~KeyInputFocusManager()
39 KeyInputFocusManager KeyInputFocusManager::Get()
41 KeyInputFocusManager manager;
43 // Check whether the focus manager is already created
44 SingletonService singletonService(SingletonService::Get());
47 Dali::BaseHandle handle = singletonService.GetSingleton(typeid(KeyInputFocusManager));
50 // If so, downcast the handle of singleton to focus manager
51 manager = KeyInputFocusManager(dynamic_cast<Internal::KeyInputFocusManager*>(handle.GetObjectPtr()));
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);
65 KeyInputFocusManager::KeyInputFocusManager(Internal::KeyInputFocusManager* impl)
70 void KeyInputFocusManager::SetFocus(Control control)
72 GetImpl(*this).SetFocus(control);
75 Control KeyInputFocusManager::GetCurrentFocusControl() const
77 return GetImpl(*this).GetCurrentFocusControl();
80 void KeyInputFocusManager::RemoveFocus(Control control)
82 GetImpl(*this).RemoveFocus(control);
85 KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusManager::KeyInputFocusChangedSignal()
87 return GetImpl(*this).KeyInputFocusChangedSignal();
90 } // namespace Toolkit