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.

245 lines
11KB

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