diff options
Diffstat (limited to 'src/lib/elm_table.c')
-rw-r--r-- | src/lib/elm_table.c | 360 |
1 files changed, 253 insertions, 107 deletions
diff --git a/src/lib/elm_table.c b/src/lib/elm_table.c index 7509c05fd..847789a93 100644 --- a/src/lib/elm_table.c +++ b/src/lib/elm_table.c @@ -2,23 +2,35 @@ #include "elm_priv.h" #include "elm_widget_table.h" -EAPI const char ELM_TABLE_SMART_NAME[] = "elm_table"; +#include "Eo.h" -EVAS_SMART_SUBCLASS_NEW - (ELM_TABLE_SMART_NAME, _elm_table, Elm_Table_Smart_Class, - Elm_Widget_Smart_Class, elm_widget_smart_class_get, NULL); +EAPI Eo_Op ELM_OBJ_TABLE_BASE_ID = EO_NOOP; -static Eina_Bool -_elm_table_smart_focus_next(const Evas_Object *obj, - Elm_Focus_Direction dir, - Evas_Object **next) +#define MY_CLASS ELM_OBJ_TABLE_CLASS + +#define MY_CLASS_NAME "elm_table" + +static void +_elm_table_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list) { - Eina_Bool ret; + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + *ret = EINA_TRUE; +} + +static void +_elm_table_smart_focus_next(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Elm_Focus_Direction dir = va_arg(*list, Elm_Focus_Direction); + Evas_Object **next = va_arg(*list, Evas_Object **); + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + if (ret) *ret = EINA_FALSE; + Eina_Bool int_ret; + const Eina_List *items; Eina_List *(*list_free)(Eina_List *list); void *(*list_data_get)(const Eina_List *list); - ELM_TABLE_DATA_GET(obj, sd); + ELM_WIDGET_DATA_GET(obj, wd); /* Focus chain */ /* TODO: Change this to use other chain */ @@ -30,33 +42,43 @@ _elm_table_smart_focus_next(const Evas_Object *obj, else { items = evas_object_table_children_get - (ELM_WIDGET_DATA(sd)->resize_obj); + (wd->resize_obj); list_data_get = eina_list_data_get; list_free = eina_list_free; - if (!items) return EINA_FALSE; + if (!items) return; } - ret = elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next); + int_ret = elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next); if (list_free) list_free((Eina_List *)items); - return ret; + if (ret) *ret = int_ret; +} + +static void +_elm_table_smart_focus_direction_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list) +{ + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + *ret = EINA_TRUE; } -static Eina_Bool -_elm_table_smart_focus_direction(const Evas_Object *obj, - const Evas_Object *base, - double degree, - Evas_Object **direction, - double *weight) +static void +_elm_table_smart_focus_direction(Eo *obj, void *_pd EINA_UNUSED, va_list *list) { - Eina_Bool ret; + Evas_Object *base = va_arg(*list, Evas_Object *); + double degree = va_arg(*list, double); + Evas_Object **direction = va_arg(*list, Evas_Object **); + double *weight = va_arg(*list, double *); + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + if (ret) *ret = EINA_FALSE; + Eina_Bool int_ret; + const Eina_List *items; Eina_List *(*list_free)(Eina_List *list); void *(*list_data_get)(const Eina_List *list); - ELM_TABLE_DATA_GET(obj, sd); + ELM_WIDGET_DATA_GET(obj, wd); /* Focus chain */ /* TODO: Change this to use other chain */ @@ -68,38 +90,44 @@ _elm_table_smart_focus_direction(const Evas_Object *obj, else { items = evas_object_table_children_get - (ELM_WIDGET_DATA(sd)->resize_obj); + (wd->resize_obj); list_data_get = eina_list_data_get; list_free = eina_list_free; - if (!items) return EINA_FALSE; + if (!items) return; } - ret = elm_widget_focus_list_direction_get + int_ret = elm_widget_focus_list_direction_get (obj, base, items, list_data_get, degree, direction, weight); if (list_free) list_free((Eina_List *)items); - return ret; + if (ret) *ret = int_ret; } static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl) { - ELM_TABLE_DATA_GET(obj, sd); + ELM_WIDGET_DATA_GET(obj, wd); - evas_object_table_mirrored_set(ELM_WIDGET_DATA(sd)->resize_obj, rtl); + evas_object_table_mirrored_set(wd->resize_obj, rtl); } -static Eina_Bool -_elm_table_smart_theme(Evas_Object *obj) +static void +_elm_table_smart_theme(Eo *obj, void *_pd EINA_UNUSED, va_list *list) { - if (!_elm_table_parent_sc->theme(obj)) return EINA_FALSE; + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + if (ret) *ret = EINA_FALSE; + + Eina_Bool super_ret; + eo_do_super(obj, elm_wdg_theme(&super_ret)); + if (super_ret == EINA_FALSE) + return; _mirrored_set(obj, elm_widget_mirrored_get(obj)); - return EINA_TRUE; + if (ret) *ret = EINA_TRUE; } static void @@ -108,12 +136,12 @@ _sizing_eval(Evas_Object *obj) Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1; Evas_Coord w, h; - ELM_TABLE_DATA_GET(obj, sd); + ELM_WIDGET_DATA_GET(obj, wd); evas_object_size_hint_min_get - (ELM_WIDGET_DATA(sd)->resize_obj, &minw, &minh); + (wd->resize_obj, &minw, &minh); evas_object_size_hint_max_get - (ELM_WIDGET_DATA(sd)->resize_obj, &maxw, &maxh); + (wd->resize_obj, &maxw, &maxh); evas_object_size_hint_min_set(obj, minw, minh); evas_object_size_hint_max_set(obj, maxw, maxh); evas_object_geometry_get(obj, NULL, NULL, &w, &h); @@ -133,21 +161,26 @@ _on_size_hints_changed(void *data, _sizing_eval(data); } -static Eina_Bool -_elm_table_smart_sub_object_del(Evas_Object *obj, - Evas_Object *child) +static void +_elm_table_sub_object_del(Eo *obj, void *_pd EINA_UNUSED, va_list *list) { - if (!_elm_table_parent_sc->sub_object_del(obj, child)) return EINA_FALSE; + Evas_Object *child = va_arg(*list, Evas_Object *); + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + if (ret) *ret = EINA_FALSE; + Eina_Bool int_ret; + + eo_do_super(obj, elm_wdg_sub_object_del(child, &int_ret)); + if (!int_ret) return; _sizing_eval(obj); - return EINA_TRUE; + if (ret) *ret = EINA_TRUE; } static void -_elm_table_smart_add(Evas_Object *obj) +_elm_table_smart_add(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) { - EVAS_SMART_DATA_ALLOC(obj, Elm_Widget_Smart_Data); + Elm_Widget_Smart_Data *priv = eo_data_get(obj, ELM_OBJ_WIDGET_CLASS); priv->resize_obj = evas_object_table_add(evas_object_evas_get(obj)); @@ -155,101 +188,93 @@ _elm_table_smart_add(Evas_Object *obj) (priv->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_size_hints_changed, obj); - _elm_table_parent_sc->base.add(obj); + eo_do_super(obj, evas_obj_smart_add()); elm_widget_can_focus_set(obj, EINA_FALSE); elm_widget_highlight_ignore_set(obj, EINA_FALSE); - _elm_table_smart_theme(obj); + eo_do(obj, elm_wdg_theme(NULL)); } static void -_elm_table_smart_del(Evas_Object *obj) +_elm_table_smart_del(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) { Eina_List *l; Evas_Object *child; - ELM_TABLE_DATA_GET(obj, sd); + ELM_WIDGET_DATA_GET(obj, wd); evas_object_event_callback_del_full - (ELM_WIDGET_DATA(sd)->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, + (wd->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_size_hints_changed, obj); /* let's make our table object the *last* to be processed, since it * may (smart) parent other sub objects here */ - EINA_LIST_FOREACH(ELM_WIDGET_DATA(sd)->subobjs, l, child) + EINA_LIST_FOREACH(wd->subobjs, l, child) { - if (child == ELM_WIDGET_DATA(sd)->resize_obj) + if (child == wd->resize_obj) { - ELM_WIDGET_DATA(sd)->subobjs = - eina_list_demote_list(ELM_WIDGET_DATA(sd)->subobjs, l); + wd->subobjs = + eina_list_demote_list(wd->subobjs, l); break; } } - _elm_table_parent_sc->base.del(obj); -} - -static void -_elm_table_smart_set_user(Elm_Table_Smart_Class *sc) -{ - ELM_WIDGET_CLASS(sc)->base.add = _elm_table_smart_add; - ELM_WIDGET_CLASS(sc)->base.del = _elm_table_smart_del; - ELM_WIDGET_CLASS(sc)->sub_object_del = _elm_table_smart_sub_object_del; - ELM_WIDGET_CLASS(sc)->theme = _elm_table_smart_theme; - ELM_WIDGET_CLASS(sc)->focus_next = _elm_table_smart_focus_next; - ELM_WIDGET_CLASS(sc)->focus_direction = _elm_table_smart_focus_direction; -} - -EAPI const Elm_Table_Smart_Class * -elm_table_smart_class_get(void) -{ - static Elm_Table_Smart_Class _sc = - ELM_TABLE_SMART_CLASS_INIT_NAME_VERSION(ELM_TABLE_SMART_NAME); - static const Elm_Table_Smart_Class *class = NULL; - - if (class) return class; - - _elm_table_smart_set(&_sc); - class = &_sc; - - return class; + eo_do_super(obj, evas_obj_smart_del()); } EAPI Evas_Object * elm_table_add(Evas_Object *parent) { - Evas_Object *obj; - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - - obj = elm_widget_add(_elm_table_smart_class_new(), parent); - if (!obj) return NULL; - - if (!elm_widget_sub_object_add(parent, obj)) - ERR("could not add %p as sub object of %p", obj, parent); - + Evas_Object *obj = eo_add(MY_CLASS, parent); + eo_unref(obj); return obj; } +static void +_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) +{ + eo_do_super(obj, eo_constructor()); + eo_do(obj, + evas_obj_type_set(MY_CLASS_NAME)); + if (!elm_widget_sub_object_add(eo_parent_get(obj), obj)) + ERR("could not add %p as sub object of %p", obj, eo_parent_get(obj)); +} + EAPI void elm_table_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous) { ELM_TABLE_CHECK(obj); - ELM_TABLE_DATA_GET(obj, sd); + eo_do(obj, elm_obj_table_homogeneous_set(homogeneous)); +} + +static void +_homogeneous_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Eina_Bool homogeneous = va_arg(*list, int); + ELM_WIDGET_DATA_GET(obj, wd); evas_object_table_homogeneous_set - (ELM_WIDGET_DATA(sd)->resize_obj, homogeneous); + (wd->resize_obj, homogeneous); } EAPI Eina_Bool elm_table_homogeneous_get(const Evas_Object *obj) { ELM_TABLE_CHECK(obj) EINA_FALSE; - ELM_TABLE_DATA_GET(obj, sd); + Eina_Bool ret = EINA_FALSE; + eo_do((Eo *) obj, elm_obj_table_homogeneous_get(&ret)); + return ret; +} - return evas_object_table_homogeneous_get(ELM_WIDGET_DATA(sd)->resize_obj); +static void +_homogeneous_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Eina_Bool *ret = va_arg(*list, Eina_Bool *); + ELM_WIDGET_DATA_GET(obj, wd); + *ret = evas_object_table_homogeneous_get(wd->resize_obj); } EAPI void @@ -258,10 +283,18 @@ elm_table_padding_set(Evas_Object *obj, Evas_Coord vertical) { ELM_TABLE_CHECK(obj); - ELM_TABLE_DATA_GET(obj, sd); + eo_do(obj, elm_obj_table_padding_set(horizontal, vertical)); +} + +static void +_padding_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Evas_Coord horizontal = va_arg(*list, Evas_Coord); + Evas_Coord vertical = va_arg(*list, Evas_Coord); + ELM_WIDGET_DATA_GET(obj, wd); evas_object_table_padding_set - (ELM_WIDGET_DATA(sd)->resize_obj, horizontal, vertical); + (wd->resize_obj, horizontal, vertical); } EAPI void @@ -270,10 +303,18 @@ elm_table_padding_get(const Evas_Object *obj, Evas_Coord *vertical) { ELM_TABLE_CHECK(obj); - ELM_TABLE_DATA_GET(obj, sd); + eo_do((Eo *) obj, elm_obj_table_padding_get(horizontal, vertical)); +} + +static void +_padding_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Evas_Coord *horizontal = va_arg(*list, Evas_Coord *); + Evas_Coord *vertical = va_arg(*list, Evas_Coord *); + ELM_WIDGET_DATA_GET(obj, wd); evas_object_table_padding_get - (ELM_WIDGET_DATA(sd)->resize_obj, horizontal, vertical); + (wd->resize_obj, horizontal, vertical); } EAPI void @@ -285,10 +326,21 @@ elm_table_pack(Evas_Object *obj, int h) { ELM_TABLE_CHECK(obj); - ELM_TABLE_DATA_GET(obj, sd); + eo_do(obj, elm_obj_table_pack(subobj, x, y, w, h)); +} + +static void +_pack(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Evas_Object *subobj = va_arg(*list, Evas_Object *); + int x = va_arg(*list, int); + int y = va_arg(*list, int); + int w = va_arg(*list, int); + int h = va_arg(*list, int); + ELM_WIDGET_DATA_GET(obj, wd); elm_widget_sub_object_add(obj, subobj); - evas_object_table_pack(ELM_WIDGET_DATA(sd)->resize_obj, subobj, x, y, w, h); + evas_object_table_pack(wd->resize_obj, subobj, x, y, w, h); } EAPI void @@ -296,10 +348,17 @@ elm_table_unpack(Evas_Object *obj, Evas_Object *subobj) { ELM_TABLE_CHECK(obj); - ELM_TABLE_DATA_GET(obj, sd); + eo_do(obj, elm_obj_table_unpack(subobj)); +} + +static void +_unpack(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Evas_Object *subobj = va_arg(*list, Evas_Object *); + ELM_WIDGET_DATA_GET(obj, wd); elm_widget_sub_object_del(obj, subobj); - evas_object_table_unpack(ELM_WIDGET_DATA(sd)->resize_obj, subobj); + evas_object_table_unpack(wd->resize_obj, subobj); } EAPI void @@ -312,9 +371,21 @@ elm_table_pack_set(Evas_Object *subobj, Evas_Object *obj = elm_widget_parent_widget_get(subobj); ELM_TABLE_CHECK(obj); - ELM_TABLE_DATA_GET(obj, sd); + eo_do(obj, elm_obj_table_pack_set(subobj, x, y, w, h)); +} + +static void +_pack_set(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Evas_Object *subobj = va_arg(*list, Evas_Object *); + int x = va_arg(*list, int); + int y = va_arg(*list, int); + int w = va_arg(*list, int); + int h = va_arg(*list, int); + + ELM_WIDGET_DATA_GET(obj, wd); - evas_object_table_pack(ELM_WIDGET_DATA(sd)->resize_obj, subobj, x, y, w, h); + evas_object_table_pack(wd->resize_obj, subobj, x, y, w, h); } EAPI void @@ -325,13 +396,24 @@ elm_table_pack_get(Evas_Object *subobj, int *h) { Evas_Object *obj = elm_widget_parent_widget_get(subobj); - unsigned short ix, iy, iw, ih; - ELM_TABLE_CHECK(obj); - ELM_TABLE_DATA_GET(obj, sd); + eo_do(obj, elm_obj_table_pack_get(subobj, x, y, w, h)); +} + +static void +_pack_get(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Evas_Object *subobj = va_arg(*list, Evas_Object *); + int *x = va_arg(*list, int *); + int *y = va_arg(*list, int *); + int *w = va_arg(*list, int *); + int *h = va_arg(*list, int *); + + unsigned short ix, iy, iw, ih; + ELM_WIDGET_DATA_GET(obj, wd); evas_object_table_pack_get - (ELM_WIDGET_DATA(sd)->resize_obj, subobj, &ix, &iy, &iw, &ih); + (wd->resize_obj, subobj, &ix, &iy, &iw, &ih); if (x) *x = ix; if (y) *y = iy; if (w) *w = iw; @@ -343,7 +425,71 @@ elm_table_clear(Evas_Object *obj, Eina_Bool clear) { ELM_TABLE_CHECK(obj); - ELM_TABLE_DATA_GET(obj, sd); + eo_do(obj, elm_obj_table_clear(clear)); +} + +static void +_clear(Eo *obj, void *_pd EINA_UNUSED, va_list *list) +{ + Eina_Bool clear = va_arg(*list, int); + ELM_WIDGET_DATA_GET(obj, wd); + + evas_object_table_clear(wd->resize_obj, clear); +} - evas_object_table_clear(ELM_WIDGET_DATA(sd)->resize_obj, clear); +static void +_class_constructor(Eo_Class *klass) +{ + const Eo_Op_Func_Description func_desc[] = { + EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), + + EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_table_smart_add), + EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_DEL), _elm_table_smart_del), + + EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_table_smart_theme), + EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_NEXT_MANAGER_IS), _elm_table_smart_focus_next_manager_is), + EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_NEXT), _elm_table_smart_focus_next), + EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_table_smart_focus_direction_manager_is), + EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_DIRECTION), _elm_table_smart_focus_direction), + EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_SUB_OBJECT_DEL), _elm_table_sub_object_del), + + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_HOMOGENEOUS_SET), _homogeneous_set), + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_HOMOGENEOUS_GET), _homogeneous_get), + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_PADDING_SET), _padding_set), + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_PADDING_GET), _padding_get), + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_PACK), _pack), + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_UNPACK), _unpack), + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_PACK_SET), _pack_set), + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_PACK_GET), _pack_get), + EO_OP_FUNC(ELM_OBJ_TABLE_ID(ELM_OBJ_TABLE_SUB_ID_CLEAR), _clear), + EO_OP_FUNC_SENTINEL + }; + eo_class_funcs_set(klass, func_desc); } + +static const Eo_Op_Description op_desc[] = { + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_HOMOGENEOUS_SET, "Set the homogeneous layout in the table."), + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_HOMOGENEOUS_GET, "Get the current table homogeneous mode."), + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_PADDING_SET, "Set padding between cells."), + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_PADDING_GET, "Get padding between cells."), + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_PACK, "Add a subobject on the table with the coordinates passed."), + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_UNPACK, "Remove child from table."), + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_PACK_SET, "Set the packing location of an existing child of the table."), + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_PACK_GET, "Get the packing location of an existing child of the table."), + EO_OP_DESCRIPTION(ELM_OBJ_TABLE_SUB_ID_CLEAR, "Faster way to remove all child objects from a table object."), + EO_OP_DESCRIPTION_SENTINEL +}; + +static const Eo_Class_Description class_desc = { + EO_VERSION, + MY_CLASS_NAME, + EO_CLASS_TYPE_REGULAR, + EO_CLASS_DESCRIPTION_OPS(&ELM_OBJ_TABLE_BASE_ID, op_desc, ELM_OBJ_TABLE_SUB_ID_LAST), + NULL, + 0, + _class_constructor, + NULL +}; + +EO_DEFINE_CLASS(elm_obj_table_class_get, &class_desc, ELM_OBJ_WIDGET_CLASS, NULL); + |