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.

218 lines
7.9KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. #include "../../CodeEditor/jucer_OpenDocumentManager.h"
  20. #include "jucer_HeaderComponent.h"
  21. #include "jucer_ProjectMessagesComponent.h"
  22. class CompileEngineChildProcess;
  23. class ProjectTab;
  24. class LiveBuildTab;
  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() override;
  37. Project* getProject() const noexcept { return project; }
  38. 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();
  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 rebuildProjectUI();
  82. void refreshTabsIfBuildStatusChanged();
  83. void toggleWarnings();
  84. void showNextError();
  85. void showPreviousError();
  86. void reinstantiateLivePreviewWindows();
  87. void addNewGUIFile();
  88. void showBubbleMessage (Rectangle<int>, const String&);
  89. StringArray getExportersWhichCanLaunch() const;
  90. static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails&,
  91. OwnedArray<Project::Item>& selectedNodes);
  92. //==============================================================================
  93. void killChildProcess();
  94. void cleanAll();
  95. void handleMissingSystemHeaders();
  96. bool isBuildTabEnabled() const;
  97. void setBuildEnabled (bool enabled, bool displayError = false);
  98. bool isBuildEnabled() const;
  99. bool areWarningsEnabled() const;
  100. //==============================================================================
  101. ApplicationCommandTarget* getNextCommandTarget() override;
  102. void getAllCommands (Array<CommandID>&) override;
  103. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  104. bool perform (const InvocationInfo&) override;
  105. bool isSaveCommand (const CommandID id);
  106. void paint (Graphics&) override;
  107. void resized() override;
  108. void childBoundsChanged (Component*) override;
  109. void lookAndFeelChanged() override;
  110. ProjectMessagesComponent& getProjectMessagesComponent() { return projectMessagesComponent; }
  111. static String getProjectTabName() { return "Project"; }
  112. static String getBuildTabName() { return "Build"; }
  113. private:
  114. //==============================================================================
  115. struct LogoComponent : public Component
  116. {
  117. LogoComponent();
  118. void paint (Graphics& g) override;
  119. static String getVersionInfo();
  120. std::unique_ptr<Drawable> logo;
  121. };
  122. struct ContentViewport : public Component
  123. {
  124. ContentViewport (Component* content);
  125. void resized() override;
  126. Viewport viewport;
  127. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ContentViewport)
  128. };
  129. //==============================================================================
  130. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  131. void changeListenerCallback (ChangeBroadcaster*) override;
  132. void showTranslationTool();
  133. void globalFocusChanged (Component*) override;
  134. void timerCallback() override;
  135. void liveBuildEnablementChanged (bool isEnabled);
  136. bool isContinuousRebuildEnabled();
  137. void setContinuousRebuildEnabled (bool b);
  138. void rebuildNow();
  139. void handleCrash (const String& message);
  140. void updateWarningState();
  141. void launchApp();
  142. void killApp();
  143. ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess();
  144. //==============================================================================
  145. void showProjectPanel (const int index);
  146. ProjectTab* getProjectTab();
  147. LiveBuildTab* getLiveBuildTab();
  148. bool canSelectedProjectBeLaunch();
  149. //==============================================================================
  150. Project* project = nullptr;
  151. OpenDocumentManager::Document* currentDocument = nullptr;
  152. RecentDocumentList recentDocumentList;
  153. LogoComponent logoComponent;
  154. HeaderComponent headerComponent { this };
  155. ProjectMessagesComponent projectMessagesComponent;
  156. Label fileNameLabel;
  157. TabbedComponent sidebarTabs { TabbedButtonBar::TabsAtTop };
  158. std::unique_ptr<ResizableEdgeComponent> resizerBar;
  159. ComponentBoundsConstrainer sidebarSizeConstrainer;
  160. std::unique_ptr<Component> translationTool, contentView;
  161. BubbleMessageComponent bubbleMessage;
  162. ReferenceCountedObjectPtr<CompileEngineChildProcess> childProcess;
  163. String lastCrashMessage;
  164. bool isForeground = false, isLiveBuildEnabled = false;
  165. int lastViewedTab = 0;
  166. //==============================================================================
  167. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  168. };