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.

681 lines
24KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #include <JuceHeader.h>
  19. #include "MainHostWindow.h"
  20. #include "../Plugins/InternalPlugins.h"
  21. //==============================================================================
  22. class MainHostWindow::PluginListWindow : public DocumentWindow
  23. {
  24. public:
  25. PluginListWindow (MainHostWindow& mw, AudioPluginFormatManager& pluginFormatManager)
  26. : DocumentWindow ("Available Plugins",
  27. LookAndFeel::getDefaultLookAndFeel().findColour (ResizableWindow::backgroundColourId),
  28. DocumentWindow::minimiseButton | DocumentWindow::closeButton),
  29. owner (mw)
  30. {
  31. auto deadMansPedalFile = getAppProperties().getUserSettings()
  32. ->getFile().getSiblingFile ("RecentlyCrashedPluginsList");
  33. setContentOwned (new PluginListComponent (pluginFormatManager,
  34. owner.knownPluginList,
  35. deadMansPedalFile,
  36. getAppProperties().getUserSettings(), true), true);
  37. setResizable (true, false);
  38. setResizeLimits (300, 400, 800, 1500);
  39. setTopLeftPosition (60, 60);
  40. restoreWindowStateFromString (getAppProperties().getUserSettings()->getValue ("listWindowPos"));
  41. setVisible (true);
  42. }
  43. ~PluginListWindow() override
  44. {
  45. getAppProperties().getUserSettings()->setValue ("listWindowPos", getWindowStateAsString());
  46. clearContentComponent();
  47. }
  48. void closeButtonPressed() override
  49. {
  50. owner.pluginListWindow = nullptr;
  51. }
  52. private:
  53. MainHostWindow& owner;
  54. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginListWindow)
  55. };
  56. //==============================================================================
  57. MainHostWindow::MainHostWindow()
  58. : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(),
  59. LookAndFeel::getDefaultLookAndFeel().findColour (ResizableWindow::backgroundColourId),
  60. DocumentWindow::allButtons)
  61. {
  62. formatManager.addDefaultFormats();
  63. formatManager.addFormat (new InternalPluginFormat());
  64. auto safeThis = SafePointer<MainHostWindow> (this);
  65. RuntimePermissions::request (RuntimePermissions::recordAudio,
  66. [safeThis] (bool granted) mutable
  67. {
  68. auto savedState = getAppProperties().getUserSettings()->getXmlValue ("audioDeviceState");
  69. safeThis->deviceManager.initialise (granted ? 256 : 0, 256, savedState.get(), true);
  70. });
  71. #if JUCE_IOS || JUCE_ANDROID
  72. setFullScreen (true);
  73. #else
  74. setResizable (true, false);
  75. setResizeLimits (500, 400, 10000, 10000);
  76. centreWithSize (800, 600);
  77. #endif
  78. graphHolder.reset (new GraphDocumentComponent (formatManager, deviceManager, knownPluginList));
  79. setContentNonOwned (graphHolder.get(), false);
  80. restoreWindowStateFromString (getAppProperties().getUserSettings()->getValue ("mainWindowPos"));
  81. setVisible (true);
  82. InternalPluginFormat internalFormat;
  83. internalTypes = internalFormat.getAllTypes();
  84. if (auto savedPluginList = getAppProperties().getUserSettings()->getXmlValue ("pluginList"))
  85. knownPluginList.recreateFromXml (*savedPluginList);
  86. for (auto& t : internalTypes)
  87. knownPluginList.addType (t);
  88. pluginSortMethod = (KnownPluginList::SortMethod) getAppProperties().getUserSettings()
  89. ->getIntValue ("pluginSortMethod", KnownPluginList::sortByManufacturer);
  90. knownPluginList.addChangeListener (this);
  91. if (auto* g = graphHolder->graph.get())
  92. g->addChangeListener (this);
  93. addKeyListener (getCommandManager().getKeyMappings());
  94. Process::setPriority (Process::HighPriority);
  95. #if JUCE_IOS || JUCE_ANDROID
  96. graphHolder->burgerMenu.setModel (this);
  97. #else
  98. #if JUCE_MAC
  99. setMacMainMenu (this);
  100. #else
  101. setMenuBar (this);
  102. #endif
  103. #endif
  104. getCommandManager().setFirstCommandTarget (this);
  105. }
  106. MainHostWindow::~MainHostWindow()
  107. {
  108. pluginListWindow = nullptr;
  109. knownPluginList.removeChangeListener (this);
  110. if (auto* g = graphHolder->graph.get())
  111. g->removeChangeListener (this);
  112. getAppProperties().getUserSettings()->setValue ("mainWindowPos", getWindowStateAsString());
  113. clearContentComponent();
  114. #if ! (JUCE_ANDROID || JUCE_IOS)
  115. #if JUCE_MAC
  116. setMacMainMenu (nullptr);
  117. #else
  118. setMenuBar (nullptr);
  119. #endif
  120. #endif
  121. graphHolder = nullptr;
  122. }
  123. void MainHostWindow::closeButtonPressed()
  124. {
  125. tryToQuitApplication();
  126. }
  127. struct AsyncQuitRetrier : private Timer
  128. {
  129. AsyncQuitRetrier() { startTimer (500); }
  130. void timerCallback() override
  131. {
  132. stopTimer();
  133. delete this;
  134. if (auto app = JUCEApplicationBase::getInstance())
  135. app->systemRequestedQuit();
  136. }
  137. };
  138. void MainHostWindow::tryToQuitApplication()
  139. {
  140. if (graphHolder->closeAnyOpenPluginWindows())
  141. {
  142. // Really important thing to note here: if the last call just deleted any plugin windows,
  143. // we won't exit immediately - instead we'll use our AsyncQuitRetrier to let the message
  144. // loop run for another brief moment, then try again. This will give any plugins a chance
  145. // to flush any GUI events that may have been in transit before the app forces them to
  146. // be unloaded
  147. new AsyncQuitRetrier();
  148. }
  149. else if (ModalComponentManager::getInstance()->cancelAllModalComponents())
  150. {
  151. new AsyncQuitRetrier();
  152. }
  153. #if JUCE_ANDROID || JUCE_IOS
  154. else if (graphHolder == nullptr || graphHolder->graph->saveDocument (PluginGraph::getDefaultGraphDocumentOnMobile()))
  155. #else
  156. else if (graphHolder == nullptr || graphHolder->graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
  157. #endif
  158. {
  159. // Some plug-ins do not want [NSApp stop] to be called
  160. // before the plug-ins are not deallocated.
  161. graphHolder->releaseGraph();
  162. JUCEApplication::quit();
  163. }
  164. }
  165. void MainHostWindow::changeListenerCallback (ChangeBroadcaster* changed)
  166. {
  167. if (changed == &knownPluginList)
  168. {
  169. menuItemsChanged();
  170. // save the plugin list every time it gets changed, so that if we're scanning
  171. // and it crashes, we've still saved the previous ones
  172. if (auto savedPluginList = std::unique_ptr<XmlElement> (knownPluginList.createXml()))
  173. {
  174. getAppProperties().getUserSettings()->setValue ("pluginList", savedPluginList.get());
  175. getAppProperties().saveIfNeeded();
  176. }
  177. }
  178. else if (graphHolder != nullptr && changed == graphHolder->graph.get())
  179. {
  180. auto title = JUCEApplication::getInstance()->getApplicationName();
  181. auto f = graphHolder->graph->getFile();
  182. if (f.existsAsFile())
  183. title = f.getFileName() + " - " + title;
  184. setName (title);
  185. }
  186. }
  187. StringArray MainHostWindow::getMenuBarNames()
  188. {
  189. StringArray names;
  190. names.add ("File");
  191. names.add ("Plugins");
  192. names.add ("Options");
  193. names.add ("Windows");
  194. return names;
  195. }
  196. PopupMenu MainHostWindow::getMenuForIndex (int topLevelMenuIndex, const String& /*menuName*/)
  197. {
  198. PopupMenu menu;
  199. if (topLevelMenuIndex == 0)
  200. {
  201. // "File" menu
  202. #if ! (JUCE_IOS || JUCE_ANDROID)
  203. menu.addCommandItem (&getCommandManager(), CommandIDs::newFile);
  204. menu.addCommandItem (&getCommandManager(), CommandIDs::open);
  205. #endif
  206. RecentlyOpenedFilesList recentFiles;
  207. recentFiles.restoreFromString (getAppProperties().getUserSettings()
  208. ->getValue ("recentFilterGraphFiles"));
  209. PopupMenu recentFilesMenu;
  210. recentFiles.createPopupMenuItems (recentFilesMenu, 100, true, true);
  211. menu.addSubMenu ("Open recent file", recentFilesMenu);
  212. #if ! (JUCE_IOS || JUCE_ANDROID)
  213. menu.addCommandItem (&getCommandManager(), CommandIDs::save);
  214. menu.addCommandItem (&getCommandManager(), CommandIDs::saveAs);
  215. #endif
  216. menu.addSeparator();
  217. menu.addCommandItem (&getCommandManager(), StandardApplicationCommandIDs::quit);
  218. }
  219. else if (topLevelMenuIndex == 1)
  220. {
  221. // "Plugins" menu
  222. PopupMenu pluginsMenu;
  223. addPluginsToMenu (pluginsMenu);
  224. menu.addSubMenu ("Create Plug-in", pluginsMenu);
  225. menu.addSeparator();
  226. menu.addItem (250, "Delete All Plug-ins");
  227. }
  228. else if (topLevelMenuIndex == 2)
  229. {
  230. // "Options" menu
  231. menu.addCommandItem (&getCommandManager(), CommandIDs::showPluginListEditor);
  232. PopupMenu sortTypeMenu;
  233. sortTypeMenu.addItem (200, "List Plug-ins in Default Order", true, pluginSortMethod == KnownPluginList::defaultOrder);
  234. sortTypeMenu.addItem (201, "List Plug-ins in Alphabetical Order", true, pluginSortMethod == KnownPluginList::sortAlphabetically);
  235. sortTypeMenu.addItem (202, "List Plug-ins by Category", true, pluginSortMethod == KnownPluginList::sortByCategory);
  236. sortTypeMenu.addItem (203, "List Plug-ins by Manufacturer", true, pluginSortMethod == KnownPluginList::sortByManufacturer);
  237. sortTypeMenu.addItem (204, "List Plug-ins Based on the Directory Structure", true, pluginSortMethod == KnownPluginList::sortByFileSystemLocation);
  238. menu.addSubMenu ("Plug-in Menu Type", sortTypeMenu);
  239. menu.addSeparator();
  240. menu.addCommandItem (&getCommandManager(), CommandIDs::showAudioSettings);
  241. menu.addCommandItem (&getCommandManager(), CommandIDs::toggleDoublePrecision);
  242. if (autoScaleOptionAvailable)
  243. menu.addCommandItem (&getCommandManager(), CommandIDs::autoScalePluginWindows);
  244. menu.addSeparator();
  245. menu.addCommandItem (&getCommandManager(), CommandIDs::aboutBox);
  246. }
  247. else if (topLevelMenuIndex == 3)
  248. {
  249. menu.addCommandItem (&getCommandManager(), CommandIDs::allWindowsForward);
  250. }
  251. return menu;
  252. }
  253. void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/)
  254. {
  255. if (menuItemID == 250)
  256. {
  257. if (graphHolder != nullptr)
  258. if (auto* graph = graphHolder->graph.get())
  259. graph->clear();
  260. }
  261. #if ! (JUCE_ANDROID || JUCE_IOS)
  262. else if (menuItemID >= 100 && menuItemID < 200)
  263. {
  264. RecentlyOpenedFilesList recentFiles;
  265. recentFiles.restoreFromString (getAppProperties().getUserSettings()
  266. ->getValue ("recentFilterGraphFiles"));
  267. if (graphHolder != nullptr)
  268. if (auto* graph = graphHolder->graph.get())
  269. if (graph != nullptr && graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
  270. graph->loadFrom (recentFiles.getFile (menuItemID - 100), true);
  271. }
  272. #endif
  273. else if (menuItemID >= 200 && menuItemID < 210)
  274. {
  275. if (menuItemID == 200) pluginSortMethod = KnownPluginList::defaultOrder;
  276. else if (menuItemID == 201) pluginSortMethod = KnownPluginList::sortAlphabetically;
  277. else if (menuItemID == 202) pluginSortMethod = KnownPluginList::sortByCategory;
  278. else if (menuItemID == 203) pluginSortMethod = KnownPluginList::sortByManufacturer;
  279. else if (menuItemID == 204) pluginSortMethod = KnownPluginList::sortByFileSystemLocation;
  280. getAppProperties().getUserSettings()->setValue ("pluginSortMethod", (int) pluginSortMethod);
  281. menuItemsChanged();
  282. }
  283. else
  284. {
  285. if (KnownPluginList::getIndexChosenByMenu (pluginDescriptions, menuItemID) >= 0)
  286. createPlugin (getChosenType (menuItemID), { proportionOfWidth (0.3f + Random::getSystemRandom().nextFloat() * 0.6f),
  287. proportionOfHeight (0.3f + Random::getSystemRandom().nextFloat() * 0.6f) });
  288. }
  289. }
  290. void MainHostWindow::menuBarActivated (bool isActivated)
  291. {
  292. if (isActivated && graphHolder != nullptr)
  293. graphHolder->unfocusKeyboardComponent();
  294. }
  295. void MainHostWindow::createPlugin (const PluginDescription& desc, Point<int> pos)
  296. {
  297. if (graphHolder != nullptr)
  298. graphHolder->createNewPlugin (desc, pos);
  299. }
  300. void MainHostWindow::addPluginsToMenu (PopupMenu& m)
  301. {
  302. if (graphHolder != nullptr)
  303. {
  304. int i = 0;
  305. for (auto& t : internalTypes)
  306. m.addItem (++i, t.name + " (" + t.pluginFormatName + ")");
  307. }
  308. m.addSeparator();
  309. pluginDescriptions = knownPluginList.getTypes();
  310. // This avoids showing the internal types again later on in the list
  311. pluginDescriptions.removeIf ([] (PluginDescription& desc)
  312. {
  313. return desc.pluginFormatName == InternalPluginFormat::getIdentifier();
  314. });
  315. KnownPluginList::addToMenu (m, pluginDescriptions, pluginSortMethod);
  316. }
  317. PluginDescription MainHostWindow::getChosenType (const int menuID) const
  318. {
  319. if (menuID >= 1 && menuID < (int) (1 + internalTypes.size()))
  320. return internalTypes[(size_t) (menuID - 1)];
  321. return pluginDescriptions[KnownPluginList::getIndexChosenByMenu (pluginDescriptions, menuID)];
  322. }
  323. //==============================================================================
  324. ApplicationCommandTarget* MainHostWindow::getNextCommandTarget()
  325. {
  326. return findFirstTargetParentComponent();
  327. }
  328. void MainHostWindow::getAllCommands (Array<CommandID>& commands)
  329. {
  330. // this returns the set of all commands that this target can perform..
  331. const CommandID ids[] = {
  332. #if ! (JUCE_IOS || JUCE_ANDROID)
  333. CommandIDs::newFile,
  334. CommandIDs::open,
  335. CommandIDs::save,
  336. CommandIDs::saveAs,
  337. #endif
  338. CommandIDs::showPluginListEditor,
  339. CommandIDs::showAudioSettings,
  340. CommandIDs::toggleDoublePrecision,
  341. CommandIDs::aboutBox,
  342. CommandIDs::allWindowsForward,
  343. CommandIDs::autoScalePluginWindows
  344. };
  345. commands.addArray (ids, numElementsInArray (ids));
  346. }
  347. void MainHostWindow::getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result)
  348. {
  349. const String category ("General");
  350. switch (commandID)
  351. {
  352. #if ! (JUCE_IOS || JUCE_ANDROID)
  353. case CommandIDs::newFile:
  354. result.setInfo ("New", "Creates a new filter graph file", category, 0);
  355. result.defaultKeypresses.add(KeyPress('n', ModifierKeys::commandModifier, 0));
  356. break;
  357. case CommandIDs::open:
  358. result.setInfo ("Open...", "Opens a filter graph file", category, 0);
  359. result.defaultKeypresses.add (KeyPress ('o', ModifierKeys::commandModifier, 0));
  360. break;
  361. case CommandIDs::save:
  362. result.setInfo ("Save", "Saves the current graph to a file", category, 0);
  363. result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier, 0));
  364. break;
  365. case CommandIDs::saveAs:
  366. result.setInfo ("Save As...",
  367. "Saves a copy of the current graph to a file",
  368. category, 0);
  369. result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::shiftModifier | ModifierKeys::commandModifier, 0));
  370. break;
  371. #endif
  372. case CommandIDs::showPluginListEditor:
  373. result.setInfo ("Edit the List of Available Plug-ins...", {}, category, 0);
  374. result.addDefaultKeypress ('p', ModifierKeys::commandModifier);
  375. break;
  376. case CommandIDs::showAudioSettings:
  377. result.setInfo ("Change the Audio Device Settings", {}, category, 0);
  378. result.addDefaultKeypress ('a', ModifierKeys::commandModifier);
  379. break;
  380. case CommandIDs::toggleDoublePrecision:
  381. updatePrecisionMenuItem (result);
  382. break;
  383. case CommandIDs::aboutBox:
  384. result.setInfo ("About...", {}, category, 0);
  385. break;
  386. case CommandIDs::allWindowsForward:
  387. result.setInfo ("All Windows Forward", "Bring all plug-in windows forward", category, 0);
  388. result.addDefaultKeypress ('w', ModifierKeys::commandModifier);
  389. break;
  390. case CommandIDs::autoScalePluginWindows:
  391. updateAutoScaleMenuItem (result);
  392. break;
  393. default:
  394. break;
  395. }
  396. }
  397. bool MainHostWindow::perform (const InvocationInfo& info)
  398. {
  399. switch (info.commandID)
  400. {
  401. #if ! (JUCE_IOS || JUCE_ANDROID)
  402. case CommandIDs::newFile:
  403. if (graphHolder != nullptr && graphHolder->graph != nullptr && graphHolder->graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
  404. graphHolder->graph->newDocument();
  405. break;
  406. case CommandIDs::open:
  407. if (graphHolder != nullptr && graphHolder->graph != nullptr && graphHolder->graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
  408. graphHolder->graph->loadFromUserSpecifiedFile (true);
  409. break;
  410. case CommandIDs::save:
  411. if (graphHolder != nullptr && graphHolder->graph != nullptr)
  412. graphHolder->graph->save (true, true);
  413. break;
  414. case CommandIDs::saveAs:
  415. if (graphHolder != nullptr && graphHolder->graph != nullptr)
  416. graphHolder->graph->saveAs (File(), true, true, true);
  417. break;
  418. #endif
  419. case CommandIDs::showPluginListEditor:
  420. if (pluginListWindow == nullptr)
  421. pluginListWindow.reset (new PluginListWindow (*this, formatManager));
  422. pluginListWindow->toFront (true);
  423. break;
  424. case CommandIDs::showAudioSettings:
  425. showAudioSettings();
  426. break;
  427. case CommandIDs::toggleDoublePrecision:
  428. if (auto* props = getAppProperties().getUserSettings())
  429. {
  430. auto newIsDoublePrecision = ! isDoublePrecisionProcessingEnabled();
  431. props->setValue ("doublePrecisionProcessing", var (newIsDoublePrecision));
  432. ApplicationCommandInfo cmdInfo (info.commandID);
  433. updatePrecisionMenuItem (cmdInfo);
  434. menuItemsChanged();
  435. if (graphHolder != nullptr)
  436. graphHolder->setDoublePrecision (newIsDoublePrecision);
  437. }
  438. break;
  439. case CommandIDs::autoScalePluginWindows:
  440. if (auto* props = getAppProperties().getUserSettings())
  441. {
  442. auto newAutoScale = ! isAutoScalePluginWindowsEnabled();
  443. props->setValue ("autoScalePluginWindows", var (newAutoScale));
  444. ApplicationCommandInfo cmdInfo (info.commandID);
  445. updateAutoScaleMenuItem (cmdInfo);
  446. menuItemsChanged();
  447. }
  448. break;
  449. case CommandIDs::aboutBox:
  450. // TODO
  451. break;
  452. case CommandIDs::allWindowsForward:
  453. {
  454. auto& desktop = Desktop::getInstance();
  455. for (int i = 0; i < desktop.getNumComponents(); ++i)
  456. desktop.getComponent (i)->toBehind (this);
  457. break;
  458. }
  459. default:
  460. return false;
  461. }
  462. return true;
  463. }
  464. void MainHostWindow::showAudioSettings()
  465. {
  466. auto* audioSettingsComp = new AudioDeviceSelectorComponent (deviceManager,
  467. 0, 256,
  468. 0, 256,
  469. true, true,
  470. true, false);
  471. audioSettingsComp->setSize (500, 450);
  472. DialogWindow::LaunchOptions o;
  473. o.content.setOwned (audioSettingsComp);
  474. o.dialogTitle = "Audio Settings";
  475. o.componentToCentreAround = this;
  476. o.dialogBackgroundColour = getLookAndFeel().findColour (ResizableWindow::backgroundColourId);
  477. o.escapeKeyTriggersCloseButton = true;
  478. o.useNativeTitleBar = false;
  479. o.resizable = false;
  480. auto* w = o.create();
  481. auto safeThis = SafePointer<MainHostWindow> (this);
  482. w->enterModalState (true,
  483. ModalCallbackFunction::create
  484. ([safeThis] (int)
  485. {
  486. auto audioState = safeThis->deviceManager.createStateXml();
  487. getAppProperties().getUserSettings()->setValue ("audioDeviceState", audioState.get());
  488. getAppProperties().getUserSettings()->saveIfNeeded();
  489. if (safeThis->graphHolder != nullptr)
  490. if (safeThis->graphHolder->graph != nullptr)
  491. safeThis->graphHolder->graph->graph.removeIllegalConnections();
  492. }), true);
  493. }
  494. bool MainHostWindow::isInterestedInFileDrag (const StringArray&)
  495. {
  496. return true;
  497. }
  498. void MainHostWindow::fileDragEnter (const StringArray&, int, int)
  499. {
  500. }
  501. void MainHostWindow::fileDragMove (const StringArray&, int, int)
  502. {
  503. }
  504. void MainHostWindow::fileDragExit (const StringArray&)
  505. {
  506. }
  507. void MainHostWindow::filesDropped (const StringArray& files, int x, int y)
  508. {
  509. if (graphHolder != nullptr)
  510. {
  511. #if ! (JUCE_ANDROID || JUCE_IOS)
  512. if (files.size() == 1 && File (files[0]).hasFileExtension (PluginGraph::getFilenameSuffix()))
  513. {
  514. if (auto* g = graphHolder->graph.get())
  515. if (g->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
  516. g->loadFrom (File (files[0]), true);
  517. }
  518. else
  519. #endif
  520. {
  521. OwnedArray<PluginDescription> typesFound;
  522. knownPluginList.scanAndAddDragAndDroppedFiles (formatManager, files, typesFound);
  523. auto pos = graphHolder->getLocalPoint (this, Point<int> (x, y));
  524. for (int i = 0; i < jmin (5, typesFound.size()); ++i)
  525. if (auto* desc = typesFound.getUnchecked(i))
  526. createPlugin (*desc, pos);
  527. }
  528. }
  529. }
  530. bool MainHostWindow::isDoublePrecisionProcessingEnabled()
  531. {
  532. if (auto* props = getAppProperties().getUserSettings())
  533. return props->getBoolValue ("doublePrecisionProcessing", false);
  534. return false;
  535. }
  536. bool MainHostWindow::isAutoScalePluginWindowsEnabled()
  537. {
  538. if (auto* props = getAppProperties().getUserSettings())
  539. return props->getBoolValue ("autoScalePluginWindows", false);
  540. return false;
  541. }
  542. void MainHostWindow::updatePrecisionMenuItem (ApplicationCommandInfo& info)
  543. {
  544. info.setInfo ("Double Floating-Point Precision Rendering", {}, "General", 0);
  545. info.setTicked (isDoublePrecisionProcessingEnabled());
  546. }
  547. void MainHostWindow::updateAutoScaleMenuItem (ApplicationCommandInfo& info)
  548. {
  549. info.setInfo ("Auto-Scale Plug-in Windows", {}, "General", 0);
  550. info.setTicked (isAutoScalePluginWindowsEnabled());
  551. }