rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=b4db1ced37f836fbb40ded6c3d855feeb0842082

commit b4db1ced37f836fbb40ded6c3d855feeb0842082
Author: Vitalii Vorobiov <vi.vorob...@samsung.com>
Date:   Fri Jul 24 15:11:22 2015 +0300

    Live View Property: part restack implementation
    
    According to how it works in genlist,
    every restack cause part_restack_above only.
    
    part_restack_below calls in rare cases where there are no parts below 
anymore,
    so simply it just put restacking part to the end of list.
    
    While list of parts in "live view property" different from style's part 
list,
    it need to go through "live view property" part list
    to find moving and relative parts by it's names.
---
 src/bin/ui/connector.c                |  11 +++-
 src/bin/ui/live_view/live_view.c      |   5 +-
 src/bin/ui/live_view/live_view.h      |   2 +-
 src/bin/ui/live_view/live_view_prop.c | 118 ++++++++++++++++++++++++++++++++--
 src/bin/ui/live_view/live_view_prop.h |   2 +-
 5 files changed, 126 insertions(+), 12 deletions(-)

diff --git a/src/bin/ui/connector.c b/src/bin/ui/connector.c
index 3959665..05cb298 100644
--- a/src/bin/ui/connector.c
+++ b/src/bin/ui/connector.c
@@ -189,8 +189,13 @@ _below_part(void *data,
      }
 
    tmp_list = eina_inlist_find(style->parts, EINA_INLIST_GET(part));
-   Part *rel = EINA_INLIST_CONTAINER_GET(tmp_list->prev, Part);
-   live_view_part_restack_below(ap->live_view, part, rel);
+   if (!tmp_list->next)
+     live_view_part_restack_below(ap->live_view, part);
+   else
+     {
+        Part *rel = EINA_INLIST_CONTAINER_GET(tmp_list->next, Part);
+        live_view_part_restack_above(ap->live_view, part, rel);
+     }
    project_changed(true);
 }
 
@@ -233,7 +238,7 @@ _restack_part_below(void *data,
    if ((!part) || (!style)) return;
    history_diff_add(style->obj, PART_TARGET, RESTACK, part->name);
    workspace_edit_object_part_restack(ap->workspace, part->name, rel->name, 
true);
-   live_view_part_restack_below(ap->live_view, part, rel);
+   live_view_part_restack_below(ap->live_view, part);
 
    tmp_list = eina_inlist_find(style->parts, EINA_INLIST_GET(part));
    tmp_prev = eina_inlist_find(style->parts, EINA_INLIST_GET(rel));
diff --git a/src/bin/ui/live_view/live_view.c b/src/bin/ui/live_view/live_view.c
index a44a9e2..5125ddb 100644
--- a/src/bin/ui/live_view/live_view.c
+++ b/src/bin/ui/live_view/live_view.c
@@ -297,10 +297,9 @@ live_view_part_restack_above(Live_View *live, Part 
*part_move, Part *part_above)
 }
 
 Eina_Bool
-live_view_part_restack_below(Live_View *live, Part *part_move, Part 
*part_below)
+live_view_part_restack_below(Live_View *live, Part *part_move)
 {
    assert(live != NULL);
    assert(part_move != NULL);
-   assert(part_below != NULL);
-   return live_view_property_part_restack_below(live->property, part_move, 
part_below);
+   return live_view_property_part_restack_below(live->property, part_move);
 }
diff --git a/src/bin/ui/live_view/live_view.h b/src/bin/ui/live_view/live_view.h
index c0d40ef..bc09469 100644
--- a/src/bin/ui/live_view/live_view.h
+++ b/src/bin/ui/live_view/live_view.h
@@ -147,6 +147,6 @@ Eina_Bool
 live_view_part_restack_above(Live_View *live, Part *part_move, Part 
*part_above);
 
 Eina_Bool
-live_view_part_restack_below(Live_View *live, Part *part_move, Part 
*part_below);
+live_view_part_restack_below(Live_View *live, Part *part_move);
 
 #endif /* UI_LIVEVIEW_HEADER_H */
diff --git a/src/bin/ui/live_view/live_view_prop.c 
b/src/bin/ui/live_view/live_view_prop.c
index 80d7bcb..72e468f 100644
--- a/src/bin/ui/live_view/live_view_prop.c
+++ b/src/bin/ui/live_view/live_view_prop.c
@@ -523,17 +523,127 @@ live_view_property_part_rename(Evas_Object *property 
__UNUSED__, Part *part __UN
    return true;
 }
 
+#define IS_SWALLOW_MOVE (part_move->type == EDJE_PART_TYPE_SWALLOW)
+#define IS_SWALLOW_CURR (part_type == EDJE_PART_TYPE_SWALLOW)
+
+#define IS_TEXT_OR_TEXTBLOCK_MOVE \
+  ((part_move->type == EDJE_PART_TYPE_TEXT) || (part_move->type == 
EDJE_PART_TYPE_TEXTBLOCK))
+
+#define IS_TEXT_OR_TEXTBLOCK_CURR \
+  ((part_type == EDJE_PART_TYPE_TEXT) || (part_type == 
EDJE_PART_TYPE_TEXTBLOCK))
+
 Eina_Bool
-live_view_property_part_restack_above(Evas_Object *property __UNUSED__, Part 
*part_move __UNUSED__, Part *part_above __UNUSED__)
+live_view_property_part_restack_above(Evas_Object *property, Part *part_move, 
Part *part_above)
 {
-   printf("Signal: moving part [%s] above [%s] \n", part_move->name, 
part_above->name);
+   Evas_Object *check_nearest = NULL, *check_move = NULL, *item_box = NULL, 
*check;
+   Eina_List *part_list = NULL, *part = NULL, *after_above_list = NULL;
+   Eina_List *items_list = NULL, *l;
+   PROP_DATA_GET();
+   Eina_Stringshare *part_name, *nearest_part = NULL;
+   int part_type;
+
+   if ((part_move->type != EDJE_PART_TYPE_TEXT) &&
+       (part_move->type != EDJE_PART_TYPE_TEXTBLOCK) &&
+       (part_move->type != EDJE_PART_TYPE_SWALLOW))
+     return false;
+
+   part_list = edje_edit_parts_list_get(pd->style->obj);
+
+   /* start searching for part with same type from part_above point.
+      We need to find name of this part. */
+   after_above_list = eina_list_data_find_list(part_list, part_above->name);
+   EINA_LIST_FOREACH(after_above_list, part, part_name)
+     {
+        part_type = edje_edit_part_type_get(pd->style->obj, part_name);
+
+        if (!strcmp(part_name, part_move->name))
+          return false;
+
+        if ((IS_SWALLOW_MOVE && IS_SWALLOW_CURR) ||
+            (IS_TEXT_OR_TEXTBLOCK_MOVE && IS_TEXT_OR_TEXTBLOCK_CURR))
+          {
+             nearest_part = part_name;
+             break;
+          }
+     }
+   edje_edit_string_list_free(part_list);
+
+   if (part_move->type ==  EDJE_PART_TYPE_SWALLOW)
+     item_box = pd->prop_swallow.swallows;
+   else if ((part_move->type ==  EDJE_PART_TYPE_TEXT) ||
+            (part_move->type ==  EDJE_PART_TYPE_TEXTBLOCK))
+     item_box = pd->prop_text.texts;
+
+   /* Now lets restack this.
+      We need to find moving check and check we need to move above */
+   assert(item_box != NULL);
+   items_list = elm_box_children_get(item_box);
+   EINA_LIST_FOREACH(items_list, l, check)
+     {
+        part_name = elm_object_part_text_get(check, NULL);
+        if (nearest_part && !strcmp(part_name, nearest_part))
+          check_nearest = check;
+
+        if (!strcmp(part_name, part_move->name))
+          check_move = check;
+
+        if (check_move && check_nearest)
+          break;
+     }
+
+   assert(check_move != NULL);
+   elm_box_unpack(item_box, check_move);
+
+   if (nearest_part)
+     {
+        assert(check_nearest != NULL);
+        elm_box_pack_before(item_box, check_move, check_nearest);
+     }
+   else /* if not found then we drop it to the end */
+     elm_box_pack_end(item_box, check_move);
+
    return true;
 }
 
+#undef IS_SWALLOW_MOVE
+#undef IS_SWALLOW_CURR
+#undef IS_TEXT_OR_TEXTBLOCK_MOVE
+#undef IS_TEXT_OR_TEXTBLOCK_CURR
+
 Eina_Bool
-live_view_property_part_restack_below(Evas_Object *property __UNUSED__, Part 
*part_move, Part *part_below __UNUSED__)
+live_view_property_part_restack_below(Evas_Object *property, Part *part_move)
 {
-   printf("Signal: moving part [%s] below [%s] \n", part_move->name, 
part_below->name);
+   Evas_Object *check_move = NULL, *item_box = NULL, *check;
+   Eina_List *items_list = NULL, *l;
+   PROP_DATA_GET();
+   Eina_Stringshare *part_name = NULL;
+
+   if ((part_move->type != EDJE_PART_TYPE_TEXT) &&
+       (part_move->type != EDJE_PART_TYPE_TEXTBLOCK) &&
+       (part_move->type != EDJE_PART_TYPE_SWALLOW))
+     return false;
+
+   /* Now lets restack this */
+   if (part_move->type ==  EDJE_PART_TYPE_SWALLOW)
+     item_box = pd->prop_swallow.swallows;
+   else if ((part_move->type ==  EDJE_PART_TYPE_TEXT) ||
+            (part_move->type ==  EDJE_PART_TYPE_TEXTBLOCK))
+     item_box = pd->prop_text.texts;
+
+   /* find check that we are moving and pack it to the end of items/box/lists 
*/
+   items_list = elm_box_children_get(item_box);
+   EINA_LIST_FOREACH(items_list, l, check)
+     {
+        part_name = elm_object_part_text_get(check, NULL);
+
+        if (!strcmp(part_name, part_move->name))
+          check_move = check;
+
+        if (check_move) break;
+     }
+
+   elm_box_unpack(item_box, check_move);
+   elm_box_pack_end(item_box, check_move);
    return true;
 }
 
diff --git a/src/bin/ui/live_view/live_view_prop.h 
b/src/bin/ui/live_view/live_view_prop.h
index 6a0126b..acb0848 100644
--- a/src/bin/ui/live_view/live_view_prop.h
+++ b/src/bin/ui/live_view/live_view_prop.h
@@ -130,6 +130,6 @@ Eina_Bool
 live_view_property_part_restack_above(Evas_Object *property, Part *part_move, 
Part *part_above);
 
 Eina_Bool
-live_view_property_part_restack_below(Evas_Object *property, Part *part_move, 
Part *part_below);
+live_view_property_part_restack_below(Evas_Object *property, Part *part_move);
 
 #endif /* UI_LIVEVIEWPROP_HEADER_H */

-- 


Reply via email to