-void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual )
-{
- RegisterVisual( index, visual, true );
-}
-
-void Control::RegisterVisual( Property::Index index, Toolkit::Visual::Base& visual, bool enabled )
-{
- bool visualReplaced ( false );
- Actor self = Self();
-
- 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() )
- {
- Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
- }
- (*iter)->visual = visual;
- visualReplaced = true;
- }
- }
-
- // If not set, set the name of the visual to the same name as the control's property.
- // ( If the control has been type registered )
- if( visual.GetName().empty() )
- {
- // Check if the control has been type registered:
- TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( typeid(*this) );
- if( typeInfo )
- {
- // Check if the property index has been registered:
- Property::IndexContainer indices;
- typeInfo.GetPropertyIndices( indices );
- Property::IndexContainer::Iterator iter = std::find( indices.Begin(), indices.End(), index );
- if( iter != indices.End() )
- {
- // If it has, then get it's name and use that for the visual
- std::string visualName = typeInfo.GetPropertyName( index );
- visual.SetName( visualName );
- }
- }
- }
-
- if( !visualReplaced ) // New registration entry
- {
- mImpl->mVisuals.PushBack( new RegisteredVisual( index, visual, enabled ) );
- }
-
- if( visual && self.OnStage() && enabled )
- {
- Toolkit::GetImplementation(visual).SetOnStage( self );
- }
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::RegisterVisual number of registered visuals(%d)\n", mImpl->mVisuals.Size() );
-
-}
-
-void Control::UnregisterVisual( Property::Index index )
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- Actor self( Self() );
- Toolkit::GetImplementation((*iter)->visual).SetOffStage( self );
- (*iter)->visual.Reset();
- 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 )
- {
- DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Control::EnableVisual Visual Already enabled set (%s) \n", enable?"enabled":"disabled");
- return;
- }
-
- (*iter)->enabled = enable;
- Actor parentActor = Self();
- if ( Self().OnStage() ) // If control not on Stage then Visual will be added when StageConnection is called.
- {
- 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.
- }
- }
- }
-}
-
-bool Control::IsVisualEnabled( Property::Index index ) const
-{
- RegisteredVisualContainer::Iterator iter;
- if ( FindVisual( index, mImpl->mVisuals, iter ) )
- {
- return (*iter)->enabled;
- }
- return false;
-}
-
-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);
- HandleIndex handleIndex;
-
- // Attempt to find the object name as a child actor
- Actor child = Self().FindChildByName( animator->objectName );
- if( child )
- {
- Property::Index propertyIndex = DevelHandle::GetPropertyIndex( child, animator->propertyKey );
- handleIndex = HandleIndex( child, propertyIndex );
- }
- else
- {
- handleIndex = GetVisualProperty( *this, mImpl->mVisuals,
- animator->objectName,
- animator->propertyKey );
- }
-
- if( handleIndex.handle && handleIndex.index != Property::INVALID_INDEX )
- {
- if( animator->animate == false )
- {
- if( animator->targetValue.GetType() != Property::NONE )
- {
- handleIndex.handle.SetProperty( handleIndex.index, animator->targetValue );
- }
- }
- else
- {
- if( animator->initialValue.GetType() != Property::NONE )
- {
- handleIndex.handle.SetProperty( handleIndex.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( handleIndex.handle, handleIndex.index ),
- animator->targetValue,
- animator->alphaFunction,
- TimePeriod( animator->timePeriodDelay,
- animator->timePeriodDuration ) );
- }
- }
- }
- }
-
- return transition;
-}
-