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.

137 lines
4.6KB

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