Added polygon select to lasso tool (#1096) #1725
Conversation
|
@PabloRufianJimenez, I've had the same build error in 228379e before. I think it's likely that the files you pushed have a mix of I don't know what development environment you are using, but I think it's Visual Studio (it often messes up line endings when I make changes), and in this case it is easy to do:
|
|
@PabloRufianJimenez I see. In any case I think the problem might have something to do with whitespace (the online build tool checks and is picky about these kinds of things). I'd try running |
|
It seems the error was fixed. Thank you! |
cameronwhite
left a comment
There was a problem hiding this comment.
Looks great overall!
One thing I noticed during testing is that pressing Ctrl+Shift+A to deselect before finishing the selection doesn't really work to cancel the selection, and any further clicks just resume from before.
I think implementing OnCommit() might be the right way to handle this (and probably fix other similar situations), so that the tool can finalize the selection first
| private CombineMode combine_mode; | ||
| private SelectionHistoryItem? hist; | ||
|
|
||
| private Path? path; |
There was a problem hiding this comment.
There are some unused variable warnings here, so I think this can be removed? It looks like the original code wasn't really making use of it (probably some leftover code from before the different selection intersection modes were added)
| public override string Name => Translations.GetString ("Lasso Select"); | ||
| public override string Icon => Pinta.Resources.Icons.ToolSelectLasso; | ||
| public override string StatusBarText => Translations.GetString ("Click and drag to draw the outline for a selection area."); | ||
| public override string StatusBarText => Translations.GetString ("On Freeform mode, click and drag to draw the outline for a selection area." + |
There was a problem hiding this comment.
Just a couple minor fixes for grammar:
- I think it should say
In Freeform / Polygon moderather thanOn - The last two lines should also end with a period
.
| lasso_polygon.RemoveAt (lasso_polygon.Count - 1); | ||
|
|
||
| if (lasso_polygon.Count == 0) { | ||
| hist?.Undo (); |
There was a problem hiding this comment.
Should this method just have a if (hist == null) return; check at the start, to make it more clear what the preconditions are? If there isn't a history item then there shouldn't be anything to backtrack, from my reading of the code
There was a problem hiding this comment.
Backtrack is not only for reverting to the previous history item, it's also to remove points from the polygon (i.e. vertices). The former only happens after all points are removed, so as to cancel the selection. Even if there's no history item, the user can still remove the last points they added if they messed up and retry.
There was a problem hiding this comment.
That makes sense, it's really just the hist?.Undo() that I'm concerned about here which implies that hist may or may not be null here
hist is the history item we created in OnMouseDown for the in-progress edit, so it must be non-null if we have a non-empty lasso_polygon right?
There was a problem hiding this comment.
That's true. A non-empty lasso_polygon must imply that hist is non-null. The reason I added the question mark in hist?.Undo() is to avoid possible null reference warning. Tell me if you would like to have this removed.
There was a problem hiding this comment.
I think the best solution would be to add something like ArgumentNullException.ThrowIfNull (hist) earlier on in the method. That should you eliminate the ? operator and also makes it more clear what the preconditions are here
There was a problem hiding this comment.
Was this an icon you created, or one from an existing source? Just checking so that we correctly record the source of it for licensing purposes
There was a problem hiding this comment.
Yes, the icon was created by me in Inkscape.
There was a problem hiding this comment.
Great! This can be added to Pinta.Resources/icons/pinta-icons.md then, which lists some of the icons contributed by developers
|
|
||
| private Separator? mode_sep; | ||
| private Label? lasso_mode_label; | ||
| private ToolBarDropDownButton? lasso_mode_buttom; |
There was a problem hiding this comment.
I didn't notice this before, but the tool should also save the setting to Pinta's preferences and restore it when loading. Something like the Recolor tool would be a simple example to follow (implementing OnSaveSettings() and loading the setting when creating the widget
The selection mode should also have been saving its settings like SelectTool.OnSaveSettings() does..


Let me know if I missed something of if there's something a have to change.