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.

JucePluginWindow.hpp 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Juce Plugin Window Helper
  3. * Copyright (C) 2013 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 PluginWindow : public DocumentWindow
  23. {
  24. public:
  25. PluginWindow()
  26. : DocumentWindow("PluginWindow", 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)
  36. {
  37. fClosed = false;
  38. centreWithSize(comp->getWidth(), comp->getHeight());
  39. setContentNonOwned(comp, true);
  40. if (! isOnDesktop())
  41. addToDesktop();
  42. setVisible(true);
  43. }
  44. void hide()
  45. {
  46. setVisible(false);
  47. if (isOnDesktop())
  48. removeFromDesktop();
  49. clearContentComponent();
  50. }
  51. bool wasClosedByUser() const
  52. {
  53. return fClosed;
  54. }
  55. protected:
  56. void closeButtonPressed() override
  57. {
  58. fClosed = true;
  59. }
  60. private:
  61. volatile bool fClosed;
  62. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginWindow)
  63. };
  64. } // namespace juce
  65. typedef juce::PluginWindow JucePluginWindow;
  66. // -----------------------------------------------------------------------
  67. #endif // JUCE_PLUGIN_WINDOW_HPP_INCLUDED