[access] enhance access features
authorShinwoo Kim <kimcinoo.efl@gmail.com>
Tue, 13 Nov 2012 05:50:08 +0000 (05:50 +0000)
committerShinwoo Kim <kimcinoo.efl@gmail.com>
Tue, 13 Nov 2012 05:50:08 +0000 (05:50 +0000)
  1. add smart_activate(); to access object.
  2. add an API _elm_access_activate_callback_set();
    - this callback is called when user wants to activate access object
      which would represent widget item or edje part object.
  3. add owner referece to the Elm_Access_Info for access object.
  4. clock: use _elm_access_activate_callback_set();

SVN revision: 79199

src/lib/elm_access.c
src/lib/elm_clock.c
src/lib/elm_widget.h

index 6a5b868..c35a48b 100644 (file)
@@ -26,6 +26,20 @@ _elm_access_smart_on_focus(Evas_Object *obj)
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_elm_access_smart_activate(Evas_Object *obj, Elm_Activate act)
+{
+   if (act != ELM_ACTIVATE_DEFAULT) return EINA_FALSE;
+
+   Elm_Access_Info *ac = evas_object_data_get(obj, "_elm_access");
+   if (!ac) return EINA_FALSE;
+
+   if (ac->activate)
+     ac->activate(ac->activate_data, ac->part_object, ac->widget_item);
+
+   return EINA_TRUE;
+}
+
 static void
 _elm_access_smart_set_user(Elm_Widget_Smart_Class *sc)
 {
@@ -35,6 +49,7 @@ _elm_access_smart_set_user(Elm_Widget_Smart_Class *sc)
    sc->focus_next = NULL;
    sc->focus_direction = NULL;
    sc->on_focus = _elm_access_smart_on_focus;
+   sc->activate = _elm_access_smart_activate;
 
    return;
 }
@@ -294,6 +309,16 @@ _elm_access_on_highlight_hook_set(Elm_Access_Info           *ac,
 }
 
 EAPI void
+_elm_access_activate_callback_set(Elm_Access_Info           *ac,
+                                  Elm_Access_Activate_Cb     func,
+                                  void                      *data)
+{
+   if (!ac) return;
+   ac->activate = func;
+   ac->activate_data = data;
+}
+
+EAPI void
 _elm_access_highlight_object_activate(Evas_Object *obj, Elm_Activate act)
 {
    Evas_Object *highlight_obj;
@@ -506,6 +531,7 @@ _elm_access_edje_object_part_object_register(Evas_Object* obj,
    Evas_Object *ao;
    Evas_Object *po = (Evas_Object *)edje_object_part_object_get(eobj, part);
    Evas_Coord x, y, w, h;
+   Elm_Access_Info *ac;
 
    if (!obj || !po) return NULL;
 
@@ -540,6 +566,10 @@ _elm_access_edje_object_part_object_register(Evas_Object* obj,
    // set access object
    evas_object_data_set(po, "_part_access_obj", ao);
 
+   /* set owner part object */
+   ac = evas_object_data_get(ao, "_elm_access");
+   ac->part_object = po;
+
    return ao;
 }
 
@@ -693,6 +723,7 @@ _elm_access_widget_item_register(Elm_Widget_Item *item)
 {
    Evas_Object *ao, *ho;
    Evas_Coord x, y, w, h;
+   Elm_Access_Info *ac;
 
    if (!item) return;
 
@@ -713,6 +744,10 @@ _elm_access_widget_item_register(Elm_Widget_Item *item)
    _elm_access_object_register(ao, ho);
 
    item->access_obj = ao;
+
+   /* set owner widget item */
+   ac = evas_object_data_get(ao, "_elm_access");
+   ac->widget_item = item;
 }
 
 EAPI void
index 01f1a49..c426cce 100644 (file)
@@ -175,6 +175,27 @@ _on_clock_val_change_stop(void *data,
 }
 
 static void
+_access_activate_cb(void *data,
+                    Evas_Object *part_obj,
+                    Elm_Widget_Item *item __UNUSED__)
+{
+   Evas_Object *digit, *inc_btn;
+   ELM_CLOCK_DATA_GET(data, sd);
+
+   digit = evas_object_smart_parent_get(part_obj);
+   if (!digit) return;
+
+   inc_btn = (Evas_Object *)edje_object_part_object_get(digit, "access.t");
+
+   if (part_obj != inc_btn)
+     _on_clock_val_down_start(data, digit, NULL, NULL);
+   else
+     _on_clock_val_up_start(data, digit, NULL, NULL);
+
+   _on_clock_val_change_stop(sd, NULL, NULL, NULL);
+}
+
+static void
 _access_time_register(Evas_Object *obj, Eina_Bool is_access)
 {
    Evas_Object *ao, *po;
@@ -224,6 +245,8 @@ _access_time_register(Evas_Object *obj, Eina_Bool is_access)
                "clock increment button for %s", digit);
              _elm_access_text_set(_elm_access_object_get(ao),
                ELM_ACCESS_TYPE, eina_strbuf_string_get(strbuf));
+             _elm_access_activate_callback_set
+               (_elm_access_object_get(ao), _access_activate_cb, obj);
 
              /* decrement button */
              ao = _elm_access_edje_object_part_object_register
@@ -232,6 +255,8 @@ _access_time_register(Evas_Object *obj, Eina_Bool is_access)
              eina_strbuf_replace(strbuf, "increment", "decrement", 1);
              _elm_access_text_set(_elm_access_object_get(ao),
                ELM_ACCESS_TYPE, eina_strbuf_string_get(strbuf));
+             _elm_access_activate_callback_set
+               (_elm_access_object_get(ao), _access_activate_cb, obj);
 
              eina_strbuf_free(strbuf);
 
@@ -269,12 +294,16 @@ _access_time_register(Evas_Object *obj, Eina_Bool is_access)
                (obj, sd->am_pm_obj, "access.t");
         _elm_access_text_set(_elm_access_object_get(ao),
           ELM_ACCESS_TYPE, E_("clock increment button for am,pm"));
+        _elm_access_activate_callback_set
+          (_elm_access_object_get(ao), _access_activate_cb, obj);
 
         /* decrement button */
         ao = _elm_access_edje_object_part_object_register
                (obj, sd->am_pm_obj, "access.b");
         _elm_access_text_set(_elm_access_object_get(ao),
           ELM_ACCESS_TYPE, E_("clock decrement button for am,pm"));
+        _elm_access_activate_callback_set
+          (_elm_access_object_get(ao), _access_activate_cb, obj);
 
          edje_object_signal_emit
            (sd->am_pm_obj, "elm,state,access,edit,on", "elm");
@@ -553,6 +582,7 @@ _ticker(void *data)
 
    gettimeofday(&timev, NULL);
    t = ((double)(1000000 - timev.tv_usec)) / 1000000.0;
+
    sd->ticker = ecore_timer_add(t, _ticker, data);
    if (!sd->edit)
      {
index 0322032..9c110c7 100644 (file)
@@ -559,6 +559,7 @@ typedef Eina_Bool             (*Elm_Widget_Del_Pre_Cb)(void *data);
 
 typedef char *(*Elm_Access_Content_Cb)(void *data, Evas_Object *obj, Elm_Widget_Item *item);
 typedef void (*Elm_Access_On_Highlight_Cb)(void *data);
+typedef void (*Elm_Access_Activate_Cb)(void *data, Evas_Object *part_obj, Elm_Widget_Item *item);
 
 struct _Elm_Access_Item
 {
@@ -574,6 +575,15 @@ struct _Elm_Access_Info
    Ecore_Timer               *delay_timer;
    void                      *on_highlight_data;
    Elm_Access_On_Highlight_Cb on_highlight;
+
+   void                      *activate_data;
+   Elm_Access_Activate_Cb    activate;
+
+   /* the owner widget item that owns this access info */
+   Elm_Widget_Item           *widget_item;
+
+   /* the owner part object that owns this access info */
+   Evas_Object               *part_object;
 };
 
 EAPI void             _elm_access_clear(Elm_Access_Info *ac);
@@ -597,6 +607,7 @@ EAPI void             _elm_access_edje_object_part_object_unregister(Evas_Object
 EAPI void             _elm_access_widget_item_register(Elm_Widget_Item *item);
 EAPI void             _elm_access_widget_item_unregister(Elm_Widget_Item *item);
 EAPI void             _elm_access_on_highlight_hook_set(Elm_Access_Info *ac, Elm_Access_On_Highlight_Cb func, void *data);
+EAPI void             _elm_access_activate_callback_set(Elm_Access_Info *ac, Elm_Access_Activate_Cb func, void *data);
 EAPI void             _elm_access_highlight_object_activate(Evas_Object *obj, Elm_Activate act);
 
 /**< put this as the first member in your widget item struct */