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.

125 lines
4.1KB

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