Canvas window: increase drag accuracy.
This commit is contained in:
parent
02e66fd034
commit
e79e70062e
3 changed files with 14 additions and 9 deletions
|
@ -116,6 +116,7 @@ class DesktopGroup:
|
|||
uint8_t _resize;
|
||||
int _last_cursor;
|
||||
|
||||
osg::Vec2 _drag_start;
|
||||
float _last_x,
|
||||
_last_y;
|
||||
double _last_scroll_time;
|
||||
|
@ -302,7 +303,8 @@ bool DesktopGroup::handleMouse(const osgGA::GUIEventAdapter& ea)
|
|||
_resize_window.reset();
|
||||
break;
|
||||
case osgGA::GUIEventAdapter::DRAG:
|
||||
_resize_window.lock()->handleResize(_resize, event->delta);
|
||||
_resize_window.lock()->handleResize( _resize,
|
||||
event->screen_pos - _drag_start );
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -379,9 +381,10 @@ bool DesktopGroup::handleMouse(const osgGA::GUIEventAdapter& ea)
|
|||
if( ea.getEventType() == osgGA::GUIEventAdapter::PUSH )
|
||||
{
|
||||
_resize_window = window_at_cursor;
|
||||
_drag_start = event->screen_pos;
|
||||
|
||||
window_at_cursor->raise();
|
||||
window_at_cursor->handleResize( _resize | canvas::Window::INIT,
|
||||
event->delta );
|
||||
window_at_cursor->handleResize(_resize | canvas::Window::INIT);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -163,7 +163,8 @@ namespace canvas
|
|||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void Window::handleResize(uint8_t mode, const osg::Vec2f& delta)
|
||||
void Window::handleResize( uint8_t mode,
|
||||
const osg::Vec2f& offset )
|
||||
{
|
||||
if( mode == NONE )
|
||||
{
|
||||
|
@ -180,14 +181,14 @@ namespace canvas
|
|||
}
|
||||
|
||||
if( mode & BOTTOM )
|
||||
_resize_bottom += delta.y();
|
||||
_resize_bottom = getRegion().b() + offset.y();
|
||||
else if( mode & TOP )
|
||||
_resize_top += delta.y();
|
||||
_resize_top = getRegion().t() + offset.y();
|
||||
|
||||
if( mode & canvas::Window::RIGHT )
|
||||
_resize_right += delta.x();
|
||||
_resize_right = getRegion().r() + offset.x();
|
||||
else if( mode & canvas::Window::LEFT )
|
||||
_resize_left += delta.x();
|
||||
_resize_left = getRegion().l() + offset.x();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -76,7 +76,8 @@ namespace canvas
|
|||
*/
|
||||
void raise();
|
||||
|
||||
void handleResize(uint8_t mode, const osg::Vec2f& delta = osg::Vec2f());
|
||||
void handleResize( uint8_t mode,
|
||||
const osg::Vec2f& offset = osg::Vec2f() );
|
||||
|
||||
protected:
|
||||
|
||||
|
|
Loading…
Reference in a new issue