summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2017-08-09 23:36:02 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-08-10 14:42:08 +0900
commit6372dcdc2df599381a359a7daa8feb7aaf141f58 (patch)
tree0d15deffcfb5bbb489e5e9e978062002b5eb0973
parent43c07afbf1aa08c175f62b27d78433256d3d9e2e (diff)
grid: Switch to Efl.Ui.Dir (EO)
Ref T5870
-rw-r--r--src/bin/elementary/test_ui_grid.c2
-rw-r--r--src/lib/efl/interfaces/efl_pack_grid.eo11
-rw-r--r--src/lib/elementary/efl_ui_grid.c57
-rw-r--r--src/lib/elementary/efl_ui_grid.eo6
-rw-r--r--src/lib/elementary/efl_ui_grid_private.h8
-rw-r--r--src/lib/elementary/elm_priv.h1
6 files changed, 36 insertions, 49 deletions
diff --git a/src/bin/elementary/test_ui_grid.c b/src/bin/elementary/test_ui_grid.c
index a293566ea1..1a84b40aae 100644
--- a/src/bin/elementary/test_ui_grid.c
+++ b/src/bin/elementary/test_ui_grid.c
@@ -585,7 +585,7 @@ test_ui_grid_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
585 efl_gfx_visible_set(f, 1); 585 efl_gfx_visible_set(f, 1);
586 586
587 efl_pack_grid_columns_set(grid, 4); 587 efl_pack_grid_columns_set(grid, 4);
588 efl_pack_grid_orientation_set(grid, EFL_ORIENT_RIGHT, EFL_ORIENT_DOWN); 588 efl_pack_grid_direction_set(grid, EFL_UI_DIR_RIGHT, EFL_UI_DIR_DOWN);
589 efl_gfx_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 589 efl_gfx_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
590 elm_object_content_set(f, grid); 590 elm_object_content_set(f, grid);
591 efl_gfx_visible_set(grid, 1); 591 efl_gfx_visible_set(grid, 1);
diff --git a/src/lib/efl/interfaces/efl_pack_grid.eo b/src/lib/efl/interfaces/efl_pack_grid.eo
index a0832bb753..1f1f21fbce 100644
--- a/src/lib/efl/interfaces/efl_pack_grid.eo
+++ b/src/lib/efl/interfaces/efl_pack_grid.eo
@@ -71,16 +71,17 @@ interface Efl.Pack.Grid (Efl.Pack.Linear)
71 rows: int; [[Number of rows]] 71 rows: int; [[Number of rows]]
72 } 72 }
73 } 73 }
74 @property grid_orientation { 74 @property grid_direction {
75 [[Primary and secondary up/left/right/down orientations for linear apis. 75 [[Primary and secondary up/left/right/down directions for linear apis.
76 76
77 Default is right and down. Overrides @Efl.Orientation.orientation. 77 Default is horizontal and vertical.
78 This overrides @Efl.Ui.Direction.direction.
78 ]] 79 ]]
79 set {} 80 set {}
80 get {} 81 get {}
81 values { 82 values {
82 primary: Efl.Orient; [[Primary orientation]] 83 primary: Efl.Ui.Dir(Efl.Ui.Dir.horizontal); [[Primary direction]]
83 secondary: Efl.Orient; [[Secondary orientation]] 84 secondary: Efl.Ui.Dir(Efl.Ui.Dir.vertical); [[Secondary direction]]
84 } 85 }
85 } 86 }
86 } 87 }
diff --git a/src/lib/elementary/efl_ui_grid.c b/src/lib/elementary/efl_ui_grid.c
index 181db543d5..58a8e0515a 100644
--- a/src/lib/elementary/efl_ui_grid.c
+++ b/src/lib/elementary/efl_ui_grid.c
@@ -274,8 +274,8 @@ _efl_ui_grid_efl_object_constructor(Eo *obj, Efl_Ui_Grid_Data *pd)
274 efl_canvas_object_type_set(obj, MY_CLASS_NAME); 274 efl_canvas_object_type_set(obj, MY_CLASS_NAME);
275 elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_FILLER); 275 elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_FILLER);
276 276
277 pd->dir1 = EFL_ORIENT_RIGHT; 277 pd->dir1 = EFL_UI_DIR_RIGHT;
278 pd->dir2 = EFL_ORIENT_DOWN; 278 pd->dir2 = EFL_UI_DIR_DOWN;
279 pd->last_col = -1; 279 pd->last_col = -1;
280 pd->last_row = -1; 280 pd->last_row = -1;
281 pd->req_cols = 0; 281 pd->req_cols = 0;
@@ -474,7 +474,7 @@ _item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx *subobj)
474 } 474 }
475 if (last) 475 if (last)
476 { 476 {
477 if (_horiz(pd->dir1)) 477 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
478 { 478 {
479 pd->last_col = last->col + last->col_span - 1; 479 pd->last_col = last->col + last->col_span - 1;
480 pd->last_row = last->row; 480 pd->last_row = last->row;
@@ -634,61 +634,52 @@ _efl_ui_grid_efl_pack_grid_grid_contents_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_
634} 634}
635 635
636EOLIAN static void 636EOLIAN static void
637_efl_ui_grid_efl_orientation_orientation_set(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Orient orient) 637_efl_ui_grid_efl_ui_direction_direction_set(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Ui_Dir dir)
638{ 638{
639 EINA_SAFETY_ON_FALSE_RETURN((orient % 90) == 0); 639 pd->dir1 = dir;
640 640
641 pd->dir1 = orient; 641 /* if both directions are either horizontal or vertical, need to adjust
642 642 * secondary direction (dir2) */
643 /* if both orientations are either horizontal or vertical, need to adjust 643 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE) ==
644 * secondary orientation (dir2) */ 644 efl_ui_dir_is_horizontal(pd->dir2, EINA_FALSE))
645 if (_horiz(pd->dir1) == _horiz(pd->dir2))
646 { 645 {
647 if (!_horiz(pd->dir1)) 646 if (!efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
648 pd->dir2 = EFL_ORIENT_RIGHT; 647 pd->dir2 = EFL_UI_DIR_RIGHT;
649 else 648 else
650 pd->dir2 = EFL_ORIENT_DOWN; 649 pd->dir2 = EFL_UI_DIR_DOWN;
651 } 650 }
652 651
653 efl_pack_layout_request(obj); 652 efl_pack_layout_request(obj);
654} 653}
655 654
656EOLIAN static Efl_Orient 655EOLIAN static Efl_Ui_Dir
657_efl_ui_grid_efl_orientation_orientation_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd) 656_efl_ui_grid_efl_ui_direction_direction_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd)
658{ 657{
659 return pd->dir1; 658 return pd->dir1;
660} 659}
661 660
662EOLIAN static void 661EOLIAN static void
663_efl_ui_grid_efl_pack_grid_grid_orientation_set(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Orient primary, Efl_Orient secondary) 662_efl_ui_grid_efl_pack_grid_grid_direction_set(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Ui_Dir primary, Efl_Ui_Dir secondary)
664{ 663{
665 EINA_SAFETY_ON_FALSE_RETURN((primary % 90) == 0);
666 EINA_SAFETY_ON_FALSE_RETURN((secondary % 90) == 0);
667
668 pd->dir1 = primary; 664 pd->dir1 = primary;
669 pd->dir2 = secondary; 665 pd->dir2 = secondary;
670 666
671 if (_horiz(pd->dir1) == _horiz(pd->dir2)) 667 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE) ==
668 efl_ui_dir_is_horizontal(pd->dir2, EINA_FALSE))
672 { 669 {
673 ERR("specified two orientations in the same axis, secondary orientation " 670 ERR("specified two directions in the same axis, secondary directions "
674 " is reset to a valid default"); 671 " is reset to a valid default");
675 switch (pd->dir1) 672 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
676 { 673 pd->dir2 = EFL_UI_DIR_DOWN;
677 case EFL_ORIENT_DOWN: 674 else
678 case EFL_ORIENT_UP: 675 pd->dir2 = EFL_UI_DIR_RIGHT;
679 pd->dir2 = EFL_ORIENT_RIGHT;
680 break;
681 default:
682 pd->dir2 = EFL_ORIENT_DOWN;
683 break;
684 }
685 } 676 }
686 677
687 efl_pack_layout_request(obj); 678 efl_pack_layout_request(obj);
688} 679}
689 680
690EOLIAN static void 681EOLIAN static void
691_efl_ui_grid_efl_pack_grid_grid_orientation_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd, Efl_Orient *primary, Efl_Orient *secondary) 682_efl_ui_grid_efl_pack_grid_grid_direction_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd, Efl_Ui_Dir *primary, Efl_Ui_Dir *secondary)
692{ 683{
693 if (primary) *primary = pd->dir1; 684 if (primary) *primary = pd->dir1;
694 if (secondary) *secondary = pd->dir2; 685 if (secondary) *secondary = pd->dir2;
@@ -770,7 +761,7 @@ _efl_ui_grid_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Gfx *su
770 int col = pd->last_col; 761 int col = pd->last_col;
771 int row = pd->last_row; 762 int row = pd->last_row;
772 763
773 if (_horiz(pd->dir1)) 764 if (efl_ui_dir_is_horizontal(pd->dir1, EINA_TRUE))
774 { 765 {
775 col++; 766 col++;
776 if (pd->req_cols && (col >= pd->req_cols)) 767 if (pd->req_cols && (col >= pd->req_cols))
diff --git a/src/lib/elementary/efl_ui_grid.eo b/src/lib/elementary/efl_ui_grid.eo
index 6e330a46b9..bc6c98a467 100644
--- a/src/lib/elementary/efl_ui_grid.eo
+++ b/src/lib/elementary/efl_ui_grid.eo
@@ -1,5 +1,5 @@
1class Efl.Ui.Grid (Elm.Widget, Efl.Pack.Grid, Efl.Pack.Layout, 1class Efl.Ui.Grid (Elm.Widget, Efl.Pack.Grid, Efl.Pack.Layout,
2 Efl.Orientation) 2 Efl.Ui.Direction)
3{ 3{
4 [[Efl UI grid class]] 4 [[Efl UI grid class]]
5 implements { 5 implements {
@@ -12,7 +12,7 @@ class Efl.Ui.Grid (Elm.Widget, Efl.Pack.Grid, Efl.Pack.Layout,
12 Elm.Widget.theme_apply; 12 Elm.Widget.theme_apply;
13 Efl.Container.content_iterate; 13 Efl.Container.content_iterate;
14 Efl.Container.content_count; 14 Efl.Container.content_count;
15 Efl.Orientation.orientation { get; set; } 15 Efl.Ui.Direction.direction { get; set; }
16 Efl.Pack.pack_clear; 16 Efl.Pack.pack_clear;
17 Efl.Pack.unpack_all; 17 Efl.Pack.unpack_all;
18 Efl.Pack.unpack; 18 Efl.Pack.unpack;
@@ -25,7 +25,7 @@ class Efl.Ui.Grid (Elm.Widget, Efl.Pack.Grid, Efl.Pack.Layout,
25 Efl.Pack.Grid.grid_size { get; set; } 25 Efl.Pack.Grid.grid_size { get; set; }
26 Efl.Pack.Grid.grid_columns { get; set; } 26 Efl.Pack.Grid.grid_columns { get; set; }
27 Efl.Pack.Grid.grid_rows { get; set; } 27 Efl.Pack.Grid.grid_rows { get; set; }
28 Efl.Pack.Grid.grid_orientation { get; set; } 28 Efl.Pack.Grid.grid_direction { get; set; }
29 Efl.Pack.Linear.pack_end; 29 Efl.Pack.Linear.pack_end;
30 Efl.Pack.Layout.layout_update; 30 Efl.Pack.Layout.layout_update;
31 Efl.Pack.Layout.layout_request; 31 Efl.Pack.Layout.layout_request;
diff --git a/src/lib/elementary/efl_ui_grid_private.h b/src/lib/elementary/efl_ui_grid_private.h
index 5d9f9efc25..e362bfa607 100644
--- a/src/lib/elementary/efl_ui_grid_private.h
+++ b/src/lib/elementary/efl_ui_grid_private.h
@@ -34,7 +34,7 @@ struct _Efl_Ui_Grid_Data
34 34
35 int req_cols, req_rows; // requested - 0 means infinite 35 int req_cols, req_rows; // requested - 0 means infinite
36 int last_col, last_row; // only used by linear apis 36 int last_col, last_row; // only used by linear apis
37 Efl_Orient dir1, dir2; // must be orthogonal (H,V or V,H) 37 Efl_Ui_Dir dir1, dir2; // must be orthogonal (H,V or V,H)
38 struct { 38 struct {
39 double h, v; 39 double h, v;
40 Eina_Bool scalable: 1; 40 Eina_Bool scalable: 1;
@@ -50,10 +50,4 @@ struct _Grid_Item_Iterator
50 Efl_Ui_Grid *object; 50 Efl_Ui_Grid *object;
51}; 51};
52 52
53static inline Eina_Bool
54_horiz(Efl_Orient dir)
55{
56 return dir % 180 == EFL_ORIENT_RIGHT;
57}
58
59#endif 53#endif
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index 09cb28533f..67f4dea3f2 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -653,6 +653,7 @@ efl_ui_dir_is_horizontal(Efl_Ui_Dir dir, Eina_Bool def_val)
653 case EFL_UI_DIR_RTL: return EINA_TRUE; 653 case EFL_UI_DIR_RTL: return EINA_TRUE;
654 case EFL_UI_DIR_DOWN: return EINA_FALSE; 654 case EFL_UI_DIR_DOWN: return EINA_FALSE;
655 case EFL_UI_DIR_UP: return EINA_FALSE; 655 case EFL_UI_DIR_UP: return EINA_FALSE;
656 default: return !!def_val;
656 } 657 }
657} 658}
658 659