diff options
author | Xavi Artigas <xavierartigas@yahoo.es> | 2019-05-16 13:03:33 +0200 |
---|---|---|
committer | Xavi Artigas <xavierartigas@yahoo.es> | 2019-05-20 13:24:16 +0200 |
commit | 41866a885577a189c3056850e7aeef3e72b4c50f (patch) | |
tree | ab4b2e8e0239c7cd95c1ae9e2c9ced3ab2450185 | |
parent | 1692ff3890875be579dbf953bd0ec2146497eba9 (diff) | |
download | efl-41866a885577a189c3056850e7aeef3e72b4c50f.tar.gz |
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
-rw-r--r-- | src/bin/elementary/test_ui_table.c | 2 | ||||
-rw-r--r-- | src/lib/efl/interfaces/efl_pack_table.eo | 33 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_table.c | 54 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_table.eo | 15 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_table_private.h | 2 | ||||
-rw-r--r-- | src/tests/elementary/efl_ui_test_table.c | 17 |
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, efl_gfx_entity_visible_set(f, 1); efl_pack_table_columns_set(table, 4); - efl_pack_table_direction_set(table, EFL_UI_DIR_RIGHT, EFL_UI_DIR_DOWN); + efl_ui_direction_set(table, EFL_UI_DIR_RIGHT); efl_gfx_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_object_content_set(f, table); 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 @@ -import efl_ui_direction; - interface @beta Efl.Pack_Table extends Efl.Pack { - [[2D containers aligned on a table with rows and columns]] + [[Interface for 2D containers which arrange their elements on a table with rows and columns. + + Elements can be positioned on a specific row and column, or they can be simply added to + the table using @Efl.Pack.pack and the container will chose where to put them. + ]] c_prefix: efl_pack; methods { pack_table { @@ -61,32 +63,23 @@ interface @beta Efl.Pack_Table extends Efl.Pack } } @property table_columns { - [[Gird columns property]] - set { [[Specifies limit for linear adds - if direction is horizontal]] } + [[Specifies the amount of columns the table will have when the fill direction is horizontal. + If it is vertical, the amount of columns depends on the amount of cells added and @.table_rows. + ]] + set {} get {} values { - cols: int; [[Number of columns]] + cols: int; [[Amount of columns.]] } } @property table_rows { - [[Table rows property]] - set { [[Specifies limit for linear adds - if direction is vertical]] } - get {} - values { - rows: int; [[Number of rows]] - } - } - @property table_direction { - [[Primary and secondary up/left/right/down directions for linear apis. - - Default is horizontal and vertical. - This overrides @Efl.Ui.Direction.direction. + [[Specifies the amount of rows the table will have when the fill direction is vertical. + If it is horizontal, the amount of rows depends on the amount of cells added and @.table_columns. ]] set {} get {} values { - primary: Efl.Ui.Dir(Efl.Ui.Dir.horizontal); [[Primary direction]] - secondary: Efl.Ui.Dir(Efl.Ui.Dir.vertical); [[Secondary direction]] + rows: int; [[Amount of rows.]] } } } 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, efl_pack_table_size_get(obj, &req_cols, &req_rows); - if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE)) + if (efl_ui_dir_is_horizontal(pd->fill_dir, EINA_TRUE)) { EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(pd->items), gi) { @@ -220,8 +220,7 @@ _efl_ui_table_efl_object_constructor(Eo *obj, Efl_Ui_Table_Data *pd) efl_access_object_access_type_set(obj, EFL_ACCESS_TYPE_SKIPPED); efl_access_object_role_set(obj, EFL_ACCESS_ROLE_FILLER); - pd->dir1 = EFL_UI_DIR_RIGHT; - pd->dir2 = EFL_UI_DIR_DOWN; + pd->fill_dir = EFL_UI_DIR_RIGHT; pd->last_col = -1; pd->last_row = -1; pd->req_cols = 0; @@ -622,24 +621,13 @@ _efl_ui_table_efl_pack_table_table_contents_get(Eo *obj EINA_UNUSED, Efl_Ui_Tabl EOLIAN static void _efl_ui_table_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Ui_Dir dir) { - if (pd->dir1 == dir) + if (pd->fill_dir == dir) return; if (dir == EFL_UI_DIR_DEFAULT) dir = EFL_UI_DIR_RIGHT; - pd->dir1 = dir; - - /* if both directions are either horizontal or vertical, need to adjust - * secondary direction (dir2) */ - if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE) == - efl_ui_dir_is_horizontal(pd->dir2, EINA_FALSE)) - { - if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE)) - pd->dir2 = EFL_UI_DIR_DOWN; - else - pd->dir2 = EFL_UI_DIR_RIGHT; - } + pd->fill_dir = dir; efl_pack_layout_request(obj); } @@ -647,37 +635,7 @@ _efl_ui_table_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl EOLIAN static Efl_Ui_Dir _efl_ui_table_efl_ui_direction_direction_get(const Eo *obj EINA_UNUSED, Efl_Ui_Table_Data *pd) { - return pd->dir1; -} - -EOLIAN static void -_efl_ui_table_efl_pack_table_table_direction_set(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Ui_Dir primary, Efl_Ui_Dir secondary) -{ - if ((pd->dir1 == primary) && (pd->dir2 == secondary)) - return; - - pd->dir1 = primary; - pd->dir2 = secondary; - - if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE) == - efl_ui_dir_is_horizontal(pd->dir2, EINA_FALSE)) - { - ERR("specified two directions in the same axis, secondary directions " - " is reset to a valid default"); - if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE)) - pd->dir2 = EFL_UI_DIR_DOWN; - else - pd->dir2 = EFL_UI_DIR_RIGHT; - } - - efl_pack_layout_request(obj); -} - -EOLIAN static void -_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) -{ - if (primary) *primary = pd->dir1; - if (secondary) *secondary = pd->dir2; + return pd->fill_dir; } EOLIAN static void @@ -770,7 +728,7 @@ _efl_ui_table_efl_pack_pack(Eo *obj, Efl_Ui_Table_Data *pd, Efl_Gfx_Entity *subo _efl_ui_table_last_position_get(obj, pd, &last_col, &last_row); - if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE)) + if (efl_ui_dir_is_horizontal(pd->fill_dir, EINA_TRUE)) { last_col++; 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 @@ class @beta Efl.Ui.Table extends Efl.Ui.Widget implements Efl.Pack_Table, Efl.Pack_Layout, Efl.Ui.Direction, Efl.Gfx.Arrangement { - [[Efl UI table class]] + [[Widget container that arranges its elements in a grid. + + The amount of rows and columns can be controlled with @Efl.Pack_Table.table_rows + and @Efl.Pack_Table.table_columns, and elements can be manually positioned with + @Efl.Pack_Table.pack_table. + Additionally, a fill direction can be defined with @Efl.Ui.Direction.direction and + elements added with @Efl.Pack.pack. Elements are then added following this direction + (horizontal or vertical) and when the amount of columns or rows has been reached, + a step is taken in the orthogonal direction. + In this second case there is no need to define both the amount of columns and rows, + as the table will expand as needed. + The default fill direction is @Efl.Ui.Dir.right. + ]] methods { @property homogeneous { [[Control homogeneous mode. @@ -39,7 +51,6 @@ class @beta Efl.Ui.Table extends Efl.Ui.Widget implements Efl.Pack_Table, Efl.Pa Efl.Pack_Table.table_size { get; set; } Efl.Pack_Table.table_columns { get; set; } Efl.Pack_Table.table_rows { get; set; } - Efl.Pack_Table.table_direction { get; set; } Efl.Pack_Layout.layout_update; Efl.Pack_Layout.layout_request; } 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 int cols, rows; int req_cols, req_rows; // requested - 0 means infinite int last_col, last_row; // only used by pack api - Efl_Ui_Dir dir1, dir2; // must be orthogonal (H,V or V,H) + Efl_Ui_Dir fill_dir; // direction in which cells are added when using pack() struct { double h, v; 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) double h, v; Eina_Bool b; Eina_Bool homogeneoush, homogeneousv; - Efl_Ui_Dir dirh, dirv; //align test efl_gfx_arrangement_content_align_get(layout, &h, &v); @@ -524,20 +523,12 @@ EFL_START_TEST (efl_ui_table_properties) ck_assert_int_eq(b, 1); //direction test - efl_pack_table_direction_get(layout, &dirh, &dirv); - ck_assert_int_eq(dirh, EFL_UI_DIR_RIGHT); - ck_assert_int_eq(dirv, EFL_UI_DIR_DOWN); - - efl_pack_table_direction_set(layout, EFL_UI_DIR_VERTICAL, EFL_UI_DIR_HORIZONTAL); - efl_pack_table_direction_get(layout, &dirh, &dirv); - ck_assert_int_eq(dirh, EFL_UI_DIR_VERTICAL); - ck_assert_int_eq(dirv, EFL_UI_DIR_HORIZONTAL); + ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_RIGHT); - efl_pack_table_direction_set(layout, EFL_UI_DIR_RIGHT, EFL_UI_DIR_RIGHT); - efl_pack_table_direction_get(layout, &dirh, &dirv); - ck_assert_int_eq(dirh, EFL_UI_DIR_RIGHT); - ck_assert_int_eq(dirv, EFL_UI_DIR_DOWN); + efl_ui_direction_set(layout, EFL_UI_DIR_VERTICAL); + ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_VERTICAL); + efl_ui_direction_set(layout, EFL_UI_DIR_RIGHT); ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_RIGHT); efl_ui_direction_set(layout, EFL_UI_DIR_DEFAULT); |