X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fcontrol-impl.cpp;h=664c7e0c71f1d7177f43a4b6ba574cedf4b2b32b;hb=5e110a596a3beb09bc6e2f9ae3d3b68d6a30c72c;hp=49064a824ac2544fb7b41e6cd0f2a0c81d54060b;hpb=57041317889e4c15e314656bb7b4904a3eb95c4a;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 index 49064a8..664c7e0 100755 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -129,46 +129,6 @@ void CreateClippingRenderer( Control& controlImpl ) } } -/** - * @brief Sets Control::Property::BACKGROUND visual - * @param[in] controlImpl The control implementation - * @param[in] visual The control background visual - * @param[in] size The current size - */ -void SetBackgroundVisual( Control::Impl& controlImpl, Toolkit::Visual::Base& visual, const Vector2& size ) -{ - Property::Map transformMap = Property::Map(); - - Vector2 newSize( 0.f, 0.f ); - newSize.width = size.width + ( controlImpl.mPadding.start + controlImpl.mPadding.end ); - newSize.height = size.height + ( controlImpl.mPadding.top + controlImpl.mPadding.bottom ); - - if( ( controlImpl.mMargin.start != 0 ) || - ( controlImpl.mMargin.end != 0 ) || - ( controlImpl.mMargin.top != 0 ) || - ( controlImpl.mMargin.bottom != 0 ) ) - { - transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize ) - .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) ) - .Add( Toolkit::Visual::Transform::Property::OFFSET, Vector2( controlImpl.mMargin.start, controlImpl.mMargin.top ) ) - .Add( Toolkit::Visual::Transform::Property::OFFSET_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) ) - .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) - .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN ); - } - else if( ( controlImpl.mPadding.start != 0 ) || - ( controlImpl.mPadding.end != 0 ) || - ( controlImpl.mPadding.top != 0 ) || - ( controlImpl.mPadding.bottom != 0 ) ) - { - transformMap.Add( Toolkit::Visual::Transform::Property::SIZE, newSize ) - .Add( Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2( Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE ) ) - .Add( Toolkit::Visual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) - .Add( Toolkit::Visual::Transform::Property::ANCHOR_POINT, Toolkit::Align::TOP_BEGIN ); - } - - visual.SetTransformAndSize( transformMap, newSize ); // Send an empty map as we do not want to modify the visual's set transform -} - } // unnamed namespace @@ -465,13 +425,15 @@ bool Control::EmitKeyEventSignal( const KeyEvent& event ) bool consumed = false; + consumed = mImpl->FilterKeyEvent( event ); + // signals are allocated dynamically when someone connects - if ( !mImpl->mKeyEventSignal.Empty() ) + if ( !consumed && !mImpl->mKeyEventSignal.Empty() ) { consumed = mImpl->mKeyEventSignal.Emit( handle, event ); } - if (!consumed) + if ( !consumed ) { // Notification for derived classes consumed = OnKeyEvent(event); @@ -657,8 +619,7 @@ void Control::OnSizeSet(const Vector3& targetSize) if( visual ) { Vector2 size( targetSize ); - SetBackgroundVisual( *mImpl, visual, size ); - + visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform } } @@ -694,39 +655,50 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) Actor child = Self().GetChildAt( i ); Vector2 newChildSize( size ); - // When set the padding or margin on the control, child should be resized and repositioned. + // When setting the padding or margin on the control child should be resized and repositioned for legacy reasons. 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 ) ) { - Extents padding = mImpl->mPadding; - - Dali::CustomActor ownerActor(GetOwner()); - Dali::LayoutDirection::Type layoutDirection = static_cast( ownerActor.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); + // 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( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection ) + // 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 ) ) { - std::swap( padding.start, padding.end ); - } + Extents padding = mImpl->mPadding; - newChildSize.width = size.width - ( padding.start + padding.end ); - newChildSize.height = size.height - ( padding.top + padding.bottom ); + Dali::CustomActor ownerActor(GetOwner()); + Dali::LayoutDirection::Type layoutDirection = static_cast( ownerActor.GetProperty( Dali::Actor::Property::LAYOUT_DIRECTION ).Get() ); - // 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 ); + if( Dali::LayoutDirection::RIGHT_TO_LEFT == layoutDirection ) + { + std::swap( padding.start, padding.end ); + } - child.SetPosition( childOffset.x, childOffset.y ); + // 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 ); + + // 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 ); + } } - container.Add( child, newChildSize ); + container.Add( child, size ); } Toolkit::Visual::Base visual = mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND ); if( visual ) { - SetBackgroundVisual( *mImpl, visual, size ); + visual.SetTransformAndSize( Property::Map(), size ); // Send an empty map as we do not want to modify the visual's set transform } }