From 44d72c210611066e2cb16f7089cc1cd36aeaabe8 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 2 Apr 2022 18:22:06 -0500 Subject: [PATCH] GUI: add load/save/select to ins/wave editors TODO: on sample editor TODO: load replace instead of load insert --- src/gui/insEdit.cpp | 59 ++++++++++++++++++++++++++++++++++++++------ src/gui/waveEdit.cpp | 17 +++++++++++++ 2 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index f9fc3db40..2e4489378 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -1132,14 +1132,59 @@ void FurnaceGUI::drawInsEdit() { ImGui::Text("no instrument selected"); } else { DivInstrument* ins=e->song.ins[curIns]; - if (ImGui::InputText("Name",&ins->name)) { - MARK_MODIFIED; - } - if (ins->type<0 || ins->type>=DIV_INS_MAX) ins->type=DIV_INS_FM; - int insType=ins->type; - if (ImGui::Combo("Type",&insType,insTypes,DIV_INS_MAX,DIV_INS_MAX)) { - ins->type=(DivInstrumentType)insType; + if (ImGui::BeginTable("InsProp",3)) { + ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("c2",ImGuiTableColumnFlags_WidthStretch); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + String insIndex=fmt::sprintf("%.2X",curIns); + if (ImGui::BeginCombo("##InsSelect",insIndex.c_str())) { + String name; + for (size_t i=0; isong.ins.size(); i++) { + name=fmt::sprintf("%.2X: %s##_INSS%d",i,e->song.ins[i]->name,i); + if (ImGui::Selectable(name.c_str(),curIns==(int)i)) { + curIns=i; + ins=e->song.ins[curIns]; + } + } + ImGui::EndCombo(); + } + + ImGui::TableNextColumn(); + ImGui::Text("Name"); + + ImGui::TableNextColumn(); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::InputText("##Name",&ins->name)) { + MARK_MODIFIED; + } + + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + // TODO: load replace + if (ImGui::Button(ICON_FA_FOLDER_OPEN "##IELoad")) { + doAction(GUI_ACTION_INS_LIST_OPEN); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_FLOPPY_O "##IESave")) { + doAction(GUI_ACTION_INS_LIST_SAVE); + } + + ImGui::TableNextColumn(); + ImGui::Text("Type"); + + ImGui::TableNextColumn(); + if (ins->type<0 || ins->type>=DIV_INS_MAX) ins->type=DIV_INS_FM; + int insType=ins->type; + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (ImGui::Combo("##Type",&insType,insTypes,DIV_INS_MAX,DIV_INS_MAX)) { + ins->type=(DivInstrumentType)insType; + } + + ImGui::EndTable(); } + if (ImGui::BeginTabBar("insEditTab")) { if (ins->type==DIV_INS_FM || ins->type==DIV_INS_OPL || ins->type==DIV_INS_OPLL || ins->type==DIV_INS_OPZ) { diff --git a/src/gui/waveEdit.cpp b/src/gui/waveEdit.cpp index e1359da93..406e7d885 100644 --- a/src/gui/waveEdit.cpp +++ b/src/gui/waveEdit.cpp @@ -19,6 +19,7 @@ #include "gui.h" #include "plot_nolerp.h" +#include "IconsFontAwesome4.h" #include "misc/cpp/imgui_stdlib.h" #include @@ -35,6 +36,22 @@ void FurnaceGUI::drawWaveEdit() { if (curWave<0 || curWave>=(int)e->song.wave.size()) { ImGui::Text("no wavetable selected"); } else { + ImGui::SetNextItemWidth(80.0f*dpiScale); + if (ImGui::InputInt("##CurWave",&curWave,1,1)) { + if (curWave<0) curWave=0; + if (curWave>=(int)e->song.wave.size()) curWave=e->song.wave.size()-1; + } + ImGui::SameLine(); + // TODO: load replace + if (ImGui::Button(ICON_FA_FOLDER_OPEN "##WELoad")) { + doAction(GUI_ACTION_WAVE_LIST_OPEN); + } + ImGui::SameLine(); + if (ImGui::Button(ICON_FA_FLOPPY_O "##WESave")) { + doAction(GUI_ACTION_WAVE_LIST_SAVE); + } + ImGui::SameLine(); + DivWavetable* wave=e->song.wave[curWave]; ImGui::Text("Width"); if (ImGui::IsItemHovered()) {