diff --git a/CMakeLists.txt b/CMakeLists.txt index 6160d8a..e51a453 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,119 +2,75 @@ cmake_minimum_required(VERSION 3.22) project(kAmp VERSION 0.0.1) -# To get started on a new GUI app, copy this entire folder (containing this file and C++ sources) to -# a convenient location, and then start making modifications. For other examples of CMakeLists for -# GUI apps, check `extras/Projucer` and `examples/DemoRunner` in the JUCE repo. - -# If you've installed JUCE somehow (via a package manager, or directly using the CMake install -# target), you'll need to tell this project that it depends on the installed copy of JUCE. If you've -# included JUCE directly in your source tree (perhaps as a submodule), you'll need to tell CMake to -# include that subdirectory as part of the build. - -# find_package(JUCE CONFIG REQUIRED) # If you've installed JUCE to your system -# or -add_subdirectory(JUCE) # If you've put JUCE in a subdirectory called JUCE - -# If your app depends the VST2 SDK, perhaps to host VST2 plugins, CMake needs to be told where -# to find the SDK on your system. This setup should be done before calling `juce_add_gui_app`. - -# juce_set_vst2_sdk_path(...) - -# `juce_add_gui_app` adds an executable target with the name passed as the first argument -# (GuiAppExample here). This target is a normal CMake target, but has a lot of extra properties set -# up by default. This function accepts many optional arguments. Check the readme at -# `docs/CMake API.md` in the JUCE repo for the full list. +# If you've installed JUCE to your system +# find_package(JUCE CONFIG REQUIRED) +# or if JUCE is a subdirectory +add_subdirectory(JUCE) juce_add_gui_app(kAmp - # ICON_BIG ... # ICON_* arguments specify a path to an image file to use as an icon - # ICON_SMALL ... - # DOCUMENT_EXTENSIONS ... # Specify file extensions that should be associated with this app - BUNDLE_ID = "eu.k-147.kAmp" - COMPANY_NAME "K-147" - PRODUCT_NAME "kAmp" - ICON_BIG "resources/images/kamp_logo_with_background.png" - ICON_SMALL "resources/images/kamp_logo_with_background.png") + BUNDLE_ID "eu.k-147.kAmp" + COMPANY_NAME "K-147" + PRODUCT_NAME "kAmp" + ICON_BIG "resources/images/kamp_logo_with_background.png" + ICON_SMALL "resources/images/kamp_logo_with_background.png" +) juce_generate_juce_header(kAmp) -# `target_sources` adds source files to a target. We pass the target that needs the sources as the -# first argument, then a visibility parameter for the sources which should normally be PRIVATE. -# Finally, we supply a list of source files that will be built into the target. This is a standard -# CMake command. - -file( - GLOB_RECURSE - SOURCES - CONFIGURE_DEPENDS - src/*.cpp +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.cpp) + +juce_add_binary_data(ResourcesBinary + SOURCES + resources/images/background.png + resources/images/kamp_logo_with_background.png + resources/icons/account.png + resources/icons/export.png + resources/icons/mute.png + resources/icons/power.png + resources/icons/settings.png + resources/icons/sync.png + resources/icons/unmute.png + resources/icons/xmark.png + resources/icons/tuner.png ) -if(APPLE) - # Sur macOS, copie dans le bundle app (Contents/Resources) - add_custom_command(TARGET kAmp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_SOURCE_DIR}/resources - $/../Resources/resources - ) -else() - # Sur Linux/Windows, copie dans le dossier de build à côté de l'exe - add_custom_command(TARGET kAmp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_SOURCE_DIR}/resources - $/resources - ) -endif() - +target_include_directories(kAmp PRIVATE "${CMAKE_BINARY_DIR}/juce_binarydata_ResourcesBinary/JuceLibraryCode") +file(GLOB_RECURSE RESOURCE_FILES "${CMAKE_SOURCE_DIR}/resources/*.*") +foreach(RESOURCE_FILE IN LISTS RESOURCE_FILES) + file(RELATIVE_PATH REL_PATH "${CMAKE_SOURCE_DIR}/resources" "${RESOURCE_FILE}") + set(DEST_PATH "${CMAKE_BINARY_DIR}/resources/${REL_PATH}") + add_custom_command( + TARGET kAmp POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RESOURCE_FILE}" "${DEST_PATH}" + ) +endforeach() -target_sources(kAmp - PRIVATE - ${SOURCES}) - -target_include_directories(kAmp - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/include) +target_sources(kAmp PRIVATE ${SOURCES}) -# `target_compile_definitions` adds some preprocessor definitions to our target. In a Projucer -# project, these might be passed in the 'Preprocessor Definitions' field. JUCE modules also make use -# of compile definitions to switch certain features on/off, so if there's a particular feature you -# need that's not on by default, check the module header for the correct flag to set here. These -# definitions will be visible both to your code, and also the JUCE module code, so for new -# definitions, pick unique names that are unlikely to collide! This is a standard CMake command. +target_include_directories(kAmp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) target_compile_definitions(kAmp - PRIVATE - # JUCE_WEB_BROWSER and JUCE_USE_CURL would be on by default, but you might not need them. - JUCE_WEB_BROWSER=0 # If you remove this, add `NEEDS_WEB_BROWSER TRUE` to the `juce_add_gui_app` call - JUCE_USE_CURL=0 # If you remove this, add `NEEDS_CURL TRUE` to the `juce_add_gui_app` call - # JUCE_IOS=1 + PRIVATE + JUCE_WEB_BROWSER=0 + JUCE_USE_CURL=0 + #JUCE_IOS=1 JUCE_APPLICATION_NAME_STRING="$" - JUCE_APPLICATION_VERSION_STRING="$") - -# If your target needs extra binary assets, you can add them here. The first argument is the name of -# a new static library target that will include all the binary resources. There is an optional -# `NAMESPACE` argument that can specify the namespace of the generated binary data class. Finally, -# the SOURCES argument should be followed by a list of source files that should be built into the -# static library. These source files can be of any kind (wav data, images, fonts, icons etc.). -# Conversion to binary-data will happen when your target is built. - -# juce_add_binary_data(GuiAppData SOURCES ...) - -# `target_link_libraries` links libraries and JUCE modules to other libraries or executables. Here, -# we're linking our executable target to the `juce::juce_gui_extra` module. Inter-module -# dependencies are resolved automatically, so `juce_core`, `juce_events` and so on will also be -# linked automatically. If we'd generated a binary data target above, we would need to link to it -# here too. This is a standard CMake command. + JUCE_APPLICATION_VERSION_STRING="$" +) target_link_libraries(kAmp - PRIVATE - # GuiAppData # If we'd created a binary data target, we'd link to it here + PRIVATE juce::juce_audio_basics juce::juce_audio_utils juce::juce_gui_extra juce::juce_dsp - PUBLIC + ResourcesBinary + PUBLIC juce::juce_recommended_config_flags juce::juce_recommended_lto_flags - juce::juce_recommended_warning_flags) + juce::juce_recommended_warning_flags +) + + diff --git a/JUCE b/JUCE index d6181bd..51a8a6d 160000 --- a/JUCE +++ b/JUCE @@ -1 +1 @@ -Subproject commit d6181bde38d858c283c3b7bf699ce6340c050b5d +Subproject commit 51a8a6d7aeae7326956d747737ccf1575e61e209 diff --git a/include/MainComponent.h b/include/MainComponent.h index 3142f86..d960151 100644 --- a/include/MainComponent.h +++ b/include/MainComponent.h @@ -57,6 +57,7 @@ class MainComponent final : public AudioAppComponent { private: + ImageComponent backgroundImage; /** diff --git a/src/MainComponent.cpp b/src/MainComponent.cpp index 3643602..681e32e 100644 --- a/src/MainComponent.cpp +++ b/src/MainComponent.cpp @@ -6,18 +6,14 @@ MainComponent::MainComponent(const Manager& manager): topMenuBarComponent(this->deviceManager, &isSoundMuted, &tuningFunction), manager(manager) { setAudioChannels(2, 2); - const Image background = ResourceManager::loadImage("resources/images/background.png"); - if (background.isValid()) { - backgroundImage.setImage(background); - backgroundImage.setImagePlacement(RectanglePlacement::stretchToFit); - addAndMakeVisible(backgroundImage); - } else { - DBG("Error : resources/images/background.png not found."); - } + + juce::Image img = juce::ImageFileFormat::loadFrom(BinaryData::background_png, BinaryData::background_pngSize); + backgroundImage.setImage(img); pedalboardContainer.setViewedComponent(&pedalboardComponent, true); pedalboardContainer.setScrollBarsShown(true, false); + addAndMakeVisible(backgroundImage); addAndMakeVisible(pedalboardContainer); addAndMakeVisible(topMenuBarComponent); addAndMakeVisible(bottomMenuBarComponent); @@ -69,3 +65,5 @@ void MainComponent::getNextAudioBlock(const AudioSourceChannelInfo &bufferToFill } void MainComponent::releaseResources() {} + + diff --git a/src/components/TopMenuBarComponent.cpp b/src/components/TopMenuBarComponent.cpp index 81326b5..7ff3703 100644 --- a/src/components/TopMenuBarComponent.cpp +++ b/src/components/TopMenuBarComponent.cpp @@ -4,49 +4,38 @@ #include "ResourceManager.h" #include "SettingsComponent.h" #include "TopMenuBarComponent.h" - -TopMenuBarComponent::TopMenuBarComponent(AudioDeviceManager& deviceManager, bool* isSoundMuted, std::function* tuningFunction) { - this->isSoundMuted = isSoundMuted; - this->tuningFunction = tuningFunction; - Image settingsImage = ResourceManager::loadImage("resources/icons/settings.png"); - if (settingsImage.isValid()) { - settingsButton.setImages(true, true, true, settingsImage, 1.0f, {}, settingsImage, 1.0f, {},settingsImage, 1.0f, {}); - settingsButton.setSize(settingsImage.getWidth(), settingsImage.getHeight()); - addAndMakeVisible(settingsButton); - } else { - DBG("Erreur : image settings.png introuvable ou invalide."); - } - - Image accountImage = ResourceManager::loadImage( - "resources/icons/account.png"); - if (accountImage.isValid()) { - accountButton.setImages(true, true, true, accountImage, 1.0f, {}, - accountImage, 1.0f, {}, accountImage, 1.0f, {}); - accountButton.setSize(accountImage.getWidth(), - accountImage.getHeight()); - addAndMakeVisible(accountButton); - } else { - DBG("Erreur : image account.png introuvable ou invalide."); - } - - Image muteImage = ResourceManager::loadImage("resources/icons/unmute.png"); - if (muteImage.isValid()) { - muteButton.setImages(true, true, true, muteImage, 1.0f, {}, muteImage, - 1.0f, {}, muteImage, 1.0f, {}); - muteButton.setSize(muteImage.getWidth(), muteImage.getHeight()); - addAndMakeVisible(muteButton); - } else { - DBG("Erreur : image mute.png introuvable ou invalide."); - } - - Image tunerImage = ResourceManager::loadImage("resources/icons/tuner.png"); - if (tunerImage.isValid()) { - tunerButton.setImages(true, true, true, tunerImage, 1.0f, {}, tunerImage, 1.0f, {}, tunerImage, 1.0f, {}); - tunerButton.setSize(tunerImage.getWidth(), tunerImage.getHeight()); - addAndMakeVisible(tunerButton); - } else { - DBG("Erreur : image tuner.png introuvable ou invalide."); - } +#include "ResourceManager.h" +#include "BinaryData.h" + +TopMenuBarComponent::TopMenuBarComponent(AudioDeviceManager& deviceManager, + bool* isMuted, std::function* tuningFunction) { + this->isSoundMuted = isMuted; + this->tuningFunction = tuningFunction; + + juce::Image settingsImage = juce::ImageFileFormat::loadFrom(BinaryData::settings_png, BinaryData::settings_pngSize); + settingsButton.setImages(true, true, true, settingsImage, 1.0f, {}, + settingsImage, 1.0f, {}, settingsImage, 1.0f, + {}); + addAndMakeVisible(settingsButton); + + + juce::Image accountImage = juce::ImageFileFormat::loadFrom(BinaryData::account_png, BinaryData::account_pngSize); + accountButton.setImages(true, true, true, accountImage, 1.0f, {}, + accountImage, 1.0f, {}, accountImage, 1.0f, + {}); + addAndMakeVisible(accountButton); + + juce::Image muteImage = juce::ImageFileFormat::loadFrom(BinaryData::mute_png, BinaryData::mute_pngSize); + muteButton.setImages(true, true, true, muteImage, 1.0f, {}, + muteImage, 1.0f, {}, muteImage, 1.0f, + {}); + addAndMakeVisible(muteButton); + + + juce::Image tunerImage = juce::ImageFileFormat::loadFrom(BinaryData::tuner_png, BinaryData::tuner_pngSize); + tunerButton.setImages(true, true, true, tunerImage, 1.0f, {}, tunerImage, 1.0f, {}, tunerImage, 1.0f, {}); + tunerButton.setSize(tunerImage.getWidth(), tunerImage.getHeight()); + addAndMakeVisible(tunerButton); #if !JUCE_IOS settingsButton.onClick = [this, &deviceManager] { @@ -90,6 +79,7 @@ void TopMenuBarComponent::paint(Graphics& g) { g.drawText("kAmp", gap, topMargin, 80, 24, Justification::left); } + void TopMenuBarComponent::resized() { auto* mainWindow = getTopLevelComponent(); if (mainWindow == nullptr) return; @@ -139,25 +129,17 @@ void TopMenuBarComponent::openAccountPopup() { void TopMenuBarComponent::toggleMute() { if (*this->isSoundMuted) { - Image muteImage = ResourceManager::loadImage( - "resources/icons/unmute.png"); - if (muteImage.isValid()) { - muteButton.setImages(false, true, true, muteImage, 1.0f, {}, - muteImage, 1.0f, {}, muteImage, 1.0f, {}); - addAndMakeVisible(muteButton); - } else { - DBG("Erreur : image mute.png introuvable ou invalide."); - } + juce::Image muteImage = juce::ImageFileFormat::loadFrom(BinaryData::unmute_png, BinaryData::unmute_pngSize); + muteButton.setImages(false, true, true, muteImage, 1.0f, {}, + muteImage, 1.0f, {}, muteImage, 1.0f, + {}); + addAndMakeVisible(muteButton); } else { - Image muteImage = - ResourceManager::loadImage("resources/icons/mute.png"); - if (muteImage.isValid()) { - muteButton.setImages(false, true, true, muteImage, 1.0f, {}, - muteImage, 1.0f, {}, muteImage, 1.0f, {}); - addAndMakeVisible(muteButton); - } else { - DBG("Erreur : image mute.png introuvable ou invalide."); - } + juce::Image muteImage = juce::ImageFileFormat::loadFrom(BinaryData::mute_png, BinaryData::mute_pngSize); + muteButton.setImages(false, true, true, muteImage, 1.0f, {}, + muteImage, 1.0f, {}, muteImage, 1.0f, + {}); + addAndMakeVisible(muteButton); } *this->isSoundMuted = !*this->isSoundMuted; } diff --git a/src/components/effects/BasePedalComponent.cpp b/src/components/effects/BasePedalComponent.cpp index 3c071c4..fb639cb 100644 --- a/src/components/effects/BasePedalComponent.cpp +++ b/src/components/effects/BasePedalComponent.cpp @@ -34,19 +34,14 @@ void BasePedalComponent::initializePedal() { pedalLabel->setJustificationType(Justification::centred); pedalLabel->setFont(FontOptions(30.0f, Font::bold)); - Image powerImage = ResourceManager::loadImage("resources/icons/power.png"); - if (powerImage.isValid()) { - enablePedalButton.setImages(true, true, true, - powerImage, 1.0f, {}, - powerImage, 1.0f, {}, - powerImage, 1.0f, {}); - enablePedalButton.onClick = [this] { - this->onEnableButtonClicked(); - }; - addAndMakeVisible(enablePedalButton); - } else { - DBG("Erreur : image power.png introuvable ou invalide."); - } + juce::Image powerImage = juce::ImageFileFormat::loadFrom(BinaryData::power_png, BinaryData::power_pngSize); + enablePedalButton.setImages(true, true, true, powerImage, 1.0f, {}, + powerImage, 1.0f, {}, powerImage, 1.0f, + {}); + enablePedalButton.onClick = [this] { + this->onEnableButtonClicked(); + }; + addAndMakeVisible(enablePedalButton); addAndMakeVisible(*pedalLabel); addAndMakeVisible(*isEnabledIndicator); diff --git a/src/utils/ModalOverlayComponent.cpp b/src/utils/ModalOverlayComponent.cpp new file mode 100644 index 0000000..e69de29