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.

187 lines
6.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "jucer_Project.h"
  21. #include "../Application/jucer_OpenDocumentManager.h"
  22. class CompileEngineChildProcess;
  23. class ProjectTab;
  24. class LiveBuildTab;
  25. class HeaderComponent;
  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();
  38. Project* getProject() const noexcept { return project; }
  39. virtual 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. bool setEditorComponent (Component* editor, OpenDocumentManager::Document* doc);
  54. Component* getEditorComponent() const { return contentView; }
  55. Component& getSidebarComponent() { return sidebarTabs; }
  56. bool goToPreviousFile();
  57. bool goToNextFile();
  58. bool canGoToCounterpart() const;
  59. bool goToCounterpart();
  60. bool saveProject (bool shouldWait = false);
  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 updateMissingFileStatuses();
  78. void createProjectTabs();
  79. void deleteProjectTabs();
  80. void rebuildProjectTabs();
  81. void refreshTabsIfBuildStatusChanged();
  82. void toggleWarnings();
  83. void showNextError();
  84. void showPreviousError();
  85. void reinstantiateLivePreviewWindows();
  86. void showBubbleMessage (Rectangle<int>, const String&);
  87. StringArray getExportersWhichCanLaunch() const;
  88. static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails&,
  89. OwnedArray<Project::Item>& selectedNodes);
  90. //==============================================================================
  91. void killChildProcess();
  92. void cleanAll();
  93. void handleMissingSystemHeaders();
  94. bool isBuildTabEnabled() const;
  95. void setBuildEnabled (bool);
  96. bool isBuildEnabled() const;
  97. bool areWarningsEnabled() const;
  98. //==============================================================================
  99. ApplicationCommandTarget* getNextCommandTarget() override;
  100. void getAllCommands (Array<CommandID>&) override;
  101. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  102. bool perform (const InvocationInfo&) override;
  103. void paint (Graphics&) override;
  104. void resized() override;
  105. void childBoundsChanged (Component*) override;
  106. void lookAndFeelChanged() override;
  107. String lastCrashMessage;
  108. private:
  109. friend HeaderComponent;
  110. //==============================================================================
  111. Project* project;
  112. OpenDocumentManager::Document* currentDocument;
  113. RecentDocumentList recentDocumentList;
  114. ScopedPointer<Component> logo, translationTool, contentView, header;
  115. TabbedComponent sidebarTabs;
  116. ScopedPointer<ResizableEdgeComponent> resizerBar;
  117. ComponentBoundsConstrainer sidebarSizeConstrainer;
  118. BubbleMessageComponent bubbleMessage;
  119. ReferenceCountedObjectPtr<CompileEngineChildProcess> childProcess;
  120. bool isForeground = false;
  121. ScopedPointer<Label> fileNameLabel;
  122. int lastViewedTab = 0;
  123. //==============================================================================
  124. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  125. void changeListenerCallback (ChangeBroadcaster*) override;
  126. void showTranslationTool();
  127. void globalFocusChanged (Component*) override;
  128. void timerCallback() override;
  129. bool isContinuousRebuildEnabled();
  130. void setContinuousRebuildEnabled (bool b);
  131. void rebuildNow();
  132. void handleCrash (const String& message);
  133. void updateWarningState();
  134. void launchApp();
  135. void killApp();
  136. ReferenceCountedObjectPtr<CompileEngineChildProcess> getChildProcess();
  137. //==============================================================================
  138. void showProjectPanel (const int index);
  139. ProjectTab* getProjectTab();
  140. LiveBuildTab* getLiveBuildTab();
  141. bool canSelectedProjectBeLaunch();
  142. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  143. };