X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fcontrol%2Fcontrol-data-impl.cpp;h=6c5de97b049c102924ef5e748aefdaa705e5644d;hb=49d793abda445643e4b3b270c10af70aed3d2f52;hp=73769c8f5e4ee61a6fbd1c22453656e08e7c9497;hpb=a2a0b8577e0a8ac8f2c5180fe0557c68a069fdaa;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 73769c8..6c5de97 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) 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. @@ -298,8 +298,6 @@ void SetVisualsOffStage( const RegisteredVisualContainer& container, Actor paren // Properties registered without macro to use specific member variables. const PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "styleName", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "backgroundColor", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); -const PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "backgroundImage", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background", Toolkit::Control::Property::BACKGROUND, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "margin", Toolkit::Control::Property::MARGIN, Property::EXTENTS, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); @@ -311,13 +309,13 @@ const PropertyRegistration Control::Impl::PROPERTY_11( typeRegistration, "leftFo const PropertyRegistration Control::Impl::PROPERTY_12( typeRegistration, "rightFocusableActorId", Toolkit::DevelControl::Property::RIGHT_FOCUSABLE_ACTOR_ID,Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_13( typeRegistration, "upFocusableActorId", Toolkit::DevelControl::Property::UP_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); const PropertyRegistration Control::Impl::PROPERTY_14( typeRegistration, "downFocusableActorId", Toolkit::DevelControl::Property::DOWN_FOCUSABLE_ACTOR_ID, Property::INTEGER, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); +const PropertyRegistration Control::Impl::PROPERTY_15( typeRegistration, "shadow", Toolkit::DevelControl::Property::SHADOW, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty ); Control::Impl::Impl( Control& controlImpl ) : mControlImpl( controlImpl ), mState( Toolkit::DevelControl::NORMAL ), mSubStateName(""), - mLayout( NULL ), mLeftFocusableActorId( -1 ), mRightFocusableActorId( -1 ), mUpFocusableActorId( -1 ), @@ -331,6 +329,7 @@ Control::Impl::Impl( Control& controlImpl ) mKeyInputFocusGainedSignal(), mKeyInputFocusLostSignal(), mResourceReadySignal(), + mVisualEventSignal(), mPinchGestureDetector(), mPanGestureDetector(), mTapGestureDetector(), @@ -433,7 +432,7 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base StopObservingVisual( currentRegisteredVisual ); // If control staged and visual enabled then visuals will be swapped once ready - if( self.OnStage() && enabled ) + if( self.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) && enabled ) { // Check if visual is currently in the process of being replaced ( is in removal container ) RegisteredVisualContainer::Iterator visualQueuedForRemoval; @@ -473,19 +472,13 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base // ( If the control has been type registered ) if( visual.GetName().empty() ) { - try + // returns empty string if index is not found as long as index is not -1 + std::string visualName = self.GetPropertyName( index ); + if( !visualName.empty() ) { - 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 ) - { - 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 ); } } @@ -529,7 +522,7 @@ void Control::Impl::RegisterVisual( Property::Index index, Toolkit::Visual::Base Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual ); // Put on stage if enabled and the control is already on the stage - if( ( enabled == VisualState::ENABLED ) && self.OnStage() ) + if( ( enabled == VisualState::ENABLED ) && self.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) ) { visualImpl.SetOnStage( self ); } @@ -593,7 +586,7 @@ void Control::Impl::EnableVisual( Property::Index index, bool enable ) (*iter)->enabled = enable; Actor parentActor = mControlImpl.Self(); - if ( mControlImpl.Self().OnStage() ) // If control not on Stage then Visual will be added when StageConnection is called. + if ( mControlImpl.Self().GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) ) // If control not on Stage then Visual will be added when StageConnection is called. { if ( enable ) { @@ -628,15 +621,15 @@ void Control::Impl::StopObservingVisual( Toolkit::Visual::Base& visual ) Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual ); // Stop observing the visual - visualImpl.RemoveResourceObserver( *this ); + visualImpl.RemoveEventObserver( *this ); } void Control::Impl::StartObservingVisual( Toolkit::Visual::Base& visual) { Internal::Visual::Base& visualImpl = Toolkit::GetImplementation( visual ); - // start observing the visual for resource ready - visualImpl.AddResourceObserver( *this ); + // start observing the visual for events + visualImpl.AddEventObserver( *this ); } // Called by a Visual when it's resource is ready @@ -669,7 +662,7 @@ void Control::Impl::ResourceReady( Visual::Base& object) } // A visual is ready so control may need relayouting if staged - if ( self.OnStage() ) + if ( self.GetProperty< bool >( Actor::Property::CONNECTED_TO_SCENE ) ) { mControlImpl.RelayoutRequest(); } @@ -682,6 +675,20 @@ void Control::Impl::ResourceReady( Visual::Base& object) } } +void Control::Impl::NotifyVisualEvent( Visual::Base& object, Property::Index signalId ) +{ + for( auto registeredIter = mVisuals.Begin(), end = mVisuals.End(); registeredIter != end; ++registeredIter ) + { + Internal::Visual::Base& registeredVisualImpl = Toolkit::GetImplementation( (*registeredIter)->visual ); + if( &object == ®isteredVisualImpl ) + { + Dali::Toolkit::Control handle( mControlImpl.GetOwner() ); + mVisualEventSignal.Emit( handle, (*registeredIter)->index, signalId ); + break; + } + } +} + bool Control::Impl::IsResourceReady() const { // Iterate through and check all the enabled visuals are ready @@ -901,29 +908,6 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons } break; - case Toolkit::Control::Property::BACKGROUND_COLOR: - { - DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" ); - controlImpl.SetBackgroundColor( value.Get< Vector4 >() ); - break; - } - - case Toolkit::Control::Property::BACKGROUND_IMAGE: - { - DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" ); - Image image = Scripting::NewImage( value ); - if ( image ) - { - controlImpl.SetBackgroundImage( image ); - } - else - { - // An empty image means the background is no longer required - controlImpl.ClearBackground(); - } - break; - } - case Toolkit::Control::Property::KEY_INPUT_FOCUS: { if ( value.Get< bool >() ) @@ -998,6 +982,21 @@ void Control::Impl::SetProperty( BaseObject* object, Property::Index index, cons break; } + case Toolkit::DevelControl::Property::SHADOW: + { + const Property::Map* map = value.GetMap(); + if( map && !map->Empty() ) + { + controlImpl.mImpl->SetShadow( *map ); + } + else + { + // The shadow is an empty property map, so we should clear the shadow + controlImpl.mImpl->ClearShadow(); + } + break; + } + } } } @@ -1056,26 +1055,6 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index break; } - case Toolkit::Control::Property::BACKGROUND_COLOR: - { - DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" ); - value = controlImpl.GetBackgroundColor(); - break; - } - - case Toolkit::Control::Property::BACKGROUND_IMAGE: - { - DALI_LOG_WARNING( "BACKGROUND_IMAGE property is deprecated. Use BACKGROUND property instead\n" ); - Property::Map map; - Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::Control::Property::BACKGROUND ); - if( visual ) - { - visual.CreatePropertyMap( map ); - } - value = map; - break; - } - case Toolkit::Control::Property::KEY_INPUT_FOCUS: { value = controlImpl.HasKeyInputFocus(); @@ -1117,6 +1096,19 @@ Property::Value Control::Impl::GetProperty( BaseObject* object, Property::Index value = map; break; } + + case Toolkit::DevelControl::Property::SHADOW: + { + Property::Map map; + Toolkit::Visual::Base visual = controlImpl.mImpl->GetVisual( Toolkit::DevelControl::Property::SHADOW ); + if( visual ) + { + visual.CreatePropertyMap( map ); + } + + value = map; + break; + } } } @@ -1391,6 +1383,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 @@ -1401,6 +1396,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 @@ -1424,22 +1422,30 @@ bool Control::Impl::FilterKeyEvent( const KeyEvent& event ) return consumed; } -Toolkit::Internal::LayoutItemPtr Control::Impl::GetLayout() const +DevelControl::VisualEventSignalType& Control::Impl::VisualEventSignal() { - return mLayout; + return mVisualEventSignal; } -void Control::Impl::SetLayout( Toolkit::Internal::LayoutItem& layout ) +void Control::Impl::SetShadow( const Property::Map& map ) { - if( mLayout ) + Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map ); + visual.SetName("shadow"); + + if( visual ) { - mLayout->Unparent(); - mLayout.Reset(); + mControlImpl.mImpl->RegisterVisual( Toolkit::DevelControl::Property::SHADOW, visual, DepthIndex::BACKGROUND_EFFECT ); + + mControlImpl.RelayoutRequest(); } - mLayout = &layout; +} + +void Control::Impl::ClearShadow() +{ + mControlImpl.mImpl->UnregisterVisual( Toolkit::DevelControl::Property::SHADOW ); - 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 + // Trigger a size negotiation request that may be needed when unregistering a visual. + mControlImpl.RelayoutRequest(); } } // namespace Internal