Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New selection system #474

Merged
merged 69 commits into from
Apr 17, 2021
Merged

New selection system #474

merged 69 commits into from
Apr 17, 2021

Conversation

OverloadedOrama
Copy link
Member

Addresses parts of #129. This PR does not include any new selection tools yet, only a new move tool.

The selection system behavior you see in this PR is not final. The UX is still a work in progress and development will most likely continue in the master branch from now on.

Finally. I've been working on this branch for at least two months. It's not ready yet, but it should be stable enough to be merged to the master branch. This PR is targeted for v0.9 and not v0.8.x.

What's new in this PR:

  • Replaced the old, array-based selection system with a new BitMap-based one. The BitMap is the same size as the sprite, unless if it's out of the canvas boundaries, in that case it is bigger. "True" bits are the selected pixels, "false" bits are unselected.
  • A new move tool that moves the contents of the cel.
  • The rectangular selection tool has been enhanced. You can now have multiple, either connected or disconnected rectangular selection parts of the image. Creating a selection while holding Shift adds to the selection, while Control subtracts from the selection. This behavior may not be final.
  • Moving selection with contents has been changed. It's currently only possible with the new move tool, and you have to press Enter (or perform any other action, like drawing) to confirm the transformation. Otherwise, you can cancel it with Escape. There will most likely be UI buttons for this in the future.
  • Animated selection outline, with the marching ants effect, done with a shader.
  • Resize the selection with gizmos.
  • Copy & paste behavior has been changed. Copying the selection now also remembers the selection itself, and pasting now creates that selection for you, instead of requiring an existing selection from the user.
  • A new menu for the selection, with "Select all", "Clear selection" and "Invert" as its options, for now.

Rotation code is also included, but it is not working properly yet.

2021-04-17.03-19-21.mp4
2021-04-17.03-21-14.mp4

…ular shape and multiple SelectionShapes can exist

- Create multiple selection rectangles
- Merge them together if they intersect
- Move the selections (without contents as of right now)
- Gizmos are being drawn but they are not functional yet

Code is very ugly.
I did this, no idea if it works properly, probably won't be used but I thought I'd keep it saved somewhere
Trying to generate a polygon from the individual selected pixels
Code is still a mess, don't bother looking.
The purpose of this is to generalize some selection code, so that it applies to all polygons, the entire selection. More will follow.
Nothing else in the selections system works properly in UndoRedo right now. Needs:

- UR support for creating selections
- UR support for modifying selections (merging and cutting selections together)
- UR support for removing selection
- UR support for moving content

& for all the rest of the remaining features
Handle all of the polygons there instead of having them as individual nodes. Should be easier to handle undo/redo this way. This commit probably breaks move tool + selection tool and undo/redo. Code is still a mess. For your sanity, I hope you are not reading this. I promise I will clean up.
Buggy and messy, of course.
… instead of each polygon having its own image

Could be further optimized for some specific cases. We could also remove selected_pixels from SelectionPolygon.
UndoRedo support for moving content not added in this commit. Should work but needs more testing. This PR also removes selected_pixels from the SelectionPolygon class.
… too

Press Enter or do any editing to confirm movement, Escape to cancel. I will most likely add UI buttons for confirm and cancel too.
Pasting now no longer requires a pre-existing selection and instead copies the selections themselves too.
…s options

Clear Selection now also confirms content moving. TopMenuContainer code has changed to no longer rely on Global for the menu buttons.
No functionality yet. They may need to be turned to nodes, so that they can easily resize based on zoom level and check for mouse enter/exit events.
…ctangle instead of individual selection parts

Still no functionality yet.
This will execute the for loop less times
…e click

Now I should actually make them resize when dragged, aye?
This should optimize the selection making a lot, and it also allows for easy border drawing without having to deal with polygons, thanks to the MarchingAntsOutline.shader

Still commit is still a WIP, image effects and brushes may not work properly yet.

Because the BitMap has a fixed size, the size of the project, moving the selection outside of canvas boundaries has proven to be a bit tricky. I did implement a hacky way of handling it, but it may be buggy and problematic. I'm still unsure whether this is the best way to handle the situation.
After they release the mouse, the black rectangle becomes the selection
…ow gets limited to the canvas bounds

Resizing currently does not work properly with negative (left & up) canvas boundaries
Rotation algorithms now accept and only work with a given image, and the pivot has been added as a parameter
Transforming the selection outside of the canvas is still broken.
And make sure the frequency of the marching ants effect always looks roughly the same on all project sizes
Although this behavior might not be the intended one
Useful for when the selection is in negative coords
This fixes the issue of project switching and keeping the previous project's offset. Again, this is only relevant for when the selection is in negative coords.
@OverloadedOrama OverloadedOrama merged commit 27cb0d2 into master Apr 17, 2021
@OverloadedOrama OverloadedOrama deleted the new-selection-system branch April 17, 2021 18:30
@OverloadedOrama OverloadedOrama mentioned this pull request Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant