From d4b052d34d94a62d9a9921f9c7916c4821bb325a Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Tue, 24 Jan 2017 23:54:10 +0700 Subject: [PATCH] Fix logic introduced in 55ae10b. Before this commit, the effect of the AddPending() call was immediately reversed by ClearSuper. --- src/draw.cpp | 6 +----- src/mouse.cpp | 16 +++++++++++++--- src/ui.h | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/draw.cpp b/src/draw.cpp index 849c24843..8fb4b3b75 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -336,10 +336,6 @@ GraphicsWindow::Selection GraphicsWindow::ChooseFromHoverToSelect() { for(const Hover &hov : hoverList) { hGroup hg = {}; if(hov.selection.entity.v != 0) { - hEntity he = hov.selection.entity; - if(he.isFromRequest() && IsFromPending(he.request())) { - continue; - } hg = SK.GetEntity(hov.selection.entity)->group; } else if(hov.selection.constraint.v != 0) { hg = SK.GetConstraint(hov.selection.constraint)->group; @@ -399,7 +395,7 @@ void GraphicsWindow::HitTestMakeSelection(Point2d mp) { if(!e.IsVisible()) continue; // Don't hover whatever's being dragged. - if(e.h.request().v == pending.point.request().v) { + if(IsFromPending(e.h.request())) { // The one exception is when we're creating a new cubic; we // want to be able to hover the first point, because that's // how we turn it into a periodic spline. diff --git a/src/mouse.cpp b/src/mouse.cpp index 9948d50ee..db11b4bb3 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -485,6 +485,14 @@ void GraphicsWindow::AddToPending(hRequest r) { pending.requests.Add(&r); } +void GraphicsWindow::ReplacePending(hRequest before, hRequest after) { + for(auto &req : pending.requests) { + if(req.v == before.v) { + req.v = after.v; + } + } +} + void GraphicsWindow::MouseMiddleOrRightDown(double x, double y) { if(GraphicsEditControlIsVisible()) return; @@ -956,12 +964,12 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { case Command::LINE_SEGMENT: case Command::CONSTR_SEGMENT: hr = AddRequest(Request::Type::LINE_SEGMENT); - AddToPending(hr); SK.GetRequest(hr)->construction = (pending.command == Command::CONSTR_SEGMENT); SK.GetEntity(hr.entity(1))->PointForceTo(v); ConstrainPointByHovered(hr.entity(1)); ClearSuper(); + AddToPending(hr); pending.operation = Pending::DRAGGING_NEW_LINE_POINT; pending.request = hr; @@ -1037,7 +1045,6 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { break; } hr = AddRequest(Request::Type::ARC_OF_CIRCLE); - AddToPending(hr); // This fudge factor stops us from immediately failing to solve // because of the arc's implicit (equal radius) tangent. Vector adj = SS.GW.projRight.WithMagnitude(2/SS.GW.scale); @@ -1047,6 +1054,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { ConstrainPointByHovered(hr.entity(2)); ClearSuper(); + AddToPending(hr); pending.operation = Pending::DRAGGING_NEW_ARC_POINT; pending.point = hr.entity(3); @@ -1055,7 +1063,6 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { } case Command::CUBIC: hr = AddRequest(Request::Type::CUBIC); - AddToPending(hr); SK.GetEntity(hr.entity(1))->PointForceTo(v); SK.GetEntity(hr.entity(2))->PointForceTo(v); SK.GetEntity(hr.entity(3))->PointForceTo(v); @@ -1063,6 +1070,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { ConstrainPointByHovered(hr.entity(1)); ClearSuper(); + AddToPending(hr); pending.operation = Pending::DRAGGING_NEW_CUBIC_POINT; pending.point = hr.entity(4); @@ -1093,6 +1101,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { break; } hr = AddRequest(Request::Type::TTF_TEXT); + AddToPending(hr); Request *r = SK.GetRequest(hr); r->str = "Abc"; r->font = "arial.ttf"; @@ -1211,6 +1220,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { // Create a new line segment, so that we continue drawing. hRequest hr = AddRequest(Request::Type::LINE_SEGMENT); + ReplacePending(pending.request, hr); SK.GetRequest(hr)->construction = SK.GetRequest(pending.request)->construction; SK.GetEntity(hr.entity(1))->PointForceTo(v); // Displace the second point of the new line segment slightly, diff --git a/src/ui.h b/src/ui.h index ee00960f1..cee4a1f82 100644 --- a/src/ui.h +++ b/src/ui.h @@ -720,6 +720,7 @@ class GraphicsWindow { void ClearPending(); bool IsFromPending(hRequest r); void AddToPending(hRequest r); + void ReplacePending(hRequest before, hRequest after); // The constraint that is being edited with the on-screen textbox. hConstraint constraintBeingEdited;