diff --git a/CMakeIncludes/Juce.cmake b/CMakeIncludes/Juce.cmake new file mode 100644 index 00000000..21cc253e --- /dev/null +++ b/CMakeIncludes/Juce.cmake @@ -0,0 +1,21 @@ +#[[ + + Adding this include will add juce to your project + +]] + +#Adds all the module sources so they appear correctly in the IDE +set_property(GLOBAL PROPERTY USE_FOLDERS YES) +option(JUCE_ENABLE_MODULE_SOURCE_GROUPS "Enable Module Source Groups" ON) + +#set any of these to "ON" if you want to build one of the juce examples +#or extras (Projucer/AudioPluginHost, etc): +option(JUCE_BUILD_EXTRAS "Build JUCE Extras" OFF) +option(JUCE_BUILD_EXAMPLES "Build JUCE Examples" OFF) + +FetchContent_Declare(juce + GIT_REPOSITORY https://github.com/juce-framework/JUCE.git +# GIT_TAG 7.0.9 + GIT_SHALLOW ON) + +FetchContent_MakeAvailable(juce) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7be5ed2..675e5be7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,63 +31,53 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR) -set (FGM_VERSION 1.4.0) +set(FGM_VERSION 1.4.0) -project (foleys_gui_magic +project(foleys_gui_magic DESCRIPTION "PluginGuiMagic" HOMEPAGE_URL "https://foleysfinest.com/PluginGuiMagic" LANGUAGES CXX) -list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMakeIncludes") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMakeIncludes") -include (PGMPluginval) +option(FOLEYS_BUILD_EXAMPLES "Build the examples" ON) +option(FOLEYS_BUILD_TESTS "Build and run the unit tests" ON) +option(FOLEYS_RUN_PLUGINVAL "Run pluginval on the example plugins" ON) -option (FOLEYS_BUILD_EXAMPLES "Build the examples" ON) -option (FOLEYS_BUILD_TESTS "Build and run the unit tests" ON) -option (FOLEYS_RUN_PLUGINVAL "Run pluginval on the example plugins" ON) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_LIST_DIR}/logs") -set_property (GLOBAL PROPERTY USE_FOLDERS ON) -set_property (GLOBAL PROPERTY DEBUG_CONFIGURATIONS Debug) -set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CMAKE_CURRENT_LIST_DIR}/logs") +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) -set (CMAKE_CXX_STANDARD 17) -set (CMAKE_CXX_STANDARD_REQUIRED ON) - -set (CMAKE_CXX_VISIBILITY_PRESET hidden) -set (CMAKE_VISIBILITY_INLINES_HIDDEN ON) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) # universal binaries on Mac -set (CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING +set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Architectures to build on MacOS. Set to arm64\;x86_64 to build universal (fat) binaries, or just one of those for faster build times.") # static linking on Windows -set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - -# JUCE -include (FetchContent) - -FetchContent_Declare ( - juce - GIT_REPOSITORY https://github.com/juce-framework/JUCE.git - GIT_TAG origin/master - GIT_SHALLOW ON) +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -set (JUCE_ENABLE_MODULE_SOURCE_GROUPS ON) -set (JUCE_BUILD_EXTRAS OFF) -set (JUCE_BUILD_EXAMPLES OFF) +include(FetchContent) -FetchContent_MakeAvailable (juce) +# JUCE if needed +if (FOLEYS_BUILD_EXAMPLES OR FOLEYS_BUILD_EXAMPLES) + include(Juce) +endif () -add_subdirectory (modules) +add_subdirectory(modules) -if(FOLEYS_BUILD_TESTS) +if (FOLEYS_BUILD_TESTS) enable_testing() - add_subdirectory (Tests) + add_subdirectory(Tests) - if(foleys_gui_magic_IS_TOP_LEVEL) - include (CTest) - endif() -endif() + if (foleys_gui_magic_IS_TOP_LEVEL) + include(CTest) + endif () +endif () # this must be AFTER the enable_testing() call above! if (FOLEYS_BUILD_EXAMPLES) @@ -96,11 +86,11 @@ endif () # install rules -set (FGM_INSTALL_DEST "${CMAKE_INSTALL_LIBDIR}/cmake/foleys_gui_magic" +set(FGM_INSTALL_DEST "${CMAKE_INSTALL_LIBDIR}/cmake/foleys_gui_magic" CACHE STRING "Directory below INSTALL_PREFIX where the foleys_gui_magic CMake package files will be installed to") -install (DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" +install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" DESTINATION "${FGM_INSTALL_DEST}/.." COMPONENT foleys_gui_magic PATTERN Tests/* EXCLUDE @@ -111,27 +101,27 @@ install (DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" PATTERN CMakeLists.txt EXCLUDE PATTERN "${CMAKE_CURRENT_BINARY_DIR}/" EXCLUDE) -include (CMakePackageConfigHelpers) +include(CMakePackageConfigHelpers) #write_basic_package_version_file (foleys_gui_magic-config-version.cmake # VERSION "${FGM_VERSION}" # COMPATIBILITY SameMajorVersion # ARCH_INDEPENDENT) -configure_package_config_file (CMakeIncludes/config.cmake foleys_gui_magic-config.cmake +configure_package_config_file(CMakeIncludes/config.cmake foleys_gui_magic-config.cmake INSTALL_DESTINATION "${FGM_INSTALL_DEST}" NO_SET_AND_CHECK_MACRO) -install (FILES "${CMAKE_CURRENT_BINARY_DIR}/foleys_gui_magic-config-version.cmake" +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/foleys_gui_magic-config-version.cmake" "${CMAKE_CURRENT_BINARY_DIR}/foleys_gui_magic-config.cmake" DESTINATION "${FGM_INSTALL_DEST}" COMPONENT foleys_gui_magic) -include (CPackComponent) +include(CPackComponent) -cpack_add_component (foleys_gui_magic +cpack_add_component(foleys_gui_magic GROUP Foleys INSTALL_TYPES Developer) -export (PACKAGE foleys_gui_magic) +export(PACKAGE foleys_gui_magic) diff --git a/modules/foleys_gui_magic/General/foleys_MagicJUCEFactories.cpp b/modules/foleys_gui_magic/General/foleys_MagicJUCEFactories.cpp index 4c49f6ce..3228c919 100644 --- a/modules/foleys_gui_magic/General/foleys_MagicJUCEFactories.cpp +++ b/modules/foleys_gui_magic/General/foleys_MagicJUCEFactories.cpp @@ -904,13 +904,13 @@ class ListBoxItem : public GuiItem, ~ListBoxItem() override { - if (auto* m = dynamic_cast(listBox.getModel())) + if (auto* m = dynamic_cast(listBox.getListBoxModel())) m->removeChangeListener (this); } void update() override { - if (auto* m = dynamic_cast(listBox.getModel())) + if (auto* m = dynamic_cast(listBox.getListBoxModel())) m->removeChangeListener (this); auto modelID = configNode.getProperty ("list-box-model", juce::String()).toString(); diff --git a/modules/foleys_gui_magic/State/foleys_RadioButtonManager.cpp b/modules/foleys_gui_magic/State/foleys_RadioButtonManager.cpp index 22b126a6..e037f0fc 100644 --- a/modules/foleys_gui_magic/State/foleys_RadioButtonManager.cpp +++ b/modules/foleys_gui_magic/State/foleys_RadioButtonManager.cpp @@ -36,9 +36,7 @@ namespace foleys { -RadioButtonHandler::RadioButtonHandler (juce::Button& buttonToControl, RadioButtonManager& manager) - : button (buttonToControl), - radioButtonManager (manager) +RadioButtonHandler::RadioButtonHandler (juce::Button& buttonToControl, RadioButtonManager& manager) : button (buttonToControl), radioButtonManager (manager) { radioButtonManager.addButton (&button); button.addListener (this); @@ -71,7 +69,7 @@ void RadioButtonHandler::setRadioGroupValue (juce::var value, juce::RangedAudioP { auto currentValue = parameter->convertFrom0to1 (parameter->getValue()); // other than setToggleState this seems not to trigger circular updates - button.getToggleStateValue() = (currentValue == static_cast(value)); + button.getToggleStateValue() = juce::approximatelyEqual (currentValue, static_cast (value)); } } @@ -97,7 +95,7 @@ void RadioButtonHandler::parameterValueChanged (int parameterIndex, float newVal auto value = parameter->convertFrom0to1 (newValue); // other than setToggleState this seems not to trigger circular updates - button.getToggleStateValue() = (value == static_cast(radioButtonValue)); + button.getToggleStateValue() = juce::approximatelyEqual (value, static_cast (radioButtonValue)); } // ============================================================================== @@ -108,23 +106,21 @@ void RadioButtonManager::buttonActivated (juce::Button* button) if (groupID == 0) return; - for (auto& otherButton : buttons) + for (auto& otherButton: buttons) if (otherButton && button != otherButton && otherButton->getRadioGroupId() == groupID) otherButton->getToggleStateValue() = false; } void RadioButtonManager::addButton (juce::Button* button) { - if (std::find(buttons.begin(), buttons.end(), button) == buttons.end()) - buttons.push_back(button); + if (std::find (buttons.begin(), buttons.end(), button) == buttons.end()) + buttons.push_back (button); } void RadioButtonManager::removeButton (juce::Button* button) { - buttons.erase (std::remove_if (buttons.begin(), buttons.end(), [button](const auto& other) - { return other == button || other == nullptr; }), - buttons.end()); + buttons.erase (std::remove_if (buttons.begin(), buttons.end(), [button] (const auto& other) { return other == button || other == nullptr; }), buttons.end()); } -} // namespace foleys +} // namespace foleys