jaehyun pushed a commit to branch master.

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

commit 69029879d8c86c71a413d53b1db9b9cf9fa376b5
Author: Jaehyun Cho <jae_hyun....@samsung.com>
Date:   Thu Feb 25 11:25:43 2016 +0900

    ctxpopup: Reset candidate values by backspace key.
    
    toggle, slider and colorselector values of candidate ctxpopup are reset
    by backspace key.
---
 src/bin/main.c     |  8 ++++++--
 src/lib/ctxpopup.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/src/bin/main.c b/src/bin/main.c
index 96e1a42..6b991e4 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -457,8 +457,12 @@ static void
 enventor_ctxpopup_activated_cb(void *data, Evas_Object *obj, void *event_info)
 {
    Enventor_Ctxpopup_Type type = (Enventor_Ctxpopup_Type) event_info;
-   if (type != ENVENTOR_CTXPOPUP_TYPE_SLIDER) return;
-   stats_info_msg_update("You could use a mouse wheel to change values 
elaborately.");
+
+   if (type == ENVENTOR_CTXPOPUP_TYPE_SLIDER)
+     stats_info_msg_update("Mouse wheel: Change values elaborately.  "
+                           "Backspace: Reset values.");
+   else if (type == ENVENTOR_CTXPOPUP_TYPE_TOGGLE)
+     stats_info_msg_update("Backspace: Reset values.");
 }
 
 static void
diff --git a/src/lib/ctxpopup.c b/src/lib/ctxpopup.c
index 6020782..8f0928b 100644
--- a/src/lib/ctxpopup.c
+++ b/src/lib/ctxpopup.c
@@ -58,6 +58,9 @@ static preset_colors_data preset_colors =
 /* Internal method implementation                                            */
 /*****************************************************************************/
 
+static Eina_Bool
+is_colorselector_type(ctxpopup_data *ctxdata);
+
 static void
 update_preset_colors(Eina_Bool update)
 {
@@ -703,6 +706,8 @@ end:
 static void
 image_relay(ctxpopup_data *ctxdata, Eina_Bool up)
 {
+   if (!ctxdata->relay_cb) return;
+
    if (up)
      ctxdata->relay_cb(ctxdata->data, ctxdata->ctxpopup, (void *) 0);
    else
@@ -710,6 +715,48 @@ image_relay(ctxpopup_data *ctxdata, Eina_Bool up)
 }
 
 static void
+candidate_reset(ctxpopup_data *ctxdata)
+{
+   attr_value *attr = ctxdata->attr;
+   if (!attr) return;
+
+   //Colorselector Candidate
+   if (is_colorselector_type(ctxdata))
+     {
+        elm_colorselector_color_set(ctxdata->colorselector, attr->val[0],
+                                    attr->val[1], attr->val[2], attr->val[3]);
+        colorselector_changed_cb(ctxdata, ctxdata->colorselector, NULL);
+     }
+   //Toggle Candidate
+   else if ((attr->type == ATTR_VALUE_BOOLEAN))
+     {
+        Eina_List *l;
+        Evas_Object *toggle;
+        int i = 0;
+        EINA_LIST_FOREACH(ctxdata->toggles, l, toggle)
+          {
+             elm_check_state_set(toggle, (Eina_Bool) roundf(attr->val[i]));
+             toggle_changed_cb(ctxdata, toggle, NULL);
+             i++;
+          }
+     }
+   //Slider Candidate
+   else if ((attr->type == ATTR_VALUE_INTEGER) ||
+            (attr->type == ATTR_VALUE_FLOAT))
+     {
+        Eina_List *l;
+        Evas_Object *slider;
+        int i = 0;
+        EINA_LIST_FOREACH(ctxdata->sliders, l, slider)
+          {
+             elm_slider_value_set(slider, attr->val[i]);
+             slider_changed_cb(ctxdata, slider, NULL);
+             i++;
+          }
+     }
+}
+
+static void
 ctxpopup_mouse_wheel_cb(void *data, Evas *e EINA_UNUSED,
                         Evas_Object *obj EINA_UNUSED, void *event_info)
 {
@@ -729,6 +776,7 @@ ctxpopup_key_down_cb(void *data, Evas *e EINA_UNUSED,
 
    if (!strcmp(ev->key, "Down")) image_relay(ctxdata, EINA_FALSE);
    else if (!strcmp(ev->key, "Up")) image_relay(ctxdata, EINA_TRUE);
+   else if (!strcmp(ev->key, "BackSpace")) candidate_reset(ctxdata);
 }
 
 /*****************************************************************************/
@@ -900,6 +948,8 @@ ctxpopup_candidate_list_create(edit_data *ed, attr_value 
*attr,
              break;
           }
    }
+   evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN,
+                                  ctxpopup_key_down_cb, ctxdata);
    evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, ctxpopup_del_cb,
                                   ctxdata);
    evas_object_smart_callback_add(ctxpopup, "dismissed", ctxpopup_dismiss_cb,

-- 


Reply via email to