efl_ui_position_manager: a way to announce new entities

there are situations where the entity is not ready yet when the initial
placing does happen. With this API you can tell the position manager
that the placing of the items can be reapplied at the entities are
availble now.

Differential Revision: https://phab.enlightenment.org/D9947
This commit is contained in:
Marcel Hollerbach 2019-09-15 11:54:51 +02:00 committed by Cedric Bail
parent 8128e3fea2
commit fc935e99d9
5 changed files with 85 additions and 0 deletions

View File

@ -91,6 +91,16 @@ interface @beta Efl.Ui.Position_Manager.Entity extends Efl.Ui.Layout_Orientable
end_id : int; [[The last item that has a new size]]
}
}
entities_ready {
[[The items from $start_id to $end_id now have their entities ready
The position manager will reapply the geometry to the elements if they are visible.
]]
params {
start_id : uint; [[The first item that is available]]
end_id : uint; [[The last item that is available]]
}
}
relative_item {
[[Translates the $current_id, into a new id which is oriented in the $direction of $current_id.
In case that there is no item, -1 is returned]]

View File

@ -19,6 +19,7 @@ typedef struct {
Eina_Vector2 scroll_position;
Efl_Ui_Layout_Orientation dir;
Vis_Segment prev_run;
unsigned int prev_consumed_space;
Eina_Size2D max_min_size;
Eina_Size2D last_viewport_size;
Eina_Size2D prev_min_size;
@ -491,6 +492,7 @@ _reposition_content(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
{
ev.start_id = pd->prev_run.start_id = cur.start_id;
ev.end_id = pd->prev_run.end_id = cur.end_id;
pd->prev_consumed_space = consumed_space;
efl_event_callback_call(obj, EFL_UI_POSITION_MANAGER_ENTITY_EVENT_VISIBLE_RANGE_CHANGED, &ev);
}
}
@ -809,5 +811,46 @@ _efl_ui_position_manager_grid_efl_object_finalize(Eo *obj, Efl_Ui_Position_Manag
return obj;
}
EOLIAN static void
_efl_ui_position_manager_grid_efl_ui_position_manager_entity_entities_ready(Eo *obj, Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int start_id, unsigned int end_id)
{
Eina_Size2D space_size;
int relevant_space_size;
Item_Position_Context ctx;
if (end_id < pd->prev_run.start_id || start_id > pd->prev_run.end_id)
return;
space_size.w = (MAX(pd->last_viewport_size.w - pd->viewport.w, 0))*pd->scroll_position.x;
space_size.h = (MAX(pd->last_viewport_size.h - pd->viewport.h, 0))*pd->scroll_position.y;
if (pd->dir == EFL_UI_LAYOUT_ORIENTATION_VERTICAL)
{
relevant_space_size = space_size.h;
}
else
{
relevant_space_size = space_size.w;
}
ctx.new = pd->prev_run;
ctx.consumed_space = pd->prev_consumed_space;
ctx.relevant_space_size = relevant_space_size;
ctx.floating_group = NULL;
ctx.placed_item = NULL;
if (pd->dir == EFL_UI_LAYOUT_ORIENTATION_VERTICAL)
{
_position_items_vertical(obj, pd, &ctx);
_position_group_items(obj, pd, &ctx);
}
else
{
_position_items_horizontal(obj, pd, &ctx);
_position_group_items(obj, pd, &ctx);
}
}
#include "efl_ui_position_manager_grid.eo.c"

View File

@ -15,6 +15,7 @@ class @beta Efl.Ui.Position_Manager.Grid extends Efl.Object
Efl.Ui.Position_Manager.Entity.position_single_item;
Efl.Ui.Position_Manager.Entity.item_size_changed;
Efl.Ui.Position_Manager.Entity.relative_item;
Efl.Ui.Position_Manager.Entity.entities_ready;
Efl.Ui.Layout_Orientable.orientation {set; get;}
Efl.Ui.Position_Manager.Data_Access_V1.data_access {set;}
Efl.Object.finalize;

View File

@ -546,4 +546,34 @@ _efl_ui_position_manager_list_efl_ui_position_manager_data_access_v1_data_access
}
EOLIAN static void
_efl_ui_position_manager_list_efl_ui_position_manager_entity_entities_ready(Eo *obj, Efl_Ui_Position_Manager_List_Data *pd, unsigned int start_id, unsigned int end_id)
{
Eina_Size2D space_size;
int relevant_space_size;
if (end_id < pd->prev_run.start_id || start_id > pd->prev_run.end_id)
return;
if (!pd->size) return;
if (pd->average_item_size <= 0) return;
cache_require(obj, pd);
//space size contains the amount of space that is outside the viewport (either to the top or to the left)
space_size.w = (MAX(pd->abs_size.w - pd->viewport.w, 0))*pd->scroll_position.x;
space_size.h = (MAX(pd->abs_size.h - pd->viewport.h, 0))*pd->scroll_position.y;
if (pd->dir == EFL_UI_LAYOUT_ORIENTATION_VERTICAL)
{
relevant_space_size = space_size.h;
}
else
{
relevant_space_size = space_size.w;
}
_position_items(obj, pd, pd->prev_run, relevant_space_size);
}
#include "efl_ui_position_manager_list.eo.c"

View File

@ -17,6 +17,7 @@ class @beta Efl.Ui.Position_Manager.List extends Efl.Object
Efl.Ui.Position_Manager.Entity.position_single_item;
Efl.Ui.Position_Manager.Entity.item_size_changed;
Efl.Ui.Position_Manager.Entity.relative_item;
Efl.Ui.Position_Manager.Entity.entities_ready;
Efl.Ui.Layout_Orientable.orientation {set; get;}
Efl.Ui.Position_Manager.Data_Access_V1.data_access {set;}
}