Move Input Method enumerations to public API
[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) 2018 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/signals/dali-signal.h>
23 #include <dali/public-api/object/property-map.h>
24 #include <dali/public-api/math/rect.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/adaptor-framework/input-method.h>
28
29 namespace Dali
30 {
31
32 /**
33  * @brief This namespace is provided for application developers to be able to show and hide the on-screen keyboard.
34  *
35  * Key events are sent to the actor in focus. Focus is set through the actor Public API.
36  */
37 namespace VirtualKeyboard
38 {
39
40 // Types
41
42 typedef Signal< void () > VoidSignalType;
43 typedef Signal< void ( bool ) > StatusSignalType;
44 typedef Signal< void ( int ) > KeyboardResizedSignalType;
45 typedef Signal< void ( int ) > LanguageChangedSignalType;
46
47 // Enumerations
48
49 /**
50  * @brief The direction of text.
51  */
52 enum TextDirection
53 {
54   LeftToRight,
55   RightToLeft,
56 };
57
58 /**
59  * @brief The meaning of the return key.
60  */
61 enum ReturnKeyType
62 {
63   DEFAULT,
64   DONE,
65   GO,
66   JOIN,
67   LOGIN,
68   NEXT,
69   SEARCH,
70   SEND,
71   SIGNIN
72 };
73
74 // Functions
75 /**
76  * @brief Show the virtual keyboard.
77  */
78 DALI_IMPORT_API void Show();
79
80 /**
81  * @brief Hide the virtual keyboard.
82  */
83 DALI_IMPORT_API void Hide();
84
85 /**
86  * @brief Returns whether the virtual keyboard is visible or not.
87  * @return true if visible, false otherwise.
88  */
89 DALI_IMPORT_API bool IsVisible();
90
91 /**
92  * @brief Set one or more of the Input Method Settings
93  * @param[in] settingsMap Map of Settings to be applied.
94  */
95 DALI_IMPORT_API void ApplySettings( const Property::Map& settingsMap );
96
97 /**
98  * @brief Set the specific return key into the virtual keyboard.
99  * @param[in] type the kind of return key types.
100  */
101 DALI_IMPORT_API void SetReturnKeyType( const InputMethod::ButtonAction::Type type );
102
103 /**
104  * @brief Retrieve the current return key type.
105  * @return the type of retun key.
106  */
107 DALI_IMPORT_API InputMethod::ButtonAction::Type GetReturnKeyType();
108
109 /**
110  * @brief Enable/disable prediction (predictive text).
111  *
112  * By default prediction text is enabled.
113  * @param[in] enable true or false to enable or disable
114  * Prediction can not be changed while the keyboard is visible. It must be set in advance of showing keyboard.
115  */
116 DALI_IMPORT_API void EnablePrediction(const bool enable);
117
118 /**
119  * @brief Returns whether prediction is enabled in the virtual keyboard
120  * @return true if predictive text enabled, false otherwise.
121  */
122 DALI_IMPORT_API bool IsPredictionEnabled();
123
124 /**
125  * @brief Provides size and position of keyboard.
126  *
127  * Position is relative to whether keyboard is visible or not.
128  * If keyboard is not visible then position will be off the screen.
129  * If keyboard is not being shown when this method is called the keyboard is partially setup (IMFContext) to get
130  * the values then taken down.  So ideally GetSizeAndPosition() should be called after Show().
131  * @return rect which is keyboard panel x, y, width, height
132  */
133 DALI_IMPORT_API Dali::Rect<int> GetSizeAndPosition();
134
135 /**
136  * @brief Rotates the keyboard orientation to the given angle.
137  *
138  * A value of 0 indicates the portrait orientation.
139  * Other valid values are 90, 180, 270.
140  * @param angle the angle is in degrees.
141  */
142 DALI_IMPORT_API void RotateTo(int angle);
143
144 /**
145  * @brief Returns text direction of the keyboard's current input language.
146  * @return The direction of the text.
147  */
148 DALI_IMPORT_API TextDirection GetTextDirection();
149
150 /**
151  * @brief Connect to this signal to be notified when the virtual keyboard is shown or hidden.
152  *
153  * A callback of the following type may be connected:
154  * @code
155  *   void YourCallbackName(bool keyboardShown);
156  * @endcode
157  * If the parameter keyboardShown is true, then the keyboard has just shown, if it is false, then it
158  * has just been hidden.
159  * @return The signal to connect to.
160  */
161 DALI_IMPORT_API StatusSignalType& StatusChangedSignal();
162
163 /**
164  * @brief Connect to this signal to be notified when the virtual keyboard is resized.
165  *
166  * A callback of the following type may be connected:
167  * @code
168  *   void YourCallbackName( int resolvedResize );
169  * @endcode
170  * The parameter sends the resolved resize defined by the IMF.
171  *
172  * User can get changed size by using GetSizeAndPosition() in the callback
173  * @return The signal to connect to.
174  */
175 DALI_IMPORT_API KeyboardResizedSignalType& ResizedSignal();
176
177 /**
178  * @brief Connect to this signal to be notified when the virtual keyboard's language is changed.
179  *
180  * A callback of the following type may be connected:
181  * @code
182  *   void YourCallbackName( int resolvedLanguage );
183  * @endcode
184  * The parameter sends the resolved language defined by the IMF.
185  *
186  * User can get the text direction of the language by calling GetTextDirection() in the callback.
187  * @return The signal to connect to.
188  */
189 DALI_IMPORT_API LanguageChangedSignalType& LanguageChangedSignal();
190
191 } // namespace VirtualKeyboard
192
193 } // namespace Dali
194
195 #endif // __DALI_VIRTUAL_KEYBOARD_H__