Skip to content

Commit d4b052d

Browse files
Evil-Spiritwhitequark
authored andcommitted
Fix logic introduced in 55ae10b.
Before this commit, the effect of the AddPending() call was immediately reversed by ClearSuper.
1 parent 3fc85b7 commit d4b052d

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/draw.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,6 @@ GraphicsWindow::Selection GraphicsWindow::ChooseFromHoverToSelect() {
336336
for(const Hover &hov : hoverList) {
337337
hGroup hg = {};
338338
if(hov.selection.entity.v != 0) {
339-
hEntity he = hov.selection.entity;
340-
if(he.isFromRequest() && IsFromPending(he.request())) {
341-
continue;
342-
}
343339
hg = SK.GetEntity(hov.selection.entity)->group;
344340
} else if(hov.selection.constraint.v != 0) {
345341
hg = SK.GetConstraint(hov.selection.constraint)->group;
@@ -399,7 +395,7 @@ void GraphicsWindow::HitTestMakeSelection(Point2d mp) {
399395
if(!e.IsVisible()) continue;
400396

401397
// Don't hover whatever's being dragged.
402-
if(e.h.request().v == pending.point.request().v) {
398+
if(IsFromPending(e.h.request())) {
403399
// The one exception is when we're creating a new cubic; we
404400
// want to be able to hover the first point, because that's
405401
// how we turn it into a periodic spline.

src/mouse.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,14 @@ void GraphicsWindow::AddToPending(hRequest r) {
485485
pending.requests.Add(&r);
486486
}
487487

488+
void GraphicsWindow::ReplacePending(hRequest before, hRequest after) {
489+
for(auto &req : pending.requests) {
490+
if(req.v == before.v) {
491+
req.v = after.v;
492+
}
493+
}
494+
}
495+
488496
void GraphicsWindow::MouseMiddleOrRightDown(double x, double y) {
489497
if(GraphicsEditControlIsVisible()) return;
490498

@@ -956,12 +964,12 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
956964
case Command::LINE_SEGMENT:
957965
case Command::CONSTR_SEGMENT:
958966
hr = AddRequest(Request::Type::LINE_SEGMENT);
959-
AddToPending(hr);
960967
SK.GetRequest(hr)->construction = (pending.command == Command::CONSTR_SEGMENT);
961968
SK.GetEntity(hr.entity(1))->PointForceTo(v);
962969
ConstrainPointByHovered(hr.entity(1));
963970

964971
ClearSuper();
972+
AddToPending(hr);
965973

966974
pending.operation = Pending::DRAGGING_NEW_LINE_POINT;
967975
pending.request = hr;
@@ -1037,7 +1045,6 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
10371045
break;
10381046
}
10391047
hr = AddRequest(Request::Type::ARC_OF_CIRCLE);
1040-
AddToPending(hr);
10411048
// This fudge factor stops us from immediately failing to solve
10421049
// because of the arc's implicit (equal radius) tangent.
10431050
Vector adj = SS.GW.projRight.WithMagnitude(2/SS.GW.scale);
@@ -1047,6 +1054,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
10471054
ConstrainPointByHovered(hr.entity(2));
10481055

10491056
ClearSuper();
1057+
AddToPending(hr);
10501058

10511059
pending.operation = Pending::DRAGGING_NEW_ARC_POINT;
10521060
pending.point = hr.entity(3);
@@ -1055,14 +1063,14 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
10551063
}
10561064
case Command::CUBIC:
10571065
hr = AddRequest(Request::Type::CUBIC);
1058-
AddToPending(hr);
10591066
SK.GetEntity(hr.entity(1))->PointForceTo(v);
10601067
SK.GetEntity(hr.entity(2))->PointForceTo(v);
10611068
SK.GetEntity(hr.entity(3))->PointForceTo(v);
10621069
SK.GetEntity(hr.entity(4))->PointForceTo(v);
10631070
ConstrainPointByHovered(hr.entity(1));
10641071

10651072
ClearSuper();
1073+
AddToPending(hr);
10661074

10671075
pending.operation = Pending::DRAGGING_NEW_CUBIC_POINT;
10681076
pending.point = hr.entity(4);
@@ -1093,6 +1101,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
10931101
break;
10941102
}
10951103
hr = AddRequest(Request::Type::TTF_TEXT);
1104+
AddToPending(hr);
10961105
Request *r = SK.GetRequest(hr);
10971106
r->str = "Abc";
10981107
r->font = "arial.ttf";
@@ -1211,6 +1220,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) {
12111220

12121221
// Create a new line segment, so that we continue drawing.
12131222
hRequest hr = AddRequest(Request::Type::LINE_SEGMENT);
1223+
ReplacePending(pending.request, hr);
12141224
SK.GetRequest(hr)->construction = SK.GetRequest(pending.request)->construction;
12151225
SK.GetEntity(hr.entity(1))->PointForceTo(v);
12161226
// Displace the second point of the new line segment slightly,

src/ui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ class GraphicsWindow {
720720
void ClearPending();
721721
bool IsFromPending(hRequest r);
722722
void AddToPending(hRequest r);
723+
void ReplacePending(hRequest before, hRequest after);
723724

724725
// The constraint that is being edited with the on-screen textbox.
725726
hConstraint constraintBeingEdited;

0 commit comments

Comments
 (0)