ui.box, ui.table: respect user min

Use restricted_min_set instead of min_set in layout_update.
min_set is set by public API(user side). if it is changed by internal function,
user will get unexpected value later. please check added test case.

Note that this reverts commit e013480e7a. instead,
this patch provides better solution of the issue refered in e013480e7.

Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es>
Differential Revision: https://phab.enlightenment.org/D8214
This commit is contained in:
Yeongjong Lee 2019-03-07 01:40:23 +00:00 committed by Cedric BAIL
parent 4a306ec39b
commit 0b7cd8d88e
6 changed files with 134 additions and 20 deletions

View File

@ -47,7 +47,7 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
count = eina_list_count(bd->children);
if (!count)
{
efl_gfx_hint_size_min_set(ui_box, EINA_SIZE2D(0, 0));
efl_gfx_hint_size_restricted_min_set(ui_box, EINA_SIZE2D(0, 0));
return;
}
@ -199,8 +199,5 @@ _efl_ui_box_custom_layout(Efl_Ui_Box *ui_box, Evas_Object_Box_Data *bd)
want[1] += (box_calc[1].margin[0] + box_calc[1].margin[1]) +
(box_calc[1].pad * (count - 1));
if (want[0] < box_calc[0].min) want[0] = box_calc[0].min;
if (want[1] < box_calc[1].min) want[1] = box_calc[1].min;
efl_gfx_hint_size_min_set(ui_box, EINA_SIZE2D(want[0], want[1]));
efl_gfx_hint_size_restricted_min_set(ui_box, EINA_SIZE2D(want[0], want[1]));
}

View File

@ -112,14 +112,10 @@ _efl_ui_container_layout_init(Eo* obj, Efl_Ui_Container_Layout_Calc *calc)
{
Eina_Rect geom;
Eina_Bool pad_scalable;
Eina_Size2D min;
geom = efl_gfx_entity_geometry_get(obj);
efl_gfx_hint_margin_get(obj, &calc[0].margin[0], &calc[0].margin[1],
&calc[1].margin[0], &calc[1].margin[1]);
min = efl_gfx_hint_size_combined_min_get(obj);
calc[0].min = min.w;
calc[1].min = min.h;
calc[0].scale = calc[1].scale = efl_gfx_entity_scale_get(obj);
efl_pack_padding_get(obj, &calc[0].pad, &calc[1].pad, &pad_scalable);

View File

@ -28,7 +28,6 @@ struct _Efl_Ui_Container_Layout_Calc
{
int pos;
int size;
int min;
int margin[2];
double align;
double scale;

View File

@ -232,7 +232,7 @@ _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
if (!pd->count)
{
efl_gfx_hint_size_min_set(ui_table, EINA_SIZE2D(0, 0));
efl_gfx_hint_size_restricted_min_set(ui_table, EINA_SIZE2D(0, 0));
return;
}
@ -369,11 +369,7 @@ _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd)
+ (table_calc.layout_calc[1].pad *
table_calc.cell_calc[1][rows - 1].index);
if (table_calc.want[0] < table_calc.layout_calc[0].min)
table_calc.want[0] = table_calc.layout_calc[0].min;
if (table_calc.want[1] < table_calc.layout_calc[1].min)
table_calc.want[1] = table_calc.layout_calc[1].min;
efl_gfx_hint_size_min_set(ui_table, EINA_SIZE2D(table_calc.want[0],
table_calc.want[1]));
efl_gfx_hint_size_restricted_min_set(ui_table,
EINA_SIZE2D(table_calc.want[0],
table_calc.want[1]));
}

View File

@ -203,7 +203,7 @@ btn_geom_assert(Hint *hint, Eina_Rect btn_geom)
Eina_Size2D layout_size, layout_min;
layout_size = efl_gfx_entity_size_get(layout);
layout_min = efl_gfx_hint_size_min_get(layout);
layout_min = efl_gfx_hint_size_combined_min_get(layout);
layout_size.w = layout_size.w > layout_min.w ? layout_size.w : layout_min.w;
layout_size.h = layout_size.h > layout_min.h ? layout_size.h : layout_min.h;
@ -344,10 +344,73 @@ EFL_START_TEST (efl_ui_box_layout_update_pack)
}
EFL_END_TEST
EFL_START_TEST (efl_ui_box_size)
{
#define USERMIN_CHECK(a, b) \
efl_canvas_group_calculate(layout); \
user_min = efl_gfx_hint_size_min_get(layout); \
ck_assert_msg(COORD_EQ(user_min.w, (a)) && COORD_EQ(user_min.h, (b)), \
"Case box_size failed... user_min: (%d, %d) expected user_min: (%d, %d)", \
user_min.w, user_min.h, (a), (b));
#define MIN_CHECK(a, b) \
efl_canvas_group_calculate(layout); \
min = efl_gfx_hint_size_combined_min_get(layout); \
ck_assert_msg(COORD_EQ(min.w, (a)) && COORD_EQ(min.h, (b)), \
"Case box_size failed... min: (%d, %d) expected min: (%d, %d)", \
min.w, min.h, (a), (b));
Eo *btn, *btn2, *btn3;
Eina_Size2D min, user_min;
btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_pack_end(layout, efl_added));
USERMIN_CHECK(0, 0);
MIN_CHECK(100, 100);
btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_pack_end(layout, efl_added));
btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_pack_end(layout, efl_added));
USERMIN_CHECK(0, 0);
MIN_CHECK(100, 300);
efl_pack_unpack(layout, btn2);
USERMIN_CHECK(0, 0);
MIN_CHECK(100, 200);
efl_pack_unpack(layout, btn3);
USERMIN_CHECK(0, 0);
MIN_CHECK(100, 100);
efl_pack_unpack(layout, btn);
USERMIN_CHECK(0, 0);
MIN_CHECK(0, 0);
efl_pack_end(layout, btn);
efl_gfx_hint_size_min_set(layout, EINA_SIZE2D(200, 200));
USERMIN_CHECK(200, 200);
MIN_CHECK(200, 200);
efl_pack_end(layout, btn2);
efl_pack_end(layout, btn3);
USERMIN_CHECK(200, 200);
MIN_CHECK(200, 300);
#undef USERMIN_ASSERT
#undef MIN_ASSERT
}
EFL_END_TEST
void efl_ui_test_box(TCase *tc)
{
tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
tcase_add_test(tc, efl_ui_box_class_check);
tcase_add_test(tc, efl_ui_box_layout_update);
tcase_add_test(tc, efl_ui_box_layout_update_pack);
tcase_add_test(tc, efl_ui_box_size);
}

View File

@ -230,7 +230,7 @@ btn_geom_assert(Hint *hint, Eina_Rect btn_geom)
Eina_Size2D layout_size, layout_min;
layout_size = efl_gfx_entity_size_get(layout);
layout_min = efl_gfx_hint_size_min_get(layout);
layout_min = efl_gfx_hint_size_combined_min_get(layout);
layout_size.w = layout_size.w > layout_min.w ? layout_size.w : layout_min.w;
layout_size.h = layout_size.h > layout_min.h ? layout_size.h : layout_min.h;
@ -355,10 +355,73 @@ EFL_START_TEST (efl_ui_table_layout_update_matrix)
}
EFL_END_TEST
EFL_START_TEST (efl_ui_table_size)
{
#define USERMIN_CHECK(a, b) \
efl_canvas_group_calculate(layout); \
user_min = efl_gfx_hint_size_min_get(layout); \
ck_assert_msg(COORD_EQ(user_min.w, (a)) && COORD_EQ(user_min.h, (b)), \
"Case table_size failed... user_min: (%d, %d) expected user_min: (%d, %d)", \
user_min.w, user_min.h, (a), (b));
#define MIN_CHECK(a, b) \
efl_canvas_group_calculate(layout); \
min = efl_gfx_hint_size_combined_min_get(layout); \
ck_assert_msg(COORD_EQ(min.w, (a)) && COORD_EQ(min.h, (b)), \
"Case table_size failed... min: (%d, %d) expected min: (%d, %d)", \
min.w, min.h, (a), (b));
Eo *btn, *btn2, *btn3;
Eina_Size2D min, user_min;
btn = efl_add(EFL_UI_BUTTON_CLASS, layout,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_pack_table(layout, efl_added, 0, 0, 1, 1));
USERMIN_CHECK(0, 0);
MIN_CHECK(100, 100);
btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_pack_table(layout, efl_added, 0, 1, 1, 1));
btn3 = efl_add(EFL_UI_BUTTON_CLASS, layout,
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(100, 100)),
efl_pack_table(layout, efl_added, 0, 2, 1, 1));
USERMIN_CHECK(0, 0);
MIN_CHECK(100, 300);
efl_pack_unpack(layout, btn);
USERMIN_CHECK(0, 0);
MIN_CHECK(100, 200);
efl_pack_unpack(layout, btn2);
USERMIN_CHECK(0, 0);
MIN_CHECK(100, 100);
efl_pack_unpack(layout, btn3);
USERMIN_CHECK(0, 0);
MIN_CHECK(0, 0);
efl_pack_table(layout, btn, 0, 0, 1, 1);
efl_gfx_hint_size_min_set(layout, EINA_SIZE2D(200, 200));
USERMIN_CHECK(200, 200);
MIN_CHECK(200, 200);
efl_pack_table(layout, btn2, 0, 1, 1, 1);
efl_pack_table(layout, btn3, 0, 2, 1, 1);
USERMIN_CHECK(200, 200);
MIN_CHECK(200, 300);
#undef USERMIN_ASSERT
#undef MIN_ASSERT
}
EFL_END_TEST
void efl_ui_test_table(TCase *tc)
{
tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
tcase_add_test(tc, efl_ui_table_class_check);
tcase_add_test(tc, efl_ui_table_size);
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_matrix);