ctxpopup: fix multi-resolution problem by advanced flexible feature 86/132286/14
authorJinYong Park <j4939.park@samsung.com>
Fri, 2 Jun 2017 06:08:11 +0000 (15:08 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 15 Dec 2017 06:58:34 +0000 (06:58 +0000)
 ctxpopup size decision priority
  1. size hint min/max set by user
  2. match_min_width / match_max_width data in theme
  3. visible_maxw / visible_maxh data in theme

  - Requirement
     profile/mobile/platform/core/uifw/efl-theme-tizen-mobile
     https://review.tizen.org/gerrit/132651

Change-Id: I4d895c865bb76b01332a6791506158861aa762c6
Signed-off-by: Jinyong Park <j4939.park@samsung.com>
src/mobile_lib/elc_ctxpopup.c

index 84b0bad..7d1aad1 100644 (file)
@@ -520,6 +520,7 @@ _base_geometry_calc(Evas_Object *obj,
    Evas_Coord_Point max_size;
    Evas_Coord_Point min_size;
    Evas_Coord_Point temp;
+   Evas_Object *win = NULL;
    int idx;
    const char *str;
 
@@ -547,6 +548,10 @@ _base_geometry_calc(Evas_Object *obj,
    else if (pos.y > hover_area.y + hover_area.h) pos.y = hover_area.y + hover_area.h;
    /* END */
 
+   win = elm_object_top_widget_get(obj);
+   if ((win) && (!eo_isa(win, ELM_WIN_CLASS)))
+     win = NULL;
+
    //recalc the edje
    edje_object_size_min_calc
      (wd->resize_obj, &base_size.x, &base_size.y);
@@ -554,14 +559,19 @@ _base_geometry_calc(Evas_Object *obj,
 
    //Limit to Max Size
    evas_object_size_hint_max_get(obj, &max_size.x, &max_size.y);
-   if ((max_size.x == -1) || (max_size.y == -1))
+   if (max_size.x == -1)
      {
-        str = edje_object_data_get(sd->layout, "visible_maxw");
-        if (str)
+        if ((str = edje_object_data_get(sd->layout, "match_max_width")) &&
+            (!strcmp(str, "portrait_width")) && (win))
+          elm_win_screen_size_get(win, NULL, NULL, &max_size.x, NULL);
+        else if (str = edje_object_data_get(sd->layout, "visible_maxw"))
           max_size.x = (int)(atoi(str)
                              * elm_config_scale_get()
                              * elm_object_scale_get(obj)
                              / edje_object_base_scale_get(sd->layout) + 0.5);
+     }
+   if (max_size.y == -1)
+     {
         str = edje_object_data_get(sd->layout, "visible_maxh");
         if (str)
           max_size.y = (int)(atoi(str)
@@ -578,8 +588,16 @@ _base_geometry_calc(Evas_Object *obj,
 
    //Limit to Min Size
    evas_object_size_hint_min_get(obj, &min_size.x, &min_size.y);
-   if ((min_size.x == 0) || (min_size.y == 0))
-     edje_object_size_min_get(sd->layout, &min_size.x, &min_size.y);
+   if (min_size.x == 0)
+     {
+        if ((str = edje_object_data_get(sd->layout, "match_min_width")) &&
+            (!strcmp(str, "portrait_width")) && (win))
+          elm_win_screen_size_get(win, NULL, NULL, &min_size.x, NULL);
+        else
+          edje_object_size_min_get(sd->layout, &min_size.x, NULL);
+     }
+   if (min_size.y == 0)
+     edje_object_size_min_get(sd->layout, NULL, &min_size.y);
 
    if ((min_size.y > 0) && (base_size.y < min_size.y))
      base_size.y = min_size.y;
@@ -1028,6 +1046,7 @@ _elm_ctxpopup_elm_layout_sizing_eval(Eo *obj, Elm_Ctxpopup_Data *sd)
         _item_sizing_eval(item);
         evas_object_size_hint_min_get(VIEW(item), &_box_size.x, &_box_size.y);
 
+        /* Disable item size fix by edc data
         str = edje_object_data_get(VIEW(item), "item_max_size");
         if (str)
           {
@@ -1042,6 +1061,7 @@ _elm_ctxpopup_elm_layout_sizing_eval(Eo *obj, Elm_Ctxpopup_Data *sd)
                   edje_object_message_signal_process(VIEW(item));
                }
           }
+        */
 
         if (!sd->horizontal)
           {
@@ -1090,6 +1110,25 @@ _elm_ctxpopup_elm_layout_sizing_eval(Eo *obj, Elm_Ctxpopup_Data *sd)
    evas_object_geometry_get(sd->parent, &x, &y, &w, &h);
    evas_object_move(sd->bg, x, y);
    evas_object_resize(sd->bg, w, h);
+
+
+   // resize item and set ellipsis state (only vertical mode)
+   if (!sd->horizontal)
+     {
+        edje_object_part_geometry_get(wd->resize_obj, "elm.swallow.content", NULL, NULL, &w, NULL);
+
+        EINA_LIST_FOREACH(sd->items, elist, item)
+          {
+             evas_object_size_hint_min_get(VIEW(item), &_box_size.x, &_box_size.y);
+
+             if (_box_size.x > w)
+               {
+                  evas_object_size_hint_min_set(VIEW(item), w, _box_size.y);
+                  edje_object_signal_emit(VIEW(item), "elm,state,text,ellipsis", "elm");
+                  edje_object_message_signal_process(VIEW(item));
+               }
+          }
+     }
 }
 
 static void
@@ -1896,6 +1935,17 @@ _on_move(void *data EINA_UNUSED,
 }
 
 static void
+_size_hints_changed_cb(void *data EINA_UNUSED,
+                       Evas *e EINA_UNUSED,
+                       Evas_Object *obj,
+                       void *event_info EINA_UNUSED)
+{
+   ELM_CTXPOPUP_DATA_GET(obj, sd);
+
+   if (sd->visible) elm_layout_sizing_eval(obj);
+}
+
+static void
 _hide_finished_cb(void *data,
                   Evas_Object *obj EINA_UNUSED,
                   const char *emission EINA_UNUSED,
@@ -2036,6 +2086,7 @@ _elm_ctxpopup_evas_object_smart_add(Eo *obj, Elm_Ctxpopup_Data *priv)
    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _on_show, NULL);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _on_hide, NULL);
    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _on_move, NULL);
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _size_hints_changed_cb, NULL);
 
    _mirrored_set(obj, elm_widget_mirrored_get(obj));