From: Thomas Geymayer Date: Thu, 6 Jun 2013 20:28:00 +0000 (+0200) Subject: Helper functions for SGRect and canvas::Element X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8896a59dff3a5efc5d5be3e999e662bf0f174b60;p=simgear.git Helper functions for SGRect and canvas::Element --- diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx index fcadfc66..af725d57 100644 --- a/simgear/canvas/elements/CanvasElement.cxx +++ b/simgear/canvas/elements/CanvasElement.cxx @@ -244,6 +244,11 @@ namespace canvas return _transform; } + osg::ref_ptr Element::getMatrixTransform() const + { + return _transform; + } + //---------------------------------------------------------------------------- void Element::childAdded(SGPropertyNode* parent, SGPropertyNode* child) { diff --git a/simgear/canvas/elements/CanvasElement.hxx b/simgear/canvas/elements/CanvasElement.hxx index 136fd5fc..b7d06f75 100644 --- a/simgear/canvas/elements/CanvasElement.hxx +++ b/simgear/canvas/elements/CanvasElement.hxx @@ -103,6 +103,7 @@ namespace canvas bool isVisible() const; osg::ref_ptr getMatrixTransform(); + osg::ref_ptr getMatrixTransform() const; virtual void childAdded( SGPropertyNode * parent, SGPropertyNode * child ); diff --git a/simgear/canvas/elements/CanvasImage.cxx b/simgear/canvas/elements/CanvasImage.cxx index 5cd5ddc3..bd3e7403 100644 --- a/simgear/canvas/elements/CanvasImage.cxx +++ b/simgear/canvas/elements/CanvasImage.cxx @@ -129,7 +129,7 @@ namespace canvas { addStyle("fill", "color", &Image::setFill); addStyle("slice", "", &Image::setSlice); - addStyle("slice-width", "numeric", &Image::setSliceWidth); + addStyle("slice-width", "", &Image::setSliceWidth); addStyle("outset", "", &Image::setOutset); } diff --git a/simgear/canvas/elements/CanvasImage.hxx b/simgear/canvas/elements/CanvasImage.hxx index 3b8dca78..741d74d8 100644 --- a/simgear/canvas/elements/CanvasImage.hxx +++ b/simgear/canvas/elements/CanvasImage.hxx @@ -43,7 +43,7 @@ namespace canvas */ Image( const CanvasWeakPtr& canvas, const SGPropertyNode_ptr& node, - const Style& parent_style, + const Style& parent_style = Style(), Element* parent = 0 ); virtual ~Image(); diff --git a/simgear/math/SGRect.hxx b/simgear/math/SGRect.hxx index 7e70a124..ad5771e9 100644 --- a/simgear/math/SGRect.hxx +++ b/simgear/math/SGRect.hxx @@ -109,6 +109,26 @@ class SGRect void setTop(T t) { _min.y() = t; } void setBottom(T b) { _max.y() = b; } + /** + * Move rect by vector + */ + SGRect& operator+=(const SGVec2& offset) + { + _min += offset; + _max += offset; + return *this; + } + + /** + * Move rect by vector in inverse direction + */ + SGRect& operator-=(const SGVec2& offset) + { + _min -= offset; + _max -= offset; + return *this; + } + bool contains(T x, T y) const { return _min.x() <= x && x <= _max.x() @@ -126,6 +146,30 @@ class SGRect _max; }; +template +inline SGRect operator+(SGRect rect, const SGVec2& offset) +{ + return rect += offset; +} + +template +inline SGRect operator+(const SGVec2& offset, SGRect rect) +{ + return rect += offset; +} + +template +inline SGRect operator-(SGRect rect, const SGVec2& offset) +{ + return rect -= offset; +} + +template +inline SGRect operator-(const SGVec2& offset, SGRect rect) +{ + return rect -= offset; +} + template inline std::basic_ostream&