/*
- * Copyright (c) 2016 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.
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
#include <dali/public-api/object/type-registry.h>
-#include <dali/public-api/images/resource-image.h>
//INTERNAL INCLUDES
#include <dali-toolkit/internal/controls/image-view/image-view-impl.h>
namespace
{
-const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time - Will be replaced by stylable tranisitions
-
BaseHandle Create()
{
return Toolkit::CheckBoxButton::New();
: Button()
{
SetTogglableButton( true );
-
- SetAnimationTime( ANIMATION_TIME );
}
CheckBoxButton::~CheckBoxButton()
{
}
-void CheckBoxButton::FadeImageTo( Actor actor , float opacity )
-{
- if( actor )
- {
- Dali::Animation transitionAnimation = GetTransitionAnimation();
-
- if( transitionAnimation )
- {
- transitionAnimation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), opacity );
- }
- }
-}
-
void CheckBoxButton::OnInitialize()
{
Button::OnInitialize();
-}
-void CheckBoxButton::PrepareForTransitionIn( Actor actor )
-{
- // Set Toolkit::Button::Property::SELECTED_VISUAL and Toolkit::Button::Property::UNSELECTED_VISUAL to opacity 0
- // Then get and start animation
+ DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) {
+ return std::unique_ptr< Dali::Accessibility::Accessible >(
+ new AccessibleImpl( actor, Dali::Accessibility::Role::CHECK_BOX ) );
+ } );
}
-void CheckBoxButton::PrepareForTransitionOut( Actor actor )
+Dali::Accessibility::States CheckBoxButton::AccessibleImpl::CalculateStates()
{
- // Set Toolkit::Button::Property::SELECTED_VISUAL and Toolkit::Button::Property::UNSELECTED_VISUAL to opacity 1
- // Then get and start animation
+ 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::OnTransitionIn( Actor actor )
+void CheckBoxButton::OnStateChange( State newState )
{
- // Only transition selected and unselected visual, background doesn't change.
- // Start Fade animation to 1
-}
-
-void CheckBoxButton::OnTransitionOut( Actor actor )
-{
- // Only transition selected and unselected visual, background doesn't change.
- // Start Fade animation to 0
+ // 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