Merge branch 'tizen_6.0' into tizen
[platform/core/uifw/ise-default.git] / src / ise-floating-mode.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "ise-floating-mode.h"
18 #include "ise.h"
19 #include <inputmethod.h>
20 #include <dlog.h>
21 #undef LOG_TAG
22 #define LOG_TAG "ISE_DEFAULT"
23
24 #define IMG_MOVE_HANDLER_BG            RESDIR "/" PROFILE_NAME"/images/move_handler_bg.png"
25 #define IMG_MOVE_HANDLER_CENTER        RESDIR "/" PROFILE_NAME"/images/move_handler_center.png"
26 #define IMG_MOVE_HANDLER_RIGHT         RESDIR "/" PROFILE_NAME"/images/move_handler_hand.png"
27 #define MOVE_HANDLER_CENTER_WIDTH      48
28 #define MOVE_HANDLER_CENTER_RIGHT      70
29
30 static Evas_Object* move_handler_bg = NULL;
31 static Evas_Object* move_handler_center = NULL;
32 static Evas_Object* move_handler_right = NULL;
33
34 void ise_show_move_handler(short int screen_w, short int screen_h)
35 {
36     move_handler_bg = evas_object_image_add(evas_object_evas_get(NATIVE_WINDOW_CAST(ime_get_main_window())));
37     LOGI("path : %s", IMG_MOVE_HANDLER_BG);
38     evas_object_image_file_set(move_handler_bg, IMG_MOVE_HANDLER_BG, NULL);
39     Evas_Load_Error err = evas_object_image_load_error_get(move_handler_bg);
40     if (err != EVAS_LOAD_ERROR_NONE) {
41         LOGD("Could not load image, error string is \"%s\"", evas_load_error_str(err));
42     } else {
43         evas_object_image_fill_set(move_handler_bg, 0, 0, screen_w, screen_h);
44         evas_object_resize(move_handler_bg, screen_w, screen_h);
45         evas_object_show(move_handler_bg);
46     }
47
48     move_handler_center = evas_object_image_add(evas_object_evas_get(NATIVE_WINDOW_CAST(ime_get_main_window())));
49     evas_object_image_file_set(move_handler_center, IMG_MOVE_HANDLER_CENTER, NULL);
50     err = evas_object_image_load_error_get(move_handler_center);
51     if (err != EVAS_LOAD_ERROR_NONE) {
52         LOGD("Could not load image, error string is \"%s\"", evas_load_error_str(err));
53     } else {
54         evas_object_image_fill_set(move_handler_center, 0, 0, MOVE_HANDLER_CENTER_WIDTH, screen_h);
55         evas_object_resize(move_handler_center, MOVE_HANDLER_CENTER_WIDTH, screen_h);
56         evas_object_move(move_handler_center, (screen_w / 2) - (MOVE_HANDLER_CENTER_WIDTH / 2), 0);
57         evas_object_show(move_handler_center);
58     }
59
60     move_handler_right = evas_object_image_add(evas_object_evas_get(NATIVE_WINDOW_CAST(ime_get_main_window())));
61     evas_object_image_file_set(move_handler_right, IMG_MOVE_HANDLER_RIGHT, NULL);
62     err = evas_object_image_load_error_get(move_handler_right);
63     if (err != EVAS_LOAD_ERROR_NONE) {
64         LOGD("Could not load image, error string is \"%s\"", evas_load_error_str(err));
65     } else {
66         evas_object_image_fill_set(move_handler_right, 0, 0, MOVE_HANDLER_CENTER_RIGHT, screen_h);
67         evas_object_resize(move_handler_right, MOVE_HANDLER_CENTER_RIGHT, screen_h);
68         evas_object_move(move_handler_right, screen_w - MOVE_HANDLER_CENTER_RIGHT, 0);
69         evas_object_show(move_handler_right);
70     }
71 }
72
73 void ise_destroy_move_handler(void)
74 {
75     if (move_handler_bg) {
76         evas_object_del(move_handler_bg);
77         move_handler_bg = NULL;
78     }
79
80     if (move_handler_center) {
81         evas_object_del(move_handler_center);
82         move_handler_center = NULL;
83     }
84
85     if (move_handler_right) {
86         evas_object_del(move_handler_right);
87         move_handler_right = NULL;
88     }
89 }