[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / virtual-keyboard.h
1 #ifndef DALI_VIRTUAL_KEYBOARD_H
2 #define DALI_VIRTUAL_KEYBOARD_H
3
4 /*
5  * Copyright (c) 2020 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/public-api/math/rect.h>
23 #include <dali/public-api/object/property-map.h>
24 #include <dali/public-api/signals/dali-signal.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/adaptor-framework/input-method.h>
28
29 namespace Dali
30 {
31 /**
32  * @brief This namespace is provided for application developers to be able to show and hide the on-screen keyboard.
33  *
34  * Key events are sent to the actor in focus. Focus is set through the actor Public API.
35  */
36 namespace VirtualKeyboard
37 {
38 // Types
39
40 typedef Signal<void()>     VoidSignalType;
41 typedef Signal<void(bool)> StatusSignalType;
42 typedef Signal<void(int)>  KeyboardResizedSignalType;
43 typedef Signal<void(int)>  LanguageChangedSignalType;
44
45 // Enumerations
46
47 /**
48  * @brief The direction of text.
49  */
50 enum TextDirection
51 {
52   LEFT_TO_RIGHT,
53   RIGHT_TO_LEFT,
54 };
55
56 /**
57  * @brief The meaning of the return key.
58  */
59 enum ReturnKeyType
60 {
61   DEFAULT,
62   DONE,
63   GO,
64   JOIN,
65   LOGIN,
66   NEXT,
67   SEARCH,
68   SEND,
69   SIGNIN
70 };
71
72 // Functions
73 /**
74  * @brief Show the virtual keyboard.
75  */
76 DALI_ADAPTOR_API void Show();
77
78 /**
79  * @brief Hide the virtual keyboard.
80  */
81 DALI_ADAPTOR_API void Hide();
82
83 /**
84  * @brief Returns whether the virtual keyboard is visible or not.
85  * @return true if visible, false otherwise.
86  */
87 DALI_ADAPTOR_API bool IsVisible();
88
89 /**
90  * @brief Set one or more of the Input Method Settings
91  * @param[in] settingsMap Map of Settings to be applied.
92  */
93 DALI_ADAPTOR_API void ApplySettings(const Property::Map& settingsMap);
94
95 /**
96  * @brief Set the specific return key into the virtual keyboard.
97  * @param[in] type the kind of return key types.
98  */
99 DALI_ADAPTOR_API void SetReturnKeyType(const InputMethod::ButtonAction::Type type);
100
101 /**
102  * @brief Retrieve the current return key type.
103  * @return the type of retun key.
104  */
105 DALI_ADAPTOR_API InputMethod::ButtonAction::Type GetReturnKeyType();
106
107 /**
108  * @brief Enable/disable prediction (predictive text).
109  *
110  * By default prediction text is enabled.
111  * @param[in] enable true or false to enable or disable
112  * Prediction can not be changed while the keyboard is visible. It must be set in advance of showing keyboard.
113  */
114 DALI_ADAPTOR_API void EnablePrediction(const bool enable);
115
116 /**
117  * @brief Returns whether prediction is enabled in the virtual keyboard
118  * @return true if predictive text enabled, false otherwise.
119  */
120 DALI_ADAPTOR_API bool IsPredictionEnabled();
121
122 /**
123  * @brief Provides size and position of keyboard.
124  *
125  * Position is relative to whether keyboard is visible or not.
126  * If keyboard is not visible then position will be off the screen.
127  * If keyboard is not being shown when this method is called the keyboard is partially setup (IMFContext) to get
128  * the values then taken down.  So ideally GetSizeAndPosition() should be called after Show().
129  * @return rect which is keyboard panel x, y, width, height
130  */
131 DALI_ADAPTOR_API Dali::Rect<int> GetSizeAndPosition();
132
133 /**
134  * @brief Rotates the keyboard orientation to the given angle.
135  *
136  * A value of 0 indicates the portrait orientation.
137  * Other valid values are 90, 180, 270.
138  * @param angle the angle is in degrees.
139  */
140 DALI_ADAPTOR_API void RotateTo(int angle);
141
142 /**
143  * @brief Returns text direction of the keyboard's current input language.
144  * @return The direction of the text.
145  */
146 DALI_ADAPTOR_API TextDirection GetTextDirection();
147
148 } // namespace VirtualKeyboard
149
150 } // namespace Dali
151
152 #endif // DALI_VIRTUAL_KEYBOARD_H