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.

267 lines
13KB

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