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.

211 lines
7.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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. #include "jucer_HeaderComponent.h"
  16. #include "jucer_ProjectMessagesComponent.h"
  17. class CompileEngineChildProcess;
  18. class ProjectTab;
  19. class LiveBuildTab;
  20. //==============================================================================
  21. class ProjectContentComponent : public Component,
  22. public ApplicationCommandTarget,
  23. private ChangeListener,
  24. private OpenDocumentManager::DocumentCloseListener,
  25. private FocusChangeListener,
  26. private Timer
  27. {
  28. public:
  29. //==============================================================================
  30. ProjectContentComponent();
  31. ~ProjectContentComponent() override;
  32. Project* getProject() const noexcept { return project; }
  33. void setProject (Project*);
  34. void saveTreeViewState();
  35. void saveOpenDocumentList();
  36. void reloadLastOpenDocuments();
  37. bool showEditorForFile (const File&, bool grabFocus);
  38. bool hasFileInRecentList (const File&) const;
  39. File getCurrentFile() const;
  40. bool showDocument (OpenDocumentManager::Document*, bool grabFocus);
  41. void hideDocument (OpenDocumentManager::Document*);
  42. OpenDocumentManager::Document* getCurrentDocument() const { return currentDocument; }
  43. void closeDocument();
  44. void saveDocument();
  45. void saveAs();
  46. void hideEditor();
  47. bool setEditorComponent (Component* editor, OpenDocumentManager::Document* doc);
  48. Component* getEditorComponentContent() const;
  49. Component* getEditorComponent() const { return contentView.get(); }
  50. Component& getSidebarComponent() { return sidebarTabs; }
  51. bool goToPreviousFile();
  52. bool goToNextFile();
  53. bool canGoToCounterpart() const;
  54. bool goToCounterpart();
  55. bool saveProject();
  56. void closeProject();
  57. void openInSelectedIDE (bool saveFirst);
  58. void showNewExporterMenu();
  59. void showProjectTab() { sidebarTabs.setCurrentTabIndex (0); }
  60. void showBuildTab() { sidebarTabs.setCurrentTabIndex (1); }
  61. int getCurrentTabIndex() { return sidebarTabs.getCurrentTabIndex(); }
  62. void showFilesPanel() { showProjectPanel (0); }
  63. void showModulesPanel() { showProjectPanel (1); }
  64. void showExportersPanel() { showProjectPanel (2); }
  65. void showProjectSettings();
  66. void showCurrentExporterSettings();
  67. void showExporterSettings (const String& exporterName);
  68. void showModule (const String& moduleID);
  69. void showLiveBuildSettings();
  70. void showUserSettings();
  71. void deleteSelectedTreeItems();
  72. void refreshProjectTreeFileStatuses();
  73. void updateMissingFileStatuses();
  74. void createProjectTabs();
  75. void deleteProjectTabs();
  76. void rebuildProjectUI();
  77. void refreshTabsIfBuildStatusChanged();
  78. void toggleWarnings();
  79. void showNextError();
  80. void showPreviousError();
  81. void reinstantiateLivePreviewWindows();
  82. void addNewGUIFile();
  83. void showBubbleMessage (Rectangle<int>, const String&);
  84. StringArray getExportersWhichCanLaunch() const;
  85. static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails&,
  86. OwnedArray<Project::Item>& selectedNodes);
  87. //==============================================================================
  88. void killChildProcess();
  89. void cleanAll();
  90. void handleMissingSystemHeaders();
  91. bool isBuildTabEnabled() const;
  92. void setBuildEnabled (bool enabled, bool displayError = false);
  93. bool isBuildEnabled() const;
  94. bool areWarningsEnabled() const;
  95. //==============================================================================
  96. ApplicationCommandTarget* getNextCommandTarget() override;
  97. void getAllCommands (Array<CommandID>&) override;
  98. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  99. bool perform (const InvocationInfo&) override;
  100. bool isSaveCommand (const CommandID id);
  101. void paint (Graphics&) override;
  102. void resized() override;
  103. void childBoundsChanged (Component*) override;
  104. void lookAndFeelChanged() override;
  105. ProjectMessagesComponent& getProjectMessagesComponent() { return projectMessagesComponent; }
  106. static String getProjectTabName() { return "Project"; }
  107. static String getBuildTabName() { return "Build"; }
  108. private:
  109. //==============================================================================
  110. struct LogoComponent : public Component
  111. {
  112. LogoComponent();
  113. void paint (Graphics& g) override;
  114. static String getVersionInfo();
  115. std::unique_ptr<Drawable> logo;
  116. };
  117. struct ContentViewport : public Component
  118. {
  119. ContentViewport (Component* content);
  120. void resized() override;
  121. Viewport viewport;
  122. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ContentViewport)
  123. };
  124. //==============================================================================
  125. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  126. void changeListenerCallback (ChangeBroadcaster*) override;
  127. void showTranslationTool();
  128. void globalFocusChanged (Component*) override;
  129. void timerCallback() override;
  130. void liveBuildEnablementChanged (bool isEnabled);
  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. Project* project = nullptr;
  146. OpenDocumentManager::Document* currentDocument = nullptr;
  147. RecentDocumentList recentDocumentList;
  148. LogoComponent logoComponent;
  149. HeaderComponent headerComponent { this };
  150. ProjectMessagesComponent projectMessagesComponent;
  151. Label fileNameLabel;
  152. TabbedComponent sidebarTabs { TabbedButtonBar::TabsAtTop };
  153. std::unique_ptr<ResizableEdgeComponent> resizerBar;
  154. ComponentBoundsConstrainer sidebarSizeConstrainer;
  155. std::unique_ptr<Component> translationTool, contentView;
  156. BubbleMessageComponent bubbleMessage;
  157. ReferenceCountedObjectPtr<CompileEngineChildProcess> childProcess;
  158. String lastCrashMessage;
  159. bool isForeground = false, isLiveBuildEnabled = false;
  160. int lastViewedTab = 0;
  161. //==============================================================================
  162. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  163. };