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.

209 lines
7.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "../../CodeEditor/jucer_OpenDocumentManager.h"
  21. class CompileEngineChildProcess;
  22. class ProjectTab;
  23. class LiveBuildTab;
  24. class HeaderComponent;
  25. //==============================================================================
  26. class ProjectContentComponent : public Component,
  27. public ApplicationCommandTarget,
  28. private ChangeListener,
  29. private OpenDocumentManager::DocumentCloseListener,
  30. private FocusChangeListener,
  31. private Timer
  32. {
  33. public:
  34. //==============================================================================
  35. ProjectContentComponent();
  36. ~ProjectContentComponent();
  37. Project* getProject() const noexcept { return project; }
  38. virtual void setProject (Project*);
  39. void saveTreeViewState();
  40. void saveOpenDocumentList();
  41. void reloadLastOpenDocuments();
  42. bool showEditorForFile (const File&, bool grabFocus);
  43. bool hasFileInRecentList (const File&) const;
  44. File getCurrentFile() const;
  45. bool showDocument (OpenDocumentManager::Document*, bool grabFocus);
  46. void hideDocument (OpenDocumentManager::Document*);
  47. OpenDocumentManager::Document* getCurrentDocument() const { return currentDocument; }
  48. void closeDocument();
  49. void saveDocument();
  50. void saveAs();
  51. void hideEditor();
  52. bool setEditorComponent (Component* editor, OpenDocumentManager::Document* doc);
  53. Component* getEditorComponentContent() const;
  54. Component* getEditorComponent() const { return contentView.get(); }
  55. Component& getSidebarComponent() { return sidebarTabs; }
  56. bool goToPreviousFile();
  57. bool goToNextFile();
  58. bool canGoToCounterpart() const;
  59. bool goToCounterpart();
  60. bool saveProject (bool shouldWait = false, bool openInIDE = false);
  61. void closeProject();
  62. void openInSelectedIDE (bool saveFirst);
  63. void showNewExporterMenu();
  64. void showProjectTab() { sidebarTabs.setCurrentTabIndex (0); }
  65. void showBuildTab() { sidebarTabs.setCurrentTabIndex (1); }
  66. int getCurrentTabIndex() { return sidebarTabs.getCurrentTabIndex(); }
  67. void showFilesPanel() { showProjectPanel (0); }
  68. void showModulesPanel() { showProjectPanel (1); }
  69. void showExportersPanel() { showProjectPanel (2); }
  70. void showProjectSettings();
  71. void showCurrentExporterSettings();
  72. void showExporterSettings (const String& exporterName);
  73. void showModule (const String& moduleID);
  74. void showLiveBuildSettings();
  75. void showUserSettings();
  76. void deleteSelectedTreeItems();
  77. void refreshProjectTreeFileStatuses();
  78. void updateMissingFileStatuses();
  79. void createProjectTabs();
  80. void deleteProjectTabs();
  81. void rebuildProjectTabs();
  82. void refreshTabsIfBuildStatusChanged();
  83. void toggleWarnings();
  84. void showNextError();
  85. void showPreviousError();
  86. void reinstantiateLivePreviewWindows();
  87. void showBubbleMessage (Rectangle<int>, const String&);
  88. StringArray getExportersWhichCanLaunch() const;
  89. static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails&,
  90. OwnedArray<Project::Item>& selectedNodes);
  91. //==============================================================================
  92. void killChildProcess();
  93. void cleanAll();
  94. void handleMissingSystemHeaders();
  95. bool isBuildTabEnabled() const;
  96. void setBuildEnabled (bool enabled, bool displayError = false);
  97. bool isBuildEnabled() const;
  98. bool areWarningsEnabled() const;
  99. //==============================================================================
  100. ApplicationCommandTarget* getNextCommandTarget() override;
  101. void getAllCommands (Array<CommandID>&) override;
  102. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  103. bool perform (const InvocationInfo&) override;
  104. bool isSaveCommand (const CommandID id);
  105. void paint (Graphics&) override;
  106. void resized() override;
  107. void childBoundsChanged (Component*) override;
  108. void lookAndFeelChanged() override;
  109. String lastCrashMessage;
  110. private:
  111. friend HeaderComponent;
  112. //==============================================================================
  113. Project* project = nullptr;
  114. OpenDocumentManager::Document* currentDocument = nullptr;
  115. RecentDocumentList recentDocumentList;
  116. std::unique_ptr<Component> logo, translationTool, contentView, header;
  117. TabbedComponent sidebarTabs { TabbedButtonBar::TabsAtTop };
  118. std::unique_ptr<ResizableEdgeComponent> resizerBar;
  119. ComponentBoundsConstrainer sidebarSizeConstrainer;
  120. BubbleMessageComponent bubbleMessage;
  121. ReferenceCountedObjectPtr<CompileEngineChildProcess> childProcess;
  122. bool isForeground = false;
  123. std::unique_ptr<Label> fileNameLabel;
  124. int lastViewedTab = 0;
  125. //==============================================================================
  126. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  127. void changeListenerCallback (ChangeBroadcaster*) override;
  128. void showTranslationTool();
  129. void globalFocusChanged (Component*) override;
  130. void timerCallback() override;
  131. bool isContinuousRebuildEnabled();
  132. void setContinuousRebuildEnabled (bool b);
  133. void rebuildNow();
  134. void handleCrash (const String& message);
  135. void updateWarningState();
  136. void launchApp();
  137. void killApp();
  138. ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess();
  139. //==============================================================================
  140. void showProjectPanel (const int index);
  141. ProjectTab* getProjectTab();
  142. LiveBuildTab* getLiveBuildTab();
  143. bool canSelectedProjectBeLaunch();
  144. //==============================================================================
  145. struct ContentViewport : public Component
  146. {
  147. ContentViewport (Component* content)
  148. {
  149. addAndMakeVisible (viewport);
  150. viewport.setViewedComponent (content, true);
  151. }
  152. void resized() override
  153. {
  154. viewport.setBounds (getLocalBounds());
  155. }
  156. Viewport viewport;
  157. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ContentViewport)
  158. };
  159. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  160. };