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.

113 lines
2.8KB

  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_SUBWIDGET_HPP_INCLUDED
  17. #define DGL_SUBWIDGET_HPP_INCLUDED
  18. #include "Widget.hpp"
  19. START_NAMESPACE_DGL
  20. // -----------------------------------------------------------------------
  21. /**
  22. Sub-Widget class.
  23. This is a handy Widget class that can be freely positioned to be used directly on a Window.
  24. This widget takes the full size of the Window it is mapped to.
  25. Sub-widgets can be added on top of this top-level widget, by creating them with this class as parent.
  26. Doing so allows for custom position and sizes.
  27. */
  28. class SubWidget : public Widget
  29. {
  30. public:
  31. /**
  32. Constructor.
  33. */
  34. explicit SubWidget(Widget* widgetToGroupTo);
  35. /**
  36. Destructor.
  37. */
  38. virtual ~SubWidget();
  39. /**
  40. Check if this widget contains the point defined by @a x and @a y.
  41. */
  42. template<typename T>
  43. bool contains(T x, T y) const noexcept;
  44. /**
  45. Check if this widget contains the point @a pos.
  46. */
  47. template<typename T>
  48. bool contains(const Point<T>& pos) const noexcept;
  49. /**
  50. Get absolute X.
  51. */
  52. int getAbsoluteX() const noexcept;
  53. /**
  54. Get absolute Y.
  55. */
  56. int getAbsoluteY() const noexcept;
  57. /**
  58. Get absolute position.
  59. */
  60. const Point<int>& getAbsolutePos() const noexcept;
  61. /**
  62. Set absolute X.
  63. */
  64. void setAbsoluteX(int x) noexcept;
  65. /**
  66. Set absolute Y.
  67. */
  68. void setAbsoluteY(int y) noexcept;
  69. /**
  70. Set absolute position using @a x and @a y values.
  71. */
  72. void setAbsolutePos(int x, int y) noexcept;
  73. /**
  74. Set absolute position.
  75. */
  76. void setAbsolutePos(const Point<int>& pos) noexcept;
  77. protected:
  78. /**
  79. A function called when the subwidget's absolute position is changed.
  80. */
  81. virtual void onPositionChanged(const PositionChangedEvent&);
  82. private:
  83. struct PrivateData;
  84. PrivateData* const pData;
  85. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SubWidget)
  86. };
  87. // -----------------------------------------------------------------------
  88. END_NAMESPACE_DGL
  89. #endif // DGL_SUBWIDGET_HPP_INCLUDED