Edje: Reparent when swallowing/unswallowing.
authorTom Hacohen <tom@stosb.com>
Thu, 7 Apr 2016 13:56:57 +0000 (14:56 +0100)
committerTom Hacohen <tom@stosb.com>
Mon, 18 Apr 2016 09:10:23 +0000 (10:10 +0100)
On swallow make the edje object the parent, on unswallow the canvas.

src/lib/edje/edje_edit.c
src/lib/edje/edje_util.c

index 05ed301..5ddd4f4 100644 (file)
@@ -315,6 +315,7 @@ _edje_real_part_free(Edje *ed, Edje_Real_Part *rp)
    if ((rp->type == EDJE_RP_TYPE_SWALLOW) && (rp->typedata.swallow)
        && (rp->typedata.swallow->swallowed_object))
      {
+        eo_parent_set(rp->typedata.swallow->swallowed_object, evas_common_evas_get(ed->obj));
         evas_object_smart_member_del(rp->typedata.swallow->swallowed_object);
         evas_object_event_callback_del(rp->typedata.swallow->swallowed_object,
                                        EVAS_CALLBACK_FREE, _edje_object_part_swallow_free_cb);
@@ -3147,7 +3148,11 @@ _edje_edit_real_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type
         evas_object_show(rp->object);
         evas_object_smart_member_add(rp->object, ed->obj);
         evas_object_layer_set(rp->object, evas_object_layer_get(ed->obj));
-        if (ep->type != EDJE_PART_TYPE_SWALLOW && ep->type != EDJE_PART_TYPE_GROUP)
+        if (ep->type == EDJE_PART_TYPE_SWALLOW)
+          {
+             eo_parent_set(rp->object, ed->obj);
+          }
+        else if (ep->type != EDJE_PART_TYPE_GROUP)
           {
              if (ep->mouse_events)
                {
index 4a522d8..a34d81c 100644 (file)
@@ -4966,6 +4966,7 @@ _edje_child_add(Edje *ed, Edje_Real_Part *rp, Evas_Object *child)
    evas_object_event_callback_add(child, EVAS_CALLBACK_DEL, _edje_child_del_cb, rp);
    evas_object_data_set(child, ".edje", ed);
    if (!ed) return;
+   eo_parent_set(child, ed->obj);
    ed->dirty = EINA_TRUE;
    ed->recalc_call = EINA_TRUE;
 #ifdef EDJE_CALC_CACHE
@@ -4975,11 +4976,21 @@ _edje_child_add(Edje *ed, Edje_Real_Part *rp, Evas_Object *child)
 }
 
 static void
+_eo_unparent_helper(Eo *child, Eo *parent)
+{
+   if (eo_parent_get(child) == parent)
+     {
+        eo_parent_set(child, evas_common_evas_get(parent));
+     }
+}
+
+static void
 _edje_child_remove(Edje *ed, Edje_Real_Part *rp, Evas_Object *child)
 {
    evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL, _edje_child_del_cb, rp);
    evas_object_data_del(child, ".edje");
    if (!ed) return;
+   _eo_unparent_helper(child, ed->obj);
    ed->dirty = EINA_TRUE;
    ed->recalc_call = EINA_TRUE;
 #ifdef EDJE_CALC_CACHE
@@ -6322,6 +6333,7 @@ _edje_real_part_swallow(Edje *ed,
 #endif
    if (!obj_swallow) return;
    rp->typedata.swallow->swallowed_object = obj_swallow;
+   eo_parent_set(obj_swallow, ed->obj);
    evas_object_smart_member_add(rp->typedata.swallow->swallowed_object, ed->obj);
    if (rp->part->clip_to_id >= 0)
      {
@@ -6380,6 +6392,7 @@ _edje_real_part_swallow_clear(Edje *ed, Edje_Real_Part *rp)
    if ((rp->type != EDJE_RP_TYPE_SWALLOW) ||
        (!rp->typedata.swallow)) return;
    if (!rp->typedata.swallow->swallowed_object) return;
+   _eo_unparent_helper(rp->typedata.swallow->swallowed_object, ed->obj);
    evas_object_smart_member_del(rp->typedata.swallow->swallowed_object);
    evas_object_event_callback_del_full(rp->typedata.swallow->swallowed_object,
                                        EVAS_CALLBACK_DEL,