summaryrefslogtreecommitdiff
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
parent9fdf584d1a476bb444dfe4aad1183342b721a111 (diff)
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
-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 = \
118 lib/elementary/efl_ui_box.eo \ 118 lib/elementary/efl_ui_box.eo \
119 lib/elementary/efl_ui_box_flow.eo \ 119 lib/elementary/efl_ui_box_flow.eo \
120 lib/elementary/efl_ui_grid.eo \ 120 lib/elementary/efl_ui_grid.eo \
121 lib/elementary/efl_ui_grid_static.eo \
121 lib/elementary/efl_ui_layout_internal_box.eo \ 122 lib/elementary/efl_ui_layout_internal_box.eo \
122 lib/elementary/efl_ui_layout_internal_table.eo \ 123 lib/elementary/efl_ui_layout_internal_table.eo \
123 lib/elementary/elm_button_internal_part.eo \ 124 lib/elementary/elm_button_internal_part.eo \
@@ -677,6 +678,8 @@ lib_elementary_libelementary_la_SOURCES = \
677 lib/elementary/efl_ui_box_layout.c \ 678 lib/elementary/efl_ui_box_layout.c \
678 lib/elementary/efl_ui_box_private.h \ 679 lib/elementary/efl_ui_box_private.h \
679 lib/elementary/efl_ui_grid.c \ 680 lib/elementary/efl_ui_grid.c \
681 lib/elementary/efl_ui_grid_static.c \
682 lib/elementary/efl_ui_grid_private.h \
680 $(NULL) 683 $(NULL)
681 684
682 685
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;
272# include <efl_ui_box.eo.h> 272# include <efl_ui_box.eo.h>
273# include <efl_ui_box_flow.eo.h> 273# include <efl_ui_box_flow.eo.h>
274# include <efl_ui_grid.eo.h> 274# include <efl_ui_grid.eo.h>
275# include <efl_ui_grid_static.eo.h>
275# include <efl_ui_image.eo.h> 276# include <efl_ui_image.eo.h>
276# include <efl_ui_win.eo.h> 277# include <efl_ui_win.eo.h>
277# include <efl_ui_win_standard.eo.h> 278# 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 = \
125 efl_ui_box.eo \ 125 efl_ui_box.eo \
126 efl_ui_box_flow.eo \ 126 efl_ui_box_flow.eo \
127 efl_ui_grid.eo \ 127 efl_ui_grid.eo \
128 efl_ui_grid_static.eo \
128 efl_ui_layout_internal_box.eo \ 129 efl_ui_layout_internal_box.eo \
129 efl_ui_layout_internal_table.eo \ 130 efl_ui_layout_internal_table.eo \
130 $(NULL) 131 $(NULL)
@@ -496,6 +497,7 @@ includesub_HEADERS = \
496 elm_win_standard.h \ 497 elm_win_standard.h \
497 elm_helper.h \ 498 elm_helper.h \
498 efl_ui_box_private.h \ 499 efl_ui_box_private.h \
500 efl_ui_grid_private.h \
499 $(NULL) 501 $(NULL)
500 502
501includesubdir = $(includedir)/elementary-@VMAJ@/ 503includesubdir = $(includedir)/elementary-@VMAJ@/
@@ -627,6 +629,7 @@ libelementary_la_SOURCES = \
627 efl_ui_box_flow.c \ 629 efl_ui_box_flow.c \
628 efl_ui_box_layout.c \ 630 efl_ui_box_layout.c \
629 efl_ui_grid.c \ 631 efl_ui_grid.c \
632 efl_ui_grid_static.c \
630 $(NULL) 633 $(NULL)
631 634
632libelementary_la_CFLAGS = @ELEMENTARY_CFLAGS@ 635libelementary_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 @@
1#ifdef HAVE_CONFIG_H 1#include "efl_ui_grid_private.h"
2# include "elementary_config.h"
3#endif
4 2
5#define EFL_PACK_LAYOUT_PROTECTED
6
7#include <Elementary.h>
8#include "elm_priv.h"
9
10#include "efl_ui_grid.eo.h"
11#include "../evas/canvas/evas_table.eo.h" 3#include "../evas/canvas/evas_table.eo.h"
12 4
13#define MY_CLASS EFL_UI_GRID_CLASS 5#define MY_CLASS EFL_UI_GRID_CLASS
14#define MY_CLASS_NAME "Efl.Ui.Grid" 6#define MY_CLASS_NAME "Efl.Ui.Grid"
15 7
16typedef struct _Efl_Ui_Grid_Data Efl_Ui_Grid_Data;
17typedef struct _Grid_Item_Iterator Grid_Item_Iterator;
18typedef struct _Grid_Item Grid_Item;
19typedef struct _Custom_Table_Data Custom_Table_Data; 8typedef struct _Custom_Table_Data Custom_Table_Data;
20 9
21static Eina_Bool _subobj_del_cb(void *data, const Eo_Event *event); 10static Eina_Bool _subobj_del_cb(void *data, const Eo_Event *event);
22static void _item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx *subobj); 11static void _item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx *subobj);
23 12
24#define GRID_ITEM_KEY "__grid_item"
25
26struct _Grid_Item
27{
28 EINA_INLIST;
29
30 Efl_Gfx *object;
31 int col_span, row_span;
32 int col, row;
33
34 Eina_Bool linear : 1;
35};
36
37struct _Efl_Ui_Grid_Data
38{
39 const Eo_Class *layout_engine;
40 const void *layout_data;
41
42 Grid_Item *items;
43 int count;
44
45 int req_cols, req_rows; // requested - 0 means infinite
46 int last_col, last_row; // only used by linear apis
47 Efl_Orient dir1, dir2; // must be orthogonal (H,V or V,H)
48 struct {
49 double h, v;
50 Eina_Bool scalable: 1;
51 } pad;
52 Eina_Bool linear_recalc : 1;
53};
54
55struct _Grid_Item_Iterator
56{
57 Eina_Iterator iterator;
58 Eina_Iterator *real_iterator;
59 Eina_List *list;
60 Efl_Ui_Grid *object;
61};
62
63struct _Custom_Table_Data 13struct _Custom_Table_Data
64{ 14{
65 Efl_Ui_Grid *parent; 15 Efl_Ui_Grid *parent;
@@ -69,12 +19,6 @@ struct _Custom_Table_Data
69EO_CALLBACKS_ARRAY_DEFINE(subobj_callbacks, 19EO_CALLBACKS_ARRAY_DEFINE(subobj_callbacks,
70 { EO_EVENT_DEL, _subobj_del_cb }); 20 { EO_EVENT_DEL, _subobj_del_cb });
71 21
72static inline Eina_Bool
73_horiz(Efl_Orient dir)
74{
75 return dir % 180 == EFL_ORIENT_RIGHT;
76}
77
78EOLIAN static Eina_Bool 22EOLIAN static Eina_Bool
79_efl_ui_grid_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd EINA_UNUSED) 23_efl_ui_grid_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd EINA_UNUSED)
80{ 24{
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 @@
1#ifndef EFL_UI_GRID_PRIVATE_H
2#define EFL_UI_GRID_PRIVATE_H
3
4#ifdef HAVE_CONFIG_H
5# include "elementary_config.h"
6#endif
7
8#define EFL_PACK_LAYOUT_PROTECTED
9
10#include <Elementary.h>
11#include "elm_priv.h"
12
13typedef struct _Efl_Ui_Grid_Data Efl_Ui_Grid_Data;
14typedef struct _Grid_Item_Iterator Grid_Item_Iterator;
15typedef struct _Grid_Item Grid_Item;
16
17#define GRID_ITEM_KEY "__grid_item"
18
19struct _Grid_Item
20{
21 EINA_INLIST;
22
23 Efl_Gfx *object;
24 int col_span, row_span;
25 int col, row;
26
27 Eina_Bool linear : 1;
28};
29
30struct _Efl_Ui_Grid_Data
31{
32 const Eo_Class *layout_engine;
33 const void *layout_data;
34
35 Grid_Item *items;
36 int count;
37
38 int req_cols, req_rows; // requested - 0 means infinite
39 int last_col, last_row; // only used by linear apis
40 Efl_Orient dir1, dir2; // must be orthogonal (H,V or V,H)
41 struct {
42 double h, v;
43 Eina_Bool scalable: 1;
44 } pad;
45 Eina_Bool linear_recalc : 1;
46};
47
48struct _Grid_Item_Iterator
49{
50 Eina_Iterator iterator;
51 Eina_Iterator *real_iterator;
52 Eina_List *list;
53 Efl_Ui_Grid *object;
54};
55
56static inline Eina_Bool
57_horiz(Efl_Orient dir)
58{
59 return dir % 180 == EFL_ORIENT_RIGHT;
60}
61
62#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 @@
1#include "efl_ui_grid_private.h"
2
3#define MY_CLASS EFL_UI_GRID_STATIC_CLASS
4#define MY_CLASS_NAME "Efl.Ui.Grid.Static"
5
6EOLIAN static Eo *
7_efl_ui_grid_static_eo_base_constructor(Eo *obj, void *pd EINA_UNUSED)
8{
9 Efl_Ui_Grid_Data *gd;
10
11 obj = eo_constructor(eo_super(obj, MY_CLASS));
12 evas_obj_type_set(obj, MY_CLASS_NAME);
13 elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_FILLER);
14
15 gd = eo_data_scope_get(obj, EFL_UI_GRID_CLASS);
16 gd->layout_engine = MY_CLASS;
17 gd->req_cols = 100;
18 gd->req_rows = 100;
19
20 return obj;
21}
22
23EOLIAN static void
24_efl_ui_grid_static_efl_pack_layout_layout_do(Eo_Class *klass EINA_UNUSED,
25 void *_pd EINA_UNUSED,
26 Eo *obj, const void *data EINA_UNUSED)
27{
28 Efl_Ui_Grid_Data *gd;
29 Grid_Item *gi;
30 Evas *e;
31 Evas_Coord x, y, w, h;
32 long long xl, yl, wl, hl, vwl, vhl;
33 Eina_Bool mirror;
34
35 gd = eo_data_scope_get(obj, EFL_UI_GRID_CLASS);
36 if (!gd->items) return;
37
38 e = evas_common_evas_get(obj);
39 eo_event_freeze(e);
40
41 efl_gfx_position_get(obj, &x, &y);
42 efl_gfx_size_get(obj, &w, &h);
43 xl = x;
44 yl = y;
45 wl = w;
46 hl = h;
47 mirror = elm_widget_mirrored_get(obj);
48 vwl = gd->req_cols;
49 vhl = gd->req_rows;
50
51 EINA_INLIST_FOREACH(gd->items, gi)
52 {
53 long long x1, y1, x2, y2;
54
55 if (!mirror)
56 {
57 x1 = xl + ((wl * (long long)gi->col) / vwl);
58 x2 = xl + ((wl * (long long)(gi->col + gi->col_span)) / vwl);
59 }
60 else
61 {
62 x1 = xl + ((wl * (vwl - (long long)(gi->col + gi->col_span))) / vwl);
63 x2 = xl + ((wl * (vwl - (long long)gi->col)) / vwl);
64 }
65 y1 = yl + ((hl * (long long)gi->row) / vhl);
66 y2 = yl + ((hl * (long long)(gi->row + gi->row_span)) / vhl);
67 efl_gfx_position_set(gi->object, x1, y1);
68 efl_gfx_size_set(gi->object, x2 - x1, y2 - y1);
69 }
70
71 eo_event_thaw(e);
72}
73
74#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 @@
1class Efl.Ui.Grid.Static (Efl.Ui.Grid)
2{
3 data: null;
4 implements {
5 Eo.Base.constructor;
6 Efl.Pack.Layout.layout_do;
7 }
8}