-
-
Notifications
You must be signed in to change notification settings - Fork 831
Implement duplication of Alt-dragged layers within the Layers panel #2847
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ | |
let draggingData: undefined | DraggingData = undefined; | ||
let fakeHighlightOfNotYetSelectedLayerBeingDragged: undefined | bigint = undefined; | ||
let dragInPanel = false; | ||
let isDuplicating = false; | ||
|
||
// Interactive clipping | ||
let layerToClipUponClick: LayerListingInfo | undefined = undefined; | ||
|
@@ -382,8 +383,9 @@ | |
|
||
// Set style of cursor for drag | ||
if (event.dataTransfer) { | ||
event.dataTransfer.dropEffect = "move"; | ||
event.dataTransfer.effectAllowed = "move"; | ||
isDuplicating = event.altKey; | ||
event.dataTransfer.dropEffect = isDuplicating ? "copy" : "move"; | ||
event.dataTransfer.effectAllowed = isDuplicating ? "copy" : "move"; | ||
Comment on lines
+386
to
+388
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please get this to update the cursor icon while dragging so the user can add or remove Alt any number of times during a drag and watch as the cursor updates, and the final state when the mouse drag is released becomes whether or not to duplicate. So the user can decide at the time of mouseup, not mousedown, whether to duplicate. |
||
} | ||
|
||
if (list) draggingData = calculateDragIndex(list, event.clientY, select); | ||
|
@@ -406,11 +408,11 @@ | |
e.preventDefault(); | ||
|
||
if (e.dataTransfer) { | ||
// Moving layers | ||
// Moving or duplicating layers | ||
if (e.dataTransfer.items.length === 0) { | ||
if (draggable && dragInPanel) { | ||
if (draggable && dragInPanel && insertIndex !== undefined) { | ||
select?.(); | ||
editor.handle.moveLayerInTree(insertParentId, insertIndex); | ||
editor.handle.moveSelectedLayersInTree(insertParentId, insertIndex, isDuplicating); | ||
} | ||
} | ||
// Importing files | ||
|
@@ -444,6 +446,7 @@ | |
draggingData = undefined; | ||
fakeHighlightOfNotYetSelectedLayerBeingDragged = undefined; | ||
dragInPanel = false; | ||
isDuplicating = false; | ||
} | ||
|
||
function rebuildLayerHierarchy(updateDocumentLayerStructure: DocumentLayerStructure) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have consolidated your new logic into the existing layer move message. Please see if you can further consolidate the logic to share code paths wherever possible. Because currently this just takes your duplicate-ish implementation and pastes it into here (followed by an early
return;
to avoid running the subsequent original non-duplication code paths).