hermet pushed a commit to branch master. http://git.enlightenment.org/tools/enventor.git/commit/?id=c59be9cf1b55e45e492dd3c0ad91bc9821472451
commit c59be9cf1b55e45e492dd3c0ad91bc9821472451 Author: Hermet Park <[email protected]> Date: Thu Jul 7 16:21:03 2016 +0900 multi-file: ++implementation. 1. make it work with template insert feature. 2. dissmiss inactivated item's view sync callbacks. --- src/bin/live_edit.c | 36 +++++++-------- src/bin/tools.c | 4 +- src/lib/Enventor_Legacy.h | 3 ++ src/lib/edc_editor.c | 5 +- src/lib/enventor_object.eo | 30 ------------ src/lib/enventor_smart.c | 111 ++++++++++++++++++++++++--------------------- 6 files changed, 85 insertions(+), 104 deletions(-) diff --git a/src/bin/live_edit.c b/src/bin/live_edit.c index 59b6ea6..4a956ed 100644 --- a/src/bin/live_edit.c +++ b/src/bin/live_edit.c @@ -418,24 +418,24 @@ live_edit_insert(live_data *ld) Enventor_Item *it = file_mgr_focused_item_get(); - enventor_object_template_part_insert(base_enventor_get(), - type, - ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT, - elm_check_state_get(ld->fixed_w_check), - elm_check_state_get(ld->fixed_h_check), - ld->rel_to_info.rel1_x_part, - ld->rel_to_info.rel1_y_part, - ld->rel_to_info.rel2_x_part, - ld->rel_to_info.rel2_y_part, - ld->rel_to_info.align_x, - ld->rel_to_info.align_y, - ld->rel_to_info.min_w, - ld->rel_to_info.min_h, - ld->rel_to_info.rel1_x, - ld->rel_to_info.rel1_y, - ld->rel_to_info.rel2_x, - ld->rel_to_info.rel2_y, - NULL, 0); + enventor_item_template_part_insert(file_mgr_focused_item_get(), + type, + ENVENTOR_TEMPLATE_INSERT_LIVE_EDIT, + elm_check_state_get(ld->fixed_w_check), + elm_check_state_get(ld->fixed_h_check), + ld->rel_to_info.rel1_x_part, + ld->rel_to_info.rel1_y_part, + ld->rel_to_info.rel2_x_part, + ld->rel_to_info.rel2_y_part, + ld->rel_to_info.align_x, + ld->rel_to_info.align_y, + ld->rel_to_info.min_w, + ld->rel_to_info.min_h, + ld->rel_to_info.rel1_x, + ld->rel_to_info.rel1_y, + ld->rel_to_info.rel2_x, + ld->rel_to_info.rel2_y, + NULL, 0); enventor_item_file_save(it, NULL); free(ld->rel_to_info.rel1_x_part); diff --git a/src/bin/tools.c b/src/bin/tools.c index 3346914..f8ec8a3 100644 --- a/src/bin/tools.c +++ b/src/bin/tools.c @@ -628,8 +628,8 @@ tools_template_insert(void) Enventor_Item *it = file_mgr_focused_item_get(); char syntax[12]; - if (enventor_object_template_insert(base_enventor_get(), syntax, - sizeof(syntax))) + if (enventor_item_template_insert(file_mgr_focused_item_get(), syntax, + sizeof(syntax))) { char msg[64]; snprintf(msg, sizeof(msg), _("Template code inserted, (%s)"), syntax); diff --git a/src/lib/Enventor_Legacy.h b/src/lib/Enventor_Legacy.h index d467011..1860879 100644 --- a/src/lib/Enventor_Legacy.h +++ b/src/lib/Enventor_Legacy.h @@ -27,5 +27,8 @@ EAPI Eina_Bool enventor_item_file_save(Enventor_Item *it, const char *file); EAPI Eina_Bool enventor_item_modified_get(const Enventor_Item *it); EAPI void enventor_item_modified_set(Enventor_Item *it, Eina_Bool modified); EAPI Eina_Bool enventor_item_del(Enventor_Item *it); +Eina_Bool enventor_item_template_insert(Enventor_Item *it, char *syntax, size_t n); +Eina_Bool enventor_item_template_part_insert(Enventor_Item *it, Edje_Part_Type part, Enventor_Template_Insert_Type insert_type, Eina_Bool fixed_w, Eina_Bool fixed_h, char *rel1_x_to, char *rel1_y_to, char *rel2_x_to, char *rel2_y_to, float align_x, float align_y, int min_w, int min_h, float rel1_x, float rel1_y, float rel2_x,float rel2_y, char *syntax, size_t n); + #include "enventor_object.eo.legacy.h" diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c index efa5421..7c56343 100644 --- a/src/lib/edc_editor.c +++ b/src/lib/edc_editor.c @@ -1172,11 +1172,12 @@ edit_view_sync_cb_set(edit_data *ed, ed->view_sync_cb = cb; ed->view_sync_cb_data = data; + if (!cb) return; + Eina_Stringshare *group_name = parser_first_group_name_get(ed->pd, ed->en_edit); - if (ed->view_sync_cb) - ed->view_sync_cb(ed->view_sync_cb_data, NULL, 0.0, NULL, group_name); + cb(ed->view_sync_cb_data, NULL, 0.0, NULL, group_name); eina_stringshare_del(group_name); } diff --git a/src/lib/enventor_object.eo b/src/lib/enventor_object.eo index 94666da..b9e74c5 100644 --- a/src/lib/enventor_object.eo +++ b/src/lib/enventor_object.eo @@ -162,36 +162,6 @@ class Enventor.Object (Elm.Widget, Efl.File) { @in color_type: Enventor_Syntax_Color_Type; } } - template_insert { - return: bool; - params { - @in syntax: char *; - @in n: size; - } - } - template_part_insert { - return: bool; - params { - @in type: Edje_Part_Type; - @in insert_type: Enventor_Template_Insert_Type; - @in fixed_w: bool; - @in fixed_h: bool; - @in rel1_x_to: char *; - @in rel1_y_to: char *; - @in rel2_x_to: char *; - @in rel2_y_to: char *; - @in align_x: float; - @in align_y: float; - @in min_w: int; - @in min_h: int; - @in rel1_x: float; - @in rel1_y: float; - @in rel2_x: float; - @in rel2_y: float; - @in syntax: char *; - @in n: size; - } - } ctxpopup_visible_get { return: bool; } diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c index bff3b5a..9a84bc2 100644 --- a/src/lib/enventor_smart.c +++ b/src/lib/enventor_smart.c @@ -735,55 +735,6 @@ _enventor_object_live_view_get(Eo *obj EINA_UNUSED, return edj_mgr_obj_get(); } -EOLIAN static Eina_Bool -_enventor_object_template_insert(Eo *obj EINA_UNUSED, Enventor_Object_Data *pd, - char *syntax, size_t n) -{ - return template_insert(pd->main_it.ed, syntax, n); -} - -EOLIAN static Eina_Bool -_enventor_object_template_part_insert(Eo *obj EINA_UNUSED, - Enventor_Object_Data *pd, - Edje_Part_Type part, - Enventor_Template_Insert_Type insert_type, - Eina_Bool fixed_w, Eina_Bool fixed_h, - char *rel1_x_to, char *rel1_y_to, - char *rel2_x_to, char *rel2_y_to, - float align_x, float align_y, - int min_w, int min_h, - float rel1_x, float rel1_y, - float rel2_x,float rel2_y, - char *syntax, size_t n) -{ - // if mirror mode, exchange properties about left and right - if (pd->mirror_mode) - { - float x1, x2; - x1 = 1.0 - rel2_x; - x2 = 1.0 - rel1_x; - rel1_x = x1; - rel2_x = x2; - - if (align_x == 0.0) - align_x = 1.0; - else if (align_x == 1.0) - align_x = 0.0; - - char *buf; - buf = rel1_x_to; - rel1_x_to = rel2_x_to; - rel2_x_to = buf; - } - - return template_part_insert(pd->focused_it->ed, part, insert_type, - fixed_w, fixed_h, - rel1_x_to, rel1_y_to, - rel2_x_to, rel2_y_to, - align_x, align_y, min_w, min_h, - rel1_x, rel1_y, rel2_x, rel2_y, - NULL, syntax, n); -} //TODO: Might need for items EOLIAN static void @@ -882,7 +833,6 @@ enventor_object_main_item_set(Enventor_Object *obj, const char *file) pd->main_it.pd = pd; pd->main_it.ed = edit_init(obj, &pd->main_it); - edit_view_sync_cb_set(pd->main_it.ed, edit_view_sync_cb, &pd->main_it); pd->focused_it = &pd->main_it; Eina_Bool ret = efl_file_set(obj, file, NULL); @@ -920,9 +870,11 @@ enventor_item_focus_set(Enventor_Item *it) { EINA_SAFETY_ON_NULL_RETURN_VAL(it, EINA_FALSE); - Enventor_Object *obj = it->pd->obj; - Enventor_Object_Data *pd = eo_data_scope_get(obj, ENVENTOR_OBJECT_CLASS); + Enventor_Object_Data *pd = it->pd; + + if (pd->focused_it == it) return EINA_TRUE; + if (pd->focused_it) edit_view_sync_cb_set(pd->focused_it->ed, NULL, NULL); edit_view_sync_cb_set(it->ed, edit_view_sync_cb, it); pd->focused_it = it; @@ -1126,4 +1078,59 @@ enventor_item_del(Enventor_Item *it) } } +Eina_Bool +enventor_item_template_insert(Enventor_Item *it, char *syntax, size_t n) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(it, EINA_FALSE); + + return template_insert(it->ed, syntax, n); +} + +Eina_Bool +enventor_item_template_part_insert(Enventor_Item *it, + Edje_Part_Type part, + Enventor_Template_Insert_Type insert_type, + Eina_Bool fixed_w, Eina_Bool fixed_h, + char *rel1_x_to, char *rel1_y_to, + char *rel2_x_to, char *rel2_y_to, + float align_x, float align_y, + int min_w, int min_h, + float rel1_x, float rel1_y, + float rel2_x,float rel2_y, + char *syntax, size_t n) +{ + EINA_SAFETY_ON_NULL_RETURN_VAL(it, EINA_FALSE); + + Enventor_Object_Data *pd = it->pd; + + // if mirror mode, exchange properties about left and right + if (pd->mirror_mode) + { + float x1, x2; + x1 = 1.0 - rel2_x; + x2 = 1.0 - rel1_x; + rel1_x = x1; + rel2_x = x2; + + if (align_x == 0.0) + align_x = 1.0; + else if (align_x == 1.0) + align_x = 0.0; + + char *buf; + buf = rel1_x_to; + rel1_x_to = rel2_x_to; + rel2_x_to = buf; + } + + return template_part_insert(it->ed, part, insert_type, + fixed_w, fixed_h, + rel1_x_to, rel1_y_to, + rel2_x_to, rel2_y_to, + align_x, align_y, min_w, min_h, + rel1_x, rel1_y, rel2_x, rel2_y, + NULL, syntax, n); +} + + #include "enventor_object.eo.c" --
