From 1f71993e8a296b051b010434daead48c0d602f45 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Sat, 11 Jul 2020 14:19:48 +0300 Subject: [PATCH] Correctly positioned mouse clicks --- applications/gui2/src/views/camera.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/applications/gui2/src/views/camera.cpp b/applications/gui2/src/views/camera.cpp index 004b1f854..16b009482 100644 --- a/applications/gui2/src/views/camera.cpp +++ b/applications/gui2/src/views/camera.cpp @@ -138,9 +138,11 @@ CameraView::~CameraView() { bool CameraView::mouseButtonEvent(const Eigen::Vector2i &p, int button, bool down, int modifiers) { //LOG(INFO) << "mouseButtonEvent: " << p << " - " << button; - if (button == 0) { - // FIXME: Allow for zoom and offset of image... - ctrl_->touch(0, ftl::codecs::TouchType::MOUSE_LEFT, p.x()-mPos.x(), p.y()-mPos.y(), 0.0f); + if (button == 0 && !down) { + auto pos = imview_->imageCoordinateAt((p - mPos).cast<float>()); + if (pos.x() >= 0.0f && pos.y() >= 0.0f) { + ctrl_->touch(0, ftl::codecs::TouchType::MOUSE_LEFT, pos.x(), pos.y(), 0.0f); + } return true; } return false; -- GitLab