SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

[Overlay] Order of drawing between Overlay and Interactive Tools #927

Open Fredosixx opened 11 months ago

Fredosixx commented 11 months ago

Currently, it seems that an overlay is always drawn AFTER the current interactive tool, whether native tool or Ruby tool.

Actually, there may be benefits but most of the time, I see this as a major drawback.

Here is an example where plants are drawn in an overlay, whereas the button palette is drawn in an interactive tool (FredoSpline).

image

Therefore, I would propose (and request) that Overlays have 2 draw functions, one AFTER and one BEFORE the current interactive tool.

Since overlay#draw() exists and draws AFTER, then, we just need to introduce a new method overlay#draw_before().

thomthom commented 11 months ago

Seems to be that tools should always draw last, since it's the thing that the user will interact with.

Is there any scenario where you'd actually want a tool to draw before an overlay?

Fredosixx commented 11 months ago

Currently, Interactive tools are drawn BEFORE the overlays. Therefore drawings of overlays overwrite drawings of the interactive tool (including native tools).

As you say, I think the right approach would have been to draw overlay BEFORE the interactive tool.

Since overaly is already out, and draw AFTER interactive tools, I was just proposing to have 2 drawing methods for overlays, Befor and After, so that this is more flexible.

thomthom commented 11 months ago

We've been talking about this internally and we can't think of any reason overlays should draw after tool. And we're not sure why it even ended up like that. Feels like a bug.

dphdave commented 11 months ago

There seems to be difference / inconsistency with overlays drawn on the 2D screen plane (eg using view#draw2d() and view#draw_text() ) and overlays drawn in 3D model space (eg using view#draw() ).

Here the 2D overlay "3" is drawn over the top of the interactive tool: image but with a different reference point, the tool is drawn over the overlay! image

Here a 3D overlay (red face) is drawn BEFORE the protractor but AFTER the inferencing points: image

dphdave commented 11 months ago

I've also just discovered that both 2D and 3D drawing from the overlay lowest down in the Overlays panel appears over 2D and 3D drawing from previous overlays. This does not make sense to me, I would expect all 2D drawing on the screen plane from all overlays to appear over all 3D drawing from all overlays.

2D "3" on the screen plane and 3D red face are drawn by separate overlays. When face rendering overlay is ordered later in the overlay panel, it appears ABOVE the 2D label. image

Fredosixx commented 11 months ago

We've been talking about this internally and we can't think of any reason overlays should draw after tool. And we're not sure why it even ended up like that. Feels like a bug.

Is it going t be fixed then?

While you are at it, you may want to add an extra method draw_after or `draw_before' to have the flexibility to have overlay partly draw before or after the interactive tool. This may be a precaution fo future usage, we never know...

Fredosixx commented 11 months ago

I have actually one use case where I need an overlay to be drawn AFTER the interactive tool.

The situation is

Although it is true that Overlays should be drawn before interactive tools, it would be good here to have the option to draw it AFTER. The most flexible ways is thus, as I proposed, to have 2 draw methods for overlays: before and after (the ame overlay could use both....)

thomthom commented 11 months ago

I've also just discovered that both 2D and 3D drawing from the overlay lowest down in the Overlays panel appears over 2D and 3D drawing from previous overlays. This does not make sense to me, I would expect all 2D drawing on the screen plane from all overlays to appear over all 3D drawing from all overlays.

Can you log this as a separate issue please? It'd be a lot easier for us to track this info if each issue have its own topic. This one is specifically about the order between tools and overlays.

thomthom commented 11 months ago

There seems to be difference / inconsistency with overlays drawn on the 2D screen plane (eg using view#draw2d() and view#draw_text() ) and overlays drawn in 3D model space (eg using view#draw() ).

I'm not 100%, I'd have to dig into the code, but the protractor might be mixing 2D and 3D drawing. 3D drawing would always appear under any 2D drawing.