X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fcontrol%2Fcontrol-data-impl.cpp;h=5e94e8f4a33aee4daf994133241fc462528fd81c;hb=refs%2Fchanges%2F59%2F194459%2F2;hp=5619cd9d696fbd76b382478e5d8bd106fba1ba16;hpb=35ee945a45d0f0d2db4a3db2e66074bf2926b1ab;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/control/control-data-impl.cpp b/dali-toolkit/internal/controls/control/control-data-impl.cpp index 5619cd9..5e94e8f 100755 --- a/dali-toolkit/internal/controls/control/control-data-impl.cpp +++ b/dali-toolkit/internal/controls/control/control-data-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. @@ -19,7 +19,7 @@ #include "control-data-impl.h" // EXTERNAL INCLUDES -#include +#include #include #include #include @@ -31,13 +31,15 @@ // INTERNAL INCLUDES #include -#include -#include #include #include -#include +#include #include #include +#include +#include +#include +#include namespace Dali { @@ -67,6 +69,7 @@ namespace #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS"); +Debug::Filter* gLogFilterLayout = Debug::Filter::New( Debug::NoLogging, false, "LOG_LAYOUT"); #endif @@ -317,6 +320,7 @@ Control::Impl::Impl( Control& controlImpl ) : mControlImpl( controlImpl ), mState( Toolkit::DevelControl::NORMAL ), mSubStateName(""), + mLayout( NULL ), mLeftFocusableActorId( -1 ), mRightFocusableActorId( -1 ), mUpFocusableActorId( -1 ), @@ -334,9 +338,12 @@ Control::Impl::Impl( Control& controlImpl ) mPanGestureDetector(), mTapGestureDetector(), mLongPressGestureDetector(), + mTooltip( NULL ), + mInputMethodContext(), mFlags( Control::ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mIsKeyboardNavigationSupported( false ), - mIsKeyboardFocusGroup( false ) + mIsKeyboardFocusGroup( false ), + mIsLayoutingRequired( false ) { } @@ -470,19 +477,13 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base // ( If the control has been type registered ) if( visual.GetName().empty() ) { - try - { - std::string visualName = self.GetPropertyName( index ); - if( !visualName.empty() ) - { - DALI_LOG_INFO( gLogFilter, Debug::Concise, "Setting visual name for property %d to %s\n", - index, visualName.c_str() ); - visual.SetName( visualName ); - } - } - catch( Dali::DaliException e ) + // returns empty string if index is not found as long as index is not -1 + std::string visualName = self.GetPropertyName( index ); + if( !visualName.empty() ) { - DALI_LOG_WARNING( "Attempting to register visual without a registered property, index: %d\n", index ); + DALI_LOG_INFO( gLogFilter, Debug::Concise, "Setting visual name for property %d to %s\n", + index, visualName.c_str() ); + visual.SetName( visualName ); } } @@ -577,7 +578,7 @@ Toolkit::Visual::Base Control::Impl::GetVisual( Property::Index index ) const void Control::Impl::EnableVisual( Property::Index index, bool enable ) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual (%d)\n", index); + DALI_LOG_INFO( gLogFilter, Debug::General, "Control::EnableVisual(%d, %s)\n", index, enable?"T":"F"); RegisteredVisualContainer::Iterator iter; if ( FindVisual( index, mVisuals, iter ) ) @@ -604,6 +605,10 @@ void Control::Impl::EnableVisual( Property::Index index, bool enable ) } } } + else + { + DALI_LOG_WARNING( "Control::EnableVisual(%d, %s) FAILED - NO SUCH VISUAL\n", index, enable?"T":"F" ); + } } bool Control::Impl::IsVisualEnabled( Property::Index index ) const @@ -635,7 +640,7 @@ void Control::Impl::StartObservingVisual( Toolkit::Visual::Base& visual) // Called by a Visual when it's resource is ready void Control::Impl::ResourceReady( Visual::Base& object) { - DALI_LOG_INFO( gLogFilter, Debug::Verbose, "ResourceReady replacements pending[%d]\n", mRemoveVisuals.Count() ); + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::Impl::ResourceReady() replacements pending[%d]\n", mRemoveVisuals.Count() ); Actor self = mControlImpl.Self(); @@ -706,83 +711,92 @@ Toolkit::Visual::ResourceStatus Control::Impl::GetVisualResourceStatus( Property return Toolkit::Visual::ResourceStatus::PREPARING; } -Dali::Animation Control::Impl::CreateTransition( const Toolkit::TransitionData& handle ) + + +void Control::Impl::AddTransitions( Dali::Animation& animation, + const Toolkit::TransitionData& handle, + bool createAnimation ) { - Dali::Animation transition; + // Setup a Transition from TransitionData. const Internal::TransitionData& transitionData = Toolkit::GetImplementation( handle ); - - if( transitionData.Count() > 0 ) + TransitionData::Iterator end = transitionData.End(); + for( TransitionData::Iterator iter = transitionData.Begin() ; + iter != end; ++iter ) { - // Setup a Transition from TransitionData. - TransitionData::Iterator end = transitionData.End(); - for( TransitionData::Iterator iter = transitionData.Begin() ; - iter != end; ++iter ) - { - TransitionData::Animator* animator = (*iter); + TransitionData::Animator* animator = (*iter); - Toolkit::Visual::Base visual = GetVisualByName( mVisuals, animator->objectName ); + Toolkit::Visual::Base visual = GetVisualByName( mVisuals, animator->objectName ); - if( visual ) - { + if( visual ) + { #if defined(DEBUG_ENABLED) - Dali::TypeInfo typeInfo; - ControlWrapper* controlWrapperImpl = dynamic_cast(&mControlImpl); - if( controlWrapperImpl ) - { - typeInfo = controlWrapperImpl->GetTypeInfo(); - } + Dali::TypeInfo typeInfo; + ControlWrapper* controlWrapperImpl = dynamic_cast(&mControlImpl); + if( controlWrapperImpl ) + { + typeInfo = controlWrapperImpl->GetTypeInfo(); + } - DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Found %s visual for %s\n", - visual.GetName().c_str(), typeInfo?typeInfo.GetName().c_str():"Unknown" ); + DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Found %s visual for %s\n", + visual.GetName().c_str(), typeInfo?typeInfo.GetName().c_str():"Unknown" ); #endif - Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual ); - - visualImpl.AnimateProperty( transition, *animator ); - } - else + Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual ); + visualImpl.AnimateProperty( animation, *animator ); + } + else + { + DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Could not find visual. Trying actors"); + // Otherwise, try any actor children of control (Including the control) + Actor child = mControlImpl.Self().FindChildByName( animator->objectName ); + if( child ) { - DALI_LOG_INFO( gLogFilter, Debug::Concise, "CreateTransition: Could not find visual. Trying actors"); - // Otherwise, try any actor children of control (Including the control) - Actor child = mControlImpl.Self().FindChildByName( animator->objectName ); - if( child ) + Property::Index propertyIndex = DevelHandle::GetPropertyIndex( child, animator->propertyKey ); + if( propertyIndex != Property::INVALID_INDEX ) { - Property::Index propertyIndex = DevelHandle::GetPropertyIndex( child, animator->propertyKey ); - if( propertyIndex != Property::INVALID_INDEX ) + if( animator->animate == false ) { - if( animator->animate == false ) + if( animator->targetValue.GetType() != Property::NONE ) { - if( animator->targetValue.GetType() != Property::NONE ) - { - child.SetProperty( propertyIndex, animator->targetValue ); - } + child.SetProperty( propertyIndex, animator->targetValue ); } - else // animate the property + } + else // animate the property + { + if( animator->initialValue.GetType() != Property::NONE ) + { + child.SetProperty( propertyIndex, animator->initialValue ); + } + + if( createAnimation && !animation ) { - if( animator->initialValue.GetType() != Property::NONE ) - { - child.SetProperty( propertyIndex, animator->initialValue ); - } - - if( ! transition ) - { - transition = Dali::Animation::New( 0.1f ); - } - - transition.AnimateTo( Property( child, propertyIndex ), - animator->targetValue, - animator->alphaFunction, - TimePeriod( animator->timePeriodDelay, - animator->timePeriodDuration ) ); + animation = Dali::Animation::New( 0.1f ); } + + animation.AnimateTo( Property( child, propertyIndex ), + animator->targetValue, + animator->alphaFunction, + TimePeriod( animator->timePeriodDelay, + animator->timePeriodDuration ) ); } } } } } +} +Dali::Animation Control::Impl::CreateTransition( const Toolkit::TransitionData& transitionData ) +{ + Dali::Animation transition; + + if( transitionData.Count() > 0 ) + { + AddTransitions( transition, transitionData, true ); + } return transition; } + + void Control::Impl::DoAction( Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes ) { RegisteredVisualContainer::Iterator iter; @@ -1375,6 +1389,9 @@ void Control::Impl::OnStageDisconnection() void Control::Impl::SetMargin( Extents margin ) { mControlImpl.mImpl->mMargin = margin; + + // Trigger a size negotiation request that may be needed when setting a margin. + mControlImpl.RelayoutRequest(); } Extents Control::Impl::GetMargin() const @@ -1385,6 +1402,9 @@ Extents Control::Impl::GetMargin() const void Control::Impl::SetPadding( Extents padding ) { mControlImpl.mImpl->mPadding = padding; + + // Trigger a size negotiation request that may be needed when setting a padding. + mControlImpl.RelayoutRequest(); } Extents Control::Impl::GetPadding() const @@ -1408,6 +1428,67 @@ bool Control::Impl::FilterKeyEvent( const KeyEvent& event ) return consumed; } +Toolkit::Internal::LayoutItemPtr Control::Impl::GetLayout() const +{ + return mLayout; +} + +void Control::Impl::SetLayout( Toolkit::Internal::LayoutItem& layout ) +{ + DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout control:%s replacing existing layout:%s\n", + mControlImpl.Self().GetName().c_str(), + mLayout?"true":"false" ); + // Check if layout already has an owner. + auto control = Toolkit::Control::DownCast( layout.GetOwner() ); + if ( control ) + { + // If the owner is not this control then the owning control can no longer own it. + Dali::Toolkit::Control handle( mControlImpl.GetOwner() ); + if( control != handle ) + { + DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::SetLayout Layout already in use, %s will now have a BinLayout\n", + control.GetName().c_str() ); + Toolkit::BinLayout binLayout = Toolkit::BinLayout::New(); + // Previous owner of the layout gets a BinLayout instead of the layout. + DevelControl::SetLayout( control, binLayout ) ; + } + else + { + return; // layout is already set to this control. + } + } + + if( mLayout ) + { + mLayout->Unparent(); + mLayout.Reset(); + } + + mLayout = &layout; + + auto controlHandle = Toolkit::Control::DownCast( mControlImpl.Self() ); // Get a handle of this control implementation without copying internals. + mLayout->Initialize( controlHandle, controlHandle.GetTypeName() ); // LayoutGroup takes ownership of existing children +} + +void Control::Impl::RemoveLayout() +{ + DALI_LOG_INFO( gLogFilterLayout, Debug::Verbose, "Control::Impl::RemoveLayout\n"); + + Toolkit::BinLayout binLayout = Toolkit::BinLayout::New(); + + mControlImpl.mImpl->SetLayout( GetImplementation( binLayout ) ) ; +} + +void Control::Impl::SetLayoutingRequired( bool layoutingRequired ) +{ + mControlImpl.mImpl->mIsLayoutingRequired = layoutingRequired; +} + +bool Control::Impl::IsLayoutingRequired() +{ + return mControlImpl.mImpl->mIsLayoutingRequired; +} + } // namespace Internal } // namespace Toolkit