CADmium-Co / CADmium

A CAD program that runs in the browser
https://cadmium-co.github.io/CADmium/
Other
1.35k stars 51 forks source link

web: reimplement new line tool state with stack instead of nested ifs #83

Closed av8ta closed 1 month ago

av8ta commented 1 month ago

I find the ui state code when using the modeling tools confusing. Rather than a bunch of nested ifs and else ifs it's simpler implemented as a stack.

MattFerraro commented 1 month ago

Can you rename to a clearer title and give a quick description?

Also there's one piece of functionality that seems to have unintentionally changed: When you close a polyline by clicking on a point that already exists, the line tool should reset to its initial state of having nothing in the stack. As written, the last point stays selected

av8ta commented 1 month ago

Thanks for spotting that bug @MattFerraro - I thought I had wrapped my head around the old code well enough to make it simpler but clearly not! Fixed by clearing the stack when it's a point we've seen before a67b516593ce072ff010f70ceccaf568a1abaaa2