Make Select All and Select None actions
This commit is contained in:
parent
71e2b5e4ca
commit
04d7ac9edc
105
src/main.js
105
src/main.js
|
|
@ -1178,6 +1178,86 @@ let actions = {
|
||||||
updateInfopanel()
|
updateInfopanel()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
selectAll: {
|
||||||
|
create: () => {
|
||||||
|
redoStack.length = 0
|
||||||
|
let selection = []
|
||||||
|
let shapeselection = []
|
||||||
|
for (let child of context.activeObject.activeLayer.children) {
|
||||||
|
let idx = child.idx
|
||||||
|
if (idx in context.activeObject.currentFrame.keys) {
|
||||||
|
selection.push(child.idx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let shape of context.activeObject.currentFrame.shapes) {
|
||||||
|
shapeselection.push(shape.idx)
|
||||||
|
}
|
||||||
|
let action = {
|
||||||
|
selection: selection,
|
||||||
|
shapeselection: shapeselection
|
||||||
|
}
|
||||||
|
undoStack.push({name: 'selectAll', action: action})
|
||||||
|
actions.selectAll.execute(action)
|
||||||
|
updateMenu()
|
||||||
|
},
|
||||||
|
execute: (action) => {
|
||||||
|
context.selection = []
|
||||||
|
context.shapeselection = []
|
||||||
|
for (let item of action.selection) {
|
||||||
|
context.selection.push(pointerList[item])
|
||||||
|
}
|
||||||
|
for (let shape of action.shapeselection) {
|
||||||
|
context.shapeselection.push(pointerList[shape])
|
||||||
|
}
|
||||||
|
updateUI()
|
||||||
|
updateMenu()
|
||||||
|
},
|
||||||
|
rollback: (action) => {
|
||||||
|
context.selection = []
|
||||||
|
context.shapeselection = []
|
||||||
|
updateUI()
|
||||||
|
updateMenu()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectNone: {
|
||||||
|
create: () => {
|
||||||
|
redoStack.length = 0
|
||||||
|
let selection = []
|
||||||
|
let shapeselection = []
|
||||||
|
for (let item of context.selection) {
|
||||||
|
let idx = child.idx
|
||||||
|
selection.push(item.idx)
|
||||||
|
}
|
||||||
|
for (let shape of context.shapeselection) {
|
||||||
|
shapeselection.push(shape.idx)
|
||||||
|
}
|
||||||
|
let action = {
|
||||||
|
selection: selection,
|
||||||
|
shapeselection: shapeselection
|
||||||
|
}
|
||||||
|
undoStack.push({name: 'selectNone', action: action})
|
||||||
|
actions.selectNone.execute(action)
|
||||||
|
updateMenu()
|
||||||
|
},
|
||||||
|
execute: (action) => {
|
||||||
|
context.selection = []
|
||||||
|
context.shapeselection = []
|
||||||
|
updateUI()
|
||||||
|
updateMenu()
|
||||||
|
},
|
||||||
|
rollback: (action) => {
|
||||||
|
context.selection = []
|
||||||
|
context.shapeselection = []
|
||||||
|
for (let item of action.selection) {
|
||||||
|
context.selection.push(pointerList[item])
|
||||||
|
}
|
||||||
|
for (let shape of action.shapeselection) {
|
||||||
|
context.shapeselection.push(pointerList[shape])
|
||||||
|
}
|
||||||
|
updateUI()
|
||||||
|
updateMenu()
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function uuidv4() {
|
function uuidv4() {
|
||||||
|
|
@ -2521,7 +2601,7 @@ window.addEventListener("keydown", (e) => {
|
||||||
delete_action()
|
delete_action()
|
||||||
break;
|
break;
|
||||||
case config.shortcuts.selectAll:
|
case config.shortcuts.selectAll:
|
||||||
selectAll()
|
actions.selectAll.create()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
break;
|
break;
|
||||||
case config.shortcuts.group:
|
case config.shortcuts.group:
|
||||||
|
|
@ -2866,21 +2946,6 @@ function delete_action() {
|
||||||
updateUI()
|
updateUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAll() {
|
|
||||||
context.selection = []
|
|
||||||
context.shapeselection = []
|
|
||||||
for (let child of context.activeObject.activeLayer.children) {
|
|
||||||
let idx = child.idx
|
|
||||||
if (idx in context.activeObject.currentFrame.keys) {
|
|
||||||
context.selection.push(child)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (let shape of context.activeObject.currentFrame.shapes) {
|
|
||||||
context.shapeselection.push(shape)
|
|
||||||
}
|
|
||||||
updateUI()
|
|
||||||
}
|
|
||||||
|
|
||||||
function addFrame() {
|
function addFrame() {
|
||||||
if (context.activeObject.currentFrameNum >= context.activeObject.activeLayer.frames.length) {
|
if (context.activeObject.currentFrameNum >= context.activeObject.activeLayer.frames.length) {
|
||||||
actions.addFrame.create()
|
actions.addFrame.create()
|
||||||
|
|
@ -5099,9 +5164,15 @@ async function updateMenu() {
|
||||||
{
|
{
|
||||||
text: "Select All",
|
text: "Select All",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
action: selectAll,
|
action: actions.selectAll.create,
|
||||||
accelerator: getShortcut("selectAll")
|
accelerator: getShortcut("selectAll")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: "Select None",
|
||||||
|
enabled: true,
|
||||||
|
action: actions.selectNone.create,
|
||||||
|
accelerator: getShortcut("selectNone")
|
||||||
|
},
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue