X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fcontrol-impl.cpp;h=354c460bdafc63e5fb9088306d605c18be79c565;hb=26efc210fc636e51a4d3df9ae7fbcc1d2a8bac40;hp=664c7e0c71f1d7177f43a4b6ba574cedf4b2b32b;hpb=5daf80c30657d359f5eb95a00dc9fe7c50180cda;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp old mode 100755 new mode 100644 index 664c7e0..354c460 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -25,9 +25,12 @@ #include #include #include +#include #include +#include #include #include +#include // INTERNAL INCLUDES #include @@ -44,6 +47,12 @@ #include #include #include +#include +#include + +#include +#include +#include namespace Dali { @@ -185,11 +194,6 @@ void Control::SetBackgroundColor( const Vector4& color ) SetBackground( map ); } -Vector4 Control::GetBackgroundColor() const -{ - return mImpl->mBackgroundColor; -} - void Control::SetBackground( const Property::Map& map ) { Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map ); @@ -203,15 +207,6 @@ void Control::SetBackground( const Property::Map& map ) } } -void Control::SetBackgroundImage( Image image ) -{ - Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( image ); - if( visual ) - { - mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, DepthIndex::BACKGROUND ); - } -} - void Control::ClearBackground() { mImpl->UnregisterVisual( Toolkit::Control::Property::BACKGROUND ); @@ -366,7 +361,11 @@ void Control::KeyboardEnter() bool Control::OnAccessibilityActivated() { - return false; // Accessibility activation is not handled by default + if( Toolkit::KeyboardFocusManager::Get().SetCurrentFocusActor( Self() ) ) + { + return OnKeyboardEnter(); + } + return false; } bool Control::OnKeyboardEnter() @@ -481,6 +480,17 @@ void Control::Initialize() { SetKeyboardNavigationSupport( true ); } + + Dali::TypeInfo type; + Self().GetTypeInfo( type ); + if (type) + { + auto typeName = type.GetName(); + DevelControl::AppendAccessibilityAttribute( Self(), "t", typeName ); + } + + if (Accessibility::IsUp()) + mImpl->AccessibilityRegister(); } void Control::OnInitialize() @@ -537,6 +547,17 @@ void Control::EmitKeyInputFocusSignal( bool focusGained ) { Dali::Toolkit::Control handle( GetOwner() ); + if( Accessibility::IsUp() ) + { + auto self = mImpl->GetAccessibilityObject( Self() ); + self->EmitFocused( focusGained ); + auto parent = self->GetParent(); + if( parent && !self->GetStates()[Dali::Accessibility::State::MANAGES_DESCENDANTS] ) + { + parent->EmitActiveDescendantChanged( parent, self ); + } + } + if ( focusGained ) { // signals are allocated dynamically when someone connects @@ -573,10 +594,21 @@ void Control::OnStageConnection( int depth ) // The clipping renderer is only created if required. CreateClippingRenderer( *this ); + + // Request to be laid out when the control is connected to the Stage. + if( Accessibility::IsUp() ) + { + mImpl->AccessibilityRegister(); + } } + void Control::OnStageDisconnection() { + if( Accessibility::IsUp() ) + { + mImpl->AccessibilityDeregister(); + } mImpl->OnStageDisconnection(); } @@ -606,10 +638,49 @@ void Control::OnPropertySet( Property::Index index, Property::Value propertyValu { // If the clipping mode has been set, we may need to create a renderer. // Only do this if we are already on-stage as the OnStageConnection will handle the off-stage clipping controls. - if( ( index == Actor::Property::CLIPPING_MODE ) && Self().OnStage() ) + switch( index ) { - // Note: This method will handle whether creation of the renderer is required. - CreateClippingRenderer( *this ); + case Actor::Property::CLIPPING_MODE: + { + if( Self().OnStage() ) + { + // Note: This method will handle whether creation of the renderer is required. + CreateClippingRenderer( *this ); + } + break; + } + case Actor::Property::VISIBLE: + { + if( Dali::Accessibility::IsUp() ) + { + Dali::Accessibility::Accessible::Get(Self())->EmitVisible( Self().GetProperty( Actor::Property::VISIBLE ).Get() ); + } + break; + } + case Toolkit::DevelControl::Property::ACCESSIBILITY_NAME: + { + if( Dali::Accessibility::IsUp() ) + { + Dali::Accessibility::Accessible::Get(Self())->Emit( Dali::Accessibility::ObjectPropertyChangeEvent::NAME ); + } + break; + } + case Toolkit::DevelControl::Property::ACCESSIBILITY_ROLE: + { + if( Dali::Accessibility::IsUp() ) + { + Dali::Accessibility::Accessible::Get(Self())->Emit( Dali::Accessibility::ObjectPropertyChangeEvent::ROLE ); + } + break; + } + case Toolkit::DevelControl::Property::ACCESSIBILITY_DESCRIPTON: + { + if( Dali::Accessibility::IsUp() ) + { + Dali::Accessibility::Accessible::Get(Self())->Emit( Dali::Accessibility::ObjectPropertyChangeEvent::DESCRIPTION ); + } + break; + } } } @@ -655,44 +726,32 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) Actor child = Self().GetChildAt( i ); Vector2 newChildSize( size ); - // When setting the padding or margin on the control child should be resized and repositioned for legacy reasons. + // When set the padding or margin on the control, child should be resized and repositioned. if( ( mImpl->mPadding.start != 0 ) || ( mImpl->mPadding.end != 0 ) || ( mImpl->mPadding.top != 0 ) || ( mImpl->mPadding.bottom != 0 ) || ( mImpl->mMargin.start != 0 ) || ( mImpl->mMargin.end != 0 ) || ( mImpl->mMargin.top != 0 ) || ( mImpl->mMargin.bottom != 0 ) ) { - // Cannot use childs Position property as it can already have margin applied on it, - // so we end up cumulatively applying them over and over again. - Toolkit::Control childControl = Toolkit::Control::DownCast( child ); - - // If control not a LayoutItem layout then must be the old Relayout algorithm hence account - // for margins and padding. - // Padding is incorrect but may have to keep this functionality for compatibility. - if ( childControl && ! Toolkit::DevelControl::GetLayout( childControl ) ) - { - Extents padding = mImpl->mPadding; + Extents padding = mImpl->mPadding; - Dali::CustomActor ownerActor(GetOwner()); - Dali::LayoutDirection::Type layoutDirection = static_cast( ownerActor.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + Dali::CustomActor ownerActor(GetOwner()); + Dali::LayoutDirection::Type layoutDirection = static_cast( ownerActor.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); - if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection ) - { - std::swap( padding.start, padding.end ); - } + if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection ) + { + std::swap( padding.start, padding.end ); + } - // Child size should include padding, this is the wrong use of padding but kept for compatibility. - newChildSize.width = size.width - ( padding.start + padding.end ); - newChildSize.height = size.height - ( padding.top + padding.bottom ); + newChildSize.width = size.width - ( padding.start + padding.end ); + newChildSize.height = size.height - ( padding.top + padding.bottom ); - // Cannot use childs Position property as it can already have padding and margin applied on it, - // so we end up cumulatively applying them over and over again. - Vector2 childOffset( 0.f, 0.f ); - childOffset.x += ( mImpl->mMargin.start + padding.start ); - childOffset.y += ( mImpl->mMargin.top + padding.top ); + // Cannot use childs Position property as it can already have padding and margin applied on it, + // so we end up cumulatively applying them over and over again. + Vector2 childOffset( 0.f, 0.f ); + childOffset.x += ( mImpl->mMargin.start + padding.start ); + childOffset.y += ( mImpl->mMargin.top + padding.top ); - child.SetPosition( childOffset.x, childOffset.y ); - } + child.SetPosition( childOffset.x, childOffset.y ); } - - container.Add( child, size ); + container.Add( child, newChildSize ); } Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND ); @@ -708,6 +767,7 @@ void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dime Vector3 Control::GetNaturalSize() { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::GetNaturalSize for %s\n", Self().GetName().c_str() ); Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND ); if( visual ) {