Fix emoticon layout issue 62/249362/4
authorJihoon Kim <jihoon48.kim@samsung.com>
Thu, 10 Dec 2020 11:33:52 +0000 (20:33 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 11 Dec 2020 05:23:58 +0000 (14:23 +0900)
Change-Id: Id5424f5b32db3cd369d86b34799932a25a71b969
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/ise-emoticon-mode.cpp

index 8d97293..6bd5017 100644 (file)
 #define EMOTICON_ICON_GAP_WIDTH_PORT 10
 #define EMOTICON_ICON_GAP_HEIGHT_PORT 2
 #endif
+
 #define EMOTICON_WIDTH_PORT (EMOTICON_ICON_WIDTH_PORT + EMOTICON_ICON_GAP_WIDTH_PORT)
 #define EMOTICON_HEIGHT_PORT (EMOTICON_ICON_HEIGHT_PORT + EMOTICON_ICON_GAP_HEIGHT_PORT)
 
 #define EMOTICON_ICON_WIDTH_LAND 27
 #define EMOTICON_ICON_HEIGHT_LAND 27
 
+#ifdef _COMMON
+#define EMOTICON_ICON_GAP_WIDTH_LAND 16
+#define EMOTICON_ICON_GAP_HEIGHT_LAND 16
+#else
 #define EMOTICON_ICON_GAP_WIDTH_LAND 4
 #define EMOTICON_ICON_GAP_HEIGHT_LAND 0
+#endif
 
 #define EMOTICON_WIDTH_LAND (EMOTICON_ICON_WIDTH_LAND + EMOTICON_ICON_GAP_WIDTH_LAND)
 #define EMOTICON_HEIGHT_LAND (EMOTICON_ICON_HEIGHT_LAND + EMOTICON_ICON_GAP_HEIGHT_LAND)
@@ -171,6 +177,26 @@ static Eina_Bool _focus_done(void *data);
 static void _multi_down(void *data, Evas *e, Evas_Object *o, void *event_info);
 static void _multi_up(void *data, Evas *e, Evas_Object *o, void *event_info);
 
+static bool get_landscape_device(int degree)
+{
+    sclint width = 0;
+    sclint height = 0;
+    bool landscape_device = false;
+
+    g_ui->get_screen_resolution(&width, &height);
+
+    if (degree == 0 || degree == 180) {
+        if (width > height)
+            landscape_device = true;
+    }
+    else {
+        if (width < height)
+            landscape_device = true;
+    }
+
+    return landscape_device;
+}
+
 void ise_read_recent_emoticon_list_from_scim(void)
 {
     LOGD("Enter\n");
@@ -241,28 +267,47 @@ void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_
     else
         evas_object_move(layout, 0, y);
 
+    bool landscape_device = get_landscape_device(screen_degree);
+
     if (is_candidate_on) {
-        if (screen_degree == 0 || screen_degree == 180)
-            elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH, EMOTICON_EDJ_GROUP_PORT_CANDIDATE_ON);
-        else
-            elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH, EMOTICON_EDJ_GROUP_LAND_CANDIDATE_ON);
+        if (screen_degree == 0 || screen_degree == 180) {
+            elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH,
+                                landscape_device ?
+                                EMOTICON_EDJ_GROUP_LAND_CANDIDATE_ON :
+                                EMOTICON_EDJ_GROUP_PORT_CANDIDATE_ON);
+        }
+        else {
+            elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH,
+                                landscape_device ?
+                                EMOTICON_EDJ_GROUP_PORT_CANDIDATE_ON :
+                                EMOTICON_EDJ_GROUP_LAND_CANDIDATE_ON);
+        }
     } else {
         sclint width = 0;
         sclint height = 0;
         g_ui->get_screen_resolution(&width, &height);
         LOGD("screen width:%d, height:%d\n", width, height);
         if (screen_degree == 0 || screen_degree == 180) {
-            elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH, EMOTICON_EDJ_GROUP_PORT_CANDIDATE_OFF);
+            elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH,
+                                landscape_device ?
+                                EMOTICON_EDJ_GROUP_LAND_CANDIDATE_OFF :
+                                EMOTICON_EDJ_GROUP_PORT_CANDIDATE_OFF);
+
             if (g_config_values.floating_mode)
                 evas_object_resize(layout, width * FLOATING_SCALE_RATE, g_ui->get_scaled_y(ISE_HEIGHT_PORT) - ELM_SCALE_SIZE(EMOTICON_HEIGHT_PORT));
             else
-                evas_object_resize(layout, width, g_ui->get_scaled_y(ISE_HEIGHT_PORT));
+                evas_object_resize(layout, width, g_ui->get_scaled_y(landscape_device ? ISE_HEIGHT_LAND : ISE_HEIGHT_PORT));
         } else {
-            elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH, EMOTICON_EDJ_GROUP_LAND_CANDIDATE_OFF);
+            elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH,
+                                landscape_device ?
+                                EMOTICON_EDJ_GROUP_PORT_CANDIDATE_OFF :
+                                EMOTICON_EDJ_GROUP_LAND_CANDIDATE_OFF);
+
             if (g_config_values.floating_mode)
                 evas_object_resize(layout, width * FLOATING_SCALE_RATE, g_ui->get_scaled_y(ISE_HEIGHT_LAND) * FLOATING_SCALE_RATE);
-            else
-                evas_object_resize(layout, width, g_ui->get_scaled_y(ISE_HEIGHT_LAND));
+            else {
+                evas_object_resize(layout, width, g_ui->get_scaled_y(landscape_device ? ISE_HEIGHT_PORT : ISE_HEIGHT_LAND));
+            }
         }
 #ifdef _WEARABLE
         if (g_config_values.floating_mode) {
@@ -274,13 +319,16 @@ void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_
         }
 #else
         if (screen_degree == 0 || screen_degree == 180) {
-            ;
+            if (landscape_device) {
+                evas_object_resize(layout, width - g_ui->get_scaled_y(88*2), g_ui->get_scaled_y(ISE_HEIGHT_LAND));
+                evas_object_move(layout, g_ui->get_scaled_y(88), y);
+            }
         } else {
             if (g_config_values.floating_mode) {
                 evas_object_resize(layout, (width - g_ui->get_scaled_y(88*2)) * FLOATING_SCALE_RATE, (g_ui->get_scaled_y(ISE_HEIGHT_LAND)) * FLOATING_SCALE_RATE);
                 evas_object_move(layout, g_ui->get_scaled_y(88), y + FLOATING_TITLE_BAR_HEIGHT);
             } else {
-                evas_object_resize(layout, width - g_ui->get_scaled_y(88*2), g_ui->get_scaled_y(ISE_HEIGHT_LAND));
+                evas_object_resize(layout, width - g_ui->get_scaled_y(88*2), g_ui->get_scaled_y(landscape_device ? ISE_HEIGHT_PORT : ISE_HEIGHT_LAND));
                 evas_object_move(layout, g_ui->get_scaled_y(88), y);
             }
         }
@@ -391,6 +439,26 @@ static void _multi_up(void *data, Evas *e, Evas_Object *o, void *event_info)
     elm_gengrid_item_selected_set(item, EINA_TRUE);
 }
 
+#ifndef _WEARABLE
+static const char *get_item_style_for_degree(int screen_degree)
+{
+    bool landscape_device = get_landscape_device(screen_degree);
+
+    if (screen_degree == 0 || screen_degree == 180) {
+        if (landscape_device)
+            return EMOTICON_GENGRID_ITEM_STYLE_LAND2;
+        else
+            return EMOTICON_GENGRID_ITEM_STYLE_PORT2;
+    }
+    else {
+        if (landscape_device)
+            return EMOTICON_GENGRID_ITEM_STYLE_PORT2;
+        else
+            return EMOTICON_GENGRID_ITEM_STYLE_LAND2;
+    }
+}
+#endif
+
 static void __ise_emoticon_create_gengrid(unsigned short int screen_degree)
 {
     gengrid = elm_gengrid_add(layout);
@@ -401,10 +469,18 @@ static void __ise_emoticon_create_gengrid(unsigned short int screen_degree)
     evas_object_size_hint_weight_set(gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
     evas_object_size_hint_align_set(gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL);
 
-    if (screen_degree == 0 || screen_degree == 180)
-        elm_gengrid_item_size_set(gengrid, ELM_SCALE_SIZE(EMOTICON_WIDTH_PORT), ELM_SCALE_SIZE(EMOTICON_HEIGHT_PORT));
-    else
-        elm_gengrid_item_size_set(gengrid, ELM_SCALE_SIZE(EMOTICON_WIDTH_LAND), ELM_SCALE_SIZE(EMOTICON_HEIGHT_LAND));
+    bool landscape_device = get_landscape_device(screen_degree);
+
+    if (screen_degree == 0 || screen_degree == 180) {
+        elm_gengrid_item_size_set(gengrid,
+                                  ELM_SCALE_SIZE(landscape_device ? EMOTICON_WIDTH_LAND : EMOTICON_WIDTH_PORT),
+                                  ELM_SCALE_SIZE(landscape_device ? EMOTICON_HEIGHT_LAND : EMOTICON_HEIGHT_PORT));
+    }
+    else {
+        elm_gengrid_item_size_set(gengrid,
+                                  ELM_SCALE_SIZE(landscape_device ? EMOTICON_WIDTH_PORT : EMOTICON_WIDTH_LAND),
+                                  ELM_SCALE_SIZE(landscape_device ? EMOTICON_HEIGHT_PORT: EMOTICON_HEIGHT_LAND));
+    }
 
     elm_gengrid_highlight_mode_set(gengrid, EINA_TRUE);
     elm_gengrid_select_mode_set(gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS);
@@ -452,16 +528,12 @@ static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_gro
     elm_gengrid_item_show(it, ELM_GENGRID_ITEM_SCROLLTO_NONE);
 }
 
-
 static void __ise_emoticon_create_item_class(unsigned short int screen_degree)
 {
     if (!gic)
         gic = elm_gengrid_item_class_new();
 
-    if (screen_degree == 0 || screen_degree == 180)
-        gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_PORT2;
-    else
-        gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_LAND2;
+    gic->item_style = get_item_style_for_degree(screen_degree);
 
     gic->func.text_get = NULL;
     gic->func.content_get = grid_content_get;
@@ -548,10 +620,7 @@ static void __ise_emoticon_create_item_class(unsigned short int screen_degree)
 #ifdef _WEARABLE
         gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_WEARABLE;
 #else
-        if (screen_degree == 0 || screen_degree == 180)
-            gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_PORT2;
-        else
-            gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_LAND2;
+        gic->item_style = get_item_style_for_degree(screen_degree);
 #endif
         gic->func.text_get = grid_text_get;
         gic->func.content_get = NULL;