From 57e64ee65b6ae35107f40ca155e2fb318a0082f6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 12 Apr 2016 14:08:35 +0900 Subject: [PATCH] Efl: Add skeletton for new containers "Pack" API I chose the name "pack" instead of containers because it is shorter, and allows out-of-the-box short C names like efl_pack_end() instead of efl_container_pack_end(). All Pack interfaces will use the same efl_pack eo prefix. This is still work in progress. @feature --- src/Makefile_Efl.am | 5 ++ src/lib/efl/Efl.h | 12 +++ src/lib/efl/interfaces/efl_interfaces_main.c | 6 ++ src/lib/efl/interfaces/efl_pack.eo | 78 +++++++++++++++++ src/lib/efl/interfaces/efl_pack_grid.eo | 88 ++++++++++++++++++++ src/lib/efl/interfaces/efl_pack_item.eo | 14 ++++ src/lib/efl/interfaces/efl_pack_linear.eo | 68 +++++++++++++++ src/lib/efl/interfaces/efl_pack_named.eo | 16 ++++ 8 files changed, 287 insertions(+) create mode 100644 src/lib/efl/interfaces/efl_pack.eo create mode 100644 src/lib/efl/interfaces/efl_pack_grid.eo create mode 100644 src/lib/efl/interfaces/efl_pack_item.eo create mode 100644 src/lib/efl/interfaces/efl_pack_linear.eo create mode 100644 src/lib/efl/interfaces/efl_pack_named.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 8b5bcf9dd1..d0ef34bb15 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -25,6 +25,11 @@ efl_eolian_files = \ lib/efl/interfaces/efl_animator.eo \ lib/efl/interfaces/efl_orientation.eo \ lib/efl/interfaces/efl_flipable.eo \ + lib/efl/interfaces/efl_pack.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/lib/efl/Efl.h b/src/lib/efl/Efl.h index 1229c9ea39..dc9b094232 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -35,6 +35,11 @@ extern "C" { #define EFL_VERSION_1_18 1 +/* Add here all the required ifdef for any @protected method */ +#ifdef EFL_EFL_BUILD +# define EFL_PACK_PROTECTED +#endif + /** * @ingroup Efl * @since 1.18 @@ -111,6 +116,13 @@ 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_linear.eo.h" +#include "interfaces/efl_pack_grid.eo.h" +#include "interfaces/efl_pack_named.eo.h" + #else #ifndef EFL_NOLEGACY_API_SUPPORT diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 987e9709d1..5f424f97d0 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -33,6 +33,12 @@ EAPI const Eo_Event_Description _EFL_GFX_CHANGED = 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_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" #include "interfaces/efl_orientation.eo.c" diff --git a/src/lib/efl/interfaces/efl_pack.eo b/src/lib/efl/interfaces/efl_pack.eo new file mode 100644 index 0000000000..7e9661b914 --- /dev/null +++ b/src/lib/efl/interfaces/efl_pack.eo @@ -0,0 +1,78 @@ +import eina_types; + +interface Efl.Pack (Efl.Pack_Item) +{ + [[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_count { + [[returns the number of UI elements packed in this container.]] + return: int; + } + clear { + [[removes all packed children, and unrefs them]] + } + unpack_all { + [[removes all packed children, without changing their refcount]] + } + unpack { + [[removes an existing item from the container, without unref. + + delete the item directly if you actually wanted to pop and unref + ]] + return: bool; [[$false if $subobj wasn't a child or can't be removed]] + params { + subobj: Efl.Pack_Item*; + } + } + /* FIXME: confusing? two meanings: named slot vs. append */ + pack { + [[Adds an item to this container. + + Depending on the container this will either fill in the default + spot, replacing any already existing element or append to the end + of the container if there is no default part. + + The container takes ownership of this object. This means if packing + failed, the object will be unrefed. + ]] + params { + subobj: Efl.Pack_Item*; + } + } + @property padding { + [[Padding between items contained in this object.]] + set {} + get {} + values { + pad_horiz: double; + pad_vert: double; + scalable: bool; + } + } + 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; + child,removed; + layout,updated; + } +} diff --git a/src/lib/efl/interfaces/efl_pack_grid.eo b/src/lib/efl/interfaces/efl_pack_grid.eo new file mode 100644 index 0000000000..eda8ebb320 --- /dev/null +++ b/src/lib/efl/interfaces/efl_pack_grid.eo @@ -0,0 +1,88 @@ +import efl_gfx_types; + +interface Efl.Pack_Grid (Efl.Pack_Linear) +{ + [[2D containers aligned on a grid with rows and columns]] + legacy_prefix: null; + eo_prefix: efl_pack; + methods { + pack_grid { + params { + subobj: Efl.Pack_Item *; + col: int; + row: int; + colspan: int @optional; [[0 means 1, -1 means @.max_span]] + rowspan: int @optional; [[0 means 1, -1 means @.max_span]] + } + } + grid_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); + params { + @in col: int; + @in row: int; + } + } + @property grid_child_position { + [[position and span of the $subobj in this container, may be modified to move the $subobj]] + set { [[same as grid_pack]] } + get {} + keys { + subobj: Efl.Pack_Item*; + } + values { + col: int; + row: int; + colspan: int; + rowspan: int; + } + } + /* FIXME: the below SET apis need to be well defined. they are not. yet */ + @property grid_size { + [[combines @.columns and @.rows]] + set {} + get {} + values { + cols: int; + rows: int; + } + } + @property columns { + set {} + get {} + values { + cols: int; + } + } + @property rows { + set {} + get {} + values { + rows: int; + } + } + @property max_span { + [[Max column or row when used with linear apis. Default is 0 (no limit) + only valid if direction is horizontal + ]] + set {} + get {} + values { + maxx: int; + } + } + @property directions { + [[primary and secondary up/left/right/down orientation for linear apis. default is right and down + overrides @Efl.Pack_Linear.direction + ]] + set {} + get {} + values { + primary: Efl.Orient; + secondary: Efl.Orient; + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_pack_item.eo b/src/lib/efl/interfaces/efl_pack_item.eo new file mode 100644 index 0000000000..a7969ef6c7 --- /dev/null +++ b/src/lib/efl/interfaces/efl_pack_item.eo @@ -0,0 +1,14 @@ +interface Efl.Pack_Item +{ + [[Describes an item that can be packed in a container.]] + legacy_prefix: null; + methods { + /* FIXME: is this same as eo_parent? shouldn't it be? */ + @property container { + get {} + values { + obj: const(Eo.Base)*; /* FIXME: this is an Efl.Pack* */ + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_pack_linear.eo b/src/lib/efl/interfaces/efl_pack_linear.eo new file mode 100644 index 0000000000..301fa3121b --- /dev/null +++ b/src/lib/efl/interfaces/efl_pack_linear.eo @@ -0,0 +1,68 @@ +/* FIXME: Efl.Pack.Linear */ +interface Efl.Pack_Linear (Efl.Pack) +{ + [[API for containers ]] + legacy_prefix: null; + eo_prefix: efl_pack; + methods { + pack_begin { + [[prepend, same as $pack_at($subobj, 0)]] + params { + @in subobj: Efl.Pack_Item*; + } + } + pack_end { + [[prepend, same as $pack_at($subobj, -1)]] + params { + @in subobj: Efl.Pack_Item*; + } + } + pack_before { + [[prepend before other subobj]] + return: bool @warn_unused; [[returns $false if $existing could not be found]] + params { + @in subobj: Efl.Pack_Item*; + @in existing: const(Efl.Pack_Item)*; + } + } + pack_after { + [[append after other subobj]] + return: bool @warn_unused; [[returns $false if $existing could not be found]] + params { + @in subobj: Efl.Pack_Item*; + @in existing: const(Efl.Pack_Item)*; + } + } + @property child_at { + set { [[Insert child at a specified index.]] } + get {} + keys { + index: int; + } + values { + subobj: Efl.Pack_Item *; + } + } + @property child_index { + [[index of the $subobj in this container, may be modified to move the $subobj]] + set { + return: bool; [[returns $false if $subobj is not a child]] + } + get {} + keys { + subobj: const(Efl.Pack_Item *); + } + values { + index: int; + } + } + @property direction { + [[primary up/left/right/down orientation for linear apis. default is right]] + set {} + get {} + values { + orient: Efl.Orient; + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_pack_named.eo b/src/lib/efl/interfaces/efl_pack_named.eo new file mode 100644 index 0000000000..eadb503cb6 --- /dev/null +++ b/src/lib/efl/interfaces/efl_pack_named.eo @@ -0,0 +1,16 @@ +interface Efl.Pack_Named (Efl.Pack) +{ + [[Common API for containers of named parts.]] + legacy_prefix: null; + eo_prefix: efl_pack; + methods { + pack_as /* @part */ { + [[Insert element in a named spot (swallow, part).]] + params { + part: const(char) *; + subobj: Efl.Pack_Item *; + } + } + + } +}