summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-05-16 13:03:33 +0200
committerXavi Artigas <xavierartigas@yahoo.es>2019-05-20 13:24:16 +0200
commit41866a885577a189c3056850e7aeef3e72b4c50f (patch)
treeab4b2e8e0239c7cd95c1ae9e2c9ced3ab2450185 /src
parent1692ff3890875be579dbf953bd0ec2146497eba9 (diff)
Efl.Pack_Table: remove table_direction
Summary: The only implementation of this interface, `Efl.Ui.Table`, only supports two fill directions (horizontal or vertical), therefore the table_direction property which supports primary and secondary directions is unnecessarily complicated. Remove it and use only `Efl.Ui.Direction.direction` to select the fill direction. Also, expanded the documentation. Fixes T7962 Test Plan: Everything builds and tests pass. Efl.Ui.Table elementary_test still work. Examples need to be adjusted to stop using table_direction. Reviewers: zmike, YOhoho, bu5hm4n, SanghyeonLee, Jaehyun_Cho Reviewed By: YOhoho Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T7962 Differential Revision: https://phab.enlightenment.org/D8902
Diffstat (limited to 'src')
-rw-r--r--src/bin/elementary/test_ui_table.c2
-rw-r--r--src/lib/efl/interfaces/efl_pack_table.eo33
-rw-r--r--src/lib/elementary/efl_ui_table.c54
-rw-r--r--src/lib/elementary/efl_ui_table.eo15
-rw-r--r--src/lib/elementary/efl_ui_table_private.h2
-rw-r--r--src/tests/elementary/efl_ui_test_table.c17
6 files changed, 38 insertions, 85 deletions
diff --git a/src/bin/elementary/test_ui_table.c b/src/bin/elementary/test_ui_table.c
index 6d52887d69..dab64ddc27 100644
--- a/src/bin/elementary/test_ui_table.c
+++ b/src/bin/elementary/test_ui_table.c
@@ -648,7 +648,7 @@ test_ui_table_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
648 efl_gfx_entity_visible_set(f, 1); 648 efl_gfx_entity_visible_set(f, 1);
649 649
650 efl_pack_table_columns_set(table, 4); 650 efl_pack_table_columns_set(table, 4);
651 efl_pack_table_direction_set(table, EFL_UI_DIR_RIGHT, EFL_UI_DIR_DOWN); 651 efl_ui_direction_set(table, EFL_UI_DIR_RIGHT);
652 efl_gfx_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 652 efl_gfx_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
653 elm_object_content_set(f, table); 653 elm_object_content_set(f, table);
654 efl_gfx_entity_visible_set(table, 1); 654 efl_gfx_entity_visible_set(table, 1);
diff --git a/src/lib/efl/interfaces/efl_pack_table.eo b/src/lib/efl/interfaces/efl_pack_table.eo
index c94bd334d3..9214eb7c65 100644
--- a/src/lib/efl/interfaces/efl_pack_table.eo
+++ b/src/lib/efl/interfaces/efl_pack_table.eo
@@ -1,8 +1,10 @@
1import efl_ui_direction;
2
3interface @beta Efl.Pack_Table extends Efl.Pack 1interface @beta Efl.Pack_Table extends Efl.Pack
4{ 2{
5 [[2D containers aligned on a table with rows and columns]] 3 [[Interface for 2D containers which arrange their elements on a table with rows and columns.
4
5 Elements can be positioned on a specific row and column, or they can be simply added to
6 the table using @Efl.Pack.pack and the container will chose where to put them.
7 ]]
6 c_prefix: efl_pack; 8 c_prefix: efl_pack;
7 methods { 9 methods {
8 pack_table { 10 pack_table {
@@ -61,32 +63,23 @@ interface @beta Efl.Pack_Table extends Efl.Pack
61 } 63 }
62 } 64 }
63 @property table_columns { 65 @property table_columns {
64 [[Gird columns property]] 66 [[Specifies the amount of columns the table will have when the fill direction is horizontal.
65 set { [[Specifies limit for linear adds - if direction is horizontal]] } 67 If it is vertical, the amount of columns depends on the amount of cells added and @.table_rows.
68 ]]
69 set {}
66 get {} 70 get {}
67 values { 71 values {
68 cols: int; [[Number of columns]] 72 cols: int; [[Amount of columns.]]
69 } 73 }
70 } 74 }
71 @property table_rows { 75 @property table_rows {
72 [[Table rows property]] 76 [[Specifies the amount of rows the table will have when the fill direction is vertical.
73 set { [[Specifies limit for linear adds - if direction is vertical]] } 77 If it is horizontal, the amount of rows depends on the amount of cells added and @.table_columns.
74 get {}
75 values {
76 rows: int; [[Number of rows]]
77 }
78 }
79 @property table_direction {
80 [[Primary and secondary up/left/right/down directions for linear apis.
81
82 Default is horizontal and vertical.
83 This overrides @Efl.Ui.Direction.direction.
84 ]] 78 ]]
85 set {} 79 set {}
86 get {} 80 get {}
87 values { 81 values {
88 primary: Efl.Ui.Dir(Efl.Ui.Dir.horizontal); [[Primary direction]] 82 rows: int; [[Amount of rows.]]
89 secondary: Efl.Ui.Dir(Efl.Ui.Dir.vertical); [[Secondary direction]]
90 } 83 }
91 } 84 }
92 } 85 }
diff --git a/src/lib/elementary/efl_ui_table.c b/src/lib/elementary/efl_ui_table.c
index 208dedd80a..3c92dcb2d0 100644
--- a/src/lib/elementary/efl_ui_table.c
+++ b/src/lib/elementary/efl_ui_table.c
@@ -90,7 +90,7 @@ _efl_ui_table_last_position_get(Eo * obj, Efl_Ui_Table_Data *pd, int *last_col,
90 90
91 efl_pack_table_size_get(obj, &req_cols, &req_rows); 91 efl_pack_table_size_get(obj, &req_cols, &req_rows);
92 92
93 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE)) 93 if (efl_ui_dir_is_horizontal(pd->fill_dir, EINA_TRUE))
94 { 94 {
95 EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(pd->items), gi) 95 EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(pd->items), gi)
96 { 96 {
@@ -220,8 +220,7 @@ _efl_ui_table_efl_object_constructor(Eo *obj, Efl_Ui_Table_Data *pd)
220 efl_access_object_access_type_set(obj, EFL_ACCESS_TYPE_SKIPPED); 220 efl_access_object_access_type_set(obj, EFL_ACCESS_TYPE_SKIPPED);
221 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_FILLER); 221 efl_access_object_role_set(obj, EFL_ACCESS_ROLE_FILLER);
222 222
223 pd->dir1 = EFL_UI_DIR_RIGHT; 223 pd->fill_dir = EFL_UI_DIR_RIGHT;
224 pd->dir2 = EFL_UI_DIR_DOWN;
225 pd->last_col = -1; 224 pd->last_col = -1;
226 pd->last_row = -1; 225 pd->last_row = -1;
227 pd->req_cols = 0; 226 pd->req_cols = 0;
@@ -622,24 +621,13 @@ _efl_ui_table_efl_pack_table_table_contents_get(Eo *obj EINA_UNUSED, Efl_Ui_Tabl
622EOLIAN static void 621EOLIAN static void
623_efl_ui_table_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Ui_Dir dir) 622_efl_ui_table_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Ui_Dir dir)
624{ 623{
625 if (pd->dir1 == dir) 624 if (pd->fill_dir == dir)
626 return; 625 return;
627 626
628 if (dir == EFL_UI_DIR_DEFAULT) 627 if (dir == EFL_UI_DIR_DEFAULT)
629 dir = EFL_UI_DIR_RIGHT; 628 dir = EFL_UI_DIR_RIGHT;
630 629
631 pd->dir1 = dir; 630 pd->fill_dir = dir;
632
633 /* if both directions are either horizontal or vertical, need to adjust
634 * secondary direction (dir2) */
635 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE) ==
636 efl_ui_dir_is_horizontal(pd->dir2, EINA_FALSE))
637 {
638 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
639 pd->dir2 = EFL_UI_DIR_DOWN;
640 else
641 pd->dir2 = EFL_UI_DIR_RIGHT;
642 }
643 631
644 efl_pack_layout_request(obj); 632 efl_pack_layout_request(obj);
645} 633}
@@ -647,37 +635,7 @@ _efl_ui_table_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl
647EOLIAN static Efl_Ui_Dir 635EOLIAN static Efl_Ui_Dir
648_efl_ui_table_efl_ui_direction_direction_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd) 636_efl_ui_table_efl_ui_direction_direction_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd)
649{ 637{
650 return pd->dir1; 638 return pd->fill_dir;
651}
652
653EOLIAN static void
654_efl_ui_table_efl_pack_table_table_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Ui_Dir primary, Efl_Ui_Dir secondary)
655{
656 if ((pd->dir1 == primary) && (pd->dir2 == secondary))
657 return;
658
659 pd->dir1 = primary;
660 pd->dir2 = secondary;
661
662 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE) ==
663 efl_ui_dir_is_horizontal(pd->dir2, EINA_FALSE))
664 {
665 ERR("specified two directions in the same axis, secondary directions "
666 " is reset to a valid default");
667 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
668 pd->dir2 = EFL_UI_DIR_DOWN;
669 else
670 pd->dir2 = EFL_UI_DIR_RIGHT;
671 }
672
673 efl_pack_layout_request(obj);
674}
675
676EOLIAN static void
677_efl_ui_table_efl_pack_table_table_direction_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd, Efl_Ui_Dir *primary, Efl_Ui_Dir *secondary)
678{
679 if (primary) *primary = pd->dir1;
680 if (secondary) *secondary = pd->dir2;
681} 639}
682 640
683EOLIAN static void 641EOLIAN static void
@@ -770,7 +728,7 @@ _efl_ui_table_efl_pack_pack(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Gfx_Entity *subo
770 728
771 _efl_ui_table_last_position_get(obj, pd, &last_col, &last_row); 729 _efl_ui_table_last_position_get(obj, pd, &last_col, &last_row);
772 730
773 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE)) 731 if (efl_ui_dir_is_horizontal(pd->fill_dir, EINA_TRUE))
774 { 732 {
775 last_col++; 733 last_col++;
776 if (pd->req_cols && (last_col >= pd->req_cols)) 734 if (pd->req_cols && (last_col >= pd->req_cols))
diff --git a/src/lib/elementary/efl_ui_table.eo b/src/lib/elementary/efl_ui_table.eo
index be5840bce2..463508bfbd 100644
--- a/src/lib/elementary/efl_ui_table.eo
+++ b/src/lib/elementary/efl_ui_table.eo
@@ -1,7 +1,19 @@
1class @beta Efl.Ui.Table extends Efl.Ui.Widget implements Efl.Pack_Table, Efl.Pack_Layout, 1class @beta Efl.Ui.Table extends Efl.Ui.Widget implements Efl.Pack_Table, Efl.Pack_Layout,
2 Efl.Ui.Direction, Efl.Gfx.Arrangement 2 Efl.Ui.Direction, Efl.Gfx.Arrangement
3{ 3{
4 [[Efl UI table class]] 4 [[Widget container that arranges its elements in a grid.
5
6 The amount of rows and columns can be controlled with @Efl.Pack_Table.table_rows
7 and @Efl.Pack_Table.table_columns, and elements can be manually positioned with
8 @Efl.Pack_Table.pack_table.
9 Additionally, a fill direction can be defined with @Efl.Ui.Direction.direction and
10 elements added with @Efl.Pack.pack. Elements are then added following this direction
11 (horizontal or vertical) and when the amount of columns or rows has been reached,
12 a step is taken in the orthogonal direction.
13 In this second case there is no need to define both the amount of columns and rows,
14 as the table will expand as needed.
15 The default fill direction is @Efl.Ui.Dir.right.
16 ]]
5 methods { 17 methods {
6 @property homogeneous { 18 @property homogeneous {
7 [[Control homogeneous mode. 19 [[Control homogeneous mode.
@@ -39,7 +51,6 @@ class @beta Efl.Ui.Table extends Efl.Ui.Widget implements Efl.Pack_Table, Efl.Pa
39 Efl.Pack_Table.table_size { get; set; } 51 Efl.Pack_Table.table_size { get; set; }
40 Efl.Pack_Table.table_columns { get; set; } 52 Efl.Pack_Table.table_columns { get; set; }
41 Efl.Pack_Table.table_rows { get; set; } 53 Efl.Pack_Table.table_rows { get; set; }
42 Efl.Pack_Table.table_direction { get; set; }
43 Efl.Pack_Layout.layout_update; 54 Efl.Pack_Layout.layout_update;
44 Efl.Pack_Layout.layout_request; 55 Efl.Pack_Layout.layout_request;
45 } 56 }
diff --git a/src/lib/elementary/efl_ui_table_private.h b/src/lib/elementary/efl_ui_table_private.h
index 5b1e193646..8d134ece73 100644
--- a/src/lib/elementary/efl_ui_table_private.h
+++ b/src/lib/elementary/efl_ui_table_private.h
@@ -36,7 +36,7 @@ struct _Efl_Ui_Table_Data
36 int cols, rows; 36 int cols, rows;
37 int req_cols, req_rows; // requested - 0 means infinite 37 int req_cols, req_rows; // requested - 0 means infinite
38 int last_col, last_row; // only used by pack api 38 int last_col, last_row; // only used by pack api
39 Efl_Ui_Dir dir1, dir2; // must be orthogonal (H,V or V,H) 39 Efl_Ui_Dir fill_dir; // direction in which cells are added when using pack()
40 struct { 40 struct {
41 double h, v; 41 double h, v;
42 Eina_Bool scalable: 1; 42 Eina_Bool scalable: 1;
diff --git a/src/tests/elementary/efl_ui_test_table.c b/src/tests/elementary/efl_ui_test_table.c
index 476be61159..a1761f1613 100644
--- a/src/tests/elementary/efl_ui_test_table.c
+++ b/src/tests/elementary/efl_ui_test_table.c
@@ -488,7 +488,6 @@ EFL_START_TEST (efl_ui_table_properties)
488 double h, v; 488 double h, v;
489 Eina_Bool b; 489 Eina_Bool b;
490 Eina_Bool homogeneoush, homogeneousv; 490 Eina_Bool homogeneoush, homogeneousv;
491 Efl_Ui_Dir dirh, dirv;
492 491
493 //align test 492 //align test
494 efl_gfx_arrangement_content_align_get(layout, &h, &v); 493 efl_gfx_arrangement_content_align_get(layout, &h, &v);
@@ -524,20 +523,12 @@ EFL_START_TEST (efl_ui_table_properties)
524 ck_assert_int_eq(b, 1); 523 ck_assert_int_eq(b, 1);
525 524
526 //direction test 525 //direction test
527 efl_pack_table_direction_get(layout, &dirh, &dirv); 526 ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_RIGHT);
528 ck_assert_int_eq(dirh, EFL_UI_DIR_RIGHT);
529 ck_assert_int_eq(dirv, EFL_UI_DIR_DOWN);
530
531 efl_pack_table_direction_set(layout, EFL_UI_DIR_VERTICAL, EFL_UI_DIR_HORIZONTAL);
532 efl_pack_table_direction_get(layout, &dirh, &dirv);
533 ck_assert_int_eq(dirh, EFL_UI_DIR_VERTICAL);
534 ck_assert_int_eq(dirv, EFL_UI_DIR_HORIZONTAL);
535 527
536 efl_pack_table_direction_set(layout, EFL_UI_DIR_RIGHT, EFL_UI_DIR_RIGHT); 528 efl_ui_direction_set(layout, EFL_UI_DIR_VERTICAL);
537 efl_pack_table_direction_get(layout, &dirh, &dirv); 529 ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_VERTICAL);
538 ck_assert_int_eq(dirh, EFL_UI_DIR_RIGHT);
539 ck_assert_int_eq(dirv, EFL_UI_DIR_DOWN);
540 530
531 efl_ui_direction_set(layout, EFL_UI_DIR_RIGHT);
541 ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_RIGHT); 532 ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_RIGHT);
542 533
543 efl_ui_direction_set(layout, EFL_UI_DIR_DEFAULT); 534 efl_ui_direction_set(layout, EFL_UI_DIR_DEFAULT);