/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
const char* const PROPERTY_NAME_SHADOW = "shadow";
const char* const PROPERTY_NAME_EMBOSS = "emboss";
const char* const PROPERTY_NAME_OUTLINE = "outline";
+const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
+ DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
+ // Check the background property
+ Property::Map backgroundMapSet;
+ Property::Map backgroundMapGet;
+
+ backgroundMapSet["enable"] = true;
+ backgroundMapSet["color"] = Color::RED;
+ label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
+
+ backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
+ DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
+
// Check the pixel size of font
label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
Property::Map outlineMapSet;
propertyMap.Insert( "outline", outlineMapSet.Add("color", Color::YELLOW).Add("width", 1) );
+ Property::Map backgroundMapSet;
+ propertyMap.Insert( "textBackground", backgroundMapSet.Add("enable", true).Add("color", Color::CYAN) );
+
Visual::Base textVisual = factory.CreateVisual( propertyMap );
Property::Map resultMap;
DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
+ value = resultMap.Find( DevelTextVisual::Property::BACKGROUND, Property::MAP );
+ DALI_TEST_CHECK( value );
+
+ Property::Map backgroundMapGet = value->Get<Property::Map>();
+ DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
+ DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
+
END_TEST;
}
#define DALI_TOOLKIT_TEXT_LABEL_DEVEL_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
* @see VerticalLineAlignment::Type for supported values
*/
VERTICAL_LINE_ALIGNMENT,
+
+ /**
+ * @brief The default text background parameters.
+ * @details Name "textBackground", type Property::MAP.
+ * @note Use "textBackground" as property name to avoid conflict with Control's "background" property
+ *
+ * The background map contains the following keys:
+ *
+ * | %Property Name | Type | Required | Description |
+ * |----------------------|----------|----------|--------------------------------------------------------------------------------------------------------------------|
+ * | enable | BOOLEAN | No | True to enable the background or false to disable (the default value is false) |
+ * | color | VECTOR4 | No | The color of the background (the default value is Color::CYAN) |
+ */
+ BACKGROUND,
};
} // namespace Property
#define DALI_TOOLKIT_DEVEL_API_VISUALS_TEXT_VISUAL_PROPERTIES_DEVEL_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
* @brief The default outline parameters.
* @details name "outline", type Property::MAP.
*/
- OUTLINE = UNDERLINE + 1
+ OUTLINE = UNDERLINE + 1,
+
+ /**
+ * @copydoc Dali::Toolkit::DevelTextLabel::Property::BACKGROUND
+ */
+ BACKGROUND = UNDERLINE + 2,
};
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
DALI_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "lineCount", INTEGER, LINE_COUNT )
DALI_PROPERTY_REGISTRATION( Toolkit, TextLabel, "lineWrapMode", INTEGER, LINE_WRAP_MODE )
DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextLabel, "textDirection", INTEGER, TEXT_DIRECTION )
-DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "verticalLineAlignment", INTEGER, VERTICAL_LINE_ALIGNMENT )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "verticalLineAlignment", INTEGER, VERTICAL_LINE_ALIGNMENT )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextLabel, "textBackground", MAP, BACKGROUND )
DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( Toolkit, TextLabel, "textColor", Color::BLACK, TEXT_COLOR )
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorRed", TEXT_COLOR_RED, TEXT_COLOR, 0 )
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( Toolkit, TextLabel, "textColorGreen", TEXT_COLOR_GREEN, TEXT_COLOR, 1 )
}
break;
}
+ case Toolkit::DevelTextLabel::Property::BACKGROUND:
+ {
+ const bool update = SetBackgroundProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ if( update )
+ {
+ impl.mTextUpdateNeeded = true;
+ }
+ break;
+ }
}
// Request relayout when text update is needed. It's necessary to call it
}
break;
}
+ case Toolkit::DevelTextLabel::Property::BACKGROUND:
+ {
+ GetBackgroundProperties( impl.mController, value, Text::EffectStyle::DEFAULT );
+ break;
+ }
}
}
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
// Combine the two buffers
imageBuffer = CombineImageBuffer( imageBuffer, underlineImageBuffer, bufferWidth, bufferHeight );
}
+
+ // Generate the background if enabled
+ const bool backgroundEnabled = mModel->IsBackgroundEnabled();
+ if ( backgroundEnabled )
+ {
+ Devel::PixelBuffer backgroundImageBuffer = CreateImageBuffer( bufferWidth, bufferHeight, Typesetter::STYLE_BACKGROUND, ignoreHorizontalAlignment, pixelFormat, penX, penY, 0u, numberOfGlyphs -1 );
+
+ // Combine the two buffers
+ imageBuffer = CombineImageBuffer( imageBuffer, backgroundImageBuffer, bufferWidth, bufferHeight );
+ }
}
// Create the final PixelData for the combined image buffer
}
}
+ // Draw the background color from the leftmost glyph to the rightmost glyph
+ if ( style == Typesetter::STYLE_BACKGROUND )
+ {
+ Vector4 backgroundColor = mModel->GetBackgroundColor();
+
+ for( int y = glyphData.verticalOffset + baseline - line.ascender; y < glyphData.verticalOffset + baseline - line.descender; y++ )
+ {
+ if( ( y < 0 ) || ( y > static_cast<int>(bufferHeight - 1) ) )
+ {
+ // Do not write out of bounds.
+ continue;
+ }
+
+ for( int x = glyphData.horizontalOffset + lineExtentLeft; x <= glyphData.horizontalOffset + lineExtentRight; x++ )
+ {
+ if( ( x < 0 ) || ( x > static_cast<int>(bufferWidth - 1) ) )
+ {
+ // Do not write out of bounds.
+ continue;
+ }
+
+ // Always RGBA image for text with styles
+ uint32_t* bitmapBuffer = reinterpret_cast< uint32_t* >( glyphData.bitmapBuffer.GetBuffer() );
+ uint32_t backgroundPixel = *( bitmapBuffer + y * glyphData.width + x );
+ uint8_t* backgroundPixelBuffer = reinterpret_cast<uint8_t*>( &backgroundPixel );
+
+ // Write the background color to the pixel buffer
+ *( backgroundPixelBuffer ) = static_cast<uint8_t>( backgroundColor.r * 255.f );
+ *( backgroundPixelBuffer + 1u ) = static_cast<uint8_t>( backgroundColor.g * 255.f );
+ *( backgroundPixelBuffer + 2u ) = static_cast<uint8_t>( backgroundColor.b * 255.f );
+ *( backgroundPixelBuffer + 3u ) = static_cast<uint8_t>( backgroundColor.a * 255.f );
+
+ *( bitmapBuffer + y * glyphData.width + x ) = backgroundPixel;
+ }
+ }
+ }
+
// Increases the vertical offset with the line's descender.
glyphData.verticalOffset += static_cast<int>( -line.descender );
}
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
return mModel->GetOutlineWidth();
}
+const Vector4& ViewModel::GetBackgroundColor() const
+{
+ return mModel->GetBackgroundColor();
+}
+
+bool ViewModel::IsBackgroundEnabled() const
+{
+ return mModel->IsBackgroundEnabled();
+}
+
void ViewModel::ElideGlyphs()
{
mIsTextElided = false;
#define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
*/
virtual float GetOutlineWidth() const;
- /**
+ /**
+ * @copydoc ModelInterface::GetBackgroundColor()
+ */
+ virtual const Vector4& GetBackgroundColor() const;
+
+ /**
+ * @copydoc ModelInterface::IsBackgroundEnabled()
+ */
+ virtual bool IsBackgroundEnabled() const;
+
+/**
* @brief Does the text elide.
*
* It stores a copy of the visible glyphs and removes as many glyphs as needed
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
return mImpl->mModel->mVisualModel->GetOutlineWidth();
}
+void Controller::SetBackgroundColor( const Vector4& color )
+{
+ mImpl->mModel->mVisualModel->SetBackgroundColor( color );
+
+ mImpl->RequestRelayout();
+}
+
+const Vector4& Controller::GetBackgroundColor() const
+{
+ return mImpl->mModel->mVisualModel->GetBackgroundColor();
+}
+
+void Controller::SetBackgroundEnabled( bool enabled )
+{
+ mImpl->mModel->mVisualModel->SetBackgroundEnabled( enabled );
+
+ mImpl->RequestRelayout();
+}
+
+bool Controller::IsBackgroundEnabled() const
+{
+ return mImpl->mModel->mVisualModel->IsBackgroundEnabled();
+}
+
void Controller::SetDefaultEmbossProperties( const std::string& embossProperties )
{
if( NULL == mImpl->mEmbossDefaults )
#define DALI_TOOLKIT_TEXT_CONTROLLER_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
unsigned int GetOutlineWidth() const;
/**
+ * @brief Set the background color.
+ *
+ * @param[in] color color of background.
+ */
+ void SetBackgroundColor( const Vector4& color );
+
+ /**
+ * @brief Retrieve the background color.
+ *
+ * @return The background color.
+ */
+ const Vector4& GetBackgroundColor() const;
+
+ /**
+ * @brief Set the background enabled flag.
+ *
+ * @param[in] enabled The background enabled flag.
+ */
+ void SetBackgroundEnabled( bool enabled );
+
+ /**
+ * @brief Returns whether to enable text background or not.
+ *
+ * @return Whether text background is enabled.
+ */
+ bool IsBackgroundEnabled() const;
+
+ /**
* @brief Sets the emboss's properties string.
*
* @note The string is stored to be recovered.
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
return 0u == numberOfItems;
}
+bool ParseBackgroundProperties( const Property::Map& backgroundProperties,
+ bool& enabled,
+ bool& colorDefined,
+ Vector4& color )
+{
+ const unsigned int numberOfItems = backgroundProperties.Count();
+
+ // Parses and applies the style.
+ for( unsigned int index = 0u; index < numberOfItems; ++index )
+ {
+ const KeyValuePair& valueGet = backgroundProperties.GetKeyValue( index );
+
+ if( ENABLE_KEY == valueGet.first.stringKey )
+ {
+ /// Enable key.
+ enabled = valueGet.second.Get<bool>();
+ }
+ else if( COLOR_KEY == valueGet.first.stringKey )
+ {
+ /// Color key.
+ colorDefined = true;
+ color = valueGet.second.Get<Vector4>();
+ }
+ }
+
+ return 0u == numberOfItems;
+}
+
bool SetUnderlineProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type )
{
bool update = false;
}
}
+bool SetBackgroundProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type )
+{
+ bool update = false;
+
+ if( controller )
+ {
+ switch( type )
+ {
+ case EffectStyle::DEFAULT:
+ {
+ const Property::Map& propertiesMap = value.Get<Property::Map>();
+
+ bool enabled = false;
+ bool colorDefined = false;
+ Vector4 color;
+
+ bool empty = true;
+
+ if ( !propertiesMap.Empty() )
+ {
+ empty = ParseBackgroundProperties( propertiesMap,
+ enabled,
+ colorDefined,
+ color );
+ }
+
+ if( !empty )
+ {
+ if( enabled != controller->IsBackgroundEnabled() )
+ {
+ controller->SetBackgroundEnabled( enabled );
+ update = true;
+ }
+
+ if( colorDefined && ( controller->GetBackgroundColor() != color ) )
+ {
+ controller->SetBackgroundColor( color );
+ update = true;
+ }
+ }
+ else
+ {
+ // Disable background.
+ if( controller->IsBackgroundEnabled() )
+ {
+ controller->SetBackgroundEnabled( false );
+ update = true;
+ }
+ }
+ break;
+ }
+ case EffectStyle::INPUT:
+ {
+ // Text background is not supported while inputting yet
+ break;
+ }
+ } // switch
+ } // if( controller )
+
+ return update;
+}
+
+void GetBackgroundProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type )
+{
+ if( controller )
+ {
+ switch( type )
+ {
+ case EffectStyle::DEFAULT:
+ {
+ const bool enabled = controller->IsBackgroundEnabled();
+ const Vector4& color = controller->GetBackgroundColor();
+
+ Property::Map map;
+ map.Insert( ENABLE_KEY, enabled );
+ map.Insert( COLOR_KEY, color );
+
+ value = map;
+
+ break;
+
+ }
+ case EffectStyle::INPUT:
+ {
+ // Text background is not supported while inputting yet
+ break;
+ }
+ }
+ }
+}
+
+
} // namespace Text
} // namespace Toolkit
#define __DALI_TOOLKIT_INTERNAL_TEXT_EFFECTS_STYLE_H__
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
bool& widthDefined,
unsigned int& width );
+
+/**
+ * @brief Parses the background properties.
+ *
+ * @param[in] backgroundProperties The map with the background properties.
+ * @param[out] enabled Whether the background is enabled.
+ * @param[out] colorDefined Whether the background color is defined.
+ * @param[out] color The background color.
+ */
+bool ParseBackgroundProperties( const Property::Map& backgroundProperties,
+ bool& enabled,
+ bool& colorDefined,
+ Vector4& color );
+
/**
* @brief Sets the underline properties.
*
*/
void GetOutlineProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type );
+/**
+ * @brief Sets the background properties.
+ *
+ * @param[in] controller The text's controller.
+ * @param[in] value The values of the background's properties.
+ * @param[in] type Whether the property is for the default background or the input background.
+ *
+ * @return Whether the background properties have been updated.
+ */
+bool SetBackgroundProperties( ControllerPtr controller, const Property::Value& value, EffectStyle::Type type );
+
+/**
+ * @brief Retrieves the background's properties.
+ *
+ * @param[in] controller The text's controller.
+ * @param[out] value The value of the underline's properties.
+ * @param[in] type Whether the property is for the default background or the input background.
+ */
+void GetBackgroundProperties( ControllerPtr controller, Property::Value& value, EffectStyle::Type type );
+
} // namespace Text
} // namespace Toolkit
#define DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
*/
virtual float GetOutlineWidth() const = 0;
+ /**
+ * @brief Retrieves the background color.
+ *
+ * @return The background color.
+ */
+ virtual const Vector4& GetBackgroundColor() const = 0;
+
+ /**
+ * @brief Returns whether background is enabled or not.
+ *
+ * @return The background state.
+ */
+ virtual bool IsBackgroundEnabled() const = 0;
+
};
} // namespace Text
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
return mVisualModel->GetOutlineWidth();
}
+const Vector4& Model::GetBackgroundColor() const
+{
+ return mVisualModel->GetBackgroundColor();
+}
+
+bool Model::IsBackgroundEnabled() const
+{
+ return mVisualModel->IsBackgroundEnabled();
+}
+
Model::Model()
: mLogicalModel(),
mVisualModel(),
#define DALI_TOOLKIT_TEXT_MODEL_H
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
*/
virtual float GetOutlineWidth() const;
+ /**
+ * @copydoc ModelInterface::GetBackgroundColor()
+ */
+ virtual const Vector4& GetBackgroundColor() const;
+
+ /**
+ * @copydoc ModelInterface::IsBackgroundEnabled()
+ */
+ virtual bool IsBackgroundEnabled() const;
+
private: // Private contructors & copy operator.
/**
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
mOutlineWidth = width;
}
+void VisualModel::SetBackgroundColor( const Vector4& color )
+{
+ mBackgroundColor = color;
+}
+
+void VisualModel::SetBackgroundEnabled( bool enabled )
+{
+ mBackgroundEnabled = enabled;
+}
+
const Vector4& VisualModel::GetTextColor() const
{
return mTextColor;
return mOutlineWidth;
}
+const Vector4& VisualModel::GetBackgroundColor() const
+{
+ return mBackgroundColor;
+}
+
+bool VisualModel::IsBackgroundEnabled() const
+{
+ return mBackgroundEnabled;
+}
+
Length VisualModel::GetNumberOfUnderlineRuns() const
{
return mUnderlineRuns.Count();
mShadowColor( Color::BLACK ),
mUnderlineColor( Color::BLACK ),
mOutlineColor( Color::WHITE ),
+ mBackgroundColor( Color::CYAN ),
mControlSize(),
mShadowOffset(),
mUnderlineHeight( 0.0f ),
mLayoutSize(),
mCachedLineIndex( 0u ),
mUnderlineEnabled( false ),
- mUnderlineColorSet( false )
+ mUnderlineColorSet( false ),
+ mBackgroundEnabled( false )
{
}
#define __DALI_TOOLKIT_TEXT_VISUAL_MODEL_IMPL_H__
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
*/
unsigned int GetOutlineWidth() const;
+ /**
+ * @brief Sets the text's background color.
+ *
+ * @param[in] color The text's background color.
+ */
+ void SetBackgroundColor( const Vector4& color );
+
+ /**
+ * @brief Retrieves the text's background color.
+ *
+ * @return The text's background color.
+ */
+ const Vector4& GetBackgroundColor() const;
+
+ /**
+ * @brief Sets whether the text has a background or not.
+ *
+ * @param[in] enabled true if the text has a background.
+ */
+ void SetBackgroundEnabled( bool enabled );
+
+ /**
+ * @brief Returns whether the text has a background or not.
+ *
+ * @return whether the text has a background or not.
+ */
+ bool IsBackgroundEnabled() const;
+
protected:
/**
Vector4 mShadowColor; ///< Color of drop shadow
Vector4 mUnderlineColor; ///< Color of underline
Vector4 mOutlineColor; ///< Color of outline
+ Vector4 mBackgroundColor; ///< Color of text background
Size mControlSize; ///< The size of the UI control.
Vector2 mShadowOffset; ///< Offset for drop shadow, 0 indicates no shadow
float mUnderlineHeight; ///< Fixed height for underline to override font metrics.
bool mUnderlineEnabled:1; ///< Underline enabled flag
bool mUnderlineColorSet:1; ///< Has the underline color been explicitly set?
+ bool mBackgroundEnabled:1; ///< Background enabled flag
};
} // namespace Text
const char * const SHADOW_PROPERTY( "shadow" );
const char * const UNDERLINE_PROPERTY( "underline" );
const char * const OUTLINE_PROPERTY( "outline" );
+const char * const BACKGROUND_PROPERTY( "textBackground" );
const Vector4 FULL_TEXTURE_RECT( 0.f, 0.f, 1.f, 1.f );
{
result = Toolkit::DevelTextVisual::Property::OUTLINE;
}
+ else if( stringKey == BACKGROUND_PROPERTY )
+ {
+ result = Toolkit::DevelTextVisual::Property::BACKGROUND;
+ }
return result;
}
GetOutlineProperties( mController, value, Text::EffectStyle::DEFAULT );
map.Insert( Toolkit::DevelTextVisual::Property::OUTLINE, value );
+
+ GetBackgroundProperties( mController, value, Text::EffectStyle::DEFAULT );
+ map.Insert( Toolkit::DevelTextVisual::Property::BACKGROUND, value );
}
void TextVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
SetOutlineProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
break;
}
+ case Toolkit::DevelTextVisual::Property::BACKGROUND:
+ {
+ SetBackgroundProperties( mController, propertyValue, Text::EffectStyle::DEFAULT );
+ break;
+ }
}
}
const bool underlineEnabled = mController->GetTextModel()->IsUnderlineEnabled();
const bool outlineEnabled = ( mController->GetTextModel()->GetOutlineWidth() > Math::MACHINE_EPSILON_1 );
+ const bool backgroundEnabled = mController->GetTextModel()->IsBackgroundEnabled();;
- const bool styleEnabled = ( shadowEnabled || underlineEnabled || outlineEnabled );
+ const bool styleEnabled = ( shadowEnabled || underlineEnabled || outlineEnabled || backgroundEnabled );
TextureSet textureSet = GetTextTexture( relayoutSize, hasMultipleTextColors, containsEmoji, styleEnabled );
mImpl->mRenderer.SetTextures( textureSet );