Pinta icon indicating copy to clipboard operation
Pinta copied to clipboard

Previous and applied selection are shown (#1454)

Open PabloRufianJimenez opened this issue 2 months ago • 5 comments

When using the Rectangle, Ellipse or Lasso select tool, the outlines of the previous selection and the applied selection (i.e. the selection that is combined with the previous selection) are shown if using a combine mode other than replace.

https://github.com/user-attachments/assets/7b945b63-f6f4-4ed1-b4d4-85dc2648f11d

PabloRufianJimenez avatar Oct 08 '25 16:10 PabloRufianJimenez

Note however that is implementation has a flaw.

  • Do a selection with any tool.
  • Do a selection in intersect mode with rectangle select or ellipse select.
  • Do another selection.
  • Undo. The applied selection outline doesn't show until you move any handle.

https://github.com/user-attachments/assets/a9bb745a-7070-495d-9143-21ebbd2acf90

This also happens if instead of doing another selection and undoing (step 3 & 4), you switch to another tool and switch back; any action that makes the tool call LoadFromDocument. The bug is only visual.

This is because SelectTool doesn't provide any method to obtain the shape of the applied selection without changing the current selection. I think this would require a rework of the select tools, so instead of having an abstract method that directly applies a new selection to the document, it returns a polygon set which is then applied.

I wanted to ask your opinion on this before committing to it or whether this implementation is good enough.

PabloRufianJimenez avatar Oct 08 '25 18:10 PabloRufianJimenez

Another possibility could be making it so the outlines are shown only when the handles are being dragged and not when idle.

PabloRufianJimenez avatar Oct 08 '25 18:10 PabloRufianJimenez

I think showing the outline only when the handle is being dragged sounds fine - that seems to be what Paint.NET was doing in the video in the bug report

I only took a quick glance over the changes (I'll be out on vacation for the next couple weeks), but my initial reaction is that I'd like to see if we can avoid adding more selection-specific methods onto BaseTool for this. I'm not a big fan of the existing IsSelectionTool property :)

For example:

  • Perhaps the DocumentSelection can also store the information for the additional outline?
  • Or, perhaps there can be some more generic way for tools to draw extra things on top of the canvas. The IToolHandle does allow for this, actually, though it was more intended for small UI elements originally

cameronwhite avatar Oct 09 '25 11:10 cameronwhite

How about creating an interface ISelectionTool, and instead of using IsSelectionTool(), we use typeof(ISelectionTool).IsInstanceOfType(...) to check for selection tools? ISelectionTool would then contain any selection-tool specific methods.

Also, I personally didn't like the idea of DocumentSelection storing the outlines since that's a visual effect and I wanted to keep it apart form the data model, but tell me what you think (when you have time ;) ).

PabloRufianJimenez avatar Oct 09 '25 14:10 PabloRufianJimenez

Yeah, storing it in the DocumentSelection probably isn't best after giving it more thought, since this more ephemeral data used by a tool

I think my other suggestion of perhaps there can be some more generic way for tools to draw extra things on top of the canvas might be a better approach. Selection tools aren't the only tools that might want to draw extra UI elements in screen space rather than canvas space. For example, the text tool can draw a dotted outline around re-editable text elements, but currently I think it draws that on the canvas so it'd look different depending on the zoom level

The IToolHandle interface was originally intended more for interactive things the user might click on, rather than extra guides, but I think that (or something similar along those lines) might be a good avenue to explore. Then the selection tools could just draw the extra outlines themselves, and maybe something similar for the text tool in the future

cameronwhite avatar Oct 09 '25 16:10 cameronwhite