cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=fc935e99d936a3b1fd4a81232e493094bf5e5989

commit fc935e99d936a3b1fd4a81232e493094bf5e5989
Author: Marcel Hollerbach <m...@marcel-hollerbach.de>
Date:   Sun Sep 15 11:54:51 2019 +0200

    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
---
 .../elementary/efl_ui_position_manager_entity.eo   | 10 +++++
 src/lib/elementary/efl_ui_position_manager_grid.c  | 43 ++++++++++++++++++++++
 src/lib/elementary/efl_ui_position_manager_grid.eo |  1 +
 src/lib/elementary/efl_ui_position_manager_list.c  | 30 +++++++++++++++
 src/lib/elementary/efl_ui_position_manager_list.eo |  1 +
 5 files changed, 85 insertions(+)

diff --git a/src/lib/elementary/efl_ui_position_manager_entity.eo 
b/src/lib/elementary/efl_ui_position_manager_entity.eo
index d61c7c62d1..865d8f3180 100644
--- a/src/lib/elementary/efl_ui_position_manager_entity.eo
+++ b/src/lib/elementary/efl_ui_position_manager_entity.eo
@@ -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]]
diff --git a/src/lib/elementary/efl_ui_position_manager_grid.c 
b/src/lib/elementary/efl_ui_position_manager_grid.c
index fee0855ec6..206bc73221 100644
--- a/src/lib/elementary/efl_ui_position_manager_grid.c
+++ b/src/lib/elementary/efl_ui_position_manager_grid.c
@@ -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"
diff --git a/src/lib/elementary/efl_ui_position_manager_grid.eo 
b/src/lib/elementary/efl_ui_position_manager_grid.eo
index 91deee348e..35ebeb5fc1 100644
--- a/src/lib/elementary/efl_ui_position_manager_grid.eo
+++ b/src/lib/elementary/efl_ui_position_manager_grid.eo
@@ -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;
diff --git a/src/lib/elementary/efl_ui_position_manager_list.c 
b/src/lib/elementary/efl_ui_position_manager_list.c
index 706fce768b..d4bedb819c 100644
--- a/src/lib/elementary/efl_ui_position_manager_list.c
+++ b/src/lib/elementary/efl_ui_position_manager_list.c
@@ -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"
diff --git a/src/lib/elementary/efl_ui_position_manager_list.eo 
b/src/lib/elementary/efl_ui_position_manager_list.eo
index 3d80b201d4..ade5a1f3cf 100644
--- a/src/lib/elementary/efl_ui_position_manager_list.eo
+++ b/src/lib/elementary/efl_ui_position_manager_list.eo
@@ -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;}
    }

-- 


Reply via email to