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.

StandaloneWindow.hpp 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DGL_STANDALONE_WINDOW_HPP_INCLUDED
  17. #define DGL_STANDALONE_WINDOW_HPP_INCLUDED
  18. #include "TopLevelWidget.hpp"
  19. #include "Window.hpp"
  20. START_NAMESPACE_DGL
  21. // -----------------------------------------------------------------------
  22. class StandaloneWindow : public Window,
  23. public TopLevelWidget
  24. {
  25. public:
  26. /**
  27. Constructor without parent.
  28. */
  29. StandaloneWindow(Application& app)
  30. : Window(app),
  31. TopLevelWidget((Window&)*this),
  32. sgc((Window&)*this) {}
  33. /**
  34. Constructor with a transient parent window, typically used to run as modal.
  35. */
  36. StandaloneWindow(Application& app, Window& transientParentWindow)
  37. : Window(app, transientParentWindow),
  38. TopLevelWidget((Window&)*this),
  39. sgc((Window&)*this, transientParentWindow) {}
  40. /**
  41. Clear current graphics context.
  42. Must be called at the end of your StandaloneWindow constructor.
  43. */
  44. void done()
  45. {
  46. sgc.done();
  47. }
  48. /**
  49. Overloaded functions to ensure they apply to the Window class.
  50. */
  51. bool isVisible() const noexcept { return Window::isVisible(); }
  52. void setVisible(bool yesNo) { Window::setVisible(yesNo); }
  53. void hide() { Window::hide(); }
  54. void show() { Window::show(); }
  55. uint getWidth() const noexcept { return Window::getWidth(); }
  56. uint getHeight() const noexcept { return Window::getHeight(); }
  57. const Size<uint> getSize() const noexcept { return Window::getSize(); }
  58. void repaint() noexcept { Window::repaint(); }
  59. void setWidth(uint width) { Window::setWidth(width); }
  60. void setHeight(uint height) { Window::setHeight(height); }
  61. void setSize(uint width, uint height) { Window::setSize(width, height); }
  62. void setSize(const Size<uint>& size) { Window::setSize(size); }
  63. bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0)
  64. { return Window::addIdleCallback(callback, timerFrequencyInMs); }
  65. bool removeIdleCallback(IdleCallback* callback) { return Window::removeIdleCallback(callback); }
  66. Application& getApp() const noexcept { return Window::getApp(); }
  67. const GraphicsContext& getGraphicsContext() const noexcept { return Window::getGraphicsContext(); }
  68. double getScaleFactor() const noexcept { return Window::getScaleFactor(); }
  69. void setGeometryConstraints(uint minimumWidth, uint minimumHeight,
  70. bool keepAspectRatio = false, bool automaticallyScale = false)
  71. { Window::setGeometryConstraints(minimumWidth, minimumHeight, keepAspectRatio, automaticallyScale); }
  72. private:
  73. ScopedGraphicsContext sgc;
  74. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StandaloneWindow)
  75. };
  76. // -----------------------------------------------------------------------
  77. END_NAMESPACE_DGL
  78. #endif // DGL_STANDALONE_WINDOW_HPP_INCLUDED