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.

155 lines
5.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - 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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-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 Sidebar;
  24. struct WizardHolder;
  25. //==============================================================================
  26. class ProjectContentComponent final : public Component,
  27. public ApplicationCommandTarget,
  28. private ChangeListener,
  29. private OpenDocumentManager::DocumentCloseListener
  30. {
  31. public:
  32. //==============================================================================
  33. ProjectContentComponent();
  34. ~ProjectContentComponent() override;
  35. Project* getProject() const noexcept { return project; }
  36. void setProject (Project*);
  37. void saveOpenDocumentList();
  38. void reloadLastOpenDocuments();
  39. bool showEditorForFile (const File&, bool grabFocus);
  40. bool hasFileInRecentList (const File&) const;
  41. File getCurrentFile() const;
  42. bool showDocument (OpenDocumentManager::Document*, bool grabFocus);
  43. void hideDocument (OpenDocumentManager::Document*);
  44. OpenDocumentManager::Document* getCurrentDocument() const { return currentDocument; }
  45. void closeDocument();
  46. void saveDocumentAsync();
  47. void saveAsAsync();
  48. void hideEditor();
  49. void setScrollableEditorComponent (std::unique_ptr<Component> component);
  50. void setEditorDocument (std::unique_ptr<Component> component, OpenDocumentManager::Document* doc);
  51. Component* getEditorComponent();
  52. Component& getSidebarComponent();
  53. bool goToPreviousFile();
  54. bool goToNextFile();
  55. bool canGoToCounterpart() const;
  56. bool goToCounterpart();
  57. void saveProjectAsync();
  58. void closeProject();
  59. void openInSelectedIDE (bool saveFirst);
  60. void showNewExporterMenu();
  61. void showFilesPanel() { showProjectPanel (0); }
  62. void showModulesPanel() { showProjectPanel (1); }
  63. void showExportersPanel() { showProjectPanel (2); }
  64. void showProjectSettings();
  65. void showCurrentExporterSettings();
  66. void showExporterSettings (const String& exporterName);
  67. void showModule (const String& moduleID);
  68. void showUserSettings();
  69. void deleteSelectedTreeItems();
  70. void refreshProjectTreeFileStatuses();
  71. void updateMissingFileStatuses();
  72. void addNewGUIFile();
  73. void showBubbleMessage (Rectangle<int>, const String&);
  74. StringArray getExportersWhichCanLaunch() const;
  75. static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails&,
  76. OwnedArray<Project::Item>& selectedNodes);
  77. //==============================================================================
  78. ApplicationCommandTarget* getNextCommandTarget() override;
  79. void getAllCommands (Array<CommandID>&) override;
  80. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  81. bool perform (const InvocationInfo&) override;
  82. bool isSaveCommand (CommandID);
  83. void paint (Graphics&) override;
  84. void resized() override;
  85. void childBoundsChanged (Component*) override;
  86. void lookAndFeelChanged() override;
  87. ProjectMessagesComponent& getProjectMessagesComponent() { return projectMessagesComponent; }
  88. static String getProjectTabName() { return "Project"; }
  89. private:
  90. //==============================================================================
  91. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  92. void changeListenerCallback (ChangeBroadcaster*) override;
  93. void showTranslationTool();
  94. //==============================================================================
  95. void showProjectPanel (int index);
  96. bool canSelectedProjectBeLaunch();
  97. //==============================================================================
  98. Project* project = nullptr;
  99. OpenDocumentManager::Document* currentDocument = nullptr;
  100. RecentDocumentList recentDocumentList;
  101. HeaderComponent headerComponent { this };
  102. std::unique_ptr<Sidebar> sidebar;
  103. ProjectMessagesComponent projectMessagesComponent;
  104. ContentViewComponent contentViewComponent;
  105. std::unique_ptr<ResizableEdgeComponent> resizerBar;
  106. ComponentBoundsConstrainer sidebarSizeConstrainer;
  107. std::unique_ptr<Component> translationTool;
  108. BubbleMessageComponent bubbleMessage;
  109. bool isForeground = false;
  110. int lastViewedTab = 0;
  111. std::unique_ptr<WizardHolder> wizardHolder;
  112. ScopedMessageBox messageBox;
  113. //==============================================================================
  114. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  115. };