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 c5edc679404fcf5f5ebd0d770b44d31978b85125
Author: Cedric BAIL <[email protected]>
AuthorDate: Fri Nov 6 00:32:58 2026 -0600

    elementary: a NULL relation base resets to the container
    
    The relation setters document that a NULL base means the container
    (the default), but a NULL base left the previous target in place. Reset
    the relation to the container instead.
    
    Also document that setting a relation on an object that is not yet a
    child packs it, which has always been the behaviour and is kept for
    stable-API compatibility.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_relative_container.eo    | 16 +++++--
 .../elementary/efl_ui_relative_container_private.h |  2 +-
 .../elementary/efl_ui_test_relative_container.c    | 50 ++++++++++++++++++++++
 3 files changed, 63 insertions(+), 5 deletions(-)

diff --git a/src/lib/elementary/efl_ui_relative_container.eo b/src/lib/elementary/efl_ui_relative_container.eo
index 8ec842ff25..e48dcf70c8 100644
--- a/src/lib/elementary/efl_ui_relative_container.eo
+++ b/src/lib/elementary/efl_ui_relative_container.eo
@@ -13,7 +13,9 @@ class Efl.Ui.Relative_Container extends Efl.Ui.Widget implements Efl.Pack_Layout
          [[Specifies the left side edge of the $child object relative to the $base object.
            When $relative_position is 0 the left edges of the two objects are aligned.
            When $relative_position is 1 the left edge of the $child object is aligned
-           to the right edge of the $base object.]]
+           to the right edge of the $base object.
+           Setting a relation on an object that is not a child of this container
+           packs it into this container.]]
          keys {
             child: Efl.Gfx.Entity; [[The child object whose size and position is
                                      being changed.]]
@@ -30,7 +32,9 @@ class Efl.Ui.Relative_Container extends Efl.Ui.Widget implements Efl.Pack_Layout
          [[Specifies the right side edge of the $child object relative to the $base object.
            When $relative_position is 0 the right edge of the $child object is aligned
            to the left edge of the $base object.
-           When $relative_position is 1 the right edges of the two objects are aligned.]]
+           When $relative_position is 1 the right edges of the two objects are aligned.
+           Setting a relation on an object that is not a child of this container
+           packs it into this container.]]
          keys {
             child: Efl.Gfx.Entity; [[The child object whose size and position is
                                      being changed.]]
@@ -47,7 +51,9 @@ class Efl.Ui.Relative_Container extends Efl.Ui.Widget implements Efl.Pack_Layout
          [[Specifies the top side edge of the $child object relative to the $base object.
            When $relative_position is 0 the top edges of the two objects are aligned.
            When $relative_position is 1 the top edge of the $child object is aligned
-           to the bottom edge of the $base object.]]
+           to the bottom edge of the $base object.
+           Setting a relation on an object that is not a child of this container
+           packs it into this container.]]
          keys {
             child: Efl.Gfx.Entity; [[The child object whose size and position is
                                      being changed.]]
@@ -64,7 +70,9 @@ class Efl.Ui.Relative_Container extends Efl.Ui.Widget implements Efl.Pack_Layout
          [[Specifies the bottom side edge of the $child object relative to the $base object.
            When $relative_position is 0 the bottom edge of the $child object is aligned
            to the top edge of the $base object.
-           When $relative_position is 1 the bottom edges of the two objects are aligned.]]
+           When $relative_position is 1 the bottom edges of the two objects are aligned.
+           Setting a relation on an object that is not a child of this container
+           packs it into this container.]]
          keys {
             child: Efl.Gfx.Entity; [[The child object whose size and position is
                                      being changed.]]
diff --git a/src/lib/elementary/efl_ui_relative_container_private.h b/src/lib/elementary/efl_ui_relative_container_private.h
index 43ea3c2d7c..4eb04de9ef 100644
--- a/src/lib/elementary/efl_ui_relative_container_private.h
+++ b/src/lib/elementary/efl_ui_relative_container_private.h
@@ -112,7 +112,7 @@ struct _Efl_Ui_Relative_Container_Content_Iterator
       if (!child) return; \
       rc = _relative_child_get(pd, child); \
       if (!rc) return; \
-      if (target) rc->rel[DIRECTION].to = target; \
+      rc->rel[DIRECTION].to = target ? target : obj; \
       if (relative_position < 0) relative_position = 0; \
       else if (relative_position > 1) relative_position = 1; \
       rc->rel[DIRECTION].relative_position = relative_position; \
diff --git a/src/tests/elementary/efl_ui_test_relative_container.c b/src/tests/elementary/efl_ui_test_relative_container.c
index 35cf5a2c6e..4cb679312f 100644
--- a/src/tests/elementary/efl_ui_test_relative_container.c
+++ b/src/tests/elementary/efl_ui_test_relative_container.c
@@ -363,6 +363,54 @@ EFL_START_TEST (efl_ui_relative_container_pack)
 }
 EFL_END_TEST
 
+EFL_START_TEST (efl_ui_relative_container_null_base_resets)
+{
+   Eo *a, *b, *target = NULL;
+   Eina_Rect ref;
+   double relative = -1.0;
+
+   a = efl_add(EFL_UI_BUTTON_CLASS, layout, efl_pack(layout, efl_added));
+   b = efl_add(EFL_UI_BUTTON_CLASS, layout, efl_pack(layout, efl_added));
+
+   efl_ui_relative_container_relation_left_set(layout, b, a, 1.0);
+   efl_ui_relative_container_relation_left_get(layout, b, &target, &relative);
+   ck_assert_ptr_eq(target, a);
+
+   efl_ui_relative_container_relation_left_set(layout, b, NULL, 0.0);
+   efl_ui_relative_container_relation_left_get(layout, b, &target, &relative);
+   ck_assert_ptr_eq(target, layout);
+   ck_assert(EINA_DBL_EQ(relative, 0.0));
+
+   // the layout matches a child that never had a relation
+   efl_canvas_group_calculate(layout);
+   ref = efl_gfx_entity_geometry_get(a);
+   ck_assert_int_eq(efl_gfx_entity_geometry_get(b).x, ref.x);
+   ck_assert_int_eq(efl_gfx_entity_geometry_get(b).w, ref.w);
+}
+EFL_END_TEST
+
+EFL_START_TEST (efl_ui_relative_container_relation_packs_child)
+{
+   Eo *btn, *child;
+   Eina_Iterator *it;
+   Eina_Bool found = EINA_FALSE;
+
+   btn = efl_add(EFL_UI_BUTTON_CLASS, layout);
+   ck_assert_int_eq(efl_content_count(layout), 0);
+
+   efl_ui_relative_container_relation_left_set(layout, btn, layout, 0.5);
+
+   it = efl_content_iterate(layout);
+   EINA_ITERATOR_FOREACH(it, child)
+     {
+        if (child == btn) found = EINA_TRUE;
+     }
+   eina_iterator_free(it);
+   ck_assert(found);
+   ck_assert_int_eq(efl_content_count(layout), 1);
+}
+EFL_END_TEST
+
 void efl_ui_test_relative_container(TCase *tc)
 {
    tcase_add_checked_fixture(tc, layout_setup, NULL);
@@ -371,4 +419,6 @@ void efl_ui_test_relative_container(TCase *tc)
    tcase_add_test(tc, efl_ui_relative_container_layout_update_chain);
    tcase_add_test(tc, efl_ui_relative_container_relation_set);
    tcase_add_test(tc, efl_ui_relative_container_pack);
+   tcase_add_test(tc, efl_ui_relative_container_null_base_resets);
+   tcase_add_test(tc, efl_ui_relative_container_relation_packs_child);
 }

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

Reply via email to