[Tizen][AT-SPI] Add Value::GetValueText()
[platform/core/uifw/dali-adaptor.git] / dali / internal / accessibility / bridge / bridge-accessible.cpp
index 0a0d5a5..0d0f9ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
 #include <dali/internal/accessibility/bridge/bridge-accessible.h>
 
 // EXTERNAL INCLUDES
+#include <dali/public-api/math/math-utils.h>
+
 #include <algorithm>
 #include <iostream>
 
@@ -60,7 +62,7 @@ std::vector<std::vector<Component*>> SplitLines(const std::vector<Component*>& c
   // Find first with non-zero area
   auto first = std::find_if(children.begin(), children.end(), [](Component* child) -> bool {
     auto extents = child->GetExtents(CoordinateType::WINDOW);
-    return extents.height != 0.0f && extents.width != 0.0f;
+    return !Dali::EqualsZero(extents.height) && !Dali::EqualsZero(extents.width);
   });
 
   if(first == children.end())
@@ -78,7 +80,7 @@ std::vector<std::vector<Component*>> SplitLines(const std::vector<Component*>& c
     auto child = *it;
 
     rect = child->GetExtents(CoordinateType::WINDOW);
-    if(rect.height == 0.0f || rect.width == 0.0f)
+    if(Dali::EqualsZero(rect.height) || Dali::EqualsZero(rect.width))
     {
       // Zero area, ignore
       continue;
@@ -156,7 +158,7 @@ static bool IsObjectZeroSize(Component* obj)
     return false;
   }
   auto extents = obj->GetExtents(CoordinateType::WINDOW);
-  return extents.height == 0 || extents.width == 0;
+  return Dali::EqualsZero(extents.height) || Dali::EqualsZero(extents.width);
 }
 
 static bool IsObjectAcceptable(Component* obj)
@@ -266,7 +268,6 @@ static std::string MakeIndent(unsigned int maxRecursionDepth)
   return std::string(GET_NAVIGABLE_AT_POINT_MAX_RECURSION_DEPTH - maxRecursionDepth, ' ');
 }
 
-
 static bool IsRoleAcceptableWhenNavigatingNextPrev(Accessible* obj)
 {
   if(!obj)
@@ -392,6 +393,7 @@ void BridgeAccessible::RegisterInterfaces()
   AddFunctionToInterface(desc, "DoGesture", &BridgeAccessible::DoGesture);
   AddFunctionToInterface(desc, "GetReadingMaterial", &BridgeAccessible::GetReadingMaterial);
   AddFunctionToInterface(desc, "GetRelationSet", &BridgeAccessible::GetRelationSet);
+  AddFunctionToInterface(desc, "SetListenPostRender", &BridgeAccessible::SetListenPostRender);
   mDbusServer.addInterface("/", desc, true);
 }
 
@@ -486,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();
@@ -571,6 +575,7 @@ BridgeAccessible::ReadingMaterialType BridgeAccessible::GetReadingMaterial()
     localizedRoleName,
     childCount,
     currentValue,
+    currentValueText,
     minimumIncrement,
     maximumValue,
     minimumValue,
@@ -990,11 +995,9 @@ std::string BridgeAccessible::GetName()
 
 DBus::ValueOrError<Accessible*, uint32_t, std::unordered_map<std::string, std::string>> BridgeAccessible::GetDefaultLabelInfo()
 {
-  auto defaultLabel = GetDefaultLabel();
-  if(defaultLabel == nullptr)
-  {
-    defaultLabel = FindSelf();
-  }
+  auto* defaultLabel = GetDefaultLabel(FindSelf());
+  DALI_ASSERT_DEBUG(defaultLabel);
+
   // By default, the text is taken from navigation context root's accessibility properties name and description.
   return {defaultLabel, static_cast<uint32_t>(defaultLabel->GetRole()), defaultLabel->GetAttributes()};
 }
@@ -1011,3 +1014,9 @@ DBus::ValueOrError<std::vector<BridgeAccessible::Relation>> BridgeAccessible::Ge
 
   return ret;
 }
+
+DBus::ValueOrError<void> BridgeAccessible::SetListenPostRender(bool enabled)
+{
+  FindSelf()->SetListenPostRender(enabled);
+  return {};
+}