Helper functions for SGRect and canvas::Element
This commit is contained in:
@@ -244,6 +244,11 @@ namespace canvas
|
|||||||
return _transform;
|
return _transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::MatrixTransform const> Element::getMatrixTransform() const
|
||||||
|
{
|
||||||
|
return _transform;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void Element::childAdded(SGPropertyNode* parent, SGPropertyNode* child)
|
void Element::childAdded(SGPropertyNode* parent, SGPropertyNode* child)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ namespace canvas
|
|||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
|
|
||||||
osg::ref_ptr<osg::MatrixTransform> getMatrixTransform();
|
osg::ref_ptr<osg::MatrixTransform> getMatrixTransform();
|
||||||
|
osg::ref_ptr<osg::MatrixTransform const> getMatrixTransform() const;
|
||||||
|
|
||||||
virtual void childAdded( SGPropertyNode * parent,
|
virtual void childAdded( SGPropertyNode * parent,
|
||||||
SGPropertyNode * child );
|
SGPropertyNode * child );
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ namespace canvas
|
|||||||
{
|
{
|
||||||
addStyle("fill", "color", &Image::setFill);
|
addStyle("fill", "color", &Image::setFill);
|
||||||
addStyle("slice", "", &Image::setSlice);
|
addStyle("slice", "", &Image::setSlice);
|
||||||
addStyle("slice-width", "numeric", &Image::setSliceWidth);
|
addStyle("slice-width", "", &Image::setSliceWidth);
|
||||||
addStyle("outset", "", &Image::setOutset);
|
addStyle("outset", "", &Image::setOutset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace canvas
|
|||||||
*/
|
*/
|
||||||
Image( const CanvasWeakPtr& canvas,
|
Image( const CanvasWeakPtr& canvas,
|
||||||
const SGPropertyNode_ptr& node,
|
const SGPropertyNode_ptr& node,
|
||||||
const Style& parent_style,
|
const Style& parent_style = Style(),
|
||||||
Element* parent = 0 );
|
Element* parent = 0 );
|
||||||
virtual ~Image();
|
virtual ~Image();
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,26 @@ class SGRect
|
|||||||
void setTop(T t) { _min.y() = t; }
|
void setTop(T t) { _min.y() = t; }
|
||||||
void setBottom(T b) { _max.y() = b; }
|
void setBottom(T b) { _max.y() = b; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move rect by vector
|
||||||
|
*/
|
||||||
|
SGRect& operator+=(const SGVec2<T>& offset)
|
||||||
|
{
|
||||||
|
_min += offset;
|
||||||
|
_max += offset;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move rect by vector in inverse direction
|
||||||
|
*/
|
||||||
|
SGRect& operator-=(const SGVec2<T>& offset)
|
||||||
|
{
|
||||||
|
_min -= offset;
|
||||||
|
_max -= offset;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool contains(T x, T y) const
|
bool contains(T x, T y) const
|
||||||
{
|
{
|
||||||
return _min.x() <= x && x <= _max.x()
|
return _min.x() <= x && x <= _max.x()
|
||||||
@@ -126,6 +146,30 @@ class SGRect
|
|||||||
_max;
|
_max;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline SGRect<T> operator+(SGRect<T> rect, const SGVec2<T>& offset)
|
||||||
|
{
|
||||||
|
return rect += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline SGRect<T> operator+(const SGVec2<T>& offset, SGRect<T> rect)
|
||||||
|
{
|
||||||
|
return rect += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline SGRect<T> operator-(SGRect<T> rect, const SGVec2<T>& offset)
|
||||||
|
{
|
||||||
|
return rect -= offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline SGRect<T> operator-(const SGVec2<T>& offset, SGRect<T> rect)
|
||||||
|
{
|
||||||
|
return rect -= offset;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename char_type, typename traits_type, typename T>
|
template<typename char_type, typename traits_type, typename T>
|
||||||
inline
|
inline
|
||||||
std::basic_ostream<char_type, traits_type>&
|
std::basic_ostream<char_type, traits_type>&
|
||||||
|
|||||||
Reference in New Issue
Block a user