hoversel: fix item size calculation to get proper size & ellipsize 77/109277/1
authorJee-Yong Um <jc9.um@samsung.com>
Mon, 9 Jan 2017 16:08:01 +0000 (01:08 +0900)
committerJee-Yong Um <jc9.um@samsung.com>
Mon, 9 Jan 2017 16:09:31 +0000 (01:09 +0900)
Signed-Off-By: Jee-Yong Um <jc9.um@samsung.com>
Change-Id: I0dba6017146fc0d6332042e139c576a1d2be6d12

src/lib/elc_hoversel.c
src/lib/elm_hover.c
src/lib/elm_widget_hoversel.h

index c20c0f21094d819f7cf9c74f4f851b63106abffb..7712af44f033adaeec1017d40169ad2df7ed9a5a 100644 (file)
@@ -97,7 +97,10 @@ _elm_hoversel_elm_widget_theme_apply(Eo *obj, Elm_Hoversel_Data *sd)
      {
         ELM_HOVERSEL_ITEM_DATA_GET(eo_item, item);
         elm_object_style_set(VIEW(item), buf);
-        elm_object_text_set(VIEW(item), item->label);
+        // TIZEN_ONLY(20150828): shrink item width expanding over hover parent
+        // elm_object_text_set(VIEW(item), item->label);
+        eo_do(eo_item, elm_wdg_item_part_text_set(NULL, item->label));
+        //
         elm_widget_disabled_set
           (VIEW(item), eo_do_ret(eo_item, int_ret, elm_wdg_item_disabled_get()));
      }
@@ -254,6 +257,26 @@ _resizing_eval(Evas_Object *obj, Elm_Hoversel_Data *sd)
 
    if ((!sd->expanded) || (!bx)) return;
 
+   // TIZEN_ONLY(20150828): shrink item width expanding over hover parent
+   Eina_List *l;
+   Elm_Object_Item *eo_it;
+   Evas_Coord it_h;
+
+   if (!sd->horizontal)
+     {
+        EINA_LIST_FOREACH(sd->items, l, eo_it)
+          {
+             ELM_HOVERSEL_ITEM_DATA_GET(eo_it, it);
+
+             evas_object_size_hint_min_get(VIEW(it), NULL, &it_h);
+             evas_object_size_hint_min_set(VIEW(it), it->minw, it_h);
+          }
+     }
+   //
+
+   elm_layout_signal_emit(sd->hover, "elm,state,align,default", "elm");
+   edje_object_message_signal_process(elm_layout_edje_get(sd->hover));
+
    elm_box_recalculate(bx);
    evas_object_size_hint_min_get(bx, &box_w, &box_h);
 
@@ -347,22 +370,17 @@ _resizing_eval(Evas_Object *obj, Elm_Hoversel_Data *sd)
                }
           }
      }
-   if (ww < obj_w) ww = obj_w;
    evas_object_size_hint_min_set(sd->spacer, ww, hh);
 
    // TIZEN_ONLY(20150828): shrink item width expanding over hover parent
    if (!sd->horizontal)
      {
-        Eina_List *l;
-        Evas_Object *it;
-        Evas_Coord it_w, it_h;
-
-        l = elm_box_children_get(bx);
-        EINA_LIST_FREE(l, it)
+        EINA_LIST_FOREACH(sd->items, l, eo_it)
           {
-             evas_object_size_hint_min_get(it, &it_w, &it_h);
-             if (it_w > ww)
-               evas_object_size_hint_min_set(it, ww, it_h);
+             ELM_HOVERSEL_ITEM_DATA_GET(eo_it, it);
+
+             evas_object_size_hint_min_get(VIEW(it), NULL, &it_h);
+             evas_object_size_hint_min_set(VIEW(it), (it->minw > ww) ? ww : it->minw, it_h);
           }
      }
    //
@@ -510,7 +528,12 @@ _elm_hoversel_item_elm_widget_item_part_text_set(Eo *eo_it EINA_UNUSED,
    eina_stringshare_replace(&it->label, label);
 
    if (VIEW(it))
-     elm_object_text_set(VIEW(it), label);
+     // TIZEN_ONLY(20150828): shrink item width expanding over hover parent
+     //elm_object_text_set(VIEW(it), label);
+     {
+        elm_object_text_set(VIEW(it), label);
+        evas_object_size_hint_min_get(VIEW(it), &it->minw, NULL);
+     }
 }
 
 static const char *
@@ -827,7 +850,9 @@ _elm_hoversel_item_add(Eo *obj, Elm_Hoversel_Data *sd, const char *label, const
    VIEW(item) = bt = elm_button_add(obj);
    elm_widget_mirrored_set(bt, elm_widget_mirrored_get(obj));
    elm_object_style_set(bt, buf);
-   elm_object_text_set(bt, item->label);
+   // TIZEN_ONLY(20150828): shrink item width expanding over hover parent
+   // elm_object_text_set(bt, item->label);
+   //
 
    if (item->icon_file)
      {
@@ -840,12 +865,16 @@ _elm_hoversel_item_add(Eo *obj, Elm_Hoversel_Data *sd, const char *label, const
         elm_object_part_content_set(bt, "icon", ic);
      }
 
-    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
-    evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    eo_do(bt,
-          eo_event_callback_add(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_item_clicked, item),
-          eo_event_callback_add(ELM_WIDGET_EVENT_FOCUSED, _item_focused_cb, item),
-          eo_event_callback_add(ELM_WIDGET_EVENT_UNFOCUSED, _item_unfocused_cb, item));
+   // TIZEN_ONLY(20150828): shrink item width expanding over hover parent
+   // To get proper size hint min width, set text after setting icon
+   eo_do(eo_item, elm_wdg_item_part_text_set(NULL, item->label));
+   //
+   evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
+   evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   eo_do(bt,
+         eo_event_callback_add(EVAS_CLICKABLE_INTERFACE_EVENT_CLICKED, _on_item_clicked, item),
+         eo_event_callback_add(ELM_WIDGET_EVENT_FOCUSED, _item_focused_cb, item),
+         eo_event_callback_add(ELM_WIDGET_EVENT_UNFOCUSED, _item_unfocused_cb, item));
 
    sd->items = eina_list_append(sd->items, eo_item);
 
index 50c07bd71746116b51576efb8ea99593349b0d03..fe2e1e456349e86222e8bfeb5dc4da5603254555 100644 (file)
@@ -702,6 +702,8 @@ _elm_hover_target_set(Eo *obj, Elm_Hover_Data *sd, Evas_Object *target)
           (sd->target, EVAS_CALLBACK_DEL, _target_del_cb, obj);
         evas_object_event_callback_del_full
           (sd->target, EVAS_CALLBACK_MOVE, _target_move_cb, obj);
+        evas_object_event_callback_del_full
+          (sd->target, EVAS_CALLBACK_RESIZE, _target_move_cb, obj);
         elm_widget_hover_object_set(sd->target, NULL);
      }
 
@@ -712,6 +714,8 @@ _elm_hover_target_set(Eo *obj, Elm_Hover_Data *sd, Evas_Object *target)
           (sd->target, EVAS_CALLBACK_DEL, _target_del_cb, obj);
         evas_object_event_callback_add
           (sd->target, EVAS_CALLBACK_MOVE, _target_move_cb, obj);
+        evas_object_event_callback_add
+          (sd->target, EVAS_CALLBACK_RESIZE, _target_move_cb, obj);
         elm_widget_hover_object_set(target, obj);
         elm_layout_sizing_eval(obj);
      }
index 5b10d8b4f74b7be5fd09ebd4192b0deda81f038e..bf20d2015e540d7a53309525bc88e2ee3b011131 100644 (file)
@@ -58,6 +58,10 @@ struct _Elm_Hoversel_Item_Data
 
    Elm_Icon_Type icon_type;
    Evas_Smart_Cb func;
+
+   // TIZEN_ONLY(20150828): shrink item width expanding over hover parent
+   Evas_Coord minw;
+   //
 };
 
 /**