[AT-SPI] Support reading states and tooltips of ToggleButton 62/243862/21
authorArtur Świgoń <a.swigon@samsung.com>
Thu, 10 Sep 2020 14:21:13 +0000 (16:21 +0200)
committerArtur Świgoń <a.swigon@samsung.com>
Fri, 23 Oct 2020 13:07:00 +0000 (15:07 +0200)
Change-Id: I71f84e5cde9734dc80d8f7fc65c75d1e94f5e178

dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp
dali-toolkit/internal/controls/buttons/toggle-button-impl.h

index 9921663..15ac51a 100644 (file)
@@ -377,14 +377,37 @@ void ToggleButton::OnPressed()
   RelayoutRequest();
 }
 
   RelayoutRequest();
 }
 
+Dali::Accessibility::States ToggleButton::AccessibleImpl::CalculateStates()
+{
+  auto states = Button::AccessibleImpl::CalculateStates();
+  auto button = Toolkit::ToggleButton::DownCast( self );
+  if( button.GetProperty<int>( Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX ) )
+    states[Dali::Accessibility::State::CHECKED] = true;
+  return states;
+}
+
+std::string ToggleButton::AccessibleImpl::GetDescriptionRaw()
+{
+  auto button = Toolkit::ToggleButton::DownCast( self );
+  auto index = button.GetProperty<int>( Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX );
+  auto tooltips = button.GetProperty<Property::Array>( Toolkit::ToggleButton::Property::TOOLTIPS );
+
+  return tooltips[index].Get<std::string>();
+}
+
 void ToggleButton::OnStateChange( State newState )
 {
   // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used
   if (Dali::Accessibility::IsUp() && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
   {
     Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(
 void ToggleButton::OnStateChange( State newState )
 {
   // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used
   if (Dali::Accessibility::IsUp() && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
   {
     Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(
-      Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0
+      Dali::Accessibility::State::CHECKED, mCurrentToggleIndex ? 1 : 0, 0
     );
     );
+
+    if(Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor())
+    {
+      Dali::Accessibility::Accessible::Get(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::DESCRIPTION);
+    }
   }
 }
 
   }
 }
 
index 30af228..7609773 100644 (file)
@@ -164,6 +164,13 @@ private:
   std::vector<std::string> mToggleTooltips;               ///< Toggle tooltips.
   unsigned int             mCurrentToggleIndex;       ///< The index of state.
 protected:
   std::vector<std::string> mToggleTooltips;               ///< Toggle tooltips.
   unsigned int             mCurrentToggleIndex;       ///< The index of state.
 protected:
+  struct AccessibleImpl : public Button::AccessibleImpl
+  {
+    using Button::AccessibleImpl::AccessibleImpl;
+
+    Dali::Accessibility::States CalculateStates() override;
+    std::string GetDescriptionRaw() override;
+  };
   void OnStateChange( State newState ) override;
 };
 
   void OnStateChange( State newState ) override;
 };