Debug::Filter* gLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_CONTROL_VISUALS");
#endif
-DALI_ENUM_TO_STRING_TABLE_BEGIN( CLIPPING_MODE )
-DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, DISABLED )
-DALI_ENUM_TO_STRING_WITH_SCOPE( ClippingMode, CLIP_CHILDREN )
-DALI_ENUM_TO_STRING_TABLE_END( CLIPPING_MODE )
-
} // unnamed namespace
-
Toolkit::Control Control::New()
{
// Create the implementation, temporarily owned on stack
void Control::SetBackground( const Property::Map& map )
{
Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( map );
+ visual.SetName("background");
if( visual )
{
mImpl->RegisterVisual( Toolkit::Control::Property::BACKGROUND, visual, DepthIndex::BACKGROUND );
}
}
+void Control::CreateClippingRenderer()
+{
+ // We want to add a transparent background if we do not have one for clipping.
+ Actor self( Self() );
+ int clippingMode = ClippingMode::DISABLED;
+ if( self.GetProperty( Actor::Property::CLIPPING_MODE ).Get( clippingMode ) )
+ {
+ if( ( clippingMode != ClippingMode::DISABLED ) &&
+ mImpl->mVisuals.Empty() &&
+ ( self.GetRendererCount() == 0u ) )
+ {
+ SetBackgroundColor( Color::TRANSPARENT );
+ }
+ }
+}
+
void Control::OnStageConnection( int depth )
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::OnStageConnection number of registered visuals(%d)\n", mImpl->mVisuals.Size() );
}
}
- if( mImpl->mVisuals.Empty() && ! self.GetRendererCount() )
- {
- Property::Value clippingValue = self.GetProperty( Actor::Property::CLIPPING_MODE );
- int clippingMode = ClippingMode::DISABLED;
- if( clippingValue.Get( clippingMode ) )
- {
- // Add a transparent background if we do not have any renderers or visuals so we clip our children
-
- if( clippingMode == ClippingMode::CLIP_CHILDREN )
- {
- // Create a transparent background visual which will also get staged.
- SetBackgroundColor( Color::TRANSPARENT );
- }
- }
- }
+ // The clipping renderer is only created if required.
+ CreateClippingRenderer();
}
void Control::OnStageDisconnection()
{
- for(RegisteredVisualContainer::Iterator iter = mImpl->mVisuals.Begin(); iter!= mImpl->mVisuals.End(); iter++)
- {
- // 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 );
- }
- }
+ mImpl->OnStageDisconnection();
}
void Control::OnKeyInputFocusGained()
void Control::OnPropertySet( Property::Index index, Property::Value propertyValue )
{
- Actor self( Self() );
- if( index == Actor::Property::CLIPPING_MODE )
+ // 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() )
{
- // Only set the background if we're already on the stage and have no renderers or visuals
-
- if( mImpl->mVisuals.Empty() && ! self.GetRendererCount() && self.OnStage() )
- {
- ClippingMode::Type clippingMode = ClippingMode::DISABLED;
- if( Scripting::GetEnumerationProperty< ClippingMode::Type >( propertyValue, CLIPPING_MODE_TABLE, CLIPPING_MODE_TABLE_COUNT, clippingMode ) )
- {
- // Add a transparent background if we do not have one so we clip children
-
- if( clippingMode == ClippingMode::CLIP_CHILDREN )
- {
- SetBackgroundColor( Color::TRANSPARENT );
- }
- }
- }
+ // Note: This method will handle whether creation of the renderer is required.
+ CreateClippingRenderer();
}
}