1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
/*
* Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "ise-language-change.h"
#include "ise.h"
#include <dlog.h>
#include <inputmethod.h>
#undef LOG_TAG
#define LOG_TAG "ISE_DEFAULT"
#define USE_EFL
static short int space_popup_width = NOT_USED;
static short int space_popup_height = NOT_USED;
static short int scroller_area_width = NOT_USED;
static short int scroller_area_height = NOT_USED;
static short int scroller_x = NOT_USED;
static short int scroller_y = NOT_USED;
static short int space_popup_width_padding = NOT_USED;
static short int arrow_image_width = NOT_USED;
static short int arrow_image_height = NOT_USED;
static short int arrow_image_x_padding = NOT_USED;
static short int arrow_image_y_padding = NOT_USED;
#ifdef _WEARABLE
#include <sclutils.h>
static short int space_image_width = NOT_USED;
static short int space_image_height = NOT_USED;
#endif
#ifdef _WEARABLE
#define IMG_ARROW_LEFT LAYOUTDIR"/wearable/image/button/B09_btn_arrow_left.png"
#define IMG_ARROW_RIGHT LAYOUTDIR"/wearable/image/button/B09_btn_arrow_right.png"
#define IMG_POPUP_FC_BG LAYOUTDIR"/wearable/image/button/language_change_popup_bg.png"
#define IMG_SPACE_POPUP_FC_PRESS LAYOUTDIR"/wearable/image/button/B09_icon_space_popup_fc_press.png"
#define EDJ_FILE RESDIR"/edje/wearable/popup_custom.edj"
#define SPACE_SIZE_HEIGHT 111
#define SPACE_SIZE_WIDTH 194
#define SPACE_PADDING_X 10
#define SPACE_PADDING_Y 10
#define SPACE_KEY_HEIGHT 60
#else
#define IMG_ARROW_LEFT LAYOUTDIR "/" PROFILE_NAME"/image/button/btn_arrow_s_left.png"
#define IMG_ARROW_RIGHT LAYOUTDIR "/" PROFILE_NAME"/image/button/btn_arrow_s_right.png"
#define IMG_POPUP_FC_BG LAYOUTDIR "/" PROFILE_NAME"/image/button/language_change_popup_bg.png"
#define EDJ_FILE RESDIR "/edje/" PROFILE_NAME"/popup_custom.edj"
#endif
static short int lang_popup_x = NOT_USED;
static short int lang_popup_y = NOT_USED;
static short int old_ev_x = NOT_USED;
static short int old_ev_y = NOT_USED;
static int scroller_region_x = NOT_USED;
static int cw = NOT_USED;
bool lang_popup_on = false;
static Ecore_Event_Handler *_lang_popup_mouse_move_handler = NULL;
static Evas_Object *win = NULL;
static Evas_Object *image_ob = NULL;
#ifdef _WEARABLE
static Evas_Object *img_space = NULL;
#endif
static Evas_Object *scroller = NULL;
static Evas_Object *img_arrow_left = NULL;
static Evas_Object *img_arrow_right = NULL;
static ISELanguageManager _language_manager;
static Eina_Bool __ise_space_flick_lang_popup_move_cb(void *data, int type, void *event_info);
static void __ise_init_space_flick_lang_change_popup_variables(short int space_button_x, short int space_button_y, short int space_button_width, short int space_button_height);
void ise_show_space_flick_language_change_popup(short int space_button_x, short int space_button_y, short int space_button_width, short int space_button_height)
{
#ifdef _WEARABLE
int space_button_width_tmp, space_button_height_tmp;
CSCLUI *ui = get_ui();
space_button_width_tmp = ui->get_scaled_x(SPACE_SIZE_WIDTH);
space_button_height_tmp = ui->get_scaled_y(SPACE_SIZE_HEIGHT);
space_button_x = ui->get_scaled_x(space_button_x + space_button_width) - space_button_width_tmp + ui->get_scaled_x(SPACE_PADDING_X);
space_button_y = ui->get_scaled_y(space_button_y + space_button_height) - space_button_height_tmp + ui->get_scaled_y(SPACE_PADDING_Y + SPACE_KEY_HEIGHT);
space_button_width = space_button_width_tmp;
space_button_height = space_button_height_tmp;
#endif
std::string left_text = "left";
std::string center_text = "center";
std::string right_text = "right";
if (lang_popup_on)
return;
scluint num = _language_manager.get_enabled_languages_num();
#ifdef _WEARABLE
if (num <= 1) {
return;
} else {
left_text = _language_manager.get_current_language();
center_text = _language_manager.get_next_language();
}
#else
if (num <= 1) {
return;
} else if (num == 2) {
left_text = _language_manager.get_next_language();
if (!left_text.empty()) {
right_text = left_text;
} else {
right_text = _language_manager.get_previous_language();
if (!right_text.empty()) {
left_text = right_text;
}
}
center_text = _language_manager.get_current_language();
} else {
left_text = _language_manager.get_next_language();
center_text = _language_manager.get_current_language();
right_text = _language_manager.get_previous_language();
}
#endif
__ise_init_space_flick_lang_change_popup_variables(space_button_x, space_button_y, space_button_width, space_button_height);
int xPos = lang_popup_x;
int yPos = lang_popup_y;
win = elm_bg_add(NATIVE_WINDOW_CAST(ime_get_main_window()));
image_ob = evas_object_image_add(evas_object_evas_get(win));
evas_object_image_file_set(image_ob, IMG_POPUP_FC_BG, NULL);
evas_object_image_border_set(image_ob, 1, 1, 1, 1);
Evas_Load_Error err = evas_object_image_load_error_get(image_ob);
if (err != EVAS_LOAD_ERROR_NONE) {
LOGD("Could not load image, error string is \"%s\"", evas_load_error_str(err));
} else {
evas_object_image_fill_set(image_ob, 0, 0, space_popup_width, space_popup_height);
evas_object_resize(image_ob, space_popup_width, space_popup_height);
evas_object_move(image_ob, xPos, yPos);
#ifdef _WEARABLE
evas_object_layer_set(image_ob, EVAS_LAYER_MAX);
#endif
evas_object_show(image_ob);
}
#ifdef _WEARABLE
#else
evas_object_color_set(win, 255, 255, 255, 255);
#endif
evas_object_resize(win, space_popup_width, space_popup_height);
evas_object_move(win, xPos, yPos);
#ifdef _WEARABLE
#else
evas_object_layer_set(win, EVAS_LAYER_MAX);
#endif
evas_object_show(win);
#ifdef _WEARABLE
img_space = evas_object_image_add(evas_object_evas_get(win));
evas_object_image_file_set(img_space, IMG_SPACE_POPUP_FC_PRESS, NULL);
evas_object_image_fill_set(img_space, 0, 0, space_image_width, space_image_height);
evas_object_resize(img_space, space_image_width, space_image_height);
evas_object_move(img_space, xPos + (space_button_width - space_image_width) / 2, yPos + (space_button_height / 2 - space_image_height) / 2 + space_button_height / 2);
evas_object_layer_set(img_space, EVAS_LAYER_MAX);
evas_object_show(img_space);
#endif
img_arrow_left = evas_object_image_add(evas_object_evas_get(win));
evas_object_image_file_set(img_arrow_left, IMG_ARROW_LEFT, NULL);
evas_object_image_fill_set(img_arrow_left, 0, 0, arrow_image_width, arrow_image_height);
evas_object_resize(img_arrow_left, arrow_image_width, arrow_image_height);
evas_object_move(img_arrow_left, xPos + arrow_image_x_padding, yPos + scroller_y);
evas_object_layer_set(img_arrow_left, EVAS_LAYER_MAX);
img_arrow_right = evas_object_image_add(evas_object_evas_get(win));
evas_object_image_file_set(img_arrow_right, IMG_ARROW_RIGHT, NULL);
evas_object_image_fill_set(img_arrow_right, 0, 0, arrow_image_width, arrow_image_height);
evas_object_resize(img_arrow_right, arrow_image_width, arrow_image_height);
evas_object_move(img_arrow_right, xPos + space_popup_width - (arrow_image_width + arrow_image_x_padding), yPos + scroller_y);
evas_object_layer_set(img_arrow_right, EVAS_LAYER_MAX);
cw = -1;
Evas_Object* _table = elm_table_add(win);
evas_object_size_hint_weight_set(_table, 0.0, 0.0);
evas_object_size_hint_align_set(_table, 0.0, 0.0);
elm_table_padding_set(_table, 0, 0);
evas_object_layer_set(_table, EVAS_LAYER_MAX);
scroller = elm_scroller_add(win);
elm_object_content_set(scroller, _table);
evas_object_resize(scroller, scroller_area_width, scroller_area_height);
evas_object_move(scroller, xPos + scroller_x, yPos);
elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
elm_scroller_propagate_events_set(scroller, EINA_TRUE);
elm_scroller_page_relative_set(scroller, 0, 0);
evas_object_layer_set(scroller, EVAS_LAYER_MAX);
Evas_Object *label1 = edje_object_add(evas_object_evas_get(win));
evas_object_show(label1);
evas_object_layer_set(label1, EVAS_LAYER_MAX);
edje_object_file_set(label1, EDJ_FILE, "language_label");
edje_object_part_text_set(label1, "language_name", left_text.c_str());
evas_object_size_hint_min_set(label1, scroller_area_width, scroller_area_height);
elm_table_pack(_table, label1, 0, 0, scroller_area_width, scroller_area_height);
Evas_Object *label2 = edje_object_add(evas_object_evas_get(win));
evas_object_show(label2);
evas_object_layer_set(label2, EVAS_LAYER_MAX);
edje_object_file_set(label2, EDJ_FILE, "language_label");
edje_object_part_text_set(label2, "language_name", center_text.c_str());
evas_object_size_hint_min_set(label2, scroller_area_width, scroller_area_height);
elm_table_pack(_table, label2, scroller_area_width, 0, scroller_area_width, scroller_area_height);
#ifdef _WEARABLE
#else
Evas_Object *label3 = edje_object_add(evas_object_evas_get(win));
evas_object_show(label3);
evas_object_layer_set(label3, EVAS_LAYER_MAX);
edje_object_file_set(label3, EDJ_FILE, "language_label");
edje_object_part_text_set(label3, "language_name", right_text.c_str());
evas_object_size_hint_min_set(label3, scroller_area_width, scroller_area_height);
elm_table_pack(_table, label3, scroller_area_width * 2, 0, scroller_area_width, scroller_area_height);
#endif
evas_object_show(img_arrow_left);
evas_object_show(img_arrow_right);
evas_object_show(_table);
evas_object_show(scroller);
elm_scroller_child_size_get(scroller, &cw, NULL);
elm_scroller_region_show(scroller, cw, 0, scroller_area_width, 0);
_lang_popup_mouse_move_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, __ise_space_flick_lang_popup_move_cb, NULL);
lang_popup_on = true;
}
void ise_destroy_space_flick_language_change_popup(void)
{
if (!lang_popup_on)
return;
elm_scroller_page_size_set(scroller, cw, 0);
if (win) {
evas_object_del(win);
win = NULL;
}
#ifdef _WEARABLE
if (image_ob) {
evas_object_del(image_ob);
image_ob = NULL;
}
if (img_space) {
evas_object_del(img_space);
img_space = NULL;
}
#endif
if (img_arrow_left) {
evas_object_del(img_arrow_left);
img_arrow_left = NULL;
}
if (img_arrow_right) {
evas_object_del(img_arrow_right);
img_arrow_right = NULL;
}
if (_lang_popup_mouse_move_handler) {
ecore_event_handler_del(_lang_popup_mouse_move_handler);
_lang_popup_mouse_move_handler = NULL;
}
scroller = NULL;
lang_popup_on = false;
scroller_region_x = -1;
old_ev_x = NOT_USED;
old_ev_y = NOT_USED;
}
static void __ise_init_space_flick_lang_change_popup_variables(short int space_button_x, short int space_button_y, short int space_button_width, short int space_button_height)
{
space_popup_width = space_button_width;
space_popup_height = space_button_height;
arrow_image_width = space_popup_width / 15;
arrow_image_height = space_popup_width / 15;
arrow_image_x_padding = space_popup_width / 20;
arrow_image_y_padding = space_popup_height / 10;
#ifdef _WEARABLE
space_image_width = arrow_image_width * 12;
space_image_height = space_popup_height / 4;
#endif
scroller_x = (arrow_image_width + arrow_image_x_padding);
scroller_y = (space_popup_height - arrow_image_height) / 2;
space_popup_width_padding = scroller_x * 2;
scroller_area_width = space_popup_width - space_popup_width_padding;
scroller_area_height = space_popup_height;
lang_popup_x = space_button_x - (space_popup_width - space_button_width) / 2;
lang_popup_y = (space_button_y - space_popup_height - arrow_image_y_padding);
}
static Eina_Bool __ise_space_flick_lang_popup_move_cb(void *data, int type, void *event_info)
{
Ecore_Event_Mouse_Move *ev = (Ecore_Event_Mouse_Move *)event_info;
if (old_ev_x == NOT_USED && old_ev_y == NOT_USED) {
old_ev_x = ev->x;
old_ev_y = ev->y;
}
elm_scroller_region_get(scroller, &scroller_region_x, NULL, NULL, NULL);
elm_scroller_region_show(scroller, scroller_region_x + (old_ev_x - ev->x)*3, 0, scroller_area_width, 0);
old_ev_x = ev->x;
old_ev_y = ev->y;
return ECORE_CALLBACK_PASS_ON;
}
|