diff options
author | Cedric BAIL <cedric.bail@free.fr> | 2018-12-28 16:39:44 -0800 |
---|---|---|
committer | Cedric BAIL <cedric.bail@free.fr> | 2019-01-30 12:06:13 -0800 |
commit | 0d5d832b87a5824c9b27ce383642d5dbc12f4632 (patch) | |
tree | 1aa658b12fbf488e4d044f8e70a1e90c8861cc56 | |
parent | 1dadeac05e14d2ba50b3bb430fe386d7a50a9d56 (diff) | |
download | efl-0d5d832b87a5824c9b27ce383642d5dbc12f4632.tar.gz |
elementary: add internal Efl_Ui_Model_Size.
This model enable View that require to compute the size of their items
to rely on an interface to provide the properties they need to get the object
size. This is the base class for all the sizing logic of the new List/Grid View.
Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D7658
-rw-r--r-- | src/Makefile_Elementary.am | 2 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_model_size.c | 48 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_model_size.eo | 19 | ||||
-rw-r--r-- | src/lib/elementary/elm_priv.h | 8 | ||||
-rw-r--r-- | src/lib/elementary/meson.build | 4 |
5 files changed, 80 insertions, 1 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index f8fca13520..9df6326dcd 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -176,6 +176,7 @@ elm_private_eolian_files = \ lib/elementary/efl_datetime_manager.eo \ lib/elementary/efl_ui_list_view_relayout.eo \ lib/elementary/efl_ui_list_view_precise_layouter.eo \ + lib/elementary/efl_ui_model_size.eo \ $(NULL) # Legacy classes - not part of public EO API @@ -886,6 +887,7 @@ lib_elementary_libelementary_la_SOURCES = \ lib/elementary/efl_ui_widget_focus_manager.c \ lib/elementary/efl_ui_caching_factory.c \ lib/elementary/efl_ui_widget_factory.c \ + lib/elementary/efl_ui_model_size.c \ $(NULL) diff --git a/src/lib/elementary/efl_ui_model_size.c b/src/lib/elementary/efl_ui_model_size.c new file mode 100644 index 0000000000..9780c2baca --- /dev/null +++ b/src/lib/elementary/efl_ui_model_size.c @@ -0,0 +1,48 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <Elementary.h> +#include "elm_priv.h" + +const char *_efl_model_property_itemw = "item.width"; +const char *_efl_model_property_itemh = "item.height"; +const char *_efl_model_property_selfw = "self.width"; +const char *_efl_model_property_selfh = "self.height"; +const char *_efl_model_property_totalw = "total.width"; +const char *_efl_model_property_totalh = "total.height"; + +static Eina_Iterator * +_efl_ui_model_size_properties_child(void) +{ + const char *properties[] = { + _efl_model_property_itemw, _efl_model_property_itemh, _efl_model_property_selfh, _efl_model_property_selfw + }; + return EINA_C_ARRAY_ITERATOR_NEW(properties); +} + +static Eina_Iterator * +_efl_ui_model_size_properties_root(void) +{ + const char *properties[] = { + _efl_model_property_itemw, _efl_model_property_itemh + }; + return EINA_C_ARRAY_ITERATOR_NEW(properties); +} + +static Eina_Iterator * +_efl_ui_model_size_efl_model_properties_get(const Eo *obj, void *pd EINA_UNUSED) +{ + Eina_Iterator *super; + Eina_Iterator *prop; + + super = efl_model_properties_get(efl_super(obj, EFL_UI_MODEL_SIZE_CLASS)); + if (efl_isa(efl_parent_get(obj), EFL_UI_MODEL_SIZE_CLASS)) + prop = _efl_ui_model_size_properties_child(); + else + prop = _efl_ui_model_size_properties_root(); + + return eina_multi_iterator_new(super, prop); +} + +#include "efl_ui_model_size.eo.c" diff --git a/src/lib/elementary/efl_ui_model_size.eo b/src/lib/elementary/efl_ui_model_size.eo new file mode 100644 index 0000000000..f08f32bc92 --- /dev/null +++ b/src/lib/elementary/efl_ui_model_size.eo @@ -0,0 +1,19 @@ +class Efl.Ui.Model_Size extends Efl.Model_Composite +{ + [[Class to be used to store object item size for List/Grid View. + + This model provide the following properties that can be retrived by + @Efl.Model.properties.get : + - "$self.width" and "$self.height" define the size of this object from the point of + view of the @Efl.Ui.View that use it. It only apply on children and not on the + top root object. + - "$item.width" and "$item.height" define all the children size and is available + only on @Efl.Ui.Model_Size that do have children. + - "$total.width" and "$total.height" define the accumulated size used by all the children. + Only vertical list accumulation logic is implemented at this point.]] + + data: null; + implements { + Efl.Model.properties { get; } + } +}
\ No newline at end of file diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h index 0fd36df9a2..9410fd4213 100644 --- a/src/lib/elementary/elm_priv.h +++ b/src/lib/elementary/elm_priv.h @@ -69,6 +69,14 @@ # include "elm_widget_item_static_focus.eo.h" #include "efl_ui_selection_manager.eo.h" # include "efl_datetime_manager.eo.h" +# include "efl_ui_model_size.eo.h" + +extern const char *_efl_model_property_itemw; +extern const char *_efl_model_property_itemh; +extern const char *_efl_model_property_selfw; +extern const char *_efl_model_property_selfh; +extern const char *_efl_model_property_totalw; +extern const char *_efl_model_property_totalh; # ifdef HAVE_LANGINFO_H # include <langinfo.h> diff --git a/src/lib/elementary/meson.build b/src/lib/elementary/meson.build index fa5b42b4a1..90cfa83ead 100644 --- a/src/lib/elementary/meson.build +++ b/src/lib/elementary/meson.build @@ -339,6 +339,7 @@ priv_eo_files = [ 'efl_datetime_manager.eo', 'efl_ui_list_view_precise_layouter.eo', 'efl_ui_list_view_relayout.eo', + 'efl_ui_model_size.eo', ] priv_eo_file_target = [] @@ -905,7 +906,8 @@ elementary_src = [ 'efl_ui_tab_page.c', 'efl_ui_widget_focus_manager.c', 'efl_ui_caching_factory.c', - 'efl_ui_widget_factory.c' + 'efl_ui_widget_factory.c', + 'efl_ui_model_size.c' ] elementary_deps = [emile, eo, efl, edje, ethumb, ethumb_client, emotion, ecore_imf, ecore_con, eldbus, efreet, efreet_mime, efreet_trash, eio, atspi, dl, intl] |