GUI: right click menu for open instrument

This commit is contained in:
tildearrow 2022-05-09 13:20:44 -05:00
parent 6bc1ee0957
commit 2e9bd65b9e
5 changed files with 34 additions and 15 deletions

View file

@ -47,7 +47,20 @@ void FurnaceGUI::drawInsList() {
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##InsLoad")) { 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(); ImGui::SameLine();
if (ImGui::Button(ICON_FA_FLOPPY_O "##InsSave")) { if (ImGui::Button(ICON_FA_FLOPPY_O "##InsSave")) {

View file

@ -25,6 +25,11 @@
#include "actionUtil.h" #include "actionUtil.h"
#include "sampleUtil.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) { void FurnaceGUI::doAction(int what) {
switch (what) { switch (what) {
case GUI_ACTION_OPEN: case GUI_ACTION_OPEN:
@ -141,6 +146,17 @@ void FurnaceGUI::doAction(int what) {
fullScreen=!fullScreen; fullScreen=!fullScreen;
SDL_SetWindowFullscreen(sdlWin,fullScreen?(SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP):0); SDL_SetWindowFullscreen(sdlWin,fullScreen?(SDL_WINDOW_FULLSCREEN|SDL_WINDOW_FULLSCREEN_DESKTOP):0);
break; 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: case GUI_ACTION_PANIC:
e->syncReset(); e->syncReset();
break; break;

View file

@ -306,6 +306,7 @@ enum FurnaceGUIActions {
GUI_ACTION_FOLLOW_ORDERS, GUI_ACTION_FOLLOW_ORDERS,
GUI_ACTION_FOLLOW_PATTERN, GUI_ACTION_FOLLOW_PATTERN,
GUI_ACTION_FULLSCREEN, GUI_ACTION_FULLSCREEN,
GUI_ACTION_TX81Z_REQUEST,
GUI_ACTION_PANIC, GUI_ACTION_PANIC,
GUI_ACTION_WINDOW_EDIT_CONTROLS, GUI_ACTION_WINDOW_EDIT_CONTROLS,

View file

@ -459,6 +459,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
D("FOLLOW_ORDERS", "Follow orders", 0), D("FOLLOW_ORDERS", "Follow orders", 0),
D("FOLLOW_PATTERN", "Follow pattern", 0), D("FOLLOW_PATTERN", "Follow pattern", 0),
D("FULLSCREEN", "Toggle full-screen", SDLK_F11), D("FULLSCREEN", "Toggle full-screen", SDLK_F11),
D("TX81Z_REQUEST", "Request voice from TX81Z", 0),
D("PANIC", "Panic", SDLK_F12), D("PANIC", "Panic", SDLK_F12),
D("WINDOW_EDIT_CONTROLS", "Edit Controls", 0), D("WINDOW_EDIT_CONTROLS", "Edit Controls", 0),

View file

@ -27,10 +27,6 @@
#include <imgui.h> #include <imgui.h>
#include "plot_nolerp.h" #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]={ const char* ssgEnvTypes[8]={
"Down Down Down", "Down.", "Down Up Down Up", "Down UP", "Up Up Up", "Up.", "Up Down Up Down", "Up DOWN" "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::TableNextRow();
ImGui::TableNextColumn(); ImGui::TableNextColumn();
// TODO: load replace
if (ImGui::Button(ICON_FA_FOLDER_OPEN "##IELoad")) { if (ImGui::Button(ICON_FA_FOLDER_OPEN "##IELoad")) {
doAction(GUI_ACTION_INS_LIST_OPEN_REPLACE); doAction(GUI_ACTION_INS_LIST_OPEN_REPLACE);
} }
@ -1477,14 +1472,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::TableNextColumn(); ImGui::TableNextColumn();
drawAlgorithm(ins->fm.alg,FM_ALGS_4OP,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale)); drawAlgorithm(ins->fm.alg,FM_ALGS_4OP,ImVec2(ImGui::GetContentRegionAvail().x,48.0*dpiScale));
if (ImGui::Button("Request from TX81Z")) { if (ImGui::Button("Request from TX81Z")) {
TAMidiMessage msg; doAction(GUI_ACTION_TX81Z_REQUEST);
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?)");
}
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Send to TX81Z")) { if (ImGui::Button("Send to TX81Z")) {