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.

113 lines
4.7KB

  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. //==============================================================================
  15. struct AnimatedAppWizard : public NewProjectWizard
  16. {
  17. AnimatedAppWizard() {}
  18. String getName() const override { return TRANS("Animated Application"); }
  19. String getDescription() const override { return TRANS("Creates an application which draws an animated graphical display."); }
  20. const char* getIcon() const override { return BinaryData::wizard_AnimatedApp_svg; }
  21. StringArray getFileCreationOptions() override
  22. {
  23. return { "Create header and implementation files",
  24. "Create header file only" };
  25. }
  26. Result processResultsFromSetupItems (WizardComp& setupComp) override
  27. {
  28. createCppFile = false;
  29. switch (setupComp.getFileCreationComboID())
  30. {
  31. case 0: createCppFile = true; break;
  32. case 1: break;
  33. default: jassertfalse; break;
  34. }
  35. return Result::ok();
  36. }
  37. bool initialiseProject (Project& project) override
  38. {
  39. createSourceFolder();
  40. File mainCppFile = getSourceFilesFolder().getChildFile ("Main.cpp");
  41. File contentCompCpp = getSourceFilesFolder().getChildFile ("MainComponent.cpp");
  42. File contentCompH = contentCompCpp.withFileExtension (".h");
  43. String contentCompName = "MainComponent";
  44. project.setProjectType (build_tools::ProjectType_GUIApp::getTypeName());
  45. Project::Item sourceGroup (createSourceGroup (project));
  46. setExecutableNameForAllTargets (project, File::createLegalFileName (appTitle));
  47. auto juceHeaderInclude = CodeHelpers::createIncludePathIncludeStatement (Project::getJuceSourceHFilename());
  48. auto appHeaders = juceHeaderInclude + newLine + CodeHelpers::createIncludeStatement (contentCompH, mainCppFile);
  49. // create main window
  50. String windowH = project.getFileTemplate (createCppFile ? "jucer_AnimatedComponentTemplate_h"
  51. : "jucer_AnimatedComponentSimpleTemplate_h")
  52. .replace ("%%include_juce%%", juceHeaderInclude)
  53. .replace ("%%content_component_class%%", contentCompName, false);
  54. if (!build_tools::overwriteFileWithNewDataIfDifferent (contentCompH, windowH))
  55. failedFiles.add (contentCompH.getFullPathName());
  56. sourceGroup.addFileAtIndex (contentCompH, -1, false);
  57. if (createCppFile)
  58. {
  59. String windowCpp = project.getFileTemplate ("jucer_AnimatedComponentTemplate_cpp")
  60. .replace ("%%include_juce%%", juceHeaderInclude)
  61. .replace ("%%include_corresponding_header%%", CodeHelpers::createIncludeStatement (contentCompH, contentCompCpp), false)
  62. .replace ("%%content_component_class%%", contentCompName, false);
  63. if (!build_tools::overwriteFileWithNewDataIfDifferent (contentCompCpp, windowCpp))
  64. failedFiles.add (contentCompCpp.getFullPathName());
  65. sourceGroup.addFileAtIndex (contentCompCpp, -1, true);
  66. }
  67. // create main cpp
  68. String mainCpp = project.getFileTemplate ("jucer_MainTemplate_SimpleWindow_cpp")
  69. .replace ("%%app_headers%%", appHeaders, false)
  70. .replace ("%%app_class_name%%", build_tools::makeValidIdentifier (appTitle + "Application", false, true, false), false)
  71. .replace ("%%content_component_class%%", contentCompName, false)
  72. .replace ("%%allow_more_than_one_instance%%", "true", false);
  73. if (!build_tools::overwriteFileWithNewDataIfDifferent (mainCppFile, mainCpp))
  74. failedFiles.add (mainCppFile.getFullPathName());
  75. sourceGroup.addFileAtIndex (mainCppFile,-1, true);
  76. return true;
  77. }
  78. private:
  79. bool createCppFile;
  80. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AnimatedAppWizard)
  81. };