The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

741 lines
36KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. #include "../Application/UserAccount/jucer_LicenseController.h"
  20. #include "Modules/jucer_AvailableModulesList.h"
  21. class ProjectExporter;
  22. class LibraryModule;
  23. class EnabledModulesList;
  24. class ProjectSaver;
  25. namespace ProjectMessages
  26. {
  27. namespace Ids
  28. {
  29. #define DECLARE_ID(name) static const Identifier name (#name)
  30. DECLARE_ID (projectMessages);
  31. DECLARE_ID (incompatibleLicense);
  32. DECLARE_ID (cppStandard);
  33. DECLARE_ID (moduleNotFound);
  34. DECLARE_ID (jucePath);
  35. DECLARE_ID (jucerFileModified);
  36. DECLARE_ID (missingModuleDependencies);
  37. DECLARE_ID (oldProjucer);
  38. DECLARE_ID (newVersionAvailable);
  39. DECLARE_ID (pluginCodeInvalid);
  40. DECLARE_ID (manufacturerCodeInvalid);
  41. DECLARE_ID (deprecatedExporter);
  42. DECLARE_ID (notification);
  43. DECLARE_ID (warning);
  44. DECLARE_ID (isVisible);
  45. #undef DECLARE_ID
  46. }
  47. inline Identifier getTypeForMessage (const Identifier& message)
  48. {
  49. static Identifier warnings[] = { Ids::incompatibleLicense, Ids::cppStandard, Ids::moduleNotFound,
  50. Ids::jucePath, Ids::jucerFileModified, Ids::missingModuleDependencies,
  51. Ids::oldProjucer, Ids::pluginCodeInvalid, Ids::manufacturerCodeInvalid,
  52. Ids::deprecatedExporter };
  53. if (std::find (std::begin (warnings), std::end (warnings), message) != std::end (warnings))
  54. return Ids::warning;
  55. if (message == Ids::newVersionAvailable)
  56. return Ids::notification;
  57. jassertfalse;
  58. return {};
  59. }
  60. inline String getTitleForMessage (const Identifier& message)
  61. {
  62. if (message == Ids::incompatibleLicense) return "Incompatible License and Splash Screen Setting";
  63. if (message == Ids::cppStandard) return "C++ Standard";
  64. if (message == Ids::moduleNotFound) return "Module Not Found";
  65. if (message == Ids::jucePath) return "JUCE Path";
  66. if (message == Ids::jucerFileModified) return "Project File Modified";
  67. if (message == Ids::missingModuleDependencies) return "Missing Module Dependencies";
  68. if (message == Ids::oldProjucer) return "Projucer Out of Date";
  69. if (message == Ids::newVersionAvailable) return "New Version Available";
  70. if (message == Ids::pluginCodeInvalid) return "Invalid Plugin Code";
  71. if (message == Ids::manufacturerCodeInvalid) return "Invalid Manufacturer Code";
  72. if (message == Ids::deprecatedExporter) return "Deprecated Exporter";
  73. jassertfalse;
  74. return {};
  75. }
  76. inline String getDescriptionForMessage (const Identifier& message)
  77. {
  78. if (message == Ids::incompatibleLicense) return "Save and export is disabled.";
  79. if (message == Ids::cppStandard) return "Module(s) have a higher C++ standard requirement than the project.";
  80. if (message == Ids::moduleNotFound) return "Module(s) could not be found at the specified paths.";
  81. if (message == Ids::jucePath) return "The path to your JUCE folder is incorrect.";
  82. if (message == Ids::jucerFileModified) return "The .jucer file has been modified since the last save.";
  83. if (message == Ids::missingModuleDependencies) return "Module(s) have missing dependencies.";
  84. if (message == Ids::oldProjucer) return "The version of the Projucer you are using is out of date.";
  85. if (message == Ids::newVersionAvailable) return "A new version of JUCE is available to download.";
  86. if (message == Ids::pluginCodeInvalid) return "The plugin code should be exactly four characters in length.";
  87. if (message == Ids::manufacturerCodeInvalid) return "The manufacturer code should be exactly four characters in length.";
  88. if (message == Ids::deprecatedExporter) return "The project includes a deprecated exporter.";
  89. jassertfalse;
  90. return {};
  91. }
  92. using MessageAction = std::pair<String, std::function<void()>>;
  93. }
  94. // Can be shared between multiple classes wanting to create a MessageBox. Ensures that there is one
  95. // MessageBox active at a given time.
  96. class MessageBoxQueue : private AsyncUpdater
  97. {
  98. public:
  99. struct Listener
  100. {
  101. using CreatorFunction = std::function<ScopedMessageBox (MessageBoxOptions, std::function<void (int)>)>;
  102. virtual ~Listener() = default;
  103. virtual void canCreateMessageBox (CreatorFunction) = 0;
  104. };
  105. void handleAsyncUpdate()
  106. {
  107. schedule();
  108. }
  109. auto addListener (Listener& l)
  110. {
  111. triggerAsyncUpdate();
  112. return listeners.addScoped (l);
  113. }
  114. private:
  115. ScopedMessageBox create (MessageBoxOptions options, std::function<void (int)> callback)
  116. {
  117. hasActiveMessageBox = true;
  118. return AlertWindow::showScopedAsync (options, [this, cb = std::move (callback)] (int result)
  119. {
  120. cb (result);
  121. hasActiveMessageBox = false;
  122. triggerAsyncUpdate();
  123. });
  124. }
  125. void schedule()
  126. {
  127. if (hasActiveMessageBox)
  128. return;
  129. auto& currentListeners = listeners.getListeners();
  130. if (! currentListeners.isEmpty())
  131. {
  132. currentListeners[0]->canCreateMessageBox ([this] (auto o, auto c)
  133. {
  134. return create (o, c);
  135. });
  136. }
  137. }
  138. ListenerList<Listener> listeners;
  139. bool hasActiveMessageBox = false;
  140. };
  141. enum class Async { no, yes };
  142. //==============================================================================
  143. class Project final : public FileBasedDocument,
  144. private ValueTree::Listener,
  145. private LicenseController::LicenseStateListener,
  146. private ChangeListener,
  147. private AvailableModulesList::Listener,
  148. private MessageBoxQueue::Listener
  149. {
  150. public:
  151. //==============================================================================
  152. Project (const File&);
  153. ~Project() override;
  154. //==============================================================================
  155. String getDocumentTitle() override;
  156. Result loadDocument (const File& file) override;
  157. Result saveDocument (const File& file) override;
  158. void saveDocumentAsync (const File& file, std::function<void (Result)> callback) override;
  159. void saveProject (Async, ProjectExporter* exporterToSave, std::function<void (Result)> onCompletion);
  160. void saveAndMoveTemporaryProject (bool openInIDE);
  161. Result saveResourcesOnly();
  162. void openProjectInIDE (ProjectExporter& exporterToOpen);
  163. File getLastDocumentOpened() override;
  164. void setLastDocumentOpened (const File& file) override;
  165. void setTitle (const String& newTitle);
  166. //==============================================================================
  167. File getProjectFolder() const { return getFile().getParentDirectory(); }
  168. File getGeneratedCodeFolder() const { return getFile().getSiblingFile ("JuceLibraryCode"); }
  169. File getSourceFilesFolder() const { return getProjectFolder().getChildFile ("Source"); }
  170. File getLocalModulesFolder() const { return getGeneratedCodeFolder().getChildFile ("modules"); }
  171. File getLocalModuleFolder (const String& moduleID) const { return getLocalModulesFolder().getChildFile (moduleID); }
  172. File getAppIncludeFile() const { return getGeneratedCodeFolder().getChildFile (getJuceSourceHFilename()); }
  173. File getBinaryDataCppFile (int index) const;
  174. File getBinaryDataHeaderFile() const { return getBinaryDataCppFile (0).withFileExtension (".h"); }
  175. static String getAppConfigFilename() { return "AppConfig.h"; }
  176. static String getPluginDefinesFilename() { return "JucePluginDefines.h"; }
  177. static String getJuceSourceHFilename() { return "JuceHeader.h"; }
  178. static String getJuceLV2DefinesFilename() { return "JuceLV2Defines.h"; }
  179. static String getLV2FileWriterName() { return "juce_lv2_helper"; }
  180. static String getVST3FileWriterName() { return "juce_vst3_helper"; }
  181. //==============================================================================
  182. template <class FileType>
  183. bool shouldBeAddedToBinaryResourcesByDefault (const FileType& file)
  184. {
  185. return ! file.hasFileExtension (sourceOrHeaderFileExtensions);
  186. }
  187. File resolveFilename (String filename) const;
  188. String getRelativePathForFile (const File& file) const;
  189. //==============================================================================
  190. // Creates editors for the project settings
  191. void createPropertyEditors (PropertyListBuilder&);
  192. //==============================================================================
  193. ValueTree getProjectRoot() const { return projectRoot; }
  194. Value getProjectValue (const Identifier& name) { return projectRoot.getPropertyAsValue (name, getUndoManagerFor (projectRoot)); }
  195. var getProjectVar (const Identifier& name) const { return projectRoot.getProperty (name); }
  196. const build_tools::ProjectType& getProjectType() const;
  197. String getProjectTypeString() const { return projectTypeValue.get(); }
  198. void setProjectType (const String& newProjectType) { projectTypeValue = newProjectType; }
  199. String getProjectNameString() const { return projectNameValue.get(); }
  200. String getProjectFilenameRootString() { return File::createLegalFileName (getDocumentTitle()); }
  201. String getProjectUIDString() const { return projectUIDValue.get(); }
  202. String getProjectLineFeed() const { return projectLineFeedValue.get(); }
  203. String getVersionString() const { return versionValue.get(); }
  204. String getVersionAsHex() const { return build_tools::getVersionAsHex (getVersionString()); }
  205. int getVersionAsHexInteger() const { return build_tools::getVersionAsHexInteger (getVersionString()); }
  206. void setProjectVersion (const String& newVersion) { versionValue = newVersion; }
  207. String getBundleIdentifierString() const { return bundleIdentifierValue.get(); }
  208. String getDefaultBundleIdentifierString() const;
  209. String getDefaultCompanyWebsiteString() const;
  210. String getDefaultAAXIdentifierString() const { return getDefaultBundleIdentifierString(); }
  211. String getDefaultPluginManufacturerString() const;
  212. String getDefaultLV2URI() const { return getCompanyWebsiteString() + "/plugins/" + build_tools::makeValidIdentifier (getProjectNameString(), false, true, false); }
  213. String getDefaultARAFactoryIDString() const;
  214. String getDefaultARADocumentArchiveID() const;
  215. String getDefaultARACompatibleArchiveIDs() const;
  216. String getCompanyNameString() const { return companyNameValue.get(); }
  217. String getCompanyCopyrightString() const { return companyCopyrightValue.get(); }
  218. String getCompanyWebsiteString() const { return companyWebsiteValue.get(); }
  219. String getCompanyEmailString() const { return companyEmailValue.get(); }
  220. String getHeaderSearchPathsString() const { return headerSearchPathsValue.get(); }
  221. StringPairArray getPreprocessorDefs() const { return parsedPreprocessorDefs; }
  222. int getMaxBinaryFileSize() const { return maxBinaryFileSizeValue.get(); }
  223. bool shouldIncludeBinaryInJuceHeader() const { return includeBinaryDataInJuceHeaderValue.get(); }
  224. String getBinaryDataNamespaceString() const { return binaryDataNamespaceValue.get(); }
  225. bool shouldDisplaySplashScreen() const { return displaySplashScreenValue.get(); }
  226. String getSplashScreenColourString() const { return splashScreenColourValue.get(); }
  227. static StringArray getCppStandardStrings() { return { "C++17", "C++20", "Use Latest" }; }
  228. static Array<var> getCppStandardVars() { return { "17", "20", "latest" }; }
  229. static String getLatestNumberedCppStandardString()
  230. {
  231. auto cppStandardVars = getCppStandardVars();
  232. return cppStandardVars[cppStandardVars.size() - 2];
  233. }
  234. String getCppStandardString() const { return cppStandardValue.get(); }
  235. StringArray getCompilerFlagSchemes() const;
  236. void addCompilerFlagScheme (const String&);
  237. void removeCompilerFlagScheme (const String&);
  238. String getPostExportShellCommandPosixString() const { return postExportShellCommandPosixValue.get(); }
  239. String getPostExportShellCommandWinString() const { return postExportShellCommandWinValue.get(); }
  240. bool shouldUseAppConfig() const { return useAppConfigValue.get(); }
  241. bool shouldAddUsingNamespaceToJuceHeader() const { return addUsingNamespaceToJuceHeader.get(); }
  242. //==============================================================================
  243. String getPluginNameString() const { return pluginNameValue.get(); }
  244. String getPluginDescriptionString() const { return pluginDescriptionValue.get();}
  245. String getPluginManufacturerString() const { return pluginManufacturerValue.get(); }
  246. String getPluginManufacturerCodeString() const { return pluginManufacturerCodeValue.get(); }
  247. String getPluginCodeString() const { return pluginCodeValue.get(); }
  248. String getPluginChannelConfigsString() const { return pluginChannelConfigsValue.get(); }
  249. String getAAXIdentifierString() const { return pluginAAXIdentifierValue.get(); }
  250. String getARAFactoryIDString() const { return pluginARAFactoryIDValue.get(); }
  251. String getARADocumentArchiveIDString() const { return pluginARAArchiveIDValue.get(); }
  252. String getARACompatibleArchiveIDStrings() const { return pluginARACompatibleArchiveIDsValue.get(); }
  253. String getPluginAUExportPrefixString() const { return pluginAUExportPrefixValue.get(); }
  254. String getPluginAUMainTypeString() const { return pluginAUMainTypeValue.get(); }
  255. String getVSTNumMIDIInputsString() const { return pluginVSTNumMidiInputsValue.get(); }
  256. String getVSTNumMIDIOutputsString() const { return pluginVSTNumMidiOutputsValue.get(); }
  257. static bool checkMultiChoiceVar (const ValueTreePropertyWithDefault& valueToCheck, Identifier idToCheck) noexcept
  258. {
  259. if (! valueToCheck.get().isArray())
  260. return false;
  261. auto v = valueToCheck.get();
  262. if (auto* varArray = v.getArray())
  263. return varArray->contains (idToCheck.toString());
  264. return false;
  265. }
  266. bool isAudioPluginProject() const { return getProjectType().isAudioPlugin(); }
  267. bool shouldBuildVST() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildVST); }
  268. bool shouldBuildVST3() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildVST3); }
  269. bool shouldBuildAU() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAU); }
  270. bool shouldBuildAUv3() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAUv3); }
  271. bool shouldBuildAAX() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildAAX); }
  272. bool shouldBuildStandalonePlugin() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildStandalone); }
  273. bool shouldBuildUnityPlugin() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildUnity); }
  274. bool shouldBuildLV2() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::buildLV2); }
  275. bool shouldEnableIAA() const { return isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::enableIAA); }
  276. bool shouldEnableARA() const { return (isAudioPluginProject() && checkMultiChoiceVar (pluginFormatsValue, Ids::enableARA)) || getProjectType().isARAAudioPlugin(); }
  277. bool isPluginSynth() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginIsSynth); }
  278. bool pluginWantsMidiInput() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginWantsMidiIn); }
  279. bool pluginProducesMidiOutput() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginProducesMidiOut); }
  280. bool isPluginMidiEffect() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginIsMidiEffectPlugin); }
  281. bool pluginEditorNeedsKeyFocus() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginEditorRequiresKeys); }
  282. bool isPluginAAXBypassDisabled() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginAAXDisableBypass); }
  283. bool isPluginAAXMultiMonoDisabled() const { return checkMultiChoiceVar (pluginCharacteristicsValue, Ids::pluginAAXDisableMultiMono); }
  284. void disableStandaloneForARAPlugIn();
  285. static StringArray getAllAUMainTypeStrings() noexcept;
  286. static Array<var> getAllAUMainTypeVars() noexcept;
  287. Array<var> getDefaultAUMainTypes() const noexcept;
  288. static StringArray getAllVSTCategoryStrings() noexcept;
  289. Array<var> getDefaultVSTCategories() const noexcept;
  290. static StringArray getAllVST3CategoryStrings() noexcept;
  291. Array<var> getDefaultVST3Categories() const noexcept;
  292. static StringArray getAllAAXCategoryStrings() noexcept;
  293. static Array<var> getAllAAXCategoryVars() noexcept;
  294. Array<var> getDefaultAAXCategories() const noexcept;
  295. bool getDefaultEnableARA() const noexcept;
  296. static StringArray getAllARAContentTypeStrings() noexcept;
  297. static Array<var> getAllARAContentTypeVars() noexcept;
  298. Array<var> getDefaultARAContentTypes() const noexcept;
  299. static StringArray getAllARATransformationFlagStrings() noexcept;
  300. static Array<var> getAllARATransformationFlagVars() noexcept;
  301. Array<var> getDefaultARATransformationFlags() const noexcept;
  302. String getAUMainTypeString() const noexcept;
  303. bool isAUSandBoxSafe() const noexcept;
  304. String getVSTCategoryString() const noexcept;
  305. String getVST3CategoryString() const noexcept;
  306. int getAAXCategory() const noexcept;
  307. int getARAContentTypes() const noexcept;
  308. int getARATransformationFlags() const noexcept;
  309. String getIAATypeCode() const;
  310. String getIAAPluginName() const;
  311. String getUnityScriptName() const { return addUnityPluginPrefixIfNecessary (getProjectNameString()) + "_UnityScript.cs"; }
  312. static String addUnityPluginPrefixIfNecessary (const String& name)
  313. {
  314. if (! name.startsWithIgnoreCase ("audioplugin"))
  315. return "audioplugin_" + name;
  316. return name;
  317. }
  318. String getLV2URI() const { return pluginLV2URIValue.get(); }
  319. //==============================================================================
  320. bool isAUPluginHost() const;
  321. bool isVSTPluginHost() const;
  322. bool isVST3PluginHost() const;
  323. bool isLV2PluginHost() const;
  324. bool isARAPluginHost() const;
  325. //==============================================================================
  326. bool shouldBuildTargetType (build_tools::ProjectType::Target::Type targetType) const noexcept;
  327. static build_tools::ProjectType::Target::Type getTargetTypeFromFilePath (const File& file, bool returnSharedTargetIfNoValidSuffix);
  328. //==============================================================================
  329. StringPairArray getAppConfigDefs();
  330. StringPairArray getAudioPluginFlags() const;
  331. //==============================================================================
  332. class Item
  333. {
  334. public:
  335. //==============================================================================
  336. Item (Project& project, const ValueTree& itemNode, bool isModuleCode);
  337. Item (const Item& other);
  338. static Item createGroup (Project& project, const String& name, const String& uid, bool isModuleCode);
  339. void initialiseMissingProperties();
  340. //==============================================================================
  341. bool isValid() const { return state.isValid(); }
  342. bool operator== (const Item& other) const { return state == other.state && &project == &other.project; }
  343. bool operator!= (const Item& other) const { return ! operator== (other); }
  344. //==============================================================================
  345. bool isFile() const;
  346. bool isGroup() const;
  347. bool isMainGroup() const;
  348. bool isImageFile() const;
  349. bool isSourceFile() const;
  350. String getID() const;
  351. void setID (const String& newID);
  352. Item findItemWithID (const String& targetId) const; // (recursive search)
  353. String getImageFileID() const;
  354. std::unique_ptr<Drawable> loadAsImageFile() const;
  355. //==============================================================================
  356. Value getNameValue();
  357. String getName() const;
  358. File getFile() const;
  359. String getFilePath() const;
  360. void setFile (const File& file);
  361. void setFile (const build_tools::RelativePath& file);
  362. File determineGroupFolder() const;
  363. bool renameFile (const File& newFile);
  364. bool shouldBeAddedToTargetProject() const;
  365. bool shouldBeAddedToTargetExporter (const ProjectExporter&) const;
  366. bool shouldBeCompiled() const;
  367. Value getShouldCompileValue();
  368. bool shouldBeAddedToBinaryResources() const;
  369. Value getShouldAddToBinaryResourcesValue();
  370. bool shouldBeAddedToXcodeResources() const;
  371. Value getShouldAddToXcodeResourcesValue();
  372. Value getShouldInhibitWarningsValue();
  373. bool shouldInhibitWarnings() const;
  374. bool isModuleCode() const;
  375. Value getShouldSkipPCHValue();
  376. bool shouldSkipPCH() const;
  377. Value getCompilerFlagSchemeValue();
  378. String getCompilerFlagSchemeString() const;
  379. void setCompilerFlagScheme (const String&);
  380. void clearCurrentCompilerFlagScheme();
  381. //==============================================================================
  382. bool canContain (const Item& child) const;
  383. int getNumChildren() const { return state.getNumChildren(); }
  384. Item getChild (int index) const { return Item (project, state.getChild (index), belongsToModule); }
  385. Item addNewSubGroup (const String& name, int insertIndex);
  386. Item getOrCreateSubGroup (const String& name);
  387. void addChild (const Item& newChild, int insertIndex);
  388. bool addFileAtIndex (const File& file, int insertIndex, bool shouldCompile);
  389. bool addFileRetainingSortOrder (const File& file, bool shouldCompile);
  390. void addFileUnchecked (const File& file, int insertIndex, bool shouldCompile);
  391. bool addRelativeFile (const build_tools::RelativePath& file, int insertIndex, bool shouldCompile);
  392. void removeItemFromProject();
  393. void sortAlphabetically (bool keepGroupsAtStart, bool recursive);
  394. Item findItemForFile (const File& file) const;
  395. bool containsChildForFile (const build_tools::RelativePath& file) const;
  396. Item getParent() const;
  397. Item createCopy();
  398. UndoManager* getUndoManager() const { return project.getUndoManagerFor (state); }
  399. Icon getIcon (bool isOpen = false) const;
  400. bool isIconCrossedOut() const;
  401. bool needsSaving() const noexcept;
  402. Project& project;
  403. ValueTree state;
  404. private:
  405. Item& operator= (const Item&);
  406. bool belongsToModule;
  407. };
  408. Item getMainGroup();
  409. void findAllImageItems (OwnedArray<Item>& items);
  410. //==============================================================================
  411. ValueTree getExporters();
  412. int getNumExporters();
  413. std::unique_ptr<ProjectExporter> createExporter (int index);
  414. void addNewExporter (const Identifier& exporterIdentifier);
  415. void createExporterForCurrentPlatform();
  416. struct ExporterIterator
  417. {
  418. ExporterIterator (Project& project);
  419. bool next();
  420. ProjectExporter& operator*() const { return *exporter; }
  421. ProjectExporter* operator->() const { return exporter.get(); }
  422. std::unique_ptr<ProjectExporter> exporter;
  423. int index;
  424. private:
  425. Project& project;
  426. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ExporterIterator)
  427. };
  428. //==============================================================================
  429. struct ConfigFlag
  430. {
  431. String symbol, description, sourceModuleID;
  432. ValueTreePropertyWithDefault value;
  433. };
  434. ValueTreePropertyWithDefault getConfigFlag (const String& name);
  435. bool isConfigFlagEnabled (const String& name, bool defaultIsEnabled = false) const;
  436. //==============================================================================
  437. void createEnabledModulesList();
  438. EnabledModulesList& getEnabledModules();
  439. const EnabledModulesList& getEnabledModules() const;
  440. AvailableModulesList& getExporterPathsModulesList() { return exporterPathsModulesList; }
  441. void rescanExporterPathModules (bool async = false);
  442. std::pair<String, File> getModuleWithID (const String&);
  443. //==============================================================================
  444. PropertiesFile& getStoredProperties() const;
  445. //==============================================================================
  446. UndoManager* getUndoManagerFor (const ValueTree&) const { return nullptr; }
  447. UndoManager* getUndoManager() const { return nullptr; }
  448. //==============================================================================
  449. static const char* projectFileExtension;
  450. //==============================================================================
  451. bool updateCachedFileState();
  452. String getCachedFileStateContent() const noexcept { return cachedFileState.second; }
  453. String serialiseProjectXml (std::unique_ptr<XmlElement>) const;
  454. //==============================================================================
  455. String getUniqueTargetFolderSuffixForExporter (const Identifier& exporterIdentifier, const String& baseTargetFolder);
  456. //==============================================================================
  457. bool isCurrentlySaving() const noexcept { return saver != nullptr; }
  458. bool isTemporaryProject() const noexcept { return tempDirectory != File(); }
  459. File getTemporaryDirectory() const noexcept { return tempDirectory; }
  460. void setTemporaryDirectory (const File&) noexcept;
  461. //==============================================================================
  462. ValueTree getProjectMessages() const { return projectMessages; }
  463. void addProjectMessage (const Identifier& messageToAdd, std::vector<ProjectMessages::MessageAction>&& messageActions);
  464. void removeProjectMessage (const Identifier& messageToRemove);
  465. std::vector<ProjectMessages::MessageAction> getMessageActions (const Identifier& message);
  466. //==============================================================================
  467. bool hasIncompatibleLicenseTypeAndSplashScreenSetting() const;
  468. bool isFileModificationCheckPending() const;
  469. bool isSaveAndExportDisabled() const;
  470. MessageBoxQueue messageBoxQueue;
  471. private:
  472. //==============================================================================
  473. void valueTreePropertyChanged (ValueTree&, const Identifier&) override;
  474. void valueTreeChildAdded (ValueTree&, ValueTree&) override;
  475. void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override;
  476. void valueTreeChildOrderChanged (ValueTree&, int, int) override;
  477. void valueTreeChildAddedOrRemoved (ValueTree&, ValueTree&);
  478. //==============================================================================
  479. void canCreateMessageBox (CreatorFunction) override;
  480. //==============================================================================
  481. template <typename This>
  482. static auto& getEnabledModulesImpl (This&);
  483. //==============================================================================
  484. struct ProjectFileModificationPoller final : private Timer
  485. {
  486. ProjectFileModificationPoller (Project& p);
  487. bool isCheckPending() const noexcept { return pending; }
  488. private:
  489. void timerCallback() override;
  490. void reset();
  491. void resaveProject();
  492. void reloadProjectFromDisk();
  493. Project& project;
  494. bool pending = false;
  495. };
  496. //==============================================================================
  497. ValueTree projectRoot { Ids::JUCERPROJECT };
  498. ValueTreePropertyWithDefault projectNameValue, projectUIDValue, projectLineFeedValue, projectTypeValue, versionValue, bundleIdentifierValue, companyNameValue,
  499. companyCopyrightValue, companyWebsiteValue, companyEmailValue, displaySplashScreenValue, splashScreenColourValue, cppStandardValue,
  500. headerSearchPathsValue, preprocessorDefsValue, userNotesValue, maxBinaryFileSizeValue, includeBinaryDataInJuceHeaderValue, binaryDataNamespaceValue,
  501. compilerFlagSchemesValue, postExportShellCommandPosixValue, postExportShellCommandWinValue, useAppConfigValue, addUsingNamespaceToJuceHeader;
  502. ValueTreePropertyWithDefault pluginFormatsValue, pluginNameValue, pluginDescriptionValue, pluginManufacturerValue, pluginManufacturerCodeValue,
  503. pluginCodeValue, pluginChannelConfigsValue, pluginCharacteristicsValue, pluginAUExportPrefixValue, pluginAAXIdentifierValue,
  504. pluginAUMainTypeValue, pluginAUSandboxSafeValue, pluginVSTCategoryValue, pluginVST3CategoryValue, pluginAAXCategoryValue,
  505. pluginEnableARA, pluginARAAnalyzableContentValue, pluginARAFactoryIDValue, pluginARAArchiveIDValue, pluginARACompatibleArchiveIDsValue, pluginARATransformFlagsValue,
  506. pluginVSTNumMidiInputsValue, pluginVSTNumMidiOutputsValue, pluginLV2URIValue;
  507. //==============================================================================
  508. std::unique_ptr<EnabledModulesList> enabledModulesList;
  509. AvailableModulesList exporterPathsModulesList;
  510. //==============================================================================
  511. void updateDeprecatedProjectSettings();
  512. //==============================================================================
  513. bool shouldWriteLegacyPluginFormatSettings = false;
  514. bool shouldWriteLegacyPluginCharacteristicsSettings = false;
  515. static Array<Identifier> getLegacyPluginFormatIdentifiers() noexcept;
  516. static Array<Identifier> getLegacyPluginCharacteristicsIdentifiers() noexcept;
  517. void writeLegacyPluginFormatSettings();
  518. void writeLegacyPluginCharacteristicsSettings();
  519. void coalescePluginFormatValues();
  520. void coalescePluginCharacteristicsValues();
  521. void updatePluginCategories();
  522. //==============================================================================
  523. File tempDirectory;
  524. std::pair<Time, String> cachedFileState;
  525. //==============================================================================
  526. StringPairArray parsedPreprocessorDefs;
  527. //==============================================================================
  528. void initialiseProjectValues();
  529. void initialiseMainGroup();
  530. void initialiseAudioPluginValues();
  531. bool setCppVersionFromOldExporterSettings();
  532. void createAudioPluginPropertyEditors (PropertyListBuilder& props);
  533. //==============================================================================
  534. void updateTitleDependencies();
  535. void updateCompanyNameDependencies();
  536. void updateProjectSettings();
  537. void updateWebsiteDependencies();
  538. ValueTree getConfigurations() const;
  539. ValueTree getConfigNode();
  540. void updateOldStyleConfigList();
  541. void moveOldPropertyFromProjectToAllExporters (Identifier name);
  542. void removeDefunctExporters();
  543. void updateOldModulePaths();
  544. //==============================================================================
  545. void licenseStateChanged() override;
  546. void changeListenerCallback (ChangeBroadcaster*) override;
  547. void availableModulesChanged (AvailableModulesList*) override;
  548. void updateLicenseWarning();
  549. void updateJUCEPathWarning();
  550. void updateModuleWarnings();
  551. void updateExporterWarnings();
  552. void updateCppStandardWarning (bool showWarning);
  553. void updateMissingModuleDependenciesWarning (bool showWarning);
  554. void updateOldProjucerWarning (bool showWarning);
  555. void updateModuleNotFoundWarning (bool showWarning);
  556. void updateCodeWarning (Identifier identifier, String value);
  557. ValueTree projectMessages { ProjectMessages::Ids::projectMessages, {},
  558. { { ProjectMessages::Ids::notification, {} }, { ProjectMessages::Ids::warning, {} } } };
  559. std::map<Identifier, std::vector<ProjectMessages::MessageAction>> messageActions;
  560. ProjectFileModificationPoller fileModificationPoller { *this };
  561. std::unique_ptr<FileChooser> chooser;
  562. std::unique_ptr<ProjectSaver> saver;
  563. std::optional<MessageBoxOptions> exporterRemovalMessageBoxOptions;
  564. ErasedScopeGuard messageBoxQueueListenerScope;
  565. ScopedMessageBox messageBox;
  566. //==============================================================================
  567. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Project)
  568. JUCE_DECLARE_WEAK_REFERENCEABLE (Project)
  569. };