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.

121 lines
4.1KB

  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. //==============================================================================
  22. /**
  23. The big top-level window where everything happens.
  24. */
  25. class MainWindow : public DocumentWindow,
  26. public ApplicationCommandTarget,
  27. public FileDragAndDropTarget,
  28. public DragAndDropContainer,
  29. private Value::Listener
  30. {
  31. public:
  32. //==============================================================================
  33. MainWindow();
  34. ~MainWindow();
  35. //==============================================================================
  36. void closeButtonPressed() override;
  37. //==============================================================================
  38. bool canOpenFile (const File& file) const;
  39. bool openFile (const File& file);
  40. void setProject (Project* newProject);
  41. Project* getProject() const { return currentProject; }
  42. void makeVisible();
  43. void restoreWindowPosition();
  44. bool closeProject (Project* project);
  45. bool closeCurrentProject();
  46. void showNewProjectWizard();
  47. bool isInterestedInFileDrag (const StringArray& files) override;
  48. void filesDropped (const StringArray& filenames, int mouseX, int mouseY) override;
  49. void activeWindowStatusChanged() override;
  50. ProjectContentComponent* getProjectContentComponent() const;
  51. //==============================================================================
  52. ApplicationCommandTarget* getNextCommandTarget() override;
  53. void getAllCommands (Array <CommandID>& commands) override;
  54. void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result) override;
  55. bool perform (const InvocationInfo& info) override;
  56. bool shouldDropFilesWhenDraggedExternally (const DragAndDropTarget::SourceDetails& sourceDetails,
  57. StringArray& files, bool& canMoveFiles) override;
  58. private:
  59. ScopedPointer<Project> currentProject;
  60. Value projectNameValue;
  61. static const char* getProjectWindowPosName() { return "projectWindowPos"; }
  62. void createProjectContentCompIfNeeded();
  63. void valueChanged (Value&) override;
  64. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
  65. };
  66. //==============================================================================
  67. class MainWindowList
  68. {
  69. public:
  70. MainWindowList();
  71. void forceCloseAllWindows();
  72. bool askAllWindowsToClose();
  73. void closeWindow (MainWindow*);
  74. void createWindowIfNoneAreOpen();
  75. void openDocument (OpenDocumentManager::Document*, bool grabFocus);
  76. bool openFile (const File& file);
  77. MainWindow* createNewMainWindow();
  78. MainWindow* getFrontmostWindow (bool createIfNotFound = true);
  79. MainWindow* getOrCreateEmptyWindow();
  80. Project* getFrontmostProject();
  81. void reopenLastProjects();
  82. void saveCurrentlyOpenProjectList();
  83. void avoidSuperimposedWindows (MainWindow*);
  84. void sendLookAndFeelChange();
  85. OwnedArray<MainWindow> windows;
  86. private:
  87. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindowList)
  88. };