// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
/**
* Button states and contents
}
}
-void Button::SetUnselectedColor( const Vector4& color )
-{
- mUnselectedColor = color;
-
- if( mUnselectedContent && !GetUnselectedImageFilename().empty() )
- {
- // If there is existing unselected content, change the color on it directly.
- mUnselectedContent.SetColor( mUnselectedColor );
- }
- else
- {
- // If there is no existing content, create a new actor to use for flat color.
- Toolkit::Control unselectedContentActor = Toolkit::Control::New();
- unselectedContentActor.SetBackgroundColor( mUnselectedColor );
- SetupContent( mUnselectedContent, unselectedContentActor );
- mUnselectedContent.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- }
-}
-
const Vector4 Button::GetUnselectedColor() const
{
return mUnselectedColor;
}
-void Button::SetSelectedColor( const Vector4& color )
+void Button::SetColor( const Vector4& color, Button::PaintState selectedState )
{
- mSelectedColor = color;
+ Actor* contentActor = NULL; // Using a pointer as SetupContent assigns the new Actor to this.
+ bool imageFileExists = false;
- if( mSelectedContent && !GetSelectedImageFilename().empty() )
+ if ( selectedState == SelectedState || selectedState == DisabledSelectedState )
{
- // If there is existing unselected content, change the color on it directly.
- mSelectedContent.SetColor( mSelectedColor );
+ mSelectedColor = color;
+ contentActor = &mSelectedContent;
+ imageFileExists = !GetSelectedImageFilename().empty();
}
else
{
- // If there is no existing content, create a new actor to use for flat color.
- Toolkit::Control selectedContentActor = Toolkit::Control::New();
- selectedContentActor.SetBackgroundColor( mSelectedColor );
- SetupContent( mSelectedContent, selectedContentActor );
- mSelectedContent.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mUnselectedColor = color;
+ contentActor = &mUnselectedContent;
+ imageFileExists = !GetUnselectedImageFilename().empty();
+ }
+
+ if ( contentActor )
+ {
+ if( imageFileExists )
+ {
+ // If there is existing unselected content, change the color on it directly.
+ contentActor->SetColor( color );
+ }
+ else
+ {
+ // If there is no existing content, create a new actor to use for flat color.
+ Actor placementActor = Actor::New();
+ Toolkit::VisualFactory rendererFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base colorRenderer;
+
+ Property::Map map;
+ map["rendererType"] = "COLOR";
+ map["mixColor"] = color;
+
+ colorRenderer = rendererFactory.CreateVisual( map );
+ colorRenderer.SetOnStage( placementActor );
+
+ SetupContent( *contentActor, placementActor ); //
+ contentActor->SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ }
}
}
return std::string();
}
-std::string Button::GetBackgroundImageFilename() const
-{
- if( mBackgroundContent )
- {
- ResourceImage image = ResourceImage::DownCast( mBackgroundContent );
- if( image )
- {
- return image.GetUrl();
- }
- }
- return std::string();
-}
-
-std::string Button::GetSelectedBackgroundImageFilename() const
-{
- if( mSelectedBackgroundContent )
- {
- ResourceImage image = ResourceImage::DownCast( mSelectedBackgroundContent );
- if( image )
- {
- return image.GetUrl();
- }
- }
- return std::string();
-}
-
std::string Button::GetDisabledImageFilename() const
{
if( mDisabledContent )
return std::string();
}
-std::string Button::GetDisabledSelectedImageFilename() const
-{
- if( mDisabledSelectedContent )
- {
- ResourceImage image = ResourceImage::DownCast( mDisabledSelectedContent );
- if( image )
- {
- return image.GetUrl();
- }
- }
- return std::string();
-}
-
-std::string Button::GetDisabledBackgroundImageFilename() const
-{
- if( mDisabledBackgroundContent )
- {
- ResourceImage image = ResourceImage::DownCast( mDisabledBackgroundContent );
- if( image )
- {
- return image.GetUrl();
- }
- }
- return std::string();
-}
-
bool Button::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
{
bool ret = false;
case Toolkit::Button::Property::UNSELECTED_COLOR:
{
- GetImplementation( button ).SetUnselectedColor( value.Get< Vector4 >() );
+ GetImplementation( button ).SetColor( value.Get< Vector4 >(), UnselectedState );
break;
}
case Toolkit::Button::Property::SELECTED_COLOR:
{
- GetImplementation( button ).SetSelectedColor( value.Get< Vector4 >() );
+ GetImplementation( button ).SetColor( value.Get< Vector4 >(), SelectedState );
break;
}