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.

201 lines
7.1KB

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