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 66da550c1db675b1ed6b9af04f0017c3aa67e44d
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 13:02:30 2026 -0600

    elementary: a layout's table part fills in order, keeps to its children
    
    The fill order of a table part started at 0,1, ignored spans and passed
    the part proxy rather than the layout to the pack, so an empty table
    refused its first child. It now follows Efl.Ui.Table's: after the last
    cell covered in the last row covered, and an empty table starts at 0,0.
    
    The cell setters acted on children that belonged to another container,
    which then moved them there. They now act only on children of the part,
    and clamp negative values like Efl.Ui.Table; pack_table on a part clamps
    too.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_layout_pack.c   | 67 ++++++++++++++++++++-----------
 src/tests/elementary/efl_ui_test_layout.c | 48 ++++++++++++++++++++++
 2 files changed, 91 insertions(+), 24 deletions(-)

diff --git a/src/lib/elementary/efl_ui_layout_pack.c b/src/lib/elementary/efl_ui_layout_pack.c
index 5aba9be14f..edc639afc0 100644
--- a/src/lib/elementary/efl_ui_layout_pack.c
+++ b/src/lib/elementary/efl_ui_layout_pack.c
@@ -309,49 +309,58 @@ _efl_ui_layout_part_table_efl_pack_unpack(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Tab
 
 
 EOLIAN static Eina_Bool
-_efl_ui_layout_part_table_efl_pack_pack(Eo *obj, Efl_Ui_Layout_Table_Data *pd, Efl_Gfx_Entity *subobj)
+_efl_ui_layout_part_table_efl_pack_pack(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Table_Data *pd, Efl_Gfx_Entity *subobj)
 {
-   int last_col = 0, last_row = 0;
-   int req_cols, req_rows;
+   int last_col = -1, last_row = -1;
    Eina_Iterator *iter;
    Eo *pack, *element;
 
+   // As Efl.Ui.Table does, with no column limit: after the last cell covered
+   // in the last row covered, an empty table starts at 0,0.
    pack = _pack_real(pd);
-
-
-   //first lookup what the most lower / right element is
    iter = evas_object_table_iterator_new(pack);
    EINA_ITERATOR_FOREACH(iter, element)
      {
-        unsigned short item_col, item_row;
+        unsigned short item_col, item_row, item_colspan, item_rowspan;
+        int end_col, end_row;
 
-        evas_object_table_pack_get(pack, element, &item_col, &item_row, NULL, NULL);
-        if (item_row > last_row ||
-            (item_row == last_row && item_col > last_col))
+        evas_object_table_pack_get(pack, element, &item_col, &item_row,
+                                   &item_colspan, &item_rowspan);
+        end_col = item_col + item_colspan - 1;
+        end_row = item_row + item_rowspan - 1;
+        if ((end_row > last_row) ||
+            ((end_row == last_row) && (end_col > last_col)))
           {
-             last_col = item_col;
-             last_row = item_row;
+             last_col = end_col;
+             last_row = end_row;
           }
      }
    eina_iterator_free(iter);
 
-   //now add the new element right to it, or do a linebreak and place
-   //that element in the next column on the first element
-   evas_object_table_col_row_size_get(pack, &req_cols, &req_rows);
-   last_col ++;
-   if (last_col > req_cols)
-     {
-        last_row ++;
-        last_col = 0;
-     }
+   last_col++;
+   if (last_row < 0) last_row = 0;
 
-   return _efl_ui_layout_table_pack(obj, pd->sd, pd->part, subobj, last_col, last_row, 1, 1);
+   return _efl_ui_layout_table_pack(pd->obj, pd->sd, pd->part, subobj, last_col, last_row, 1, 1);
 }
 
 
+// The limits of Efl.Ui.Table: no negative cell, spans of one at least, and
+// nothing past what the evas table can hold.
+static void
+_table_cell_clamp(int *col, int *colspan)
+{
+   if (*col < 0) *col = 0;
+   if (*col > USHRT_MAX) *col = USHRT_MAX;
+   if (*colspan < 1) *colspan = 1;
+   if (*col + *colspan > USHRT_MAX) *colspan = USHRT_MAX - *col;
+   if (*colspan < 1) *colspan = 1;
+}
+
 EOLIAN static Eina_Bool
 _efl_ui_layout_part_table_efl_pack_table_pack_table(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Table_Data *pd, Efl_Gfx_Entity *subobj, int col, int row, int colspan, int rowspan)
 {
+   _table_cell_clamp(&col, &colspan);
+   _table_cell_clamp(&row, &rowspan);
    return _efl_ui_layout_table_pack(pd->obj, pd->sd, pd->part, subobj, col, row, colspan, rowspan);
 }
 
@@ -407,6 +416,12 @@ _efl_ui_layout_part_table_efl_pack_table_table_cell_column_get(const Eo *obj EIN
    return ret;
 }
 
+static Eina_Bool
+_table_child_is_mine(Eo *pack, Efl_Gfx_Entity *subobj)
+{
+   return pack && subobj && (evas_object_smart_parent_get(subobj) == pack);
+}
+
 EOLIAN static void
 _efl_ui_layout_part_table_efl_pack_table_table_cell_column_set(Eo *obj EINA_UNUSED, Efl_Ui_Layout_Table_Data *pd, Efl_Gfx_Entity * subobj, int col, int colspan)
 {
@@ -414,7 +429,9 @@ _efl_ui_layout_part_table_efl_pack_table_table_cell_column_set(Eo *obj EINA_UNUS
 
    Eo *pack = _pack_real(pd);
 
-   evas_object_table_pack_get(pack, subobj, NULL, &r, NULL, &rs);
+   if (!_table_child_is_mine(pack, subobj)) return;
+   if (!evas_object_table_pack_get(pack, subobj, NULL, &r, NULL, &rs)) return;
+   _table_cell_clamp(&col, &colspan);
    evas_object_table_pack(pack, subobj, col, r, colspan, rs);
 }
 
@@ -440,7 +457,9 @@ _efl_ui_layout_part_table_efl_pack_table_table_cell_row_set(Eo *obj EINA_UNUSED,
 
    Eo *pack = _pack_real(pd);
 
-   evas_object_table_pack_get(pack, subobj, &c, NULL, &cs, NULL);
+   if (!_table_child_is_mine(pack, subobj)) return;
+   if (!evas_object_table_pack_get(pack, subobj, &c, NULL, &cs, NULL)) return;
+   _table_cell_clamp(&row, &rowspan);
    evas_object_table_pack(pack, subobj, c, row, cs, rowspan);
 }
 
diff --git a/src/tests/elementary/efl_ui_test_layout.c b/src/tests/elementary/efl_ui_test_layout.c
index cfea966c49..6d21327e94 100644
--- a/src/tests/elementary/efl_ui_test_layout.c
+++ b/src/tests/elementary/efl_ui_test_layout.c
@@ -886,6 +886,53 @@ EFL_START_TEST(efl_ui_layout_test_navigation_bar_side_content)
 }
 EFL_END_TEST
 
+/* The fill order of a table part is Efl.Ui.Table's: after the last cell
+ * covered, and an empty table starts at 0,0. The cell setters only act on
+ * children of the part, and a pack_table with a negative cell is clamped. */
+EFL_START_TEST(efl_ui_layout_test_table_part_fill_order)
+{
+   char buf[PATH_MAX];
+   Eo *win, *ly, *a, *b, *c, *foreign;
+   int col, row;
+
+   win = win_add(NULL, "layout", EFL_UI_WIN_TYPE_BASIC);
+   ly = efl_add(EFL_UI_LAYOUT_CLASS, win);
+   snprintf(buf, sizeof(buf), "%s/objects/test.edj", ELM_TEST_DATA_DIR);
+   ck_assert(efl_file_simple_load(ly, buf, "table_layout"));
+
+   a = efl_add(EFL_UI_BUTTON_CLASS, win);
+   b = efl_add(EFL_UI_BUTTON_CLASS, win);
+   c = efl_add(EFL_UI_BUTTON_CLASS, win);
+   foreign = efl_add(EFL_UI_BUTTON_CLASS, win);
+
+   /* an empty table starts at 0,0 */
+   ck_assert(efl_pack(efl_part(ly, "table"), a));
+   ck_assert(efl_pack_table_cell_column_get(efl_part(ly, "table"), a, &col, NULL));
+   ck_assert(efl_pack_table_cell_row_get(efl_part(ly, "table"), a, &row, NULL));
+   ck_assert_int_eq(col, 0);
+   ck_assert_int_eq(row, 0);
+
+   /* the next one goes after the last cell covered, spans included */
+   ck_assert(efl_pack_table(efl_part(ly, "table"), b, 1, 0, 3, 1));
+   ck_assert(efl_pack(efl_part(ly, "table"), c));
+   ck_assert(efl_pack_table_cell_column_get(efl_part(ly, "table"), c, &col, NULL));
+   ck_assert(efl_pack_table_cell_row_get(efl_part(ly, "table"), c, &row, NULL));
+   ck_assert_int_eq(col, 4);
+   ck_assert_int_eq(row, 0);
+
+   /* a child that is not the part's has no cell to change here */
+   efl_pack_table_cell_column_set(efl_part(ly, "table"), foreign, 2, 1);
+   ck_assert_ptr_eq(efl_pack_table_content_get(efl_part(ly, "table"), 1, 0), b);
+   ck_assert_int_eq(efl_content_count(efl_part(ly, "table")), 3);
+
+   /* a negative cell is clamped, as Efl.Ui.Table does */
+   ck_assert(efl_pack_unpack(efl_part(ly, "table"), c));
+   ck_assert(efl_pack_table(efl_part(ly, "table"), c, -3, -1, 0, 0));
+   ck_assert(efl_pack_table_cell_column_get(efl_part(ly, "table"), c, &col, NULL));
+   ck_assert_int_eq(col, 0);
+}
+EFL_END_TEST
+
 void efl_ui_test_layout(TCase *tc)
 {
    tcase_add_test(tc, efl_ui_layout_calc_subobjs_without_calc);
@@ -913,5 +960,6 @@ void efl_ui_test_layout(TCase *tc)
    tcase_add_test(tc, efl_ui_layout_test_navigation_bar_side_content);
    tcase_add_test(tc, efl_ui_layout_test_property_bind_unknown_key);
    tcase_add_test(tc, efl_ui_layout_test_table_part_getters);
+   tcase_add_test(tc, efl_ui_layout_test_table_part_fill_order);
    tcase_add_test(tc, efl_ui_layout_test_box_part);
 }

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

Reply via email to