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.

151 lines
5.5KB

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