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.

195 lines
7.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 "jucer_MainWindow.h"
  15. #include "../Project/jucer_Module.h"
  16. #include "jucer_AutoUpdater.h"
  17. #include "../CodeEditor/jucer_SourceCodeEditor.h"
  18. #include "../Utility/UI/jucer_ProjucerLookAndFeel.h"
  19. #include "../Licenses/jucer_LicenseController.h"
  20. struct ChildProcessCache;
  21. //==============================================================================
  22. class ProjucerApplication : public JUCEApplication,
  23. private AsyncUpdater,
  24. private LicenseController::StateChangedCallback
  25. {
  26. public:
  27. ProjucerApplication();
  28. static ProjucerApplication& getApp();
  29. static ApplicationCommandManager& getCommandManager();
  30. //==============================================================================
  31. void initialise (const String& commandLine) override;
  32. void initialiseBasics();
  33. bool initialiseLogger (const char* filePrefix);
  34. void initialiseWindows (const String& commandLine);
  35. void shutdown() override;
  36. void systemRequestedQuit() override;
  37. void deleteLogger();
  38. //==============================================================================
  39. const String getApplicationName() override { return "Projucer"; }
  40. const String getApplicationVersion() override { return ProjectInfo::versionString; }
  41. String getVersionDescription() const;
  42. bool moreThanOneInstanceAllowed() override { return true; } // this is handled manually in initialise()
  43. void anotherInstanceStarted (const String& commandLine) override;
  44. //==============================================================================
  45. MenuBarModel* getMenuModel();
  46. StringArray getMenuNames();
  47. void createMenu (PopupMenu&, const String& menuName);
  48. void createFileMenu (PopupMenu&);
  49. void createEditMenu (PopupMenu&);
  50. void createViewMenu (PopupMenu&);
  51. void createBuildMenu (PopupMenu&);
  52. void createColourSchemeItems (PopupMenu&);
  53. void createWindowMenu (PopupMenu&);
  54. void createDocumentMenu (PopupMenu&);
  55. void createToolsMenu (PopupMenu&);
  56. void createHelpMenu (PopupMenu&);
  57. void createExtraAppleMenuItems (PopupMenu&);
  58. void handleMainMenuCommand (int menuItemID);
  59. //==============================================================================
  60. void getAllCommands (Array<CommandID>&) override;
  61. void getCommandInfo (CommandID commandID, ApplicationCommandInfo&) override;
  62. bool perform (const InvocationInfo&) override;
  63. //==============================================================================
  64. void createNewProject();
  65. void createNewProjectFromClipboard();
  66. void createNewPIP();
  67. void askUserToOpenFile();
  68. bool openFile (const File&);
  69. void saveAllDocuments();
  70. bool closeAllDocuments (bool askUserToSave);
  71. bool closeAllMainWindows();
  72. void closeAllMainWindowsAndQuitIfNeeded();
  73. void clearRecentFiles();
  74. PropertiesFile::Options getPropertyFileOptionsFor (const String& filename, bool isProjectSettings);
  75. //==============================================================================
  76. void showUTF8ToolWindow();
  77. void showSVGPathDataToolWindow();
  78. void showAboutWindow();
  79. void showPathsWindow (bool highlightJUCEPath = false);
  80. void showEditorColourSchemeWindow();
  81. void showPIPCreatorWindow();
  82. void launchForumBrowser();
  83. void launchModulesBrowser();
  84. void launchClassesBrowser();
  85. void launchTutorialsBrowser();
  86. void updateAllBuildTabs();
  87. //==============================================================================
  88. void licenseStateChanged (const LicenseState&) override;
  89. void doLogout();
  90. bool isPaidOrGPL() const { return licenseController == nullptr || licenseController->getState().isPaidOrGPL(); }
  91. //==============================================================================
  92. void selectEditorColourSchemeWithName (const String& schemeName);
  93. static bool isEditorColourSchemeADefaultScheme (const StringArray& schemes, int editorColourSchemeIndex);
  94. static int getEditorColourSchemeForGUIColourScheme (const StringArray& schemes, int guiColourSchemeIndex);
  95. //==============================================================================
  96. void rescanJUCEPathModules();
  97. void rescanUserPathModules();
  98. AvailableModuleList& getJUCEPathModuleList() { return jucePathModuleList; }
  99. AvailableModuleList& getUserPathsModuleList() { return userPathsModuleList; }
  100. //==============================================================================
  101. ProjucerLookAndFeel lookAndFeel;
  102. std::unique_ptr<StoredSettings> settings;
  103. std::unique_ptr<Icons> icons;
  104. struct MainMenuModel;
  105. std::unique_ptr<MainMenuModel> menuModel;
  106. MainWindowList mainWindowList;
  107. OpenDocumentManager openDocumentManager;
  108. std::unique_ptr<ApplicationCommandManager> commandManager;
  109. std::unique_ptr<Component> utf8Window, svgPathWindow, aboutWindow, pathsWindow,
  110. editorColourSchemeWindow, pipCreatorWindow;
  111. std::unique_ptr<FileLogger> logger;
  112. bool isRunningCommandLine;
  113. std::unique_ptr<ChildProcessCache> childProcessCache;
  114. std::unique_ptr<LicenseController> licenseController;
  115. private:
  116. //==============================================================================
  117. void handleAsyncUpdate() override;
  118. void initCommandManager();
  119. void createExamplesPopupMenu (PopupMenu&) noexcept;
  120. Array<File> getSortedExampleDirectories() noexcept;
  121. Array<File> getSortedExampleFilesInDirectory (const File&) const noexcept;
  122. bool findWindowAndOpenPIP (const File&);
  123. void findAndLaunchExample (int);
  124. void checkIfGlobalJUCEPathHasChanged();
  125. File tryToFindDemoRunnerExecutable();
  126. File tryToFindDemoRunnerProject();
  127. void launchDemoRunner();
  128. void showSetJUCEPathAlert();
  129. void setColourScheme (int index, bool saveSetting);
  130. void setEditorColourScheme (int index, bool saveSetting);
  131. void updateEditorColourSchemeIfNeeded();
  132. //==============================================================================
  133. void* server = nullptr;
  134. std::unique_ptr<TooltipWindow> tooltipWindow;
  135. AvailableModuleList jucePathModuleList, userPathsModuleList;
  136. int numExamples = 0;
  137. std::unique_ptr<AlertWindow> demoRunnerAlert;
  138. std::unique_ptr<AlertWindow> pathAlert;
  139. bool hasScannedForDemoRunnerExecutable = false, hasScannedForDemoRunnerProject = false;
  140. File lastJUCEPath, lastDemoRunnerExectuableFile, lastDemoRunnerProjectFile;
  141. #if JUCE_LINUX
  142. ChildProcess makeProcess;
  143. #endif
  144. int selectedColourSchemeIndex = 0, selectedEditorColourSchemeIndex = 0;
  145. //==============================================================================
  146. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjucerApplication)
  147. };