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.

173 lines
6.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. #include "jucer_Project.h"
  19. #include "../Application/jucer_OpenDocumentManager.h"
  20. class CompileEngineChildProcess;
  21. //==============================================================================
  22. class ProjectContentComponent : public Component,
  23. public ApplicationCommandTarget,
  24. private ChangeListener,
  25. private OpenDocumentManager::DocumentCloseListener,
  26. private FocusChangeListener,
  27. private Timer
  28. {
  29. public:
  30. //==============================================================================
  31. ProjectContentComponent();
  32. ~ProjectContentComponent();
  33. Project* getProject() const noexcept { return project; }
  34. virtual void setProject (Project*);
  35. void saveTreeViewState();
  36. void saveOpenDocumentList();
  37. void reloadLastOpenDocuments();
  38. bool showEditorForFile (const File&, bool grabFocus);
  39. bool hasFileInRecentList (const File&) const;
  40. File getCurrentFile() const;
  41. bool showDocument (OpenDocumentManager::Document*, bool grabFocus);
  42. void hideDocument (OpenDocumentManager::Document*);
  43. OpenDocumentManager::Document* getCurrentDocument() const { return currentDocument; }
  44. void closeDocument();
  45. void saveDocument();
  46. void saveAs();
  47. void hideEditor();
  48. bool setEditorComponent (Component* editor, OpenDocumentManager::Document* doc);
  49. Component* getEditorComponent() const { return contentView; }
  50. Component& getTabsComponent() { return treeViewTabs; }
  51. bool goToPreviousFile();
  52. bool goToNextFile();
  53. bool canGoToCounterpart() const;
  54. bool goToCounterpart();
  55. bool saveProject();
  56. void closeProject();
  57. void openInIDE (bool saveFirst);
  58. void openInIDE (int exporterIndex, bool saveFirst);
  59. void showNewExporterMenu();
  60. void showFilesTab();
  61. void showConfigTab();
  62. void showBuildTab();
  63. void showProjectSettings();
  64. void showModules();
  65. void showModule (const String& moduleID);
  66. void deleteSelectedTreeItems();
  67. void updateMainWindowTitle();
  68. void updateMissingFileStatuses();
  69. void createProjectTabs();
  70. void deleteProjectTabs();
  71. void rebuildProjectTabs();
  72. void refreshTabsIfBuildStatusChanged();
  73. void toggleWarnings();
  74. void showNextError();
  75. void showPreviousError();
  76. void reinstantiateLivePreviewWindows();
  77. void showBubbleMessage (Rectangle<int>, const String&);
  78. StringArray getExportersWhichCanLaunch() const;
  79. static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails&,
  80. OwnedArray<Project::Item>& selectedNodes);
  81. //==============================================================================
  82. void killChildProcess();
  83. void cleanAll();
  84. void handleMissingSystemHeaders();
  85. bool isBuildTabEnabled() const;
  86. void setBuildEnabled (bool);
  87. bool isBuildEnabled() const;
  88. bool areWarningsEnabled() const;
  89. //==============================================================================
  90. ApplicationCommandTarget* getNextCommandTarget() override;
  91. void getAllCommands (Array<CommandID>&) override;
  92. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  93. bool perform (const InvocationInfo&) override;
  94. void paint (Graphics&) override;
  95. void paintOverChildren (Graphics&) override;
  96. void resized() override;
  97. void childBoundsChanged (Component*) override;
  98. void lookAndFeelChanged() override;
  99. String lastCrashMessage;
  100. private:
  101. //==============================================================================
  102. Project* project;
  103. OpenDocumentManager::Document* currentDocument;
  104. RecentDocumentList recentDocumentList;
  105. ScopedPointer<Component> logo, translationTool, contentView;
  106. TabbedComponent treeViewTabs;
  107. ScopedPointer<ResizableEdgeComponent> resizerBar;
  108. ComponentBoundsConstrainer treeSizeConstrainer;
  109. BubbleMessageComponent bubbleMessage;
  110. ReferenceCountedObjectPtr<CompileEngineChildProcess> childProcess;
  111. bool isForeground = false;
  112. //==============================================================================
  113. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  114. void changeListenerCallback (ChangeBroadcaster*) override;
  115. void showTranslationTool();
  116. void globalFocusChanged (Component*) override;
  117. void timerCallback() override;
  118. Component* createBuildTab (CompileEngineChildProcess*);
  119. Component* createDisabledBuildTabSubscribe (String textPrefix, bool loggedIn, bool dllPresent);
  120. Component* createDisabledBuildTabInfoOnly (const char* messsage);
  121. bool isContinuousRebuildEnabled() { return getAppSettings().getGlobalProperties().getBoolValue ("continuousRebuild", true); }
  122. void setContinuousRebuildEnabled (bool b) { getAppSettings().getGlobalProperties().setValue ("continuousRebuild", b); }
  123. void rebuildNow();
  124. void handleCrash (const String& message);
  125. void updateWarningState();
  126. void launchApp();
  127. void killApp();
  128. bool isBuildTabSuitableForLoggedInUser() const;
  129. bool isBuildTabLoggedInWithoutLicense() const;
  130. ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess();
  131. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  132. };