/*
- * 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.
#include <cstring> // for strcmp
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/integration-api/debug.h>
-#include <dali/public-api/events/touch-data.h>
-#include <dali/public-api/images/resource-image.h>
+#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
mPreviousButtonState = mButtonState; // Store previous state for visual removal (used when animations ended)
mButtonState = requestedState; // Update current state
- if ( Self().OnStage() )
+ if ( Self().GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) )
{
OnStateChange( mButtonState ); // Notify derived buttons
SelectRequiredVisual( VISUAL_INDEX_FOR_STATE[ mButtonState ][ BACKGROUND ] );
else
{
// if its not a string then get a Property::Map from the property if possible.
- Property::Map *map = value.GetMap();
+ const Property::Map *map = value.GetMap();
if( map && !map->Empty() ) // Empty map results in current visual removal.
{
DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "CreateVisualsForComponent Using Map(%d)\n", index );
mTapDetector.Attach( self );
mTapDetector.DetectedSignal().Connect(this, &Button::OnTap);
- self.SetKeyboardFocusable( true );
+ self.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE, true );
+ self.SetProperty( Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true );
- self.TouchSignal().Connect( this, &Button::OnTouch );
+ self.TouchedSignal().Connect( this, &Button::OnTouch );
}
bool Button::OnAccessibilityActivated()
return OnKeyboardEnter();
}
-bool Button::OnTouch( Actor actor, const TouchData& touch )
+bool Button::OnTouch( Actor actor, const TouchEvent& touch )
{
-
- // Only events are processed when the button is not disabled
- auto result( false );
-
- if( !IsDisabled() )
+ if( !IsDisabled() && (actor == touch.GetHitActor(0)) )
{
if ( 1 == touch.GetPointCount() )
{
// Sets the button state to the default
mButtonPressedState = UNPRESSED;
}
- result = true;
}
- return result;
+ return false;
}
bool Button::OnKeyboardEnter()
return ret;
}
-void Button::OnStageDisconnection()
+void Button::OnSceneDisconnection()
{
if( DEPRESSED == mButtonPressedState )
{
mButtonPressedState = UNPRESSED;
- Control::OnStageDisconnection(); // Visuals will be set off stage
+ Control::OnSceneDisconnection(); // Visuals will be set off stage
}
-void Button::OnStageConnection( int depth )
+void Button::OnSceneConnection( int depth )
{
- DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::OnStageConnection ptr(%p) \n", this );
+ DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::OnSceneConnection ptr(%p) \n", this );
OnButtonVisualRemoval( VISUAL_INDEX_FOR_STATE[ mPreviousButtonState ][ BACKGROUND ] );
OnButtonVisualRemoval( VISUAL_INDEX_FOR_STATE[ mPreviousButtonState ][ FOREGROUND ] );
SelectRequiredVisual( Toolkit::Button::Property::LABEL );
SelectRequiredVisual( VISUAL_INDEX_FOR_STATE[ mButtonState ][ BACKGROUND ] );
SelectRequiredVisual( VISUAL_INDEX_FOR_STATE[ mButtonState ][ FOREGROUND ] );
- Control::OnStageConnection( depth ); // Enabled visuals will be put on stage
+ Control::OnSceneConnection( depth ); // Enabled visuals will be put on stage
RelayoutRequest();
}
else
{
// Get a Property::Map from the property if possible.
- Property::Map* setPropertyMap = value.GetMap();
+ const Property::Map* setPropertyMap = value.GetMap();
if( setPropertyMap )
{
- TextVisual::ConvertStringKeysToIndexKeys( *setPropertyMap );
- GetImplementation( button ).MergeWithExistingLabelProperties( *setPropertyMap, outTextVisualProperties );
+ Property::Map indexKeys = TextVisual::ConvertStringKeysToIndexKeys( *setPropertyMap );
+ GetImplementation( button ).MergeWithExistingLabelProperties( indexKeys, outTextVisualProperties );
}
}
return mForegroundPadding;
}
+std::string Button::AccessibleImpl::GetNameRaw()
+{
+ auto slf = Toolkit::Button::DownCast( self );
+
+ Property::Map label = slf.GetProperty<Property::Map>( Toolkit::Button::Property::LABEL );
+
+ std::string labelText;
+ label.Find( Toolkit::TextVisual::Property::TEXT )->Get( labelText );
+
+ return labelText;
+}
+
+Property::Index Button::AccessibleImpl::GetNamePropertyIndex()
+{
+ Property::Index label = Toolkit::Button::Property::LABEL;
+ Property::Map labelMap = self.GetProperty<Property::Map>(label);
+
+ if (MapContainsTextString(labelMap))
+ return label;
+ else
+ return Property::INVALID_INDEX;
+}
+
+Dali::Accessibility::States Button::AccessibleImpl::CalculateStates()
+{
+ auto tmp = Control::Impl::AccessibleImpl::CalculateStates();
+ tmp[Dali::Accessibility::State::SELECTABLE] = true;
+ auto slf = Toolkit::Button::DownCast( self );
+ tmp[Dali::Accessibility::State::ENABLED] = !slf.GetProperty<bool>( Toolkit::Button::Property::DISABLED );
+ tmp[Dali::Accessibility::State::CHECKED] = slf.GetProperty<bool>( Toolkit::Button::Property::SELECTED );
+ return tmp;
+}
+
} // namespace Internal
} // namespace Toolkit