hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=14a0e2cfd2f41dad50e823c9f309e088d662ceac

commit 14a0e2cfd2f41dad50e823c9f309e088d662ceac
Author: ChunEon Park <her...@hermet.pe.kr>
Date:   Mon Jun 22 22:45:40 2015 +0900

    tools: improved ui.
    
    add click / toggle on/off effect.
---
 data/themes/default/theme_ext.edc |  25 ++++++
 src/bin/base_gui.c                |  12 ++-
 src/bin/goto.c                    |   8 +-
 src/bin/live_edit.c               |   6 +-
 src/bin/main.c                    |  20 +++--
 src/bin/menu.c                    |   4 +
 src/bin/panes.c                   |  12 ++-
 src/bin/search.c                  |   6 ++
 src/bin/tools.c                   | 176 ++++++++++++++++++++++++++++++++++++--
 src/include/tools.h               |   8 +-
 10 files changed, 254 insertions(+), 23 deletions(-)

diff --git a/data/themes/default/theme_ext.edc 
b/data/themes/default/theme_ext.edc
index fb8807f..9aae13c 100644
--- a/data/themes/default/theme_ext.edc
+++ b/data/themes/default/theme_ext.edc
@@ -1253,7 +1253,20 @@ group { name: "elm/button/base/enventor";
          desc { "default";
          }
       }
+      rect { "icon_highlight";
+         desc { "default";
+         }
+         //This status is for tools selected effect
+         desc { "selected";
+            inherit: "default" 0.0;
+            color: 51 153 255 255;
+         }
+         desc { "clicked";
+            inherit: "selected" 0.0;
+         }
+      }
       rect { "icon_clip";
+         clip_to: "icon_highlight";
          desc { "default";
          }
          desc { "disabled";
@@ -1397,6 +1410,16 @@ group { name: "elm/button/base/enventor";
    }
    programs {
       program {
+         signal: "icon,highlight,enabled"; source: "";
+         action: STATE_SET "selected" "0.0";
+         target: "icon_highlight";
+      }
+      program {
+         signal: "icon,highlight,disabled"; source: "";
+         action: STATE_SET "default" "0.0";
+         target: "icon_highlight";
+      }
+      program {
          signal: "mouse,down,1"; source: "event";
          action: SIGNAL_EMIT "elm,action,press" "elm";
          after: "button_click_anim";
@@ -1405,6 +1428,7 @@ group { name: "elm/button/base/enventor";
          action: STATE_SET "clicked" 0.0;
          target: "base";
          target: "text2";
+         target: "icon_highlight";
       }
       program {
          signal: "mouse,up,1"; source: "event";
@@ -1415,6 +1439,7 @@ group { name: "elm/button/base/enventor";
          action: STATE_SET "default" 0.0;
          target: "base";
          target: "text2";
+         target: "icon_highlight";
       }
       program {
          signal: "elm,anim,activate"; source: "elm";
diff --git a/src/bin/base_gui.c b/src/bin/base_gui.c
index 1484e71..4d1806e 100644
--- a/src/bin/base_gui.c
+++ b/src/bin/base_gui.c
@@ -148,6 +148,7 @@ void
 base_console_full_view(void)
 {
    panes_console_full_view();
+   tools_console_update(EINA_TRUE);
 }
 
 void
@@ -165,15 +166,22 @@ base_console_auto_hide(void)
    if (!config_console_get()) return;
    if (bd->console_msg) return;
    panes_editors_full_view(EINA_TRUE);
+   tools_console_update(EINA_FALSE);
 }
 
 void
 base_console_toggle(void)
 {
    if (panes_editors_full_view_get())
-     panes_editors_full_view(EINA_FALSE);
+     {
+        tools_console_update(EINA_TRUE);
+        panes_editors_full_view(EINA_FALSE);
+     }
    else
-     panes_editors_full_view(EINA_TRUE);
+     {
+        tools_console_update(EINA_FALSE);
+        panes_editors_full_view(EINA_TRUE);
+     }
 }
 
 void
diff --git a/src/bin/goto.c b/src/bin/goto.c
index e5e6d69..1c624e7 100644
--- a/src/bin/goto.c
+++ b/src/bin/goto.c
@@ -162,6 +162,8 @@ goto_open(Evas_Object *enventor)
                                btn);
    evas_object_show(win);
 
+   tools_goto_update(enventor, EINA_FALSE);
+
    gd->win = win;
    gd->layout = layout;
    gd->entry = entry;
@@ -180,12 +182,16 @@ void
 goto_close(void)
 {
    goto_data *gd = g_gd;
-
    if (!gd) return;
+
+   Evas_Object *enventor = gd->enventor;
+
    //Save last state
    evas_object_geometry_get(gd->win, NULL, NULL, &win_w, &win_h);
    elm_win_screen_position_get(gd->win, &win_x, &win_y);
    evas_object_del(gd->win);
    free(gd);
    g_gd = NULL;
+
+   tools_goto_update(enventor, EINA_FALSE);
 }
diff --git a/src/bin/live_edit.c b/src/bin/live_edit.c
index 3c6df67..60aa284 100644
--- a/src/bin/live_edit.c
+++ b/src/bin/live_edit.c
@@ -912,6 +912,7 @@ live_edit_toggle(void)
 {
    live_data *ld = g_ld;
    Eina_Bool on = !ld->on;
+   ld->on = on;
 
    if (on)
      {
@@ -919,11 +920,10 @@ live_edit_toggle(void)
         ld->live_view = enventor_object_live_view_get(ld->enventor);
         ld->ctxpopup = ctxpopup_create(ld);
         stats_info_msg_update("Select a part to add in Live View.");
+        tools_live_update(ld->enventor, EINA_FALSE);
      }
    else
      live_edit_cancel();
-
-   ld->on = on;
 }
 
 Eina_Bool
@@ -978,6 +978,8 @@ live_edit_cancel(void)
      }
 
    ld->on = EINA_FALSE;
+
+   tools_live_update(ld->enventor, EINA_FALSE);
 }
 
 void
diff --git a/src/bin/main.c b/src/bin/main.c
index 9539fe4..7b8ba1e 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -35,6 +35,15 @@ auto_indent_toggle(app_data *ad)
 }
 
 static void
+enventor_tools_update(Evas_Object *enventor)
+{
+   tools_lines_update(enventor, EINA_FALSE);
+   tools_highlight_update(enventor, EINA_FALSE);
+   tools_swallow_update(enventor, EINA_FALSE);
+   tools_status_update(enventor, EINA_FALSE);
+}
+
+static void
 enventor_common_setup(Evas_Object *enventor)
 {
    const char *font_name;
@@ -43,13 +52,8 @@ enventor_common_setup(Evas_Object *enventor)
    enventor_object_font_set(enventor, font_name, font_style);
    enventor_object_font_scale_set(enventor, config_font_scale_get());
    enventor_object_live_view_scale_set(enventor, config_view_scale_get());
-   tools_lines_update(enventor, EINA_FALSE);
-   enventor_object_part_highlight_set(enventor, config_part_highlight_get());
-   tools_highlight_update(enventor, EINA_FALSE);
    enventor_object_auto_indent_set(enventor, config_auto_indent_get());
    enventor_object_auto_complete_set(enventor, config_auto_complete_get());
-   tools_swallow_update(enventor, EINA_FALSE);
-   tools_status_update(NULL, EINA_FALSE);
 
    Eina_List *list = eina_list_append(NULL, config_edj_path_get());
    enventor_object_path_set(enventor, ENVENTOR_OUT_EDJ, list);
@@ -121,6 +125,7 @@ config_update_cb(void *data)
    Evas_Object *enventor = ad->enventor;
 
    enventor_common_setup(enventor);
+   enventor_tools_update(enventor);
 
    syntax_color_update(enventor);
 
@@ -205,8 +210,10 @@ main_mouse_wheel_cb(void *data, int type EINA_UNUSED, void 
*ev)
 static Evas_Object *
 tools_set(Evas_Object *enventor)
 {
-   Evas_Object *tools = tools_create(base_layout_get(), enventor);
+   Evas_Object *tools = tools_init(base_layout_get(), enventor);
    base_tools_set(tools);
+   enventor_tools_update(enventor);
+
    return tools;
 }
 
@@ -850,6 +857,7 @@ term(app_data *ad EINA_UNUSED)
    menu_term();
    live_edit_term();
    stats_term();
+   tools_term();
    base_gui_term();
    file_mgr_term();
    config_term();
diff --git a/src/bin/menu.c b/src/bin/menu.c
index 6fe0365..ce8a7b2 100644
--- a/src/bin/menu.c
+++ b/src/bin/menu.c
@@ -62,6 +62,8 @@ menu_close(menu_data *md)
 {
    if (!md->menu_layout) return;
    elm_object_signal_emit(md->menu_layout, "elm,state,dismiss", "");
+
+   tools_menu_update(EINA_FALSE);
 }
 
 static void
@@ -673,6 +675,8 @@ menu_open(menu_data *md)
    elm_object_text_set(btn, "Back");
    elm_object_part_content_set(layout, "elm.swallow.prev_btn", btn);
 
+   tools_menu_update(EINA_TRUE);
+
    md->menu_layout = layout;
    md->active_request++;
 }
diff --git a/src/bin/panes.c b/src/bin/panes.c
index fac705e..138de8f 100644
--- a/src/bin/panes.c
+++ b/src/bin/panes.c
@@ -62,8 +62,16 @@ v_unpress_cb(void *data, Evas_Object *obj, void *event_info 
EINA_UNUSED)
     config_console_size_set(size);
 
    double origin = elm_panes_content_right_size_get(pd->vert.obj);
-   if (origin == 0.0) pd->vert.state = PANES_EDITORS_EXPAND;
-   else pd->vert.state = PANES_SPLIT_VIEW;
+   if (origin == 0.0)
+     {
+        pd->vert.state = PANES_EDITORS_EXPAND;
+        tools_console_update(EINA_FALSE);
+     }
+   else
+     {
+        pd->vert.state = PANES_SPLIT_VIEW;
+        tools_console_update(EINA_TRUE);
+     }
 }
 
 static void
diff --git a/src/bin/search.c b/src/bin/search.c
index 2f0d691..cb9e4b4 100644
--- a/src/bin/search.c
+++ b/src/bin/search.c
@@ -405,6 +405,8 @@ search_open(Evas_Object *enventor)
                                btn_replace_all);
    evas_object_show(win);
 
+   tools_search_update(enventor, EINA_FALSE);
+
    sd->win = win;
    sd->enventor = enventor;
    sd->layout = layout;
@@ -427,6 +429,8 @@ search_close(void)
    search_data *sd = g_sd;
    if (!sd) return;
 
+   Evas_Object *enventor = sd->enventor;
+
    enventor_object_select_none(sd->enventor);
    while (sd->syntax_color > 0)
      {
@@ -440,4 +444,6 @@ search_close(void)
    evas_object_del(sd->win);
    free(sd);
    g_sd = NULL;
+
+   tools_search_update(enventor, EINA_FALSE);
 }
diff --git a/src/bin/tools.c b/src/bin/tools.c
index b2c8ca2..dc6856f 100644
--- a/src/bin/tools.c
+++ b/src/bin/tools.c
@@ -4,13 +4,30 @@
 
 #include "common.h"
 
+typedef struct tools_s
+{
+   Evas_Object *swallow_btn;
+   Evas_Object *status_btn;
+   Evas_Object *lines_btn;
+   Evas_Object *highlight_btn;
+   Evas_Object *goto_btn;
+   Evas_Object *find_btn;
+   Evas_Object *live_btn;
+   Evas_Object *console_btn;
+   Evas_Object *menu_btn;
+   Evas_Object *box;
+} tools_data;
+
+static tools_data *g_td = NULL;
+
 static void
-menu_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
-        void *event_info EINA_UNUSED)
+menu_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
 {
+   Evas_Object *enventor = data;
+
    if (live_edit_get()) live_edit_cancel();
    if (search_is_opened()) search_close();
-   if (goto_is_opened()) goto_close();
+   if (goto_is_opened()) tools_goto_update(enventor, EINA_TRUE);
 
    menu_toggle();
 }
@@ -69,6 +86,9 @@ static void
 console_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
            void *event_info EINA_UNUSED)
 {
+   tools_data *td = g_td;
+   if (!td) return;
+
    base_console_toggle();
 }
 
@@ -130,9 +150,28 @@ tools_btn_create(Evas_Object *parent, const char *icon,
    return btn;
 }
 
+void
+tools_term(void)
+{
+   tools_data *td = g_td;
+   assert(td);
+   free(td);
+}
+
 Evas_Object *
-tools_create(Evas_Object *parent, Evas_Object *enventor)
+tools_init(Evas_Object *parent, Evas_Object *enventor)
 {
+   tools_data *td = g_td;
+   if (td) return (td->box);
+
+   td = calloc(1, sizeof(tools_data));
+   if (!td)
+     {
+        EINA_LOG_ERR("Failed to allocate Memory!");
+        return NULL;
+     }
+   g_td = td;
+
    Evas_Object *box = elm_box_add(parent);
    elm_box_horizontal_set(box, EINA_TRUE);
    elm_box_padding_set(box, 10, 0);
@@ -147,6 +186,7 @@ tools_create(Evas_Object *parent, Evas_Object *enventor)
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
+   td->menu_btn = btn;
 
    Evas_Object *sp;
    sp = elm_separator_add(box);
@@ -176,18 +216,21 @@ tools_create(Evas_Object *parent, Evas_Object *enventor)
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
+   td->find_btn = btn;
 
    btn = tools_btn_create(box, "goto", "Goto Lines (Ctrl + L)",
                           goto_cb, enventor);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
+   td->goto_btn = btn;
 
    btn = tools_btn_create(box, "lines", "Line Numbers (F5)",
                           lines_cb, enventor);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
+   td->lines_btn = btn;
 
    sp = elm_separator_add(box);
    evas_object_show(sp);
@@ -198,19 +241,22 @@ tools_create(Evas_Object *parent, Evas_Object *enventor)
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
+   td->highlight_btn = btn;
 
    btn = tools_btn_create(box, "swallow_s", "Dummy Swallow (Ctrl + W)",
                           swallow_cb, enventor);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
+   td->swallow_btn = btn;
 
    btn = tools_btn_create(box, "live_edit", "Live View Edit (Ctrl + E)",
-                          live_edit_cb, NULL);
+                          live_edit_cb, enventor);
    evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 0.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
    evas_object_data_set(box, "live_edit", btn);
+   td->live_btn = btn;
 
    sp = elm_separator_add(box);
    evas_object_show(sp);
@@ -222,15 +268,23 @@ tools_create(Evas_Object *parent, Evas_Object *enventor)
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 1.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
+   td->console_btn = btn;
 
    btn = tools_btn_create(box, "status", "Status (F11)", status_cb, NULL);
    elm_object_tooltip_orient_set(btn, ELM_TOOLTIP_ORIENT_BOTTOM_LEFT);
    evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
    evas_object_size_hint_align_set(btn, 1.0, EVAS_HINT_FILL);
    elm_box_pack_end(box, btn);
+   td->status_btn = btn;
 
    evas_object_show(box);
 
+   td->box = box;
+
+   //Turn on if console is valid size.
+   if (!config_console_get() && (config_console_size_get() > 0))
+     tools_console_update(EINA_TRUE);
+
    return box;
 }
 
@@ -243,36 +297,140 @@ tools_live_edit_get(Evas_Object *tools)
 void
 tools_highlight_update(Evas_Object *enventor, Eina_Bool toggle)
 {
+   tools_data *td = g_td;
+   if (!td) return;
+
    if (toggle) config_part_highlight_set(!config_part_highlight_get());
    enventor_object_part_highlight_set(enventor,
                                       config_part_highlight_get());
+   if (toggle)
+     {
+        if (config_part_highlight_get())
+          stats_info_msg_update("Part Highlighting Enabled.");
+        else
+          stats_info_msg_update("Part Highlighting Disabled.");
+     }
+
+   //Toggle on/off
    if (config_part_highlight_get())
-     stats_info_msg_update("Part Highlighting Enabled.");
+     elm_object_signal_emit(td->highlight_btn, "icon,highlight,enabled", "");
    else
-     stats_info_msg_update("Part Highlighting Disabled.");
+     elm_object_signal_emit(td->highlight_btn, "icon,highlight,disabled", "");
 }
 
 void
 tools_lines_update(Evas_Object *enventor, Eina_Bool toggle)
 {
+   tools_data *td = g_td;
+   if (!td) return;
+
    if (toggle) config_linenumber_set(!config_linenumber_get());
    enventor_object_linenumber_set(enventor, config_linenumber_get());
+
+   //Toggle on/off
+   if (config_linenumber_get())
+     elm_object_signal_emit(td->lines_btn, "icon,highlight,enabled", "");
+   else
+     elm_object_signal_emit(td->lines_btn, "icon,highlight,disabled", "");
 }
 
 void
 tools_swallow_update(Evas_Object *enventor, Eina_Bool toggle)
 {
+   tools_data *td = g_td;
+   if (!td) return;
+
    if (toggle) config_dummy_swallow_set(!config_dummy_swallow_get());
    enventor_object_dummy_swallow_set(enventor, config_dummy_swallow_get());
 
+   if (toggle)
+     {
+        if (config_dummy_swallow_get())
+          stats_info_msg_update("Dummy Swallow Enabled.");
+        else
+          stats_info_msg_update("Dummy Swallow Disabled.");
+     }
+   //Toggle on/off
    if (config_dummy_swallow_get())
-     stats_info_msg_update("Dummy Swallow Enabled.");
+     elm_object_signal_emit(td->swallow_btn, "icon,highlight,enabled", "");
    else
-     stats_info_msg_update("Dummy Swallow Disabled.");
+     elm_object_signal_emit(td->swallow_btn, "icon,highlight,disabled", "");
 }
 
 void
 tools_status_update(Evas_Object *enventor EINA_UNUSED, Eina_Bool toggle)
 {
+   tools_data *td = g_td;
+   if (!td) return;
+
    base_statusbar_toggle(toggle);
+
+   //Toggle on/off
+   if (config_stats_bar_get())
+     elm_object_signal_emit(td->status_btn, "icon,highlight,enabled", "");
+   else
+     elm_object_signal_emit(td->status_btn, "icon,highlight,disabled", "");
+}
+
+void
+tools_goto_update(Evas_Object *enventor EINA_UNUSED,
+                  Eina_Bool toggle EINA_UNUSED)
+{
+   tools_data *td = g_td;
+   if (!td) return;
+
+   if (goto_is_opened())
+     elm_object_signal_emit(td->goto_btn, "icon,highlight,enabled", "");
+   else
+     elm_object_signal_emit(td->goto_btn, "icon,highlight,disabled", "");
+}
+
+void
+tools_search_update(Evas_Object *enventor EINA_UNUSED,
+                    Eina_Bool toggle EINA_UNUSED)
+{
+   tools_data *td = g_td;
+   if (!td) return;
+
+   if (search_is_opened())
+     elm_object_signal_emit(td->find_btn, "icon,highlight,enabled", "");
+   else
+     elm_object_signal_emit(td->find_btn, "icon,highlight,disabled", "");
+}
+
+void
+tools_live_update(Evas_Object *enventor EINA_UNUSED,
+                  Eina_Bool toggle EINA_UNUSED)
+{
+   tools_data *td = g_td;
+   if (!td) return;
+
+   if (live_edit_get())
+     elm_object_signal_emit(td->live_btn, "icon,highlight,enabled", "");
+   else
+     elm_object_signal_emit(td->live_btn, "icon,highlight,disabled", "");
+}
+
+void
+tools_console_update(Eina_Bool on)
+{
+   tools_data *td = g_td;
+   if (!td) return;
+
+   if (on)
+     elm_object_signal_emit(td->console_btn, "icon,highlight,enabled", "");
+   else
+     elm_object_signal_emit(td->console_btn, "icon,highlight,disabled", "");
+}
+
+void
+tools_menu_update(Eina_Bool on)
+{
+   tools_data *td = g_td;
+   if (!td) return;
+
+   if (on)
+     elm_object_signal_emit(td->menu_btn, "icon,highlight,enabled", "");
+   else
+     elm_object_signal_emit(td->menu_btn, "icon,highlight,disabled", "");
 }
diff --git a/src/include/tools.h b/src/include/tools.h
index 16a490e..0b4e4f6 100644
--- a/src/include/tools.h
+++ b/src/include/tools.h
@@ -1,6 +1,12 @@
-Evas_Object *tools_create(Evas_Object *parent, Evas_Object *enventor);
+Evas_Object *tools_init(Evas_Object *parent, Evas_Object *enventor);
+void tools_term(void);
 Evas_Object *tools_live_edit_get(Evas_Object *tools);
 void tools_highlight_update(Evas_Object *enventor, Eina_Bool toggle);
 void tools_lines_update(Evas_Object *enventor, Eina_Bool toggle);
 void tools_swallow_update(Evas_Object *enventor, Eina_Bool toggle);
 void tools_status_update(Evas_Object *enventor, Eina_Bool toggle);
+void tools_goto_update(Evas_Object *enventor, Eina_Bool toggle);
+void tools_search_update(Evas_Object *enventor, Eina_Bool toggle);
+void tools_live_update(Evas_Object *enventor, Eina_Bool toggle);
+void tools_console_update(Eina_Bool on);
+void tools_menu_update(Eina_Bool on);

-- 


Reply via email to