From eaed3f40a2b660f4f9aefd0b2366528dae2ed561 Mon Sep 17 00:00:00 2001 From: josc146 Date: Sun, 10 Dec 2023 23:37:23 +0800 Subject: [PATCH] improve current instrument display --- frontend/src/_locales/ja/main.json | 3 +- frontend/src/_locales/zh-hans/main.json | 3 +- .../AudiotrackManager/AudiotrackEditor.tsx | 44 +++++-------------- 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/frontend/src/_locales/ja/main.json b/frontend/src/_locales/ja/main.json index ce76ad6..326c02b 100644 --- a/frontend/src/_locales/ja/main.json +++ b/frontend/src/_locales/ja/main.json @@ -312,5 +312,6 @@ "JP": "日本語", "Music": "音楽", "Other": "その他", - "Import MIDI": "MIDIをインポート" + "Import MIDI": "MIDIをインポート", + "Current Instrument": "現在の楽器" } \ No newline at end of file diff --git a/frontend/src/_locales/zh-hans/main.json b/frontend/src/_locales/zh-hans/main.json index af02789..f39640b 100644 --- a/frontend/src/_locales/zh-hans/main.json +++ b/frontend/src/_locales/zh-hans/main.json @@ -312,5 +312,6 @@ "JP": "日文", "Music": "音乐", "Other": "其他", - "Import MIDI": "导入MIDI" + "Import MIDI": "导入MIDI", + "Current Instrument": "当前乐器" } \ No newline at end of file diff --git a/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx b/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx index 5247489..e47892f 100644 --- a/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx +++ b/frontend/src/pages/AudiotrackManager/AudiotrackEditor.tsx @@ -28,7 +28,6 @@ import { tracksMinimalTotalTime } from '../../types/composition'; import { toast } from 'react-toastify'; -import { ToastOptions } from 'react-toastify/dist/types'; import { absPathAsset, flushMidiRecordingContent, @@ -38,7 +37,6 @@ import { refreshTracksTotalTime } from '../../utils'; import { OpenOpenFileDialog, PlayNote } from '../../../wailsjs/go/backend_golang/App'; -import { t } from 'i18next'; const snapValue = 25; const minimalMoveTime = 8; // 1000/125=8ms wait_events=125 @@ -56,35 +54,6 @@ const pixelFix = 0.5; const topToArrowIcon = 19; const arrowIconToTracks = 23; -const displayCurrentInstrumentType = () => { - const displayPanelId = 'instrument_panel_id'; - const content: React.ReactNode = -
- {InstrumentTypeNameMap.map((name, i) => - {t(name)})} -
; - const options: ToastOptions = { - type: 'default', - autoClose: 2000, - toastId: displayPanelId, - position: 'top-left', - style: { - width: 'fit-content' - } - }; - if (toast.isActive(displayPanelId)) - toast.update(displayPanelId, { - render: content, - ...options - }); - else - toast(content, options); -}; - const velocityToBin = (velocity: number) => { velocity = Math.max(0, Math.min(velocity, velocityEvents - 1)); const binsize = velocityEvents / (velocityBins - 1); @@ -164,7 +133,6 @@ let dropRecordingTime = false; export const midiMessageHandler = async (data: MidiMessage) => { if (data.messageType === 'ControlChange') { commonStore.setInstrumentType(Math.round(data.value / 127 * (InstrumentTypeNameMap.length - 1))); - displayCurrentInstrumentType(); return; } if (commonStore.recordingTrackId) { @@ -568,6 +536,18 @@ const AudiotrackEditor: FC<{ setPrompt: (prompt: string) => void }> = observer(( } + { + commonStore.platform !== 'web' && +
+ {t('Current Instrument') + ':'} + {InstrumentTypeNameMap.map((name, i) => + {t(name)})} +
+ }