Refactoring input mode indicator 03/86803/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 5 Sep 2016 04:20:55 +0000 (13:20 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 5 Sep 2016 04:45:09 +0000 (13:45 +0900)
Change-Id: I06b6585920876ca7763321392a114df7951fdea2
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
CMakeLists.txt
src/include/modeindicator.h [new file with mode: 0644]
src/ise.cpp
src/modeindicator.cpp [new file with mode: 0644]

index 09684c6..f19f159 100644 (file)
@@ -22,6 +22,7 @@ SET(ISE_SRCS
     src/ise-emoticon-list.cpp
     src/ise-emoticon-mode.cpp
     src/cbhm.cpp
+    src/modeindicator.cpp
 )
 
 SET(ISE_PACKAGE ${PROJECT_NAME})
diff --git a/src/include/modeindicator.h b/src/include/modeindicator.h
new file mode 100644 (file)
index 0000000..b4adff5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012 - 2016 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.
+ *
+ */
+#ifndef __MODE_INDICATOR_H__
+#define __MODE_INDICATOR_H__
+
+#include <Elementary.h>
+#include <scltypes.h>
+
+#ifdef _WEARABLE
+void create_indicator_window(sclint width, sclint height);
+void destroy_indicator_window(void);
+void show_indicator_window(void);
+void hide_indicator_window(void);
+
+void create_indicator_dots(int dot_num, int focus_dot);
+void destroy_indicator_dots(void);
+#endif
+
+#endif //__MODE_INDICATOR_H__
index 8b232f4..2ed42f3 100644 (file)
@@ -37,6 +37,7 @@
 #include "ise-stt-engine.h"
 #include "ise-stt-mode.h"
 #include "ise-stt-option.h"
+#include "modeindicator.h"
 #include <stt.h>
 
 #define CANDIDATE_WINDOW_HEIGHT 84
@@ -147,80 +148,6 @@ static sclboolean           _cm_popup_opened = FALSE;
 static const char          *_cm_key_list[CM_KEY_LIST_SIZE] = {USER_KEYSTRING_OPTION, USER_KEYSTRING_EMOTICON, USER_KEYSTRING_CLIPBOARD, USER_VOICE_LANGUAGE};
 static scluint              _current_cm_key_id = 0;
 
-#ifdef _WEARABLE
-#define MAX_DOTS_NUMBER     5
-
-static Evas_Object         *_indicator_win = NULL;
-static Evas_Object         *_indicator_dot[MAX_DOTS_NUMBER] = {NULL, NULL, NULL, NULL, NULL};
-static SclPoint             _dot_3[3] = {{157, 4}, {175, 3}, {193, 4}};
-static SclPoint             _dot_4[4] = {{148, 5}, {166, 3}, {184, 3}, {202, 5}};
-static SclPoint             _dot_5[5] = {{139, 6}, {157, 4}, {175, 3}, {193, 4}, {211, 6}};
-
-static Evas_Object* create_indicator_window(void)
-{
-    Evas_Object *win = elm_win_add(NULL, "IndicatorWindow", ELM_WIN_UTILITY);
-    if (win) {
-        elm_win_borderless_set(win, EINA_TRUE);
-        elm_win_title_set(win, "ISF Popup");
-        elm_win_prop_focus_skip_set(static_cast<Evas_Object*>(win), TRUE);
-    }
-
-    sclint width = 0;
-    sclint height = 0;
-    if (g_ui)
-        g_ui->get_screen_resolution(&width, &height);
-    LOGD("screen width:%d, height:%d\n", width, height);
-    evas_object_resize(win, width, 22);
-    evas_object_move(win, 0, 0);
-    return win;
-}
-
-static void create_indicator_dots(int dot_num)
-{
-    LOGD("dots number:%d\n", dot_num);
-    SclPoint *dots = NULL;
-
-    if (dot_num == 3) {
-        dots = _dot_3;
-    } else if (dot_num == 4) {
-        dots = _dot_4;
-    } else {
-        dots = _dot_5;
-    }
-
-    for (int i = 0; i < dot_num; i++) {
-        if (_indicator_dot[i])
-            evas_object_del(_indicator_dot[i]);
-
-        _indicator_dot[i] = evas_object_image_add(evas_object_evas_get(_indicator_win));
-        evas_object_image_file_set(_indicator_dot[i], LAYOUTDIR"/wearable/image/indicator_horizontal_dot.png", NULL);
-        evas_object_image_filled_set(_indicator_dot[i], EINA_TRUE);
-        evas_object_image_alpha_set(_indicator_dot[i], EINA_TRUE);
-        evas_object_resize(_indicator_dot[i], 10, 10);
-        evas_object_move(_indicator_dot[i], dots[i].x, dots[i].y);
-        evas_object_show(_indicator_dot[i]);
-    }
-}
-
-static void destroy_indicator_dots(void)
-{
-    for (int i = 0; i < MAX_DOTS_NUMBER; i++) {
-        if (_indicator_dot[i])
-            evas_object_del(_indicator_dot[i]);
-        _indicator_dot[i] = NULL;
-    }
-}
-
-static void destroy_indicator_window(void)
-{
-    destroy_indicator_dots();
-    if (_indicator_win) {
-        evas_object_del(_indicator_win);
-        _indicator_win = NULL;
-    }
-}
-#endif
-
 /*
  * This callback class will receive all response events from SCL
  * So you should perform desired tasks in this class.
@@ -1427,11 +1354,13 @@ ise_show(int ic)
     }
 
     if (dot_num > 0) {
-        if (_indicator_win == NULL) {
-            _indicator_win = create_indicator_window();
-        }
+        sclint width = 0;
+        sclint height = 0;
+        if (g_ui)
+            g_ui->get_screen_resolution(&width, &height);
+
+        create_indicator_window(width, height);
         destroy_indicator_dots();
-        create_indicator_dots(dot_num);
 
         int focus_dot = 0;
         switch (g_keyboard_state.layout) {
@@ -1451,12 +1380,10 @@ ise_show(int ic)
                 break;
         }
 
-        evas_object_image_file_set(_indicator_dot[focus_dot], LAYOUTDIR"/wearable/image/indicator_horizontal_focus_dot.png", NULL);
-
-        //evas_object_raise(_indicator_win);
-        evas_object_show(_indicator_win);
+        create_indicator_dots(dot_num, focus_dot);
+        show_indicator_window();
     } else {
-        evas_object_hide(_indicator_win);
+        hide_indicator_window();
     }
 #endif
 }
@@ -1514,8 +1441,7 @@ ise_hide()
     }
 
 #ifdef _WEARABLE
-    if (_indicator_win)
-        evas_object_hide(_indicator_win);
+    hide_indicator_window();
 #endif
 }
 
diff --git a/src/modeindicator.cpp b/src/modeindicator.cpp
new file mode 100644 (file)
index 0000000..5b59520
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2012 - 2016 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 <Elementary.h>
+#include <scltypes.h>
+#include <dlog.h>
+
+using namespace scl;
+
+#ifdef _WEARABLE
+#define MAX_DOTS_NUMBER     5
+
+static Evas_Object         *_indicator_win = NULL;
+static Evas_Object         *_indicator_dot[MAX_DOTS_NUMBER] = {NULL, NULL, NULL, NULL, NULL};
+static SclPoint             _dot_3[3] = {{157, 4}, {175, 3}, {193, 4}};
+static SclPoint             _dot_4[4] = {{148, 5}, {166, 3}, {184, 3}, {202, 5}};
+static SclPoint             _dot_5[5] = {{139, 6}, {157, 4}, {175, 3}, {193, 4}, {211, 6}};
+
+void create_indicator_window(sclint width, sclint height)
+{
+    if (_indicator_win)
+        return;
+
+    Evas_Object *win = elm_win_add(NULL, "IndicatorWindow", ELM_WIN_UTILITY);
+    if (win) {
+        elm_win_borderless_set(win, EINA_TRUE);
+        elm_win_title_set(win, "ISF Popup");
+        elm_win_prop_focus_skip_set(static_cast<Evas_Object*>(win), EINA_TRUE);
+    }
+
+    LOGD("screen width : %d, height : %d\n", width, height);
+    evas_object_resize(win, width, 22);
+    evas_object_move(win, 0, 0);
+
+    _indicator_win = win;
+}
+
+void create_indicator_dots(int dot_num, int focus_dot)
+{
+    LOGD("dots number : %d\n", dot_num);
+    SclPoint *dots = NULL;
+
+    if (dot_num == 3) {
+        dots = _dot_3;
+    } else if (dot_num == 4) {
+        dots = _dot_4;
+    } else {
+        dots = _dot_5;
+    }
+
+    for (int i = 0; i < dot_num; i++) {
+        if (_indicator_dot[i])
+            evas_object_del(_indicator_dot[i]);
+
+        _indicator_dot[i] = evas_object_image_add(evas_object_evas_get(_indicator_win));
+        evas_object_image_file_set(_indicator_dot[i], LAYOUTDIR"/wearable/image/indicator_horizontal_dot.png", NULL);
+        evas_object_image_filled_set(_indicator_dot[i], EINA_TRUE);
+        evas_object_image_alpha_set(_indicator_dot[i], EINA_TRUE);
+        evas_object_resize(_indicator_dot[i], 10, 10);
+        evas_object_move(_indicator_dot[i], dots[i].x, dots[i].y);
+        evas_object_show(_indicator_dot[i]);
+    }
+
+    evas_object_image_file_set(_indicator_dot[focus_dot], LAYOUTDIR"/wearable/image/indicator_horizontal_focus_dot.png", NULL);
+}
+
+void destroy_indicator_dots(void)
+{
+    for (int i = 0; i < MAX_DOTS_NUMBER; i++) {
+        if (_indicator_dot[i])
+            evas_object_del(_indicator_dot[i]);
+        _indicator_dot[i] = NULL;
+    }
+}
+
+void destroy_indicator_window(void)
+{
+    destroy_indicator_dots();
+    if (_indicator_win) {
+        evas_object_del(_indicator_win);
+        _indicator_win = NULL;
+    }
+}
+
+void show_indicator_window(void)
+{
+    if (_indicator_win)
+        evas_object_show(_indicator_win);
+}
+
+void hide_indicator_window(void)
+{
+    if (_indicator_win)
+        evas_object_hide(_indicator_win);
+}
+#endif
+