mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-09 03:22:49 +00:00
fix: new actions show as compound chords
fixes #107 feat: add ability to edit compound chords
This commit is contained in:
@@ -20,6 +20,20 @@
|
|||||||
return a - b;
|
return a - b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeChordInput(...actions: number[]) {
|
||||||
|
const compound = compoundIndices ?? [];
|
||||||
|
return [
|
||||||
|
...compound,
|
||||||
|
...Array.from(
|
||||||
|
{
|
||||||
|
length: 12 - (compound.length + actions.length + 1),
|
||||||
|
},
|
||||||
|
() => 0,
|
||||||
|
),
|
||||||
|
...actions.toSorted(compare),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function edit() {
|
function edit() {
|
||||||
pressedKeys = new Set();
|
pressedKeys = new Set();
|
||||||
editing = true;
|
editing = true;
|
||||||
@@ -43,12 +57,12 @@
|
|||||||
if (!editing) return;
|
if (!editing) return;
|
||||||
editing = false;
|
editing = false;
|
||||||
if (pressedKeys.size < 1) return;
|
if (pressedKeys.size < 1) return;
|
||||||
if (!chord) return dispatch("submit", [...pressedKeys].sort(compare));
|
if (!chord) return dispatch("submit", makeChordInput(...pressedKeys));
|
||||||
changes.update((changes) => {
|
changes.update((changes) => {
|
||||||
changes.push({
|
changes.push({
|
||||||
type: ChangeType.Chord,
|
type: ChangeType.Chord,
|
||||||
id: chord!.id,
|
id: chord!.id,
|
||||||
actions: [...pressedKeys].sort(compare),
|
actions: makeChordInput(...pressedKeys),
|
||||||
phrase: chord!.phrase,
|
phrase: chord!.phrase,
|
||||||
});
|
});
|
||||||
return changes;
|
return changes;
|
||||||
@@ -59,10 +73,11 @@
|
|||||||
function addSpecial(event: MouseEvent) {
|
function addSpecial(event: MouseEvent) {
|
||||||
selectAction(event, (action) => {
|
selectAction(event, (action) => {
|
||||||
changes.update((changes) => {
|
changes.update((changes) => {
|
||||||
|
console.log(compoundIndices, chordActions, action);
|
||||||
changes.push({
|
changes.push({
|
||||||
type: ChangeType.Chord,
|
type: ChangeType.Chord,
|
||||||
id: chord!.id,
|
id: chord!.id,
|
||||||
actions: [...chord!.actions, action].sort(compare),
|
actions: makeChordInput(...chordActions!, action),
|
||||||
phrase: chord!.phrase,
|
phrase: chord!.phrase,
|
||||||
});
|
});
|
||||||
return changes;
|
return changes;
|
||||||
|
|||||||
Reference in New Issue
Block a user