Audio plugin host https://kx.studio/carla
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.

92 lines
2.2KB

  1. /*
  2. * Juce Plugin Window Helper
  3. * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef JUCE_PLUGIN_WINDOW_HPP_INCLUDED
  18. #define JUCE_PLUGIN_WINDOW_HPP_INCLUDED
  19. #include "juce_gui_basics.h"
  20. // -----------------------------------------------------------------------
  21. namespace juce {
  22. class JucePluginWindow : public DocumentWindow
  23. {
  24. public:
  25. JucePluginWindow()
  26. : DocumentWindow("JucePluginWindow", Colour(50, 50, 200), DocumentWindow::closeButton, false),
  27. fClosed(false)
  28. {
  29. setVisible(false);
  30. //setAlwaysOnTop(true);
  31. setOpaque(true);
  32. setResizable(false, false);
  33. setUsingNativeTitleBar(true);
  34. }
  35. void show(Component* const comp, const bool useContentOwned = false)
  36. {
  37. fClosed = false;
  38. centreWithSize(comp->getWidth(), comp->getHeight());
  39. if (useContentOwned)
  40. setContentOwned(comp, false);
  41. else
  42. setContentNonOwned(comp, true);
  43. if (! isOnDesktop())
  44. addToDesktop();
  45. setVisible(true);
  46. }
  47. void hide()
  48. {
  49. setVisible(false);
  50. if (isOnDesktop())
  51. removeFromDesktop();
  52. clearContentComponent();
  53. }
  54. bool wasClosedByUser() const noexcept
  55. {
  56. return fClosed;
  57. }
  58. protected:
  59. void closeButtonPressed() override
  60. {
  61. fClosed = true;
  62. }
  63. private:
  64. volatile bool fClosed;
  65. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(JucePluginWindow)
  66. };
  67. } // namespace juce
  68. using juce::JucePluginWindow;
  69. // -----------------------------------------------------------------------
  70. #endif // JUCE_PLUGIN_WINDOW_HPP_INCLUDED