aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Jr <larry.olj@gmail.com>2017-08-01 19:00:10 -0300
committerLarry Jr <larry.olj@gmail.com>2017-08-01 19:00:10 -0300
commite9a3dfc0dcc379bee52f9bf1c18d9229f7d55c97 (patch)
tree59cdfb6eb7a3b2230bf2a241be7624109ff63e76
parentfocus changed to use Focus.Manager (diff)
downloadefl-e9a3dfc0dcc379bee52f9bf1c18d9229f7d55c97.tar.gz
Elementary: added Efl_Ui_Layout_Factory Class
-rw-r--r--src/Makefile_Elementary.am2
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/efl_ui_layout_factory.c126
-rw-r--r--src/lib/elementary/efl_ui_layout_factory.eo22
4 files changed, 151 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 877fa1a423..5eff118b48 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -130,6 +130,7 @@ elm_public_eolian_files = \
lib/elementary/efl_ui_focus_user.eo \
lib/elementary/efl_ui_list.eo \
lib/elementary/efl_ui_list_pan.eo \
+ lib/elementary/efl_ui_layout_factory.eo \
$(NULL)
# Private classes (not exposed or shipped)
@@ -687,6 +688,7 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/efl_ui_focus_object.c \
lib/elementary/efl_ui_focus_manager_root_focus.c \
lib/elementary/efl_ui_list.c \
+ lib/elementary/efl_ui_layout_factory.c \
$(NULL)
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index 0943280f8d..8b1427da3f 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -280,6 +280,7 @@ EAPI extern Elm_Version *elm_version;
# include <efl_ui_text_editable.eo.h>
# include <efl_ui_clock.eo.h>
# include <efl_ui_image_factory.eo.h>
+# include <efl_ui_layout_factory.eo.h>
# include <efl_ui_list.eo.h>
# include <efl_ui_list_pan.eo.h>
#endif
diff --git a/src/lib/elementary/efl_ui_layout_factory.c b/src/lib/elementary/efl_ui_layout_factory.c
new file mode 100644
index 0000000000..e7f6600527
--- /dev/null
+++ b/src/lib/elementary/efl_ui_layout_factory.c
@@ -0,0 +1,126 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#include <Elementary.h>
+#include "elm_priv.h"
+
+#define MY_CLASS EFL_UI_LAYOUT_FACTORY_CLASS
+#define MY_CLASS_NAME "Efl.Ui.Layout_Factory"
+
+typedef struct _Efl_Ui_Layout_Factory_Data
+{
+ Eina_Array *layouts;
+ Eina_Hash *connects;
+ Eina_Stringshare *klass;
+ Eina_Stringshare *group;
+ Eina_Stringshare *style;
+} Efl_Ui_Layout_Factory_Data;
+
+Eina_Bool
+_model_connect(const Eina_Hash *hash, const void *key, void *data, void *fdata)
+{
+ Eo *layout = fdata;
+ Eina_Stringshare *name = key;
+ Eina_Stringshare *property = data;
+
+ efl_ui_model_connect(layout, name, property);
+
+ return EINA_TRUE;
+}
+
+EOLIAN static Eo *
+_efl_ui_layout_factory_efl_object_constructor(Eo *obj, Efl_Ui_Layout_Factory_Data *pd)
+{
+ obj = efl_constructor(efl_super(obj, MY_CLASS));
+
+ pd->klass = NULL;
+ pd->group = NULL;
+ pd->style = NULL;
+ pd->layouts = eina_array_new(8);
+ pd->connects = eina_hash_stringshared_new(EINA_FREE_CB(eina_stringshare_del));
+
+ return obj;
+}
+
+EOLIAN static void
+_efl_ui_layout_factory_efl_object_destructor(Eo *obj, Efl_Ui_Layout_Factory_Data *pd)
+{
+ Eina_Array_Iterator iterator;
+ Eo *layout;
+ int i;
+
+ EINA_ARRAY_ITER_NEXT(pd->layouts, i, layout, iterator)
+ efl_parent_set(layout, NULL);
+
+ eina_array_free(pd->layouts);
+
+ eina_stringshare_del(pd->klass);
+ eina_stringshare_del(pd->group);
+ eina_stringshare_del(pd->style);
+
+ eina_hash_free(pd->connects);
+
+ efl_destructor(efl_super(obj, MY_CLASS));
+}
+
+EOLIAN static Efl_Gfx *
+_efl_ui_layout_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Layout_Factory_Data *pd
+ , Efl_Model *model, Efl_Gfx *parent)
+{
+ Efl_Gfx *layout;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
+
+ if (eina_array_count(pd->layouts))
+ {
+ layout = eina_array_pop(pd->layouts);
+ efl_parent_set(layout, parent);
+ }
+ else
+ {
+ layout = efl_add(ELM_LAYOUT_CLASS, parent);
+ eina_hash_foreach(pd->connects, _model_connect, layout);
+ elm_layout_theme_set(layout, pd->klass, pd->group, pd->style);
+ }
+
+ efl_ui_view_model_set(layout, model);
+
+ return layout;
+}
+
+EOLIAN static void
+_efl_ui_layout_factory_efl_ui_factory_release(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd, Efl_Gfx *layout)
+{
+ efl_ui_view_model_set(layout, NULL);
+ eina_array_push(pd->layouts, layout);
+}
+
+EOLIAN static void
+_efl_ui_layout_factory_efl_ui_model_connect_connect(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd
+ , const char *name, const char *property)
+{
+ Eina_Stringshare *ss_name, *ss_prop;
+
+ ss_name = eina_stringshare_add(name);
+
+ if (property == NULL)
+ {
+ eina_hash_del(pd->connects, ss_name, NULL);
+ return;
+ }
+
+ ss_prop = eina_stringshare_add(property);
+ eina_stringshare_del(eina_hash_set(pd->connects, ss_name, ss_prop));
+}
+
+EOLIAN static void
+_efl_ui_layout_factory_theme_config(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Factory_Data *pd
+ , const char *klass, const char *group, const char *style)
+{
+ eina_stringshare_replace(&pd->klass, klass);
+ eina_stringshare_replace(&pd->group, group);
+ eina_stringshare_replace(&pd->style, style);
+}
+
+#include "efl_ui_layout_factory.eo.c"
diff --git a/src/lib/elementary/efl_ui_layout_factory.eo b/src/lib/elementary/efl_ui_layout_factory.eo
new file mode 100644
index 0000000000..e712900d1c
--- /dev/null
+++ b/src/lib/elementary/efl_ui_layout_factory.eo
@@ -0,0 +1,22 @@
+class Efl.Ui.Layout_Factory (Efl.Object, Efl.Ui.Factory)
+{
+ [[Efl Ui Layout Factory class]]
+ methods {
+ theme_config {
+ [[]]
+ params {
+ klass: string; [[The class of the group.]]
+ group: string; [[The group.]]
+ style: string; [[The style to used.]]
+ }
+ }
+ }
+
+ implements {
+ Efl.Object.constructor;
+ Efl.Object.destructor;
+ Efl.Ui.Factory.create;
+ Efl.Ui.Factory.release;
+ Efl.Ui.Model.Connect.connect;
+ }
+}