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