zero01101 / openOutpaint

local offline javascript and html canvas outpainting gizmo for stable diffusion webUI API 🐠
MIT License
503 stars 44 forks source link

Select tool overhaul #295

Closed Metachs closed 1 week ago

Metachs commented 2 weeks ago

I had some time to kill and went in to fix a few issues with the select tool, but wound up doing a minor overhaul, and figured someone else might find it useful. Mostly UI and adding controls. Other than applying the final transform, the core functionality is mostly unchanged.

While none of the other tools were in need of as much attention as select, I've made similar updates to a few of them. If y'all aren't willing to accept these sorts of changes, let me know, and I won't bother cleaning them up.

Changes:

Reset State in the Ctrl+A shortcuts so that the current selection isn't lost when the shortcuts are used with a transformed selection. Previously, if you selected a region, moved it, then hit Ctrl+A, the transformed selection was lost. (Might want to apply instead, but resetting seems like the safest option.)

Fix History State Desynchronization when undo/redo is called while a selection is active. For example, previously, moving a selection, calling an undo that removes the active layer, then cancelling the transform with R-click, would place the restored image in an inaccessible layer. To do this, added onundo/onredo callbacks to the commands object in commands.js (Only major change outside of select.js). These are called before undoing/redoing, and provide a function that can be called to cancel the undo/redo. Selection state is now reset before all undo/redo commands. Performing an undo with a transformed selection resets the selection and cancels the undo, unless going back multiple steps. So undo effectively undoes the current transformation.

Refactored how Transformation is applied to make it easier to add shortcuts and additional functionality.

Fixed the broken "Delete" hotkey that completely broke history.

Added a toggle to always move to a new layer when transforming a selection. (file-plus icon)

Added "Layer" buttons to the Save Selection/Save Visible buttons that copy selected content to a new layer. Reworked their UI a bit to fit everything.

Added a new row of buttons

Mouse Controls

Keyboard Shortcuts

zero01101 commented 1 week ago

whoa :o enormous thanks for all the work!