Canvas: backdrop/stroke option for text (based on Gijs patch).

This commit is contained in:
Thomas Geymayer 2014-07-27 11:05:49 +02:00
parent 92851135d4
commit 719ee36f5c

View File

@ -38,6 +38,7 @@ namespace canvas
void setCharacterAspect(float aspect); void setCharacterAspect(float aspect);
void setLineHeight(float factor); void setLineHeight(float factor);
void setFill(const std::string& fill); void setFill(const std::string& fill);
void setStroke(const std::string& color);
void setBackgroundColor(const std::string& fill); void setBackgroundColor(const std::string& fill);
SGVec2i sizeForWidth(int w) const; SGVec2i sizeForWidth(int w) const;
@ -88,6 +89,19 @@ namespace canvas
setColor( color ); setColor( color );
} }
//----------------------------------------------------------------------------
void Text::TextOSG::setStroke(const std::string& stroke)
{
osg::Vec4 color;
if( stroke == "none" || !parseColor(stroke, color) )
setBackdropType(NONE);
else
{
setBackdropType(OUTLINE);
setBackdropColor(color);
}
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void Text::TextOSG::setBackgroundColor(const std::string& fill) void Text::TextOSG::setBackgroundColor(const std::string& fill)
{ {
@ -546,6 +560,7 @@ namespace canvas
addStyle("fill", "color", &TextOSG::setFill, text); addStyle("fill", "color", &TextOSG::setFill, text);
addStyle("background", "color", &TextOSG::setBackgroundColor, text); addStyle("background", "color", &TextOSG::setBackgroundColor, text);
addStyle("stroke", "color", &TextOSG::setStroke, text);
addStyle("character-size", addStyle("character-size",
"numeric", "numeric",
static_cast< static_cast<