Skip to content

Commit

Permalink
Fix logic introduced in 55ae10b.
Browse files Browse the repository at this point in the history
Before this commit, the effect of the AddPending() call was
immediately reversed by ClearSuper.
  • Loading branch information
Evil-Spirit authored and whitequark committed Jan 24, 2017
1 parent 3fc85b7 commit d4b052d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/draw.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
16 changes: 13 additions & 3 deletions src/mouse.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -1055,14 +1063,14 @@ 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);
SK.GetEntity(hr.entity(4))->PointForceTo(v);
ConstrainPointByHovered(hr.entity(1));

ClearSuper();
AddToPending(hr);

pending.operation = Pending::DRAGGING_NEW_CUBIC_POINT;
pending.point = hr.entity(4);
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/ui.h
Expand Up @@ -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;
Expand Down

0 comments on commit d4b052d

Please sign in to comment.