edje: Use Eina.Size2D for group min & max size

This commit is contained in:
Jean-Philippe Andre 2017-09-18 17:01:10 +09:00
parent d8eea084fb
commit 942cbbed73
8 changed files with 107 additions and 77 deletions

View File

@ -2230,6 +2230,50 @@ EAPI void edje_object_transition_duration_factor_set(Evas_Object *obj, double sc
*/
EAPI double edje_object_transition_duration_factor_get(const Evas_Object *obj);
/**
* @brief Gets the minimum size specified -- as an EDC property -- for a given
* Edje object
*
* This function retrieves the obj object's minimum size values, as declared in
* its EDC group definition. For instance, for an Edje object of minimum size
* 100x100 pixels: collections { group { name: "a_group"; min: 100 100; } }
*
* @note If the @c min EDC property was not declared for this object, this call
* will return 0x0.
*
* @note On failure, this function also return 0x0.
*
* See also @ref edje_object_size_max_get.
*
* @param[out] minw Pointer to a variable where to store the minimum width
* @param[out] minh Pointer to a variable where to store the minimum height
*
* @ingroup Edje_Object
*/
EAPI void edje_object_size_min_get(const Edje_Object *obj, int *minw, int *minh);
/**
* @brief Gets the maximum size specified -- as an EDC property -- for a given
* Edje object
*
* This function retrieves the object's maximum size values, as declared in its
* EDC group definition. For instance, for an Edje object of maximum size
* 100x100 pixels: collections { group { name: "a_group"; max: 100 100; } }
*
* @note If the @c max EDC property was not declared for the object, this call
* will return the maximum size a given Edje object may have, for each axis.
*
* @note On failure, this function will return 0x0.
*
* See also @ref edje_object_size_min_get.
*
* @param[out] maxw The maximum width
* @param[out] maxh The maximum height
*
* @ingroup Edje_Object
*/
EAPI void edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh);
/**
* @}
*/

View File

@ -1158,3 +1158,21 @@ edje_object_transition_duration_factor_get(const Evas_Object *obj)
if (speed <= 0.0) speed = 1.0;
return 1.0/speed;
}
EAPI void
edje_object_size_min_get(const Edje_Object *obj, int *minw, int *minh)
{
Eina_Size2D sz;
sz = efl_canvas_layout_group_size_min_get(obj);
if (minw) *minw = sz.w;
if (minh) *minh = sz.h;
}
EAPI void
edje_object_size_max_get(const Edje_Object *obj, int *maxw, int *maxh)
{
Eina_Size2D sz;
sz = efl_canvas_layout_group_size_max_get(obj);
if (maxw) *maxw = sz.w;
if (maxh) *maxh = sz.h;
}

View File

@ -1114,7 +1114,7 @@ struct _Edje_Part_Collection
int references;
struct {
Edje_Size min, max;
Eina_Size2D min, max;
unsigned char orientation;
} prop;

View File

@ -3096,50 +3096,32 @@ _edje_object_efl_part_part(Eo *obj, Edje *ed, const char *part)
return _edje_other_internal_proxy_get(obj, ed, rp);
}
EOLIAN void
_edje_object_efl_canvas_layout_group_group_size_min_get(Eo *obj EINA_UNUSED, Edje *ed, Evas_Coord *minw, Evas_Coord *minh)
EOLIAN Eina_Size2D
_edje_object_efl_canvas_layout_group_group_size_min_get(Eo *obj EINA_UNUSED, Edje *ed)
{
if ((!ed) || (!ed->collection))
{
if (minw) *minw = 0;
if (minh) *minh = 0;
return;
}
if (minw) *minw = ed->collection->prop.min.w;
if (minh) *minh = ed->collection->prop.min.h;
return EINA_SIZE2D(0, 0);
return ed->collection->prop.min;
}
EOLIAN void
_edje_object_efl_canvas_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Edje *ed EINA_UNUSED, Evas_Coord *maxw, Evas_Coord *maxh)
EOLIAN Eina_Size2D
_edje_object_efl_canvas_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Edje *ed EINA_UNUSED)
{
Eina_Size2D sz;
if ((!ed) || (!ed->collection))
{
if (maxw) *maxw = 0;
if (maxh) *maxh = 0;
return;
}
return EINA_SIZE2D(0, 0);
/* Need to recalc before providing the object. */
_edje_recalc_do(ed);
if (ed->collection->prop.max.w == 0)
{
/* XXX TODO: convert maxw to 0, fix things that break. */
if (maxw) *maxw = EDJE_INF_MAX_W;
}
else
{
if (maxw) *maxw = ed->collection->prop.max.w;
}
if (ed->collection->prop.max.h == 0)
{
/* XXX TODO: convert maxh to 0, fix things that break. */
if (maxh) *maxh = EDJE_INF_MAX_H;
}
else
{
if (maxh) *maxh = ed->collection->prop.max.h;
}
sz = ed->collection->prop.max;
/* XXX TODO: use 0 as max, fix things that break. */
if (sz.w == 0) sz.w = EDJE_INF_MAX_W;
if (sz.h == 0) sz.h = EDJE_INF_MAX_H;
return sz;
}
EOLIAN void

View File

@ -1,3 +1,5 @@
import eina_types;
interface Efl.Canvas.Layout_Group
{
[[APIs representing static data from a group in an edje file.
@ -27,11 +29,9 @@ interface Efl.Canvas.Layout_Group
See also @.group_size_max.
]]
legacy: edje_object_size_min_get;
}
values {
minw: int; [[Pointer to a variable where to store the minimum width]]
minh: int; [[Pointer to a variable where to store the minimum height]]
min: Eina.Size2D; [[The minimum size as set in EDC.]]
}
}
@property group_size_max {
@ -57,11 +57,9 @@ interface Efl.Canvas.Layout_Group
See also @.group_size_min.
]]
legacy: edje_object_size_max_get;
}
values {
maxw: int; [[The maximum width]]
maxh: int; [[The maximum height]]
max: Eina.Size2D; [[The maximum size as set in EDC.]]
}
}
@property group_data {

View File

@ -1165,28 +1165,22 @@ _efl_ui_image_efl_canvas_layout_signal_signal_emit(Eo *obj EINA_UNUSED, Efl_Ui_I
edje_object_signal_emit(sd->img, emission, source);
}
EOLIAN static void
_efl_ui_image_efl_canvas_layout_group_group_size_min_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, int *w, int *h)
EOLIAN static Eina_Size2D
_efl_ui_image_efl_canvas_layout_group_group_size_min_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
{
if (sd->edje)
edje_object_size_min_get(sd->img, w, h);
return efl_canvas_layout_group_size_min_get(sd->img);
else
{
if (w) *w = 0;
if (h) *h = 0;
}
return EINA_SIZE2D(0, 0);
}
EOLIAN static void
_efl_ui_image_efl_canvas_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, int *w, int *h)
EOLIAN static Eina_Size2D
_efl_ui_image_efl_canvas_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
{
if (sd->edje)
edje_object_size_max_get(sd->img, w, h);
return efl_canvas_layout_group_size_max_get(sd->img);
else
{
if (w) *w = 0;
if (h) *h = 0;
}
return EINA_SIZE2D(0, 0);
}
EOLIAN static void

View File

@ -1552,28 +1552,22 @@ _efl_ui_image_zoomable_efl_image_image_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Imag
if (h) *h = pd->size.imh;
}
EOLIAN static void
_efl_ui_image_zoomable_efl_canvas_layout_group_group_size_min_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd, int *w, int *h)
EOLIAN static Eina_Size2D
_efl_ui_image_zoomable_efl_canvas_layout_group_group_size_min_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
{
if (sd->edje)
edje_object_size_min_get(sd->edje, w, h);
return efl_canvas_layout_group_size_min_get(sd->edje);
else
{
if (w) *w = 0;
if (h) *h = 0;
}
return EINA_SIZE2D(0, 0);
}
EOLIAN static void
_efl_ui_image_zoomable_efl_canvas_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd, int *w, int *h)
EOLIAN static Eina_Size2D
_efl_ui_image_zoomable_efl_canvas_layout_group_group_size_max_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
{
if (sd->edje)
edje_object_size_max_get(sd->edje, w, h);
return efl_canvas_layout_group_size_max_get(sd->edje);
else
{
if (w) *w = 0;
if (h) *h = 0;
}
return EINA_SIZE2D(0, 0);
}
static Eina_Bool

View File

@ -1646,20 +1646,20 @@ _efl_ui_layout_efl_canvas_layout_group_group_data_get(Eo *obj, Efl_Ui_Layout_Dat
return efl_canvas_layout_group_data_get(wd->resize_obj, key);
}
EOLIAN static void
_efl_ui_layout_efl_canvas_layout_group_group_size_min_get(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, int *w, int *h)
EOLIAN static Eina_Size2D
_efl_ui_layout_efl_canvas_layout_group_group_size_min_get(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_SIZE2D(0, 0));
efl_canvas_layout_group_size_min_get(wd->resize_obj, w, h);
return efl_canvas_layout_group_size_min_get(wd->resize_obj);
}
EOLIAN static void
_efl_ui_layout_efl_canvas_layout_group_group_size_max_get(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, int *w, int *h)
EOLIAN static Eina_Size2D
_efl_ui_layout_efl_canvas_layout_group_group_size_max_get(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_SIZE2D(0, 0));
efl_canvas_layout_group_size_max_get(wd->resize_obj, w, h);
return efl_canvas_layout_group_size_max_get(wd->resize_obj);
}
/* layout's sizing evaluation is deferred. evaluation requests are