Canvas image fill and source rect setters.

C++ code can set the fill and source rect directly.
This commit is contained in:
James Turner
2016-12-16 09:24:40 +00:00
parent b29536f8b7
commit 2f21b582cd
2 changed files with 21 additions and 3 deletions

View File

@@ -487,11 +487,17 @@ namespace canvas
if( !fill.empty() // If no color is given default to white
&& !parseColor(fill, color) )
return;
_colors->front() = color;
_colors->dirty();
setFill(color);
}
//----------------------------------------------------------------------------
void Image::setFill(const osg::Vec4& color)
{
_colors->front() = color;
_colors->dirty();
}
//----------------------------------------------------------------------------
void Image::setOutset(const std::string& outset)
{
@@ -506,6 +512,13 @@ namespace canvas
_attributes_dirty |= SRC_RECT;
}
//----------------------------------------------------------------------------
void Image::setSourceRect(const SGRect<float>& sourceRect)
{
_attributes_dirty |= SRC_RECT;
_src_rect = sourceRect;
}
//----------------------------------------------------------------------------
void Image::setSlice(const std::string& slice)
{

View File

@@ -61,6 +61,7 @@ namespace canvas
void setImage(osg::ref_ptr<osg::Image> img);
void setFill(const std::string& fill);
void setFill(const osg::Vec4& color);
/**
* @see http://www.w3.org/TR/css3-background/#border-image-outset
@@ -95,6 +96,10 @@ namespace canvas
bool handleEvent(const EventPtr& event);
/**
*
*/
void setSourceRect(const SGRect<float>& sourceRect);
protected:
enum ImageAttributes