mBoundingBox(),
mHighlightColor( LIGHT_BLUE ),
mHighlightPosition( Vector2::ZERO ),
+ mHighlightSize( Vector2::ZERO ),
+ mControlSize( Vector2::ZERO ),
+ mHighlightOutlineOffset( 0.f ),
mActiveCursor( ACTIVE_CURSOR_NONE ),
mCursorBlinkInterval( CURSOR_BLINK_INTERVAL ),
mCursorBlinkDuration( 0.0f ),
if ( mHighlightActor )
{
// Sets the position of the highlight actor inside the decorator.
- mHighlightActor.SetPosition( mHighlightPosition.x,
- mHighlightPosition.y );
+ mHighlightActor.SetPosition( mHighlightPosition.x + mHighlightOutlineOffset,
+ mHighlightPosition.y + mHighlightOutlineOffset );
const unsigned int numberOfQuads = mHighlightQuadList.Count();
if( 0u != numberOfQuads )
Vector2 mHighlightPosition; ///< The position of the highlight actor.
Size mHighlightSize; ///< The size of the highlighted text.
Size mControlSize; ///< The control's size. Set by the Relayout.
+ float mHighlightOutlineOffset; ///< The outline's offset.
unsigned int mActiveCursor;
unsigned int mCursorBlinkInterval;
*( mImpl->mHighlightQuadList.Begin() + index ) = quad;
}
-void Decorator::SetHighLightBox( const Vector2& position, const Size& size )
+void Decorator::SetHighLightBox( const Vector2& position, const Size& size, float outlineOffset )
{
mImpl->mHighlightPosition = position;
mImpl->mHighlightSize = size;
+ mImpl->mHighlightOutlineOffset = outlineOffset;
}
void Decorator::ClearHighlights()
{
mImpl->mHighlightQuadList.Clear();
mImpl->mHighlightPosition = Vector2::ZERO;
+ mImpl->mHighlightOutlineOffset = 0.f;
}
void Decorator::ResizeHighlightQuads( unsigned int numberOfQuads )
*
* @param[in] position The position of the highlighted text in decorator's coords.
* @param[in] size The size of the highlighted text.
+ * @param[in] outlineOffset The outline's offset.
*/
void SetHighLightBox( const Vector2& position,
- const Size& size );
+ const Size& size,
+ float outlineOffset );
/**
* @brief Removes all of the previously added highlights.
floatStr = ss.str();
}
+void UintToString( unsigned int value, std::string& uIntStr )
+{
+ std::stringstream ss;
+ ss << value;
+ uIntStr = ss.str();
+}
+
void UintColorToVector4( unsigned int color, Vector4& retColor )
{
retColor.a = static_cast<float>( ( color & 0xFF000000 ) >> 24u ) / 255.f;
void FloatToString( float value, std::string& floatStr );
/**
+ * @brief Converts an unsigned int into a string.
+ *
+ * @param[in] value The unsigned int value.
+ * @param[out] uIntStr The string.
+ */
+void UintToString( unsigned int value, std::string& uIntStr );
+
+/**
* @brief Converts an ARGB color packed in 4 byte unsigned int into a Vector4 color used in Dali.
*
* @param[in] color An ARGB color packed in an unsigned int.
}
void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
+ const uint32_t outlineWidth,
const PixelData& bitmap,
Dali::Toolkit::AtlasManager::AtlasSlot& slot )
{
GlyphRecordEntry record;
record.mIndex = glyph.index;
+ record.mOutlineWidth = outlineWidth;
record.mImageId = slot.mImageId;
record.mCount = 1;
bool AtlasGlyphManager::IsCached( Text::FontId fontId,
Text::GlyphIndex index,
+ uint32_t outlineWidth,
Dali::Toolkit::AtlasManager::AtlasSlot& slot )
{
for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin();
glyphRecordIt != fontGlyphRecordIt->mGlyphRecords.End();
++glyphRecordIt )
{
- if ( glyphRecordIt->mIndex == index )
+ if ( glyphRecordIt->mIndex == index && glyphRecordIt->mOutlineWidth == outlineWidth )
{
slot.mImageId = glyphRecordIt->mImageId;
slot.mAtlasId = mAtlasManager.GetAtlas( slot.mImageId );
return mMetrics;
}
-void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta )
+void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta )
{
if( 0 != delta )
{
glyphRecordIt != fontGlyphRecordIt->mGlyphRecords.End();
++glyphRecordIt )
{
- if ( glyphRecordIt->mIndex == index )
+ if ( glyphRecordIt->mIndex == index && glyphRecordIt->mOutlineWidth == outlineWidth )
{
glyphRecordIt->mCount += delta;
DALI_ASSERT_DEBUG( glyphRecordIt->mCount >= 0 && "Glyph ref-count should not be negative" );
struct GlyphRecordEntry
{
Text::GlyphIndex mIndex;
+ uint32_t mOutlineWidth;
uint32_t mImageId;
int32_t mCount;
};
* @copydoc Toolkit::AtlasGlyphManager::Add
*/
void Add( const Text::GlyphInfo& glyph,
+ const uint32_t outlineWidth,
const PixelData& bitmap,
Dali::Toolkit::AtlasManager::AtlasSlot& slot );
*/
bool IsCached( Text::FontId fontId,
Text::GlyphIndex index,
+ uint32_t outlineWidth,
Dali::Toolkit::AtlasManager::AtlasSlot& slot );
/**
/**
* @copydoc toolkit::AtlasGlyphManager::AdjustReferenceCount
*/
- void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta );
+ void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta );
/**
* @copydoc Toolkit::AtlasGlyphManager::GetTextures
}
void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph,
+ const uint32_t outlineWidth,
const PixelData& bitmap,
AtlasManager::AtlasSlot& slot )
{
- GetImplementation(*this).Add( glyph, bitmap, slot );
+ GetImplementation(*this).Add( glyph, outlineWidth, bitmap, slot );
}
void AtlasGlyphManager::GenerateMeshData( uint32_t imageId,
bool AtlasGlyphManager::IsCached( Text::FontId fontId,
Text::GlyphIndex index,
+ uint32_t outlineWidth,
AtlasManager::AtlasSlot& slot )
{
- return GetImplementation(*this).IsCached( fontId, index, slot );
+ return GetImplementation(*this).IsCached( fontId, index, outlineWidth, slot );
}
void AtlasGlyphManager::SetNewAtlasSize( uint32_t width, uint32_t height, uint32_t blockWidth, uint32_t blockHeight )
return GetImplementation(*this).GetMetrics();
}
-void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta )
+void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta )
{
- GetImplementation(*this).AdjustReferenceCount( fontId, index, delta );
+ GetImplementation(*this).AdjustReferenceCount( fontId, index, outlineWidth, delta );
}
} // namespace Toolkit
* @brief Ask Atlas Manager to add a glyph
*
* @param[in] glyph glyph to add to an atlas
+ * @param[in] outlineWidth the outline width of the glyph
* @param[in] bitmap bitmap to use for glyph addition
* @param[out] slot information returned by atlas manager for addition
*/
void Add( const Text::GlyphInfo& glyph,
+ const uint32_t outlineWidth,
const PixelData& bitmap,
AtlasManager::AtlasSlot& slot );
*
* @param[in] fontId The font that this glyph comes from
* @param[in] index The GlyphIndex of this glyph
+ * @param[in] outlineWidth The outline width of this glyph
* @param[out] slot container holding information about the glyph( mImage = 0 indicates not being cached )
*
* @return Whether glyph is cached or not ?
*/
bool IsCached( Text::FontId fontId,
Text::GlyphIndex index,
+ uint32_t outlineWidth,
AtlasManager::AtlasSlot& slot );
/**
*
* @param[in] fontId The font this image came from
* @param[in] index The index of the glyph
+ * @param[in] outlineWidth The outline width of the glyph
* @param[in] delta The adjustment to make to the reference count
*/
- void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta );
+ void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta );
private:
const float ONE( 1.0f );
const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
-const int NO_OUTLINE( 0 );
+const uint32_t NO_OUTLINE = 0;
}
struct AtlasRenderer::Impl
TextCacheEntry()
: mFontId( 0 ),
mIndex( 0 ),
+ mOutlineWidth( 0 ),
mImageId( 0 )
{
}
FontId mFontId;
Text::GlyphIndex mIndex;
+ uint32_t mOutlineWidth;
uint32_t mImageId;
};
return false;
}
- void CacheGlyph( const GlyphInfo& glyph, FontId lastFontId, AtlasManager::AtlasSlot& slot )
+ void CacheGlyph( const GlyphInfo& glyph, FontId lastFontId, uint32_t outline, AtlasManager::AtlasSlot& slot )
{
- bool glyphNotCached = !mGlyphManager.IsCached( glyph.fontId, glyph.index, slot ); // Check FontGlyphRecord vector for entry with glyph index and fontId
+ const bool glyphNotCached = !mGlyphManager.IsCached( glyph.fontId, glyph.index, outline, slot ); // Check FontGlyphRecord vector for entry with glyph index and fontId
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "AddGlyphs fontID[%u] glyphIndex[%u] [%s]\n", glyph.fontId, glyph.index, (glyphNotCached)?"not cached":"cached" );
// Create a new image for the glyph
PixelData bitmap;
+ // Whether the glyph is an outline.
+ const bool isOutline = 0u != outline;
+
// Whether the current glyph is a color one.
const bool isColorGlyph = mFontClient.IsColorGlyph( glyph.fontId, glyph.index );
- // Retrieve the emoji's bitmap.
- TextAbstraction::FontClient::GlyphBufferData glyphBufferData;
- glyphBufferData.width = isColorGlyph ? glyph.width : 0; // Desired width and height.
- glyphBufferData.height = isColorGlyph ? glyph.height : 0;
-
- mFontClient.CreateBitmap( glyph.fontId,
- glyph.index,
- glyphBufferData,
- NO_OUTLINE );
-
- // Create the pixel data.
- bitmap = PixelData::New( glyphBufferData.buffer,
- glyph.width * glyph.height * GetBytesPerPixel( glyphBufferData.format ),
- glyph.width,
- glyph.height,
- glyphBufferData.format,
- PixelData::DELETE_ARRAY );
-
- if( bitmap )
+ if( !isOutline || ( isOutline && !isColorGlyph) )
{
- // Ensure that the next image will fit into the current block size
- if( bitmap.GetWidth() > blockSize.mNeededBlockWidth )
+ // Retrieve the emoji's bitmap.
+ TextAbstraction::FontClient::GlyphBufferData glyphBufferData;
+ glyphBufferData.width = isColorGlyph ? glyph.width : 0; // Desired width and height.
+ glyphBufferData.height = isColorGlyph ? glyph.height : 0;
+
+ mFontClient.CreateBitmap( glyph.fontId,
+ glyph.index,
+ glyphBufferData,
+ outline );
+
+ // Create the pixel data.
+ bitmap = PixelData::New( glyphBufferData.buffer,
+ glyphBufferData.width * glyphBufferData.height * GetBytesPerPixel( glyphBufferData.format ),
+ glyphBufferData.width,
+ glyphBufferData.height,
+ glyphBufferData.format,
+ PixelData::DELETE_ARRAY );
+
+ if( bitmap )
{
- blockSize.mNeededBlockWidth = bitmap.GetWidth();
- }
+ // Ensure that the next image will fit into the current block size
+ if( bitmap.GetWidth() > blockSize.mNeededBlockWidth )
+ {
+ blockSize.mNeededBlockWidth = bitmap.GetWidth();
+ }
- if( bitmap.GetHeight() > blockSize.mNeededBlockHeight )
- {
- blockSize.mNeededBlockHeight = bitmap.GetHeight();
- }
+ if( bitmap.GetHeight() > blockSize.mNeededBlockHeight )
+ {
+ blockSize.mNeededBlockHeight = bitmap.GetHeight();
+ }
- // If CheckAtlas in AtlasManager::Add can't fit the bitmap in the current atlas it will create a new atlas
+ // If CheckAtlas in AtlasManager::Add can't fit the bitmap in the current atlas it will create a new atlas
- // Setting the block size and size of new atlas does not mean a new one will be created. An existing atlas may still surffice.
- mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
- DEFAULT_ATLAS_HEIGHT,
- blockSize.mNeededBlockWidth,
- blockSize.mNeededBlockHeight );
+ // Setting the block size and size of new atlas does not mean a new one will be created. An existing atlas may still surffice.
+ mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
+ DEFAULT_ATLAS_HEIGHT,
+ blockSize.mNeededBlockWidth,
+ blockSize.mNeededBlockHeight );
- // Locate a new slot for our glyph
- mGlyphManager.Add( glyph, bitmap, slot ); // slot will be 0 is glyph not added
+ // Locate a new slot for our glyph
+ mGlyphManager.Add( glyph, outline, bitmap, slot ); // slot will be 0 is glyph not added
+ }
}
}
else
{
// We have 2+ copies of the same glyph
- mGlyphManager.AdjustReferenceCount( glyph.fontId, glyph.index, 1/*increment*/ );
+ mGlyphManager.AdjustReferenceCount( glyph.fontId, glyph.index, outline, 1 ); //increment
}
}
void GenerateMesh( const GlyphInfo& glyph,
const Vector2& position,
const Vector4& color,
+ uint32_t outline,
AtlasManager::AtlasSlot& slot,
bool underlineGlyph,
float currentUnderlinePosition,
textCacheEntry.mFontId = glyph.fontId;
textCacheEntry.mImageId = slot.mImageId;
textCacheEntry.mIndex = glyph.index;
+ textCacheEntry.mOutlineWidth = outline;
newTextCache.PushBack( textCacheEntry );
void CreateActors( const std::vector<MeshRecord>& meshContainer,
const Size& textSize,
- const Vector4& defaultColor,
+ const Vector4& color,
const Vector4& shadowColor,
const Vector2& shadowOffset,
- Style style,
Actor textControl,
- Property::Index animatablePropertyIndex )
+ Property::Index animatablePropertyIndex,
+ bool drawShadow )
{
if( !mActor )
{
{
const MeshRecord& meshRecord = *it;
- Actor actor = CreateMeshActor( textControl, animatablePropertyIndex, defaultColor, meshRecord, textSize, STYLE_NORMAL );
+ Actor actor = CreateMeshActor( textControl, animatablePropertyIndex, color, meshRecord, textSize, STYLE_NORMAL );
// Whether the actor has renderers.
const bool hasRenderer = actor.GetRendererCount() > 0u;
// Create an effect if necessary
if( hasRenderer &&
- ( style == STYLE_DROP_SHADOW ) )
+ drawShadow )
{
// Change the color of the vertices.
for( Vector<AtlasManager::Vertex2D>::Iterator vIt = meshRecord.mMesh.mVertices.Begin(),
vertex.mColor = shadowColor;
}
- Actor shadowActor = CreateMeshActor(textControl, animatablePropertyIndex, defaultColor, meshRecord, textSize, STYLE_DROP_SHADOW );
+ Actor shadowActor = CreateMeshActor(textControl, animatablePropertyIndex, color, meshRecord, textSize, STYLE_DROP_SHADOW );
#if defined(DEBUG_ENABLED)
shadowActor.SetName( "Text Shadow renderable actor" );
#endif
float minLineOffset )
{
AtlasManager::AtlasSlot slot;
+ slot.mImageId = 0u;
+ slot.mAtlasId = 0u;
+
+ AtlasManager::AtlasSlot slotOutline;
+ slotOutline.mImageId = 0u;
+ slotOutline.mAtlasId = 0u;
+
std::vector< MeshRecord > meshContainer;
+ std::vector< MeshRecord > meshContainerOutline;
Vector< Extent > extents;
mDepth = depth;
const Vector2 halfTextSize( textSize * 0.5f );
const Vector2& shadowOffset( view.GetShadowOffset() );
const Vector4& shadowColor( view.GetShadowColor() );
- const bool underlineEnabled( view.IsUnderlineEnabled() );
+ const bool underlineEnabled = view.IsUnderlineEnabled();
const Vector4& underlineColor( view.GetUnderlineColor() );
- const float underlineHeight( view.GetUnderlineHeight() );
+ const float underlineHeight = view.GetUnderlineHeight();
+ const unsigned int outlineWidth = view.GetOutlineWidth();
+ const Vector4& outlineColor( view.GetOutlineColor() );
+ const bool isOutline = 0u != outlineWidth;
const bool useDefaultColor = ( NULL == colorsBuffer );
for( uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i )
{
const GlyphInfo& glyph = *( glyphsBuffer + i );
- const bool underlineGlyph = underlineEnabled || IsGlyphUnderlined( i, underlineRuns );
- thereAreUnderlinedGlyphs = thereAreUnderlinedGlyphs || underlineGlyph;
+ const bool isGlyphUnderlined = underlineEnabled || IsGlyphUnderlined( i, underlineRuns );
+ thereAreUnderlinedGlyphs = thereAreUnderlinedGlyphs || isGlyphUnderlined;
// No operation for white space
if( glyph.width && glyph.height )
{
// Are we still using the same fontId as previous
- if( underlineGlyph && ( glyph.fontId != lastUnderlinedFontId ) )
+ if( isGlyphUnderlined && ( glyph.fontId != lastUnderlinedFontId ) )
{
// We need to fetch fresh font underline metrics
FontMetrics fontMetrics;
} // underline
// Retrieves and caches the glyph's bitmap.
- CacheGlyph( glyph, lastFontId, slot );
+ CacheGlyph( glyph, lastFontId, NO_OUTLINE, slot );
+
+ // Retrieves and caches the outline glyph's bitmap.
+ if( isOutline )
+ {
+ CacheGlyph( glyph, lastFontId, outlineWidth, slotOutline );
+ }
// Move the origin (0,0) of the mesh to the center of the actor
const Vector2 position = *( positionsBuffer + i ) - halfTextSize - lineOffsetPosition;
if ( 0u != slot.mImageId ) // invalid slot id, glyph has failed to be added to atlas
{
+ Vector2 positionPlusOutlineOffset = position;
+ if( isOutline )
+ {
+ // Add an offset to the text.
+ const float outlineWidthOffset = static_cast<float>( outlineWidth );
+ positionPlusOutlineOffset += Vector2( outlineWidthOffset, outlineWidthOffset );
+ }
+
// Get the color of the character.
const ColorIndex colorIndex = useDefaultColor ? 0u : *( colorIndicesBuffer + i );
const Vector4& color = ( useDefaultColor || ( 0u == colorIndex ) ) ? defaultColor : *( colorsBuffer + colorIndex - 1u );
GenerateMesh( glyph,
- position,
+ positionPlusOutlineOffset,
color,
+ NO_OUTLINE,
slot,
- underlineGlyph,
+ isGlyphUnderlined,
currentUnderlinePosition,
currentUnderlineThickness,
meshContainer,
lastFontId = glyph.fontId; // Prevents searching for existing blocksizes when string of the same fontId.
}
+
+ if( isOutline && ( 0u != slotOutline.mImageId ) ) // invalid slot id, glyph has failed to be added to atlas
+ {
+ GenerateMesh( glyph,
+ position,
+ outlineColor,
+ outlineWidth,
+ slotOutline,
+ false,
+ currentUnderlinePosition,
+ currentUnderlineThickness,
+ meshContainerOutline,
+ newTextCache,
+ extents);
+ }
}
} // glyphs
}
// For each MeshData object, create a mesh actor and add to the renderable actor
+ bool isShadowDrawn = false;
+ if( !meshContainerOutline.empty() )
+ {
+ const bool drawShadow = STYLE_DROP_SHADOW == style;
+ CreateActors( meshContainerOutline,
+ textSize,
+ outlineColor,
+ shadowColor,
+ shadowOffset,
+ textControl,
+ animatablePropertyIndex,
+ drawShadow );
+
+ isShadowDrawn = drawShadow;
+ }
+
+ // For each MeshData object, create a mesh actor and add to the renderable actor
if( !meshContainer.empty() )
{
+ const bool drawShadow = !isShadowDrawn && ( STYLE_DROP_SHADOW == style );
CreateActors( meshContainer,
textSize,
defaultColor,
shadowColor,
shadowOffset,
- style,
textControl,
- animatablePropertyIndex );
+ animatablePropertyIndex,
+ drawShadow );
}
#if defined(DEBUG_ENABLED)
{
for( Vector< TextCacheEntry >::Iterator oldTextIter = mTextCache.Begin(); oldTextIter != mTextCache.End(); ++oldTextIter )
{
- mGlyphManager.AdjustReferenceCount( oldTextIter->mFontId, oldTextIter->mIndex, -1/*decrement*/ );
+ mGlyphManager.AdjustReferenceCount( oldTextIter->mFontId, oldTextIter->mIndex, oldTextIter->mOutlineWidth, -1/*decrement*/ );
}
mTextCache.Resize( 0 );
}
actor.SetSize( actorSize );
actor.RegisterProperty("uOffset", Vector2::ZERO );
actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
+
return actor;
}
const SelectionBoxInfo& firstSelectionBoxLineInfo = *( selectionBoxLinesInfo.Begin() );
highLightPosition.y = firstSelectionBoxLineInfo.lineOffset;
- mEventData->mDecorator->SetHighLightBox( highLightPosition, highLightSize );
+ mEventData->mDecorator->SetHighLightBox( highLightPosition, highLightSize, static_cast<float>( mModel->GetOutlineWidth() ) );
if( !mEventData->mDecorator->IsSmoothHandlePanEnabled() )
{
Text::GetCursorPosition( parameters,
cursorInfo );
+ // Adds Outline offset.
+ const float outlineWidth = static_cast<float>( mModel->GetOutlineWidth() );
+ cursorInfo.primaryPosition.x += outlineWidth;
+ cursorInfo.primaryPosition.y += outlineWidth;
+ cursorInfo.secondaryPosition.x += outlineWidth;
+ cursorInfo.secondaryPosition.y += outlineWidth;
+
if( isMultiLine )
{
// If the text is editable and multi-line, the cursor position after a white space shouldn't exceed the boundaries of the text control.
return mImpl->mModel->mVisualModel->GetOutlineColor();
}
-void Controller::SetOutlineWidth( float width )
+void Controller::SetOutlineWidth( unsigned int width )
{
mImpl->mModel->mVisualModel->SetOutlineWidth( width );
mImpl->RequestRelayout();
}
-float Controller::GetOutlineWidth() const
+unsigned int Controller::GetOutlineWidth() const
{
return mImpl->mModel->mVisualModel->GetOutlineWidth();
}
const Vector<CharacterIndex>& glyphsToCharactersMap = mImpl->mModel->mVisualModel->mGlyphsToCharacters;
const Vector<Length>& charactersPerGlyph = mImpl->mModel->mVisualModel->mCharactersPerGlyph;
const Character* const textBuffer = mImpl->mModel->mLogicalModel->mText.Begin();
- float outlineWidth = mImpl->mModel->GetOutlineWidth();
+ const float outlineWidth = static_cast<float>( mImpl->mModel->GetOutlineWidth() );
// Set the layout parameters.
Layout::Parameters layoutParameters( size,
*
* @param[in] width The width in pixels of the outline, 0 indicates no outline
*/
- void SetOutlineWidth( float width );
+ void SetOutlineWidth( unsigned int width );
/**
* @brief Retrieves the width of an outline
*
* @return The width of the outline.
*/
- float GetOutlineWidth() const;
+ unsigned int GetOutlineWidth() const;
/**
* @brief Sets the emboss's properties string.
if( ENABLE_KEY == valueGet.first.stringKey )
{
/// Enable key.
- const std::string enableStr = valueGet.second.Get<std::string>();
- enabled = Text::TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() );
+ if( valueGet.second.GetType() == Dali::Property::STRING )
+ {
+ const std::string enableStr = valueGet.second.Get<std::string>();
+ enabled = Text::TokenComparison( TRUE_TOKEN, enableStr.c_str(), enableStr.size() );
+ }
+ else
+ {
+ enabled = valueGet.second.Get<bool>();
+ }
}
else if( COLOR_KEY == valueGet.first.stringKey )
{
/// 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( HEIGHT_KEY == valueGet.first.stringKey )
{
/// Height key.
heightDefined = true;
- const std::string heightStr = valueGet.second.Get<std::string>();
-
- height = StringToFloat( heightStr.c_str() );
+ if( valueGet.second.GetType() == Dali::Property::STRING )
+ {
+ const std::string heightStr = valueGet.second.Get<std::string>();
+ height = StringToFloat( heightStr.c_str() );
+ }
+ else
+ {
+ height = valueGet.second.Get<float>();
+ }
}
}
bool& colorDefined,
Vector4& color,
bool& widthDefined,
- float& width )
+ unsigned int& width )
{
const unsigned int numberOfItems = underlinePropertiesMap.Count();
{
/// Width key.
widthDefined = true;
- width = valueGet.second.Get<float>();
+ width = static_cast<unsigned int>( valueGet.second.Get<float>() );
}
}
heightDefined,
height );
- controller->UnderlineSetByString( !empty);
+ controller->UnderlineSetByString( !empty );
}
}
else
bool colorDefined = false;
Vector4 color;
bool widthDefined = false;
- float width = 0.f;
+ unsigned int width = 0u;
bool empty = true;
update = true;
}
- if( widthDefined && ( fabsf( controller->GetOutlineWidth() - width ) > Math::MACHINE_EPSILON_1000 ) )
+ if( widthDefined && ( controller->GetOutlineWidth() != width ) )
{
controller->SetOutlineWidth( width );
update = true;
else
{
// Disable outline
- if( fabsf( controller->GetOutlineWidth() ) > Math::MACHINE_EPSILON_1000 )
+ if( 0u != controller->GetOutlineWidth() )
{
- controller->SetOutlineWidth( 0.0f );
+ controller->SetOutlineWidth( 0u );
update = true;
}
}
else
{
const Vector4& color = controller->GetOutlineColor();
- const float width = controller->GetOutlineWidth();
+ const unsigned int width = controller->GetOutlineWidth();
Property::Map map;
map.Insert( COLOR_KEY, colorStr );
std::string widthStr;
- FloatToString( width, widthStr );
+ UintToString( width, widthStr );
map.Insert( WIDTH_KEY, widthStr );
value = map;
bool& colorDefined,
Vector4& color,
bool& widthDefined,
- float& width );
+ unsigned int& width );
/**
* @brief Sets the underline properties.
virtual void GetUnderlineRuns( GlyphRun* underlineRuns,
UnderlineRunIndex index,
Length numberOfRuns ) const = 0;
+
+ /**
+ * @brief Retrieve the outline color.
+ *
+ * @return The outline color.
+ */
+ virtual const Vector4& GetOutlineColor() const = 0;
+
+ /**
+ * @brief Retrieves the width of an outline
+ *
+ * @return The width of the outline.
+ */
+ virtual unsigned int GetOutlineWidth() const = 0;
+
};
} // namespace Text
}
}
+const Vector4& View::GetOutlineColor() const
+{
+ if( mImpl->mVisualModel )
+ {
+ return mImpl->mVisualModel->GetOutlineColor();
+ }
+ return Vector4::ZERO;
+}
+
+unsigned int View::GetOutlineWidth() const
+{
+ if( mImpl->mVisualModel )
+ {
+ return mImpl->mVisualModel->GetOutlineWidth();
+ }
+ return 0u;
+}
+
} // namespace Text
} // namespace Toolkit
UnderlineRunIndex index,
Length numberOfRuns ) const;
+ /**
+ * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineColor()
+ */
+ virtual const Vector4& GetOutlineColor() const;
+
+ /**
+ * @copydoc Dali::Toolkit::Text::ViewInterface::GetOutlineWidth()
+ */
+ virtual unsigned int GetOutlineWidth() const;
+
private:
// Undefined
mUnderlineHeight = height;
}
-void VisualModel::SetOutlineWidth( float width )
+void VisualModel::SetOutlineWidth( unsigned int width )
{
mOutlineWidth = width;
}
return mUnderlineHeight;
}
-float VisualModel::GetOutlineWidth() const
+unsigned int VisualModel::GetOutlineWidth() const
{
return mOutlineWidth;
}
mControlSize(),
mShadowOffset(),
mUnderlineHeight( 0.0f ),
- mOutlineWidth( 0.0f ),
+ mOutlineWidth( 0u ),
mShadowBlurRadius( 0.0f ),
mNaturalSize(),
mLayoutSize(),
*
* @param[in] width The width in pixels of the outline, 0 indicates no outline
*/
- void SetOutlineWidth( float width );
+ void SetOutlineWidth( unsigned int width );
/**
* @brief Retrieves the width of an outline
*
* @return The width of the outline.
*/
- float GetOutlineWidth() const;
+ unsigned int GetOutlineWidth() const;
protected:
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.
- float mOutlineWidth; ///< Width of outline.
+ unsigned int mOutlineWidth; ///< Width of outline.
float mShadowBlurRadius; ///< Blur radius of shadow, 0 indicates no blur.
private: