diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 6c1d678490..dca49af7f9 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -26,11 +26,10 @@ efl_eolian_files = \ lib/efl/interfaces/efl_orientation.eo \ lib/efl/interfaces/efl_flipable.eo \ lib/efl/interfaces/efl_pack.eo \ - lib/efl/interfaces/efl_pack_engine.eo \ + lib/efl/interfaces/efl_pack_layout.eo \ lib/efl/interfaces/efl_pack_linear.eo \ lib/efl/interfaces/efl_pack_grid.eo \ lib/efl/interfaces/efl_pack_named.eo \ - lib/efl/interfaces/efl_pack_item.eo \ lib/efl/interfaces/efl_vpath.eo \ lib/efl/interfaces/efl_vpath_manager.eo \ lib/efl/interfaces/efl_vpath_file.eo \ diff --git a/src/bin/elementary/test_ui_box.c b/src/bin/elementary/test_ui_box.c index df7c1c339f..e23ca1f043 100644 --- a/src/bin/elementary/test_ui_box.c +++ b/src/bin/elementary/test_ui_box.c @@ -3,6 +3,7 @@ # include "elementary_config.h" #endif +#define EFL_PACK_LAYOUT_PROTECTED #include #include @@ -161,7 +162,7 @@ static void _custom_engine_layout_do(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Pack *pack, const void *data EINA_UNUSED) { - Eina_Iterator *it = efl_pack_contents_iterate(pack); + Eina_Iterator *it = efl_pack_contents_get(pack); int count = efl_pack_contents_count(pack), i = 0; int px, py, pw, ph; Eo *sobj; @@ -186,7 +187,7 @@ _custom_engine_layout_do(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, /* Common Eo Class boilerplate. */ static const Eo_Op_Description custom_engine_op_desc[] = { - EO_OP_CLASS_FUNC_OVERRIDE(efl_pack_engine_layout_do, _custom_engine_layout_do), + EO_OP_CLASS_FUNC_OVERRIDE(efl_pack_layout_do, _custom_engine_layout_do), }; static const Eo_Class_Description custom_engine_class_desc = { @@ -194,7 +195,7 @@ static const Eo_Class_Description custom_engine_class_desc = { EO_CLASS_DESCRIPTION_OPS(custom_engine_op_desc), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(_test_ui_box_custom_engine_class_get, &custom_engine_class_desc, EFL_PACK_ENGINE_INTERFACE, NULL) +EO_DEFINE_CLASS(_test_ui_box_custom_engine_class_get, &custom_engine_class_desc, EFL_PACK_LAYOUT_INTERFACE, NULL) static Eina_Bool custom_check_cb(void *data, const Eo_Event *event) diff --git a/src/bin/elementary/test_ui_grid.c b/src/bin/elementary/test_ui_grid.c index 2d261f706e..7ab38fc2cf 100644 --- a/src/bin/elementary/test_ui_grid.c +++ b/src/bin/elementary/test_ui_grid.c @@ -1,6 +1,8 @@ #ifdef HAVE_CONFIG_H # include "elementary_config.h" #endif + +#define EFL_PACK_LAYOUT_PROTECTED #include static Evas_Object *objects[7] = {}; @@ -18,7 +20,7 @@ static void _custom_engine_layout_do(Eo *obj, void *pd, Efl_Pack *pack, const vo /* Common Eo Class boilerplate. */ static const Eo_Op_Description custom_engine_op_desc[] = { - EO_OP_CLASS_FUNC_OVERRIDE(efl_pack_engine_layout_do, _custom_engine_layout_do), + EO_OP_CLASS_FUNC_OVERRIDE(efl_pack_layout_do, _custom_engine_layout_do), }; static const Eo_Class_Description custom_engine_class_desc = { @@ -26,7 +28,7 @@ static const Eo_Class_Description custom_engine_class_desc = { EO_CLASS_DESCRIPTION_OPS(custom_engine_op_desc), NULL, 0, NULL, NULL }; -EO_DEFINE_CLASS(_test_ui_grid_custom_engine_class_get, &custom_engine_class_desc, EFL_PACK_ENGINE_INTERFACE, NULL) +EO_DEFINE_CLASS(_test_ui_grid_custom_engine_class_get, &custom_engine_class_desc, EFL_PACK_LAYOUT_INTERFACE, NULL) #define CUSTOM_ENGINE_CLASS _test_ui_grid_custom_engine_class_get() @@ -130,12 +132,12 @@ static Eina_Bool child_evt_cb(void *data, const Eo_Event *event) { Elm_Label *o = data; - Efl_Pack_Item *it = event->info; + Efl_Gfx_Base *it = event->info; int col, row, colspan, rowspan; char buf[64]; - efl_pack_child_position_get(event->obj, it, &col, &row, &colspan, &rowspan); - if (event->desc == EFL_PACK_EVENT_CHILD_ADDED) + efl_pack_grid_content_position_get(event->obj, it, &col, &row, &colspan, &rowspan); + if (event->desc == EFL_PACK_EVENT_CONTENT_ADDED) sprintf(buf, "pack %d,%d %dx%d", col, row, colspan, rowspan); else sprintf(buf, "unpack %d,%d %dx%d", col, row, colspan, rowspan); @@ -164,10 +166,10 @@ _custom_engine_layout_do(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, efl_pack_grid_size_get(pack, &cols, &rows); if (!cols || !rows) goto end; - it = efl_pack_contents_iterate(pack); + it = efl_pack_contents_get(pack); EINA_ITERATOR_FOREACH(it, item) { - if (efl_pack_child_position_get(pack, item, &c, &r, &cs, &rs)) + if (efl_pack_grid_content_position_get(pack, item, &c, &r, &cs, &rs)) { int x, y, mw, mh; @@ -414,8 +416,8 @@ test_ui_grid(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i efl_gfx_visible_set(o, 1); o = elm_label_add(win); - eo_event_callback_add(grid, EFL_PACK_EVENT_CHILD_ADDED, child_evt_cb, o); - eo_event_callback_add(grid, EFL_PACK_EVENT_CHILD_REMOVED, child_evt_cb, o); + eo_event_callback_add(grid, EFL_PACK_EVENT_CONTENT_ADDED, child_evt_cb, o); + eo_event_callback_add(grid, EFL_PACK_EVENT_CONTENT_REMOVED, child_evt_cb, o); evas_object_size_hint_align_set(o, 0.5, 0); evas_object_size_hint_weight_set(o, 1, 1); efl_pack(bx, o); @@ -596,8 +598,8 @@ test_ui_grid_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, efl_gfx_visible_set(o, 1); o = elm_label_add(win); - eo_event_callback_add(grid, EFL_PACK_EVENT_CHILD_ADDED, child_evt_cb, o); - eo_event_callback_add(grid, EFL_PACK_EVENT_CHILD_REMOVED, child_evt_cb, o); + eo_event_callback_add(grid, EFL_PACK_EVENT_CONTENT_ADDED, child_evt_cb, o); + eo_event_callback_add(grid, EFL_PACK_EVENT_CONTENT_REMOVED, child_evt_cb, o); evas_object_size_hint_align_set(o, 0.5, 0); evas_object_size_hint_weight_set(o, 1, 1); efl_pack(bx, o); @@ -612,7 +614,7 @@ test_ui_grid_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, efl_pack(vbox, f); efl_gfx_visible_set(f, 1); - efl_pack_columns_set(grid, 4); + efl_pack_grid_columns_set(grid, 4); efl_pack_directions_set(grid, EFL_ORIENT_RIGHT, EFL_ORIENT_DOWN); evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_object_content_set(f, grid); diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index f078e4157d..f1a02201dd 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -37,7 +37,7 @@ extern "C" { /* Add here all the required ifdef for any @protected method */ #ifdef EFL_EFL_BUILD -# define EFL_PACK_PROTECTED +# define EFL_PACK_LAYOUT_PROTECTED #endif /** @@ -117,9 +117,8 @@ static inline void efl_gfx_color16_type_set(Efl_Gfx_Color *color, #include "interfaces/efl_gfx.x" /* Packing & containers */ -#include "interfaces/efl_pack_item.eo.h" #include "interfaces/efl_pack.eo.h" -#include "interfaces/efl_pack_engine.eo.h" +#include "interfaces/efl_pack_layout.eo.h" #include "interfaces/efl_pack_linear.eo.h" #include "interfaces/efl_pack_grid.eo.h" #include "interfaces/efl_pack_named.eo.h" diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 05be37f44c..0899fd3947 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -34,11 +34,10 @@ EAPI const Eo_Event_Description _EFL_GFX_PATH_CHANGED = EO_EVENT_DESCRIPTION("Graphics path changed"); #include "interfaces/efl_pack.eo.c" -#include "interfaces/efl_pack_engine.eo.c" +#include "interfaces/efl_pack_layout.eo.c" #include "interfaces/efl_pack_linear.eo.c" #include "interfaces/efl_pack_grid.eo.c" #include "interfaces/efl_pack_named.eo.c" -#include "interfaces/efl_pack_item.eo.c" #include "interfaces/efl_model_base.eo.c" #include "interfaces/efl_animator.eo.c" diff --git a/src/lib/efl/interfaces/efl_pack.eo b/src/lib/efl/interfaces/efl_pack.eo index 2c9780fe0b..720ff4d670 100644 --- a/src/lib/efl/interfaces/efl_pack.eo +++ b/src/lib/efl/interfaces/efl_pack.eo @@ -1,37 +1,35 @@ import eina_types; -interface Efl.Pack (Efl.Pack_Item) +interface Efl.Pack (Efl.Gfx.Base) { [[API common to all UI container objects.]] legacy_prefix: null; methods { - /* should this actually just be the eo children list? */ - contents_iterate { - [[Begin iterating over this object's children.]] - return: free(own(iterator *), eina_iterator_free) @warn_unused; + contents_get { + [[Begin iterating over this object's contents.]] + return: free(own(iterator *), eina_iterator_free) @warn_unused; } contents_count { - [[returns the number of UI elements packed in this container.]] + [[Returns the number of UI elements packed in this container.]] return: int; } - clear { - [[removes all packed children, and unrefs them]] + pack_clear { + [[Removes all packed contents, and unreferences them.]] } unpack_all { - [[removes all packed children, without changing their refcount]] + [[Removes all packed contents, without unreferencing them. + + Use with caution. + ]] } unpack { - [[removes an existing item from the container, without unref. - - delete the item directly if you actually wanted to pop and unref - ]] + [[Removes an existing item from the container, without deleting it.]] return: bool; [[$false if $subobj wasn't a child or can't be removed]] params { - subobj: Efl.Pack_Item*; + subobj: own(Efl.Gfx.Base *); } } - /* FIXME: confusing? two meanings: named slot vs. append */ pack { [[Adds an item to this container. @@ -43,7 +41,7 @@ interface Efl.Pack (Efl.Pack_Item) failed, the object will be unrefed. ]] params { - subobj: Efl.Pack_Item*; + subobj: own(Efl.Gfx.Base *); } } @property pack_align { @@ -55,7 +53,7 @@ interface Efl.Pack (Efl.Pack_Item) align_vert: double; } } - @property padding { + @property pack_padding { [[Padding between items contained in this object.]] set {} get {} @@ -65,36 +63,10 @@ interface Efl.Pack (Efl.Pack_Item) scalable: bool; } } - @property layout_engine { - [[Implementation of this container's layout algorithm. - - The default value is the same as the widget class (eg. Efl.Ui.Box). - ]] - set { return: bool; } - get {} - values { - engine: const(Eo.Class)*; [[A class implementing a class function layout_do.]] - data: const(void)*; [[Any data to pass along to layout_do. - Owned by the caller. Depends on the layout engine.]] - } - } - layout_update @protected { - [[Implementation of this container's layout algorithm. - - EFL will call this function whenever the contents of this - container need to be re-layed out on the canvas. - - This can be overriden to implement highly specific layout - behaviours. - ]] - } - layout_request { - [[Requests EFL to call the @.layout_update method on this object.]] - } } events { - child,added: Efl.Pack_Item*; [[sent after a new item was added]] - child,removed: Efl.Pack_Item*; [[sent after an item was removed, may happen after unref]] - layout,updated; [[sent after the layout was updated]] + content,added: Efl.Gfx.Base*; [[Sent after a new item was added.]] + content,removed: Efl.Gfx.Base*; [[Sent after an item was removed, before unref.]] + layout,updated; [[Sent after the layout was updated.]] } } diff --git a/src/lib/efl/interfaces/efl_pack_engine.eo b/src/lib/efl/interfaces/efl_pack_engine.eo deleted file mode 100644 index f12bc11911..0000000000 --- a/src/lib/efl/interfaces/efl_pack_engine.eo +++ /dev/null @@ -1,12 +0,0 @@ -interface Efl.Pack_Engine -{ - legacy_prefix: null; - methods { - layout_do @class { - params { - pack: Efl.Pack*; - data: const(void)*; - } - } - } -} diff --git a/src/lib/efl/interfaces/efl_pack_grid.eo b/src/lib/efl/interfaces/efl_pack_grid.eo index 2ca2c0d5d0..b1c235bee9 100644 --- a/src/lib/efl/interfaces/efl_pack_grid.eo +++ b/src/lib/efl/interfaces/efl_pack_grid.eo @@ -8,37 +8,36 @@ interface Efl.Pack_Grid (Efl.Pack_Linear) methods { pack_grid { params { - subobj: Efl.Pack_Item *; + subobj: own(Efl.Gfx.Base *); col: int; row: int; - colspan: int @optional; [[0 means 1, -1 means @.columns]] - rowspan: int @optional; [[0 means 1, -1 means @.rows]] + colspan: int @optional; [[0 means 1, -1 means @.grid_columns]] + rowspan: int @optional; [[0 means 1, -1 means @.grid_rows]] } } - pack_children_at { - [[grids can have overlapping children - returns a list because - we expect only few items per cell - ]] - return: free(own(list *), eina_list_free); + grid_contents_at { + [[Returns all objects at a given position in this grid.]] + return: free(own(iterator *), eina_iterator_free); + params { + @in col: int; + @in row: int; + @in below: bool @optional; [[If $true get objects spanning over this cell.]] + } + } + grid_content_at { + [[Returns the first child at position, see @.grid_contents_at.]] + return: Efl.Gfx.Base*; params { @in col: int; @in row: int; } } - pack_child_at { - [[returns the top child at position. see also @.pack_children_at]] - return: Efl.Pack_Item*; - params { - @in col: int; - @in row: int; - } - } - @property pack_child_position { + @property grid_content_position { [[position and span of the $subobj in this container, may be modified to move the $subobj]] set { [[same as grid_pack]] } get { return: bool; [[returns false if item is not a child]] } keys { - subobj: Efl.Pack_Item*; + subobj: Efl.Gfx.Base*; } values { col: int; @@ -47,9 +46,8 @@ interface Efl.Pack_Grid (Efl.Pack_Linear) rowspan: int; } } - /* FIXME: the below SET apis need to be well defined. they are not. yet */ @property grid_size { - [[combines @.columns and @.rows]] + [[Combines @.grid_columns and @.grid_rows]] set {} get {} values { @@ -57,23 +55,24 @@ interface Efl.Pack_Grid (Efl.Pack_Linear) rows: int; } } - @property columns { - set { [[specifies limit for linear adds - if direction is horizontal]] } + @property grid_columns { + set { [[Specifies limit for linear adds - if direction is horizontal]] } get {} values { cols: int; } } - @property rows { - set { [[specifies limit for linear adds - if direction is vertical]] } + @property grid_rows { + set { [[Specifies limit for linear adds - if direction is vertical]] } get {} values { rows: int; } } @property directions { - [[primary and secondary up/left/right/down orientation for linear apis. default is right and down - overrides @Efl.Pack_Linear.direction + [[Primary and secondary up/left/right/down orientations for linear apis. + + Default is right and down. Overrides @Efl.Pack_Linear.direction. ]] set {} get {} diff --git a/src/lib/efl/interfaces/efl_pack_item.eo b/src/lib/efl/interfaces/efl_pack_item.eo deleted file mode 100644 index 83c1105220..0000000000 --- a/src/lib/efl/interfaces/efl_pack_item.eo +++ /dev/null @@ -1,6 +0,0 @@ -/* FIXME: this is not necessary - just use efl.gfx.base */ -interface Efl.Pack_Item -{ - [[Describes an item that can be packed in a container.]] - legacy_prefix: null; -} diff --git a/src/lib/efl/interfaces/efl_pack_layout.eo b/src/lib/efl/interfaces/efl_pack_layout.eo new file mode 100644 index 0000000000..dbae2ee218 --- /dev/null +++ b/src/lib/efl/interfaces/efl_pack_layout.eo @@ -0,0 +1,45 @@ +interface Efl.Pack_Layout () +{ + [[Low-level APIs for object that can lay their children out. + + Used for containers (box, grid). + ]] + legacy_prefix: null; + eo_prefix: efl_pack; + methods { + @property layout_engine { + [[Implementation of this container's layout algorithm. + + The default value is the same as the widget class. + ]] + set {} + get {} + values { + /* FIXME: engine is an Eo.Class */ + engine: const(Eo.Base)*; [[Must be an $Efl.Pack_Layout subclass.]] + data: const(void)*; [[Any data to pass along to $Efl.Pack_Layout.layout_do. + Owned by the caller. Depends on the layout engine.]] + } + } + layout_request { + [[Requests EFL to call the @.layout_update method on this object.]] + } + layout_update @protected { + [[Implementation of this container's layout algorithm. + + EFL will call this function whenever the contents of this + container need to be re-layed out on the canvas. + + This can be overriden to implement highly specific layout + behaviours. + ]] + } + layout_do @class @protected { + [[Lay out (resize and move) children objects of $pack.]] + params { + pack: Efl.Gfx.Base*; [[The container to lay out.]] + data: const(void)* @optional; [[Extra data passed by the caller.]] + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_pack_linear.eo b/src/lib/efl/interfaces/efl_pack_linear.eo index 301fa3121b..3859470baa 100644 --- a/src/lib/efl/interfaces/efl_pack_linear.eo +++ b/src/lib/efl/interfaces/efl_pack_linear.eo @@ -1,3 +1,5 @@ +import efl_orientation; + /* FIXME: Efl.Pack.Linear */ interface Efl.Pack_Linear (Efl.Pack) { @@ -6,58 +8,77 @@ interface Efl.Pack_Linear (Efl.Pack) eo_prefix: efl_pack; methods { pack_begin { - [[prepend, same as $pack_at($subobj, 0)]] + [[Prepend an object at the beginning of this container. + + This is the same as @.pack_insert($subobj, 0). + ]] params { - @in subobj: Efl.Pack_Item*; + @in subobj: own(Efl.Gfx.Base *); } } pack_end { - [[prepend, same as $pack_at($subobj, -1)]] + [[Append object at the end of this container. + + This is the same as @.pack_insert($subobj, -1). + ]] params { - @in subobj: Efl.Pack_Item*; + @in subobj: own(Efl.Gfx.Base *); } } pack_before { - [[prepend before other subobj]] + [[Prepend item before other sub object.]] return: bool @warn_unused; [[returns $false if $existing could not be found]] params { - @in subobj: Efl.Pack_Item*; - @in existing: const(Efl.Pack_Item)*; + @in subobj: own(Efl.Gfx.Base *); + @in existing: const(Efl.Gfx.Base)*; } } pack_after { - [[append after other subobj]] + [[Append item after other sub object.]] return: bool @warn_unused; [[returns $false if $existing could not be found]] params { - @in subobj: Efl.Pack_Item*; - @in existing: const(Efl.Pack_Item)*; + @in subobj: own(Efl.Gfx.Base *); + @in existing: const(Efl.Gfx.Base)*; } } - @property child_at { - set { [[Insert child at a specified index.]] } + pack_insert { + [[Inserts $subobj at the specified $index. If $index is not valid, appends.]] + params { + @in subobj: own(Efl.Gfx.Base *); + @in index: int; + } + } + @property content_at { + [[Content at a given index in this container. + + Index -1 refers to the last item. + ]] + /* set {} - can be defined */ get {} keys { index: int; } values { - subobj: Efl.Pack_Item *; + subobj: Efl.Gfx.Base *; } } - @property child_index { - [[index of the $subobj in this container, may be modified to move the $subobj]] + @property content_index { + [[Index of the child in this container, may be modified to move the $subobj.]] set { - return: bool; [[returns $false if $subobj is not a child]] + + return: bool; [[Returns $false if $subobj is not a child. + Negative values can be used to refer to the end.]] } get {} keys { - subobj: const(Efl.Pack_Item *); + subobj: Efl.Gfx.Base *; } values { index: int; } } @property direction { - [[primary up/left/right/down orientation for linear apis. default is right]] + [[Primary up/left/right/down orientation. Default is right.]] set {} get {} values { diff --git a/src/lib/efl/interfaces/efl_pack_named.eo b/src/lib/efl/interfaces/efl_pack_named.eo index eadb503cb6..3c71ef8b45 100644 --- a/src/lib/efl/interfaces/efl_pack_named.eo +++ b/src/lib/efl/interfaces/efl_pack_named.eo @@ -8,9 +8,8 @@ interface Efl.Pack_Named (Efl.Pack) [[Insert element in a named spot (swallow, part).]] params { part: const(char) *; - subobj: Efl.Pack_Item *; + subobj: Efl.Gfx.Base *; } } - } } diff --git a/src/lib/elementary/efl_ui_box.c b/src/lib/elementary/efl_ui_box.c index 79fb089972..d89ff204c6 100644 --- a/src/lib/elementary/efl_ui_box.c +++ b/src/lib/elementary/efl_ui_box.c @@ -19,6 +19,7 @@ static void * _efl_ui_box_list_data_get(const Eina_List *list) { Evas_Object_Box_Option *opt = eina_list_data_get(list); + return opt->obj; } @@ -27,7 +28,8 @@ _child_added_cb_proxy(void *data, const Eo_Event *event) { Evas_Object *box = data; Evas_Object_Box_Option *opt = event->info; - eo_event_callback_call(box, EFL_PACK_EVENT_CHILD_ADDED, opt->obj); + + eo_event_callback_call(box, EFL_PACK_EVENT_CONTENT_ADDED, opt->obj); return EINA_TRUE; } @@ -37,7 +39,8 @@ _child_removed_cb_proxy(void *data, const Eo_Event *event) { Evas_Object *box = data; Evas_Object *child = event->info; - eo_event_callback_call(box, EFL_PACK_EVENT_CHILD_REMOVED, child); + + eo_event_callback_call(box, EFL_PACK_EVENT_CONTENT_REMOVED, child); return EINA_TRUE; } @@ -62,7 +65,7 @@ _efl_ui_box_elm_widget_focus_next(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED, Elm { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); Evas_Object_Box_Data *bd = - evas_object_smart_data_get(wd->resize_obj); + evas_object_smart_data_get(wd->resize_obj); items = bd->children; list_data_get = _efl_ui_box_list_data_get; @@ -91,7 +94,7 @@ _efl_ui_box_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data *_pd { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); Evas_Object_Box_Data *bd = - evas_object_smart_data_get(wd->resize_obj); + evas_object_smart_data_get(wd->resize_obj); items = bd->children; list_data_get = _efl_ui_box_list_data_get; @@ -99,7 +102,7 @@ _efl_ui_box_elm_widget_focus_direction(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data *_pd if (!items) return EINA_FALSE; } return elm_widget_focus_list_direction_get - (obj, base, items, list_data_get, degree, direction, direction_item, weight); + (obj, base, items, list_data_get, degree, direction, direction_item, weight); } static void @@ -136,7 +139,7 @@ _on_size_hints_changed(void *data, Evas *e EINA_UNUSED, if (obj == resizeobj) efl_pack_layout_request(obj); else - _sizing_eval(data, pd); + _sizing_eval(data, pd); } static void @@ -149,38 +152,37 @@ _evas_box_custom_layout(Evas_Object *evas_box EINA_UNUSED, } EOLIAN static void -_efl_ui_box_efl_pack_layout_update(Eo *obj, Efl_Ui_Box_Data *pd) +_efl_ui_box_efl_pack_layout_layout_update(Eo *obj, Efl_Ui_Box_Data *pd) { - efl_pack_engine_layout_do(pd->layout_engine, obj, pd->layout_data); + efl_pack_layout_do(pd->layout_engine, obj, pd->layout_data); eo_event_callback_call(obj, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL); } EOLIAN static void -_efl_ui_box_efl_pack_engine_layout_do(Eo *klass EINA_UNUSED, +_efl_ui_box_efl_pack_layout_layout_do(Eo *klass EINA_UNUSED, void *_pd EINA_UNUSED, Eo *obj, const void *data EINA_UNUSED) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); Evas_Object_Box_Data *bd; - bd = eo_data_scope_get(wd->resize_obj, EVAS_BOX_CLASS); + bd = evas_object_smart_data_get(wd->resize_obj); _efl_ui_box_custom_layout(obj, bd); } -EOLIAN static Eina_Bool -_efl_ui_box_efl_pack_layout_engine_set(Eo *obj, Efl_Ui_Box_Data *pd, - const Eo_Class *klass, const void *data) +EOLIAN static void +_efl_ui_box_efl_pack_layout_layout_engine_set(Eo *obj, Efl_Ui_Box_Data *pd, + const Eo_Class *klass, const void *data) { pd->layout_engine = klass ? klass : eo_class_get(obj); pd->layout_data = data; efl_pack_layout_request(obj); _sizing_eval(obj, pd); - return EINA_TRUE; } EOLIAN static void -_efl_ui_box_efl_pack_layout_engine_get(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data *pd, - const Eo_Class **klass, const void **data) +_efl_ui_box_efl_pack_layout_layout_engine_get(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data *pd, + const Eo_Class **klass, const void **data) { if (klass) *klass = pd->layout_engine; if (data) *data = pd->layout_data; @@ -213,8 +215,8 @@ _efl_ui_box_evas_object_smart_add(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED) evas_obj_smart_add(eo_super(obj, MY_CLASS)); elm_widget_sub_object_parent_add(obj); - eo_event_callback_add(wd->resize_obj, EFL_PACK_EVENT_CHILD_ADDED, _child_added_cb_proxy, obj); - eo_event_callback_add(wd->resize_obj, EFL_PACK_EVENT_CHILD_REMOVED, _child_removed_cb_proxy, obj); + eo_event_callback_add(wd->resize_obj, EVAS_BOX_EVENT_CHILD_ADDED, _child_added_cb_proxy, obj); + eo_event_callback_add(wd->resize_obj, EVAS_BOX_EVENT_CHILD_REMOVED, _child_removed_cb_proxy, obj); elm_widget_can_focus_set(obj, EINA_FALSE); elm_widget_highlight_ignore_set(obj, EINA_TRUE); @@ -233,8 +235,8 @@ _efl_ui_box_evas_object_smart_del(Eo *obj, Efl_Ui_Box_Data *sd) ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); evas_object_event_callback_del_full - (wd->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, - _on_size_hints_changed, obj); + (wd->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, + _on_size_hints_changed, obj); /* let's make our box object the *last* to be processed, since it * may (smart) parent other sub objects here */ @@ -243,7 +245,7 @@ _efl_ui_box_evas_object_smart_del(Eo *obj, Efl_Ui_Box_Data *sd) if (child == wd->resize_obj) { wd->subobjs = - eina_list_demote_list(wd->subobjs, l); + eina_list_demote_list(wd->subobjs, l); break; } } @@ -251,14 +253,6 @@ _efl_ui_box_evas_object_smart_del(Eo *obj, Efl_Ui_Box_Data *sd) evas_obj_smart_del(eo_super(obj, MY_CLASS)); } -EAPI Evas_Object * -efl_ui_box_add(Evas_Object *parent) -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL); - Evas_Object *obj = eo_add(MY_CLASS, parent); - return obj; -} - EOLIAN static Eo * _efl_ui_box_eo_base_constructor(Eo *obj, Efl_Ui_Box_Data *pd) { @@ -290,11 +284,12 @@ _efl_ui_box_efl_pack_contents_count(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED) } EOLIAN static void -_efl_ui_box_efl_pack_clear(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED) +_efl_ui_box_efl_pack_pack_clear(Eo *obj, Efl_Ui_Box_Data *pd) { - /* EINA_TRUE means to delete objects as well */ ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + evas_object_box_remove_all(wd->resize_obj, EINA_TRUE); + _sizing_eval(obj, pd); } EOLIAN static void @@ -312,14 +307,12 @@ _efl_ui_box_efl_pack_unpack_all(Eo *obj, Efl_Ui_Box_Data *pd) elm_widget_sub_object_del(obj, opt->obj); pd->delete_me = EINA_FALSE; - /* EINA_FALSE means do not delete objects */ evas_object_box_remove_all(wd->resize_obj, EINA_FALSE); - /* update size hints */ _sizing_eval(obj, pd); } EOLIAN static Eina_Bool -_efl_ui_box_efl_pack_unpack(Eo *obj, Efl_Ui_Box_Data *pd, Efl_Pack_Item *subobj) +_efl_ui_box_efl_pack_unpack(Eo *obj, Efl_Ui_Box_Data *pd, Efl_Gfx_Base *subobj) { Eina_Bool ret = EINA_FALSE; ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); @@ -334,13 +327,13 @@ _efl_ui_box_efl_pack_unpack(Eo *obj, Efl_Ui_Box_Data *pd, Efl_Pack_Item *subobj) } EOLIAN static void -_efl_ui_box_efl_pack_pack(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, Efl_Pack_Item *subobj) +_efl_ui_box_efl_pack_pack(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, Efl_Gfx_Base *subobj) { efl_pack_end(obj, subobj); } EOLIAN static void -_efl_ui_box_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, Efl_Pack_Item *subobj) +_efl_ui_box_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, Efl_Gfx_Base *subobj) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -349,7 +342,7 @@ _efl_ui_box_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, E } EOLIAN static void -_efl_ui_box_efl_pack_linear_pack_begin(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED, Efl_Pack_Item *subobj) +_efl_ui_box_efl_pack_linear_pack_begin(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED, Efl_Gfx_Base *subobj) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -358,7 +351,7 @@ _efl_ui_box_efl_pack_linear_pack_begin(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED } EOLIAN static Eina_Bool -_efl_ui_box_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED, Efl_Pack_Item *subobj, const Efl_Pack_Item *existing) +_efl_ui_box_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED, Efl_Gfx_Base *subobj, const Efl_Gfx_Base *existing) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); @@ -375,7 +368,7 @@ _efl_ui_box_efl_pack_linear_pack_before(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSE } EOLIAN static Eina_Bool -_efl_ui_box_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED, Efl_Pack_Item *subobj, const Efl_Pack_Item *existing) +_efl_ui_box_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED, Efl_Gfx_Base *subobj, const Efl_Gfx_Base *existing) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); @@ -391,14 +384,42 @@ _efl_ui_box_efl_pack_linear_pack_after(Eo *obj, Efl_Ui_Box_Data *_pd EINA_UNUSED return EINA_TRUE; } -static inline Efl_Pack_Item * +EOLIAN static void +_efl_ui_box_efl_pack_linear_pack_insert(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, + Efl_Gfx_Base *subobj, int index) +{ + if (!index) + efl_pack_begin(obj, subobj); + else if (index == -1) + efl_pack_end(obj, subobj); + else + { + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); + Evas_Object_Box_Data *bd; + int cnt; + + bd = evas_object_smart_data_get(wd->resize_obj); + cnt = eina_list_count(bd ? bd->children : NULL); + if (!cnt) + index = 0; + else + { + index %= cnt; + if (index < 0) index += cnt; + } + evas_object_box_insert_at(wd->resize_obj, subobj, index); + } +} + +static inline Efl_Gfx_Base * _box_item(Evas_Object_Box_Option *opt) { return opt ? opt->obj : NULL; } -EOLIAN static Efl_Pack_Item * -_efl_ui_box_efl_pack_linear_child_at_get(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, int index) +EOLIAN static Efl_Gfx_Base * +_efl_ui_box_efl_pack_linear_content_at_get(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, + int index) { Evas_Object_Box_Data *bd; int cnt; @@ -415,7 +436,7 @@ _efl_ui_box_efl_pack_linear_child_at_get(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSE cnt = eina_list_count(bd->children); if (!cnt) return NULL; - if (index >= cnt) + if (index >= (cnt - 1)) return _box_item(eina_list_last_data_get(bd->children)); else if (index <= (-cnt)) return _box_item(eina_list_data_get(bd->children)); @@ -427,25 +448,64 @@ _efl_ui_box_efl_pack_linear_child_at_get(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSE return _box_item(eina_list_nth(bd->children, index)); } -EOLIAN static void -_efl_ui_box_efl_pack_linear_child_at_set(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, int index, Efl_Pack_Item *subobj) +EOLIAN static int +_efl_ui_box_efl_pack_linear_content_index_get(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, + Efl_Gfx_Base *subobj) { - if (!index) - efl_pack_begin(obj, subobj); - else if (index == -1) - efl_pack_end(obj, subobj); - else + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, -1); + Evas_Object_Box_Data *bd; + Evas_Object_Box_Option *opt; + Eina_List *l; + int k = 0; + + if (evas_object_smart_parent_get(subobj) != wd->resize_obj) + goto end; + + bd = evas_object_smart_data_get(wd->resize_obj); + EINA_LIST_FOREACH(bd->children, l, opt) { - Efl_Pack_Item *other = efl_pack_child_at_get(obj, index); - if (!other) - efl_pack_end(obj, subobj); - else - efl_pack_after(obj, subobj, other); + if (opt->obj == subobj) + return k; + k++; } + +end: + ERR("object %p (%s) is not a child of %p (%s)", + subobj, eo_class_name_get(subobj), obj, eo_class_name_get(obj)); + return -1; +} + +EOLIAN static Eina_Bool +_efl_ui_box_efl_pack_linear_content_index_set(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED, + Efl_Gfx_Base *subobj, int index) +{ + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); + Evas_Object_Box_Data *bd; + int cnt; + + if (evas_object_smart_parent_get(subobj) != wd->resize_obj) + { + ERR("object %p (%s) is not a child of %p (%s)", + subobj, eo_class_name_get(subobj), obj, eo_class_name_get(obj)); + return EINA_FALSE; + } + + bd = evas_object_smart_data_get(wd->resize_obj); + cnt = eina_list_count(bd->children); + if (!cnt) + { + efl_pack(obj, subobj); + return EINA_TRUE; + } + + index %= cnt; + if (index < 0) index += index; + + return (evas_object_box_insert_at(wd->resize_obj, subobj, index) != NULL); } EOLIAN static void -_efl_ui_box_efl_pack_layout_request(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED) +_efl_ui_box_efl_pack_layout_layout_request(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED) { evas_object_smart_need_recalculate_set(obj, EINA_TRUE); } @@ -453,7 +513,7 @@ _efl_ui_box_efl_pack_layout_request(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED) static Eina_Bool _box_item_iterator_next(Box_Item_Iterator *it, void **data) { - Efl_Pack_Item *sub; + Efl_Gfx_Base *sub; if (!eina_iterator_next(it->real_iterator, (void **) &sub)) return EINA_FALSE; @@ -477,7 +537,7 @@ _box_item_iterator_free(Box_Item_Iterator *it) } EOLIAN static Eina_Iterator * -_efl_ui_box_efl_pack_contents_iterate(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED) +_efl_ui_box_efl_pack_contents_get(Eo *obj, Efl_Ui_Box_Data *pd EINA_UNUSED) { Box_Item_Iterator *it; @@ -510,7 +570,7 @@ _efl_ui_box_efl_pack_linear_direction_set(Eo *obj, Efl_Ui_Box_Data *pd, Efl_Orie break; case EFL_ORIENT_RIGHT: - //case EFL_ORIENT_LEFT: + //case EFL_ORIENT_LEFT: default: pd->orient = EFL_ORIENT_RIGHT; break; @@ -526,7 +586,7 @@ _efl_ui_box_efl_pack_linear_direction_get(Eo *obj EINA_UNUSED, Efl_Ui_Box_Data * } EOLIAN static void -_efl_ui_box_efl_pack_padding_set(Eo *obj, Efl_Ui_Box_Data *pd, double h, double v, Eina_Bool scalable) +_efl_ui_box_efl_pack_pack_padding_set(Eo *obj, Efl_Ui_Box_Data *pd, double h, double v, Eina_Bool scalable) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -542,11 +602,11 @@ _efl_ui_box_efl_pack_padding_set(Eo *obj, Efl_Ui_Box_Data *pd, double h, double evas_object_box_padding_set(wd->resize_obj, h * scale, v * scale); } else - evas_object_box_padding_set(wd->resize_obj, h, v); + evas_object_box_padding_set(wd->resize_obj, h, v); } EOLIAN static void -_efl_ui_box_efl_pack_padding_get(Eo *obj, Efl_Ui_Box_Data *pd, double *h, double *v, Eina_Bool *scalable) +_efl_ui_box_efl_pack_pack_padding_get(Eo *obj, Efl_Ui_Box_Data *pd, double *h, double *v, Eina_Bool *scalable) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); diff --git a/src/lib/elementary/efl_ui_box.eo b/src/lib/elementary/efl_ui_box.eo index 2ef5a76d1c..6e085a890e 100644 --- a/src/lib/elementary/efl_ui_box.eo +++ b/src/lib/elementary/efl_ui_box.eo @@ -1,10 +1,10 @@ -class Efl.Ui.Box (Elm.Widget, Efl.Pack_Engine, Efl.Pack_Linear) +class Efl.Ui.Box (Elm.Widget, Efl.Pack_Linear, Efl.Pack_Layout) { legacy_prefix: null; implements { Eo.Base.constructor; - // smart obj + // Smart obj Evas.Object_Smart.add; Evas.Object_Smart.del; Evas.Object_Smart.calculate; @@ -15,31 +15,33 @@ class Efl.Ui.Box (Elm.Widget, Efl.Pack_Engine, Efl.Pack_Linear) Elm.Widget.focus_direction_manager_is; Elm.Widget.focus_next; - Efl.Pack.contents_iterate; + // Packing interfaces + Efl.Pack.contents_get; Efl.Pack.contents_count; - Efl.Pack.clear; + Efl.Pack.pack_clear; Efl.Pack.unpack_all; Efl.Pack.unpack; Efl.Pack.pack; - Efl.Pack.padding.get; - Efl.Pack.padding.set; + Efl.Pack.pack_padding.get; + Efl.Pack.pack_padding.set; Efl.Pack.pack_align.get; Efl.Pack.pack_align.set; - Efl.Pack.layout_update; - Efl.Pack.layout_request; - Efl.Pack.layout_engine.get; - Efl.Pack.layout_engine.set; Efl.Pack_Linear.pack_begin; Efl.Pack_Linear.pack_end; Efl.Pack_Linear.pack_before; Efl.Pack_Linear.pack_after; - Efl.Pack_Linear.child_at.get; - Efl.Pack_Linear.child_at.set; - //Efl.Pack_Linear.child_index.get; - //Efl.Pack_Linear.child_index.set; + Efl.Pack_Linear.pack_insert; + Efl.Pack_Linear.content_at.get; + Efl.Pack_Linear.content_index.get; + Efl.Pack_Linear.content_index.set; Efl.Pack_Linear.direction.set; Efl.Pack_Linear.direction.get; - Efl.Pack_Engine.layout_do; + // Custom layouts + Efl.Pack_Layout.layout_update; + Efl.Pack_Layout.layout_request; + Efl.Pack_Layout.layout_engine.get; + Efl.Pack_Layout.layout_engine.set; + Efl.Pack_Layout.layout_do; } } diff --git a/src/lib/elementary/efl_ui_box_flow.c b/src/lib/elementary/efl_ui_box_flow.c index e3db2549a2..2dbc2cbdaa 100644 --- a/src/lib/elementary/efl_ui_box_flow.c +++ b/src/lib/elementary/efl_ui_box_flow.c @@ -42,7 +42,7 @@ _efl_ui_box_flow_box_flow_max_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Box_Flow_Data } EOLIAN static void -_efl_ui_box_flow_efl_pack_engine_layout_do(Eo_Class *klass EINA_UNUSED, +_efl_ui_box_flow_efl_pack_layout_layout_do(Eo_Class *klass EINA_UNUSED, void *_pd EINA_UNUSED, Eo *obj, const void *data) { diff --git a/src/lib/elementary/efl_ui_box_flow.eo b/src/lib/elementary/efl_ui_box_flow.eo index 9357a8e3ff..733e74259a 100644 --- a/src/lib/elementary/efl_ui_box_flow.eo +++ b/src/lib/elementary/efl_ui_box_flow.eo @@ -4,7 +4,7 @@ struct Efl.Ui.Box_Flow_Params { max_size: bool; } -class Efl.Ui.Box_Flow (Efl.Ui.Box, Efl.Pack_Engine) +class Efl.Ui.Box_Flow (Efl.Ui.Box, Efl.Pack_Layout) { [[A custom layout engine for @Efl.Ui.Box.]] legacy_prefix: null; @@ -26,6 +26,6 @@ class Efl.Ui.Box_Flow (Efl.Ui.Box, Efl.Pack_Engine) } implements { Eo.Base.constructor; - Efl.Pack_Engine.layout_do; + Efl.Pack_Layout.layout_do; } } diff --git a/src/lib/elementary/efl_ui_box_private.h b/src/lib/elementary/efl_ui_box_private.h index 39a7a64b7a..dcff646f11 100644 --- a/src/lib/elementary/efl_ui_box_private.h +++ b/src/lib/elementary/efl_ui_box_private.h @@ -5,7 +5,7 @@ # include "elementary_config.h" #endif -#define EFL_PACK_PROTECTED +#define EFL_PACK_LAYOUT_PROTECTED #include #include "elm_priv.h" diff --git a/src/lib/elementary/efl_ui_grid.c b/src/lib/elementary/efl_ui_grid.c index b8a7ee06a2..1a43e3278f 100644 --- a/src/lib/elementary/efl_ui_grid.c +++ b/src/lib/elementary/efl_ui_grid.c @@ -2,7 +2,7 @@ # include "elementary_config.h" #endif -#define EFL_PACK_PROTECTED +#define EFL_PACK_LAYOUT_PROTECTED #include #include "elm_priv.h" @@ -19,7 +19,7 @@ typedef struct _Grid_Item Grid_Item; typedef struct _Custom_Table_Data Custom_Table_Data; static Eina_Bool _subobj_del_cb(void *data, const Eo_Event *event); -static void _item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj); +static void _item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx_Base *subobj); #define GRID_ITEM_KEY "__grid_item" @@ -27,7 +27,7 @@ struct _Grid_Item { EINA_INLIST; - Efl_Pack_Item *object; + Efl_Gfx_Base *object; int col_span, row_span; int col, row; @@ -104,7 +104,7 @@ _efl_ui_grid_elm_widget_focus_next(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, El else { items = evas_object_table_children_get - (wd->resize_obj); + (wd->resize_obj); list_data_get = eina_list_data_get; list_free = eina_list_free; @@ -145,7 +145,7 @@ _efl_ui_grid_elm_widget_focus_direction(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSE else { items = evas_object_table_children_get - (wd->resize_obj); + (wd->resize_obj); list_data_get = eina_list_data_get; list_free = eina_list_free; @@ -153,7 +153,7 @@ _efl_ui_grid_elm_widget_focus_direction(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSE } int_ret = elm_widget_focus_list_direction_get - (obj, base, items, list_data_get, degree, direction, direction_item, weight); + (obj, base, items, list_data_get, degree, direction, direction_item, weight); if (list_free) list_free((Eina_List *)items); @@ -196,9 +196,9 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); evas_object_size_hint_min_get - (wd->resize_obj, &minw, &minh); + (wd->resize_obj, &minw, &minh); evas_object_size_hint_max_get - (wd->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); @@ -250,33 +250,32 @@ _custom_table_calc(Eo *obj, Custom_Table_Data *pd) } /* End of custom table class */ -EOLIAN Eina_Bool -_efl_ui_grid_efl_pack_layout_engine_set(Eo *obj, Efl_Ui_Grid_Data *pd, const Eo_Class *engine, const void *data) +EOLIAN static void +_efl_ui_grid_efl_pack_layout_layout_engine_set(Eo *obj, Efl_Ui_Grid_Data *pd, const Eo_Class *engine, const void *data) { pd->layout_engine = engine ? engine : eo_class_get(obj); pd->layout_data = data; efl_pack_layout_request(obj); - return EINA_TRUE; } -EOLIAN void -_efl_ui_grid_efl_pack_layout_engine_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd, const Eo_Class **engine, const void **data) +EOLIAN static void +_efl_ui_grid_efl_pack_layout_layout_engine_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd, const Eo_Class **engine, const void **data) { if (engine) *engine = pd->layout_engine; if (data) *data = pd->layout_data; } EOLIAN static void -_efl_ui_grid_efl_pack_layout_update(Eo *obj, Efl_Ui_Grid_Data *pd) +_efl_ui_grid_efl_pack_layout_layout_update(Eo *obj, Efl_Ui_Grid_Data *pd) { _sizing_eval(obj, pd); - efl_pack_engine_layout_do(pd->layout_engine, obj, pd->layout_data); + efl_pack_layout_do(pd->layout_engine, obj, pd->layout_data); } EOLIAN static void -_efl_ui_grid_efl_pack_engine_layout_do(Eo *klass EINA_UNUSED, - void *_pd EINA_UNUSED, - Eo *obj, const void *data EINA_UNUSED) +_efl_ui_grid_efl_pack_layout_layout_do(Eo *klass EINA_UNUSED, + void *_pd EINA_UNUSED, + Eo *obj, const void *data EINA_UNUSED) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -310,7 +309,7 @@ _efl_ui_grid_evas_object_smart_add(Eo *obj, Efl_Ui_Grid_Data *pd) elm_widget_resize_object_set(obj, table, EINA_TRUE); evas_object_event_callback_add - (table, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _table_size_hints_changed, obj); + (table, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _table_size_hints_changed, obj); evas_obj_smart_add(eo_super(obj, MY_CLASS)); @@ -329,8 +328,8 @@ _efl_ui_grid_evas_object_smart_del(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); evas_object_event_callback_del_full - (wd->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, - _table_size_hints_changed, obj); + (wd->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, + _table_size_hints_changed, obj); /* let's make our table object the *last* to be processed, since it * may (smart) parent other sub objects here */ @@ -339,7 +338,7 @@ _efl_ui_grid_evas_object_smart_del(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) if (child == wd->resize_obj) { wd->subobjs = - eina_list_demote_list(wd->subobjs, l); + eina_list_demote_list(wd->subobjs, l); break; } } @@ -367,7 +366,7 @@ _efl_ui_grid_eo_base_constructor(Eo *obj, Efl_Ui_Grid_Data *pd) EOLIAN static void -_efl_ui_grid_efl_pack_padding_set(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, double h, double v, Eina_Bool scalable) +_efl_ui_grid_efl_pack_pack_padding_set(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, double h, double v, Eina_Bool scalable) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -382,11 +381,11 @@ _efl_ui_grid_efl_pack_padding_set(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, dou evas_object_table_padding_set(wd->resize_obj, h * scale, v * scale); } else - evas_object_table_padding_set(wd->resize_obj, h, v); + evas_object_table_padding_set(wd->resize_obj, h, v); } EOLIAN static void -_efl_ui_grid_efl_pack_padding_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, double *h, double *v, Eina_Bool *scalable) +_efl_ui_grid_efl_pack_pack_padding_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, double *h, double *v, Eina_Bool *scalable) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -411,7 +410,7 @@ _subobj_del_cb(void *data, const Eo_Event *event) } static void -_pack_at(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj, +_pack_at(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx_Base *subobj, int col, int row, int colspan, int rowspan, Eina_Bool linear) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -467,7 +466,7 @@ _pack_at(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj, eo_key_data_set(subobj, GRID_ITEM_KEY, gi); elm_widget_sub_object_add(obj, subobj); - eo_event_callback_call(obj, EFL_PACK_EVENT_CHILD_ADDED, subobj); + eo_event_callback_call(obj, EFL_PACK_EVENT_CONTENT_ADDED, subobj); eo_event_callback_array_add(subobj, subobj_callbacks, obj); } @@ -476,7 +475,7 @@ _pack_at(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj, EOLIAN static void _efl_ui_grid_efl_pack_grid_pack_grid(Eo *obj, Efl_Ui_Grid_Data *pd, - Efl_Pack_Item *subobj, + Efl_Gfx_Base *subobj, int col, int row, int colspan, int rowspan) { EINA_SAFETY_ON_NULL_RETURN(subobj); @@ -485,7 +484,7 @@ _efl_ui_grid_efl_pack_grid_pack_grid(Eo *obj, Efl_Ui_Grid_Data *pd, } EOLIAN static void -_efl_ui_grid_efl_pack_grid_pack_child_position_set(Eo *obj, Efl_Ui_Grid_Data *pd, Evas_Object *subobj, int col, int row, int colspan, int rowspan) +_efl_ui_grid_efl_pack_grid_grid_content_position_set(Eo *obj, Efl_Ui_Grid_Data *pd, Evas_Object *subobj, int col, int row, int colspan, int rowspan) { EINA_SAFETY_ON_NULL_RETURN(subobj); @@ -499,7 +498,7 @@ _efl_ui_grid_efl_pack_grid_pack_child_position_set(Eo *obj, Efl_Ui_Grid_Data *pd } EOLIAN static Eina_Bool -_efl_ui_grid_efl_pack_grid_pack_child_position_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, Evas_Object *subobj, int *col, int *row, int *colspan, int *rowspan) +_efl_ui_grid_efl_pack_grid_grid_content_position_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, Evas_Object *subobj, int *col, int *row, int *colspan, int *rowspan) { int c = -1, r = -1, cs = 0, rs = 0; Grid_Item *gi; @@ -530,8 +529,8 @@ end: return ret; } -EOLIAN static Efl_Pack_Item * -_efl_ui_grid_efl_pack_grid_pack_child_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, int col, int row) +EOLIAN static Efl_Gfx_Base * +_efl_ui_grid_efl_pack_grid_grid_content_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, int col, int row) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); @@ -539,7 +538,7 @@ _efl_ui_grid_efl_pack_grid_pack_child_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUS } static void -_item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj) +_item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx_Base *subobj) { Grid_Item *gi = eo_key_data_get(subobj, GRID_ITEM_KEY); Grid_Item *gi2, *last = NULL; @@ -587,7 +586,7 @@ _item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj) } end: - eo_event_callback_call(obj, EFL_PACK_EVENT_CHILD_REMOVED, subobj); + eo_event_callback_call(obj, EFL_PACK_EVENT_CONTENT_REMOVED, subobj); pd->items = (Grid_Item *) eina_inlist_remove(EINA_INLIST_GET(pd->items), EINA_INLIST_GET(gi)); pd->count--; @@ -596,7 +595,7 @@ end: } EOLIAN static Eina_Bool -_efl_ui_grid_efl_pack_unpack(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj) +_efl_ui_grid_efl_pack_unpack(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx_Base *subobj) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); @@ -612,7 +611,7 @@ _efl_ui_grid_efl_pack_unpack(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subob } EOLIAN static void -_efl_ui_grid_efl_pack_clear(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) +_efl_ui_grid_efl_pack_pack_clear(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) { ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); @@ -627,8 +626,8 @@ _efl_ui_grid_efl_pack_unpack_all(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) evas_object_table_clear(wd->resize_obj, EINA_FALSE); } -EOLIAN void -_efl_ui_grid_efl_pack_layout_request(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) +EOLIAN static void +_efl_ui_grid_efl_pack_layout_layout_request(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) { evas_object_smart_need_recalculate_set(obj, EINA_TRUE); } @@ -636,7 +635,7 @@ _efl_ui_grid_efl_pack_layout_request(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) static Eina_Bool _grid_item_iterator_next(Grid_Item_Iterator *it, void **data) { - Efl_Pack_Item *sub; + Efl_Gfx_Base *sub; if (!eina_iterator_next(it->real_iterator, (void **) &sub)) return EINA_FALSE; @@ -659,19 +658,18 @@ _grid_item_iterator_free(Grid_Item_Iterator *it) free(it); } -EOLIAN static Eina_Iterator * -_efl_ui_grid_efl_pack_contents_iterate(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) +static inline Eina_Iterator * +_grid_item_iterator_create(Eo *obj, Eina_List *list) { Grid_Item_Iterator *it; - - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + if (!list) return NULL; it = calloc(1, sizeof(*it)); if (!it) return NULL; EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR); - it->list = evas_object_table_children_get(wd->resize_obj); + it->list = list; it->real_iterator = eina_list_iterator_new(it->list); it->iterator.version = EINA_ITERATOR_VERSION; it->iterator.next = FUNC_ITERATOR_NEXT(_grid_item_iterator_next); @@ -682,21 +680,49 @@ _efl_ui_grid_efl_pack_contents_iterate(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED return &it->iterator; } +EOLIAN static Eina_Iterator * +_efl_ui_grid_efl_pack_contents_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED) +{ + Eina_List *list; + + ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); + + list = evas_object_table_children_get(wd->resize_obj); + return _grid_item_iterator_create(obj, list); +} + EOLIAN static int _efl_ui_grid_efl_pack_contents_count(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd) { return pd->count; } -EOLIAN static Eina_List * -_efl_ui_grid_efl_pack_grid_pack_children_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, int col, int row) +EOLIAN static Eina_Iterator * +_efl_ui_grid_efl_pack_grid_grid_contents_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, + int col, int row, Eina_Bool below) { - Eina_List *l = NULL; + Eina_List *list, *atlist = NULL; + Evas_Object *sobj; ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL); - /* FIXME: only one item returned */ - return eina_list_append(l, evas_object_table_child_get(wd->resize_obj, col, row)); + list = evas_object_table_children_get(wd->resize_obj); + EINA_LIST_FREE(list, sobj) + { + Grid_Item *gi = eo_key_data_get(sobj, GRID_ITEM_KEY); + if (!gi) continue; + + if ((gi->col == col) && (gi->row == row)) + atlist = eina_list_append(atlist, sobj); + else if (below) + { + if ((gi->col <= col) && (gi->col + gi->col_span >= col) && + (gi->row <= row) && (gi->row + gi->row_span >= row)) + atlist = eina_list_append(atlist, sobj); + } + } + + return _grid_item_iterator_create(obj, atlist); } EOLIAN static void @@ -713,7 +739,7 @@ _efl_ui_grid_efl_pack_linear_direction_set(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Or if (!_horiz(pd->dir1)) pd->dir2 = EFL_ORIENT_RIGHT; else - pd->dir2 = EFL_ORIENT_DOWN; + pd->dir2 = EFL_ORIENT_DOWN; } efl_pack_layout_request(obj); @@ -775,12 +801,12 @@ _efl_ui_grid_efl_pack_grid_grid_size_set(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUS EOLIAN static void _efl_ui_grid_efl_pack_grid_grid_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd EINA_UNUSED, int *cols, int *rows) { - if (cols) *cols = efl_pack_columns_get(obj); - if (rows) *rows = efl_pack_rows_get(obj); + if (cols) *cols = efl_pack_grid_columns_get(obj); + if (rows) *rows = efl_pack_grid_rows_get(obj); } EOLIAN static void -_efl_ui_grid_efl_pack_grid_columns_set(Eo *obj, Efl_Ui_Grid_Data *pd, int columns) +_efl_ui_grid_efl_pack_grid_grid_columns_set(Eo *obj, Efl_Ui_Grid_Data *pd, int columns) { pd->req_cols = columns; @@ -788,7 +814,7 @@ _efl_ui_grid_efl_pack_grid_columns_set(Eo *obj, Efl_Ui_Grid_Data *pd, int column } EOLIAN static int -_efl_ui_grid_efl_pack_grid_columns_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd) +_efl_ui_grid_efl_pack_grid_grid_columns_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd) { if (!pd->req_cols) { @@ -801,7 +827,7 @@ _efl_ui_grid_efl_pack_grid_columns_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd } EOLIAN static void -_efl_ui_grid_efl_pack_grid_rows_set(Eo *obj, Efl_Ui_Grid_Data *pd, int rows) +_efl_ui_grid_efl_pack_grid_grid_rows_set(Eo *obj, Efl_Ui_Grid_Data *pd, int rows) { pd->req_rows = rows; @@ -809,7 +835,7 @@ _efl_ui_grid_efl_pack_grid_rows_set(Eo *obj, Efl_Ui_Grid_Data *pd, int rows) } EOLIAN static int -_efl_ui_grid_efl_pack_grid_rows_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd) +_efl_ui_grid_efl_pack_grid_grid_rows_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd) { if (!pd->req_rows) { @@ -822,14 +848,14 @@ _efl_ui_grid_efl_pack_grid_rows_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd) } EOLIAN static void -_efl_ui_grid_efl_pack_pack(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, Efl_Pack_Item *subobj) +_efl_ui_grid_efl_pack_pack(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, Efl_Gfx_Base *subobj) { /* this is just an alias */ efl_pack_end(obj, subobj); } EOLIAN static void -_efl_ui_grid_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj) +_efl_ui_grid_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx_Base *subobj) { EINA_SAFETY_ON_NULL_RETURN(subobj); diff --git a/src/lib/elementary/efl_ui_grid.eo b/src/lib/elementary/efl_ui_grid.eo index 839d7a24a9..afa0e6bac9 100644 --- a/src/lib/elementary/efl_ui_grid.eo +++ b/src/lib/elementary/efl_ui_grid.eo @@ -1,47 +1,52 @@ -class Efl.Ui.Grid (Elm.Widget, Efl.Pack_Grid, Efl.Pack_Engine) +class Efl.Ui.Grid (Elm.Widget, Efl.Pack_Grid, Efl.Pack_Layout) { + legacy_prefix: null; implements { Eo.Base.constructor; + // Smart obj Evas.Object_Smart.add; Evas.Object_Smart.del; Evas.Object_Smart.calculate; + // Focus Elm.Widget.focus_direction; Elm.Widget.focus_next_manager_is; Elm.Widget.focus_direction_manager_is; Elm.Widget.focus_next; Elm.Widget.theme_apply; - Efl.Pack.contents_iterate; + // Packing interface + Efl.Pack.contents_get; Efl.Pack.contents_count; - Efl.Pack.clear; + Efl.Pack.pack_clear; Efl.Pack.unpack_all; Efl.Pack.unpack; Efl.Pack.pack; - Efl.Pack.padding.get; - Efl.Pack.padding.set; - Efl.Pack.layout_update; - Efl.Pack.layout_request; + Efl.Pack.pack_padding.get; + Efl.Pack.pack_padding.set; Efl.Pack_Grid.pack_grid; - Efl.Pack_Grid.pack_children_at; - Efl.Pack_Grid.pack_child_at; - Efl.Pack_Grid.pack_child_position.set; - Efl.Pack_Grid.pack_child_position.get; + Efl.Pack_Grid.grid_contents_at; + Efl.Pack_Grid.grid_content_at; + Efl.Pack_Grid.grid_content_position.set; + Efl.Pack_Grid.grid_content_position.get; Efl.Pack_Grid.grid_size.set; Efl.Pack_Grid.grid_size.get; - Efl.Pack_Grid.columns.set; - Efl.Pack_Grid.columns.get; - Efl.Pack_Grid.rows.set; - Efl.Pack_Grid.rows.get; + Efl.Pack_Grid.grid_columns.set; + Efl.Pack_Grid.grid_columns.get; + Efl.Pack_Grid.grid_rows.set; + Efl.Pack_Grid.grid_rows.get; Efl.Pack_Grid.directions.set; Efl.Pack_Grid.directions.get; Efl.Pack_Linear.pack_end; Efl.Pack_Linear.direction.set; Efl.Pack_Linear.direction.get; - Efl.Pack.layout_engine.get; - Efl.Pack.layout_engine.set; - Efl.Pack_Engine.layout_do; + // Custom layouts + Efl.Pack_Layout.layout_update; + Efl.Pack_Layout.layout_request; + Efl.Pack_Layout.layout_engine.get; + Efl.Pack_Layout.layout_engine.set; + Efl.Pack_Layout.layout_do; } }