[AT-SPI] Squashed implementation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / check-box-button-impl.cpp
index 9c898c7..45c5057 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 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.
 #include "check-box-button-impl.h"
 
 // EXTERNAL INCLUDES
+#include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry.h>
 
-// INTERNAL INCLUDES
-#include "check-box-button-default-painter-impl.h"
+//INTERNAL INCLUDES
+#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
+#include <dali-toolkit/devel-api/shader-effects/image-region-effect.h>
+
+#if defined(DEBUG_ENABLED)
+  extern Debug::Filter* gLogButtonFilter;
+#endif
 
 namespace Dali
 {
@@ -43,6 +51,8 @@ BaseHandle Create()
 
 TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create );
 
+
+
 }
 
 Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
@@ -63,16 +73,40 @@ Dali::Toolkit::CheckBoxButton CheckBoxButton::New()
 CheckBoxButton::CheckBoxButton()
 : Button()
 {
-  // Creates specific painter.
-  ButtonPainterPtr painter = new CheckBoxButtonDefaultPainter();
-  SetPainter( painter );
-
   SetTogglableButton( true );
+  DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) {
+    return std::unique_ptr< Dali::Accessibility::Accessible >(
+        new AccessibleImpl( actor, Dali::Accessibility::Role::CHECK_BOX ) );
+  } );
 }
 
 CheckBoxButton::~CheckBoxButton()
 {
-  SetPainter( NULL );
+}
+
+void CheckBoxButton::OnInitialize()
+{
+  Button::OnInitialize();
+}
+
+Dali::Accessibility::States CheckBoxButton::AccessibleImpl::CalculateStates()
+{
+  auto tmp = Button::AccessibleImpl::CalculateStates();
+  auto slf = Toolkit::Button::DownCast( self );
+  if( slf.GetProperty<bool>( Toolkit::Button::Property::SELECTED ) )
+    tmp[Dali::Accessibility::State::CHECKED] = true;
+  return tmp;
+}
+
+void CheckBoxButton::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