forked from enlightenment/efl
ui.table: remove leagcy evas_table from Efl.Ui.Table
Remove evas_table. This expect to improve performance by removing internal function call related evas_table. Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D8615
This commit is contained in:
parent
ef3281c924
commit
3e49501043
File diff suppressed because it is too large
Load Diff
|
@ -20,7 +20,8 @@ class @beta Efl.Ui.Table extends Efl.Ui.Widget implements Efl.Pack_Table, Efl.Pa
|
||||||
implements {
|
implements {
|
||||||
Efl.Object.constructor;
|
Efl.Object.constructor;
|
||||||
Efl.Canvas.Group.group_calculate;
|
Efl.Canvas.Group.group_calculate;
|
||||||
Efl.Ui.Widget.theme_apply;
|
Efl.Gfx.Entity.position { set; }
|
||||||
|
Efl.Gfx.Entity.size { set; }
|
||||||
Efl.Container.content_iterate;
|
Efl.Container.content_iterate;
|
||||||
Efl.Container.content_count;
|
Efl.Container.content_count;
|
||||||
Efl.Ui.Direction.direction { get; set; }
|
Efl.Ui.Direction.direction { get; set; }
|
||||||
|
|
|
@ -224,13 +224,14 @@ _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
|
||||||
Table_Item *ti;
|
Table_Item *ti;
|
||||||
Item_Calc *items, *item;
|
Item_Calc *items, *item;
|
||||||
Efl_Ui_Container_Item_Hints *hints;
|
Efl_Ui_Container_Item_Hints *hints;
|
||||||
int id = 0, i = 0, rows, cols;
|
int id = 0, i = 0, count, rows, cols;
|
||||||
int (*_efl_ui_table_item_pos_get[2])(Table_Calc *, Item_Calc *, Eina_Bool);
|
int (*_efl_ui_table_item_pos_get[2])(Table_Calc *, Item_Calc *, Eina_Bool);
|
||||||
int (*_efl_ui_table_item_size_get[2])(Table_Calc *, Item_Calc *, Eina_Bool);
|
int (*_efl_ui_table_item_size_get[2])(Table_Calc *, Item_Calc *, Eina_Bool);
|
||||||
|
|
||||||
Table_Calc table_calc;
|
Table_Calc table_calc;
|
||||||
|
|
||||||
if (!pd->count)
|
count = pd->count;
|
||||||
|
|
||||||
|
if (!count)
|
||||||
{
|
{
|
||||||
efl_gfx_hint_size_restricted_min_set(ui_table, EINA_SIZE2D(0, 0));
|
efl_gfx_hint_size_restricted_min_set(ui_table, EINA_SIZE2D(0, 0));
|
||||||
return;
|
return;
|
||||||
|
@ -249,20 +250,21 @@ _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
|
||||||
memset(table_calc.cell_calc[0], 0, cols * sizeof(Cell_Calc));
|
memset(table_calc.cell_calc[0], 0, cols * sizeof(Cell_Calc));
|
||||||
memset(table_calc.cell_calc[1], 0, rows * sizeof(Cell_Calc));
|
memset(table_calc.cell_calc[1], 0, rows * sizeof(Cell_Calc));
|
||||||
|
|
||||||
items = alloca(pd->count * sizeof(*items));
|
items = alloca(count * sizeof(*items));
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
memset(items, 0, pd->count * sizeof(*items));
|
memset(items, 0, count * sizeof(*items));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
table_calc.cols = cols;
|
table_calc.cols = cols;
|
||||||
table_calc.rows = rows;
|
table_calc.rows = rows;
|
||||||
// scan all items, get their properties, calculate total weight & min size
|
// scan all items, get their properties, calculate total weight & min size
|
||||||
EINA_INLIST_FOREACH(pd->items, ti)
|
EINA_INLIST_FOREACH(EINA_INLIST_GET(pd->items), ti)
|
||||||
{
|
{
|
||||||
if (((ti->col + ti->col_span) > cols) ||
|
if (((ti->col + ti->col_span) > cols) ||
|
||||||
((ti->row + ti->row_span) > rows))
|
((ti->row + ti->row_span) > rows))
|
||||||
{
|
{
|
||||||
efl_gfx_entity_visible_set(ti->object, EINA_FALSE);
|
efl_gfx_entity_geometry_set(ti->object, EINA_RECT(9999, 9999, 0, 0));
|
||||||
|
count--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +345,7 @@ _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
|
||||||
_efl_ui_table_item_size_get[1] = _efl_ui_table_regular_item_size_get;
|
_efl_ui_table_item_size_get[1] = _efl_ui_table_regular_item_size_get;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < pd->count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
Eina_Rect space, item_geom;
|
Eina_Rect space, item_geom;
|
||||||
item = &items[i];
|
item = &items[i];
|
||||||
|
|
|
@ -25,17 +25,17 @@ struct _Table_Item
|
||||||
Efl_Gfx_Entity *object;
|
Efl_Gfx_Entity *object;
|
||||||
int col_span, row_span;
|
int col_span, row_span;
|
||||||
int col, row;
|
int col, row;
|
||||||
|
|
||||||
Eina_Bool linear : 1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Efl_Ui_Table_Data
|
struct _Efl_Ui_Table_Data
|
||||||
{
|
{
|
||||||
Table_Item *items;
|
Table_Item *items;
|
||||||
|
Eo *clipper;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
|
int cols, rows;
|
||||||
int req_cols, req_rows; // requested - 0 means infinite
|
int req_cols, req_rows; // requested - 0 means infinite
|
||||||
int last_col, last_row; // only used by linear apis
|
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 dir1, dir2; // must be orthogonal (H,V or V,H)
|
||||||
struct {
|
struct {
|
||||||
double h, v;
|
double h, v;
|
||||||
|
@ -44,6 +44,8 @@ struct _Efl_Ui_Table_Data
|
||||||
struct {
|
struct {
|
||||||
double h, v;
|
double h, v;
|
||||||
} align;
|
} align;
|
||||||
|
Eina_Bool cols_recalc : 1;
|
||||||
|
Eina_Bool rows_recalc : 1;
|
||||||
Eina_Bool linear_recalc : 1;
|
Eina_Bool linear_recalc : 1;
|
||||||
Eina_Bool homogeneoush : 1;
|
Eina_Bool homogeneoush : 1;
|
||||||
Eina_Bool homogeneousv : 1;
|
Eina_Bool homogeneousv : 1;
|
||||||
|
@ -52,9 +54,8 @@ struct _Efl_Ui_Table_Data
|
||||||
struct _Table_Item_Iterator
|
struct _Table_Item_Iterator
|
||||||
{
|
{
|
||||||
Eina_Iterator iterator;
|
Eina_Iterator iterator;
|
||||||
Eina_Iterator *real_iterator;
|
|
||||||
Eina_List *list;
|
|
||||||
Efl_Ui_Table *object;
|
Efl_Ui_Table *object;
|
||||||
|
Eina_Inlist *cur;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -251,9 +251,7 @@ layout_setup()
|
||||||
{
|
{
|
||||||
win = win_add();
|
win = win_add();
|
||||||
|
|
||||||
layout = efl_add(EFL_UI_TABLE_CLASS, win,
|
layout = efl_add(EFL_UI_TABLE_CLASS, win);
|
||||||
efl_pack_align_set(efl_added, 0.8, 0.2),
|
|
||||||
efl_ui_direction_set(efl_added, EFL_UI_DIR_VERTICAL));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -281,6 +279,9 @@ EFL_START_TEST (efl_ui_table_layout_update)
|
||||||
{
|
{
|
||||||
int i, max_index = (sizeof(hints) / sizeof(Hint));
|
int i, max_index = (sizeof(hints) / sizeof(Hint));
|
||||||
|
|
||||||
|
efl_pack_align_set(layout, 0.8, 0.2);
|
||||||
|
efl_ui_direction_set(layout, EFL_UI_DIR_VERTICAL);
|
||||||
|
|
||||||
Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
|
Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
|
||||||
efl_pack_table(layout, efl_added, 0, 0, 1, 1));
|
efl_pack_table(layout, efl_added, 0, 0, 1, 1));
|
||||||
|
|
||||||
|
@ -297,6 +298,9 @@ EFL_START_TEST (efl_ui_table_layout_update_pack)
|
||||||
int i, max_index2, max_index3;
|
int i, max_index2, max_index3;
|
||||||
Eo *btn, *btn2, *btn3;
|
Eo *btn, *btn2, *btn3;
|
||||||
|
|
||||||
|
efl_pack_align_set(layout, 0.8, 0.2);
|
||||||
|
efl_ui_direction_set(layout, EFL_UI_DIR_VERTICAL);
|
||||||
|
|
||||||
max_index2 = ((sizeof(hints2) / sizeof(Hint)) / 2);
|
max_index2 = ((sizeof(hints2) / sizeof(Hint)) / 2);
|
||||||
max_index3 = ((sizeof(hints3) / sizeof(Hint)) / 3);
|
max_index3 = ((sizeof(hints3) / sizeof(Hint)) / 3);
|
||||||
|
|
||||||
|
@ -333,6 +337,9 @@ EFL_START_TEST (efl_ui_table_layout_update_matrix)
|
||||||
int i, j, max_index = (sizeof(hints_matrix) / sizeof(Hint));
|
int i, j, max_index = (sizeof(hints_matrix) / sizeof(Hint));
|
||||||
Eo *btn[9];
|
Eo *btn[9];
|
||||||
|
|
||||||
|
efl_pack_align_set(layout, 0.8, 0.2);
|
||||||
|
efl_ui_direction_set(layout, EFL_UI_DIR_VERTICAL);
|
||||||
|
|
||||||
efl_gfx_hint_margin_set(layout, 10, 10, 20, 20);
|
efl_gfx_hint_margin_set(layout, 10, 10, 20, 20);
|
||||||
efl_ui_table_homogeneous_set(layout, 0, 1);
|
efl_ui_table_homogeneous_set(layout, 0, 1);
|
||||||
efl_pack_padding_set(layout, 10, 5, 0);
|
efl_pack_padding_set(layout, 10, 5, 0);
|
||||||
|
@ -419,6 +426,143 @@ EFL_START_TEST (efl_ui_table_size)
|
||||||
}
|
}
|
||||||
EFL_END_TEST
|
EFL_END_TEST
|
||||||
|
|
||||||
|
EFL_START_TEST (efl_ui_table_pack_table)
|
||||||
|
{
|
||||||
|
#define BTN_NUM 3
|
||||||
|
Eo *o, *btn[BTN_NUM];
|
||||||
|
Eina_Iterator *itr;
|
||||||
|
int i, cols, rows;
|
||||||
|
|
||||||
|
for (i = 0; i < BTN_NUM; i++)
|
||||||
|
btn[i] = efl_add(EFL_UI_BUTTON_CLASS, layout);
|
||||||
|
|
||||||
|
//pack test
|
||||||
|
ck_assert(efl_pack(layout, btn[0]));
|
||||||
|
ck_assert_ptr_eq(efl_pack_table_content_get(layout, 0, 0), btn[0]);
|
||||||
|
efl_pack_table_size_get(layout, &cols, &rows);
|
||||||
|
ck_assert_int_eq(cols, 1);
|
||||||
|
ck_assert_int_eq(rows, 1);
|
||||||
|
|
||||||
|
ck_assert(efl_pack_table(layout, btn[1], 6, 0, 1, 1));
|
||||||
|
ck_assert_ptr_eq(efl_pack_table_content_get(layout, 6, 0), btn[1]);
|
||||||
|
efl_pack_table_size_get(layout, &cols, &rows);
|
||||||
|
ck_assert_int_eq(cols, 7);
|
||||||
|
ck_assert_int_eq(rows, 1);
|
||||||
|
|
||||||
|
ck_assert(efl_pack(layout, btn[2]));
|
||||||
|
ck_assert_ptr_eq(efl_pack_table_content_get(layout, 7, 0), btn[2]);
|
||||||
|
efl_pack_table_size_get(layout, &cols, &rows);
|
||||||
|
ck_assert_int_eq(cols, 8);
|
||||||
|
ck_assert_int_eq(rows, 1);
|
||||||
|
|
||||||
|
ck_assert_int_eq(efl_content_count(layout), BTN_NUM);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
itr = efl_content_iterate(layout);
|
||||||
|
EINA_ITERATOR_FOREACH(itr, o)
|
||||||
|
{
|
||||||
|
ck_assert_ptr_eq(o, btn[i++]);
|
||||||
|
}
|
||||||
|
eina_iterator_free(itr);
|
||||||
|
|
||||||
|
//unpack test
|
||||||
|
ck_assert(efl_pack_unpack(layout, btn[2]));
|
||||||
|
ck_assert(!efl_pack_unpack(layout, btn[2]));
|
||||||
|
|
||||||
|
efl_pack_unpack_all(layout);
|
||||||
|
ck_assert_int_eq(efl_content_count(layout), 0);
|
||||||
|
ck_assert(!efl_invalidated_get(btn[0]));
|
||||||
|
|
||||||
|
for (i = 0; i < BTN_NUM; i++)
|
||||||
|
efl_pack(layout, btn[i]);
|
||||||
|
|
||||||
|
efl_pack_clear(layout);
|
||||||
|
ck_assert_int_eq(efl_content_count(layout), 0);
|
||||||
|
ck_assert(efl_invalidated_get(btn[0]));
|
||||||
|
#undef BTN_NUM
|
||||||
|
}
|
||||||
|
EFL_END_TEST
|
||||||
|
|
||||||
|
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_pack_align_get(layout, &h, &v);
|
||||||
|
ck_assert(EINA_DBL_EQ(h, 0.5));
|
||||||
|
ck_assert(EINA_DBL_EQ(v, 0.5));
|
||||||
|
|
||||||
|
efl_pack_align_set(layout, 0.3, 0.8234);
|
||||||
|
efl_pack_align_get(layout, &h, &v);
|
||||||
|
ck_assert(EINA_DBL_EQ(h, 0.3));
|
||||||
|
ck_assert(EINA_DBL_EQ(v, 0.8234));
|
||||||
|
|
||||||
|
efl_pack_align_set(layout, -0.23, 123);
|
||||||
|
efl_pack_align_get(layout, &h, &v);
|
||||||
|
ck_assert(EINA_DBL_EQ(h, -1));
|
||||||
|
ck_assert(EINA_DBL_EQ(v, 1));
|
||||||
|
|
||||||
|
//padding test
|
||||||
|
efl_pack_padding_get(layout, &h, &v, &b);
|
||||||
|
ck_assert(EINA_DBL_EQ(h, 0.0));
|
||||||
|
ck_assert(EINA_DBL_EQ(v, 0.0));
|
||||||
|
ck_assert_int_eq(b, 0);
|
||||||
|
|
||||||
|
efl_pack_padding_set(layout, 0.3, 0.8234, 1);
|
||||||
|
efl_pack_padding_get(layout, &h, &v, &b);
|
||||||
|
ck_assert(EINA_DBL_EQ(h, 0.3));
|
||||||
|
ck_assert(EINA_DBL_EQ(v, 0.8234));
|
||||||
|
ck_assert_int_eq(b, 1);
|
||||||
|
|
||||||
|
efl_pack_padding_set(layout, -1.23, 123, 45);
|
||||||
|
efl_pack_padding_get(layout, &h, &v, &b);
|
||||||
|
ck_assert(EINA_DBL_EQ(h, 0));
|
||||||
|
ck_assert(EINA_DBL_EQ(v, 123));
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_RIGHT);
|
||||||
|
|
||||||
|
efl_ui_direction_set(layout, EFL_UI_DIR_DEFAULT);
|
||||||
|
ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_RIGHT);
|
||||||
|
|
||||||
|
efl_ui_direction_set(layout, EFL_UI_DIR_HORIZONTAL);
|
||||||
|
ck_assert_int_eq(efl_ui_direction_get(layout), EFL_UI_DIR_HORIZONTAL);
|
||||||
|
|
||||||
|
//homogeneous test
|
||||||
|
efl_ui_table_homogeneous_get(layout, &homogeneoush, &homogeneousv);
|
||||||
|
ck_assert_int_eq(homogeneoush, 0);
|
||||||
|
ck_assert_int_eq(homogeneousv, 0);
|
||||||
|
|
||||||
|
efl_ui_table_homogeneous_set(layout, 123, -123);
|
||||||
|
efl_ui_table_homogeneous_get(layout, &homogeneoush, &homogeneousv);
|
||||||
|
ck_assert_int_eq(homogeneoush, 1);
|
||||||
|
ck_assert_int_eq(homogeneousv, 1);
|
||||||
|
|
||||||
|
efl_ui_table_homogeneous_set(layout, 1, 0);
|
||||||
|
efl_ui_table_homogeneous_get(layout, &homogeneoush, &homogeneousv);
|
||||||
|
ck_assert_int_eq(homogeneoush, 1);
|
||||||
|
ck_assert_int_eq(homogeneousv, 0);
|
||||||
|
}
|
||||||
|
EFL_END_TEST
|
||||||
|
|
||||||
void efl_ui_test_table(TCase *tc)
|
void efl_ui_test_table(TCase *tc)
|
||||||
{
|
{
|
||||||
tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
|
tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
|
||||||
|
@ -427,4 +571,6 @@ void efl_ui_test_table(TCase *tc)
|
||||||
tcase_add_test(tc, efl_ui_table_layout_update);
|
tcase_add_test(tc, efl_ui_table_layout_update);
|
||||||
tcase_add_test(tc, efl_ui_table_layout_update_pack);
|
tcase_add_test(tc, efl_ui_table_layout_update_pack);
|
||||||
tcase_add_test(tc, efl_ui_table_layout_update_matrix);
|
tcase_add_test(tc, efl_ui_table_layout_update_matrix);
|
||||||
|
tcase_add_test(tc, efl_ui_table_pack_table);
|
||||||
|
tcase_add_test(tc, efl_ui_table_properties);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue