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.

184 lines
6.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #pragma once
  18. #include "jucer_Project.h"
  19. #include "../Application/jucer_OpenDocumentManager.h"
  20. class CompileEngineChildProcess;
  21. class ProjectTab;
  22. class LiveBuildTab;
  23. class HeaderComponent;
  24. //==============================================================================
  25. class ProjectContentComponent : public Component,
  26. public ApplicationCommandTarget,
  27. private ChangeListener,
  28. private OpenDocumentManager::DocumentCloseListener,
  29. private FocusChangeListener,
  30. private Timer
  31. {
  32. public:
  33. //==============================================================================
  34. ProjectContentComponent();
  35. ~ProjectContentComponent();
  36. Project* getProject() const noexcept { return project; }
  37. virtual void setProject (Project*);
  38. void saveTreeViewState();
  39. void saveOpenDocumentList();
  40. void reloadLastOpenDocuments();
  41. bool showEditorForFile (const File&, bool grabFocus);
  42. bool hasFileInRecentList (const File&) const;
  43. File getCurrentFile() const;
  44. bool showDocument (OpenDocumentManager::Document*, bool grabFocus);
  45. void hideDocument (OpenDocumentManager::Document*);
  46. OpenDocumentManager::Document* getCurrentDocument() const { return currentDocument; }
  47. void closeDocument();
  48. void saveDocument();
  49. void saveAs();
  50. void hideEditor();
  51. bool setEditorComponent (Component* editor, OpenDocumentManager::Document* doc);
  52. Component* getEditorComponent() const { return contentView; }
  53. Component& getSidebarComponent() { return sidebarTabs; }
  54. bool goToPreviousFile();
  55. bool goToNextFile();
  56. bool canGoToCounterpart() const;
  57. bool goToCounterpart();
  58. bool saveProject();
  59. void closeProject();
  60. void openInSelectedIDE (bool saveFirst);
  61. void showNewExporterMenu();
  62. void showProjectTab() { sidebarTabs.setCurrentTabIndex (0); }
  63. void showBuildTab() { sidebarTabs.setCurrentTabIndex (1); }
  64. void showFilesPanel() { showProjectPanel (0); }
  65. void showModulesPanel() { showProjectPanel (1); }
  66. void showExportersPanel() { showProjectPanel (2); }
  67. void showProjectSettings();
  68. void showCurrentExporterSettings();
  69. void showExporterSettings (const String& exporterName);
  70. void showModule (const String& moduleID);
  71. void showLiveBuildSettings();
  72. void showUserSettings();
  73. void deleteSelectedTreeItems();
  74. void updateMissingFileStatuses();
  75. void createProjectTabs();
  76. void deleteProjectTabs();
  77. void rebuildProjectTabs();
  78. void refreshTabsIfBuildStatusChanged();
  79. void toggleWarnings();
  80. void showNextError();
  81. void showPreviousError();
  82. void reinstantiateLivePreviewWindows();
  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);
  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. void paint (Graphics&) override;
  101. void resized() override;
  102. void childBoundsChanged (Component*) override;
  103. void lookAndFeelChanged() override;
  104. String lastCrashMessage;
  105. private:
  106. friend HeaderComponent;
  107. //==============================================================================
  108. Project* project;
  109. OpenDocumentManager::Document* currentDocument;
  110. RecentDocumentList recentDocumentList;
  111. ScopedPointer<Component> logo, translationTool, contentView, header;
  112. TabbedComponent sidebarTabs;
  113. ScopedPointer<ResizableEdgeComponent> resizerBar;
  114. ComponentBoundsConstrainer sidebarSizeConstrainer;
  115. BubbleMessageComponent bubbleMessage;
  116. ReferenceCountedObjectPtr<CompileEngineChildProcess> childProcess;
  117. bool isForeground = false;
  118. ScopedPointer<Label> fileNameLabel;
  119. int lastViewedTab = 0;
  120. //==============================================================================
  121. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  122. void changeListenerCallback (ChangeBroadcaster*) override;
  123. void showTranslationTool();
  124. void globalFocusChanged (Component*) override;
  125. void timerCallback() override;
  126. bool isContinuousRebuildEnabled();
  127. void setContinuousRebuildEnabled (bool b);
  128. void rebuildNow();
  129. void handleCrash (const String& message);
  130. void updateWarningState();
  131. void launchApp();
  132. void killApp();
  133. ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess();
  134. //==============================================================================
  135. void showProjectPanel (const int index);
  136. ProjectTab* getProjectTab();
  137. LiveBuildTab* getLiveBuildTab();
  138. bool canSelectedProjectBeLaunch();
  139. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  140. };