+ //----------------------------------------------------------------------------
+ bool Image::handleMouseEvent(MouseEventPtr event)
+ {
+ CanvasPtr src_canvas = _src_canvas.lock();
+
+ if( !src_canvas )
+ return false;
+
+ if( _outset.valid )
+ {
+ CSSOffsets outset = _outset.getAbsOffsets(getTextureDimensions());
+
+ event.reset( new MouseEvent(*event) );
+ event->client_pos += osg::Vec2f(outset.l, outset.t);
+ event->client_pos.x() *= src_canvas->getViewWidth()
+ / (_region.width() + outset.l + outset.r);
+ event->client_pos.y() *= src_canvas->getViewHeight()
+ / (_region.height() + outset.t + outset.b);
+ }
+
+ return src_canvas->handleMouseEvent(event);
+ }
+
+ //----------------------------------------------------------------------------
+ Image::CSSOffsets
+ Image::CSSBorder::getRelOffsets(const SGRect<int>& dim) const
+ {
+ CSSOffsets ret;
+ for(int i = 0; i < 4; ++i)
+ {
+ ret.val[i] = offsets.val[i];
+ if( !types.rel[i] )
+ ret.val[i] /= (i & 1) ? dim.height() : dim.width();
+ }
+ return ret;
+ }
+
+ //----------------------------------------------------------------------------
+ Image::CSSOffsets
+ Image::CSSBorder::getAbsOffsets(const SGRect<int>& dim) const
+ {
+ CSSOffsets ret;
+ for(int i = 0; i < 4; ++i)
+ {
+ ret.val[i] = offsets.val[i];
+ if( types.rel[i] )
+ ret.val[i] *= (i & 1) ? dim.height() : dim.width();
+ }
+ return ret;
+ }
+