bu5hm4n pushed a commit to branch master.

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

commit 4f0ce2c58c7b44888462c81a85340b70dd95f4bc
Author: Marcel Hollerbach <[email protected]>
Date:   Fri Apr 26 14:16:30 2019 +0200

    efl_ui: add a internal flag to mark widgets internal
    
    when a widget is marked internal, widgets can use that to behave in
    certain ways. Box for example uses this to not alter the widget_parent
    property anymore. Which is usefull for when boxes are used internally.
    
    Reviewed-by: Cedric BAIL <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D8736
---
 src/lib/elementary/efl_ui_box.c        | 16 +++++++++++++---
 src/lib/elementary/efl_ui_widget.c     | 18 ++++++++++++++++++
 src/lib/elementary/elm_priv.h          |  9 +++++++++
 src/lib/elementary/elm_widget.h        |  1 +
 src/tests/elementary/efl_ui_test_box.c | 13 +++++++++++++
 5 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/src/lib/elementary/efl_ui_box.c b/src/lib/elementary/efl_ui_box.c
index 92288e6b1a..c905ee18a2 100644
--- a/src/lib/elementary/efl_ui_box.c
+++ b/src/lib/elementary/efl_ui_box.c
@@ -52,8 +52,11 @@ _efl_ui_box_child_register(Eo *obj, Efl_Ui_Box_Data *pd, 
Efl_Gfx_Entity *subobj)
         return EINA_FALSE;
      }
 
-   if (!efl_ui_widget_sub_object_add(obj, subobj))
-     return EINA_FALSE;
+   if (!efl_ui_widget_internal_get(obj))
+     {
+        if (!efl_ui_widget_sub_object_add(obj, subobj))
+          return EINA_FALSE;
+     }
 
    efl_key_data_set(subobj, "_elm_leaveme", obj);
    efl_canvas_group_member_add(obj, subobj);
@@ -74,9 +77,16 @@ _efl_ui_box_child_unregister(Eo *obj, Efl_Ui_Box_Data *pd 
EINA_UNUSED, Efl_Gfx_E
         ERR("subobj %p %s is not part of this widget", subobj, 
efl_class_name_get(subobj) );
         return EINA_FALSE;
      }
-   if (!subobj || !_elm_widget_sub_object_redirect_to_top(obj, subobj))
+
+   if (!subobj)
      return EINA_FALSE;
 
+   if (!efl_ui_widget_internal_get(obj))
+     {
+        if (!_elm_widget_sub_object_redirect_to_top(obj, subobj))
+          return EINA_FALSE;
+     }
+
    efl_canvas_group_member_remove(obj, subobj);
    efl_canvas_object_clipper_set(subobj, NULL);
    efl_key_data_set(subobj, "_elm_leaveme", NULL);
diff --git a/src/lib/elementary/efl_ui_widget.c 
b/src/lib/elementary/efl_ui_widget.c
index 69d1700281..6f41aaec24 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -5850,6 +5850,24 @@ _efl_ui_widget_efl_object_invalidate(Eo *obj, 
Efl_Ui_Widget_Data *pd)
 
 #include "efl_ui_widget_part_bg.eo.c"
 
+EAPI void
+efl_ui_widget_internal_set(Eo *obj, Eina_Bool b)
+{
+   ELM_WIDGET_DATA_GET(obj, pd);
+   EINA_SAFETY_ON_NULL_RETURN(pd);
+
+   pd->internal = b;
+}
+
+EAPI Eina_Bool
+efl_ui_widget_internal_get(Eo *obj)
+{
+   ELM_WIDGET_DATA_GET(obj, pd);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
+
+   return pd->internal;
+}
+
 /* Efl.Part Bg end */
 
 
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index 94316191a5..f5eb2038b4 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -1022,4 +1022,13 @@ void legacy_object_focus_handle(Efl_Ui_Focus_Object 
*object);
 
 void _efl_ui_focus_event_redirector(Efl_Ui_Focus_Object *obj, 
Efl_Ui_Focus_Object *goal);
 
+/**
+ * With this flag you can indicate that this widget is used internally.
+ * Indicating that a widget is internal, can be used by the implementing 
widget, that the parent property of the added sub-object should not be adjusted 
or altered.
+ * There is no direct promise that any widget behaves like the above, every 
case should be handchecked.
+ */
+void efl_ui_widget_internal_set(Eo *obj, Eina_Bool internal);
+Eina_Bool efl_ui_widget_internal_get(Eo *obj);
+
+
 #endif
diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h
index 2f4de74721..fec163dc44 100644
--- a/src/lib/elementary/elm_widget.h
+++ b/src/lib/elementary/elm_widget.h
@@ -410,6 +410,7 @@ typedef struct _Elm_Widget_Smart_Data
    Eina_Bool                     on_destroy: 1; /**< This is true when the 
widget is on destruction(general widget destructor). */
    Eina_Bool                     provider_lookup : 1; /**< This is true when 
efl_provider_find is currently walking the tree */
    Eina_Bool                     has_shadow : 1;
+   Eina_Bool                     internal : 1;
 } Elm_Widget_Smart_Data;
 
 typedef Elm_Widget_Smart_Data Efl_Ui_Widget_Data;
diff --git a/src/tests/elementary/efl_ui_test_box.c 
b/src/tests/elementary/efl_ui_test_box.c
index a0fcb141ec..dd44b3ebca 100644
--- a/src/tests/elementary/efl_ui_test_box.c
+++ b/src/tests/elementary/efl_ui_test_box.c
@@ -5,6 +5,7 @@
 #include <Efl_Ui.h>
 #include <Elementary.h>
 #include "elm_suite.h"
+#include "elm_priv.h"
 
 #define COORD_EQ(a, b) (!!(abs(a - b) < 2))
 #define GEOMETRY_EQ(a, b) (COORD_EQ(a.x, b.x) && COORD_EQ(a.y, b.y) && \
@@ -551,6 +552,17 @@ EFL_START_TEST (efl_ui_box_properties)
 }
 EFL_END_TEST
 
+EFL_START_TEST (efl_ui_box_internal)
+{
+   Efl_Ui_Widget *w = efl_add(EFL_UI_BUTTON_CLASS, win);
+
+   efl_ui_widget_internal_set(layout, EINA_TRUE);
+   ck_assert_ptr_eq(efl_ui_widget_parent_get(w), win);
+   efl_pack(layout, w);
+   ck_assert_ptr_eq(efl_ui_widget_parent_get(w), win);
+}
+EFL_END_TEST
+
 void efl_ui_test_box(TCase *tc)
 {
    tcase_add_checked_fixture(tc, layout_setup, layout_teardown);
@@ -560,4 +572,5 @@ void efl_ui_test_box(TCase *tc)
    tcase_add_test(tc, efl_ui_box_size);
    tcase_add_test(tc, efl_ui_box_pack_unpack);
    tcase_add_test(tc, efl_ui_box_properties);
+   tcase_add_test(tc, efl_ui_box_internal);
 }

-- 


Reply via email to