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.

205 lines
7.2KB

  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* getEditorComponent() const { return contentView; }
  54. Component& getSidebarComponent() { return sidebarTabs; }
  55. bool goToPreviousFile();
  56. bool goToNextFile();
  57. bool canGoToCounterpart() const;
  58. bool goToCounterpart();
  59. bool saveProject (bool shouldWait = false);
  60. void closeProject();
  61. void openInSelectedIDE (bool saveFirst);
  62. void showNewExporterMenu();
  63. void showProjectTab() { sidebarTabs.setCurrentTabIndex (0); }
  64. void showBuildTab() { sidebarTabs.setCurrentTabIndex (1); }
  65. int getCurrentTabIndex() { return sidebarTabs.getCurrentTabIndex(); }
  66. void showFilesPanel() { showProjectPanel (0); }
  67. void showModulesPanel() { showProjectPanel (1); }
  68. void showExportersPanel() { showProjectPanel (2); }
  69. void showProjectSettings();
  70. void showCurrentExporterSettings();
  71. void showExporterSettings (const String& exporterName);
  72. void showModule (const String& moduleID);
  73. void showLiveBuildSettings();
  74. void showUserSettings();
  75. void deleteSelectedTreeItems();
  76. void updateMissingFileStatuses();
  77. void createProjectTabs();
  78. void deleteProjectTabs();
  79. void rebuildProjectTabs();
  80. void refreshTabsIfBuildStatusChanged();
  81. void toggleWarnings();
  82. void showNextError();
  83. void showPreviousError();
  84. void reinstantiateLivePreviewWindows();
  85. void showBubbleMessage (Rectangle<int>, const String&);
  86. StringArray getExportersWhichCanLaunch() const;
  87. static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails&,
  88. OwnedArray<Project::Item>& selectedNodes);
  89. //==============================================================================
  90. void killChildProcess();
  91. void cleanAll();
  92. void handleMissingSystemHeaders();
  93. bool isBuildTabEnabled() const;
  94. void setBuildEnabled (bool enabled, bool displayError = false);
  95. bool isBuildEnabled() const;
  96. bool areWarningsEnabled() const;
  97. //==============================================================================
  98. ApplicationCommandTarget* getNextCommandTarget() override;
  99. void getAllCommands (Array<CommandID>&) override;
  100. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  101. bool perform (const InvocationInfo&) override;
  102. void paint (Graphics&) override;
  103. void resized() override;
  104. void childBoundsChanged (Component*) override;
  105. void lookAndFeelChanged() override;
  106. String lastCrashMessage;
  107. private:
  108. friend HeaderComponent;
  109. //==============================================================================
  110. Project* project;
  111. OpenDocumentManager::Document* currentDocument;
  112. RecentDocumentList recentDocumentList;
  113. ScopedPointer<Component> logo, translationTool, contentView, header;
  114. TabbedComponent sidebarTabs;
  115. ScopedPointer<ResizableEdgeComponent> resizerBar;
  116. ComponentBoundsConstrainer sidebarSizeConstrainer;
  117. BubbleMessageComponent bubbleMessage;
  118. ReferenceCountedObjectPtr<CompileEngineChildProcess> childProcess;
  119. bool isForeground = false;
  120. ScopedPointer<Label> fileNameLabel;
  121. int lastViewedTab = 0;
  122. //==============================================================================
  123. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  124. void changeListenerCallback (ChangeBroadcaster*) override;
  125. void showTranslationTool();
  126. void globalFocusChanged (Component*) override;
  127. void timerCallback() override;
  128. bool isContinuousRebuildEnabled();
  129. void setContinuousRebuildEnabled (bool b);
  130. void rebuildNow();
  131. void handleCrash (const String& message);
  132. void updateWarningState();
  133. void launchApp();
  134. void killApp();
  135. ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess();
  136. //==============================================================================
  137. void showProjectPanel (const int index);
  138. ProjectTab* getProjectTab();
  139. LiveBuildTab* getLiveBuildTab();
  140. bool canSelectedProjectBeLaunch();
  141. //==============================================================================
  142. struct ContentViewport : public Component
  143. {
  144. ContentViewport (Component* content)
  145. {
  146. addAndMakeVisible (viewport);
  147. viewport.setViewedComponent (content, true);
  148. }
  149. void resized() override
  150. {
  151. viewport.setBounds (getLocalBounds());
  152. }
  153. Viewport viewport;
  154. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ContentViewport)
  155. };
  156. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  157. };