Restricted sizing eval for layout
authorIván Briano <ivan.briano@intel.com>
Fri, 25 Oct 2013 16:51:33 +0000 (14:51 -0200)
committerIván Briano <ivan.briano@intel.com>
Fri, 25 Oct 2013 16:51:33 +0000 (14:51 -0200)
This allows to select an axis that the layout will use its current size
to restrict the min size calculation of the inner edje, possibly helping
with textblock min size issues

src/lib/elm_layout.c
src/lib/elm_layout_eo.h
src/lib/elm_layout_legacy.h
src/lib/elm_widget_layout.h

index b185141..027aa24 100644 (file)
@@ -101,11 +101,20 @@ static void
 _sizing_eval(Evas_Object *obj, Elm_Layout_Smart_Data *sd)
 {
    Evas_Coord minh = -1, minw = -1;
+   Evas_Coord rest_w = 0, rest_h = 0;
    ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);
 
-   edje_object_size_min_calc(wd->resize_obj, &minw, &minh);
+   if (sd->restricted_calc_w)
+     rest_w = wd->w;
+   if (sd->restricted_calc_h)
+     rest_h = wd->h;
+
+   edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh,
+                                        rest_w, rest_h);
    evas_object_size_hint_min_set(obj, minw, minh);
    evas_object_size_hint_max_set(obj, -1, -1);
+
+   sd->restricted_calc_w = sd->restricted_calc_h = EINA_FALSE;
 }
 
 /* common content cases for layout objects: icon and text */
@@ -1785,6 +1794,26 @@ _elm_layout_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
    evas_object_smart_changed(obj);
 }
 
+EAPI void
+elm_layout_sizing_restricted_eval(Evas_Object *obj, Eina_Bool w, Eina_Bool h)
+{
+   ELM_LAYOUT_CHECK(obj);
+   eo_do(obj, elm_obj_layout_sizing_restricted_eval(w, h));
+}
+
+static void
+_elm_layout_smart_sizing_restricted_eval(Eo *obj, void *_pd, va_list *list)
+{
+   Elm_Layout_Smart_Data *sd = _pd;
+   Eina_Bool w = va_arg(*list, int);
+   Eina_Bool h = va_arg(*list, int);
+
+   sd->restricted_calc_w = !!w;
+   sd->restricted_calc_h = !!h;
+
+   evas_object_smart_changed(obj);
+}
+
 EAPI int
 elm_layout_freeze(Evas_Object *obj)
 {
@@ -2232,6 +2261,7 @@ _class_constructor(Eo_Class *klass)
         EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_EDJE_GET), _elm_layout_smart_edje_get),
         EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_DATA_GET), _elm_layout_smart_data_get),
         EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL), _elm_layout_smart_sizing_eval),
+        EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_RESTRICTED_EVAL), _elm_layout_smart_sizing_restricted_eval),
         EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_PART_CURSOR_SET), _elm_layout_smart_part_cursor_set),
         EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_PART_CURSOR_GET), _elm_layout_smart_part_cursor_get),
         EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_PART_CURSOR_UNSET), _elm_layout_smart_part_cursor_unset),
@@ -2290,6 +2320,7 @@ static const Eo_Op_Description op_desc[] = {
      EO_OP_DESCRIPTION(ELM_OBJ_LAYOUT_SUB_ID_THEME_ENABLE, "Checks whenever 'theme' is impemented in current class."),
      EO_OP_DESCRIPTION(ELM_OBJ_LAYOUT_SUB_ID_FREEZE, "Freezes the Elementary layout object."),
      EO_OP_DESCRIPTION(ELM_OBJ_LAYOUT_SUB_ID_THAW, "Thaws the Elementary layout object."),
+     EO_OP_DESCRIPTION(ELM_OBJ_LAYOUT_SUB_ID_SIZING_RESTRICTED_EVAL, "Eval sizing, restricted to current width/height size."),
 
 
      EO_OP_DESCRIPTION_SENTINEL
index bbacde2..1abb538 100644 (file)
@@ -45,6 +45,7 @@
    ELM_OBJ_LAYOUT_SUB_ID_THEME_ENABLE,
    ELM_OBJ_LAYOUT_SUB_ID_FREEZE,
    ELM_OBJ_LAYOUT_SUB_ID_THAW,
+   ELM_OBJ_LAYOUT_SUB_ID_SIZING_RESTRICTED_EVAL,
    ELM_OBJ_LAYOUT_SUB_ID_LAST
 };
 
 #define elm_obj_layout_sizing_eval() ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL)
 
 /**
+ * @def elm_obj_layout_sizing_restricted_eval
+ * @since 1.8
+ *
+ * Eval sizing, restricted to current width and/or height
+ *
+ * @see elm_layout_sizing_restricted_eval
+ */
+#define elm_obj_layout_sizing_restricted_eval(width, height) ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_RESTRICTED_EVAL), EO_TYPECHECK(Eina_Bool, width), EO_TYPECHECK(Eina_Bool, height)
+
+/**
  * @def elm_obj_layout_part_cursor_set
  * @since 1.8
  *
index 98450ad..5006902 100644 (file)
@@ -416,6 +416,24 @@ EAPI const char                  *elm_layout_data_get(const Evas_Object *obj, co
 EAPI void                         elm_layout_sizing_eval(Evas_Object *obj);
 
 /**
+ * Request sizing reevaluation, restricted to current width and/or height
+ *
+ * Useful mostly when there are TEXTBLOCK parts defining the height of the
+ * object and nothing else restricting it to a minimum width. Calling this
+ * function will restrict the minimum size in the Edje calculation to whatever
+ * size it the layout has at the moment.
+ *
+ * @param obj The layout object
+ * @param w   Restrict minimum size to the current width
+ * @param h   Restrict minimum size ot the current height
+ *
+ * @since 1.8
+ *
+ * @ingroup Layout
+ */
+EAPI void                         elm_layout_sizing_restricted_eval(Evas_Object *obj, Eina_Bool w, Eina_Bool h);
+
+/**
  * Sets a specific cursor for an edje part.
  *
  * @param obj The layout object.
index 514eefd..40b0933 100644 (file)
@@ -84,6 +84,8 @@ typedef struct _Elm_Layout_Smart_Data
    int                   frozen; /**< Layout freeze counter */
 
    Eina_Bool             needs_size_calc : 1;
+   Eina_Bool             restricted_calc_w : 1;
+   Eina_Bool             restricted_calc_h : 1;
 } Elm_Layout_Smart_Data;
 
 /**