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.

146 lines
4.9KB

  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 "../Utility/PIPs/jucer_PIPGenerator.h"
  20. #include "../Project/jucer_Project.h"
  21. #include "../CodeEditor/jucer_OpenDocumentManager.h"
  22. class ProjectContentComponent;
  23. //==============================================================================
  24. /**
  25. The big top-level window where everything happens.
  26. */
  27. class MainWindow : public DocumentWindow,
  28. public ApplicationCommandTarget,
  29. public FileDragAndDropTarget,
  30. public DragAndDropContainer,
  31. private Value::Listener
  32. {
  33. public:
  34. //==============================================================================
  35. MainWindow();
  36. ~MainWindow() override;
  37. enum class OpenInIDE { no, yes };
  38. //==============================================================================
  39. void closeButtonPressed() override;
  40. //==============================================================================
  41. bool canOpenFile (const File& file) const;
  42. bool openFile (const File& file);
  43. void setProject (std::unique_ptr<Project> newProject);
  44. Project* getProject() const { return currentProject.get(); }
  45. void makeVisible();
  46. void restoreWindowPosition();
  47. void updateTitleBarIcon();
  48. bool closeCurrentProject (OpenDocumentManager::SaveIfNeeded askToSave);
  49. void moveProject (File newProjectFile, OpenInIDE openInIDE);
  50. void showStartPage();
  51. void showLoginFormOverlay();
  52. void hideLoginFormOverlay();
  53. bool isShowingLoginForm() const noexcept { return loginFormOpen; }
  54. bool isInterestedInFileDrag (const StringArray& files) override;
  55. void filesDropped (const StringArray& filenames, int mouseX, int mouseY) override;
  56. void activeWindowStatusChanged() override;
  57. ProjectContentComponent* getProjectContentComponent() const;
  58. //==============================================================================
  59. ApplicationCommandTarget* getNextCommandTarget() override;
  60. void getAllCommands (Array <CommandID>& commands) override;
  61. void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) override;
  62. bool perform (const InvocationInfo& info) override;
  63. bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
  64. StringArray& files, bool& canMoveFiles) override;
  65. private:
  66. void valueChanged (Value&) override;
  67. static const char* getProjectWindowPosName() { return "projectWindowPos"; }
  68. void createProjectContentCompIfNeeded();
  69. bool openPIP (PIPGenerator);
  70. void setupTemporaryPIPProject (PIPGenerator&);
  71. void initialiseProjectWindow();
  72. std::unique_ptr<Project> currentProject;
  73. Value projectNameValue;
  74. std::unique_ptr<Component> blurOverlayComponent;
  75. bool loginFormOpen = false;
  76. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  77. };
  78. //==============================================================================
  79. class MainWindowList
  80. {
  81. public:
  82. MainWindowList();
  83. void forceCloseAllWindows();
  84. bool askAllWindowsToClose();
  85. void closeWindow (MainWindow*);
  86. void goToSiblingWindow (MainWindow*, int delta);
  87. void createWindowIfNoneAreOpen();
  88. void openDocument (OpenDocumentManager::Document*, bool grabFocus);
  89. bool openFile (const File& file, bool openInBackground = false);
  90. MainWindow* createNewMainWindow();
  91. MainWindow* getFrontmostWindow (bool createIfNotFound = true);
  92. MainWindow* getOrCreateEmptyWindow();
  93. MainWindow* getMainWindowForFile (const File&);
  94. MainWindow* getMainWindowWithLoginFormOpen();
  95. Project* getFrontmostProject();
  96. void reopenLastProjects();
  97. void saveCurrentlyOpenProjectList();
  98. void checkWindowBounds (MainWindow&);
  99. void sendLookAndFeelChange();
  100. OwnedArray<MainWindow> windows;
  101. private:
  102. bool isInReopenLastProjects = false;
  103. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindowList)
  104. };