DISTRHO Plugin Framework
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.

102 lines
3.2KB

  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_TOP_LEVEL_WIDGET_HPP_INCLUDED
  17. #define DGL_TOP_LEVEL_WIDGET_HPP_INCLUDED
  18. #include "Widget.hpp"
  19. #ifdef DISTRHO_DEFINES_H_INCLUDED
  20. START_NAMESPACE_DISTRHO
  21. class UI;
  22. END_NAMESPACE_DISTRHO
  23. #endif
  24. START_NAMESPACE_DGL
  25. class Window;
  26. // -----------------------------------------------------------------------
  27. /**
  28. Top-Level Widget class.
  29. This is the only Widget class that is allowed to be used directly on a Window.
  30. This widget takes the full size of the Window it is mapped to.
  31. Sub-widgets can be added on top of this top-level widget, by creating them with this class as parent.
  32. Doing so allows for custom position and sizes.
  33. This class is used as the type for DPF Plugin UIs.
  34. So anything that a plugin UI might need that does not belong in a simple Widget will go here.
  35. */
  36. class TopLevelWidget : public Widget
  37. {
  38. public:
  39. /**
  40. Constructor.
  41. */
  42. explicit TopLevelWidget(Window& windowToMapTo);
  43. /**
  44. Destructor.
  45. */
  46. virtual ~TopLevelWidget();
  47. /**
  48. Get the application associated with this top-level widget's window.
  49. */
  50. Application& getApp() const noexcept;
  51. /**
  52. Get the window associated with this top-level widget.
  53. */
  54. Window& getWindow() const noexcept;
  55. // TODO group stuff after here, convenience functions present in Window class
  56. bool addIdleCallback(IdleCallback* callback, uint timerFrequencyInMs = 0);
  57. bool removeIdleCallback(IdleCallback* callback);
  58. double getScaleFactor() const noexcept;
  59. void repaint() noexcept;
  60. void repaint(const Rectangle<uint>& rect) noexcept;
  61. void setGeometryConstraints(uint minimumWidth,
  62. uint minimumHeight,
  63. bool keepAspectRatio = false,
  64. bool automaticallyScale = false);
  65. DISTRHO_DEPRECATED_BY("getApp()")
  66. Application& getParentApp() const noexcept { return getApp(); }
  67. DISTRHO_DEPRECATED_BY("getWindow()")
  68. Window& getParentWindow() const noexcept { return getWindow(); }
  69. private:
  70. struct PrivateData;
  71. PrivateData* const pData;
  72. friend class Window;
  73. #ifdef DISTRHO_DEFINES_H_INCLUDED
  74. friend class DISTRHO_NAMESPACE::UI;
  75. #endif
  76. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TopLevelWidget)
  77. };
  78. // -----------------------------------------------------------------------
  79. END_NAMESPACE_DGL
  80. #endif // DGL_TOP_LEVEL_WIDGET_HPP_INCLUDED