Skip to content

Commit

Permalink
refsにpreviewNoteIdsを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
sigprogramming committed Feb 12, 2025
1 parent 69e9026 commit 9a2bc91
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/composables/useSequencerStateMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const useSequencerStateMachine = (
const refs: Refs = {
nowPreviewing: ref(false),
previewNotes: ref([]),
previewNoteIds: ref(new Set()),
previewRectForRectSelect: ref(undefined),
previewPitchEdit: ref(undefined),
cursorState: ref("UNSET"),
Expand All @@ -51,6 +52,7 @@ export const useSequencerStateMachine = (
stateMachine,
nowPreviewing: computed(() => refs.nowPreviewing.value),
previewNotes: computed(() => refs.previewNotes.value),
previewNoteIds: computed(() => refs.previewNoteIds.value),
previewRectForRectSelect: computed(
() => refs.previewRectForRectSelect.value,
),
Expand Down
1 change: 1 addition & 0 deletions src/sing/sequencerStateMachine/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export type ComputedRefs = {
export type Refs = {
readonly nowPreviewing: Ref<boolean>;
readonly previewNotes: Ref<Note[]>;
readonly previewNoteIds: Ref<Set<NoteId>>;
readonly previewRectForRectSelect: Ref<Rect | undefined>;
readonly previewPitchEdit: Ref<
| { type: "draw"; data: number[]; startFrame: number }
Expand Down
2 changes: 2 additions & 0 deletions src/sing/sequencerStateMachine/states/addNoteState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class AddNoteState
const noteEndPos = noteToAdd.position + noteToAdd.duration;

context.previewNotes.value = [noteToAdd];
context.previewNoteIds.value = new Set([noteToAdd.id]);
context.cursorState.value = "DRAW";
context.guideLineTicks.value = noteEndPos;
context.nowPreviewing.value = true;
Expand Down Expand Up @@ -165,6 +166,7 @@ export class AddNoteState
}

context.previewNotes.value = [];
context.previewNoteIds.value = new Set();
context.cursorState.value = "UNSET";
context.nowPreviewing.value = false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/sing/sequencerStateMachine/states/moveNoteState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class MoveNoteState
}

context.previewNotes.value = [...targetNotesArray];
context.previewNoteIds.value = new Set(this.targetNoteIds);
context.cursorState.value = "MOVE";
context.guideLineTicks.value = guideLineTicks;
context.nowPreviewing.value = true;
Expand Down Expand Up @@ -192,6 +193,7 @@ export class MoveNoteState
}

context.previewNotes.value = [];
context.previewNoteIds.value = new Set();
context.cursorState.value = "UNSET";
context.nowPreviewing.value = false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/sing/sequencerStateMachine/states/resizeNoteLeftState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class ResizeNoteLeftState
const mouseDownNote = getOrThrow(targetNotesMap, this.mouseDownNoteId);

context.previewNotes.value = [...targetNotesArray];
context.previewNoteIds.value = new Set(this.targetNoteIds);
context.cursorState.value = "EW_RESIZE";
context.guideLineTicks.value = mouseDownNote.position;
context.nowPreviewing.value = true;
Expand Down Expand Up @@ -186,6 +187,7 @@ export class ResizeNoteLeftState
}

context.previewNotes.value = [];
context.previewNoteIds.value = new Set();
context.cursorState.value = "UNSET";
context.nowPreviewing.value = false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/sing/sequencerStateMachine/states/resizeNoteRightState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class ResizeNoteRightState
const noteEndPos = mouseDownNote.position + mouseDownNote.duration;

context.previewNotes.value = [...targetNotesArray];
context.previewNoteIds.value = new Set(this.targetNoteIds);
context.cursorState.value = "EW_RESIZE";
context.guideLineTicks.value = noteEndPos;
context.nowPreviewing.value = true;
Expand Down Expand Up @@ -187,6 +188,7 @@ export class ResizeNoteRightState
}

context.previewNotes.value = [];
context.previewNoteIds.value = new Set();
context.cursorState.value = "UNSET";
context.nowPreviewing.value = false;
}
Expand Down

0 comments on commit 9a2bc91

Please sign in to comment.