GUI: improve the buttons

This commit is contained in:
tildearrow 2023-12-22 19:18:23 -05:00
parent c65debad68
commit 27f4f6830e
3 changed files with 150 additions and 124 deletions

View file

@ -21,8 +21,9 @@
#include "guiConst.h" #include "guiConst.h"
#include "../fileutils.h" #include "../fileutils.h"
#include "misc/cpp/imgui_stdlib.h" #include "misc/cpp/imgui_stdlib.h"
#include <imgui.h>
void FurnaceGUI::drawExportAudio() { void FurnaceGUI::drawExportAudio(bool onWindow) {
exitDisabledTimer=1; exitDisabledTimer=1;
ImGui::RadioButton("one file",&audioExportType,0); ImGui::RadioButton("one file",&audioExportType,0);
@ -35,7 +36,13 @@ void FurnaceGUI::drawExportAudio() {
if (exportFadeOut<0.0) exportFadeOut=0.0; if (exportFadeOut<0.0) exportFadeOut=0.0;
} }
if (ImGui::Button("Export")) { if (onWindow) {
ImGui::Separator();
if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
ImGui::SameLine();
}
if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) {
switch (audioExportType) { switch (audioExportType) {
case 0: case 0:
openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE); openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE);
@ -51,7 +58,7 @@ void FurnaceGUI::drawExportAudio() {
} }
} }
void FurnaceGUI::drawExportVGM() { void FurnaceGUI::drawExportVGM(bool onWindow) {
exitDisabledTimer=1; exitDisabledTimer=1;
ImGui::Text("settings:"); ImGui::Text("settings:");
@ -129,16 +136,25 @@ void FurnaceGUI::drawExportVGM() {
} }
ImGui::Text("select the chip you wish to export, but only up to %d of each type.",(vgmExportVersion>=0x151)?2:1); ImGui::Text("select the chip you wish to export, but only up to %d of each type.",(vgmExportVersion>=0x151)?2:1);
if (hasOneAtLeast) { if (hasOneAtLeast) {
if (ImGui::Button("Export")) { if (onWindow) {
ImGui::Separator();
if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
ImGui::SameLine();
}
if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) {
openFileDialog(GUI_FILE_EXPORT_VGM); openFileDialog(GUI_FILE_EXPORT_VGM);
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
} else { } else {
ImGui::Text("nothing to export"); ImGui::Text("nothing to export");
if (onWindow) {
ImGui::Separator();
if (ImGui::Button("Cancel",ImVec2(400.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
}
} }
} }
void FurnaceGUI::drawExportZSM() { void FurnaceGUI::drawExportZSM(bool onWindow) {
exitDisabledTimer=1; exitDisabledTimer=1;
ImGui::Text("Commander X16 Zsound Music File"); ImGui::Text("Commander X16 Zsound Music File");
@ -149,13 +165,18 @@ void FurnaceGUI::drawExportZSM() {
ImGui::Checkbox("loop",&zsmExportLoop); ImGui::Checkbox("loop",&zsmExportLoop);
ImGui::SameLine(); ImGui::SameLine();
ImGui::Checkbox("optimize size",&zsmExportOptimize); ImGui::Checkbox("optimize size",&zsmExportOptimize);
if (ImGui::Button("Export")) { if (onWindow) {
ImGui::Separator();
if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
ImGui::SameLine();
}
if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) {
openFileDialog(GUI_FILE_EXPORT_ZSM); openFileDialog(GUI_FILE_EXPORT_ZSM);
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
} }
void FurnaceGUI::drawExportAmigaVal() { void FurnaceGUI::drawExportAmigaVal(bool onWindow) {
exitDisabledTimer=1; exitDisabledTimer=1;
ImGui::Text( ImGui::Text(
@ -167,7 +188,12 @@ void FurnaceGUI::drawExportAmigaVal() {
ImGui::Text("Directory"); ImGui::Text("Directory");
ImGui::SameLine(); ImGui::SameLine();
ImGui::InputText("##AVDPath",&workingDirROMExport); ImGui::InputText("##AVDPath",&workingDirROMExport);
if (ImGui::Button("Bake Data")) { if (onWindow) {
ImGui::Separator();
if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
ImGui::SameLine();
}
if (ImGui::Button("Bake Data",ImVec2(200.0f*dpiScale,0))) {
std::vector<DivROMExportOutput> out=e->buildROM(DIV_ROM_AMIGA_VALIDATION); std::vector<DivROMExportOutput> out=e->buildROM(DIV_ROM_AMIGA_VALIDATION);
if (workingDirROMExport.size()>0) { if (workingDirROMExport.size()>0) {
if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR; if (workingDirROMExport[workingDirROMExport.size()-1]!=DIR_SEPARATOR) workingDirROMExport+=DIR_SEPARATOR_STR;
@ -187,19 +213,24 @@ void FurnaceGUI::drawExportAmigaVal() {
} }
} }
void FurnaceGUI::drawExportText() { void FurnaceGUI::drawExportText(bool onWindow) {
exitDisabledTimer=1; exitDisabledTimer=1;
ImGui::Text( ImGui::Text(
"this option exports the song to a text file.\n" "this option exports the song to a text file.\n"
); );
if (ImGui::Button("Export")) { if (onWindow) {
ImGui::Separator();
if (ImGui::Button("Cancel",ImVec2(200.0f*dpiScale,0))) ImGui::CloseCurrentPopup();
ImGui::SameLine();
}
if (ImGui::Button("Export",ImVec2(200.0f*dpiScale,0))) {
openFileDialog(GUI_FILE_EXPORT_TEXT); openFileDialog(GUI_FILE_EXPORT_TEXT);
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
} }
void FurnaceGUI::drawExportCommand() { void FurnaceGUI::drawExportCommand(bool onWindow) {
exitDisabledTimer=1; exitDisabledTimer=1;
ImGui::Text( ImGui::Text(
@ -209,29 +240,31 @@ void FurnaceGUI::drawExportCommand() {
"technical/development use only!" "technical/development use only!"
); );
if (ImGui::Button("Export (binary)")) { if (onWindow) {
ImGui::Separator();
if (ImGui::Button("Cancel",ImVec2(133.3f*dpiScale,0))) ImGui::CloseCurrentPopup();
ImGui::SameLine();
}
if (ImGui::Button("Export (binary)",ImVec2(133.3f*dpiScale,0))) {
openFileDialog(GUI_FILE_EXPORT_CMDSTREAM_BINARY); openFileDialog(GUI_FILE_EXPORT_CMDSTREAM_BINARY);
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
if (ImGui::Button("Export (text)")) { ImGui::SameLine();
if (ImGui::Button("Export (text)",ImVec2(133.3f*dpiScale,0))) {
openFileDialog(GUI_FILE_EXPORT_CMDSTREAM); openFileDialog(GUI_FILE_EXPORT_CMDSTREAM);
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
} }
void FurnaceGUI::drawExport() { void FurnaceGUI::drawExport() {
ImVec2 avail=ImGui::GetContentRegionAvail();
avail.y-=ImGui::GetFrameHeightWithSpacing();
if (ImGui::BeginChild("sysPickerC",avail,false)) {
if (settings.exportOptionsLayout==1 || curExportType==GUI_EXPORT_NONE) { if (settings.exportOptionsLayout==1 || curExportType==GUI_EXPORT_NONE) {
if (ImGui::BeginTabBar("ExportTypes")) { if (ImGui::BeginTabBar("ExportTypes")) {
if (ImGui::BeginTabItem("Audio")) { if (ImGui::BeginTabItem("Audio")) {
drawExportAudio(); drawExportAudio(true);
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("VGM")) { if (ImGui::BeginTabItem("VGM")) {
drawExportVGM(); drawExportVGM(true);
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
int numZSMCompat=0; int numZSMCompat=0;
@ -240,7 +273,7 @@ void FurnaceGUI::drawExport() {
} }
if (numZSMCompat>0) { if (numZSMCompat>0) {
if (ImGui::BeginTabItem("ZSM")) { if (ImGui::BeginTabItem("ZSM")) {
drawExportZSM(); drawExportZSM(true);
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
} }
@ -250,38 +283,38 @@ void FurnaceGUI::drawExport() {
} }
if (numAmiga && settings.iCannotWait) { if (numAmiga && settings.iCannotWait) {
if (ImGui::BeginTabItem("Amiga Validation")) { if (ImGui::BeginTabItem("Amiga Validation")) {
drawExportAmigaVal(); drawExportAmigaVal(true);
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
} }
if (ImGui::BeginTabItem("Text")) { if (ImGui::BeginTabItem("Text")) {
drawExportText(); drawExportText(true);
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Command Stream")) { if (ImGui::BeginTabItem("Command Stream")) {
drawExportCommand(); drawExportCommand(true);
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
} else switch (curExportType) { } else switch (curExportType) {
case GUI_EXPORT_AUDIO: case GUI_EXPORT_AUDIO:
drawExportAudio(); drawExportAudio(true);
break; break;
case GUI_EXPORT_VGM: case GUI_EXPORT_VGM:
drawExportVGM(); drawExportVGM(true);
break; break;
case GUI_EXPORT_ZSM: case GUI_EXPORT_ZSM:
drawExportZSM(); drawExportZSM(true);
break; break;
case GUI_EXPORT_AMIGA_VAL: case GUI_EXPORT_AMIGA_VAL:
drawExportAmigaVal(); drawExportAmigaVal(true);
break; break;
case GUI_EXPORT_TEXT: case GUI_EXPORT_TEXT:
drawExportText(); drawExportText(true);
break; break;
case GUI_EXPORT_CMD_STREAM: case GUI_EXPORT_CMD_STREAM:
drawExportCommand(); drawExportCommand(true);
break; break;
default: default:
ImGui::Text("congratulations! you've unlocked a secret panel."); ImGui::Text("congratulations! you've unlocked a secret panel.");
@ -322,7 +355,3 @@ void FurnaceGUI::drawExport() {
break; break;
} }
} }
ImGui::EndChild();
ImGui::Separator();
if (ImGui::Button("Cancel")) ImGui::CloseCurrentPopup();
}

View file

@ -5420,11 +5420,8 @@ bool FurnaceGUI::loop() {
ImGui::EndPopup(); ImGui::EndPopup();
} }
if (ImGui::BeginPopupModal("Export",NULL,ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar)) { if (ImGui::BeginPopupModal("Export",NULL,ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollWithMouse|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::SetWindowPos(ImVec2(((canvasW)-ImGui::GetWindowSize().x)*0.5,((canvasH)-ImGui::GetWindowSize().y)*0.5)); ImGui::SetWindowPos(ImVec2(((canvasW)-ImGui::GetWindowSize().x)*0.5,((canvasH)-ImGui::GetWindowSize().y)*0.5));
if (ImGui::GetWindowSize().x<newSongMinSize.x || ImGui::GetWindowSize().y<newSongMinSize.y) {
ImGui::SetWindowSize(newSongMinSize,ImGuiCond_Always);
}
drawExport(); drawExport();
ImGui::EndPopup(); ImGui::EndPopup();
} }

View file

@ -2349,12 +2349,12 @@ class FurnaceGUI {
int audioExportType; int audioExportType;
FurnaceGUIExportTypes curExportType; FurnaceGUIExportTypes curExportType;
void drawExportAudio(); void drawExportAudio(bool onWindow=false);
void drawExportVGM(); void drawExportVGM(bool onWindow=false);
void drawExportZSM(); void drawExportZSM(bool onWindow=false);
void drawExportAmigaVal(); void drawExportAmigaVal(bool onWindow=false);
void drawExportText(); void drawExportText(bool onWindow=false);
void drawExportCommand(); void drawExportCommand(bool onWindow=false);
void drawSSGEnv(unsigned char type, const ImVec2& size); void drawSSGEnv(unsigned char type, const ImVec2& size);
void drawWaveform(unsigned char type, bool opz, const ImVec2& size); void drawWaveform(unsigned char type, bool opz, const ImVec2& size);