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.

133 lines
4.4KB

  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 (std::unique_ptr<Project> newProject);
  42. Project* getProject() const { return currentProject.get(); }
  43. bool tryToOpenPIP (const File& f);
  44. void makeVisible();
  45. void restoreWindowPosition();
  46. bool closeCurrentProject (bool askToSave);
  47. void moveProject (File newProjectFile);
  48. void showStartPage();
  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. std::unique_ptr<Project> currentProject;
  62. Value projectNameValue;
  63. static const char* getProjectWindowPosName() { return "projectWindowPos"; }
  64. void createProjectContentCompIfNeeded();
  65. void setTitleBarIcon();
  66. void openPIP (PIPGenerator&);
  67. void valueChanged (Value&) override;
  68. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  69. };
  70. //==============================================================================
  71. class MainWindowList
  72. {
  73. public:
  74. MainWindowList();
  75. void forceCloseAllWindows();
  76. bool askAllWindowsToClose();
  77. void closeWindow (MainWindow*);
  78. void goToSiblingWindow (MainWindow*, int delta);
  79. void createWindowIfNoneAreOpen();
  80. void openDocument (OpenDocumentManager::Document*, bool grabFocus);
  81. bool openFile (const File& file, bool openInBackground = false);
  82. MainWindow* createNewMainWindow();
  83. MainWindow* getFrontmostWindow (bool createIfNotFound = true);
  84. MainWindow* getOrCreateEmptyWindow();
  85. MainWindow* getMainWindowForFile (const File&);
  86. Project* getFrontmostProject();
  87. void reopenLastProjects();
  88. void saveCurrentlyOpenProjectList();
  89. void checkWindowBounds (MainWindow&);
  90. void sendLookAndFeelChange();
  91. OwnedArray<MainWindow> windows;
  92. private:
  93. bool isInReopenLastProjects = false;
  94. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindowList)
  95. };