-
Notifications
You must be signed in to change notification settings - Fork 313
/
Copy pathMenuBar.vue
123 lines (116 loc) · 2.75 KB
/
MenuBar.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<template>
<BaseMenuBar
editor="song"
:file-sub-menu-data="fileSubMenuData"
:edit-sub-menu-data="editSubMenuData"
/>
</template>
<script setup lang="ts">
import { computed } from "vue";
import { useStore } from "@/store";
import BaseMenuBar from "@/components/Menu/MenuBar/BaseMenuBar.vue";
import { MenuItemData } from "@/components/Menu/type";
const store = useStore();
const uiLocked = computed(() => store.getters.UI_LOCKED);
const isNotesSelected = computed(() => store.state.selectedNoteIds.size > 0);
const importMidiFile = async () => {
if (uiLocked.value) return;
await store.dispatch("IMPORT_MIDI_FILE", {});
};
const importMusicXMLFile = async () => {
if (uiLocked.value) return;
await store.dispatch("IMPORT_MUSICXML_FILE", {});
};
const exportWaveFile = async () => {
if (uiLocked.value) return;
await store.dispatch("EXPORT_WAVE_FILE", {});
};
const fileSubMenuData: MenuItemData[] = [
{
type: "button",
label: "音声を出力",
onClick: () => {
exportWaveFile();
},
disableWhenUiLocked: true,
},
{ type: "separator" },
{
type: "button",
label: "MIDI読み込み",
onClick: () => {
importMidiFile();
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "MusicXML読み込み",
onClick: () => {
importMusicXMLFile();
},
disableWhenUiLocked: true,
},
];
const editSubMenuData: MenuItemData[] = [
{ type: "separator" },
{
type: "button",
label: "コピー",
onClick: () => {
if (uiLocked.value) return;
store.dispatch("COPY_NOTES_TO_CLIPBOARD");
},
disableWhenUiLocked: true,
disabled: !isNotesSelected.value,
},
{
type: "button",
label: "切り取り",
onClick: () => {
if (uiLocked.value) return;
store.dispatch("COMMAND_CUT_NOTES_TO_CLIPBOARD");
},
disableWhenUiLocked: true,
disabled: !isNotesSelected.value,
},
{
type: "button",
label: "貼り付け",
onClick: () => {
if (uiLocked.value) return;
store.dispatch("COMMAND_PASTE_NOTES_FROM_CLIPBOARD");
},
disableWhenUiLocked: true,
},
{ type: "separator" },
{
type: "button",
label: "すべて選択",
onClick: () => {
if (uiLocked.value) return;
store.dispatch("SELECT_ALL_NOTES");
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "選択解除",
onClick: () => {
if (uiLocked.value) return;
store.dispatch("DESELECT_ALL_NOTES");
},
disableWhenUiLocked: true,
},
{ type: "separator" },
{
type: "button",
label: "クオンタイズ",
onClick: () => {
if (uiLocked.value) return;
store.dispatch("COMMAND_QUANTIZE_SELECTED_NOTES");
},
disableWhenUiLocked: true,
},
];
</script>