Open weerox opened 4 years ago
One solution to this might be to delay the drawing of the component before the mouse has moved. This would work with the current workflow, since when the mouse is up at the toolbar we shouldn't be able to see the component anyway, and when we have just placed a component, the new one wouldn't be visible anyway since they snap to the same point. Though when shortcuts are implemented there might look weird, since we can change tools while being inside the canvas.
I agree with this, what we can do is detect if the cursor is inside the drawing area when the tool is selected and enable drawing in that case, and wait until the cursor enters the drawing area in the other case.
I'd like to look into fixing this, it would be a great opportunity for me to better understand how the components are drawn.
Great, I will leave that to you then 👍
I took a look at it today and tried to solve it by adding a variable in ComponentTool
which keeps track of whether the component should be drawn. The state of the variable is then checked in the Draw()
method. The variable is set to false
immediately after the tool has been selected.
This partially solved the problem, the component isn't drawn directly when switching tools, but it is drawn when the mouse enter the Circuit/Package editor "tab bar". It isn't as noticeable since your mouse is on the move and will soon enter the circuit editor anyway, but I'm still not quite satisfied.
Do you have an idea as to how to solve it? The most robust solution would be the one that was suggested above, to detect whether the tool is inside the editor and only draw the component if it is. The problem is that I can't figure out how to do that.
To find out if the component is above the mouse area I would first check if there is like a MouseEntered event that we could hook up to tools, otherwise we could look at the current mouse pos and compare that to the client rectangle of the drawing area and see if the mouse is inside of it. Those would be the ways I would do it. Easiest I think would be the latter.
When selecting a component tool or immediately after placing a component, the new component, which should be positioned at the cursor, is instead positioned at what I guess is the origin of the "canvas".