efl_access_object: Support org.a11y.atspi.Value.Text property 12/291412/4
authorLukasz Oleksak <l.oleksak@samsung.com>
Fri, 14 Apr 2023 10:14:38 +0000 (12:14 +0200)
committerLukasz Oleksak <l.oleksak@samsung.com>
Mon, 17 Apr 2023 08:38:39 +0000 (08:38 +0000)
The application may set the "value_format" attribute to one of the
following values in order to customize what is read by the Screen Reader:

    1. "percent" (the default) - current value normalized as a percentage
       of the range [minimum value, maximum value],
    2. "number" - current value verbatim
    3. "text" - customized textual representation is used instead of current value

Option "text" must be acompanied by registration of a callback that would provide
relevant textual representation of current value:

    efl_access_object_value_text_cb_set(slider, value_text_cb, NULL);
    efl_access_object_attribute_append(slider, "value_format", "text");

    static char *value_text_cb(void *data, Evas_Object *obj)
    {
        return strdup("This information is set by value text callback");
    }

@tizen_only

Change-Id: Ic0d544dc163dff20551dddbcfe92ffcbd1876541

src/lib/elementary/efl_access_object.c
src/lib/elementary/efl_access_object.eo
src/lib/elementary/efl_ui_widget.c
src/lib/elementary/elm_slider.c

index f08a3f0..b95cffa 100644 (file)
@@ -155,6 +155,9 @@ struct _Efl_Access_Object_Data
    Efl_Access_Reading_Info_Cb_Item name_cb_item;
    Efl_Access_Reading_Info_Cb_Item description_cb_item;
    //
+   //TIZEN_ONLY(20230414): Support org.a11y.atspi.Value.Text property.
+   Efl_Access_Reading_Info_Cb_Item value_text_cb_item;
+   //
    //TIZEN_ONLY(20170405) Add gesture method to accessible interface
    Efl_Access_Gesture_Cb_Item gesture_cb_item;
    Elm_Atspi_Gesture_Cb_Item legacy_gesture_cb_item;
@@ -162,6 +165,9 @@ struct _Efl_Access_Object_Data
    Eina_List     *attr_list;
    const char    *name;
    const char    *description;
+   //TIZEN_ONLY(20230414): Support org.a11y.atspi.Value.Text property.
+   const char    *value_text;
+   //
    const char    *translation_domain;
    Efl_Access_Role role;
    Efl_Access_Reading_Info_Type_Mask reading_info;
@@ -465,6 +471,35 @@ _efl_access_object_description_cb_set(Eo *obj EINA_UNUSED, Efl_Access_Object_Dat
 }
 //
 
+//TIZEN_ONLY(20230414): Support org.a11y.atspi.Value.Text property.
+EOLIAN static const char *
+_efl_access_object_value_text_get(const Eo *obj, Efl_Access_Object_Data *pd)
+{
+   char *ret = NULL;
+   if (pd->value_text_cb_item.cb)
+     ret = pd->value_text_cb_item.cb((void *)pd->value_text_cb_item.data, (Eo *)obj);
+   if (ret)
+     {
+        eina_stringshare_replace(&pd->value_text, ret);
+        free(ret);
+     }
+   return pd->value_text;
+}
+
+EOLIAN static void
+_efl_access_object_value_text_set(Eo *obj EINA_UNUSED, Efl_Access_Object_Data *pd, const char *val)
+{
+   eina_stringshare_replace(&pd->value_text, val);
+}
+
+EOLIAN static void
+_efl_access_object_value_text_cb_set(Eo *obj EINA_UNUSED, Efl_Access_Object_Data *pd, Efl_Access_Reading_Info_Cb value_text_cb, const void *data)
+{
+   pd->value_text_cb_item.cb = value_text_cb;
+   pd->value_text_cb_item.data = data;
+}
+//
+
 //TIZEN_ONLY(20170405) Add gesture method to accessible interface
 EOLIAN static void
 _efl_access_object_gesture_cb_set(Eo *obj EINA_UNUSED, Efl_Access_Object_Data *pd, Efl_Access_Gesture_Cb gesture_cb, const void *data)
index 10c2637..033065a 100644 (file)
@@ -350,6 +350,27 @@ mixin @beta Efl.Access.Object requires Efl.Object
          }
       }
       //
+      //TIZEN_ONLY(20230414): Support org.a11y.atspi.Value.Text property.
+      @property value_text_cb @beta {
+         [[The callback for textual representation of value carried by object.]]
+         set {
+         }
+         values {
+            value_text_cb: Efl.Access.Reading_Info_Cb; [[The callback for textual representation of value]]
+            data: const (void_ptr);
+         }
+      }
+      @property value_text @beta {
+         [[Textual representation of value carried by object.]]
+         get {
+         }
+         set {
+         }
+         values {
+            value_text: string; [[Textual representation of value carried by object]]
+         }
+      }
+      //
       @property relation_set @protected @beta {
          [[An all relations between accessible object and other accessible objects.]]
          get {
index 430b8d4..8317aff 100644 (file)
@@ -4384,6 +4384,10 @@ _elm_widget_item_efl_object_destructor(Eo *eo_item, Elm_Widget_Item_Data *item)
    efl_access_object_description_cb_set(eo_item, NULL, NULL);
    efl_access_object_name_cb_set(eo_item, NULL, NULL);
    //
+   //TIZEN_ONLY(20230414): Support org.a11y.atspi.Value.Text property.
+   efl_access_object_value_text_set(eo_item, NULL);
+   efl_access_object_value_text_cb_set(eo_item, NULL, NULL);
+   //
    //TIZEN_ONLY(20170405) Add gesture method to accessible interface
    efl_access_object_gesture_cb_set(eo_item, NULL, NULL);
    //
@@ -5829,6 +5833,10 @@ _efl_ui_widget_efl_object_destructor(Eo *obj, Elm_Widget_Smart_Data *sd)
    efl_access_object_description_cb_set(obj, NULL, NULL);
    efl_access_object_name_cb_set(obj, NULL, NULL);
    //
+   //TIZEN_ONLY(20230414): Support org.a11y.atspi.Value.Text property.
+   efl_access_object_value_text_set(obj, NULL);
+   efl_access_object_value_text_cb_set(obj, NULL, NULL);
+   //
    //TIZEN_ONLY(20170405) Add gesture method to accessible interface
    efl_access_object_gesture_cb_set(obj, NULL, NULL);
    //
index f5bbeb9..9139b99 100644 (file)
@@ -1993,7 +1993,9 @@ EOLIAN static void
 _elm_slider_efl_access_value_value_and_text_get(const Eo *obj EINA_UNUSED, Elm_Slider_Data *sd, double *value, const char **text)
 {
    if (value) *value = sd->val;
-   if (text) *text = NULL;
+   //TIZEN_ONLY(20230414): Support org.a11y.atspi.Value.Text property.
+   if (text) *text = efl_access_object_value_text_get(efl_super(obj, MY_CLASS));
+   //
 }
 
 EOLIAN static Eina_Bool