+ void SetState( DevelControl::State state, bool withTransitions=true )
+ {
+ if( mState != state )
+ {
+ // If mState was Disabled, and new state is Focused, should probably
+ // store that fact, e.g. in another property that FocusManager can access.
+ mState = state;
+
+ // Trigger state change and transitions
+ // Apply new style, if stylemanager is available
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ if( styleManager )
+ {
+ const StylePtr stylePtr = GetImpl( styleManager ).GetRecordedStyle( Toolkit::Control( mControlImpl.GetOwner() ) );
+ if( stylePtr )
+ {
+ for( int i=mVisuals.Count()-1; i >= 0; i-- )
+ {
+ mControlImpl.UnregisterVisual( mVisuals[i]->index );
+ }
+
+ Dali::CustomActor handle( mControlImpl.GetOwner() );
+ stylePtr->ApplyVisualsAndPropertiesRecursively( handle );
+ }
+ }
+ }
+ }
+
+ void SetSubState( const std::string& subStateName, bool withTransitions=true )
+ {
+ if( mSubStateName != subStateName )
+ {
+ // Get existing sub-state visuals, and unregister them
+ Dali::CustomActor handle( mControlImpl.GetOwner() );
+
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ if( styleManager )
+ {
+ const StylePtr stylePtr = GetImpl( styleManager ).GetRecordedStyle( Toolkit::Control( mControlImpl.GetOwner() ) );
+ if( stylePtr )
+ {
+ // Stringify state
+ std::string stateName = Scripting::GetEnumerationName< Toolkit::DevelControl::State >( mState, ControlStateTable, ControlStateTableCount );
+
+ const StylePtr* state = stylePtr->subStates.Find( stateName );
+ if( state )
+ {
+ StylePtr stateStyle(*state);
+
+ // Unregister existing visuals of this substate
+ const StylePtr* subState = stateStyle->subStates.Find( mSubStateName );
+ if( subState )
+ {
+ StylePtr subStateStyle(*subState);
+
+ for( Dictionary<Property::Map>::iterator iter = subStateStyle->visuals.Begin(); iter != subStateStyle->visuals.End(); ++iter )
+ {
+ const std::string& visualName = (*iter).key;
+ Dali::Property::Index index = handle.GetPropertyIndex( visualName );
+ if( index != Property::INVALID_INDEX )
+ {
+ mControlImpl.UnregisterVisual( index );
+ }
+ }
+ }
+
+ // Register visuals of the new substate
+ const StylePtr* newSubState = stateStyle->subStates.Find( subStateName );
+ if( newSubState )
+ {
+ StylePtr newSubStateStyle(*newSubState);
+ newSubStateStyle->ApplyVisuals( handle );
+ newSubStateStyle->ApplyProperties( handle );
+ }
+ }
+ }
+ }
+
+ mSubStateName = subStateName;
+ }
+ }
+