elementary: add internal Efl_Ui_Model_Size.
authorCedric BAIL <cedric.bail@free.fr>
Sat, 29 Dec 2018 00:39:44 +0000 (16:39 -0800)
committerTaehyub Kim <taehyub.kim@samsung.com>
Thu, 31 Jan 2019 03:45:41 +0000 (12:45 +0900)
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

src/Makefile_Elementary.am
src/lib/elementary/efl_ui_model_size.c [new file with mode: 0644]
src/lib/elementary/efl_ui_model_size.eo [new file with mode: 0644]
src/lib/elementary/elm_priv.h
src/lib/elementary/meson.build

index 19b743d..ef99e47 100644 (file)
@@ -178,6 +178,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)
 
 ## TIZEN_ONLY(20180509): support elementary optional build
@@ -912,6 +913,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 (file)
index 0000000..9780c2b
--- /dev/null
@@ -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 (file)
index 0000000..f08f32b
--- /dev/null
@@ -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
index 7788f6a..89561cb 100644 (file)
 # 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>
index e6608bd..2ec2428 100644 (file)
@@ -340,6 +340,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 = []
@@ -910,7 +911,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]