namespace Dali
{
+extern bool CaseInsensitiveStringCompare( const std::string& a, const std::string& b );
namespace Toolkit
{
+namespace Internal
+{
+
+extern const Dali::Scripting::StringEnum ControlStateTable[];
+extern const unsigned int ControlStateTableCount;
+
+
+// Not static or anonymous - shared with other translation units
+const Scripting::StringEnum ControlStateTable[] = {
+ { "NORMAL", Toolkit::DevelControl::NORMAL },
+ { "FOCUSED", Toolkit::DevelControl::FOCUSED },
+ { "DISABLED", Toolkit::DevelControl::DISABLED },
+}; const unsigned int ControlStateTableCount = sizeof( ControlStateTable ) / sizeof( ControlStateTable[0] );
+
+} // Internal namespace
+
namespace
{
// Construction & Destruction
Impl(Control& controlImpl)
: mControlImpl( controlImpl ),
+ mState( Toolkit::DevelControl::NORMAL ),
+ mSubStateName(""),
mStyleName(""),
mBackgroundColor(Color::TRANSPARENT),
mStartingPinchScale( NULL ),
break;
}
+ case Toolkit::DevelControl::Property::STATE:
+ {
+ bool withTransitions=true;
+ const Property::Value* valuePtr=&value;
+ Property::Map* map = value.GetMap();
+ if(map)
+ {
+ Property::Value* value2 = map->Find("withTransitions");
+ if( value2 )
+ {
+ withTransitions = value2->Get<bool>();
+ }
+
+ valuePtr = map->Find("state");
+ }
+
+ if( valuePtr )
+ {
+ Toolkit::DevelControl::State state( controlImpl.mImpl->mState );
+ if( Scripting::GetEnumerationProperty< Toolkit::DevelControl::State >( *valuePtr, ControlStateTable, ControlStateTableCount, state ) )
+ {
+ controlImpl.mImpl->SetState( state, withTransitions );
+ }
+ }
+ }
+ break;
+
+ case Toolkit::DevelControl::Property::SUB_STATE:
+ {
+ std::string subState;
+ if( value.Get( subState ) )
+ {
+ controlImpl.mImpl->SetSubState( subState );
+ }
+ }
+ break;
+
case Toolkit::Control::Property::BACKGROUND_COLOR:
{
DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
break;
}
+ case Toolkit::DevelControl::Property::STATE:
+ {
+ value = controlImpl.mImpl->mState;
+ break;
+ }
+
+ case Toolkit::DevelControl::Property::SUB_STATE:
+ {
+ value = controlImpl.mImpl->mSubStateName;
+ break;
+ }
+
case Toolkit::Control::Property::BACKGROUND_COLOR:
{
DALI_LOG_WARNING( "BACKGROUND_COLOR property is deprecated. Use BACKGROUND property instead\n" );
return value;
}
+ 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;
+ }
+ }
+
// Data
Control& mControlImpl;
+ DevelControl::State mState;
+ std::string mSubStateName;
+
RegisteredVisualContainer mVisuals; // Stores visuals needed by the control, non trivial type so std::vector used.
std::string mStyleName;
Vector4 mBackgroundColor; ///< The color of the background visual
static const PropertyRegistration PROPERTY_4;
static const PropertyRegistration PROPERTY_5;
static const PropertyRegistration PROPERTY_6;
+ static const PropertyRegistration PROPERTY_7;
+ static const PropertyRegistration PROPERTY_8;
};
// Properties registered without macro to use specific member variables.
const PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "keyInputFocus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
const PropertyRegistration Control::Impl::PROPERTY_5( typeRegistration, "background", Toolkit::Control::Property::BACKGROUND, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
const PropertyRegistration Control::Impl::PROPERTY_6( typeRegistration, "tooltip", Toolkit::DevelControl::Property::TOOLTIP, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_7( typeRegistration, "state", Toolkit::DevelControl::Property::STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+const PropertyRegistration Control::Impl::PROPERTY_8( typeRegistration, "subState", Toolkit::DevelControl::Property::SUB_STATE, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
Toolkit::Control Control::New()
{