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.

87 lines
2.7KB

  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. START_NAMESPACE_DGL
  20. class Window;
  21. // -----------------------------------------------------------------------
  22. /**
  23. Top-Level Widget class.
  24. This is the only Widget class that is allowed to be used directly on a Window.
  25. This widget takes the full size of the Window it is mapped to.
  26. Sub-widgets can be added on top of this top-level widget, by creating them with this class as parent.
  27. Doing so allows for custom position and sizes.
  28. This class is used as the type for DPF Plugin UIs.
  29. So anything that a plugin UI might need that does not belong in a simple Widget will go here.
  30. */
  31. class TopLevelWidget : public Widget
  32. {
  33. public:
  34. /**
  35. Constructor.
  36. */
  37. explicit TopLevelWidget(Window& windowToMapTo);
  38. /**
  39. Destructor.
  40. */
  41. virtual ~TopLevelWidget();
  42. protected:
  43. /**
  44. A function called before any draw operations begin (in the current event-loop cycle).
  45. Can be used to setup any resources for needed drawing.
  46. The default implementation simply paints the full Widget contents black.
  47. */
  48. virtual void onDisplayBefore();
  49. /**
  50. A function called after all draw operations have ended (in the current event-loop cycle).
  51. Can be used to clear any resources setup during onDisplayBefore().
  52. The default implementation does nothing.
  53. */
  54. virtual void onDisplayAfter();
  55. /**
  56. A function called when the widget is resized.
  57. Reimplemented from Widget::onResize.
  58. */
  59. void onResize(const ResizeEvent&) override;
  60. private:
  61. struct PrivateData;
  62. PrivateData* const pData;
  63. friend class Window;
  64. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TopLevelWidget)
  65. };
  66. // -----------------------------------------------------------------------
  67. END_NAMESPACE_DGL
  68. #endif // DGL_TOP_LEVEL_WIDGET_HPP_INCLUDED