Add deviceName to GetNextFocusableView() in CustomFocusAlgorithm.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / focus-manager / keyboard-focus-manager-devel.h
1 #ifndef DALI_TOOLKIT_KEYBOARD_FOCUS_MANAGER_DEVEL_H
2 #define DALI_TOOLKIT_KEYBOARD_FOCUS_MANAGER_DEVEL_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace DevelKeyboardFocusManager
32 {
33 /**
34  * @brief Interface used to provide custom keyboard focus algorithm for retrieving the next focusable actor.
35  *
36  * The application / toolkit can implement the interface and override the keyboard focus behaviour.
37  * Upon providing an implementation of this interface, the PreFocusChangeSignal is no longer emitted.
38  * If focus is changing within a layout container, then the layout container is queried first to provide
39  * the next focusable actor. If this does not provide a valid actor, then the Keyboard FocusManager will
40  * check focusable properties to determine next focusable actor. If focusable properties are not set,
41  * then the Keyboard FocusManager calls the GetNextFocusableActor() method of this interface.
42  */
43 class CustomAlgorithmInterface
44 {
45 public:
46   /**
47    * @brief Virtual destructor.
48    */
49   virtual ~CustomAlgorithmInterface(){};
50
51   /**
52    * @brief Called by the KeyboardFocusManager to get the next focusable actor.
53    *
54    * @param[in] current The current focused actor
55    * @param[in] proposed The proposed focused actor
56    * @param[in] direction The direction of focus movement
57    * @param[in] deviceName The name of the device where the key event occurred.
58    * @return A handle to the next focusable actor
59    */
60   virtual Actor GetNextFocusableActor(Actor current, Actor proposed, Control::KeyboardFocus::Direction direction, const std::string& deviceName = "") = 0;
61
62 };
63
64 /**
65  * @brief Provide the implementation of custom Focus algorithm interface
66  *
67  * @param[in] keyboardFocusManager The instance of KeyboardFocusManager
68  * @param[in] interface The user's implementation of CustomAlgorithmInterface
69  * @see DevelKeyboardFocusManager::CustomAlgorithmInterface
70  */
71 DALI_TOOLKIT_API void SetCustomAlgorithm(KeyboardFocusManager keyboardFocusManager, CustomAlgorithmInterface& interface);
72
73 /**
74  * @brief Decide using focus indicator or not
75  *
76  * @param[in] keyboardFocusManager The instance of KeyboardFocusManager
77  * @param[in] enable Whether using focus indicator or not
78  */
79 DALI_TOOLKIT_API void EnableFocusIndicator(KeyboardFocusManager keyboardFocusManager, bool enable);
80
81 /**
82  * @brief Check focus indicator is enabled or not
83  *
84  * @param[in] keyboardFocusManager The instance of KeyboardFocusManager
85  * @return True when focus indicator is enabled
86  */
87 DALI_TOOLKIT_API bool IsFocusIndicatorEnabled(KeyboardFocusManager keyboardFocusManager);
88
89 /**
90  * @brief Decide using default focus algorithm or not
91  *
92  * @param[in] keyboardFocusManager The instance of KeyboardFocusManager
93  * @param[in] enable Whether using default focus algorithm or not
94  */
95 DALI_TOOLKIT_API void EnableDefaultAlgorithm(KeyboardFocusManager keyboardFocusManager, bool enable);
96
97 /**
98  * @brief Check default focus algorithm is enabled or not
99  *
100  * @param[in] keyboardFocusManager The instance of KeyboardFocusManager
101  * @return True when default focus algorithm is enabled
102  */
103 DALI_TOOLKIT_API bool IsDefaultAlgorithmEnabled(KeyboardFocusManager keyboardFocusManager);
104
105 /**
106  * @brief Moves the focus to the next focusable actor in the focus
107  * chain in the given direction (according to the focus traversal
108  * order).
109  *
110  * @param[in] keyboardFocusManager The instance of KeyboardFocusManager
111  * @param direction The direction of focus movement
112  * @param deviceName The device name
113  * @return true if the movement was successful
114  * @pre The KeyboardFocusManager has been initialized.
115  */
116 DALI_TOOLKIT_API bool MoveFocus(KeyboardFocusManager keyboardFocusManager, Control::KeyboardFocus::Direction direction, const std::string& deviceName);
117
118
119 } // namespace DevelKeyboardFocusManager
120
121 } // namespace Toolkit
122
123 } // namespace Dali
124
125 #endif // DALI_TOOLKIT_KEYBOARD_FOCUS_MANAGER_DEVEL_H