From bd3a6961188be202a991b2e1c7df799af01cb3ab Mon Sep 17 00:00:00 2001 From: Sauraen Date: Sun, 5 Feb 2023 16:35:09 -0800 Subject: [PATCH] Updated JUCE version, fixed some GUI related bugs --- CMakeLists.txt | 13 ++++++------- Source/SeqEditor.cpp | 34 +++++++++++++++++++++++++++------- Source/SeqFile.cpp | 10 +++++----- Source/TextListBox.cpp | 6 +++++- Source/TextListBox.hpp | 2 +- juce | 2 +- 6 files changed, 45 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9df46a2..b06b3b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ list(TRANSFORM SEQ64_GUI_ONLY_SOURCES PREPEND "Source/") if(WIN32) set(SEQ64_COMPILE_OPTIONS "/W2" "/O2") else() - set(SEQ64_COMPILE_OPTIONS "-Wall" "-Wextra" "-Wno-sign-compare" "-Wno-sign-conversion" "-O3") + set(SEQ64_COMPILE_OPTIONS "-Wall" "-Wextra" "-Wno-sign-compare" "-Wno-sign-conversion" "-O2") endif() set(NAME_STR "SEQ64 V${PROJECT_VERSION}") @@ -79,6 +79,10 @@ set(SEQ64_DEFINITIONS JUCE_APPLICATION_VERSION_HEX=${VER_HEX} ) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) +set(CMAKE_CXX_EXTENSIONS FALSE) + # Console version add_executable(seq64_console @@ -89,9 +93,6 @@ add_executable(seq64_console "juce/modules/juce_audio_basics/juce_audio_basics.cpp" "juce/modules/juce_data_structures/juce_data_structures.cpp" ) -if(APPLE) - set_target_properties(seq64_console PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED TRUE CXX_EXTENSIONS FALSE) -endif() target_include_directories(seq64_console PRIVATE "Source" "juce/modules" @@ -116,12 +117,10 @@ if(SEQ64_BUILD_GUI) juce_add_gui_app(seq64_gui PRODUCT_NAME "seq64_gui" COMPANY_NAME "Sauraen") juce_generate_juce_header(seq64_gui) target_sources(seq64_gui PRIVATE ${SEQ64_SHARED_SOURCES} ${SEQ64_GUI_ONLY_SOURCES}) - if(APPLE) - set_target_properties(seq64_gui PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED TRUE CXX_EXTENSIONS FALSE) - endif() target_compile_definitions(seq64_gui PRIVATE ${SEQ64_DEFINITIONS} JUCE_DISPLAY_SPLASH_SCREEN=0 + JUCE_MODAL_LOOPS_PERMITTED=1 ) target_link_libraries(seq64_gui PRIVATE juce::juce_core diff --git a/Source/SeqEditor.cpp b/Source/SeqEditor.cpp index 7dfad4f..3474c20 100644 --- a/Source/SeqEditor.cpp +++ b/Source/SeqEditor.cpp @@ -790,7 +790,10 @@ void SeqEditor::buttonClicked (juce::Button* buttonThatWasClicked) //TODO default files File f = File::getSpecialLocation(File::userHomeDirectory); //TODO SEQ64::readFolderProperty("midiimportfolder"); FileChooser box("Select a MIDI to load...", f, "*.mid;*.midi;*.rmi", true); - if(!box.browseForFileToOpen()) return; + File oldwd = File::getCurrentWorkingDirectory(); + bool hitokay = box.browseForFileToOpen(); + oldwd.setAsCurrentWorkingDirectory(); + if(!hitokay) return; f = box.getResult(); if(!f.existsAsFile()){ std::cout << "File " << f.getFullPathName() << " does not exist!"; @@ -814,7 +817,10 @@ void SeqEditor::buttonClicked (juce::Button* buttonThatWasClicked) File savelocation = File::getSpecialLocation(File::userHomeDirectory); //SEQ64::readFolderProperty("midifolder"); FileChooser box("Save MIDI", savelocation, "*.mid", true); - if(!box.browseForFileToSave(true)) return; + File oldwd = File::getCurrentWorkingDirectory(); + bool hitokay = box.browseForFileToSave(true); + oldwd.setAsCurrentWorkingDirectory(); + if(!hitokay) return; savelocation = box.getResult(); startSeqOperation("MIDI export", &SeqFile::exportMIDI, savelocation, midiopts); //[/UserButtonCode_btnExportMIDI] @@ -827,7 +833,10 @@ void SeqEditor::buttonClicked (juce::Button* buttonThatWasClicked) if(!checkSeqPresence(false)) return; File f = File::getSpecialLocation(File::userHomeDirectory); //TODO SEQ64::readFolderProperty("romfolder"); FileChooser box("Load .mus", f, "*.mus", true); - if(!box.browseForFileToOpen()) return; + File oldwd = File::getCurrentWorkingDirectory(); + bool hitokay = box.browseForFileToOpen(); + oldwd.setAsCurrentWorkingDirectory(); + if(!hitokay) return; f = box.getResult(); seq.reset(new SeqFile(abi)); startSeqOperation(".mus import", &SeqFile::importMus, f); @@ -839,7 +848,10 @@ void SeqEditor::buttonClicked (juce::Button* buttonThatWasClicked) if(!checkSeqPresence(true)) return; File savelocation = File::getSpecialLocation(File::userHomeDirectory); //SEQ64::readFolderProperty("comfolder"); FileChooser box("Save .mus", savelocation, "*.mus", true); - if(!box.browseForFileToSave(true)) return; + File oldwd = File::getCurrentWorkingDirectory(); + bool hitokay = box.browseForFileToSave(true); + oldwd.setAsCurrentWorkingDirectory(); + if(!hitokay) return; savelocation = box.getResult(); int dialect = optMusCommunity->getToggleState() ? 0 : optMusCanon->getToggleState() ? 2 : 4; dialect |= optStyleSFX->getToggleState() ? 1 : 0; @@ -854,7 +866,10 @@ void SeqEditor::buttonClicked (juce::Button* buttonThatWasClicked) if(!checkSeqPresence(false)) return; File f = File::getSpecialLocation(File::userHomeDirectory); //TODO SEQ64::readFolderProperty("romfolder"); FileChooser box("Load .com/.aseq", f, "*.com;*.aseq;*.seq;*.m64;*.bin;*.seq", true); - if(!box.browseForFileToOpen()) return; + File oldwd = File::getCurrentWorkingDirectory(); + bool hitokay = box.browseForFileToOpen(); + oldwd.setAsCurrentWorkingDirectory(); + if(!hitokay) return; f = box.getResult(); seq.reset(new SeqFile(abi)); startSeqOperation(".com/.aseq import", &SeqFile::importCom, f); @@ -866,7 +881,10 @@ void SeqEditor::buttonClicked (juce::Button* buttonThatWasClicked) if(!checkSeqPresence(true)) return; File savelocation = File::getSpecialLocation(File::userHomeDirectory); //SEQ64::readFolderProperty("comfolder"); FileChooser box("Save .com/.aseq", savelocation, "*.com;*.aseq;*.seq;*.m64;*.bin;*.seq", true); - if(!box.browseForFileToSave(true)) return; + File oldwd = File::getCurrentWorkingDirectory(); + bool hitokay = box.browseForFileToSave(true); + oldwd.setAsCurrentWorkingDirectory(); + if(!hitokay) return; savelocation = box.getResult(); startSeqOperation(".com/.aseq export", &SeqFile::exportCom, savelocation); //[/UserButtonCode_btnExportCom] @@ -957,7 +975,9 @@ void SeqEditor::timerCallback(){ } ValueTree SeqEditor::getABI(){ - ValueTree abi = SeqFile::loadABI(lstABI->get(lstABI->getLastRowSelected())); + int row = lstABI->getLastRowSelected(); + String abistr = lstABI->get(row); + ValueTree abi = SeqFile::loadABI(abistr); if(!abi.isValid()){ NativeMessageBox::showMessageBox(AlertWindow::WarningIcon, "seq64", "Invalid ABI selected!"); diff --git a/Source/SeqFile.cpp b/Source/SeqFile.cpp index ce9cd1e..6509f17 100644 --- a/Source/SeqFile.cpp +++ b/Source/SeqFile.cpp @@ -166,12 +166,12 @@ StringArray SeqFile::getAvailABIs(){ ValueTree SeqFile::loadABI(String name){ File abifile = findFile("abi/" + name + ".xml"); if(!abifile.existsAsFile()){ - std::cout << "Could not find file " + abifile.getFullPathName() + "!"; + std::cout << "Could not find file " + abifile.getFullPathName() + "!\n"; return ValueTree(); } std::unique_ptr xml = parseXML(abifile); if(!xml){ - std::cout << "Error parsing XML of " + abifile.getFullPathName() + "!"; + std::cout << "Error parsing XML of " + abifile.getFullPathName() + "!\n"; return ValueTree(); } return ValueTree::fromXml(*xml); @@ -179,17 +179,17 @@ ValueTree SeqFile::loadABI(String name){ bool SeqFile::saveABI(String name, ValueTree abi_){ File abifile = findFile("abi/" + name + ".xml"); if(!abifile.existsAsFile()){ - std::cout << "Could not find file " + abifile.getFullPathName() + "!"; + std::cout << "Could not find file " + abifile.getFullPathName() + "!\n"; return false; } std::unique_ptr xml = abi_.createXml(); if(!xml){ - std::cout << "Error creating XML for currently loaded ABI!"; + std::cout << "Error creating XML for currently loaded ABI!\n"; return false; } FileOutputStream fos(abifile); if(fos.failedToOpen()){ - std::cout << "Couldn't open file " + abifile.getFullPathName() + " for writing!"; + std::cout << "Couldn't open file " + abifile.getFullPathName() + " for writing!\n"; return false; } fos.setPosition(0); diff --git a/Source/TextListBox.cpp b/Source/TextListBox.cpp index a2d3d45..cf1eb42 100644 --- a/Source/TextListBox.cpp +++ b/Source/TextListBox.cpp @@ -31,7 +31,11 @@ void TextListBox::Listener::rowDoubleClicked(TextListBox* parent, int row) { } TextListBox::TextListBox(Listener *l, String headerCaption) - : ListBox("TextListBox", this), listener(l), font(15.0f), selectonadd(true) { + : ListBoxModel(), // this must be constructed as a model before passing + ListBox("TextListBox", this), // itself to ListBox constructor + listener(l), + font(15.0f), + selectonadd(true) { setMultipleSelectionEnabled(false); setClickingTogglesRowSelection(false); setRowSelectedOnMouseDown(true); diff --git a/Source/TextListBox.hpp b/Source/TextListBox.hpp index 26575f2..de4d271 100644 --- a/Source/TextListBox.hpp +++ b/Source/TextListBox.hpp @@ -27,7 +27,7 @@ #include "Common.hpp" -class TextListBox : public ListBox, ListBoxModel +class TextListBox : public ListBoxModel, public ListBox { public: class Listener{ diff --git a/juce b/juce index cc9fdc3..69795dc 160000 --- a/juce +++ b/juce @@ -1 +1 @@ -Subproject commit cc9fdc3d6a89b86ecd902c1f24258ae8cdcc5639 +Subproject commit 69795dc8e589a9eb5df251b6dd994859bf7b3fab