edje: fix edje RTL description in case of custom state of a part 31/67831/1
authorMinwoo, Lee <minwoo47.lee@samsung.com>
Thu, 28 Apr 2016 12:13:28 +0000 (21:13 +0900)
committerMinwoo, Lee <minwoo47.lee@samsung.com>
Thu, 28 Apr 2016 12:20:44 +0000 (21:20 +0900)
This patch is from opensource (59681c331139e4d5424e77ff1614dc47fa8ddd8ef5c4cd2f7f51f739f5f69eb4c857ccbfd8d51b0a)

    Summary:
    In case of RTL, the "custom" state properties does not apply. It happened because we don't copy the latest src to
    dst in set_state(PART:.., "custom", 0.0); in case of dst is already populated.
    We should copy the updated src to dst whenever we set the new custom description.

    @fix

    Reviewers: cedric, raster, jpeg, zmike, jaehwan

    Subscribers: kimcinoo, seoz, jpeg

    Differential Revision: https://phab.enlightenment.org/D339

Signed-off-by: Minwoo, Lee <minwoo47.lee@samsung.com>
Change-Id: Icf0b73f0cf2056e8f368c4215fc8139f2b4828e0

src/lib/edje/edje_calc.c

index ca0fee2..de9ef53 100644 (file)
@@ -271,6 +271,56 @@ _edje_part_make_rtl(Edje_Part_Description_Common *desc)
    desc->rel2.id_x = i;
 }
 
+static Edje_Part_Description_Common *
+_edje_get_custom_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type)
+{
+   Edje_Part_Description_Common *ret;
+   size_t memsize = 0;
+
+   /* RTL flag is not set, return original description */
+   if (!edje_object_mirrored_get(ed->obj))
+     return src;
+
+   if (!(*dst))
+     {
+        ret = _edje_get_description_by_orientation(ed, src, dst, type);
+        return ret;
+     }
+
+#define POPULATE_MEMSIZE_RTL(Short, Type)                        \
+case EDJE_PART_TYPE_##Short:                                          \
+{                                                                     \
+   memsize = sizeof(Edje_Part_Description_##Type);                    \
+   break;                                                             \
+}
+
+   switch (type)
+     {
+        POPULATE_MEMSIZE_RTL(RECTANGLE, Common);
+        POPULATE_MEMSIZE_RTL(SNAPSHOT, Snapshot);
+        POPULATE_MEMSIZE_RTL(SWALLOW, Common);
+        POPULATE_MEMSIZE_RTL(GROUP, Common);
+        POPULATE_MEMSIZE_RTL(SPACER, Common);
+        POPULATE_MEMSIZE_RTL(TEXT, Text);
+        POPULATE_MEMSIZE_RTL(TEXTBLOCK, Text);
+        POPULATE_MEMSIZE_RTL(IMAGE, Image);
+        POPULATE_MEMSIZE_RTL(PROXY, Proxy);
+        POPULATE_MEMSIZE_RTL(BOX, Box);
+        POPULATE_MEMSIZE_RTL(TABLE, Table);
+        POPULATE_MEMSIZE_RTL(EXTERNAL, External);
+        POPULATE_MEMSIZE_RTL(CAMERA, Camera);
+        POPULATE_MEMSIZE_RTL(LIGHT, Light);
+        POPULATE_MEMSIZE_RTL(MESH_NODE, Mesh_Node);
+     }
+#undef POPULATE_MEMSIZE_RTL
+
+   ret = *dst;
+   memcpy(ret, src, memsize);
+   _edje_part_make_rtl(ret);
+
+   return ret;
+}
+
 /**
  * Returns part description
  *
@@ -398,8 +448,8 @@ _edje_part_description_find(Edje *ed, Edje_Real_Part *rp, const char *state_name
 
    if (!strcmp(state_name, "custom"))
      return rp->custom ?
-            _edje_get_description_by_orientation(ed, rp->custom->description,
-                                                 &rp->custom->description_rtl, ep->type) : NULL;
+            _edje_get_custom_description_by_orientation(ed, rp->custom->description,
+                                                       &rp->custom->description_rtl, ep->type) : NULL;
 
    if (!strcmp(state_name, "default") && approximate)
      {