summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJee-Yong Um <jc9.um@samsung.com>2016-06-10 13:29:33 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-06-10 14:05:43 +0900
commitc17b3d40a25f6a2202d15d278bc87e01246988dc (patch)
tree7114f4dfdb111db5da80027a9af079117b944cd1 /src
parent9fdf584d1a476bb444dfe4aad1183342b721a111 (diff)
downloadefl-c17b3d40a25f6a2202d15d278bc87e01246988dc.tar.gz
Efl.Ui.Grid.Static: Add implementation of simple grid
Summary: Efl.Ui.Grid.Static uses virtual coordinates when arranging its child objects. (like Evas.Grid) Reviewers: jpeg Subscribers: woohyun, cedric Differential Revision: https://phab.enlightenment.org/D3989
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Elementary.am3
-rw-r--r--src/lib/elementary/Elementary.h.in1
-rw-r--r--src/lib/elementary/Makefile.am3
-rw-r--r--src/lib/elementary/efl_ui_grid.c58
-rw-r--r--src/lib/elementary/efl_ui_grid_private.h62
-rw-r--r--src/lib/elementary/efl_ui_grid_static.c74
-rw-r--r--src/lib/elementary/efl_ui_grid_static.eo8
7 files changed, 152 insertions, 57 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 4f7dc08ba3..9034a8d068 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -118,6 +118,7 @@ elm_public_eolian_files = \
lib/elementary/efl_ui_box.eo \
lib/elementary/efl_ui_box_flow.eo \
lib/elementary/efl_ui_grid.eo \
+ lib/elementary/efl_ui_grid_static.eo \
lib/elementary/efl_ui_layout_internal_box.eo \
lib/elementary/efl_ui_layout_internal_table.eo \
lib/elementary/elm_button_internal_part.eo \
@@ -677,6 +678,8 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/efl_ui_box_layout.c \
lib/elementary/efl_ui_box_private.h \
lib/elementary/efl_ui_grid.c \
+ lib/elementary/efl_ui_grid_static.c \
+ lib/elementary/efl_ui_grid_private.h \
$(NULL)
diff --git a/src/lib/elementary/Elementary.h.in b/src/lib/elementary/Elementary.h.in
index 6f362ec974..dee412d985 100644
--- a/src/lib/elementary/Elementary.h.in
+++ b/src/lib/elementary/Elementary.h.in
@@ -272,6 +272,7 @@ EAPI extern Elm_Version *elm_version;
# include <efl_ui_box.eo.h>
# include <efl_ui_box_flow.eo.h>
# include <efl_ui_grid.eo.h>
+# include <efl_ui_grid_static.eo.h>
# include <efl_ui_image.eo.h>
# include <efl_ui_win.eo.h>
# include <efl_ui_win_standard.eo.h>
diff --git a/src/lib/elementary/Makefile.am b/src/lib/elementary/Makefile.am
index a553e074bc..13854bc928 100644
--- a/src/lib/elementary/Makefile.am
+++ b/src/lib/elementary/Makefile.am
@@ -125,6 +125,7 @@ elm_eolian_files = \
efl_ui_box.eo \
efl_ui_box_flow.eo \
efl_ui_grid.eo \
+ efl_ui_grid_static.eo \
efl_ui_layout_internal_box.eo \
efl_ui_layout_internal_table.eo \
$(NULL)
@@ -496,6 +497,7 @@ includesub_HEADERS = \
elm_win_standard.h \
elm_helper.h \
efl_ui_box_private.h \
+ efl_ui_grid_private.h \
$(NULL)
includesubdir = $(includedir)/elementary-@VMAJ@/
@@ -627,6 +629,7 @@ libelementary_la_SOURCES = \
efl_ui_box_flow.c \
efl_ui_box_layout.c \
efl_ui_grid.c \
+ efl_ui_grid_static.c \
$(NULL)
libelementary_la_CFLAGS = @ELEMENTARY_CFLAGS@
diff --git a/src/lib/elementary/efl_ui_grid.c b/src/lib/elementary/efl_ui_grid.c
index 66c8635455..0828caece9 100644
--- a/src/lib/elementary/efl_ui_grid.c
+++ b/src/lib/elementary/efl_ui_grid.c
@@ -1,65 +1,15 @@
-#ifdef HAVE_CONFIG_H
-# include "elementary_config.h"
-#endif
+#include "efl_ui_grid_private.h"
-#define EFL_PACK_LAYOUT_PROTECTED
-
-#include <Elementary.h>
-#include "elm_priv.h"
-
-#include "efl_ui_grid.eo.h"
#include "../evas/canvas/evas_table.eo.h"
#define MY_CLASS EFL_UI_GRID_CLASS
#define MY_CLASS_NAME "Efl.Ui.Grid"
-typedef struct _Efl_Ui_Grid_Data Efl_Ui_Grid_Data;
-typedef struct _Grid_Item_Iterator Grid_Item_Iterator;
-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_Gfx *subobj);
-#define GRID_ITEM_KEY "__grid_item"
-
-struct _Grid_Item
-{
- EINA_INLIST;
-
- Efl_Gfx *object;
- int col_span, row_span;
- int col, row;
-
- Eina_Bool linear : 1;
-};
-
-struct _Efl_Ui_Grid_Data
-{
- const Eo_Class *layout_engine;
- const void *layout_data;
-
- Grid_Item *items;
- int count;
-
- int req_cols, req_rows; // requested - 0 means infinite
- int last_col, last_row; // only used by linear apis
- Efl_Orient dir1, dir2; // must be orthogonal (H,V or V,H)
- struct {
- double h, v;
- Eina_Bool scalable: 1;
- } pad;
- Eina_Bool linear_recalc : 1;
-};
-
-struct _Grid_Item_Iterator
-{
- Eina_Iterator iterator;
- Eina_Iterator *real_iterator;
- Eina_List *list;
- Efl_Ui_Grid *object;
-};
-
struct _Custom_Table_Data
{
Efl_Ui_Grid *parent;
@@ -69,12 +19,6 @@ struct _Custom_Table_Data
EO_CALLBACKS_ARRAY_DEFINE(subobj_callbacks,
{ EO_EVENT_DEL, _subobj_del_cb });
-static inline Eina_Bool
-_horiz(Efl_Orient dir)
-{
- return dir % 180 == EFL_ORIENT_RIGHT;
-}
-
EOLIAN static Eina_Bool
_efl_ui_grid_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd EINA_UNUSED)
{
diff --git a/src/lib/elementary/efl_ui_grid_private.h b/src/lib/elementary/efl_ui_grid_private.h
new file mode 100644
index 0000000000..ab2aa85a20
--- /dev/null
+++ b/src/lib/elementary/efl_ui_grid_private.h
@@ -0,0 +1,62 @@
+#ifndef EFL_UI_GRID_PRIVATE_H
+#define EFL_UI_GRID_PRIVATE_H
+
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#define EFL_PACK_LAYOUT_PROTECTED
+
+#include <Elementary.h>
+#include "elm_priv.h"
+
+typedef struct _Efl_Ui_Grid_Data Efl_Ui_Grid_Data;
+typedef struct _Grid_Item_Iterator Grid_Item_Iterator;
+typedef struct _Grid_Item Grid_Item;
+
+#define GRID_ITEM_KEY "__grid_item"
+
+struct _Grid_Item
+{
+ EINA_INLIST;
+
+ Efl_Gfx *object;
+ int col_span, row_span;
+ int col, row;
+
+ Eina_Bool linear : 1;
+};
+
+struct _Efl_Ui_Grid_Data
+{
+ const Eo_Class *layout_engine;
+ const void *layout_data;
+
+ Grid_Item *items;
+ int count;
+
+ int req_cols, req_rows; // requested - 0 means infinite
+ int last_col, last_row; // only used by linear apis
+ Efl_Orient dir1, dir2; // must be orthogonal (H,V or V,H)
+ struct {
+ double h, v;
+ Eina_Bool scalable: 1;
+ } pad;
+ Eina_Bool linear_recalc : 1;
+};
+
+struct _Grid_Item_Iterator
+{
+ Eina_Iterator iterator;
+ Eina_Iterator *real_iterator;
+ Eina_List *list;
+ Efl_Ui_Grid *object;
+};
+
+static inline Eina_Bool
+_horiz(Efl_Orient dir)
+{
+ return dir % 180 == EFL_ORIENT_RIGHT;
+}
+
+#endif
diff --git a/src/lib/elementary/efl_ui_grid_static.c b/src/lib/elementary/efl_ui_grid_static.c
new file mode 100644
index 0000000000..a8209d26b1
--- /dev/null
+++ b/src/lib/elementary/efl_ui_grid_static.c
@@ -0,0 +1,74 @@
+#include "efl_ui_grid_private.h"
+
+#define MY_CLASS EFL_UI_GRID_STATIC_CLASS
+#define MY_CLASS_NAME "Efl.Ui.Grid.Static"
+
+EOLIAN static Eo *
+_efl_ui_grid_static_eo_base_constructor(Eo *obj, void *pd EINA_UNUSED)
+{
+ Efl_Ui_Grid_Data *gd;
+
+ obj = eo_constructor(eo_super(obj, MY_CLASS));
+ evas_obj_type_set(obj, MY_CLASS_NAME);
+ elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_FILLER);
+
+ gd = eo_data_scope_get(obj, EFL_UI_GRID_CLASS);
+ gd->layout_engine = MY_CLASS;
+ gd->req_cols = 100;
+ gd->req_rows = 100;
+
+ return obj;
+}
+
+EOLIAN static void
+_efl_ui_grid_static_efl_pack_layout_layout_do(Eo_Class *klass EINA_UNUSED,
+ void *_pd EINA_UNUSED,
+ Eo *obj, const void *data EINA_UNUSED)
+{
+ Efl_Ui_Grid_Data *gd;
+ Grid_Item *gi;
+ Evas *e;
+ Evas_Coord x, y, w, h;
+ long long xl, yl, wl, hl, vwl, vhl;
+ Eina_Bool mirror;
+
+ gd = eo_data_scope_get(obj, EFL_UI_GRID_CLASS);
+ if (!gd->items) return;
+
+ e = evas_common_evas_get(obj);
+ eo_event_freeze(e);
+
+ efl_gfx_position_get(obj, &x, &y);
+ efl_gfx_size_get(obj, &w, &h);
+ xl = x;
+ yl = y;
+ wl = w;
+ hl = h;
+ mirror = elm_widget_mirrored_get(obj);
+ vwl = gd->req_cols;
+ vhl = gd->req_rows;
+
+ EINA_INLIST_FOREACH(gd->items, gi)
+ {
+ long long x1, y1, x2, y2;
+
+ if (!mirror)
+ {
+ x1 = xl + ((wl * (long long)gi->col) / vwl);
+ x2 = xl + ((wl * (long long)(gi->col + gi->col_span)) / vwl);
+ }
+ else
+ {
+ x1 = xl + ((wl * (vwl - (long long)(gi->col + gi->col_span))) / vwl);
+ x2 = xl + ((wl * (vwl - (long long)gi->col)) / vwl);
+ }
+ y1 = yl + ((hl * (long long)gi->row) / vhl);
+ y2 = yl + ((hl * (long long)(gi->row + gi->row_span)) / vhl);
+ efl_gfx_position_set(gi->object, x1, y1);
+ efl_gfx_size_set(gi->object, x2 - x1, y2 - y1);
+ }
+
+ eo_event_thaw(e);
+}
+
+#include "efl_ui_grid_static.eo.c"
diff --git a/src/lib/elementary/efl_ui_grid_static.eo b/src/lib/elementary/efl_ui_grid_static.eo
new file mode 100644
index 0000000000..1514dbb1fd
--- /dev/null
+++ b/src/lib/elementary/efl_ui_grid_static.eo
@@ -0,0 +1,8 @@
+class Efl.Ui.Grid.Static (Efl.Ui.Grid)
+{
+ data: null;
+ implements {
+ Eo.Base.constructor;
+ Efl.Pack.Layout.layout_do;
+ }
+}