Skip to content

Commit

Permalink
git add .
Browse files Browse the repository at this point in the history
  • Loading branch information
romot-co committed Nov 16, 2024
1 parent ad6e950 commit 0025f78
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 118 deletions.
15 changes: 7 additions & 8 deletions src/components/Sing/ScoreSequencer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
:isPreview="previewNoteIds.has(note.id)"
:isOverlapping="overlappingNoteIdsInSelectedTrack.has(note.id)"
:previewLyric="previewLyrics.get(note.id) || null"
:previewMode
:nowPreviewing
:previewMode
:cursorClass
@barMousedown="onNoteBarMouseDown($event, note)"
@barDoubleClick="onNoteBarDoubleClick($event, note)"
Expand Down Expand Up @@ -187,7 +187,7 @@ import ContextMenu, {
} from "@/components/Menu/ContextMenu.vue";
import { NoteId } from "@/type/preload";
import { useStore } from "@/store";
import { Note, SequencerEditTarget } from "@/store/type";
import { Note, SequencerEditTarget, CursorState } from "@/store/type";
import {
getEndTicksOfPhrase,
getNoteDuration,
Expand Down Expand Up @@ -233,20 +233,18 @@ import {
import { applyGaussianFilter, linearInterpolation } from "@/sing/utility";
import { useLyricInput } from "@/composables/useLyricInput";
import { useCursorState } from "@/composables/useCursorState";
import { CursorState } from "@/type/preload";
import { ExhaustiveError } from "@/type/utility";
import { uuid4 } from "@/helpers/random";
import { useEditMode } from "@/composables/useEditMode";
const store = useStore();
const state = store.state;
// 直接イベントが来ているかどうか
const isSelfEventTarget = (event: UIEvent) => {
return event.target === event.currentTarget;
};
const { warn } = createLogger("ScoreSequencer");
const store = useStore();
const state = store.state;
// 選択中のトラックID
const selectedTrackId = computed(() => store.getters.SELECTED_TRACK_ID);
Expand Down Expand Up @@ -382,6 +380,7 @@ const cursorX = ref(0);
const cursorY = ref(0);
// カーソル状態の更新
// TODO: useCursorStateに委譲
const { setCursorState, cursorState, cursorClass } = useCursorState();
watch(
() => cursorState.value,
Expand All @@ -406,8 +405,8 @@ const onLyricConfirmed = (nextNoteId: NoteId | undefined) => {
// プレビュー
// FIXME: 関連する値を1つのobjectにまとめる
const nowPreviewing = computed(() => previewMode.value !== "IDLE");
const previewMode = ref<PreviewMode>("IDLE");
const nowPreviewing = computed(() => previewMode.value !== "IDLE");
const executePreviewProcess = ref(false);
let previewRequestId = 0;
let previewStartEditTarget: SequencerEditTarget = "NOTE";
Expand Down Expand Up @@ -1473,7 +1472,7 @@ watch(playheadTicks, (newPlayheadPosition) => {
if (!sequencerBodyElement) {
if (import.meta.env.DEV) {
// HMR時にここにたどり着くことがあるので、開発時は警告だけにする
// TODO: HMR時��ここにたどり着く原因を調査して修正する
// TODO: HMR時もここにたどり着く原因を調査して修正する
warn("sequencerBodyElement is null.");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sing/SequencerNote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ const onLeftEdgeMouseDown = (event: MouseEvent) => {
&.cursor-erase {
.note-bar,
.note-edge {
cursor: inherit !important;
cursor: inherit;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useCursorState.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ref, computed } from "vue";
import { CursorState } from "@/type/preload";
import { CursorState } from "@/store/type";

// カーソル状態を管理するカスタムコンポーザブル
export const useCursorState = () => {
Expand Down
54 changes: 2 additions & 52 deletions src/composables/useEditMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,6 @@ import {
} from "@/store/type";
import { MouseButton } from "@/sing/viewHelper";

/*
// ノート編集モードのプリセット定義
export const NOTE_EDIT_MODES: Record<NoteEditMode["type"], NoteEditMode> = {
SELECT_FIRST: {
type: "SELECT_FIRST",
cursor: CursorState.UNSET,
behaviors: {
shouldSelectAfterEditing: true,
shouldAddNoteOnClick: false,
shouldAddNoteOnDoubleClick: true,
shouldDeselectAllOnClick: true,
shouldRectSelectOnDrag: true,
shouldDeselectAllOnCtrlOrCommandClick: true,
},
},
EDIT_FIRST: {
type: "EDIT_FIRST",
cursor: CursorState.DRAW,
behaviors: {
shouldSelectAfterEditing: true,
shouldAddNoteOnClick: true,
shouldAddNoteOnDoubleClick: false,
shouldDeselectAllOnClick: false,
shouldRectSelectOnDrag: false,
shouldDeselectAllOnCtrlOrCommandClick: false,
},
},
};
// ピッチ編集モードのプリセット定義
export const PITCH_EDIT_MODES: Record<PitchEditMode["type"], PitchEditMode> = {
DRAW: {
type: "DRAW",
cursor: CursorState.DRAW,
},
ERASE: {
type: "ERASE",
cursor: CursorState.ERASE,
},
}; */

// マウスダウン時の振る舞い
export type MouseDownBehavior =
| "IGNORE"
Expand All @@ -62,17 +21,7 @@ export type MouseDownBehavior =
// ダブルクリック時の振る舞い
export type MouseDoubleClickBehavior = "IGNORE" | "ADD_NOTE" | "EDIT_LYRIC";

/*
// マウスエッジ時の振る舞い
export type MouseEdgeBehavior =
| "IGNORE"
| "START_RESIZE_LEFT"
| "START_RESIZE_RIGHT";
// マウスバー時の振る舞い
export type MouseBarBehavior = "IGNORE" | "START_MOVE" | "EDIT_LYRIC";
*/

// マウスダウン時のコンテキスト
export interface MouseDownContext {
isSelfEventTarget: boolean;
mouseButton: MouseButton;
Expand All @@ -81,6 +30,7 @@ export interface MouseDownContext {
editingLyricNoteId?: NoteId;
}

// 最低限必要なコンテキスト
export interface EditModeContext {
ctrlKey: Ref<boolean>;
shiftKey: Ref<boolean>;
Expand Down
10 changes: 10 additions & 0 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,16 @@ export const PhraseKey = (id: string): PhraseKey => phraseKeySchema.parse(id);
export type SequencerEditTarget = "NOTE" | "PITCH";
export type NoteEditTool = "SELECT_FIRST" | "EDIT_FIRST";
export type PitchEditTool = "DRAW" | "ERASE";
// カーソルの状態
// NOTE: enumが妥当なのかは要検討
export enum CursorState {
UNSET = "unset",
EW_RESIZE = "ew-resize",
MOVE = "move",
CROSSHAIR = "crosshair",
DRAW = "draw",
ERASE = "erase",
}

export type TrackParameters = {
gain: boolean;
Expand Down
56 changes: 0 additions & 56 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,59 +718,3 @@ export interface MessageBoxReturnValue {
export const SandboxKey = "backend";

export type EditorType = "talk" | "song";

// カーソルの状態
// NOTE: enumが妥当なのかは要検討
export enum CursorState {
UNSET = "unset",
EW_RESIZE = "ew-resize",
MOVE = "move",
CROSSHAIR = "crosshair",
DRAW = "draw",
ERASE = "erase",
}

// ノート編集モードの種類
// 以下の2つについてはできることは同様でクリック時に主要となる操作が違う
// SELECT_FIRST: 選択優先(基本操作は選択)
// EDIT_FIRST: 編集優先(基本操作は編集)
export type NoteEditModeType = "SELECT_FIRST" | "EDIT_FIRST";

// ピッチ編集モードの種類
// DRAW: 変更ピッチを描画
// ERASE: 変更ピッチを削除
export type PitchEditModeType = "DRAW" | "ERASE";

// ノート編集時の振る舞い
export interface NoteEditBehaviors {
// 編集後にノートを選択するか
shouldSelectAfterEditing: boolean;
// クリック時にノートを追加するか
shouldAddNoteOnClick: boolean;
// ダブルクリック時にノートを追加するか
shouldAddNoteOnDoubleClick: boolean;
// クリック時に選択を解除するか
shouldDeselectAllOnClick: boolean;
// ドラッグ時に矩形選択を行うか
shouldRectSelectOnDrag: boolean;
// Ctrl/Cmdクリック時に選択を解除するか
shouldDeselectAllOnCtrlOrCommandClick: boolean;
}

// ノート編集モード
export interface NoteEditMode {
type: NoteEditModeType;
cursor: CursorState;
behaviors: NoteEditBehaviors;
}

// ピッチ編集モード
export interface PitchEditMode {
type: PitchEditModeType;
cursor: CursorState;
}

// 編集モード
export type EditMode =
| { target: "NOTE"; mode: NoteEditMode }
| { target: "PITCH"; mode: PitchEditMode };

0 comments on commit 0025f78

Please sign in to comment.