-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[project-sequencer-statemachine] ツールに対応 #2517
Merged
Hiroshiba
merged 2 commits into
VOICEVOX:project-sequencer-statemachine
from
sigprogramming:support_tools
Feb 2, 2025
+282
−58
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これなかなか・・・という相当難しそうなのですが、今のmainブランチだとペンモードでctrl押すと消しゴムツールが選ばれてるようなUIになるんですよねー。。。
難度を考えなければStateがEraseに移動すべきなんですが。。。どうしましょう。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctrl押したときですが、「消しゴムツールが選ばれる」ではなく「消しゴムツールと同じ動作になる」でも良いかもと思っています。(ステートは変えずに、動作とマウスカーソルを変える形)
ちなみにVoiSonaでは、Ctrlキーを押すとマウスカーソルは変わりますが、ツールの選択状態の表示は変わらないようになっていました。
ステートを変える(Eraseに移動する)形にするなら、今はステートが次のステートを決定する設計になっているので、Eraseに
transitionStateIdOnCtrlKeyReleased
を渡す感じになるかなと思います。(遷移先のステートの決定をステート以外が行う設計にすればもっと自然になると思いますが、ひとまず今の設計で各ステートの処理を一通り実装して、その後改良、という流れで進めるのが良いかなと思っています)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たしかに、消しゴムアイコンにさえすればツールの選択状態は変えなくても良さそうにも感じました!!
共有まで…! @romot-co