rimmed pushed a commit to branch master.

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

commit 18c224545f93a52fb316bda93b9b463a1ba67297
Author: Vitalii Vorobiov <vi.vorob...@samsung.com>
Date:   Thu Jul 23 11:48:55 2015 +0300

    Live View Property: use theme_update and apply new API
    
    Use live_view_theme_update after every changing instead of unsetting and 
setting
    live object (which was so ridiculus).
    Now theme_update goes only after project_changed function.
    Apply new API (they are only stubs for now and doesn't work).
    
    TODO:
    Animator (apply theme_update and
    add function that update only programs/signals in live view)
---
 src/bin/history/history_attribute.c |  2 -
 src/bin/history/history_part.c      |  5 ---
 src/bin/history/history_state.c     |  1 -
 src/bin/ui/connector.c              | 84 +++++++++++++------------------------
 src/bin/ui/dialogs/part_dialog.c    |  2 +-
 src/bin/ui/shortcuts/shortcuts.c    |  2 +-
 src/bin/ui/workspace/ui_workspace.c |  1 -
 7 files changed, 32 insertions(+), 65 deletions(-)

diff --git a/src/bin/history/history_attribute.c 
b/src/bin/history/history_attribute.c
index ec7c810..4cc00e8 100644
--- a/src/bin/history/history_attribute.c
+++ b/src/bin/history/history_attribute.c
@@ -127,7 +127,6 @@ _history_ui_attribute_update(Evas_Object *source, 
Attribute_Diff *change)
                                         (void *)change->part);
         workspace_edit_object_part_state_set(app->workspace, part);
         ui_property_part_set(prop, part);
-        live_view_widget_style_set(app->live_view, app->project, style);
      }
    else
      {
@@ -143,7 +142,6 @@ _history_ui_attribute_update(Evas_Object *source, 
Attribute_Diff *change)
         ui_property_part_unset(prop);
         ui_property_style_set(prop, style, app->workspace);
         workspace_edit_object_recalc(app->workspace);
-        live_view_widget_style_set(app->live_view, app->project, style);
      }
 }
 
diff --git a/src/bin/history/history_part.c b/src/bin/history/history_part.c
index 56f550a..4321751 100644
--- a/src/bin/history/history_part.c
+++ b/src/bin/history/history_part.c
@@ -150,7 +150,6 @@ _part_redo(Evas_Object *source, Part_Diff *change)
 
    Evas_Object *prop = ui_block_property_get(app);
    Evas_Object *widget_list = ui_block_widget_list_get(app);
-   live_view_widget_style_unset(app->live_view);
 
    switch (change->diff.action_type)
      {
@@ -209,7 +208,6 @@ _part_redo(Evas_Object *source, Part_Diff *change)
         }
       break;
      }
-   live_view_widget_style_set(app->live_view, app->project, style);
    return true;
 }
 
@@ -233,8 +231,6 @@ _part_undo(Evas_Object *source, Part_Diff *change)
    Evas_Object *prop = ui_block_property_get(app);
    Evas_Object *widget_list = ui_block_widget_list_get(app);
 
-   live_view_widget_style_unset(app->live_view);
-
    switch (change->diff.action_type)
      {
       case ADD:
@@ -295,7 +291,6 @@ _part_undo(Evas_Object *source, Part_Diff *change)
         }
       break;
      }
-   live_view_widget_style_set(app->live_view, app->project, style);
    return true;
 }
 
diff --git a/src/bin/history/history_state.c b/src/bin/history/history_state.c
index a7e16ae..abd8261 100644
--- a/src/bin/history/history_state.c
+++ b/src/bin/history/history_state.c
@@ -196,7 +196,6 @@ _history_ui_state_update(Evas_Object *source, State_Diff 
*change)
      }
    ui_widget_list_part_selected_set(ui_block_widget_list_get(app), 
change->part,
                                     true);
-   live_view_widget_style_set(app->live_view, app->project, style);
 }
 
 State_Params *
diff --git a/src/bin/ui/connector.c b/src/bin/ui/connector.c
index 6b4e646..95e569b 100644
--- a/src/bin/ui/connector.c
+++ b/src/bin/ui/connector.c
@@ -91,26 +91,27 @@ _del_part(void *data,
         return;
      }
    part_name = strdup(part->name);
+
    /* In case when deleting part which is dragable area for another part,
       reloading style into liveview crash application */
-   live_view_widget_style_unset(ap->live_view);
    history_diff_add(style->obj, PART_TARGET, DEL, part_name);
    if (workspace_edit_object_part_del(ap->workspace, part->name))
-     ui_widget_list_selected_part_del(ui_block_widget_list_get(ap), style);
+     {
+        live_view_part_del(ap->live_view->property, part);
+        ui_widget_list_selected_part_del(ui_block_widget_list_get(ap), style);
+     }
 
    if (!style->parts)
      {
         ui_signal_list_data_unset(ap->block.signal_list);
+        _on_ws_part_unselect(ap, ap->workspace, part_name);
         workspace_highlight_unset(ap->workspace);
         /* Source code is updated on part selection.
            If this was last part we should update it manualy */
         prop_view = ui_block_property_get(ap);
         ui_property_code_of_group_setup(prop_view);
      }
-   else
-     {
-        live_view_widget_style_set(ap->live_view, ap->project, style);
-     }
+
    free(part_name);
    project_changed(true);
 }
@@ -144,7 +145,6 @@ _del_part_item(void *data,
      }
    workspace_edit_object_recalc(ap->workspace);
    project_changed(true);
-   live_view_widget_style_set(ap->live_view, ap->project, 
ap->project->current_style);
 }
 
 static void
@@ -152,11 +152,9 @@ _above_part(void *data,
           Evas_Object *obj __UNUSED__,
           void *event_info __UNUSED__)
 {
+   Eina_Inlist *tmp_list = NULL;
    App_Data *ap = (App_Data *)data;
    Style *style = ap->project->current_style;
-
-   assert(ap != NULL);
-
    if (!ui_widget_list_selected_part_above(ui_block_widget_list_get(ap), 
style))
       return;
    Part *part = ui_widget_list_selected_part_get(ui_block_widget_list_get(ap));
@@ -164,10 +162,12 @@ _above_part(void *data,
    history_diff_add(style->obj, PART_TARGET, RESTACK, part->name);
    if (!workspace_edit_object_part_above(ap->workspace, part->name))
      {
-        ERR("workspace_edit_object_part_above returned FALSE");
-        abort();
+        NOTIFY_ERROR(_("Internal edje error occurred on part move"));
+        ui_widget_list_selected_part_below(ui_block_widget_list_get(ap), 
style);
      }
-   live_view_widget_style_set(ap->live_view, ap->project, style);
+   tmp_list = eina_inlist_find(style->parts, EINA_INLIST_GET(part));
+   Part *rel = EINA_INLIST_CONTAINER_GET(tmp_list->next, Part);
+   live_view_part_restack_above(ap->live_view->property, part, rel);
    project_changed(true);
 }
 
@@ -176,11 +176,9 @@ _below_part(void *data,
           Evas_Object *obj __UNUSED__,
           void *event_info __UNUSED__)
 {
+   Eina_Inlist *tmp_list = NULL;
    App_Data *ap = (App_Data *)data;
    Style *style = ap->project->current_style;
-
-   assert(ap != NULL);
-
    if (!ui_widget_list_selected_part_below(ui_block_widget_list_get(ap), 
style))
       return;
    Part *part = ui_widget_list_selected_part_get(ui_block_widget_list_get(ap));
@@ -188,10 +186,13 @@ _below_part(void *data,
    history_diff_add(style->obj, PART_TARGET, RESTACK, part->name);
    if (!workspace_edit_object_part_below(ap->workspace, part->name))
      {
-        ERR("workspace_edit_object_part_below returned FALSE");
-        abort();
+        NOTIFY_ERROR(_("Internal edje error occurred on part move"));
+        ui_widget_list_selected_part_above(ui_block_widget_list_get(ap), 
style);
      }
-   live_view_widget_style_set(ap->live_view, ap->project, style);
+
+   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->property, part, rel);
    project_changed(true);
 }
 
@@ -202,25 +203,19 @@ _restack_part_above(void *data,
 {
    App_Data *ap = (App_Data *)data;
    Part *rel = (Part *)event_info;
-
-   assert(ap != NULL);
-
    Part *part = ui_widget_list_selected_part_get(ui_block_widget_list_get(ap));
    Style *style = ap->project->current_style;
    Eina_Inlist *tmp_list = NULL, *tmp_prev = NULL;
 
-   assert(part != NULL);
-   assert(style != NULL);
-
+   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, 
false);
-   live_view_widget_style_set(ap->live_view, ap->project, style);
+   live_view_part_restack_above(ap->live_view->property, part, rel);
 
    tmp_list = eina_inlist_find(style->parts, EINA_INLIST_GET(part));
    tmp_prev = eina_inlist_find(style->parts, EINA_INLIST_GET(rel));
    project_changed(true);
-
-   assert(tmp_list != NULL);
+   if (!tmp_list) return;
 
    style->parts = eina_inlist_remove(style->parts, tmp_list);
    style->parts = eina_inlist_prepend_relative(style->parts, tmp_list, 
tmp_prev);
@@ -233,25 +228,19 @@ _restack_part_below(void *data,
 {
    App_Data *ap = (App_Data *)data;
    Part *rel = (Part *)event_info;
-
-   assert(ap != NULL);
-
    Style *style = ap->project->current_style;
    Part *part = ui_widget_list_selected_part_get(ui_block_widget_list_get(ap));
    Eina_Inlist *tmp_list = NULL, *tmp_prev = NULL;
 
-   assert(part != NULL);
-   assert(style != NULL);
-
+   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_widget_style_set(ap->live_view, ap->project, style);
+   live_view_part_restack_below(ap->live_view->property, part, rel);
 
    tmp_list = eina_inlist_find(style->parts, EINA_INLIST_GET(part));
    tmp_prev = eina_inlist_find(style->parts, EINA_INLIST_GET(rel));
    project_changed(true);
-
-   assert(tmp_list != NULL);
+   if (!tmp_list) return;
 
    style->parts = eina_inlist_remove(style->parts, tmp_list);
    style->parts = eina_inlist_append_relative(style->parts, tmp_list, 
tmp_prev);
@@ -275,17 +264,6 @@ _show_part(void *data,
      }
 }
 
-/*
-static void
-_live_view_update(void *data,
-                  Evas_Object *obj __UNUSED__,
-                  void *event_info __UNUSED__)
-{
-   App_Data *ap = (App_Data *)data;
-   live_view_theme_update(ap->live_view, ap->project);
-}
-*/
-
 static void
 _signal_select(void *data,
                Evas_Object *obj __UNUSED__,
@@ -1038,14 +1016,8 @@ _progress_end(void *data, PM_Project_Result result)
      }
 #endif /* HAVE_ENVENTOR */
 
-   if (ap->project->current_style)
-     {
-        live_view_widget_style_unset(ap->live_view);
-        live_view_widget_style_set(ap->live_view, ap->project, 
ap->project->current_style);
-     }
    splash_del(ap->splash);
    ap->splash = NULL;
-
 }
 
 static Eina_Bool
@@ -1141,6 +1113,10 @@ project_changed(Eina_Bool save)
    pm_save_to_dev(ap->project, ap->project->current_style, save);
    ap->project->changed = true;
    ui_menu_disable_set(ap->menu, MENU_FILE_SAVE, false);
+   /* for example this function will be called after adding layout, so no need
+      in updating live view */
+   if (ap->project->current_style)
+     live_view_theme_update(ap->live_view, ap->project);
 }
 
 
/******************************************************************************/
diff --git a/src/bin/ui/dialogs/part_dialog.c b/src/bin/ui/dialogs/part_dialog.c
index c9b3a05..44dddd4 100644
--- a/src/bin/ui/dialogs/part_dialog.c
+++ b/src/bin/ui/dialogs/part_dialog.c
@@ -78,7 +78,7 @@ _cancel_clicked(void *data,
    history_diff_add(style->obj, PART_TARGET, ADD, name); \
    ap->popup = NULL; \
    ui_menu_items_list_disable_set(ap->menu, MENU_ITEMS_LIST_MAIN, false); \
-   live_view_widget_style_set(ap->live_view, ap->project, style); \
+   live_view_part_add(ap->live_view->property, 
ui_widget_list_selected_part_get(widget_list)); \
    project_changed(true);
 
 static void
diff --git a/src/bin/ui/shortcuts/shortcuts.c b/src/bin/ui/shortcuts/shortcuts.c
index 61d5a46..2b7d418 100644
--- a/src/bin/ui/shortcuts/shortcuts.c
+++ b/src/bin/ui/shortcuts/shortcuts.c
@@ -147,7 +147,7 @@ _random_name_generate(char *part_name, unsigned int length)
    if (workspace_edit_object_part_add(workspace, name, TYPE, DATA)) \
      ui_widget_list_part_add(widget_list, style, name); \
    history_diff_add(style->obj, PART_TARGET, ADD, name); \
-   live_view_widget_style_set(app->live_view, app->project, style); \
+   live_view_part_add(app->live_view->property, 
ui_widget_list_selected_part_get(widget_list)); \
    project_changed(true);
 
 #define PART_ADD(TYPE, FUNC) \
diff --git a/src/bin/ui/workspace/ui_workspace.c 
b/src/bin/ui/workspace/ui_workspace.c
index d3cc527..ee0e135 100644
--- a/src/bin/ui/workspace/ui_workspace.c
+++ b/src/bin/ui/workspace/ui_workspace.c
@@ -1320,7 +1320,6 @@ workspace_edit_object_recalc(Evas_Object *obj)
      {
         container_min_size_set(app->live_view->live_view, min_w, min_h);
         container_max_size_set(app->live_view->live_view, max_w, max_h);
-        live_view_widget_style_set(app->live_view, app->project, sd->style);
      }
    return groupedit_edit_object_recalc_all(sd->groupedit);
 }

-- 


Reply via email to