1 #ifndef DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H
2 #define DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/public-api/object/object-registry.h>
27 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
28 #include <dali-toolkit/public-api/controls/control.h>
36 } // namespace Integration
42 class KeyInputFocusManager;
45 * @copydoc Toolkit::KeyInputFocusManager
47 class KeyInputFocusManager : public Dali::BaseObject, public Dali::ConnectionTracker
51 * Construct a new KeyInputFocusManager.
53 KeyInputFocusManager();
56 * @copydoc Toolkit::SetFocus
58 void SetFocus(Toolkit::Control control);
61 * @copydoc Toolkit::RemoveFocus
63 void RemoveFocus(Toolkit::Control control);
66 * @copydoc Toolkit::GetCurrentFocusControl
68 Toolkit::Control GetCurrentFocusControl() const;
72 * @copydoc Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignal()
74 Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusChangedSignal();
77 * Connects a callback function with the object's signals.
78 * @param[in] object The object providing the signal.
79 * @param[in] tracker Used to disconnect the signal.
80 * @param[in] signalName The signal to connect to.
81 * @param[in] functor A newly allocated FunctorDelegate.
82 * @return True if the signal was connected.
83 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
85 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
91 virtual ~KeyInputFocusManager();
95 * This will be called when a new scene holder is created
96 * @param sceneHolder The new scene holder
98 void OnSceneHolderCreated(Dali::Integration::SceneHolder& sceneHolder);
101 * Callback for the key event when no actor in the stage has gained the key input focus
102 * @param[in] event The KeyEvent event.
104 bool OnKeyEvent(const KeyEvent& event);
107 * Signal handler called when a focused Control is removed from Scene.
108 * @param[in] control The control removed from the scene.
110 void OnFocusControlSceneDisconnection(Dali::Actor control);
113 * Recursively deliver events to the control and its parents, until the event is consumed or the stage is reached.
114 * @param[in] control The control got KeyEvent.
115 * @param[in] event The KeyEvent.
116 * @return True if KeyEvent is consumed.
118 bool EmitKeyEventSignal(Toolkit::Control control, const KeyEvent& event);
121 * Gets the current native window id
123 uint32_t GetCurrentWindowId() const;
127 KeyInputFocusManager(const KeyInputFocusManager&);
129 KeyInputFocusManager& operator=(const KeyInputFocusManager& rhs);
132 // The key input focus change signal
133 Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalType mKeyInputFocusChangedSignal;
135 SlotDelegate<KeyInputFocusManager> mSlotDelegate;
137 Toolkit::Control mCurrentFocusControl; ///< The current focused control
138 uint32_t mCurrentWindowId; ///< The native window id of current focused control
141 } // namespace Internal
143 inline Internal::KeyInputFocusManager& GetImpl(Dali::Toolkit::KeyInputFocusManager& obj)
145 DALI_ASSERT_ALWAYS(obj);
147 Dali::BaseObject& handle = obj.GetBaseObject();
149 return static_cast<Internal::KeyInputFocusManager&>(handle);
152 inline const Internal::KeyInputFocusManager& GetImpl(const Dali::Toolkit::KeyInputFocusManager& obj)
154 DALI_ASSERT_ALWAYS(obj);
156 const Dali::BaseObject& handle = obj.GetBaseObject();
158 return static_cast<const Internal::KeyInputFocusManager&>(handle);
161 } // namespace Toolkit
165 #endif // DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H