[AT-SPI] Squashed implementation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / toggle-button-impl.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 6aaf423..a3c4464
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -21,7 +21,6 @@
 // EXTERNAL INCLUDES
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
-#include <dali/public-api/images/resource-image.h>
 #include <dali/devel-api/scripting/scripting.h>
 #include <dali/public-api/object/property-array.h>
 #include <dali/integration-api/debug.h>
@@ -97,6 +96,10 @@ ToggleButton::ToggleButton()
 {
   DALI_LOG_INFO( gLogButtonFilter, Debug::General, "ToggleButton::Constructor\n" );
   SetTogglableButton( false );
+  DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) {
+    return std::unique_ptr< Dali::Accessibility::Accessible >(
+        new AccessibleImpl( actor, Dali::Accessibility::Role::TOGGLE_BUTTON ) );
+  } );
 }
 
 ToggleButton::~ToggleButton()
@@ -110,7 +113,7 @@ void ToggleButton::OnInitialize()
 
   // Toggle button requires the Leave event.
   Actor self = Self();
-  self.SetLeaveRequired( true );
+  self.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
 }
 
 void ToggleButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )
@@ -137,7 +140,7 @@ void ToggleButton::SetProperty( BaseObject* object, Property::Index propertyInde
       }
       case Toolkit::ToggleButton::Property::TOOLTIPS:
       {
-        Property::Array* tipArray = value.GetArray();
+        const Property::Array* tipArray = value.GetArray();
         if( tipArray )
         {
           std::vector<std::string> tips;
@@ -373,6 +376,17 @@ void ToggleButton::OnPressed()
   RelayoutRequest();
 }
 
+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
+    );
+  }
+}
+
 } // namespace Internal
 
 } // namespace Toolkit