-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [project-sequencer-statemachine] ツールに対応 (#2517)
- Loading branch information
1 parent
8c26457
commit fce6ce8
Showing
13 changed files
with
282 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/sing/sequencerStateMachine/states/drawPitchToolIdleState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { SetNextState, State } from "@/sing/stateMachine"; | ||
import { | ||
Context, | ||
Input, | ||
SequencerStateDefinitions, | ||
} from "@/sing/sequencerStateMachine/common"; | ||
import { getButton } from "@/sing/viewHelper"; | ||
import { isOnCommandOrCtrlKeyDown } from "@/store/utility"; | ||
|
||
export class DrawPitchToolIdleState | ||
implements State<SequencerStateDefinitions, Input, Context> | ||
{ | ||
readonly id = "drawPitchToolIdle"; | ||
|
||
onEnter() {} | ||
|
||
process({ | ||
input, | ||
context, | ||
setNextState, | ||
}: { | ||
input: Input; | ||
context: Context; | ||
setNextState: SetNextState<SequencerStateDefinitions>; | ||
}) { | ||
const mouseButton = getButton(input.mouseEvent); | ||
const selectedTrackId = context.selectedTrackId.value; | ||
|
||
if ( | ||
input.mouseEvent.type === "mousedown" && | ||
mouseButton === "LEFT_BUTTON" && | ||
input.targetArea === "SequencerBody" | ||
) { | ||
if (isOnCommandOrCtrlKeyDown(input.mouseEvent)) { | ||
setNextState("erasePitch", { | ||
cursorPosAtStart: input.cursorPos, | ||
targetTrackId: selectedTrackId, | ||
returnStateId: this.id, | ||
}); | ||
} else { | ||
setNextState("drawPitch", { | ||
cursorPosAtStart: input.cursorPos, | ||
targetTrackId: selectedTrackId, | ||
returnStateId: this.id, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
onExit() {} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/sing/sequencerStateMachine/states/editNotesToolIdleState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { SetNextState, State } from "@/sing/stateMachine"; | ||
import { | ||
Context, | ||
executeNotesSelectionProcess, | ||
getGuideLineTicks, | ||
Input, | ||
SequencerStateDefinitions, | ||
} from "@/sing/sequencerStateMachine/common"; | ||
import { getButton, isSelfEventTarget } from "@/sing/viewHelper"; | ||
import { isOnCommandOrCtrlKeyDown } from "@/store/utility"; | ||
|
||
export class EditNotesToolIdleState | ||
implements State<SequencerStateDefinitions, Input, Context> | ||
{ | ||
readonly id = "editNotesToolIdle"; | ||
|
||
onEnter() {} | ||
|
||
process({ | ||
input, | ||
context, | ||
setNextState, | ||
}: { | ||
input: Input; | ||
context: Context; | ||
setNextState: SetNextState<SequencerStateDefinitions>; | ||
}) { | ||
const mouseButton = getButton(input.mouseEvent); | ||
const selectedTrackId = context.selectedTrackId.value; | ||
|
||
if (input.targetArea === "SequencerBody") { | ||
context.guideLineTicks.value = getGuideLineTicks( | ||
input.cursorPos, | ||
context, | ||
); | ||
} | ||
|
||
if ( | ||
input.mouseEvent.type === "mousedown" && | ||
mouseButton === "LEFT_BUTTON" && | ||
isSelfEventTarget(input.mouseEvent) | ||
) { | ||
if (input.targetArea === "SequencerBody") { | ||
if (input.mouseEvent.shiftKey) { | ||
setNextState("selectNotesWithRect", { | ||
cursorPosAtStart: input.cursorPos, | ||
returnStateId: this.id, | ||
}); | ||
} else if (isOnCommandOrCtrlKeyDown(input.mouseEvent)) { | ||
void context.store.actions.DESELECT_ALL_NOTES(); | ||
} else { | ||
void context.store.actions.DESELECT_ALL_NOTES(); | ||
setNextState("addNote", { | ||
cursorPosAtStart: input.cursorPos, | ||
targetTrackId: selectedTrackId, | ||
returnStateId: this.id, | ||
}); | ||
} | ||
} else if (input.targetArea === "Note") { | ||
executeNotesSelectionProcess(context, input.mouseEvent, input.note); | ||
setNextState("moveNote", { | ||
cursorPosAtStart: input.cursorPos, | ||
targetTrackId: selectedTrackId, | ||
targetNoteIds: context.selectedNoteIds.value, | ||
mouseDownNoteId: input.note.id, | ||
returnStateId: this.id, | ||
}); | ||
} else if (input.targetArea === "NoteLeftEdge") { | ||
executeNotesSelectionProcess(context, input.mouseEvent, input.note); | ||
setNextState("resizeNoteLeft", { | ||
cursorPosAtStart: input.cursorPos, | ||
targetTrackId: selectedTrackId, | ||
targetNoteIds: context.selectedNoteIds.value, | ||
mouseDownNoteId: input.note.id, | ||
returnStateId: this.id, | ||
}); | ||
} else if (input.targetArea === "NoteRightEdge") { | ||
executeNotesSelectionProcess(context, input.mouseEvent, input.note); | ||
setNextState("resizeNoteRight", { | ||
cursorPosAtStart: input.cursorPos, | ||
targetTrackId: selectedTrackId, | ||
targetNoteIds: context.selectedNoteIds.value, | ||
mouseDownNoteId: input.note.id, | ||
returnStateId: this.id, | ||
}); | ||
} | ||
} | ||
} | ||
|
||
onExit() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.