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.

274 lines
14KB

  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 "../../Utility/Helpers/jucer_MiscUtilities.h"
  20. //==============================================================================
  21. namespace NewProjectTemplates
  22. {
  23. enum class ProjectCategory
  24. {
  25. application,
  26. plugin,
  27. library
  28. };
  29. inline String getProjectCategoryString (ProjectCategory category)
  30. {
  31. if (category == ProjectCategory::application) return "Application";
  32. if (category == ProjectCategory::plugin) return "Plug-In";
  33. if (category == ProjectCategory::library) return "Library";
  34. jassertfalse;
  35. return "Unknown";
  36. }
  37. enum class FileCreationOptions
  38. {
  39. noFiles,
  40. main,
  41. header,
  42. headerAndCpp,
  43. processorAndEditor,
  44. araPluginFiles
  45. };
  46. using FilenameAndContent = std::pair<String, String>;
  47. using OptionAndFilenameAndContent = std::pair<FileCreationOptions, std::vector<FilenameAndContent>>;
  48. using OptionsAndFiles = std::vector<OptionAndFilenameAndContent>;
  49. struct ProjectTemplate
  50. {
  51. ProjectCategory category;
  52. String displayName, description, projectTypeString;
  53. const char* icon;
  54. StringArray requiredModules;
  55. OptionsAndFiles fileOptionsAndFiles;
  56. FileCreationOptions defaultFileOption;
  57. std::vector<FilenameAndContent> getFilesForOption (FileCreationOptions option) const
  58. {
  59. auto iter = std::find_if (fileOptionsAndFiles.begin(), fileOptionsAndFiles.end(),
  60. [option] (const OptionAndFilenameAndContent& opt) { return opt.first == option; });
  61. if (iter != fileOptionsAndFiles.end())
  62. return iter->second;
  63. return {};
  64. }
  65. };
  66. inline bool isApplication (const ProjectTemplate& t) noexcept { return t.category == ProjectCategory::application; }
  67. inline bool isPlugin (const ProjectTemplate& t) noexcept { return t.category == ProjectCategory::plugin; }
  68. inline bool isLibrary (const ProjectTemplate& t) noexcept { return t.category == ProjectCategory::library; }
  69. //==============================================================================
  70. inline var getVarForFileOption (FileCreationOptions opt)
  71. {
  72. if (opt == FileCreationOptions::noFiles) return "none";
  73. if (opt == FileCreationOptions::main) return "main";
  74. if (opt == FileCreationOptions::header) return "header";
  75. if (opt == FileCreationOptions::headerAndCpp) return "headercpp";
  76. if (opt == FileCreationOptions::processorAndEditor) return "processoreditor";
  77. if (opt == FileCreationOptions::araPluginFiles) return "arapluginfiles";
  78. jassertfalse;
  79. return {};
  80. }
  81. inline FileCreationOptions getFileOptionForVar (var opt)
  82. {
  83. if (opt == "none") return FileCreationOptions::noFiles;
  84. if (opt == "main") return FileCreationOptions::main;
  85. if (opt == "header") return FileCreationOptions::header;
  86. if (opt == "headercpp") return FileCreationOptions::headerAndCpp;
  87. if (opt == "processoreditor") return FileCreationOptions::processorAndEditor;
  88. if (opt == "arapluginfiles") return FileCreationOptions::araPluginFiles;
  89. jassertfalse;
  90. return {};
  91. }
  92. inline String getStringForFileOption (FileCreationOptions opt)
  93. {
  94. if (opt == FileCreationOptions::noFiles) return "No Files";
  95. if (opt == FileCreationOptions::main) return "Main.cpp";
  96. if (opt == FileCreationOptions::header) return "Main.cpp + .h";
  97. if (opt == FileCreationOptions::headerAndCpp) return "Main.cpp + .h/.cpp ";
  98. if (opt == FileCreationOptions::processorAndEditor) return "Processor and Editor";
  99. if (opt == FileCreationOptions::araPluginFiles) return "ARA Plugin Files";
  100. jassertfalse;
  101. return {};
  102. }
  103. //==============================================================================
  104. template <typename... Strings>
  105. inline StringArray addAndReturn (StringArray arr, Strings... strings)
  106. {
  107. arr.addArray ({ strings... });
  108. return arr;
  109. }
  110. inline std::vector<ProjectTemplate> getAllTemplates()
  111. {
  112. return
  113. {
  114. { ProjectCategory::application,
  115. "Blank", "Creates a blank JUCE GUI application.",
  116. build_tools::ProjectType_GUIApp::getTypeName(),
  117. BinaryData::wizard_GUI_svg,
  118. getModulesRequiredForComponent(),
  119. {},
  120. FileCreationOptions::noFiles
  121. },
  122. { ProjectCategory::application,
  123. "GUI", "Creates a blank JUCE GUI application with a single window component.",
  124. build_tools::ProjectType_GUIApp::getTypeName(),
  125. BinaryData::wizard_GUI_svg,
  126. getModulesRequiredForComponent(),
  127. {
  128. { FileCreationOptions::noFiles, {} },
  129. { FileCreationOptions::main, { { "Main.cpp", "jucer_MainTemplate_NoWindow_cpp" } } },
  130. { FileCreationOptions::header, { { "Main.cpp", "jucer_MainTemplate_Window_cpp" },
  131. { "MainComponent.h", "jucer_ContentCompSimpleTemplate_h" } } },
  132. { FileCreationOptions::headerAndCpp, { { "Main.cpp", "jucer_MainTemplate_Window_cpp" },
  133. { "MainComponent.h", "jucer_ContentCompTemplate_h" },
  134. { "MainComponent.cpp", "jucer_ContentCompTemplate_cpp" } } }
  135. },
  136. FileCreationOptions::headerAndCpp },
  137. { ProjectCategory::application,
  138. "Audio", "Creates a blank JUCE GUI application with a single window component and audio and MIDI in/out functions.",
  139. build_tools::ProjectType_GUIApp::getTypeName(),
  140. BinaryData::wizard_AudioApp_svg,
  141. addAndReturn (getModulesRequiredForComponent(), "juce_audio_basics", "juce_audio_devices", "juce_audio_formats",
  142. "juce_audio_processors", "juce_audio_utils", "juce_gui_extra"),
  143. {
  144. { FileCreationOptions::header, { { "Main.cpp", "jucer_MainTemplate_Window_cpp" },
  145. { "MainComponent.h", "jucer_AudioComponentSimpleTemplate_h" } } },
  146. { FileCreationOptions::headerAndCpp, { { "Main.cpp", "jucer_MainTemplate_Window_cpp" },
  147. { "MainComponent.h", "jucer_AudioComponentTemplate_h" },
  148. { "MainComponent.cpp", "jucer_AudioComponentTemplate_cpp" } } }
  149. },
  150. FileCreationOptions::headerAndCpp },
  151. { ProjectCategory::application,
  152. "Console", "Creates a command-line application without GUI support.",
  153. build_tools::ProjectType_ConsoleApp::getTypeName(),
  154. BinaryData::wizard_ConsoleApp_svg,
  155. getModulesRequiredForConsole(),
  156. {
  157. { FileCreationOptions::noFiles, {} },
  158. { FileCreationOptions::main, { { "Main.cpp", "jucer_MainConsoleAppTemplate_cpp" } } }
  159. },
  160. FileCreationOptions::main },
  161. { ProjectCategory::application,
  162. "Animated", "Creates a JUCE GUI application which draws an animated graphical display.",
  163. build_tools::ProjectType_GUIApp::getTypeName(),
  164. BinaryData::wizard_AnimatedApp_svg,
  165. addAndReturn (getModulesRequiredForComponent(), "juce_gui_extra"),
  166. {
  167. { FileCreationOptions::header, { { "Main.cpp", "jucer_MainTemplate_Window_cpp" },
  168. { "MainComponent.h", "jucer_AudioComponentSimpleTemplate_h" } } },
  169. { FileCreationOptions::headerAndCpp, { { "Main.cpp", "jucer_MainTemplate_Window_cpp" },
  170. { "MainComponent.h", "jucer_AnimatedComponentTemplate_h" },
  171. { "MainComponent.cpp", "jucer_AnimatedComponentTemplate_cpp" } } }
  172. },
  173. FileCreationOptions::headerAndCpp },
  174. { ProjectCategory::application,
  175. "OpenGL", "Creates a blank JUCE application with a single window component. "
  176. "This component supports openGL drawing features including 3D model import and GLSL shaders.",
  177. build_tools::ProjectType_GUIApp::getTypeName(),
  178. BinaryData::wizard_OpenGL_svg,
  179. addAndReturn (getModulesRequiredForComponent(), "juce_gui_extra", "juce_opengl"),
  180. {
  181. { FileCreationOptions::header, { { "Main.cpp", "jucer_MainTemplate_Window_cpp" },
  182. { "MainComponent.h", "jucer_AudioComponentSimpleTemplate_h" } } },
  183. { FileCreationOptions::headerAndCpp, { { "Main.cpp", "jucer_MainTemplate_Window_cpp" },
  184. { "MainComponent.h", "jucer_OpenGLComponentTemplate_h" },
  185. { "MainComponent.cpp", "jucer_OpenGLComponentTemplate_cpp" } } }
  186. },
  187. FileCreationOptions::headerAndCpp },
  188. { ProjectCategory::plugin,
  189. "Basic", "Creates an audio plug-in with a single window GUI and audio/MIDI IO functions.",
  190. build_tools::ProjectType_AudioPlugin::getTypeName(),
  191. BinaryData::wizard_AudioPlugin_svg,
  192. getModulesRequiredForAudioProcessor(),
  193. {
  194. { FileCreationOptions::processorAndEditor, { { "PluginProcessor.cpp", "jucer_AudioPluginFilterTemplate_cpp" },
  195. { "PluginProcessor.h", "jucer_AudioPluginFilterTemplate_h" },
  196. { "PluginEditor.cpp", "jucer_AudioPluginEditorTemplate_cpp" },
  197. { "PluginEditor.h", "jucer_AudioPluginEditorTemplate_h" } } }
  198. },
  199. FileCreationOptions::processorAndEditor
  200. },
  201. { ProjectCategory::plugin,
  202. "ARA", "Creates an ARA audio plug-in, augmenting the basic audio plug-in with ARA functionality.",
  203. build_tools::ProjectType_ARAAudioPlugin::getTypeName(),
  204. BinaryData::wizard_AudioPlugin_svg,
  205. getModulesRequiredForAudioProcessor(),
  206. {
  207. { FileCreationOptions::araPluginFiles, { { "PluginProcessor.cpp", "jucer_AudioPluginFilterTemplate_cpp" },
  208. { "PluginProcessor.h", "jucer_AudioPluginFilterTemplate_h" },
  209. { "PluginEditor.cpp", "jucer_AudioPluginEditorTemplate_cpp" },
  210. { "PluginEditor.h", "jucer_AudioPluginEditorTemplate_h" },
  211. { "PluginARADocumentController.cpp", "jucer_AudioPluginARADocumentControllerTemplate_cpp" },
  212. { "PluginARADocumentController.h", "jucer_AudioPluginARADocumentControllerTemplate_h" },
  213. { "PluginARAPlaybackRenderer.cpp", "jucer_AudioPluginARAPlaybackRendererTemplate_cpp" },
  214. { "PluginARAPlaybackRenderer.h", "jucer_AudioPluginARAPlaybackRendererTemplate_h" }} }
  215. },
  216. FileCreationOptions::araPluginFiles
  217. },
  218. { ProjectCategory::library,
  219. "Static Library", "Creates a static library.",
  220. build_tools::ProjectType_StaticLibrary::getTypeName(),
  221. BinaryData::wizard_StaticLibrary_svg,
  222. getModulesRequiredForConsole(),
  223. {},
  224. FileCreationOptions::noFiles
  225. },
  226. { ProjectCategory::library,
  227. "Dynamic Library", "Creates a dynamic library.",
  228. build_tools::ProjectType_DLL::getTypeName(),
  229. BinaryData::wizard_DLL_svg,
  230. getModulesRequiredForConsole(),
  231. {},
  232. FileCreationOptions::noFiles
  233. }
  234. };
  235. }
  236. }