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.

200 lines
7.4KB

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