From 0e0d7a98d509d3b6872dc871176b2861890bdabf Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Wed, 24 Aug 2016 21:56:14 +0300 Subject: [PATCH] Fix ScaleWidget not moving when surface moved --- src/Application/ScaleWidget.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Application/ScaleWidget.cpp b/src/Application/ScaleWidget.cpp index 7999826..b2b6243 100644 --- a/src/Application/ScaleWidget.cpp +++ b/src/Application/ScaleWidget.cpp @@ -30,6 +30,16 @@ void ScaleWidget::draw(){ _surface->getBoundingBox().x + _surface->getBoundingBox().width, _surface->getBoundingBox().y)); + // Handle surface move + float dx = _line[0].x - centroid.x; + float dy = _line[0].y - centroid.y; + + _line[0].x -= dx; + _line[0].y -= dy; + _line[1].x -= dx; + _line[1].y -= dy; + + // Continue float scale = lineLength / _line[0].distance(_line[1]); _line[1].x = _line[0].x + (_line[1].x - _line[0].x) * scale;