diff --git a/src/lib/elementary/efl_ui_table.c b/src/lib/elementary/efl_ui_table.c index fd7ee11e4c..6655573231 100644 --- a/src/lib/elementary/efl_ui_table.c +++ b/src/lib/elementary/efl_ui_table.c @@ -174,7 +174,7 @@ EOLIAN static void _efl_ui_table_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_Table_Data *_pd EINA_UNUSED, Eina_Size2D sz) { efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), sz); - efl_canvas_group_change(obj); + efl_pack_layout_request(obj); } EOLIAN static void @@ -508,8 +508,9 @@ _efl_ui_table_efl_pack_unpack_all(Eo *obj, Efl_Ui_Table_Data *pd) } EOLIAN static void -_efl_ui_table_efl_pack_layout_layout_request(Eo *obj, Efl_Ui_Table_Data *pd EINA_UNUSED) +_efl_ui_table_efl_pack_layout_layout_request(Eo *obj, Efl_Ui_Table_Data *pd) { + pd->full_recalc = EINA_TRUE; efl_canvas_group_need_recalculate_set(obj, EINA_TRUE); } diff --git a/src/lib/elementary/efl_ui_table_layout.c b/src/lib/elementary/efl_ui_table_layout.c index 013a35a6cd..a0307f52e0 100644 --- a/src/lib/elementary/efl_ui_table_layout.c +++ b/src/lib/elementary/efl_ui_table_layout.c @@ -218,6 +218,27 @@ _efl_ui_table_regular_item_size_get(Table_Calc *table_calc, Item_Calc *item, Ein - item->hints[axis].margin[0] - item->hints[axis].margin[1]; } +/* this function performs a simplified layout when the table has changed position + * but no other changes have occurred, e.g., when a table is being scrolled + */ +static void +_efl_ui_table_layout_simple(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd) +{ + Table_Item *ti; + Eina_Position2D pos = efl_gfx_entity_position_get(ui_table); + + EINA_INLIST_FOREACH(EINA_INLIST_GET(pd->items), ti) + { + Eina_Position2D child_pos = efl_gfx_entity_position_get(ti->object); + + efl_gfx_entity_position_set(ti->object, + EINA_POSITION2D(pos.x - pd->last_pos.x + child_pos.x, + pos.y - pd->last_pos.y + child_pos.y)); + } + pd->last_pos = pos; + efl_event_callback_call(ui_table, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL); +} + void _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd) { @@ -231,14 +252,19 @@ _efl_ui_table_custom_layout(Efl_Ui_Table *ui_table, Efl_Ui_Table_Data *pd) Eina_Bool do_free; count = pd->count; - if (!count) { efl_gfx_hint_size_restricted_min_set(ui_table, EINA_SIZE2D(0, 0)); return; } - + if (!pd->full_recalc) + { + _efl_ui_table_layout_simple(ui_table, pd); + return; + } _efl_ui_container_layout_init(ui_table, table_calc.layout_calc); + pd->last_pos.x = table_calc.layout_calc[0].pos - table_calc.layout_calc[0].margin[0]; + pd->last_pos.y = table_calc.layout_calc[1].pos - table_calc.layout_calc[1].margin[0]; table_calc.want[0] = table_calc.want[1] = 0; table_calc.weight_sum[0] = table_calc.weight_sum[1] = 0; @@ -391,6 +417,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); + pd->full_recalc = EINA_FALSE; efl_gfx_hint_size_restricted_min_set(ui_table, EINA_SIZE2D(table_calc.want[0], table_calc.want[1])); diff --git a/src/lib/elementary/efl_ui_table_private.h b/src/lib/elementary/efl_ui_table_private.h index ff261f1fae..47d1cc4cb7 100644 --- a/src/lib/elementary/efl_ui_table_private.h +++ b/src/lib/elementary/efl_ui_table_private.h @@ -44,11 +44,13 @@ struct _Efl_Ui_Table_Data struct { double h, v; } align; + Eina_Position2D last_pos; Eina_Bool cols_recalc : 1; Eina_Bool rows_recalc : 1; Eina_Bool linear_recalc : 1; Eina_Bool homogeneoush : 1; Eina_Bool homogeneousv : 1; + Eina_Bool full_recalc : 1; //whether to force full recalc }; struct _Table_Item_Iterator