From 2e9bd65b9e06551db9017221c4fef3929f08ad05 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 9 May 2022 13:20:44 -0500 Subject: [PATCH] GUI: right click menu for open instrument --- src/gui/dataList.cpp | 15 ++++++++++++++- src/gui/doAction.cpp | 18 +++++++++++++++++- src/gui/gui.h | 1 + src/gui/guiConst.cpp | 1 + src/gui/insEdit.cpp | 14 +------------- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 0de552054..0df3015a2 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -47,7 +47,20 @@ void FurnaceGUI::drawInsList() { } ImGui::SameLine(); if (ImGui::Button(ICON_FA_FOLDER_OPEN "##InsLoad")) { - doAction((settings.insLoadAlwaysReplace && curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); + doAction(GUI_ACTION_INS_LIST_OPEN); + } + if (ImGui::BeginPopupContextItem("InsOpenOpt")) { + if (ImGui::MenuItem("replace...")) { + doAction((curIns>=0 && curIns<(int)e->song.ins.size())?GUI_ACTION_INS_LIST_OPEN_REPLACE:GUI_ACTION_INS_LIST_OPEN); + } + ImGui::Separator(); + if (ImGui::MenuItem("load from TX81Z")) { + doAction(GUI_ACTION_TX81Z_REQUEST); + } + ImGui::EndPopup(); + } + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("Open (insert; right-click to replace)"); } ImGui::SameLine(); if (ImGui::Button(ICON_FA_FLOPPY_O "##InsSave")) { diff --git a/src/gui/doAction.cpp b/src/gui/doAction.cpp index d966b797e..2e1dd3779 100644 --- a/src/gui/doAction.cpp +++ b/src/gui/doAction.cpp @@ -25,6 +25,11 @@ #include "actionUtil.h" #include "sampleUtil.h" +const unsigned char avRequest[15]={ + 0xf0, 0x43, 0x20, 0x7e, 0x4c, 0x4d, 0x20, 0x20, 0x38, 0x39, 0x37, 0x36, 0x41, 0x45, 0xf7 +}; + + void FurnaceGUI::doAction(int what) { switch (what) { case GUI_ACTION_OPEN: @@ -141,6 +146,17 @@ void FurnaceGUI::doAction(int what) { fullScreen=!fullScreen; SDL_SetWindowFullscreen(sdlWin,fullScreen?(SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP):0); break; + case GUI_ACTION_TX81Z_REQUEST: { + TAMidiMessage msg; + msg.type=TA_MIDI_SYSEX; + msg.sysExData.reset(new unsigned char[15]); + msg.sysExLen=15; + memcpy(msg.sysExData.get(),avRequest,15); + if (!e->sendMidiMessage(msg)) { + showError("Error while sending request (MIDI output not configured?)"); + } + break; + } case GUI_ACTION_PANIC: e->syncReset(); break; @@ -1251,4 +1267,4 @@ void FurnaceGUI::doAction(int what) { setOrder(curOrder); break; } -} \ No newline at end of file +} diff --git a/src/gui/gui.h b/src/gui/gui.h index e0b31a3be..667a6425b 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -306,6 +306,7 @@ enum FurnaceGUIActions { GUI_ACTION_FOLLOW_ORDERS, GUI_ACTION_FOLLOW_PATTERN, GUI_ACTION_FULLSCREEN, + GUI_ACTION_TX81Z_REQUEST, GUI_ACTION_PANIC, GUI_ACTION_WINDOW_EDIT_CONTROLS, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 3cbd82046..6760acb6a 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -459,6 +459,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={ D("FOLLOW_ORDERS", "Follow orders", 0), D("FOLLOW_PATTERN", "Follow pattern", 0), D("FULLSCREEN", "Toggle full-screen", SDLK_F11), + D("TX81Z_REQUEST", "Request voice from TX81Z", 0), D("PANIC", "Panic", SDLK_F12), D("WINDOW_EDIT_CONTROLS", "Edit Controls", 0), diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index a1b78bd1c..82b47fb69 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -27,10 +27,6 @@ #include #include "plot_nolerp.h" -const unsigned char avRequest[15]={ - 0xf0, 0x43, 0x20, 0x7e, 0x4c, 0x4d, 0x20, 0x20, 0x38, 0x39, 0x37, 0x36, 0x41, 0x45, 0xf7 -}; - const char* ssgEnvTypes[8]={ "Down Down Down", "Down.", "Down Up Down Up", "Down UP", "Up Up Up", "Up.", "Up Down Up Down", "Up DOWN" }; @@ -1364,7 +1360,6 @@ void FurnaceGUI::drawInsEdit() { ImGui::TableNextRow(); ImGui::TableNextColumn(); - // TODO: load replace if (ImGui::Button(ICON_FA_FOLDER_OPEN "##IELoad")) { doAction(GUI_ACTION_INS_LIST_OPEN_REPLACE); } @@ -1477,14 +1472,7 @@ void FurnaceGUI::drawInsEdit() { ImGui::TableNextColumn(); drawAlgorithm(ins->fm.alg,FM_ALGS_4OP,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale)); if (ImGui::Button("Request from TX81Z")) { - TAMidiMessage msg; - msg.type=TA_MIDI_SYSEX; - msg.sysExData.reset(new unsigned char[15]); - msg.sysExLen=15; - memcpy(msg.sysExData.get(),avRequest,15); - if (!e->sendMidiMessage(msg)) { - showError("Error while sending request (MIDI output not configured?)"); - } + doAction(GUI_ACTION_TX81Z_REQUEST); } ImGui::SameLine(); if (ImGui::Button("Send to TX81Z")) {