forked from enlightenment/efl
efl_ui_position_manager_common: generalize code
move the same code to a common header file. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9630
This commit is contained in:
parent
8520c648b3
commit
9eef883312
|
@ -11,6 +11,10 @@ typedef struct {
|
||||||
Eina_Free_Cb free_cb;
|
Eina_Free_Cb free_cb;
|
||||||
} Api_Callback;
|
} Api_Callback;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int start_id, end_id;
|
||||||
|
} Vis_Segment;
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
_fill_buffer(Api_Callback *cb , int start_id, int len, int *group_id, void *data)
|
_fill_buffer(Api_Callback *cb , int start_id, int len, int *group_id, void *data)
|
||||||
{
|
{
|
||||||
|
@ -57,3 +61,20 @@ vis_change_segment(Api_Callback *cb, int a, int b, Eina_Bool flag)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
vis_segment_swap(Api_Callback *cb, Vis_Segment new, Vis_Segment old)
|
||||||
|
{
|
||||||
|
if (new.end_id <= old.start_id || new.start_id >= old.end_id)
|
||||||
|
{
|
||||||
|
//it is important to first make the segment visible here, and then hide the rest
|
||||||
|
//otherwise we get a state where item_container has 0 subchildren, which triggers a lot of focus logic.
|
||||||
|
vis_change_segment(cb, new.start_id, new.end_id, EINA_TRUE);
|
||||||
|
vis_change_segment(cb, old.start_id, old.end_id, EINA_FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vis_change_segment(cb, old.start_id, new.start_id, (old.start_id > new.start_id));
|
||||||
|
vis_change_segment(cb, old.end_id, new.end_id, (old.end_id < new.end_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -12,10 +12,6 @@
|
||||||
#define MY_DATA_GET(obj, pd) \
|
#define MY_DATA_GET(obj, pd) \
|
||||||
Efl_Ui_Position_Manager_Grid_Data *pd = efl_data_scope_get(obj, MY_CLASS);
|
Efl_Ui_Position_Manager_Grid_Data *pd = efl_data_scope_get(obj, MY_CLASS);
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int start_id, end_id;
|
|
||||||
} Vis_Segment;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Api_Callback min_size, object;
|
Api_Callback min_size, object;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
@ -460,18 +456,7 @@ _reposition_content(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
|
||||||
|
|
||||||
//to performance optimize the whole widget, we are setting the objects that are outside the viewport to visibility false
|
//to performance optimize the whole widget, we are setting the objects that are outside the viewport to visibility false
|
||||||
//The code below ensures that things outside the viewport are always hidden, and things inside the viewport are visible
|
//The code below ensures that things outside the viewport are always hidden, and things inside the viewport are visible
|
||||||
if (cur.end_id < pd->prev_run.start_id || cur.start_id > pd->prev_run.end_id)
|
vis_segment_swap(&pd->object, cur, pd->prev_run);
|
||||||
{
|
|
||||||
//it is important to first make the segment visible here, and then hide the rest
|
|
||||||
//otherwise we get a state where item_container has 0 subchildren, which triggers a lot of focus logic.
|
|
||||||
vis_change_segment(&pd->object, cur.start_id, cur.end_id, EINA_TRUE);
|
|
||||||
vis_change_segment(&pd->object, pd->prev_run.start_id, pd->prev_run.end_id, EINA_FALSE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vis_change_segment(&pd->object, pd->prev_run.start_id, cur.start_id, (pd->prev_run.start_id > cur.start_id));
|
|
||||||
vis_change_segment(&pd->object, pd->prev_run.end_id, cur.end_id, (pd->prev_run.end_id < cur.end_id));
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.new = cur;
|
ctx.new = cur;
|
||||||
ctx.consumed_space = consumed_space;
|
ctx.consumed_space = consumed_space;
|
||||||
|
|
|
@ -13,11 +13,6 @@
|
||||||
#define MY_DATA_GET(obj, pd) \
|
#define MY_DATA_GET(obj, pd) \
|
||||||
Efl_Ui_Position_Manager_List_Data *pd = efl_data_scope_get(obj, MY_CLASS);
|
Efl_Ui_Position_Manager_List_Data *pd = efl_data_scope_get(obj, MY_CLASS);
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
unsigned int start_id, end_id;
|
|
||||||
} Vis_Segment;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Api_Callback min_size, object;
|
Api_Callback min_size, object;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
@ -168,23 +163,6 @@ err:
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
|
||||||
_visual_segment_swap(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, Vis_Segment new, Vis_Segment old)
|
|
||||||
{
|
|
||||||
if (new.end_id <= old.start_id || new.start_id >= old.end_id)
|
|
||||||
{
|
|
||||||
//it is important to first make the segment visible here, and then hide the rest
|
|
||||||
//otherwise we get a state where item_container has 0 subchildren, which triggers a lot of focus logic.
|
|
||||||
vis_change_segment(&pd->object, new.start_id, new.end_id, EINA_TRUE);
|
|
||||||
vis_change_segment(&pd->object, old.start_id, old.end_id, EINA_FALSE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vis_change_segment(&pd->object, old.start_id, new.start_id, (old.start_id > new.start_id));
|
|
||||||
vis_change_segment(&pd->object, old.end_id, new.end_id, (old.end_id < new.end_id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
_position_items(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, Vis_Segment new, int relevant_space_size)
|
_position_items(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, Vis_Segment new, int relevant_space_size)
|
||||||
{
|
{
|
||||||
|
@ -327,7 +305,7 @@ position_content(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd)
|
||||||
cur = _search_visual_segment(obj, pd, relevant_space_size, relevant_viewport);
|
cur = _search_visual_segment(obj, pd, relevant_space_size, relevant_viewport);
|
||||||
//to performance optimize the whole widget, we are setting the objects that are outside the viewport to visibility false
|
//to performance optimize the whole widget, we are setting the objects that are outside the viewport to visibility false
|
||||||
//The code below ensures that things outside the viewport are always hidden, and things inside the viewport are visible
|
//The code below ensures that things outside the viewport are always hidden, and things inside the viewport are visible
|
||||||
_visual_segment_swap(obj, pd, cur, pd->prev_run);
|
vis_segment_swap(&pd->object, cur, pd->prev_run);
|
||||||
|
|
||||||
_position_items(obj, pd, cur, relevant_space_size);
|
_position_items(obj, pd, cur, relevant_space_size);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue