Canvas: fix position for drag events and multiclick handling.

- Calculate local/client position for every drag event
   instead of just reporting the position of the initial
   mousedown event.
 - Only pressing the same button multiple times increases
   the mouse clickcount.
This commit is contained in:
Thomas Geymayer
2014-03-15 14:53:08 +01:00
parent 80e77b8372
commit f28e3fc9bb
7 changed files with 79 additions and 59 deletions
+12
View File
@@ -303,6 +303,18 @@ namespace canvas
return _transform.get();
}
//----------------------------------------------------------------------------
osg::Vec2f Element::posToLocal(const osg::Vec2f& pos) const
{
getMatrix();
const osg::Matrix& m = _transform->getInverseMatrix();
return osg::Vec2f
(
m(0, 0) * pos[0] + m(1, 0) * pos[1] + m(3, 0),
m(0, 1) * pos[0] + m(1, 1) * pos[1] + m(3, 1)
);
}
//----------------------------------------------------------------------------
void Element::childAdded(SGPropertyNode* parent, SGPropertyNode* child)
{
@@ -129,6 +129,11 @@ namespace canvas
osg::MatrixTransform* getMatrixTransform();
osg::MatrixTransform const* getMatrixTransform() const;
/**
* Transform position to local coordinages.
*/
osg::Vec2f posToLocal(const osg::Vec2f& pos) const;
virtual void childAdded( SGPropertyNode * parent,
SGPropertyNode * child );
virtual void childRemoved( SGPropertyNode * parent,