#include <dali-toolkit/public-api/controls/control-impl.h>
// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+#include <limits>
#include <stack>
#include <dali/public-api/actors/image-actor.h>
#include <dali/public-api/actors/mesh-actor.h>
-#include <dali/public-api/animation/active-constraint.h>
#include <dali/public-api/animation/constraint.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/geometry/mesh.h>
actor.SetPositionInheritanceMode( USE_PARENT_POSITION_PLUS_LOCAL_POSITION );
actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
actor.SetZ( BACKGROUND_ACTOR_Z_POSITION );
- actor.SetRelayoutEnabled( true );
- actor.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS );
+ actor.SetRelayoutEnabled( false );
+
+ Constraint constraint = Constraint::New<Vector3>( actor,
+ constrainingIndex,
+ EqualToConstraint() );
+ constraint.AddSource( ParentSource( Actor::Property::SIZE ) );
+ constraint.Apply();
}
} // unnamed namespace
// Construction & Destruction
Impl(Control& controlImpl)
: mControlImpl( controlImpl ),
+ mStyleName(""),
mBackground( NULL ),
mStartingPinchScale( NULL ),
mKeyEventSignal(),
switch ( index )
{
+ case Toolkit::Control::Property::STYLE_NAME:
+ {
+ controlImpl.SetStyleName( value.Get< std::string >() );
+ break;
+ }
+
case Toolkit::Control::Property::BACKGROUND_COLOR:
{
controlImpl.SetBackgroundColor( value.Get< Vector4 >() );
switch ( index )
{
+ case Toolkit::Control::Property::STYLE_NAME:
+ {
+ value = controlImpl.GetStyleName();
+ break;
+ }
+
case Toolkit::Control::Property::BACKGROUND_COLOR:
{
value = controlImpl.GetBackgroundColor();
// Data
Control& mControlImpl;
+ std::string mStyleName;
Background* mBackground; ///< Only create the background if we use it
Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
Toolkit::Control::KeyEventSignalType mKeyEventSignal;
static PropertyRegistration PROPERTY_1;
static PropertyRegistration PROPERTY_2;
static PropertyRegistration PROPERTY_3;
+ static PropertyRegistration PROPERTY_4;
};
// Properties registered without macro to use specific member variables.
-PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
-PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "key-input-focus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+PropertyRegistration Control::Impl::PROPERTY_1( typeRegistration, "style-name", Toolkit::Control::Property::STYLE_NAME, Property::STRING, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+PropertyRegistration Control::Impl::PROPERTY_2( typeRegistration, "background-color", Toolkit::Control::Property::BACKGROUND_COLOR, Property::VECTOR4, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+PropertyRegistration Control::Impl::PROPERTY_3( typeRegistration, "background-image", Toolkit::Control::Property::BACKGROUND_IMAGE, Property::MAP, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
+PropertyRegistration Control::Impl::PROPERTY_4( typeRegistration, "key-input-focus", Toolkit::Control::Property::KEY_INPUT_FOCUS, Property::BOOLEAN, &Control::Impl::SetProperty, &Control::Impl::GetProperty );
Toolkit::Control Control::New()
{
return mImpl->mLongPressGestureDetector;
}
+void Control::SetStyleName( const std::string& styleName )
+{
+ if( styleName != mImpl->mStyleName )
+ {
+ mImpl->mStyleName = styleName;
+
+ // Apply new style
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ }
+}
+
+const std::string& Control::GetStyleName() const
+{
+ return mImpl->mStyleName;
+}
+
void Control::SetBackgroundColor( const Vector4& color )
{
Background& background( mImpl->GetBackground() );
Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
// Register for style changes
- styleManager.StyleChangeSignal().Connect( this, &Control::DoStyleChange );
+ styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
// SetTheme
GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
{
}
-void Control::OnThemeChange( Toolkit::StyleManager styleManager )
-{
- GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
-}
-
-void Control::OnFontChange( bool defaultFontChange, bool defaultFontSizeChange )
+void Control::OnStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
{
+ // By default the control is only interested in theme (not font) changes
+ if( change.themeChange )
+ {
+ GetImpl( styleManager ).ApplyThemeStyle( Toolkit::Control( GetOwner() ) );
+ }
}
void Control::OnPinch(const PinchGesture& pinch)
mImpl->SignalDisconnected( slotObserver, callback );
}
-void Control::DoStyleChange( Toolkit::StyleManager styleManager, StyleChange change )
-{
- if( change.themeChange )
- {
- OnThemeChange( styleManager );
- }
- else if( change.defaultFontChange || change.defaultFontSizeChange )
- {
- OnFontChange( change.defaultFontChange, change.defaultFontSizeChange );
- }
-}
-
} // namespace Internal
} // namespace Toolkit