2 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include "ise-tutorial-mode.h"
21 #include <inputmethod.h>
23 #define LOG_TAG "ISE_DEFAULT"
27 #define OVERLAY_TITLE_WIDTH 190
28 #define OVERLAY_TITLE_HEIGHT 100
30 #define OVERLAY_CONTENT_WIDTH 294
31 #define OVERLAY_CONTENT_HEIGHT 111
33 #define GUIDE_TITLE_TEXT_FONT_DEFAULT_SIZE 36
34 #define GUIDE_TITLE_TEXT_FONT_MIN_SIZE 20
36 #define GUIDE_MAIN_TEXT_FONT_DEFAULT_SIZE 28
37 #define GUIDE_MAIN_TEXT_FONT_MIN_SIZE 10
39 #define BUTTON_WIDTH 56
40 #define BUTTON_HEIGHT 56
41 #define BUTTON_PADDING_X 152
42 #define BUTTON_PADDING_Y 289
43 #define BASE_WIDTH 360
44 #define BASE_HEIGHT 360
46 #define DEFAULT_FORMAT_GUIDE_TITLE_TEXT "DEFAULT='font=Tizen:style=Regular font_size=%d align=center color=#ffffff text_class=tizen wrap=mixed'"
47 #define DEFAULT_FORMAT_GUIDE_MAIN_TEXT "DEFAULT='font=Tizen:style=Large font_size=%d align=center color=#ffffff text_class=tizen wrap=mixed' newline='br'"
49 #define TUTORIAL_TITLE dgettext(PACKAGE, "IDS_IME_BODY_USING_KEYBOARD_ABB")
50 #define TUTORIAL_CONTEXT_1 dgettext(PACKAGE, "IDS_TTRL_BODY_TURN_THE_BEZEL_CLOCKWISE_TO_VIEW_NUMBERS_AND_MORE_ABB")
51 #define TUTORIAL_CONTEXT_2 dgettext(PACKAGE, "IDS_TTRL_BODY_TURN_THE_BEZEL_ANTICLOCKWISE_TO_GET_STARTED_ABB")
53 static Evas_Object *main_window = NULL;
54 static Evas_Object *tutorial_window = NULL;
55 static Evas_Object *image_ob = NULL;
56 static Evas_Object *rotate = NULL;
57 static Evas_Object *button = NULL;
58 static Ecore_Timer *tutorial_window_create_timer = NULL;
59 static Ecore_Timer *tutorial_window_destory_timer = NULL;
61 static int SCREEN_WIDTH, SCREEN_HEIGHT;
62 static bool is_tutorial_show = false;
64 static sclu32 _context_layout = 0;
66 static Eina_Bool ise_destroy_tutorial_mode_cb(void *data);
67 static Eina_Bool tutorial_show_layout_cb(void *data);
69 #define EDJ_FILE_PATH RESDIR"/edje/wearable/tutorial_popup.edj"
70 #define IMG_POPUP_FC_BG LAYOUTDIR"/wearable/image/tutorial/gear_tutorial_bg.png"
71 #define IMG_POPUP_TUTORIAL_CW LAYOUTDIR"/wearable/image/tutorial/gear_tutorial_rotate_cw.png"
72 #define IMG_POPUP_TUTORIAL_CCW LAYOUTDIR"/wearable/image/tutorial/gear_tutorial_rotate_ccw.png"
73 #define IMG_POPUP_BUTTON_OK_NORMAL LAYOUTDIR"/wearable/image/tutorial/gear_tutorial_att_ok_normal.png"
74 #define IMG_POPUP_BUTTON_OK_PRESS LAYOUTDIR"/wearable/image/tutorial/gear_tutorial_att_ok_press.png"
75 #define IMG_POPUP_BUTTON_CANCEL_NORMAL LAYOUTDIR"/wearable/image/tutorial/gear_tutorial_bt_cancel_normal.png"
76 #define IMG_POPUP_BUTTON_CANCEL_PRESS LAYOUTDIR"/wearable/image/tutorial/gear_tutorial_bt_cancel_press.png"
78 void view_set_image(Evas_Object *parent, const char *part_name, const char *image_path)
80 Evas_Object *image = NULL;
85 image = elm_object_part_content_get(parent, part_name);
87 image = elm_image_add(parent);
91 elm_object_part_content_set(parent, part_name, image);
93 if (EINA_FALSE == elm_image_file_set(image, image_path, NULL)) {
96 evas_object_show(image);
100 static void guide_popup_bt_close_cb(void *user_data, Evas *e, Evas_Object *obj, void *event_info)
102 view_set_image(button, NULL, IMG_POPUP_BUTTON_CANCEL_PRESS);
103 if (tutorial_window_destory_timer == NULL)
104 tutorial_window_destory_timer = ecore_timer_add(0.5,
105 ise_destroy_tutorial_mode_cb,
109 void ise_show_tutorial_mode_popup(int type)
111 _context_layout = type;
112 main_window = ime_get_main_window();
113 elm_win_screen_size_get(main_window, NULL, NULL, &SCREEN_WIDTH, &SCREEN_HEIGHT);
114 ise_destroy_tutorial_mode_popup();
116 if (tutorial_window_create_timer == NULL)
117 tutorial_window_create_timer = ecore_timer_add(0,
118 tutorial_show_layout_cb,
122 static Eina_Bool ise_destroy_tutorial_mode_cb(void *data)
124 ise_destroy_tutorial_mode_popup();
125 return ECORE_CALLBACK_CANCEL;
128 static Eina_Bool tutorial_show_layout_cb(void *data)
130 if (!tutorial_window) {
131 tutorial_window = elm_win_add(main_window, NULL,
133 elm_win_borderless_set(tutorial_window, EINA_TRUE);
134 elm_win_alpha_set(tutorial_window, EINA_TRUE);
135 elm_win_title_set(tutorial_window, "ISF Popup");
137 elm_win_aux_hint_add(tutorial_window, "wm.policy.win.rot.dependent", "1");
140 elm_win_prop_focus_skip_set(tutorial_window, EINA_TRUE);
142 evas_object_resize(tutorial_window, SCREEN_WIDTH, SCREEN_HEIGHT);
143 evas_object_move(tutorial_window, 0, 0);
144 evas_object_show(tutorial_window);
145 elm_win_raise(tutorial_window);
147 image_ob = evas_object_image_add(evas_object_evas_get(tutorial_window));
148 evas_object_image_file_set(image_ob, IMG_POPUP_FC_BG, NULL);
149 evas_object_image_border_set(image_ob, 0, 0, 0, 0);
150 Evas_Load_Error err_image = evas_object_image_load_error_get(image_ob);
151 if (err_image != EVAS_LOAD_ERROR_NONE) {
152 LOGD("Could not load image, error string is \"%s\"", evas_load_error_str(err_image));
154 evas_object_image_fill_set(image_ob, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
155 evas_object_resize(image_ob, SCREEN_WIDTH, SCREEN_HEIGHT);
156 evas_object_move(image_ob, 0, 0);
157 evas_object_layer_set(image_ob, EVAS_LAYER_MAX);
158 evas_object_show(image_ob);
161 rotate = evas_object_image_add(evas_object_evas_get(tutorial_window));
162 if (_context_layout == ISE_LAYOUT_STYLE_NORMAL) {
163 evas_object_image_file_set(rotate, IMG_POPUP_TUTORIAL_CW, NULL);
164 } else if (_context_layout == ISE_LAYOUT_STYLE_NUMBER) {
165 evas_object_image_file_set(rotate, IMG_POPUP_TUTORIAL_CCW, NULL);
167 evas_object_image_border_set(rotate, 0, 0, 0, 0);
169 Evas_Load_Error err_rotate = evas_object_image_load_error_get(rotate);
170 if (err_rotate != EVAS_LOAD_ERROR_NONE) {
171 LOGD("Could not load image, error string is \"%s\"", evas_load_error_str(err_rotate));
173 evas_object_image_fill_set(rotate, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 2);
174 evas_object_resize(rotate, SCREEN_WIDTH, SCREEN_HEIGHT / 2);
175 evas_object_move(rotate, 0, 0);
176 evas_object_layer_set(rotate, EVAS_LAYER_MAX);
177 evas_object_show(rotate);
180 Evas_Object *context = edje_object_add(evas_object_evas_get(tutorial_window));
181 evas_object_layer_set(context, EVAS_LAYER_MAX);
182 edje_object_file_set(context, EDJ_FILE_PATH, "main");
183 evas_object_resize(context, SCREEN_WIDTH, SCREEN_HEIGHT);
184 evas_object_move(context, 0, 0);
186 if (_context_layout == ISE_LAYOUT_STYLE_NORMAL) {
187 edje_object_part_text_set(context, "title", TUTORIAL_TITLE);
188 edje_object_part_text_set(context, "context1", TUTORIAL_CONTEXT_1);
190 button = elm_button_add(tutorial_window);
191 elm_object_style_set(button, "focus");
192 view_set_image(button, NULL, IMG_POPUP_BUTTON_CANCEL_NORMAL);
193 evas_object_resize(button, BUTTON_WIDTH*SCREEN_WIDTH/BASE_WIDTH, BUTTON_HEIGHT*SCREEN_HEIGHT/BASE_HEIGHT);
194 evas_object_move(button, BUTTON_PADDING_X*SCREEN_WIDTH/BASE_WIDTH, BUTTON_PADDING_Y*SCREEN_HEIGHT/BASE_HEIGHT);
195 evas_object_layer_set(button, EVAS_LAYER_MAX);
196 evas_object_show(button);
198 evas_object_event_callback_add(button, EVAS_CALLBACK_MOUSE_DOWN, guide_popup_bt_close_cb, NULL);
199 } else if (_context_layout == ISE_LAYOUT_STYLE_NUMBER) {
200 edje_object_part_text_set(context, "context2", TUTORIAL_CONTEXT_2);
202 evas_object_show(context);
204 is_tutorial_show = true;
206 return ECORE_CALLBACK_CANCEL;
209 void ise_destroy_tutorial_mode_popup()
211 if (tutorial_window) {
212 evas_object_del(tutorial_window);
213 tutorial_window = NULL;
217 evas_object_del(image_ob);
222 evas_object_del(rotate);
226 if (tutorial_window_create_timer) {
227 ecore_timer_del(tutorial_window_create_timer);
228 tutorial_window_create_timer = NULL;
231 if (tutorial_window_destory_timer) {
232 ecore_timer_del(tutorial_window_destory_timer);
233 tutorial_window_destory_timer = NULL;
236 is_tutorial_show = false;
239 bool check_is_tutorial_show()
241 return is_tutorial_show;