From d4e1a3e65fec47601d89bc1f96eded90e15e8aa1 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Wed, 2 Nov 2022 03:30:51 -0500 Subject: [PATCH] GUI: wave/sample preview using piano --- src/gui/piano.cpp | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/src/gui/piano.cpp b/src/gui/piano.cpp index f4d4d9dfa..cb9ce969b 100644 --- a/src/gui/piano.cpp +++ b/src/gui/piano.cpp @@ -375,9 +375,21 @@ void FurnaceGUI::drawPiano() { int note=i-60; if (!pianoKeyPressed[i]) { if (pianoKeyPressed[i]!=oldPianoKeyPressed[i]) { - e->synchronized([this,note]() { - e->autoNoteOff(-1,note); - }); + switch (curWindow) { + case GUI_WINDOW_WAVE_LIST: + case GUI_WINDOW_WAVE_EDIT: + e->stopWavePreview(); + break; + case GUI_WINDOW_SAMPLE_LIST: + case GUI_WINDOW_SAMPLE_EDIT: + e->stopSamplePreview(); + break; + default: + e->synchronized([this,note]() { + e->autoNoteOff(-1,note); + }); + break; + } } } } @@ -386,10 +398,22 @@ void FurnaceGUI::drawPiano() { int note=i-60; if (pianoKeyPressed[i]) { if (pianoKeyPressed[i]!=oldPianoKeyPressed[i]) { - e->synchronized([this,note]() { - e->autoNoteOn(-1,curIns,note); - }); - if (edit) noteInput(note,0); + switch (curWindow) { + case GUI_WINDOW_WAVE_LIST: + case GUI_WINDOW_WAVE_EDIT: + e->previewWave(curWave,note); + break; + case GUI_WINDOW_SAMPLE_LIST: + case GUI_WINDOW_SAMPLE_EDIT: + e->previewSample(curWave,note); + break; + default: + e->synchronized([this,note]() { + e->autoNoteOn(-1,curIns,note); + }); + if (edit) noteInput(note,0); + break; + } } } } @@ -398,7 +422,8 @@ void FurnaceGUI::drawPiano() { ImGui::EndTable(); } } - if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PIANO; + // don't worry about it + //if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PIANO; ImGui::End(); // draw input pad if necessary @@ -459,7 +484,8 @@ void FurnaceGUI::drawPiano() { } ImGui::EndDisabled(); } - if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PIANO; + // don't worry about it either + //if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PIANO; ImGui::End(); } }