-void Control::RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual )
-{
- RegisterVisual( index, placementActor, visual, true );
-}
-
-void Control::RegisterVisual( Property::Index index, Actor& placementActor, Toolkit::Visual::Base& visual, bool enabled )
-{
- bool visualReplaced ( false );
- Actor actorToRegister; // Null actor, replaced if placement actor not Self
- Actor self = Self();
-
- if ( placementActor != self ) // Prevent increasing ref count if actor self
- {
- actorToRegister = placementActor;
- }
-
- if ( !mImpl->mVisuals.Empty() )
- {
- 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)->placementActor )
- {
- (*iter)->visual.SetOffStage( (*iter)->placementActor );
- }
- else
- {
- (*iter)->visual.SetOffStage( self );
- }
- }
- (*iter)->visual = visual;
- (*iter)->placementActor = actorToRegister;
- visualReplaced = true;
- }
- }
-
- if ( !visualReplaced ) // New registration entry
- {
- mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, actorToRegister, enabled ) );
- }
-
- if( visual && self.OnStage() && enabled )
- {
- visual.SetOnStage( placementActor );
- }
-}
-
-void Control::UnregisterVisual( Property::Index index )
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- mImpl->mVisuals.Erase( iter );
- }
-}
-
-Toolkit::Visual::Base Control::GetVisual( Property::Index index ) const
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- return (*iter)->visual;
- }
-
- return Toolkit::Visual::Base();
-}
-
-void Control::EnableVisual( Property::Index index, bool enable )
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- if ( (*iter)->enabled == enable )
- {
- return;
- }
-
- (*iter)->enabled = enable;
- Actor parentActor = Self();
- if ( (*iter)->placementActor )
- {
- parentActor = (*iter)->placementActor;
- }
-
- if ( Self().OnStage() ) // If control not on Stage then Visual will be added when StageConnection is called.
- {
- if ( enable )
- {
-
- (*iter)->visual.SetOnStage( parentActor );
- }
- else
- {
- (*iter)->visual.SetOffStage( parentActor ); // No need to call if control not staged.
- }
- }
- }
-}
-
-bool Control::IsVisualEnabled( Property::Index index ) const
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- return (*iter)->enabled;
- }
- return false;
-}
-
-Actor Control::GetPlacementActor( Property::Index index ) const
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- if( (*iter)->placementActor )
- {
- return (*iter)->placementActor;
- }
- else
- {
- return Self();
- }
- }
-
- return Actor();
-}
-
-Dali::Animation Control::CreateTransition( const Toolkit::TransitionData& handle )
-{
- Dali::Animation transition;
- const Internal::TransitionData& transitionData = Toolkit::GetImplementation( handle );
-
- if( transitionData.Count() > 0 )
- {
- // Setup a Transition from TransitionData.
- TransitionData::Iterator end = transitionData.End();
- for( TransitionData::Iterator iter = transitionData.Begin() ;
- iter != end; ++iter )
- {
- TransitionData::Animator* animator = (*iter);
- VisualProperty visualProperty;
-
- // Attempt to find the object name as a child actor
- Actor child = Self().FindChildByName( animator->objectName );
- if( child )
- {
- Property::Index propertyIndex = child.GetPropertyIndex( animator->propertyKey );
- visualProperty = VisualProperty( child, propertyIndex );
- }
- else
- {
- // Is it a placement actor/visual pair?;
- visualProperty = GetVisualProperty( *this, mImpl->mVisuals,
- animator->objectName,
- animator->propertyKey );
- }
-
- if( visualProperty.handle && visualProperty.index != Property::INVALID_INDEX )
- {
- if( animator->animate == false )
- {
- if( animator->targetValue.GetType() != Property::NONE )
- {
- visualProperty.handle.SetProperty( visualProperty.index, animator->targetValue );
- }
- }
- else
- {
- if( animator->initialValue.GetType() != Property::NONE )
- {
- visualProperty.handle.SetProperty( visualProperty.index, animator->initialValue );
- }
-
- if( ! transition )
- {
- // Create an animation with a default .1 second duration - the animators
- // will automatically force it to the 'right' duration.
- transition = Dali::Animation::New( 0.1f );
- }
-
- transition.AnimateTo( Property( visualProperty.handle, visualProperty.index ),
- animator->targetValue,
- animator->alphaFunction,
- TimePeriod( animator->timePeriodDelay,
- animator->timePeriodDuration ) );
- }
- }
- }
- }
-
- return transition;
-}
-
-