From: Thomas Geymayer Date: Sat, 8 Dec 2012 13:59:29 +0000 (+0100) Subject: Canvas: MouseEvent now contains screen and client pos X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a882263033de7633a3b91ace231f237d66ac1532;p=simgear.git Canvas: MouseEvent now contains screen and client pos --- diff --git a/simgear/canvas/Canvas.cxx b/simgear/canvas/Canvas.cxx index ef8f266d..c2882ebf 100644 --- a/simgear/canvas/Canvas.cxx +++ b/simgear/canvas/Canvas.cxx @@ -350,8 +350,8 @@ namespace canvas //---------------------------------------------------------------------------- bool Canvas::handleMouseEvent(const MouseEventPtr& event) { - _mouse_x = event->pos.x(); - _mouse_y = event->pos.y(); + _mouse_x = event->client_pos.x(); + _mouse_y = event->client_pos.y(); _mouse_dx = event->delta.x(); _mouse_dy = event->delta.y(); _mouse_button = event->button; @@ -365,7 +365,7 @@ namespace canvas return false; EventVisitor visitor( EventVisitor::TRAVERSE_DOWN, - event->getPos(), + event->getClientPos(), event->getDelta() ); if( !_root_group->accept(visitor) ) return false; diff --git a/simgear/canvas/CanvasEventManager.cxx b/simgear/canvas/CanvasEventManager.cxx index d7135f80..53da08d1 100644 --- a/simgear/canvas/CanvasEventManager.cxx +++ b/simgear/canvas/CanvasEventManager.cxx @@ -180,17 +180,21 @@ namespace canvas // (eg. removed by another event handler) continue; - if( mouse_event && event->type != Event::DRAG ) - { - // TODO transform pos and delta for drag events. Maybe we should just - // store the global coordinates and convert to local coordinates - // on demand. - - // Position and delta are specified in local coordinate system of - // current element - mouse_event->pos = it->local_pos; - mouse_event->delta = it->local_delta; - } + // TODO provide functions to convert position and delta to local + // coordinates on demand. Events shouldn't contain informations in + // local coordinates as they might differe between different elements + // receiving the same event. +// if( mouse_event && event->type != Event::DRAG ) +// { +// // TODO transform pos and delta for drag events. Maybe we should just +// // store the global coordinates and convert to local coordinates +// // on demand. +// +// // Position and delta are specified in local coordinate system of +// // current element +// mouse_event->pos = it->local_pos; +// mouse_event->delta = it->local_delta; +// } el->callListeners(event); diff --git a/simgear/canvas/MouseEvent.hxx b/simgear/canvas/MouseEvent.hxx index 31694171..5bbfb993 100644 --- a/simgear/canvas/MouseEvent.hxx +++ b/simgear/canvas/MouseEvent.hxx @@ -38,19 +38,23 @@ namespace canvas click_count(0) {} - osg::Vec2f getPos() const { return pos; } - osg::Vec3f getPos3() const { return osg::Vec3f(pos, 0); } + osg::Vec2f getScreenPos() const { return screen_pos; } + osg::Vec2f getClientPos() const { return client_pos; } osg::Vec2f getDelta() const { return delta; } - float getPosX() const { return pos.x(); } - float getPosY() const { return pos.y(); } + float getScreenX() const { return screen_pos.x(); } + float getScreenY() const { return screen_pos.y(); } + + float getClientX() const { return client_pos.x(); } + float getClientY() const { return client_pos.y(); } float getDeltaX() const { return delta.x(); } float getDeltaY() const { return delta.y(); } int getCurrentClickCount() const { return click_count; } - osg::Vec2f pos, + osg::Vec2f screen_pos, //