Cleanup, removed a new control that no longer made sense.

This commit is contained in:
Metachs 2024-08-26 10:44:37 -04:00
parent 27896897b2
commit 954a2ac0ec
2 changed files with 32 additions and 37 deletions

View file

@ -208,9 +208,3 @@
-webkit-mask-image: url("../res/icons/file-plus.svg"); -webkit-mask-image: url("../res/icons/file-plus.svg");
mask-image: url("../res/icons/file-plus.svg"); mask-image: url("../res/icons/file-plus.svg");
} }
.ui.inline-icon.icon-lock::after,
.ui.icon > .icon-lock {
-webkit-mask-image: url("../res/icons/lock.svg");
mask-image: url("../res/icons/lock.svg");
}

View file

@ -117,7 +117,6 @@ const selectTransformTool = () =>
state.block_res_change = true; state.block_res_change = true;
state.toNewLayer = false; state.toNewLayer = false;
state.preserveOriginal = false;
state.useClipboard = !!( state.useClipboard = !!(
navigator.clipboard && navigator.clipboard.write navigator.clipboard && navigator.clipboard.write
@ -336,18 +335,30 @@ const selectTransformTool = () =>
}; };
// Handles right mouse double clicks - Select topmost layer with content under pointer // Handles right mouse double clicks - Select topmost layer with content under pointer
// Holding shift key selects bottommost layer // Holding shift key Selects the next topmost if current layer has visible content under pointer.
state.drclickcb = (evn) => { state.drclickcb = (evn) => {
if (state.selected) return; if (state.selected) return;
for (let l of (evn.evn.shiftKey ? uil.layers : uil.layers.toReversed()) ) { // If shift key is held, and current layer is has visible pixels under pointer
if (!l.hidden && !isCanvasBlank(evn.x,evn.y,2,2,l.canvas)) { // select topmost visible layer beneath the active layer
uil.active=l; let shift = evn.evn.shiftKey
state.dclickcb_timeout = state.dclickcb_timeout ?? window.setTimeout(async ()=>{ && !uil.active.hidden
state.dclickcb_timeout = null; && !isCanvasBlank(evn.x,evn.y,2,2,uil.active.canvas);
if (!state.selected && !selection.exists) { state.ctrlacb(evn); } let layer = shift ? uil.active : null;
},300); for (let l of uil.layers.toReversed()) {
return; if (shift) {
if (layer==l) shift = false;
} }
else if (!l.hidden && !isCanvasBlank(evn.x,evn.y,2,2,l.canvas)){
layer = l;
break;
}
}
if (layer) {
uil.active=layer;
state.dclickcb_timeout = state.dclickcb_timeout ?? window.setTimeout(async ()=>{
state.dclickcb_timeout = null;
if (!state.selected && !selection.exists) { state.ctrlacb(evn); }
},300);
} }
}; };
@ -527,7 +538,7 @@ const selectTransformTool = () =>
state.keydowncb = (evn) => { }; state.keydowncb = (evn) => { };
// Keyboard callbacks (For now, they just handle the "delete" key) // Keyboard callbacks
state.keyclickcb = (evn) => { }; state.keyclickcb = (evn) => { };
// Register Delete Shortcut // Register Delete Shortcut
@ -536,19 +547,19 @@ const selectTransformTool = () =>
// Register Escape Shortcut // Register Escape Shortcut
state.escapecb = (evn) => { state.reset(false); }; state.escapecb = (evn) => { state.reset(false); };
// Register Shift-Delete Shortcut // Register Shift-Delete Shortcut - Delete Outside Selection and Apply
state.sdelcb = (evn) => { state.applyTransform(false,true,false,false); }; state.sdelcb = (evn) => { state.applyTransform(false,true,false,false); };
// Register Enter Shortcut (Delegates to clickcb) // Register Enter Shortcut - Apply Transform (Delegates to clickcb)
state.entercb = (evn) => { state.clickcb(evn); }; state.entercb = (evn) => { state.clickcb(evn); };
// Register Ctrl-Enter Shortcut // Register Ctrl-Enter Shortcut - Copy Selection to new layer, restore original
state.ctentercb = (evn) => { state.applyTransform(false,false,true,true); }; state.ctentercb = (evn) => { state.applyTransform(false,false,true,true); };
// Register Shift-Enter Shortcut // Register Shift-Enter Shortcut - Move Selection to new layer
state.sentercb = (evn) => { state.applyTransform(false,false,true,false); }; state.sentercb = (evn) => { state.applyTransform(false,false,true,false); };
// Register Ctrl-Shift-Enter Shortcut // Register Ctrl-Shift-Enter Shortcut - Copy Visible Selection to new layer
state.sctentercb = async (evn) => { state.sctentercb = async (evn) => {
var selectBB = var selectBB =
state.selected.bb != undefined state.selected.bb != undefined
@ -703,10 +714,10 @@ const selectTransformTool = () =>
}; };
// Apply Transform and Reset State, optionally erase Selection or Clear Original Layer // Apply Transform and Reset State, optionally erase Selection or Clear Original Layer
// newLayer and keepOriginal default to null, overriding the forced variants if explicitly set to false // newLayer defaults to null, overriding the forced variants if explicitly set to false
// Only checks if Selection exists and content has been selected // Only checks if Selection exists and content has been selected
// Does not check if content has been transformed, eg for deletion/applying to new layer // Does not check if content has been transformed, eg for deletion/applying to new layer
state.applyTransform = async (eraseSelected = false, clearLayer = false, newLayer = null, keepOriginal = null) => { state.applyTransform = async (eraseSelected = false, clearLayer = false, newLayer = null, keepOriginal = false) => {
const isBlank = const isBlank =
isCanvasBlank( 0, 0, state.selected.canvas.width, state.selected.canvas.height, state.selected.canvas); isCanvasBlank( 0, 0, state.selected.canvas.width, state.selected.canvas.height, state.selected.canvas);
@ -738,7 +749,7 @@ const selectTransformTool = () =>
} }
); );
// Erase Original Selection Area // Erase Original Selection Area
else if (eraseSelected || !(keepOriginal ?? state.preserveOriginal)) await commands.runCommand( else if (eraseSelected || !keepOriginal) await commands.runCommand(
"eraseImage", "eraseImage",
"Transform Tool Erase", "Transform Tool Erase",
{ {
@ -880,15 +891,6 @@ const selectTransformTool = () =>
"Always Create New Layer", "Always Create New Layer",
"icon-file-plus" "icon-file-plus"
).checkbox; ).checkbox;
// preserveOriginal
state.ctxmenu.preserveOriginalLabel = _toolbar_input.checkbox(
state,
"openoutpaint/select-preserveOriginal",
"preserveOriginal",
"Preserve Original Image - Restore original content after transforming selection",
"icon-lock"
).checkbox;
// Selection Peek Opacity // Selection Peek Opacity
state.ctxmenu.selectionPeekOpacitySlider = _toolbar_input.slider( state.ctxmenu.selectionPeekOpacitySlider = _toolbar_input.slider(
@ -947,7 +949,7 @@ const selectTransformTool = () =>
const ActiveSelectionButton = document.createElement("button"); const ActiveSelectionButton = document.createElement("button");
ActiveSelectionButton.classList.add("button", "tool"); ActiveSelectionButton.classList.add("button", "tool");
ActiveSelectionButton.textContent = "📄"; ActiveSelectionButton.textContent = "📄";
ActiveSelectionButton.title = "Commands Applied to the visible Selection"; ActiveSelectionButton.title = "Commands Applied to the Current Selection";
ActiveSelectionButton.disabled = true; ActiveSelectionButton.disabled = true;
@ -1014,7 +1016,7 @@ const selectTransformTool = () =>
const VisibleSelectionButton = document.createElement("button"); const VisibleSelectionButton = document.createElement("button");
VisibleSelectionButton.classList.add("button", "tool"); VisibleSelectionButton.classList.add("button", "tool");
VisibleSelectionButton.textContent = "👁"; VisibleSelectionButton.textContent = "👁";
VisibleSelectionButton.title = "Commands Applied to the visible Selection"; VisibleSelectionButton.title = "Commands Applied to All Visible Content In the Selected Area";
VisibleSelectionButton.disabled = true; VisibleSelectionButton.disabled = true;
visibleActionArray.appendChild(saveVisibleSelectionButton); visibleActionArray.appendChild(saveVisibleSelectionButton);
@ -1104,7 +1106,6 @@ const selectTransformTool = () =>
array.appendChild(state.ctxmenu.useClipboardLabel); array.appendChild(state.ctxmenu.useClipboardLabel);
array.appendChild(state.ctxmenu.toNewLayerLabel); array.appendChild(state.ctxmenu.toNewLayerLabel);
array.appendChild(state.ctxmenu.preserveOriginalLabel);
menu.appendChild(array); menu.appendChild(array);
menu.appendChild(state.ctxmenu.selectionPeekOpacitySlider); menu.appendChild(state.ctxmenu.selectionPeekOpacitySlider);