/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// 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/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/public-api/visuals/color-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+
/**
* Button states and contents
} // unnamed namespace
Button::Button()
-: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mAutoRepeatingTimer(),
mUnselectedColor( Color::WHITE ), // The natural colors of the specified images will be used by default.
mSelectedColor( Color::WHITE ),
void Button::SetColor( const Vector4& color, Button::PaintState selectedState )
{
- Actor& contentActor = mSelectedContent;
+ Actor* contentActor = NULL; // Using a pointer as SetupContent assigns the new Actor to this.
bool imageFileExists = false;
+ Property::Index visualIndex = Toolkit::Button::Property::SELECTED_STATE_IMAGE;
if ( selectedState == SelectedState || selectedState == DisabledSelectedState )
{
mSelectedColor = color;
+ contentActor = &mSelectedContent;
imageFileExists = !GetSelectedImageFilename().empty();
}
else
{
mUnselectedColor = color;
- contentActor = mUnselectedContent;
+ contentActor = &mUnselectedContent;
imageFileExists = !GetUnselectedImageFilename().empty();
+ visualIndex = Toolkit::Button::Property::UNSELECTED_STATE_IMAGE;
}
- if( contentActor && imageFileExists )
- {
- // If there is existing unselected content, change the color on it directly.
- contentActor.SetColor( color );
- }
- else
+ if ( contentActor )
{
- // If there is no existing content, create a new actor to use for flat color.
- Actor placementActor = Actor::New();
- Toolkit::RendererFactory rendererFactory = Toolkit::RendererFactory::Get();
- Toolkit::ControlRenderer colorRenderer;
-
- Property::Map map;
- map["rendererType"] = "color";
- map["mixColor"] = color;
-
- colorRenderer = rendererFactory.CreateControlRenderer( map );
- colorRenderer.SetOnStage( placementActor );
- SetupContent( contentActor, placementActor );
- contentActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ 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 visualFactory = Toolkit::VisualFactory::Get();
+ Toolkit::Visual::Base visual;
+
+ Property::Map map;
+ map[ Toolkit::DevelVisual::Property::TYPE ] = Toolkit::Visual::COLOR;
+ map[ Toolkit::ColorVisual::Property::MIX_COLOR ] = color;
+
+ visual = visualFactory.CreateVisual( map );
+
+ RegisterVisual( visualIndex, visual );
+
+ SetupContent( *contentActor, placementActor ); //
+ contentActor->SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ }
}
}