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.

252 lines
12KB

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