Fix logic introduced in 55ae10b.

Before this commit, the effect of the AddPending() call was
immediately reversed by ClearSuper.
This commit is contained in:
EvilSpirit 2017-01-24 23:54:10 +07:00 committed by whitequark
parent 3fc85b7934
commit d4b052d34d
3 changed files with 15 additions and 8 deletions

View File

@ -336,10 +336,6 @@ GraphicsWindow::Selection GraphicsWindow::ChooseFromHoverToSelect() {
for(const Hover &hov : hoverList) { for(const Hover &hov : hoverList) {
hGroup hg = {}; hGroup hg = {};
if(hov.selection.entity.v != 0) { 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; hg = SK.GetEntity(hov.selection.entity)->group;
} else if(hov.selection.constraint.v != 0) { } else if(hov.selection.constraint.v != 0) {
hg = SK.GetConstraint(hov.selection.constraint)->group; hg = SK.GetConstraint(hov.selection.constraint)->group;
@ -399,7 +395,7 @@ void GraphicsWindow::HitTestMakeSelection(Point2d mp) {
if(!e.IsVisible()) continue; if(!e.IsVisible()) continue;
// Don't hover whatever's being dragged. // 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 // The one exception is when we're creating a new cubic; we
// want to be able to hover the first point, because that's // want to be able to hover the first point, because that's
// how we turn it into a periodic spline. // how we turn it into a periodic spline.

View File

@ -485,6 +485,14 @@ void GraphicsWindow::AddToPending(hRequest r) {
pending.requests.Add(&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) { void GraphicsWindow::MouseMiddleOrRightDown(double x, double y) {
if(GraphicsEditControlIsVisible()) return; if(GraphicsEditControlIsVisible()) return;
@ -956,12 +964,12 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
case Command::LINE_SEGMENT: case Command::LINE_SEGMENT:
case Command::CONSTR_SEGMENT: case Command::CONSTR_SEGMENT:
hr = AddRequest(Request::Type::LINE_SEGMENT); hr = AddRequest(Request::Type::LINE_SEGMENT);
AddToPending(hr);
SK.GetRequest(hr)->construction = (pending.command == Command::CONSTR_SEGMENT); SK.GetRequest(hr)->construction = (pending.command == Command::CONSTR_SEGMENT);
SK.GetEntity(hr.entity(1))->PointForceTo(v); SK.GetEntity(hr.entity(1))->PointForceTo(v);
ConstrainPointByHovered(hr.entity(1)); ConstrainPointByHovered(hr.entity(1));
ClearSuper(); ClearSuper();
AddToPending(hr);
pending.operation = Pending::DRAGGING_NEW_LINE_POINT; pending.operation = Pending::DRAGGING_NEW_LINE_POINT;
pending.request = hr; pending.request = hr;
@ -1037,7 +1045,6 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
break; break;
} }
hr = AddRequest(Request::Type::ARC_OF_CIRCLE); hr = AddRequest(Request::Type::ARC_OF_CIRCLE);
AddToPending(hr);
// This fudge factor stops us from immediately failing to solve // This fudge factor stops us from immediately failing to solve
// because of the arc's implicit (equal radius) tangent. // because of the arc's implicit (equal radius) tangent.
Vector adj = SS.GW.projRight.WithMagnitude(2/SS.GW.scale); 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)); ConstrainPointByHovered(hr.entity(2));
ClearSuper(); ClearSuper();
AddToPending(hr);
pending.operation = Pending::DRAGGING_NEW_ARC_POINT; pending.operation = Pending::DRAGGING_NEW_ARC_POINT;
pending.point = hr.entity(3); pending.point = hr.entity(3);
@ -1055,7 +1063,6 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
} }
case Command::CUBIC: case Command::CUBIC:
hr = AddRequest(Request::Type::CUBIC); hr = AddRequest(Request::Type::CUBIC);
AddToPending(hr);
SK.GetEntity(hr.entity(1))->PointForceTo(v); SK.GetEntity(hr.entity(1))->PointForceTo(v);
SK.GetEntity(hr.entity(2))->PointForceTo(v); SK.GetEntity(hr.entity(2))->PointForceTo(v);
SK.GetEntity(hr.entity(3))->PointForceTo(v); SK.GetEntity(hr.entity(3))->PointForceTo(v);
@ -1063,6 +1070,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
ConstrainPointByHovered(hr.entity(1)); ConstrainPointByHovered(hr.entity(1));
ClearSuper(); ClearSuper();
AddToPending(hr);
pending.operation = Pending::DRAGGING_NEW_CUBIC_POINT; pending.operation = Pending::DRAGGING_NEW_CUBIC_POINT;
pending.point = hr.entity(4); pending.point = hr.entity(4);
@ -1093,6 +1101,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
break; break;
} }
hr = AddRequest(Request::Type::TTF_TEXT); hr = AddRequest(Request::Type::TTF_TEXT);
AddToPending(hr);
Request *r = SK.GetRequest(hr); Request *r = SK.GetRequest(hr);
r->str = "Abc"; r->str = "Abc";
r->font = "arial.ttf"; 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. // Create a new line segment, so that we continue drawing.
hRequest hr = AddRequest(Request::Type::LINE_SEGMENT); hRequest hr = AddRequest(Request::Type::LINE_SEGMENT);
ReplacePending(pending.request, hr);
SK.GetRequest(hr)->construction = SK.GetRequest(pending.request)->construction; SK.GetRequest(hr)->construction = SK.GetRequest(pending.request)->construction;
SK.GetEntity(hr.entity(1))->PointForceTo(v); SK.GetEntity(hr.entity(1))->PointForceTo(v);
// Displace the second point of the new line segment slightly, // Displace the second point of the new line segment slightly,

View File

@ -720,6 +720,7 @@ public:
void ClearPending(); void ClearPending();
bool IsFromPending(hRequest r); bool IsFromPending(hRequest r);
void AddToPending(hRequest r); void AddToPending(hRequest r);
void ReplacePending(hRequest before, hRequest after);
// The constraint that is being edited with the on-screen textbox. // The constraint that is being edited with the on-screen textbox.
hConstraint constraintBeingEdited; hConstraint constraintBeingEdited;