This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit 122d411e053d8dc344f4773b24317c376dcb9b21
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 20:46:01 2026 -0600

    elementary: grid: an unmeasured item's stand-in size is not a cell size
    
    A grid over an Average_Model, scrolled down, with a row prepended
    collapsed to one column: the new item, which nobody measured, was said
    to be as big as the view, and the grid made its minimum size the biggest
    of what it was said (it only grows), as the full build of its groups did
    with all of the items nobody measured. Both now go by the sizes that are
    known, as the grid already did when an item left, and the stand-in is
    only used while nothing is known. The average signal of the view (item 0
    to 0, a full invalidation) is not for a grid, which does not estimate.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_collection_view.c        |  5 ++
 src/lib/elementary/efl_ui_position_manager_grid.c  | 57 +++++++++++---
 src/tests/elementary/efl_ui_test_collection_view.c | 86 +++++++++++++++++++++-
 3 files changed, 132 insertions(+), 16 deletions(-)

diff --git a/src/lib/elementary/efl_ui_collection_view.c b/src/lib/elementary/efl_ui_collection_view.c
index 27b2a017c1..049e3ca5cb 100644
--- a/src/lib/elementary/efl_ui_collection_view.c
+++ b/src/lib/elementary/efl_ui_collection_view.c
@@ -2186,6 +2186,11 @@ _efl_model_properties_changed(void *data, const Efl_Event *event)
       told that some size may have, to ask if what it keeps of the other rows is
       still what they are. */
    if (!pd->manager || !ev || !ev->changed_properties) return;
+   /* (The grid does not estimate: the size of a cell is the one of its items,
+      and what it would be told here, the size an item nobody measured has,
+      is not one that it may grow its minimum size with. Asked for all of the
+      cells, it would also forget its columns.) */
+   if (efl_isa(pd->manager, EFL_UI_POSITION_MANAGER_GRID_CLASS)) return;
    exact = _efl_ui_exact_model_find(pd->model);
    if (!exact || !efl_isa(exact, EFL_UI_AVERAGE_MODEL_CLASS)) return;
    EINA_ARRAY_ITER_NEXT(ev->changed_properties, i, property, it)
diff --git a/src/lib/elementary/efl_ui_position_manager_grid.c b/src/lib/elementary/efl_ui_position_manager_grid.c
index 6f3726e34b..ee103c08d6 100644
--- a/src/lib/elementary/efl_ui_position_manager_grid.c
+++ b/src/lib/elementary/efl_ui_position_manager_grid.c
@@ -57,6 +57,8 @@ _update_min_size(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd, int
    pd->max_min_size.h = MAX(pd->max_min_size.h, min_size.h);
 }
 
+static Eina_Bool _min_size_known_get(Efl_Ui_Position_Manager_Grid_Data *pd, Eina_Size2D *max);
+
 static void
 _group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
 {
@@ -65,6 +67,7 @@ _group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
    Efl_Ui_Position_Manager_Size_Batch_Entity size_buffer[len];
    Efl_Ui_Position_Manager_Size_Batch_Result size_result;
    Group_Cache_Line line = { 0 };
+   Eina_Size2D known;
 
    if (!pd->group_cache_dirty)
      return;
@@ -111,6 +114,9 @@ _group_cache_require(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd)
         _update_min_size(obj, pd, i, size_buffer[buffer_id].size);
      }
    eina_inarray_push(pd->group_cache, &line);
+   // The same rule as when it is asked for again: the sizes that are known. What
+   // was said for the others is what the first of them gets, when none is.
+   if (_min_size_known_get(pd, &known)) pd->max_min_size = known;
 }
 
 static inline void
@@ -181,18 +187,19 @@ _group_cache_remove(Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int idx)
    return EINA_FALSE;
 }
 
-// The biggest minimum size of the items, asked for again: an item that goes may
-// have been the one that gave it, and the sizes are not kept to tell. Only the
-// sizes that are known are asked for: nothing is fetched or built for the items
-// that nobody has seen to find out what they would give.
-static void
-_min_size_recompute(Efl_Ui_Position_Manager_Grid_Data *pd)
+// The biggest minimum size of the items that are known. Only the sizes that are
+// known are asked for: nothing is fetched or built for the items that nobody
+// has seen to find out what they would give, and what is said for an item that
+// was not measured (the size of the view, before anything was) is not a size
+// that any of the cells has. False if nothing is known.
+static Eina_Bool
+_min_size_known_get(Efl_Ui_Position_Manager_Grid_Data *pd, Eina_Size2D *max)
 {
    Efl_Ui_Position_Manager_Size_Batch_Entity size_buffer[100];
    Efl_Ui_Position_Manager_Size_Batch_Result size_result;
-   Eina_Size2D max = EINA_SIZE2D(0, 0);
    unsigned int i = 0;
 
+   *max = EINA_SIZE2D(0, 0);
    while (i < pd->size)
      {
         unsigned int j, filled;
@@ -201,18 +208,28 @@ _min_size_recompute(Efl_Ui_Position_Manager_Grid_Data *pd)
                                                 MIN(100, pd->size - i), size_buffer);
         filled = MIN(size_result.filled_items, 100);
         // (what is not told is not known: the biggest is then the one that was)
-        if (!filled) return;
+        if (!filled) return EINA_FALSE;
         for (j = 0; j < filled; j++)
           {
              // (an item that is not known is 0x0)
              if (!size_buffer[j].size.w && !size_buffer[j].size.h) continue;
-             max.w = MAX(max.w, size_buffer[j].size.w);
-             max.h = MAX(max.h, size_buffer[j].size.h);
+             max->w = MAX(max->w, size_buffer[j].size.w);
+             max->h = MAX(max->h, size_buffer[j].size.h);
           }
         i += filled;
      }
+   return max->w || max->h;
+}
+
+// The biggest minimum size of the items, asked for again: an item that goes may
+// have been the one that gave it, and the sizes are not kept to tell.
+static void
+_min_size_recompute(Efl_Ui_Position_Manager_Grid_Data *pd)
+{
+   Eina_Size2D max;
+
    // (nothing known, nothing to go on: what it was stays)
-   if (!max.w && !max.h) return;
+   if (!_min_size_known_get(pd, &max)) return;
    if ((max.w != pd->max_min_size.w) || (max.h != pd->max_min_size.h))
      {
         pd->max_min_size = max;
@@ -722,6 +739,22 @@ _schedule_recalc_abs_size(Eo *obj, Efl_Ui_Position_Manager_Grid_Data *pd)
                                               .free = _rebuild_job_free);
 }
 
+// An item that comes gives its size if it is a known one: what is said for an
+// item nobody measured is not a size of a cell, and the minimum would grow to it.
+// It is that or nothing only while no size is known at all.
+static void
+_min_size_added(Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int index, Eina_Size2D said)
+{
+   Efl_Ui_Position_Manager_Size_Batch_Entity known;
+   Efl_Ui_Position_Manager_Size_Batch_Result result;
+
+   result = _batch_request_size_known(pd->callbacks, index, index + 1, 1, &known);
+   if (result.filled_items && (known.size.w || known.size.h))
+     _update_min_size(NULL, pd, index, known.size);
+   else if (!pd->max_min_size.w && !pd->max_min_size.h)
+     _update_min_size(NULL, pd, index, said);
+}
+
 EOLIAN static void
 _efl_ui_position_manager_grid_efl_ui_position_manager_entity_item_added(Eo *obj, Efl_Ui_Position_Manager_Grid_Data *pd, int added_index, Efl_Gfx_Entity *subobj EINA_UNUSED)
 {
@@ -737,7 +770,7 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_item_added(Eo *obj,
    // The groups were right before, and still are with the item in its own (sizes are made of them)
    if (clean && _group_cache_insert(pd, added_index, &size_buffer[0]))
      pd->group_cache_dirty = EINA_FALSE;
-   _update_min_size(obj, pd, added_index, size_buffer[0].size);
+   _min_size_added(pd, added_index, size_buffer[0].size);
    _flush_min_size(obj, pd);
    _schedule_recalc_abs_size(obj, pd);
 }
diff --git a/src/tests/elementary/efl_ui_test_collection_view.c b/src/tests/elementary/efl_ui_test_collection_view.c
index 33bb849fdb..92f24b7c7c 100644
--- a/src/tests/elementary/efl_ui_test_collection_view.c
+++ b/src/tests/elementary/efl_ui_test_collection_view.c
@@ -1811,7 +1811,9 @@ EFL_START_TEST(test_efl_ui_collection_view_many_single_adds_grid)
    unsigned int counted;
 
    counted = _single_adds_rows(rows, EINA_TRUE, EINA_TRUE);
-   ck_assert_uint_lt(counted, rows * 20);
+   // (more than a list, as the cells are not as wide as the view and a screen
+   // shows many of them: still far from what the rows there are would make)
+   ck_assert_uint_lt(counted, rows * 100);
 }
 EFL_END_TEST
 
@@ -2003,7 +2005,7 @@ EFL_START_TEST(test_efl_ui_position_manager_grid_min_size_known_only)
 {
    Efl_Ui_Win *win;
    Efl_Ui_Position_Manager_Entity *manager;
-   static const int widths[] = { 40, 90, 60, 50, 95 };
+   static const int widths[] = { 40, 95, 60, 50, 90 };
    unsigned int i;
 
    win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
@@ -2019,16 +2021,21 @@ EFL_START_TEST(test_efl_ui_position_manager_grid_min_size_known_only)
                                                           NULL, _known_size_cb, NULL, _cache_count);
    efl_ui_position_manager_entity_viewport_set(manager, EINA_RECT(0, 0, 200, 300));
    ecore_main_loop_iterate();
+   // (the biggest of the known ones, which are the first two, and not the 90 that is not known)
    ck_assert_int_eq(efl_ui_position_manager_entity_position_single_item(manager, 0).w, 95);
 
    // The item that gave the biggest one goes: the others that are known give theirs
    _known_calls = _full_calls = 0;
    _cache_count--;
-   efl_ui_position_manager_entity_item_removed(manager, _cache_count, _cache_dummy);
+   for (i = 1; i < _cache_count; i++)
+     {
+        _cache_sizes[i] = widths[i + 1];
+     }
+   efl_ui_position_manager_entity_item_removed(manager, 1, _cache_dummy);
    ecore_main_loop_iterate();
    ck_assert_uint_gt(_known_calls, 0);
    ck_assert_uint_eq(_full_calls, 0);
-   ck_assert_int_eq(efl_ui_position_manager_entity_position_single_item(manager, 0).w, 90);
+   ck_assert_int_eq(efl_ui_position_manager_entity_position_single_item(manager, 0).w, 60);
 
    efl_del(manager);
 }
@@ -2263,6 +2270,76 @@ EFL_START_TEST(test_efl_ui_collection_view_average_model_estimates)
 }
 EFL_END_TEST
 
+static void
+_cell_size(void *data EINA_UNUSED, const Efl_Event *ev)
+{
+   efl_gfx_hint_size_min_set(ev->info, EINA_SIZE2D(60, 40));
+}
+
+// A grid over an Average_Model, scrolled down, with a row that comes at the
+// start: what is said for the rows nobody measured (the size of the view) is
+// not the size of a cell, and the cells are not made as wide as the view,
+// which is one column.
+EFL_START_TEST(test_efl_ui_collection_view_average_model_grid_prepend)
+{
+   Efl_Ui_Win *win;
+   Efl_Model *model, *sizes, *base;
+   Efl_Ui_Factory *fl;
+   Efl_Ui_Grid_View *gv;
+   Efl_Ui_Position_Manager_Entity *manager;
+   Eina_Rect r0, r1;
+   int i;
+
+   win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+   efl_gfx_entity_size_set(win, EINA_SIZE2D(200, 300));
+
+   model = _make_model(win);
+   for (i = NUM_ITEMS; i < AVG_ROWS; i++)
+     {
+        efl_model_child_add(model);
+     }
+   base = efl_ui_view_model_get(model);
+   sizes = efl_add(EFL_UI_AVERAGE_MODEL_CLASS, win, efl_ui_view_model_set(efl_added, model));
+   manager = efl_new(EFL_UI_POSITION_MANAGER_GRID_CLASS);
+   fl = efl_add(EFL_UI_WIDGET_FACTORY_CLASS, win,
+                efl_ui_widget_factory_item_class_set(efl_added, EFL_UI_LIST_PLACEHOLDER_ITEM_CLASS),
+                efl_event_callback_add(efl_added, EFL_UI_FACTORY_EVENT_ITEM_BUILDING,
+                                       _cell_size, NULL));
+   gv = efl_add(EFL_UI_GRID_VIEW_CLASS, win,
+                efl_ui_collection_view_position_manager_set(efl_added, manager),
+                efl_ui_collection_view_factory_set(efl_added, fl),
+                efl_ui_view_model_set(efl_added, sizes));
+   efl_content_set(win, gv);
+   get_me_to_those_events(gv);
+   for (i = 0; i < 50; i++)
+     {
+        ecore_main_loop_iterate();
+     }
+
+   efl_ui_scrollable_content_pos_set(gv, EINA_POSITION2D(0, 2000));
+   for (i = 0; i < 20; i++)
+     {
+        ecore_main_loop_iterate();
+     }
+   r0 = efl_ui_position_manager_entity_position_single_item(manager, 0);
+   r1 = efl_ui_position_manager_entity_position_single_item(manager, 1);
+   ck_assert_int_eq(r0.y, r1.y);
+   ck_assert_int_gt(r1.x, r0.x);
+
+   efl_model_child_add(base);
+   for (i = 0; i < 20; i++)
+     {
+        ecore_main_loop_iterate();
+     }
+   ck_assert_uint_eq(efl_model_children_count_get(sizes), AVG_ROWS + 1);
+   r0 = efl_ui_position_manager_entity_position_single_item(manager, 0);
+   r1 = efl_ui_position_manager_entity_position_single_item(manager, 1);
+   ck_assert_int_eq(r0.y, r1.y);
+   ck_assert_int_gt(r1.x, r0.x);
+   ck_assert_int_le(r0.w, 100);
+}
+EFL_END_TEST
+
 void efl_ui_test_collection_view(TCase *tc)
 {
    tcase_add_test(tc, test_efl_ui_collection_view_basic);
@@ -2297,4 +2374,5 @@ void efl_ui_test_collection_view(TCase *tc)
    tcase_add_test(tc, test_efl_ui_position_manager_grid_min_size_known_only);
    tcase_add_test(tc, test_efl_ui_collection_view_grid_remove_fetches_nothing);
    tcase_add_test(tc, test_efl_ui_collection_view_average_model_estimates);
+   tcase_add_test(tc, test_efl_ui_collection_view_average_model_grid_prepend);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to