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.

132 lines
4.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "../Project/UI/jucer_ProjectContentComponent.h"
  21. #include "../Utility/PIPs/jucer_PIPGenerator.h"
  22. //==============================================================================
  23. /**
  24. The big top-level window where everything happens.
  25. */
  26. class MainWindow : public DocumentWindow,
  27. public ApplicationCommandTarget,
  28. public FileDragAndDropTarget,
  29. public DragAndDropContainer,
  30. private Value::Listener
  31. {
  32. public:
  33. //==============================================================================
  34. MainWindow();
  35. ~MainWindow() override;
  36. //==============================================================================
  37. void closeButtonPressed() override;
  38. //==============================================================================
  39. bool canOpenFile (const File& file) const;
  40. bool openFile (const File& file);
  41. void setProject (Project* newProject);
  42. Project* getProject() const { return currentProject.get(); }
  43. bool tryToOpenPIP (const File& f);
  44. void makeVisible();
  45. void restoreWindowPosition();
  46. bool closeProject (Project* project, bool askToSave = true);
  47. bool closeCurrentProject();
  48. void moveProject (File newProjectFile);
  49. void showStartPage();
  50. bool isInterestedInFileDrag (const StringArray& files) override;
  51. void filesDropped (const StringArray& filenames, int mouseX, int mouseY) override;
  52. void activeWindowStatusChanged() override;
  53. ProjectContentComponent* getProjectContentComponent() const;
  54. //==============================================================================
  55. ApplicationCommandTarget* getNextCommandTarget() override;
  56. void getAllCommands (Array <CommandID>& commands) override;
  57. void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) override;
  58. bool perform (const InvocationInfo& info) override;
  59. bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
  60. StringArray& files, bool& canMoveFiles) override;
  61. private:
  62. std::unique_ptr<Project> currentProject;
  63. Value projectNameValue;
  64. static const char* getProjectWindowPosName() { return "projectWindowPos"; }
  65. void createProjectContentCompIfNeeded();
  66. void setTitleBarIcon();
  67. void openPIP (PIPGenerator&);
  68. void valueChanged (Value&) override;
  69. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  70. };
  71. //==============================================================================
  72. class MainWindowList
  73. {
  74. public:
  75. MainWindowList();
  76. void forceCloseAllWindows();
  77. bool askAllWindowsToClose();
  78. void closeWindow (MainWindow*);
  79. void goToSiblingWindow (MainWindow*, int delta);
  80. void createWindowIfNoneAreOpen();
  81. void openDocument (OpenDocumentManager::Document*, bool grabFocus);
  82. bool openFile (const File& file, bool openInBackground = false);
  83. MainWindow* createNewMainWindow();
  84. MainWindow* getFrontmostWindow (bool createIfNotFound = true);
  85. MainWindow* getOrCreateEmptyWindow();
  86. MainWindow* getMainWindowForFile (const File&);
  87. Project* getFrontmostProject();
  88. void reopenLastProjects();
  89. void saveCurrentlyOpenProjectList();
  90. void avoidSuperimposedWindows (MainWindow*);
  91. void sendLookAndFeelChange();
  92. OwnedArray<MainWindow> windows;
  93. private:
  94. bool isInReopenLastProjects = false;
  95. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindowList)
  96. };