diff --git a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp index 6bfb7db16e..5948b27434 100644 --- a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp +++ b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.cpp @@ -12,13 +12,7 @@ #include "jucer_GlobalPreferences.h" -//============================================================================== -const String PathSettingsTab::vst2KeyName = "vst2Path"; -const String PathSettingsTab::vst3KeyName = "vst3Path"; -const String PathSettingsTab::rtasKeyName = "rtasPath"; -const String PathSettingsTab::aaxKeyName = "aaxPath"; -const String PathSettingsTab::androidSdkKeyName = "androidSdkPath"; -const String PathSettingsTab::androidNdkKeyName = "androidNdkPath"; + //============================================================================== class AppearanceSettingsTab : public GlobalPreferencesTab, @@ -47,16 +41,16 @@ PathSettingsTab::PathSettingsTab (DependencyPathOS os) { const int maxChars = 1024; - vst2PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (vst2KeyName, os), "VST SDK", maxChars, false)); - vst3PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (vst3KeyName, os), "VST3 SDK", maxChars, false)); + vst2PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::vst2KeyName, os), "VST SDK", maxChars, false)); + vst3PathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::vst3KeyName, os), "VST3 SDK", maxChars, false)); #if ! JUCE_LINUX - rtasPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (rtasKeyName, os), "RTAS SDK", maxChars, false)); - aaxPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (aaxKeyName, os), "AAX SDK", maxChars, false)); + rtasPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::rtasKeyName, os), "RTAS SDK", maxChars, false)); + aaxPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::aaxKeyName, os), "AAX SDK", maxChars, false)); #endif - androidSdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (androidSdkKeyName, os), "Android SDK", maxChars, false)); - androidNdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (androidNdkKeyName, os), "Android NDK", maxChars, false)); + androidSdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::androidSdkKeyName, os), "Android SDK", maxChars, false)); + androidNdkPathComponent = pathComponents.add (new TextPropertyComponent (getPathByKey (DependencyPath::androidNdkKeyName, os), "Android NDK", maxChars, false)); for (TextPropertyComponent** component = pathComponents.begin(); component != pathComponents.end(); ++component) { @@ -80,12 +74,12 @@ void PathSettingsTab::textPropertyComponentChanged (TextPropertyComponent* textP String PathSettingsTab::getKeyForPropertyComponent (TextPropertyComponent* component) const { - if (component == vst2PathComponent) return vst2KeyName; - if (component == vst3PathComponent) return vst3KeyName; - if (component == rtasPathComponent) return rtasKeyName; - if (component == aaxPathComponent) return aaxKeyName; - if (component == androidSdkPathComponent) return androidSdkKeyName; - if (component == androidNdkPathComponent) return androidNdkKeyName; + if (component == vst2PathComponent) return DependencyPath::vst2KeyName; + if (component == vst3PathComponent) return DependencyPath::vst3KeyName; + if (component == rtasPathComponent) return DependencyPath::rtasKeyName; + if (component == aaxPathComponent) return DependencyPath::aaxKeyName; + if (component == androidSdkPathComponent) return DependencyPath::androidSdkKeyName; + if (component == androidNdkPathComponent) return DependencyPath::androidNdkKeyName; // this property component does not have a key associated to it! jassertfalse; @@ -128,11 +122,11 @@ Value& PathSettingsTab::getPathByKey (const String& key, DependencyPathOS os) //============================================================================== String PathSettingsTab::getFallbackPathByKey (const String& key, DependencyPathOS os) { - if (key == vst2KeyName || key == vst3KeyName) + if (key == DependencyPath::vst2KeyName || key == DependencyPath::vst3KeyName) return os == DependencyPath::windows ? "c:\\SDKs\\VST3 SDK" : "~/SDKs/VST3 SDK"; - if (key == rtasKeyName) + if (key == DependencyPath::rtasKeyName) { if (os == DependencyPath::windows) return "c:\\SDKs\\PT_80_SDK"; if (os == DependencyPath::osx) return "~/SDKs/PT_80_SDK"; @@ -142,7 +136,7 @@ String PathSettingsTab::getFallbackPathByKey (const String& key, DependencyPathO return String(); } - if (key == aaxKeyName) + if (key == DependencyPath::aaxKeyName) { if (os == DependencyPath::windows) return "c:\\SDKs\\AAX"; if (os == DependencyPath::osx) return "~/SDKs/AAX" ; @@ -152,11 +146,11 @@ String PathSettingsTab::getFallbackPathByKey (const String& key, DependencyPathO return String(); } - if (key == androidSdkKeyName) + if (key == DependencyPath::androidSdkKeyName) return os == DependencyPath::windows ? "c:\\SDKs\\android-sdk" : "~/Library/Android/sdk"; - if (key == androidNdkKeyName) + if (key == DependencyPath::androidNdkKeyName) return os == DependencyPath::windows ? "c:\\SDKs\\android-ndk" : "~/Library/Android/ndk"; @@ -170,23 +164,23 @@ bool PathSettingsTab::checkPathByKey (const String& key, const String& path) { String fileToCheckFor; - if (key == vst2KeyName) + if (key == DependencyPath::vst2KeyName) { fileToCheckFor = "public.sdk/source/vst2.x/audioeffectx.h"; } - else if (key == vst3KeyName) + else if (key == DependencyPath::vst3KeyName) { fileToCheckFor = "base/source/baseiids.cpp"; } - else if (key == rtasKeyName) + else if (key == DependencyPath::rtasKeyName) { fileToCheckFor = "AlturaPorts/TDMPlugIns/PlugInLibrary/EffectClasses/CEffectProcessMIDI.cpp"; } - else if (key == aaxKeyName) + else if (key == DependencyPath::aaxKeyName) { fileToCheckFor = "Interfaces/AAX_Exports.cpp"; } - else if (key == androidSdkKeyName) + else if (key == DependencyPath::androidSdkKeyName) { #if JUCE_WINDOWS fileToCheckFor = "platform-tools/adb.exe"; @@ -194,7 +188,7 @@ bool PathSettingsTab::checkPathByKey (const String& key, const String& path) fileToCheckFor = "platform-tools/adb"; #endif } - else if (key == androidNdkKeyName) + else if (key == DependencyPath::androidNdkKeyName) { #if JUCE_WINDOWS fileToCheckFor = "ndk-depends.exe"; diff --git a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h index d5a3a8330c..9e9f66714f 100644 --- a/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h +++ b/extras/Introjucer/Source/Application/jucer_GlobalPreferences.h @@ -47,9 +47,6 @@ public: static String getFallbackPathByKey (const String& key, DependencyPathOS); static bool checkPathByKey (const String& key, const String& path); - const static String vst2KeyName, vst3KeyName, rtasKeyName, aaxKeyName, - androidSdkKeyName, androidNdkKeyName; - private: void textPropertyComponentChanged (TextPropertyComponent*) override; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h index bc199430e6..b84dbbc2f1 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Android.h @@ -38,7 +38,8 @@ public: } //============================================================================== - AndroidProjectExporter (Project& p, const ValueTree& t) : ProjectExporter (p, t) + AndroidProjectExporter (Project& p, const ValueTree& t) + : ProjectExporter (p, t) { name = getNameAndroid(); @@ -62,6 +63,8 @@ public: if (getKeyAliasValue().getValue().isVoid()) getKeyAliasValue() = "androiddebugkey"; if (getKeyAliasPassValue().getValue().isVoid()) getKeyAliasPassValue() = "android"; if (getCPP11EnabledValue().getValue().isVoid()) getCPP11EnabledValue() = true; + + initialiseDependencyPathValues(); } //============================================================================== @@ -83,10 +86,10 @@ public: props.add (new TextPropertyComponent (getVersionCodeValue(), "Android Version Code", 32, false), "An integer value that represents the version of the application code, relative to other versions."); - props.add (new DependencyPathPropertyComponent (getSDKPathValue(), "Android SDK Path", PathSettingsTab::androidSdkKeyName), + props.add (new DependencyPathPropertyComponent (getSDKPathValue(), "Android SDK Path"), "The path to the Android SDK folder on the target build machine"); - props.add (new DependencyPathPropertyComponent (getNDKPathValue(), "Android NDK Path", PathSettingsTab::androidNdkKeyName), + props.add (new DependencyPathPropertyComponent (getNDKPathValue(), "Android NDK Path"), "The path to the Android NDK folder on the target build machine"); props.add (new TextPropertyComponent (getMinimumSDKVersionValue(), "Minimum SDK version", 32, false), @@ -132,10 +135,10 @@ public: String getActivitySubClassPath() const { return settings [Ids::androidActivitySubClassName]; } Value getVersionCodeValue() { return getSetting (Ids::androidVersionCode); } String getVersionCodeString() const { return settings [Ids::androidVersionCode]; } - Value getSDKPathValue() { return getSetting (Ids::androidSDKPath); } - String getSDKPathString() const { return settings [Ids::androidSDKPath]; } - Value getNDKPathValue() { return getSetting (Ids::androidNDKPath); } - String getNDKPathString() const { return settings [Ids::androidNDKPath]; } + Value getSDKPathValue() { return sdkPath; } + String getSDKPathString() const { return sdkPath.toString(); } + Value getNDKPathValue() { return ndkPath; } + String getNDKPathString() const { return ndkPath.toString(); } Value getNDKToolchainVersionValue() { return getSetting (Ids::toolset); } String getNDKToolchainVersionString() const { return settings [Ids::toolset]; } @@ -748,6 +751,23 @@ private: writeXmlOrThrow (strings, file, "utf-8", 100); } + void initialiseDependencyPathValues() + { + sdkPath = Value (new DependencyPathValueSource ( + getSetting (Ids::androidSDKPath), + DependencyPath::androidSdkKeyName, + DependencyPath::getThisOS() + )); + + ndkPath = Value (new DependencyPathValueSource ( + getSetting (Ids::androidNDKPath), + DependencyPath::androidNdkKeyName, + DependencyPath::getThisOS() + )); + } + //============================================================================== + Value sdkPath, ndkPath; + JUCE_DECLARE_NON_COPYABLE (AndroidProjectExporter) }; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h index aee48437aa..615246be17 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_CodeBlocks.h @@ -89,6 +89,8 @@ public: if (getTargetLocationString().isEmpty()) getTargetLocationValue() = getDefaultBuildsRootFolder() + getTargetFolderName (os); + + initialiseDependencyPathValues(); } //============================================================================== @@ -401,6 +403,38 @@ private: xml.createNewChildElement ("Add")->setAttribute (nm, value); } + void initialiseDependencyPathValues() + { + DependencyPathOS pathOS = isLinux() ? DependencyPathOS::linux : DependencyPathOS::windows; + + vst2Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vstFolder), + DependencyPath::vst2KeyName, + pathOS + )); + + vst3Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vst3Folder), + DependencyPath::vst3KeyName, + pathOS + )); + + if (! isLinux()) + { + aaxPath = Value (new DependencyPathValueSource ( + getSetting (Ids::aaxFolder), + DependencyPath::aaxKeyName, + pathOS + )); + + rtasPath = Value (new DependencyPathValueSource ( + getSetting (Ids::rtasFolder), + DependencyPath::rtasKeyName, + pathOS + )); + } + } + CodeBlocksOS os; JUCE_DECLARE_NON_COPYABLE (CodeBlocksProjectExporter) diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h index 857b94cb35..84701428e5 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_MSVC.h @@ -33,6 +33,8 @@ public: projectGUID = createGUID (project.getProjectUID()); updateOldSettings(); + + initialiseDependencyPathValues(); } //============================================================================== @@ -555,6 +557,33 @@ protected: : (".\\" + filename); } + void initialiseDependencyPathValues() + { + vst2Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vstFolder), + DependencyPath::vst2KeyName, + DependencyPathOS::windows + )); + + vst3Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vst3Folder), + DependencyPath::vst3KeyName, + DependencyPathOS::windows + )); + + aaxPath = Value (new DependencyPathValueSource ( + getSetting (Ids::aaxFolder), + DependencyPath::aaxKeyName, + DependencyPathOS::windows + )); + + rtasPath = Value (new DependencyPathValueSource ( + getSetting (Ids::rtasFolder), + DependencyPath::rtasKeyName, + DependencyPathOS::windows + )); + } + JUCE_DECLARE_NON_COPYABLE (MSVCProjectExporterBase) }; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h index 7f01e77088..80cb78068b 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_Make.h @@ -45,6 +45,8 @@ public: if (getTargetLocationString().isEmpty()) getTargetLocationValue() = getDefaultBuildsRootFolder() + "LinuxMakefile"; + + initialiseDependencyPathValues(); } //============================================================================== @@ -346,5 +348,20 @@ private: + "_" + String::toHexString (file.toUnixStyle().hashCode()) + ".o"; } + void initialiseDependencyPathValues() + { + vst2Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vstFolder), + DependencyPath::vst2KeyName, + DependencyPathOS::linux + )); + + vst3Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vst3Folder), + DependencyPath::vst3KeyName, + DependencyPathOS::linux + )); + } + JUCE_DECLARE_NON_COPYABLE (MakefileProjectExporter) }; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h index 95b4de0900..a0d69fa050 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExport_XCode.h @@ -53,6 +53,8 @@ public: if (getTargetLocationString().isEmpty()) getTargetLocationValue() = getDefaultBuildsRootFolder() + (iOS ? "iOS" : "MacOSX"); + + initialiseDependencyPathValues(); } static XCodeProjectExporter* createForSettings (Project& project, const ValueTree& settings) @@ -1499,4 +1501,31 @@ private: jassert (version >= 4); return "10." + String (version) + " SDK"; } + + void initialiseDependencyPathValues() + { + vst2Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vstFolder), + DependencyPath::vst2KeyName, + DependencyPathOS::osx + )); + + vst3Path = Value (new DependencyPathValueSource ( + getSetting (Ids::vst3Folder), + DependencyPath::vst3KeyName, + DependencyPathOS::osx + )); + + aaxPath = Value (new DependencyPathValueSource ( + getSetting (Ids::aaxFolder), + DependencyPath::aaxKeyName, + DependencyPathOS::osx + )); + + rtasPath = Value (new DependencyPathValueSource ( + getSetting (Ids::rtasFolder), + DependencyPath::rtasKeyName, + DependencyPathOS::osx + )); + } }; diff --git a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h index 96ddd244a2..56e66d3aef 100644 --- a/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h +++ b/extras/Introjucer/Source/Project Saving/jucer_ProjectExporter.h @@ -114,6 +114,10 @@ public: Value getUserNotes() { return getSetting (Ids::userNotes); } + Value getVSTPathValue (bool isVST3) const { return isVST3 ? vst3Path : vst2Path; } + Value getRTASPathValue() const { return rtasPath; } + Value getAAXPathValue() const { return aaxPath; } + // NB: this is the path to the parent "modules" folder that contains the named module, not the // module folder itself. Value getPathForModuleValue (const String& moduleID); @@ -329,6 +333,7 @@ protected: const ProjectType& projectType; const String projectName; const File projectFolder; + Value vst2Path, vst3Path, rtasPath, aaxPath; // these must be initialised in the specific exporter c'tors! mutable Array itemGroups; void initItemGroups() const; diff --git a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h index 66a3b9eca5..ee342b99dd 100644 --- a/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h +++ b/extras/Introjucer/Source/Project/jucer_AudioPluginModule.h @@ -223,31 +223,14 @@ namespace exporter.rebaseFromProjectFolderToBuildTarget (path) .toWindowsStyle()); } - - DependencyPathOS getDependencyPathOS (const ProjectExporter& exporter) - { - if (exporter.isWindows()) return DependencyPath::windows; - if (exporter.isXcode()) return DependencyPath::osx; - if (exporter.isLinux()) return DependencyPath::linux; - - // cannot figure out which OS's dependency paths this exporter wants!! - jassertfalse; - return DependencyPath::unknown; - } } //============================================================================== namespace VSTHelpers { - static Value getVSTFolder (ProjectExporter& exporter, bool isVST3) - { - return exporter.getSetting (isVST3 ? Ids::vst3Folder - : Ids::vstFolder); - } - static void addVSTFolderToPath (ProjectExporter& exporter, bool isVST3) { - const String vstFolder (getVSTFolder (exporter, isVST3).toString()); + const String vstFolder (exporter.getVSTPathValue (isVST3).toString()); if (vstFolder.isNotEmpty()) { @@ -264,10 +247,8 @@ namespace VSTHelpers { const String vstFormat (isVST3 ? "VST3" : "VST"); - props.add (new DependencyPathPropertyComponent (getVSTFolder (exporter, isVST3), - vstFormat + " Folder", - isVST3 ? PathSettingsTab::vst3KeyName : PathSettingsTab::vst2KeyName, - getDependencyPathOS (exporter)), + props.add (new DependencyPathPropertyComponent (exporter.getVSTPathValue (isVST3), + vstFormat + " Folder"), "If you're building a " + vstFormat + ", this must be the folder containing the " + vstFormat + " SDK. This should be an absolute path."); } @@ -326,15 +307,19 @@ namespace VSTHelpers //============================================================================== namespace RTASHelpers { - static Value getRTASFolder (ProjectExporter& exporter) { return exporter.getSetting (Ids::rtasFolder); } - static RelativePath getRTASFolderPath (ProjectExporter& exporter) { return RelativePath (exporter.getSettingString (Ids::rtasFolder), - RelativePath::projectFolder); } + static RelativePath getRTASRelativeFolderPath (ProjectExporter& exporter) + { + return RelativePath (exporter.getRTASPathValue().toString(), RelativePath::projectFolder); + } - static bool isExporterSupported (ProjectExporter& exporter) { return exporter.isVisualStudio() || exporter.isXcode(); } + static bool isExporterSupported (ProjectExporter& exporter) + { + return exporter.isVisualStudio() || exporter.isXcode(); + } static void addExtraSearchPaths (ProjectExporter& exporter) { - RelativePath rtasFolder (getRTASFolderPath (exporter)); + RelativePath rtasFolder (getRTASRelativeFolderPath (exporter)); if (exporter.isVisualStudio()) { @@ -419,7 +404,7 @@ namespace RTASHelpers { fixMissingXcodePostBuildScript (exporter); - const RelativePath rtasFolder (getRTASFolderPath (exporter)); + const RelativePath rtasFolder (getRTASRelativeFolderPath (exporter)); if (exporter.isVisualStudio()) { @@ -474,10 +459,8 @@ namespace RTASHelpers { fixMissingXcodePostBuildScript (exporter); - props.add (new DependencyPathPropertyComponent (getRTASFolder (exporter), - "RTAS Folder", - PathSettingsTab::rtasKeyName, - getDependencyPathOS (exporter)), + props.add (new DependencyPathPropertyComponent (exporter.getRTASPathValue(), + "RTAS Folder"), "If you're building an RTAS, this must be the folder containing the RTAS SDK. This should be an absolute path."); } } @@ -611,15 +594,19 @@ namespace AUHelpers //============================================================================== namespace AAXHelpers { - static Value getAAXFolder (ProjectExporter& exporter) { return exporter.getSetting (Ids::aaxFolder); } - static RelativePath getAAXFolderPath (ProjectExporter& exporter) { return RelativePath (exporter.getSettingString (Ids::aaxFolder), - RelativePath::projectFolder); } + static RelativePath getAAXRelativeFolderPath (ProjectExporter& exporter) + { + return RelativePath (exporter.getAAXPathValue().toString(), RelativePath::projectFolder); + } - static bool isExporterSupported (ProjectExporter& exporter) { return exporter.isVisualStudio() || exporter.isXcode(); } + static bool isExporterSupported (ProjectExporter& exporter) + { + return exporter.isVisualStudio() || exporter.isXcode(); + } static void addExtraSearchPaths (ProjectExporter& exporter) { - const RelativePath aaxFolder (getAAXFolderPath (exporter)); + const RelativePath aaxFolder (getAAXRelativeFolderPath (exporter)); exporter.addToExtraSearchPaths (aaxFolder); exporter.addToExtraSearchPaths (aaxFolder.getChildFile ("Interfaces")); @@ -632,7 +619,7 @@ namespace AAXHelpers { fixMissingXcodePostBuildScript (exporter); - const RelativePath aaxLibsFolder (getAAXFolderPath (exporter).getChildFile ("Libs")); + const RelativePath aaxLibsFolder (getAAXRelativeFolderPath (exporter).getChildFile ("Libs")); if (exporter.isVisualStudio()) { @@ -661,10 +648,8 @@ namespace AAXHelpers { fixMissingXcodePostBuildScript (exporter); - props.add (new DependencyPathPropertyComponent (getAAXFolder (exporter), - "AAX SDK Folder", - PathSettingsTab::aaxKeyName, - getDependencyPathOS (exporter)), + props.add (new DependencyPathPropertyComponent (exporter.getAAXPathValue(), + "AAX SDK Folder"), "If you're building an AAX, this must be the folder containing the AAX SDK. This should be an absolute path."); } } diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp index 757affefb2..4c7504b784 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.cpp @@ -12,24 +12,52 @@ #include "jucer_DependencyPathPropertyComponent.h" #include "../Application/jucer_GlobalPreferences.h" +//============================================================================== +const String DependencyPath::vst2KeyName = "vst2Path"; +const String DependencyPath::vst3KeyName = "vst3Path"; +const String DependencyPath::rtasKeyName = "rtasPath"; +const String DependencyPath::aaxKeyName = "aaxPath"; +const String DependencyPath::androidSdkKeyName = "androidSdkPath"; +const String DependencyPath::androidNdkKeyName = "androidNdkPath"; + +//============================================================================== + +DependencyPathValueSource::DependencyPathValueSource (const Value& projectSettingsPath, + String globalSettingsKey, + DependencyPathOS osThisSettingAppliesTo) + : projectSettingsValue (projectSettingsPath), + globalKey (globalSettingsKey), + os (osThisSettingAppliesTo), + globalSettingsValue (PathSettingsTab::getPathByKey (globalKey, os)), + fallbackValue (PathSettingsTab::getFallbackPathByKey (globalKey, os)) +{ + globalSettingsValue.addListener (this); +} + +bool DependencyPathValueSource::isValidPath() const +{ + // if we are on another OS than the one which this path setting is for, + // we have no way of knowing whether the path is valid - so just assume it is: + if (! appliesToThisOS()) + return true; + + return PathSettingsTab::checkPathByKey (globalKey, getValue().toString()); +} //============================================================================== DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& value, - const String& propertyName, - const String& globalKeyName, - DependencyPathOS os) - : TextPropertyComponent (propertyName, 1024, false), - globalKey (globalKeyName), - pathValueSource (new DependencyPathValueSource (value, - PathSettingsTab::getPathByKey (globalKeyName, os), - PathSettingsTab::getFallbackPathByKey (globalKeyName, os), - os)), - pathValue (pathValueSource) + const String& propertyName) +try : TextPropertyComponent (propertyName, 1024, false), + pathValue (value), + pathValueSource (dynamic_cast (pathValue.getValueSource())) { - bool initialValueIsEmpty = value.toString().isEmpty(); + bool initialValueIsEmpty = ! pathValueSource.isUsingProjectSettings(); getValue().referTo (pathValue); + // the following step is necessary because the above referTo() has internally called setValue(), + // which has set the project value to whatever is displayed in the label (this may be the + // global/fallback value). In this case we have to reset the project value to blank: if (initialValueIsEmpty) getValue().setValue (String::empty); @@ -41,12 +69,19 @@ DependencyPathPropertyComponent::DependencyPathPropertyComponent (const Value& v else jassertfalse; } +catch (const std::bad_cast&) +{ + // a DependencyPathPropertyComponent must be initialised with a Value + // that is referring to a DependencyPathValueSource! + jassertfalse; + throw; +} void DependencyPathPropertyComponent::valueChanged (Value& value) { // this callback handles the update of this setting in case // the user changed the global preferences. - if (value.refersToSameSourceAs (pathValue) && pathValueSource->isUsingGlobalSettings()) + if (value.refersToSameSourceAs (pathValue) && pathValueSource.isUsingGlobalSettings()) textWasEdited(); } @@ -58,22 +93,12 @@ void DependencyPathPropertyComponent::textWasEdited() Colour DependencyPathPropertyComponent::getTextColourToDisplay() const { - if (! pathValueSource->isUsingProjectSettings()) - return isValidPath() ? Colours::grey - : Colours::lightpink; + if (! pathValueSource.isUsingProjectSettings()) + return pathValueSource.isValidPath() ? Colours::grey + : Colours::lightpink; - return isValidPath() ? Colours::black - : Colours::red; -} - -bool DependencyPathPropertyComponent::isValidPath() const -{ - // if we are on another OS than the one which this path setting is for, - // we have no way of knowing whether the path is valid - so just assume it is: - if (! pathValueSource->appliesToThisOS()) - return true; - - return PathSettingsTab::checkPathByKey (globalKey, getValue().toString()); + return pathValueSource.isValidPath() ? Colours::black + : Colours::red; } void DependencyPathPropertyComponent::labelTextChanged (Label*) @@ -82,7 +107,7 @@ void DependencyPathPropertyComponent::labelTextChanged (Label*) void DependencyPathPropertyComponent::editorShown (Label* /*label*/, TextEditor& editor) { - if (! pathValueSource->isUsingProjectSettings()) + if (! pathValueSource.isUsingProjectSettings()) editor.setText (String::empty, dontSendNotification); } diff --git a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h index cbe11ae324..70b5ecd390 100644 --- a/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h +++ b/extras/Introjucer/Source/Project/jucer_DependencyPathPropertyComponent.h @@ -12,8 +12,9 @@ #define JUCER_DEPENDENCYPATHPROPERTYCOMPONENT_H_INCLUDED //============================================================================== -namespace DependencyPath +class DependencyPath { +public: enum OS { windows = 0, @@ -34,6 +35,9 @@ namespace DependencyPath return DependencyPath::unknown; #endif } + + const static String vst2KeyName, vst3KeyName, rtasKeyName, aaxKeyName, + androidSdkKeyName, androidNdkKeyName; }; typedef DependencyPath::OS DependencyPathOS; @@ -50,16 +54,8 @@ class DependencyPathValueSource : public Value::ValueSource, { public: DependencyPathValueSource (const Value& projectSettingsPath, - const Value& globalSettingsPath, - const String& fallbackPath, - DependencyPathOS osThisSettingAppliesTo) - : projectSettingsValue (projectSettingsPath), - globalSettingsValue (globalSettingsPath), - fallbackValue (fallbackPath), - os (osThisSettingAppliesTo) - { - globalSettingsValue.addListener (this); - } + String globalSettingsKey, + DependencyPathOS osThisSettingAppliesTo); /** This gets the currently used value, which may be either the project setting, the global setting, or the fallback value. */ @@ -102,6 +98,8 @@ public: return os == DependencyPath::getThisOS(); } + bool isValidPath() const; + private: void valueChanged (Value& value) override { @@ -134,6 +132,16 @@ private: /** the dependency path setting as set in this Introjucer project. */ Value projectSettingsValue; + /** the global key used in the application settings for the global setting value. + needed for checking whether the path is valid. */ + String globalKey; + + /** on what operating system should this dependency path be used? + note that this is *not* the os that is targeted by the project, + but rather the os on which the project will be compiled + (= on which the path settings need to be set correctly). */ + DependencyPathOS os; + /** the dependency path global setting on this machine. used when there value set for this project is invalid. */ Value globalSettingsValue; @@ -142,12 +150,6 @@ private: whenever the latter doesn't apply, e.g. the setting is for another OS than the ome this machine is running. */ String fallbackValue; - - /** on what operating system should this dependency path be used? - note that this is *not* the os that is targeted by the project, - but rather the os on which the project will be compiled - (= on which the path settings need to be set correctly). */ - DependencyPathOS os; }; @@ -158,9 +160,7 @@ class DependencyPathPropertyComponent : public TextPropertyComponent, { public: DependencyPathPropertyComponent (const Value& value, - const String& propertyName, - const String& globalKey, - DependencyPathOS os = DependencyPath::getThisOS()); + const String& propertyName); private: @@ -174,18 +174,12 @@ private: /** This function handles path changes because the global path changed. */ void valueChanged (Value& value) override; - /** Check if the current value is a valid path. */ - bool isValidPath() const; - - /** the property key of the global property that this component is tracking. */ - String globalKey; - - /** the value source of this dependency path setting. */ - DependencyPathValueSource* pathValueSource; - - /** the value object around the value source. */ + /** the value that represents this dependency path setting. */ Value pathValue; + /** a reference to the value source that this value refers to. */ + DependencyPathValueSource& pathValueSource; + // Label::Listener overrides: void labelTextChanged (Label* labelThatHasChanged) override; void editorShown (Label*, TextEditor&) override;