Change-Id: Id6d420e1be92a95edf0b0c6d9b8d91acec78dfde
15 files changed:
Property::Map shadowMapSet;
Property::Map shadowMapGet;
Property::Map shadowMapSet;
Property::Map shadowMapGet;
- shadowMapSet.Insert( "color", "green" );
- shadowMapSet.Insert( "offset", "2 2" );
+ shadowMapSet.Insert( "color", Color::GREEN );
+ shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
+ shadowMapSet.Insert( "blurRadius", 3.0f );
editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
TextEditor editor = TextEditor::New();
TextEditor editor = TextEditor::New();
- std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
+ std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
Stage::GetCurrent().Add( editor );
Stage::GetCurrent().Add( editor );
- editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
+ editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
std::string result;
Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
std::string result;
Property::Map shadowMapSet;
Property::Map shadowMapGet;
Property::Map shadowMapSet;
Property::Map shadowMapGet;
- shadowMapSet.Insert( "color", "green" );
- shadowMapSet.Insert( "offset", "2 2" );
+ shadowMapSet.Insert( "color", Color::GREEN );
+ shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
+ shadowMapSet.Insert( "blurRadius", 3.0f );
field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
Property::Map shadowMapSet;
Property::Map shadowMapGet;
Property::Map shadowMapSet;
Property::Map shadowMapGet;
- shadowMapSet.Insert( "color", "green" );
- shadowMapSet.Insert( "offset", "2 2" );
+ shadowMapSet.Insert( "color", Color::GREEN );
+ shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
+ shadowMapSet.Insert( "blurRadius", 5.0f );
label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
shadowMapSet.Clear();
Property::Map shadowDisabledMapGet;
shadowMapSet.Clear();
Property::Map shadowDisabledMapGet;
- shadowDisabledMapGet.Insert( "color", "green" );
- shadowDisabledMapGet.Insert( "offset", "0 0" );
+ shadowDisabledMapGet.Insert( "color", Color::GREEN );
+ shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
+ shadowDisabledMapGet.Insert( "blurRadius", 5.0f );
label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
Property::Map shadowMapSet;
shadowMapSet.Insert( "color", "green" );
shadowMapSet.Insert( "offset", "2 2" );
Property::Map shadowMapSet;
shadowMapSet.Insert( "color", "green" );
shadowMapSet.Insert( "offset", "2 2" );
+ shadowMapSet.Insert( "blurRadius", "3" );
label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
outlineMapSet["color"] = Color::RED;
label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
outlineMapSet["color"] = Color::RED;
// Create the image buffer for shadow
Devel::PixelBuffer shadowImageBuffer = CreateImageBuffer( bufferWidth, bufferHeight, Typesetter::STYLE_SHADOW, ignoreHorizontalAlignment, pixelFormat, penY, 0u, numberOfGlyphs - 1 );
// Create the image buffer for shadow
Devel::PixelBuffer shadowImageBuffer = CreateImageBuffer( bufferWidth, bufferHeight, Typesetter::STYLE_SHADOW, ignoreHorizontalAlignment, pixelFormat, penY, 0u, numberOfGlyphs - 1 );
+ // Check whether it will be a soft shadow
+ const float& blurRadius = mModel->GetShadowBlurRadius();
+
+ if ( blurRadius > Math::MACHINE_EPSILON_1 )
+ {
+ shadowImageBuffer.ApplyGaussianBlur( blurRadius );
+ }
+
// Combine the two buffers
imageBuffer = CombineImageBuffer( imageBuffer, shadowImageBuffer, bufferWidth, bufferHeight );
}
// Combine the two buffers
imageBuffer = CombineImageBuffer( imageBuffer, shadowImageBuffer, bufferWidth, bufferHeight );
}
return mModel->GetShadowColor();
}
return mModel->GetShadowColor();
}
+const float& ViewModel::GetShadowBlurRadius() const
+{
+ return mModel->GetShadowBlurRadius();
+}
+
const Vector4& ViewModel::GetUnderlineColor() const
{
return mModel->GetUnderlineColor();
const Vector4& ViewModel::GetUnderlineColor() const
{
return mModel->GetUnderlineColor();
virtual const Vector4& GetShadowColor() const;
/**
virtual const Vector4& GetShadowColor() const;
/**
+ * @copydoc ModelInterface::GetShadowBlurRadius()
+ */
+ virtual const float& GetShadowBlurRadius() const;
+
+ /**
* @copydoc ModelInterface::GetUnderlineColor()
*/
virtual const Vector4& GetUnderlineColor() const;
* @copydoc ModelInterface::GetUnderlineColor()
*/
virtual const Vector4& GetUnderlineColor() const;
return mImpl->mModel->mVisualModel->GetShadowColor();
}
return mImpl->mModel->mVisualModel->GetShadowColor();
}
+void Controller::SetShadowBlurRadius( const float& shadowBlurRadius )
+{
+ if ( fabsf( GetShadowBlurRadius() - shadowBlurRadius ) > Math::MACHINE_EPSILON_1 )
+ {
+ mImpl->mModel->mVisualModel->SetShadowBlurRadius( shadowBlurRadius );
+
+ mImpl->RequestRelayout();
+ }
+}
+
+const float& Controller::GetShadowBlurRadius() const
+{
+ return mImpl->mModel->mVisualModel->GetShadowBlurRadius();
+}
+
void Controller::SetUnderlineColor( const Vector4& color )
{
mImpl->mModel->mVisualModel->SetUnderlineColor( color );
void Controller::SetUnderlineColor( const Vector4& color )
{
mImpl->mModel->mVisualModel->SetUnderlineColor( color );
const Vector4& GetShadowColor() const;
/**
const Vector4& GetShadowColor() const;
/**
+ * @brief Set the shadow blur radius.
+ *
+ * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
+ */
+ void SetShadowBlurRadius( const float& shadowBlurRadius );
+
+ /**
+ * @brief Retrieve the shadow blur radius.
+ *
+ * @return The shadow blur radius.
+ */
+ const float& GetShadowBlurRadius() const;
+
+ /**
* @brief Set the underline color.
*
* @param[in] color color of underline.
* @brief Set the underline color.
*
* @param[in] color color of underline.
{
const std::string COLOR_KEY( "color" );
const std::string OFFSET_KEY( "offset" );
{
const std::string COLOR_KEY( "color" );
const std::string OFFSET_KEY( "offset" );
+const std::string BLUR_RADIUS_KEY( "blurRadius" );
const std::string WIDTH_KEY( "width" );
const std::string HEIGHT_KEY( "height" );
const std::string ENABLE_KEY( "enable" );
const std::string WIDTH_KEY( "width" );
const std::string HEIGHT_KEY( "height" );
const std::string ENABLE_KEY( "enable" );
bool& colorDefined,
Vector4& color,
bool& offsetDefined,
bool& colorDefined,
Vector4& color,
bool& offsetDefined,
+ Vector2& offset,
+ bool& blurRadiusDefined,
+ float& blurRadius )
{
const unsigned int numberOfItems = shadowPropertiesMap.Count();
{
const unsigned int numberOfItems = shadowPropertiesMap.Count();
/// Color key.
colorDefined = true;
/// Color key.
colorDefined = true;
- const std::string colorStr = valueGet.second.Get<std::string>();
-
- Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
+ if( valueGet.second.GetType() == Dali::Property::STRING )
+ {
+ const std::string colorStr = valueGet.second.Get<std::string>();
+ Text::ColorStringToVector4( colorStr.c_str(), colorStr.size(), color );
+ }
+ else
+ {
+ color = valueGet.second.Get<Vector4>();
+ }
}
else if( OFFSET_KEY == valueGet.first.stringKey )
{
/// Offset key.
offsetDefined = true;
}
else if( OFFSET_KEY == valueGet.first.stringKey )
{
/// Offset key.
offsetDefined = true;
- const std::string offsetStr = valueGet.second.Get<std::string>();
+ if( valueGet.second.GetType() == Dali::Property::STRING )
+ {
+ const std::string offsetStr = valueGet.second.Get<std::string>();
+ StringToVector2( offsetStr.c_str(), offsetStr.size(), offset );
+ }
+ else
+ {
+ offset = valueGet.second.Get<Vector2>();
+ }
+ }
+ else if( BLUR_RADIUS_KEY == valueGet.first.stringKey )
+ {
+ /// Blur radius key.
+ blurRadiusDefined = true;
- StringToVector2( offsetStr.c_str(), offsetStr.size(), offset );
+ if( valueGet.second.GetType() == Dali::Property::STRING )
+ {
+ const std::string blurRadiusStr = valueGet.second.Get<std::string>();
+ blurRadius = StringToFloat( blurRadiusStr.c_str() );
+ }
+ else
+ {
+ blurRadius = valueGet.second.Get<float>();
+ }
Vector4 color;
bool offsetDefined = false;
Vector2 offset;
Vector4 color;
bool offsetDefined = false;
Vector2 offset;
+ bool blurRadiusDefined = false;
+ float blurRadius;
colorDefined,
color,
offsetDefined,
colorDefined,
color,
offsetDefined,
+ offset,
+ blurRadiusDefined,
+ blurRadius );
controller->ShadowSetByString( !empty );
controller->ShadowSetByString( !empty );
colorDefined,
color,
offsetDefined,
colorDefined,
color,
offsetDefined,
+ offset,
+ blurRadiusDefined,
+ blurRadius );
controller->ShadowSetByString( false );
}
controller->ShadowSetByString( false );
}
controller->SetShadowOffset( offset );
update = true;
}
controller->SetShadowOffset( offset );
update = true;
}
+
+ if( blurRadiusDefined && ( controller->GetShadowBlurRadius() != blurRadius ) )
+ {
+ controller->SetShadowBlurRadius( blurRadius );
+ update = true;
+ }
{
const Vector4& color = controller->GetShadowColor();
const Vector2& offset = controller->GetShadowOffset();
{
const Vector4& color = controller->GetShadowColor();
const Vector2& offset = controller->GetShadowOffset();
+ const float& blurRadius = controller->GetShadowBlurRadius();
if ( controller->IsShadowSetByString() )
{
if ( controller->IsShadowSetByString() )
{
std::string offsetStr;
Vector2ToString( offset, offsetStr );
std::string offsetStr;
Vector2ToString( offset, offsetStr );
- shadowProperties += "\"offset\":\"" + offsetStr + "\"}";
+ shadowProperties += "\"offset\":\"" + offsetStr + "\",";
+
+ std::string blurRadiusStr;
+ FloatToString( blurRadius, blurRadiusStr );
+ shadowProperties += "\"blurRadius\":\"" + blurRadiusStr + "\"}";
value = shadowProperties;
}
value = shadowProperties;
}
- std::string colorStr;
- Vector4ToColorString( color, colorStr );
- map.Insert( COLOR_KEY, colorStr );
-
- std::string offsetStr;
- Vector2ToString( offset, offsetStr );
- map.Insert( OFFSET_KEY, offsetStr );
+ map.Insert( COLOR_KEY, color );
+ map.Insert( OFFSET_KEY, offset );
+ map.Insert( BLUR_RADIUS_KEY, blurRadius );
virtual const Vector4& GetShadowColor() const = 0;
/**
virtual const Vector4& GetShadowColor() const = 0;
/**
+ * @brief Retrieve the shadow blur radius.
+ *
+ * @return The shadow blur radius.
+ */
+ virtual const float& GetShadowBlurRadius() const = 0;
+
+ /**
* @brief Retrieves the underline color.
*
* @return The underline color.
* @brief Retrieves the underline color.
*
* @return The underline color.
return mVisualModel->mShadowColor;
}
return mVisualModel->mShadowColor;
}
+const float& Model::GetShadowBlurRadius() const
+{
+ return mVisualModel->mShadowBlurRadius;
+}
+
const Vector4& Model::GetUnderlineColor() const
{
return mVisualModel->GetUnderlineColor();
const Vector4& Model::GetUnderlineColor() const
{
return mVisualModel->GetUnderlineColor();
virtual const Vector4& GetShadowColor() const;
/**
virtual const Vector4& GetShadowColor() const;
/**
+ * @copydoc ModelInterface::GetShadowBlurRadius()
+ */
+ virtual const float& GetShadowBlurRadius() const;
+
+ /**
* @copydoc ModelInterface::GetUnderlineColor()
*/
virtual const Vector4& GetUnderlineColor() const;
* @copydoc ModelInterface::GetUnderlineColor()
*/
virtual const Vector4& GetUnderlineColor() const;
mShadowColor = shadowColor;
}
mShadowColor = shadowColor;
}
+void VisualModel::SetShadowBlurRadius( const float& shadowBlurRadius )
+{
+ mShadowBlurRadius = shadowBlurRadius;
+}
+
void VisualModel::SetUnderlineColor( const Vector4& color )
{
mUnderlineColor = color;
void VisualModel::SetUnderlineColor( const Vector4& color )
{
mUnderlineColor = color;
+const float& VisualModel::GetShadowBlurRadius() const
+{
+ return mShadowBlurRadius;
+}
+
const Vector4& VisualModel::GetUnderlineColor() const
{
return mUnderlineColor;
const Vector4& VisualModel::GetUnderlineColor() const
{
return mUnderlineColor;
mShadowOffset(),
mUnderlineHeight( 0.0f ),
mOutlineWidth( 0.0f ),
mShadowOffset(),
mUnderlineHeight( 0.0f ),
mOutlineWidth( 0.0f ),
+ mShadowBlurRadius( 0.0f ),
mNaturalSize(),
mLayoutSize(),
mCachedLineIndex( 0u ),
mNaturalSize(),
mLayoutSize(),
mCachedLineIndex( 0u ),
const Vector4& GetShadowColor() const;
/**
const Vector4& GetShadowColor() const;
/**
+ * @brief Set the shadow blur radius.
+ *
+ * @param[in] shadowBlurRadius The shadow blur radius, 0,0 indicates no blur.
+ */
+ void SetShadowBlurRadius( const float& shadowBlurRadius );
+
+ /**
+ * @brief Retrieve the shadow blur radius.
+ *
+ * @return The shadow blur radius.
+ */
+ const float& GetShadowBlurRadius() const;
+
+ /**
* @brief Sets the text's underline color.
*
* @param[in] color The text's underline color.
* @brief Sets the text's underline color.
*
* @param[in] color The text's underline color.
Vector2 mShadowOffset; ///< Offset for drop shadow, 0 indicates no shadow
float mUnderlineHeight; ///< Fixed height for underline to override font metrics.
float mOutlineWidth; ///< Width of outline.
Vector2 mShadowOffset; ///< Offset for drop shadow, 0 indicates no shadow
float mUnderlineHeight; ///< Fixed height for underline to override font metrics.
float mOutlineWidth; ///< Width of outline.
+ float mShadowBlurRadius; ///< Blur radius of shadow, 0 indicates no blur.
-To add a drop-shadow to the text, simply set the SHADOW property. Shadow parameters can be set through a json string, see the examples below.
+To add a drop-shadow to the text, simply set the SHADOW property. Shadow parameters can be set through a json string or through a property map, see the examples below.
label3.SetProperty( TextLabel::Property::TEXT, "Text with Bigger Shadow" );
label3.SetProperty( TextLabel::Property::SHADOW, "{\"offset\":\"2 2\",\"color\":\"black\"}" );
label3.SetProperty( TextLabel::Property::TEXT, "Text with Bigger Shadow" );
label3.SetProperty( TextLabel::Property::SHADOW, "{\"offset\":\"2 2\",\"color\":\"black\"}" );
-label4.SetProperty( TextLabel::Property::TEXT, "Text with Color Shadow" );
-label4.SetProperty( TextLabel::Property::SHADOW, "{\"offset\":\"1 1\",\"color\":\"red\"}" );
+label4.SetProperty( TextLabel::Property::TEXT, "Text with Color Soft Shadow" );
+
+Property::Map shadow;
+shadow.Insert( "offset", Vector2(1.0f, 1.0f) );
+shadow.Insert( "color", Color::RED );
+shadow.Insert( "blurRadius", 2.0f ); // A value of 0 indicates no blur. The bigger the radius, the more blurry.
+label4.SetProperty( TextLabel::Property::SHADOW, shadow );
+
label3.text = "Text with Bigger Shadow";
label3.shadow = "{\"offset\":\"2 2\",\"color\":\"black\"}";
label3.text = "Text with Bigger Shadow";
label3.shadow = "{\"offset\":\"2 2\",\"color\":\"black\"}";
-label4.SetProperty( TextLabel::Property::TEXT, "Text with Color Shadow" );
-label3.shadow = "{\"offset\":\"1 1\",\"color\":\"red\"}";
+label4.SetProperty( TextLabel::Property::TEXT, "Text with Color Soft Shadow" );
+var shadow = {
+ "offset" : [ 1.0, 1.0 ],
+ "color" : dali.COLOR_RED;
+ "blurRadius" : 2.0
+};
+label4.shadow = shadow;
+