#include <dali/public-api/animation/constraints.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/size-negotiation/relayout-container.h>
-#include <dali/devel-api/object/type-registry-helper.h>
+#include <dali/public-api/object/type-registry-helper.h>
#include <dali/devel-api/rendering/renderer.h>
#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
-#include <dali-toolkit/devel-api/styling/style-manager.h>
#include <dali-toolkit/internal/styling/style-manager-impl.h>
#include <dali-toolkit/internal/controls/renderers/color/color-renderer.h>
+#include <dali-toolkit/internal/controls/renderers/renderer-string-constants.h>
namespace Dali
{
DALI_TYPE_REGISTRATION_END()
-const char * const COLOR_RENDERER_COLOR_NAME("blendColor");
-
} // unnamed namespace
namespace Internal
: mControlImpl( controlImpl ),
mStyleName(""),
mBackgroundRenderer(),
+ mBackgroundColor(Color::TRANSPARENT),
mStartingPinchScale( NULL ),
mKeyEventSignal(),
mPinchGestureDetector(),
mLongPressGestureDetector(),
mFlags( Control::ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ),
mIsKeyboardNavigationSupported( false ),
- mIsKeyboardFocusGroup( false ),
- mAddRemoveBackgroundChild( false )
+ mIsKeyboardFocusGroup( false )
{
}
Control& mControlImpl;
std::string mStyleName;
Toolkit::ControlRenderer mBackgroundRenderer; ///< The control renderer to render the background
+ Vector4 mBackgroundColor; ///< The color of the background renderer
Vector3* mStartingPinchScale; ///< The scale when a pinch gesture starts, TODO: consider removing this
Toolkit::Control::KeyEventSignalType mKeyEventSignal;
Toolkit::Control::KeyInputFocusSignalType mKeyInputFocusGainedSignal;
ControlBehaviour mFlags :CONTROL_BEHAVIOUR_FLAG_COUNT; ///< Flags passed in from constructor.
bool mIsKeyboardNavigationSupported :1; ///< Stores whether keyboard navigation is supported by the control.
bool mIsKeyboardFocusGroup :1; ///< Stores whether the control is a focus group.
- bool mAddRemoveBackgroundChild:1; ///< Flag to know when we are adding or removing our own actor to avoid call to OnControlChildAdd
// Properties - these need to be members of Internal::Control::Impl as they need to function within this class.
static const PropertyRegistration PROPERTY_1;
void Control::SetBackgroundColor( const Vector4& color )
{
Actor self( Self() );
- Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
- factory.ResetRenderer( mImpl->mBackgroundRenderer, self, color );
- mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ mImpl->mBackgroundColor = color;
+ Property::Map map;
+ map[ RENDERER_TYPE ] = COLOR_RENDERER;
+ map[ "mixColor" ] = color;
+ InitializeControlRenderer( self, mImpl->mBackgroundRenderer, map );
+ if( mImpl->mBackgroundRenderer )
+ {
+ mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ }
}
Vector4 Control::GetBackgroundColor() const
{
- if( mImpl->mBackgroundRenderer && ( &typeid( GetImplementation(mImpl->mBackgroundRenderer) ) == &typeid( ColorRenderer ) ) )
- {
- Property::Map map;
- mImpl->mBackgroundRenderer.CreatePropertyMap( map );
- const Property::Value* colorValue = map.Find( COLOR_RENDERER_COLOR_NAME );
- Vector4 color;
- if( colorValue && colorValue->Get(color))
- {
- return color;
- }
- }
-
- return Color::TRANSPARENT;
+ return mImpl->mBackgroundColor;
}
-void Control::SetBackground(const Property::Map& map)
+void Control::SetBackground( const Property::Map& map )
{
Actor self( Self() );
- mImpl->mBackgroundRenderer.RemoveAndReset( self );
- Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
- mImpl->mBackgroundRenderer = factory.GetControlRenderer( map );
- if( mImpl->mBackgroundRenderer && self.OnStage() ) // Request control renderer with a property map might return an empty handle
+ InitializeControlRenderer( self, mImpl->mBackgroundRenderer, map );
+ if( mImpl->mBackgroundRenderer )
{
mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
- mImpl->mBackgroundRenderer.SetOnStage( self );
}
}
void Control::SetBackgroundImage( Image image )
{
Actor self( Self() );
- Toolkit::RendererFactory factory = Toolkit::RendererFactory::Get();
- factory.ResetRenderer( mImpl->mBackgroundRenderer, self, image );
- mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ InitializeControlRenderer( self, mImpl->mBackgroundRenderer, image );
+ if( mImpl->mBackgroundRenderer )
+ {
+ mImpl->mBackgroundRenderer.SetDepthIndex( DepthIndex::BACKGROUND );
+ }
}
void Control::ClearBackground()
return mImpl->mKeyEventSignal;
}
-Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusGainedSignal()
+Toolkit::Control::KeyInputFocusSignalType& Control::KeyInputFocusGainedSignal()
{
return mImpl->mKeyInputFocusGainedSignal;
}
-Toolkit::Control::KeyInputFocusSignalType& Control:: KeyInputFocusLostSignal()
+Toolkit::Control::KeyInputFocusSignalType& Control::KeyInputFocusLostSignal()
{
return mImpl->mKeyInputFocusLostSignal;
}
if( mImpl->mFlags & REQUIRES_STYLE_CHANGE_SIGNALS )
{
- Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ Toolkit::StyleManager styleManager = StyleManager::Get();
+
// if stylemanager is available
if( styleManager )
{
+ StyleManager& styleManagerImpl = GetImpl( styleManager );
+
// Register for style changes
- styleManager.StyleChangeSignal().Connect( this, &Control::OnStyleChange );
+ styleManagerImpl.ControlStyleChangeSignal().Connect( this, &Control::OnStyleChange );
// Apply the current style
- GetImpl( styleManager ).ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
+ styleManagerImpl.ApplyThemeStyleAtInit( Toolkit::Control( GetOwner() ) );
}
}
void Control::OnChildAdd(Actor& child)
{
- // If this is the background actor, then we do not want to inform deriving classes
- if ( mImpl->mAddRemoveBackgroundChild )
- {
- return;
- }
-
// Notify derived classes.
OnControlChildAdd( child );
}
void Control::OnChildRemove(Actor& child)
{
- // If this is the background actor, then we do not want to inform deriving classes
- if ( mImpl->mAddRemoveBackgroundChild )
- {
- return;
- }
-
// Notify derived classes.
OnControlChildRemove( child );
}
void Control::OnSizeSet(const Vector3& targetSize)
{
- // Background is resized through size negotiation
+ if( mImpl->mBackgroundRenderer )
+ {
+ Vector2 size( targetSize );
+ mImpl->mBackgroundRenderer.SetSize( size );
+ }
}
void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize)