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.

147 lines
5.4KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 7 technical preview.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For the technical preview this file cannot be licensed commercially.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #pragma once
  14. #include "../../CodeEditor/jucer_OpenDocumentManager.h"
  15. #include "jucer_HeaderComponent.h"
  16. #include "jucer_ProjectMessagesComponent.h"
  17. #include "jucer_ContentViewComponent.h"
  18. class Sidebar;
  19. struct WizardHolder;
  20. //==============================================================================
  21. class ProjectContentComponent : public Component,
  22. public ApplicationCommandTarget,
  23. private ChangeListener,
  24. private OpenDocumentManager::DocumentCloseListener
  25. {
  26. public:
  27. //==============================================================================
  28. ProjectContentComponent();
  29. ~ProjectContentComponent() override;
  30. Project* getProject() const noexcept { return project; }
  31. void setProject (Project*);
  32. void saveOpenDocumentList();
  33. void reloadLastOpenDocuments();
  34. bool showEditorForFile (const File&, bool grabFocus);
  35. bool hasFileInRecentList (const File&) const;
  36. File getCurrentFile() const;
  37. bool showDocument (OpenDocumentManager::Document*, bool grabFocus);
  38. void hideDocument (OpenDocumentManager::Document*);
  39. OpenDocumentManager::Document* getCurrentDocument() const { return currentDocument; }
  40. void closeDocument();
  41. void saveDocumentAsync();
  42. void saveAsAsync();
  43. void hideEditor();
  44. void setScrollableEditorComponent (std::unique_ptr<Component> component);
  45. void setEditorDocument (std::unique_ptr<Component> component, OpenDocumentManager::Document* doc);
  46. Component* getEditorComponent();
  47. Component& getSidebarComponent();
  48. bool goToPreviousFile();
  49. bool goToNextFile();
  50. bool canGoToCounterpart() const;
  51. bool goToCounterpart();
  52. void saveProjectAsync();
  53. void closeProject();
  54. void openInSelectedIDE (bool saveFirst);
  55. void showNewExporterMenu();
  56. void showFilesPanel() { showProjectPanel (0); }
  57. void showModulesPanel() { showProjectPanel (1); }
  58. void showExportersPanel() { showProjectPanel (2); }
  59. void showProjectSettings();
  60. void showCurrentExporterSettings();
  61. void showExporterSettings (const String& exporterName);
  62. void showModule (const String& moduleID);
  63. void showUserSettings();
  64. void deleteSelectedTreeItems();
  65. void refreshProjectTreeFileStatuses();
  66. void updateMissingFileStatuses();
  67. void addNewGUIFile();
  68. void showBubbleMessage (Rectangle<int>, const String&);
  69. StringArray getExportersWhichCanLaunch() const;
  70. static void getSelectedProjectItemsBeingDragged (const DragAndDropTarget::SourceDetails&,
  71. OwnedArray<Project::Item>& selectedNodes);
  72. //==============================================================================
  73. ApplicationCommandTarget* getNextCommandTarget() override;
  74. void getAllCommands (Array<CommandID>&) override;
  75. void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
  76. bool perform (const InvocationInfo&) override;
  77. bool isSaveCommand (const CommandID id);
  78. void paint (Graphics&) override;
  79. void resized() override;
  80. void childBoundsChanged (Component*) override;
  81. void lookAndFeelChanged() override;
  82. ProjectMessagesComponent& getProjectMessagesComponent() { return projectMessagesComponent; }
  83. static String getProjectTabName() { return "Project"; }
  84. private:
  85. //==============================================================================
  86. bool documentAboutToClose (OpenDocumentManager::Document*) override;
  87. void changeListenerCallback (ChangeBroadcaster*) override;
  88. void showTranslationTool();
  89. //==============================================================================
  90. void showProjectPanel (const int index);
  91. bool canSelectedProjectBeLaunch();
  92. //==============================================================================
  93. Project* project = nullptr;
  94. OpenDocumentManager::Document* currentDocument = nullptr;
  95. RecentDocumentList recentDocumentList;
  96. HeaderComponent headerComponent { this };
  97. std::unique_ptr<Sidebar> sidebar;
  98. ProjectMessagesComponent projectMessagesComponent;
  99. ContentViewComponent contentViewComponent;
  100. std::unique_ptr<ResizableEdgeComponent> resizerBar;
  101. ComponentBoundsConstrainer sidebarSizeConstrainer;
  102. std::unique_ptr<Component> translationTool;
  103. BubbleMessageComponent bubbleMessage;
  104. bool isForeground = false;
  105. int lastViewedTab = 0;
  106. std::unique_ptr<WizardHolder> wizardHolder;
  107. //==============================================================================
  108. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjectContentComponent)
  109. };