X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Fpublic-api%2Fcontrols%2Fcontrol-impl.cpp;h=2bc13bed5ebfac45ec4c8ebf9b3db918cd618217;hp=a01cc5e0788264b1d1709ab868691ad613f30750;hb=c8c89602dd8734c4fba423047b6a07c7c005b423;hpb=f871dce5373ce3d4f414963a68505eefc0d49cd2 diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index a01cc5e..2bc13be 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -38,12 +38,13 @@ #include #include #include -#include +#include #include #include #include #include #include +#include namespace Dali { @@ -165,6 +166,16 @@ HandleIndex GetVisualProperty( return HandleIndex( handle, Property::INVALID_INDEX ); } +void SetDefaultTransform( Property::Map& propertyMap ) +{ + propertyMap.Clear(); + propertyMap + .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, Vector2(0.0f, 0.0f) ) + .Add( Toolkit::DevelVisual::Transform::Property::SIZE, Vector2(1.0f, 1.0f) ) + .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::CENTER ) + .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, Toolkit::Align::CENTER ) + .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4::ZERO ); +} /** * Creates control through type registry @@ -531,11 +542,6 @@ Toolkit::Control Control::New() return handle; } -Control::~Control() -{ - delete mImpl; -} - void Control::SetStyleName( const std::string& styleName ) { if( styleName != mImpl->mStyleName ) @@ -560,7 +566,7 @@ void Control::SetBackgroundColor( const Vector4& color ) { mImpl->mBackgroundColor = color; Property::Map map; - map[ Toolkit::VisualProperty::TYPE ] = Toolkit::Visual::COLOR; + map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::COLOR; map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color; SetBackground( map ); @@ -747,22 +753,22 @@ void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visu bool visualReplaced ( false ); Actor self = Self(); - if ( !mImpl->mVisuals.Empty() ) + if( !mImpl->mVisuals.Empty() ) { - RegisteredVisualContainer::Iterator iter; - // Check if visual (index) is already registered. Replace if so. - if ( FindVisual( index, mImpl->mVisuals, iter ) ) + RegisteredVisualContainer::Iterator iter; + // Check if visual (index) is already registered. Replace if so. + if ( FindVisual( index, mImpl->mVisuals, iter ) ) + { + if( (*iter)->visual && self.OnStage() ) { - if( (*iter)->visual && self.OnStage() ) - { - Toolkit::GetImplementation((*iter)->visual).SetOffStage( self ); - } - (*iter)->visual = visual; - visualReplaced = true; + Toolkit::GetImplementation((*iter)->visual).SetOffStage( self ); } + (*iter)->visual = visual; + visualReplaced = true; + } } - if ( !visualReplaced ) // New registration entry + if( !visualReplaced ) // New registration entry { mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) ); } @@ -803,6 +809,7 @@ void Control::EnableVisual( Property::Index index, bool enable ) { if ( (*iter)->enabled == enable ) { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual Already enabled set (%s) \n", enable?"enabled":"disabled"); return; } @@ -812,11 +819,12 @@ void Control::EnableVisual( Property::Index index, bool enable ) { if ( enable ) { - + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting Visual(%d) on stage \n", index ); Toolkit::GetImplementation((*iter)->visual).SetOnStage( parentActor ); } else { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Setting Visual(%d) off stage \n", index ); Toolkit::GetImplementation((*iter)->visual).SetOffStage( parentActor ); // No need to call if control not staged. } } @@ -981,6 +989,11 @@ Control::Control( ControlBehaviour behaviourFlags ) mImpl->mFlags = behaviourFlags; } +Control::~Control() +{ + delete mImpl; +} + void Control::Initialize() { // Call deriving classes so initialised before styling is applied to them. @@ -1084,11 +1097,14 @@ void Control::EmitKeyInputFocusSignal( bool focusGained ) void Control::OnStageConnection( int depth ) { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection number of registered visuals(%d)\n", mImpl->mVisuals.Size() ); + for(RegisteredVisualContainer::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++) { // Check whether the visual is empty and enabled if( (*iter)->visual && (*iter)->enabled ) { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection Setting visual(%d) on stage\n", (*iter)->index ); Actor self( Self() ); Toolkit::GetImplementation((*iter)->visual).SetOnStage( self ); } @@ -1102,6 +1118,7 @@ void Control::OnStageDisconnection() // Check whether the visual is empty if( (*iter)->visual ) { + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageDisconnection Setting visual(%d) off stage\n", (*iter)->index ); Actor self( Self() ); Toolkit::GetImplementation((*iter)->visual).SetOffStage( self ); } @@ -1136,7 +1153,9 @@ void Control::OnSizeSet(const Vector3& targetSize) if( visual ) { Vector2 size( targetSize ); - visual.SetSize( size ); + Property::Map transformMap; + SetDefaultTransform( transformMap ); + visual.SetTransformAndSize( transformMap, size ); } } @@ -1171,6 +1190,15 @@ void Control::OnRelayout( const Vector2& size, RelayoutContainer& container ) { container.Add( Self().GetChildAt( i ), size ); } + + Toolkit::Visual::Base visual = GetVisual( Toolkit::Control::Property::BACKGROUND ); + if( visual ) + { + Vector2 controlSize( size ); + Property::Map transformMap; + SetDefaultTransform( transformMap ); + visual.SetTransformAndSize( transformMap, controlSize ); + } } void Control::OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )