gengrid : enable layout sizing eval and content min limit feature in gengrid 41/108441/2
authorSangHyeon Lee <sh10233.lee@samsung.com>
Tue, 3 Jan 2017 08:40:26 +0000 (17:40 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Wed, 4 Jan 2017 09:57:23 +0000 (01:57 -0800)
Change-Id: Id3fa2770a19b46b149168e782b2c5a87376f84b4
(cherry picked from commit 209e03d4a3612ede14f7473b90ee8f7394fc6ef6)

src/lib/elm_gengrid.c
src/lib/elm_widget_gengrid.h

index 8a95718..9d76daf 100644 (file)
@@ -678,6 +678,7 @@ _calc(void *data)
           {
              sd->minh = minh;
              sd->minw = minw;
+             elm_layout_sizing_eval(sd->obj);
              eo_do(sd->pan_obj, eo_event_callback_call
                    (ELM_PAN_EVENT_CHANGED, NULL));
           }
@@ -4621,11 +4622,48 @@ _elm_gengrid_item_new(Elm_Gengrid_Data *sd,
 
 /* common layout sizing won't apply here */
 EOLIAN static void
-_elm_gengrid_elm_layout_sizing_eval(Eo *obj EINA_UNUSED, Elm_Gengrid_Data *_pd EINA_UNUSED)
+_elm_gengrid_elm_layout_sizing_eval(Eo *obj, Elm_Gengrid_Data *sd)
 {
-   return;  /* no-op */
+   Evas_Coord minw = 0, minh = 0, maxw = -1, maxh = -1, vw = 0, vh = 0;
+
+   ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+
+   evas_object_size_hint_min_get(obj, &minw, &minh);
+   evas_object_size_hint_max_get(obj, &maxw, &maxh);
+   edje_object_size_min_calc(wd->resize_obj, &vw, &vh);
+
+   if (sd->scr_minw)
+     {
+        maxw = -1;
+        minw = vw + sd->minw;
+     }
+   if (sd->scr_minh)
+     {
+        maxh = -1;
+        minh = vh + sd->minh;
+     }
+
+   if ((maxw > 0) && (minw > maxw))
+     minw = maxw;
+   if ((maxh > 0) && (minh > maxh))
+     minh = maxh;
+
+   evas_object_size_hint_min_set(obj, minw, minh);
+   evas_object_size_hint_max_set(obj, maxw, maxh);
 }
 
+static void
+_content_min_limit_cb(Evas_Object *obj, Eina_Bool w, Eina_Bool h)
+{
+   ELM_GENGRID_DATA_GET(obj, sd);
+
+   sd->scr_minw = !!w;
+   sd->scr_minh = !!h;
+
+   elm_layout_sizing_eval(obj);
+}
+
+
 EOLIAN static void
 _elm_gengrid_evas_object_smart_add(Eo *obj, Elm_Gengrid_Data *priv)
 {
@@ -4675,7 +4713,8 @@ _elm_gengrid_evas_object_smart_add(Eo *obj, Elm_Gengrid_Data *priv)
          elm_interface_scrollable_edge_top_cb_set(_edge_top_cb),
          elm_interface_scrollable_edge_bottom_cb_set(_edge_bottom_cb),
          elm_interface_scrollable_scroll_cb_set(_scroll_cb),
-         elm_interface_scrollable_page_change_cb_set(_scroll_page_change_cb));
+         elm_interface_scrollable_page_change_cb_set(_scroll_page_change_cb),
+         elm_interface_scrollable_content_min_limit_cb_set(_content_min_limit_cb));
 
    //Tizen Only: Item should be shown as top position.
    priv->align_x = 0.0;
index cab2334..1d23a77 100644 (file)
@@ -160,6 +160,8 @@ struct _Elm_Gengrid_Data
    unsigned int                       *custom_tot_sum; /* array to store total sum of all widths or heights. this is used for item alignment calculations. */
    unsigned int                       custom_tot_max; /* maximum of the total sums over all rows or columns. this is also used for item alignment calculations. */
    unsigned int                       custom_alloc_size; /* amount of memory allocated to above dynamic arrays in terms of number of rows or columns. */
+   Eina_Bool                             scr_minw : 1;
+   Eina_Bool                             scr_minh : 1;
 };
 
 struct Elm_Gen_Item_Type