hermet pushed a commit to branch master.

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

commit bb09392d12f0a7f16014e4d202827757de01b674
Author: Hermet Park <her...@hermet.pe.kr>
Date:   Sat Feb 27 17:31:12 2016 +0900

    edc_navigator: 3rd patch for base navigation behavior.
---
 data/themes/default/images.edc                |  18 ++++
 data/themes/default/images/Makefile.am        |  10 +-
 data/themes/default/images/navi_group.png     | Bin 0 -> 514 bytes
 data/themes/default/images/navi_image.png     | Bin 0 -> 268 bytes
 data/themes/default/images/navi_rect.png      | Bin 0 -> 207 bytes
 data/themes/default/images/navi_spacer.png    | Bin 0 -> 324 bytes
 data/themes/default/images/navi_state.png     | Bin 0 -> 205 bytes
 data/themes/default/images/navi_swallow.png   | Bin 0 -> 677 bytes
 data/themes/default/images/navi_text.png      | Bin 0 -> 412 bytes
 data/themes/default/images/navi_textblock.png | Bin 0 -> 475 bytes
 data/themes/default/images/navi_unknown.png   | Bin 0 -> 375 bytes
 src/bin/base_gui.c                            |  33 +++++--
 src/bin/edc_navigator.c                       | 137 +++++++++++++++++++++-----
 src/bin/main.c                                |   9 +-
 src/include/base_gui.h                        |   4 +-
 src/include/edc_navigator.h                   |   4 +-
 src/lib/edj_viewer.c                          |   6 ++
 src/lib/enventor_object.eo                    |   6 ++
 src/lib/enventor_private.h                    |   2 +-
 src/lib/enventor_smart.c                      |   8 ++
 20 files changed, 194 insertions(+), 43 deletions(-)

diff --git a/data/themes/default/images.edc b/data/themes/default/images.edc
index e3d0f47..53f2b7d 100644
--- a/data/themes/default/images.edc
+++ b/data/themes/default/images.edc
@@ -22,6 +22,15 @@ images {
    image: "expand.png" COMP;
    image: "invert.png" COMP;
    image: "edc_navigator.png" COMP;
+   image: "navi_group.png" COMP;
+   image: "navi_rect.png" COMP;
+   image: "navi_image.png" COMP;
+   image: "navi_swallow.png" COMP;
+   image: "navi_text.png" COMP;
+   image: "navi_textblock.png" COMP;
+   image: "navi_spacer.png" COMP;
+   image: "navi_state.png" COMP;
+   image: "navi_unknown.png" COMP;
 }
 
 #define ICON_GROUP(_group_name, _image_path) \
@@ -57,5 +66,14 @@ ICON_GROUP("Text", "live_text.png")
 ICON_GROUP("Textblock", "live_textblock.png")
 ICON_GROUP("close", "icon_close.png")
 ICON_GROUP("edc_navigator", "edc_navigator.png")
+ICON_GROUP("navi_group", "navi_group.png")
+ICON_GROUP("navi_image", "navi_image.png")
+ICON_GROUP("navi_rect", "navi_rect.png")
+ICON_GROUP("navi_swallow", "navi_swallow.png")
+ICON_GROUP("navi_text", "navi_text.png")
+ICON_GROUP("navi_textblock", "navi_textblock.png")
+ICON_GROUP("navi_spacer", "navi_spacer.png")
+ICON_GROUP("navi_state", "navi_state.png")
+ICON_GROUP("navi_unknown", "navi_unknown.png")
 
 #undef ICON_GROUP
diff --git a/data/themes/default/images/Makefile.am 
b/data/themes/default/images/Makefile.am
index ae6658e..a35e749 100644
--- a/data/themes/default/images/Makefile.am
+++ b/data/themes/default/images/Makefile.am
@@ -71,4 +71,12 @@ EXTRA_DIST = \
        invert.png \
        icon_close.png \
    edc_navigator.png \
-       cursor_arrow.png
+       cursor_arrow.png \
+       navi_group.png \
+       navi_image.png \
+       navi_rect.png \
+       navi_swallow.png \
+       navi_text.png \
+       navi_textblock.png \
+       navi_spacer.png \
+       navi_unknown.png
diff --git a/data/themes/default/images/navi_group.png 
b/data/themes/default/images/navi_group.png
new file mode 100644
index 0000000..7f6dcfc
Binary files /dev/null and b/data/themes/default/images/navi_group.png differ
diff --git a/data/themes/default/images/navi_image.png 
b/data/themes/default/images/navi_image.png
new file mode 100644
index 0000000..d3b4d88
Binary files /dev/null and b/data/themes/default/images/navi_image.png differ
diff --git a/data/themes/default/images/navi_rect.png 
b/data/themes/default/images/navi_rect.png
new file mode 100644
index 0000000..e33305b
Binary files /dev/null and b/data/themes/default/images/navi_rect.png differ
diff --git a/data/themes/default/images/navi_spacer.png 
b/data/themes/default/images/navi_spacer.png
new file mode 100644
index 0000000..17ab0bb
Binary files /dev/null and b/data/themes/default/images/navi_spacer.png differ
diff --git a/data/themes/default/images/navi_state.png 
b/data/themes/default/images/navi_state.png
new file mode 100644
index 0000000..1a4d229
Binary files /dev/null and b/data/themes/default/images/navi_state.png differ
diff --git a/data/themes/default/images/navi_swallow.png 
b/data/themes/default/images/navi_swallow.png
new file mode 100644
index 0000000..27f02b0
Binary files /dev/null and b/data/themes/default/images/navi_swallow.png differ
diff --git a/data/themes/default/images/navi_text.png 
b/data/themes/default/images/navi_text.png
new file mode 100644
index 0000000..0c46a98
Binary files /dev/null and b/data/themes/default/images/navi_text.png differ
diff --git a/data/themes/default/images/navi_textblock.png 
b/data/themes/default/images/navi_textblock.png
new file mode 100644
index 0000000..d4f3f57
Binary files /dev/null and b/data/themes/default/images/navi_textblock.png 
differ
diff --git a/data/themes/default/images/navi_unknown.png 
b/data/themes/default/images/navi_unknown.png
new file mode 100644
index 0000000..3ec3a23
Binary files /dev/null and b/data/themes/default/images/navi_unknown.png differ
diff --git a/src/bin/base_gui.c b/src/bin/base_gui.c
index 05b9e4c..a76a89c 100644
--- a/src/bin/base_gui.c
+++ b/src/bin/base_gui.c
@@ -6,6 +6,7 @@ typedef struct base_s
    Evas_Object *layout;
    Evas_Object *console;
    Evas_Object *enventor;
+   Ecore_Timer *edc_navigator_timer;
    Eina_Bool console_msg : 1;
 } base_data;
 
@@ -31,6 +32,19 @@ win_resize_cb(void *data EINA_UNUSED, Evas *o EINA_UNUSED, 
Evas_Object *obj,
    config_win_size_set(w, h);
 }
 
+static Eina_Bool
+edc_navigator_update_timer_cb(void *data)
+{
+   base_data *bd = g_bd;
+
+   const char *group_name = data;
+   edc_navigator_group_update(group_name);
+
+   bd->edc_navigator_timer = NULL;
+
+   return ECORE_CALLBACK_CANCEL;
+}
+
 /*****************************************************************************/
 /* Externally accessible calls                                               */
 /*****************************************************************************/
@@ -195,31 +209,38 @@ void
 base_gui_term(void)
 {
    base_data *bd = g_bd;
-   assert(bd);
+   if (!bd) return;
 
+   ecore_timer_del(bd->edc_navigator_timer);
    edc_navigator_term();
    panes_term();
 
    free(bd);
+   g_bd = NULL;
 }
 
 void
-base_edc_navigator_parts_reload(void)
+base_edc_navigator_group_update(const char *group_name)
 {
-   edc_navigator_parts_reload();
+   base_data *bd = g_bd;
+   if (!bd) return;
+
+   ecore_timer_del(bd->edc_navigator_timer);
+   bd->edc_navigator_timer = ecore_timer_add(1, edc_navigator_update_timer_cb,
+                                             group_name);
 }
 
 void
-base_edc_navigator_group_reload(void)
+base_edc_navigator_reload(void)
 {
-   edc_navigator_group_reload();
+   edc_navigator_reload();
 }
 
 void
 base_console_reset(void)
 {
    base_data *bd = g_bd;
-   assert(bd);
+   if (!bd) return;
 
    console_text_set(bd->console, "");
    bd->console_msg = EINA_FALSE;
diff --git a/src/bin/edc_navigator.c b/src/bin/edc_navigator.c
index c269e57..709b3b5 100644
--- a/src/bin/edc_navigator.c
+++ b/src/bin/edc_navigator.c
@@ -17,6 +17,12 @@ typedef struct edc_navigator_s
    Elm_Genlist_Item_Class *state_itc;
 } navi_data;
 
+typedef struct part_item_data_s
+{
+   const char *text;
+   Edje_Part_Type type;
+} part_item_data;
+
 static navi_data *g_nd = NULL;
 
 /*****************************************************************************/
@@ -70,24 +76,69 @@ gl_text_get_cb(void *data, Evas_Object *obj EINA_UNUSED,
 }
 
 static Evas_Object *
-gl_content_get_cb(void *data, Evas_Object *obj EINA_UNUSED,
-                  const char *part EINA_UNUSED)
+gl_state_content_get_cb(void *data, Evas_Object *obj, const char *part)
 {
-   return NULL;
+   if (strcmp("elm.swallow.icon", part)) return NULL;
+
+   //TODO: Add Icon
+   Evas_Object *image = elm_image_add(obj);
+   elm_image_file_set(image, EDJE_PATH, "navi_state");
+   return image;
 }
 
 static void
-gl_del_cb(void *data, Evas_Object *obj EINA_UNUSED)
+gl_part_del_cb(void *data, Evas_Object *obj EINA_UNUSED)
 {
+   part_item_data *item_data = data;
+   free(item_data);
+}
 
+static char *
+gl_part_text_get_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                    const char *part EINA_UNUSED)
+{
+   part_item_data *item_data = data;
+   return strdup(item_data->text);
 }
 
-static void
-gl_group_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void 
*event_info)
+static Evas_Object *
+gl_part_content_get_cb(void *data, Evas_Object *obj, const char *part)
 {
-   Elm_Object_Item *it = event_info;
+   if (strcmp("elm.swallow.icon", part)) return NULL;
+   part_item_data *item_data = data;
 
-   //TODO: Search Current Group
+   //TODO: Add Icon
+   Evas_Object *image = elm_image_add(obj);
+   const char *group;
+
+   switch (item_data->type)
+     {
+      case EDJE_PART_TYPE_RECTANGLE:
+         group = "navi_rect";
+         break;
+      case EDJE_PART_TYPE_TEXT:
+         group = "navi_text";
+         break;
+      case EDJE_PART_TYPE_IMAGE:
+         group = "navi_image";
+         break;
+      case EDJE_PART_TYPE_SWALLOW:
+         group = "navi_swallow";
+         break;
+      case EDJE_PART_TYPE_TEXTBLOCK:
+         group = "navi_textblock";
+         break;
+      case EDJE_PART_TYPE_SPACER:
+         group = "navi_spacer";
+         break;
+      default:
+         group = "navi_unknown";
+         break;
+     }
+
+   elm_image_file_set(image, EDJE_PATH, group);
+
+   return image;
 }
 
 static void
@@ -101,18 +152,44 @@ gl_part_selected_cb(void *data, Evas_Object *obj 
EINA_UNUSED, void *event_info)
    states_reload(nd, it);
 }
 
+static Evas_Object *
+gl_group_content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+   if (strcmp("elm.swallow.icon", part)) return NULL;
+
+   //TODO: Add Icon
+   Evas_Object *image = elm_image_add(obj);
+   elm_image_file_set(image, EDJE_PATH, "navi_group");
+   return image;
+}
+
+static void
+gl_group_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void 
*event_info)
+{
+   Elm_Object_Item *it = event_info;
+
+   //TODO: Search Current Group
+}
+
 /*****************************************************************************/
 /* Externally accessible calls                                               */
 /*****************************************************************************/
 
 void
-edc_navigator_parts_reload(void)
+edc_navigator_group_update(const char *cur_group)
 {
-   if (!config_edc_navigator_get()) return;
-
    navi_data *nd = g_nd;
    if (!nd) return;
 
+   if (!config_edc_navigator_get()) return;
+
+   if (!cur_group)
+     {
+        Elm_Object_Item *it = elm_genlist_selected_item_get(nd->genlist);
+        elm_genlist_item_selected_set(it, EINA_FALSE);
+        return;
+     }
+
    Eina_List *l;
    Elm_Object_Item *it;
 
@@ -121,20 +198,18 @@ edc_navigator_parts_reload(void)
       elm_object_item_del(it);
 
    //Find a current group item
-   const char *cur_group = stats_group_name_get();
-   if (!cur_group) return;
-
    Elm_Object_Item *group_item = NULL;
 
    EINA_LIST_FOREACH(nd->group_items, l, it)
      {
         group_item = it;
-        const char *group_name = elm_object_item_text_get(it);
+        const char *group_name = elm_object_item_data_get(it);
         if (!group_name) continue;
 
         if (!strcmp(group_name, cur_group) &&
             strlen(group_name) == strlen(cur_group))
           {
+             elm_genlist_item_selected_set(it, EINA_TRUE);
              group_item = it;
              break;
           }
@@ -147,22 +222,31 @@ edc_navigator_parts_reload(void)
    edje_edit_string_list_free(nd->part_list);
    nd->part_list = enventor_object_parts_list_get(enventor);
    char *name;
+   part_item_data *data;
+   Edje_Part_Type part_type;
 
    EINA_LIST_FOREACH(nd->part_list, l, name)
      {
+        part_type = enventor_object_part_type_get(enventor, name);
+        data = malloc(sizeof(part_item_data));
+        data->text = name;
+        data->type = part_type;
+
         it = elm_genlist_item_append(nd->genlist,
                                      nd->part_itc,          /* item class */
-                                     name,                  /* item data */
+                                     data,
                                      group_item,            /* parent */
                                      ELM_GENLIST_ITEM_NONE, /* item type */
                                      gl_part_selected_cb,   /* select cb */
                                      nd);                   /* select cb data 
*/
         nd->part_items = eina_list_append(nd->part_items, it);
      }
+
+   //Append Programs
 }
 
 void
-edc_navigator_group_reload(void)
+edc_navigator_reload(void)
 {
    if (!config_edc_navigator_get()) return;
 
@@ -181,7 +265,7 @@ edc_navigator_group_reload(void)
    const char *cur_group = stats_group_name_get();
 
    //Update Group
-   EINA_LIST_REVERSE_FOREACH(nd->group_list, l, name)
+   EINA_LIST_FOREACH(nd->group_list, l, name)
      {
         it = elm_genlist_item_append(nd->genlist,
                                      nd->group_itc,         /* item class */
@@ -189,14 +273,14 @@ edc_navigator_group_reload(void)
                                      NULL,                  /* parent */
                                      ELM_GENLIST_ITEM_NONE, /* item type */
                                      gl_group_selected_cb,  /* select cb */
-                                     nd);                   /* select cb data 
*/
+                                     name);                 /* select cb data 
*/
 
         nd->group_items = eina_list_append(nd->group_items, it);
 
         //Update Parts only if current group
         if (cur_group && !strcmp(name, cur_group) &&
             (strlen(name) == strlen(cur_group)))
-           edc_navigator_parts_reload();
+          edc_navigator_group_update(cur_group);
      }
 }
 
@@ -212,6 +296,7 @@ edc_navigator_init(Evas_Object *parent)
    g_nd = nd;
 
    Evas_Object *genlist = elm_genlist_add(parent);
+   elm_object_focus_allow_set(genlist, EINA_FALSE);
 
    //Group Item Class
    Elm_Genlist_Item_Class *itc;
@@ -219,17 +304,16 @@ edc_navigator_init(Evas_Object *parent)
    itc = elm_genlist_item_class_new();
    itc->item_style = "default";
    itc->func.text_get = gl_text_get_cb;
-   itc->func.content_get = gl_content_get_cb;
-   itc->func.del = gl_del_cb;
+   itc->func.content_get = gl_group_content_get_cb;
 
    nd->group_itc = itc;
 
    //Part Item Class
    itc = elm_genlist_item_class_new();
    itc->item_style = "default";
-   itc->func.text_get = gl_text_get_cb;
-   itc->func.content_get = gl_content_get_cb;
-   itc->func.del = gl_del_cb;
+   itc->func.text_get = gl_part_text_get_cb;
+   itc->func.content_get = gl_part_content_get_cb;
+   itc->func.del = gl_part_del_cb;
 
    nd->part_itc = itc;
 
@@ -237,8 +321,7 @@ edc_navigator_init(Evas_Object *parent)
    itc = elm_genlist_item_class_new();
    itc->item_style = "default";
    itc->func.text_get = gl_text_get_cb;
-   itc->func.content_get = gl_content_get_cb;
-   itc->func.del = gl_del_cb;
+   itc->func.content_get = gl_state_content_get_cb;
 
    nd->state_itc = itc;
 
diff --git a/src/bin/main.c b/src/bin/main.c
index 9ffed8f..2b5c558 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -402,7 +402,7 @@ enventor_cursor_group_changed_cb(void *data EINA_UNUSED,
 {
    const char *group_name = event_info;
    stats_edc_group_update(group_name);
-   base_edc_navigator_parts_reload();
+   base_edc_navigator_group_update(group_name);
 }
 
 static void
@@ -431,7 +431,7 @@ enventor_live_view_loaded_cb(void *data EINA_UNUSED, 
Evas_Object *obj,
    Evas_Coord w, h;
    config_view_size_get(&w, &h);
    enventor_object_live_view_size_set(obj, w, h);
-   base_edc_navigator_group_reload();
+   base_edc_navigator_reload();
 }
 
 static void
@@ -487,7 +487,6 @@ enventor_live_view_updated_cb(void *data, Evas_Object *obj,
                               void *event_info EINA_UNUSED)
 {
    app_data *ad = data;
-
    if (ad->lazy_save && enventor_object_modified_get(obj))
      {
         enventor_object_save(obj, config_input_path_get());
@@ -498,6 +497,8 @@ enventor_live_view_updated_cb(void *data, Evas_Object *obj,
         ad->lazy_save = EINA_FALSE;
         ad->on_saving = EINA_FALSE;
      }
+
+   base_edc_navigator_group_update(stats_group_name_get());
 }
 
 static void
@@ -924,7 +925,7 @@ init(app_data *ad, int argc, char **argv)
 }
 
 static void
-term(app_data *ad EINA_UNUSED)
+term(app_data *ad)
 {
    menu_term();
    live_edit_term();
diff --git a/src/include/base_gui.h b/src/include/base_gui.h
index 90457a8..50d22c5 100644
--- a/src/include/base_gui.h
+++ b/src/include/base_gui.h
@@ -23,5 +23,5 @@ void base_console_reset(void);
 void base_error_msg_set(const char *msg);
 void base_console_full_view(void);
 void base_edc_navigator_toggle(Eina_Bool toggle);
-void base_edc_navigator_group_reload(void);
-void base_edc_navigator_parts_reload(void);
+void base_edc_navigator_reload(void);
+void base_edc_navigator_group_update(const char *group_name);
diff --git a/src/include/edc_navigator.h b/src/include/edc_navigator.h
index fa886c3..18f65c9 100644
--- a/src/include/edc_navigator.h
+++ b/src/include/edc_navigator.h
@@ -1,4 +1,4 @@
 Evas_Object *edc_navigator_init(Evas_Object *parent);
 void edc_navigator_term(void);
-void edc_navigator_group_reload(void);
-void edc_navigator_parts_reload(void);
+void edc_navigator_reload(void);
+void edc_navigator_group_update(const char *cur_group);
diff --git a/src/lib/edj_viewer.c b/src/lib/edj_viewer.c
index 505df35..3d78de5 100644
--- a/src/lib/edj_viewer.c
+++ b/src/lib/edj_viewer.c
@@ -760,6 +760,12 @@ view_programs_list_get(view_data *vd)
    return edje_edit_programs_list_get(vd->layout);
 }
 
+Edje_Part_Type
+view_part_type_get(view_data *vd, const char *part)
+{
+   return edje_edit_part_type_get(vd->layout, part);
+}
+
 Eina_List *
 view_part_states_list_get(view_data *vd, const char *part)
 {
diff --git a/src/lib/enventor_object.eo b/src/lib/enventor_object.eo
index 30a2c71..9ceb16d 100644
--- a/src/lib/enventor_object.eo
+++ b/src/lib/enventor_object.eo
@@ -233,6 +233,12 @@ class Enventor.Object (Elm.Widget, Efl.File) {
             @in h: Evas_Coord *;
          }
       }
+      part_type_get {
+         return: Edje_Part_Type;
+         params {
+            @in part_name: const(char) *;
+         }
+      }
       redo {
          return: bool;
       }
diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h
index 41c8acc..a4898ca 100644
--- a/src/lib/enventor_private.h
+++ b/src/lib/enventor_private.h
@@ -232,7 +232,7 @@ Eina_List *view_program_targets_get(view_data *vd, const 
char *prog);
 void view_string_list_free(Eina_List *list);
 void view_part_state_set(view_data *vd, const char *part, const char 
*description, const double state);
 void view_obj_need_reload_set(view_data *vd);
-
+Edje_Part_Type view_part_type_get(view_data *vd, const char *part);
 
 /* template */
 Eina_Bool template_part_insert(edit_data *ed, Edje_Part_Type part_type, 
Enventor_Template_Insert_Type insert_type, float rel1_x, float rel1_y, float 
rel2_x, float rel2_y, const Eina_Stringshare *group_name, char *syntax, size_t 
n);
diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c
index 6e391df..be3c0e8 100644
--- a/src/lib/enventor_smart.c
+++ b/src/lib/enventor_smart.c
@@ -323,6 +323,14 @@ _enventor_object_part_states_list_get(Eo *obj EINA_UNUSED,
    return view_part_states_list_get(VIEW_DATA, part);
 }
 
+EOLIAN static Edje_Part_Type
+_enventor_object_part_type_get(Eo *obj EINA_UNUSED,
+                               Enventor_Object_Data *pd EINA_UNUSED,
+                               const char *part_name)
+{
+   return view_part_type_get(VIEW_DATA, part_name);
+}
+
 EOLIAN static Eina_List *
 _enventor_object_parts_list_get(Eo *obj EINA_UNUSED,
                                 Enventor_Object_Data *pd EINA_UNUSED)

-- 


Reply via email to