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 "../fileutils.h"
#include "misc/cpp/imgui_stdlib.h"
#include <imgui.h>
void FurnaceGUI::drawExportAudio() {
void FurnaceGUI::drawExportAudio(bool onWindow) {
exitDisabledTimer=1;
ImGui::RadioButton("one file",&audioExportType,0);
@ -35,7 +36,13 @@ void FurnaceGUI::drawExportAudio() {
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) {
case 0:
openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE);
@ -51,7 +58,7 @@ void FurnaceGUI::drawExportAudio() {
}
}
void FurnaceGUI::drawExportVGM() {
void FurnaceGUI::drawExportVGM(bool onWindow) {
exitDisabledTimer=1;
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);
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);
ImGui::CloseCurrentPopup();
}
} else {
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;
ImGui::Text("Commander X16 Zsound Music File");
@ -149,13 +165,18 @@ void FurnaceGUI::drawExportZSM() {
ImGui::Checkbox("loop",&zsmExportLoop);
ImGui::SameLine();
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);
ImGui::CloseCurrentPopup();
}
}
void FurnaceGUI::drawExportAmigaVal() {
void FurnaceGUI::drawExportAmigaVal(bool onWindow) {
exitDisabledTimer=1;
ImGui::Text(
@ -167,7 +188,12 @@ void FurnaceGUI::drawExportAmigaVal() {
ImGui::Text("Directory");
ImGui::SameLine();
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);
if (workingDirROMExport.size()>0) {
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;
ImGui::Text(
"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);
ImGui::CloseCurrentPopup();
}
}
void FurnaceGUI::drawExportCommand() {
void FurnaceGUI::drawExportCommand(bool onWindow) {
exitDisabledTimer=1;
ImGui::Text(
@ -209,29 +240,31 @@ void FurnaceGUI::drawExportCommand() {
"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);
ImGui::CloseCurrentPopup();
}
if (ImGui::Button("Export (text)")) {
ImGui::SameLine();
if (ImGui::Button("Export (text)",ImVec2(133.3f*dpiScale,0))) {
openFileDialog(GUI_FILE_EXPORT_CMDSTREAM);
ImGui::CloseCurrentPopup();
}
}
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 (ImGui::BeginTabBar("ExportTypes")) {
if (ImGui::BeginTabItem("Audio")) {
drawExportAudio();
drawExportAudio(true);
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("VGM")) {
drawExportVGM();
drawExportVGM(true);
ImGui::EndTabItem();
}
int numZSMCompat=0;
@ -240,7 +273,7 @@ void FurnaceGUI::drawExport() {
}
if (numZSMCompat>0) {
if (ImGui::BeginTabItem("ZSM")) {
drawExportZSM();
drawExportZSM(true);
ImGui::EndTabItem();
}
}
@ -250,38 +283,38 @@ void FurnaceGUI::drawExport() {
}
if (numAmiga && settings.iCannotWait) {
if (ImGui::BeginTabItem("Amiga Validation")) {
drawExportAmigaVal();
drawExportAmigaVal(true);
ImGui::EndTabItem();
}
}
if (ImGui::BeginTabItem("Text")) {
drawExportText();
drawExportText(true);
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Command Stream")) {
drawExportCommand();
drawExportCommand(true);
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
} else switch (curExportType) {
case GUI_EXPORT_AUDIO:
drawExportAudio();
drawExportAudio(true);
break;
case GUI_EXPORT_VGM:
drawExportVGM();
drawExportVGM(true);
break;
case GUI_EXPORT_ZSM:
drawExportZSM();
drawExportZSM(true);
break;
case GUI_EXPORT_AMIGA_VAL:
drawExportAmigaVal();
drawExportAmigaVal(true);
break;
case GUI_EXPORT_TEXT:
drawExportText();
drawExportText(true);
break;
case GUI_EXPORT_CMD_STREAM:
drawExportCommand();
drawExportCommand(true);
break;
default:
ImGui::Text("congratulations! you've unlocked a secret panel.");
@ -321,8 +354,4 @@ void FurnaceGUI::drawExport() {
}
break;
}
}
ImGui::EndChild();
ImGui::Separator();
if (ImGui::Button("Cancel")) ImGui::CloseCurrentPopup();
}

View file

@ -5420,11 +5420,8 @@ bool FurnaceGUI::loop() {
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));
if (ImGui::GetWindowSize().x<newSongMinSize.x || ImGui::GetWindowSize().y<newSongMinSize.y) {
ImGui::SetWindowSize(newSongMinSize,ImGuiCond_Always);
}
drawExport();
ImGui::EndPopup();
}

View file

@ -2305,7 +2305,7 @@ class FurnaceGUI {
int pianoOffset, pianoOffsetEdit;
int pianoView, pianoInputPadMode;
//effect sorting
// effect sorting
bool effectsShow[10];
// TX81Z
@ -2349,12 +2349,12 @@ class FurnaceGUI {
int audioExportType;
FurnaceGUIExportTypes curExportType;
void drawExportAudio();
void drawExportVGM();
void drawExportZSM();
void drawExportAmigaVal();
void drawExportText();
void drawExportCommand();
void drawExportAudio(bool onWindow=false);
void drawExportVGM(bool onWindow=false);
void drawExportZSM(bool onWindow=false);
void drawExportAmigaVal(bool onWindow=false);
void drawExportText(bool onWindow=false);
void drawExportCommand(bool onWindow=false);
void drawSSGEnv(unsigned char type, const ImVec2& size);
void drawWaveform(unsigned char type, bool opz, const ImVec2& size);