[Tizen][AT-SPI] Add Value::GetValueText() 88/291488/1
authorArtur Świgoń <a.swigon@samsung.com>
Thu, 13 Apr 2023 09:32:32 +0000 (11:32 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Mon, 17 Apr 2023 10:01:01 +0000 (12:01 +0200)
Change-Id: I2995c49d8cb590454e9cf0773bcf97955393718c

dali/devel-api/atspi-interfaces/value.h
dali/internal/accessibility/bridge/bridge-accessible.cpp
dali/internal/accessibility/bridge/bridge-accessible.h
dali/internal/accessibility/bridge/bridge-value.cpp
dali/internal/accessibility/bridge/bridge-value.h

index 6c9a963..2560222 100644 (file)
@@ -38,11 +38,37 @@ public:
   /**
    * @brief Gets the current value.
    *
+   * 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) - GetCurrent() normalized as a percentage
+   *    of the range [GetMinimum(), GetMaximum()],
+   * 2. "number" - GetCurrent() verbatim
+   * 3. "text" - GetValueText() is used instead of GetCurrent()
+   *
    * @return The current value
+   *
+   * @see Value::GetMinimum()
+   * @see Value::GetMaximum()
+   * @see Value::GetValueText()
+   * @see Dali::Toolkit::DevelControl::AppendAccessibilityAttribute()
   */
   virtual double GetCurrent() const = 0;
 
   /**
+   * @brief Gets the formatted current value.
+   *
+   * This does not have to be GetCurrent() formatted in any particular way,
+   * i.e. it may be an arbitrary string, e.g. "small font size" for the
+   * numeric value 10.0.
+   *
+   * @return The current value as text
+   *
+   * @note Only used if the "value_format" attribute is "text"
+   * @see Value::GetCurrent()
+   */
+  virtual std::string GetValueText() const = 0;
+
+  /**
    * @brief Gets the highest possible value.
    *
    * @return The highest value.
index db9a2aa..0d0f9ed 100644 (file)
@@ -488,14 +488,16 @@ BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
 
   auto describedByObject = findObjectByRelationType(RelationType::DESCRIBED_BY);
 
-  double currentValue     = 0.0;
-  double minimumIncrement = 0.0;
-  double maximumValue     = 0.0;
-  double minimumValue     = 0.0;
-  auto*  valueInterface   = Value::DownCast(self);
+  double      currentValue     = 0.0;
+  std::string currentValueText;
+  double      minimumIncrement = 0.0;
+  double      maximumValue     = 0.0;
+  double      minimumValue     = 0.0;
+  auto*       valueInterface   = Value::DownCast(self);
   if(valueInterface)
   {
     currentValue     = valueInterface->GetCurrent();
+    currentValueText = valueInterface->GetValueText();
     minimumIncrement = valueInterface->GetMinimumIncrement();
     maximumValue     = valueInterface->GetMaximum();
     minimumValue     = valueInterface->GetMinimum();
@@ -573,6 +575,7 @@ BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
     localizedRoleName,
     childCount,
     currentValue,
+    currentValueText,
     minimumIncrement,
     maximumValue,
     minimumValue,
index cf67cac..329fc43 100644 (file)
@@ -74,6 +74,7 @@ public:
     std::string,                      // localized name
     int32_t,                          // child count
     double,                           // current value
+    std::string,                      // formatted current value
     double,                           // minimum increment
     double,                           // maximum value
     double,                           // minimum value
index 8ac9007..37e752b 100644 (file)
@@ -28,6 +28,7 @@ void BridgeValue::RegisterInterfaces()
 {
   DBus::DBusInterfaceDescription desc{Accessible::GetInterfaceName(AtspiInterface::VALUE)};
   AddGetSetPropertyToInterface(desc, "CurrentValue", &BridgeValue::GetCurrentValue, &BridgeValue::SetCurrentValue);
+  AddGetPropertyToInterface(desc, "Text", &BridgeValue::GetCurrentValueText);
   AddGetPropertyToInterface(desc, "MaximumValue", &BridgeValue::GetMaximumValue);
   AddGetPropertyToInterface(desc, "MinimumIncrement", &BridgeValue::GetMinimumIncrement);
   AddGetPropertyToInterface(desc, "MinimumValue", &BridgeValue::GetMinimumValue);
@@ -49,6 +50,11 @@ void BridgeValue::SetCurrentValue(double newValue)
   FindSelf()->SetCurrent(newValue);
 }
 
+std::string BridgeValue::GetCurrentValueText()
+{
+  return FindSelf()->GetValueText();
+}
+
 double BridgeValue::GetMaximumValue()
 {
   return FindSelf()->GetMaximum();
index caa7cc1..e2d4d09 100644 (file)
@@ -64,6 +64,11 @@ public:
   void SetCurrentValue(double newValue);
 
   /**
+   * @copydoc Dali::Accessibility::Value::GetValueText()
+   */
+  std::string GetCurrentValueText();
+
+  /**
    * @copydoc Dali::Accessibility::Value::GetMaximum()
    */
   double GetMaximumValue();