Verified Commit 341a0ec6 authored by Nathan Lee's avatar Nathan Lee Committed by Marc Jeanmougin
Browse files

On switch to measure tool, always remember old position

Previously we reset the measurement when it was off-screen,
which isn't too useful (as it was reset to the arbitrary
position 0,0, providing no benefits to the user).

Fix #2630
parent bd934929
Pipeline #367469988 canceled with stages
in 1 minute and 56 seconds
......@@ -170,8 +170,11 @@ Geom::Point calcAngleDisplayAnchor(SPDesktop *desktop, double angle, double base
// We now have the ideal position, but need to see if it will fit/work.
Geom::Rect screen_world = desktop->getCanvas()->get_area_world();
screen_world.expandBy(fontsize * -3, fontsize / -2);
where = desktop->w2d(screen_world.clamp(desktop->d2w(where)));
if (screen_world.interiorContains(desktop->d2w(startPoint)) ||
screen_world.interiorContains(desktop->d2w(endPoint))) {
screen_world.expandBy(fontsize * -3, fontsize / -2);
where = desktop->w2d(screen_world.clamp(desktop->d2w(where)));
} // else likely initialized the measurement tool, keep display near the measurement.
return where;
}
......@@ -342,6 +345,8 @@ MeasureTool::MeasureTool()
this->knot_start->setStroke(0x0000007f, 0x0000007f, 0x0000007f, 0x0000007f);
this->knot_start->setShape(Inkscape::CANVAS_ITEM_CTRL_SHAPE_CIRCLE);
this->knot_start->updateCtrl();
this->knot_start->moveto(start_p);
this->knot_start->show();
this->knot_end = new SPKnot(desktop, _("Measure end, <b>Shift+Click</b> for position dialog"),
Inkscape::CANVAS_ITEM_CTRL_TYPE_SHAPER, "CanvasItemCtrl:MeasureTool");
......@@ -350,21 +355,10 @@ MeasureTool::MeasureTool()
this->knot_end->setStroke(0x0000007f, 0x0000007f, 0x0000007f, 0x0000007f);
this->knot_end->setShape(Inkscape::CANVAS_ITEM_CTRL_SHAPE_CIRCLE);
this->knot_end->updateCtrl();
this->knot_end->moveto(end_p);
this->knot_end->show();
Geom::Rect screen_world = desktop->getCanvas()->get_area_world();
if (screen_world.interiorContains(desktop->d2w(start_p)) && //
screen_world.interiorContains(desktop->d2w(end_p)) && end_p != Geom::Point()) {
this->knot_start->moveto(start_p);
this->knot_start->show();
this->knot_end->moveto(end_p);
this->knot_end->show();
showCanvasItems();
} else {
start_p = Geom::Point(0,0);
end_p = Geom::Point(0,0);
writeMeasurePoint(start_p, true);
writeMeasurePoint(end_p, false);
}
showCanvasItems();
this->_knot_start_moved_connection = this->knot_start->moved_signal.connect(sigc::mem_fun(*this, &MeasureTool::knotStartMovedHandler));
this->_knot_start_click_connection = this->knot_start->click_signal.connect(sigc::mem_fun(*this, &MeasureTool::knotClickHandler));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment