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.

134 lines
3.4KB

  1. /*
  2. * DISTRHO Plugin Toolkit (DPT)
  3. * Copyright (C) 2012-2013 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_GEOMETRY_HPP_INCLUDED
  17. #define DGL_GEOMETRY_HPP_INCLUDED
  18. #include "Base.hpp"
  19. START_NAMESPACE_DGL
  20. // -----------------------------------------------------------------------
  21. template<typename T>
  22. class Point
  23. {
  24. public:
  25. Point();
  26. Point(T x, T y);
  27. Point(const Point<T>& pos);
  28. T getX() const;
  29. T getY() const;
  30. void setX(T x);
  31. void setY(T y);
  32. void move(T x, T y);
  33. void move(const Point<T>& pos);
  34. Point<T>& operator=(const Point<T>& pos);
  35. Point<T>& operator+=(const Point<T>& pos);
  36. Point<T>& operator-=(const Point<T>& pos);
  37. bool operator==(const Point<T>& pos) const;
  38. bool operator!=(const Point<T>& pos) const;
  39. private:
  40. T fX, fY;
  41. template<typename> friend class Rectangle;
  42. };
  43. // -----------------------------------------------------------------------
  44. template<typename T>
  45. class Size
  46. {
  47. public:
  48. Size();
  49. Size(T width, T height);
  50. Size(const Size<T>& size);
  51. T getWidth() const;
  52. T getHeight() const;
  53. void setWidth(T width);
  54. void setHeight(T height);
  55. Size<T>& operator=(const Size<T>& size);
  56. Size<T>& operator+=(const Size<T>& size);
  57. Size<T>& operator-=(const Size<T>& size);
  58. Size<T>& operator*=(T m);
  59. Size<T>& operator/=(T d);
  60. bool operator==(const Size<T>& size) const;
  61. bool operator!=(const Size<T>& size) const;
  62. private:
  63. T fWidth, fHeight;
  64. template<typename> friend class Rectangle;
  65. };
  66. // -----------------------------------------------------------------------
  67. template<typename T>
  68. class Rectangle
  69. {
  70. public:
  71. Rectangle();
  72. Rectangle(T x, T y, T width, T height);
  73. Rectangle(T x, T y, const Size<T>& size);
  74. Rectangle(const Point<T>& pos, T width, T height);
  75. Rectangle(const Point<T>& pos, const Size<T>& size);
  76. Rectangle(const Rectangle<T>& rect);
  77. T getX() const;
  78. T getY() const;
  79. T getWidth() const;
  80. T getHeight() const;
  81. const Point<T>& getPos() const;
  82. const Size<T>& getSize() const;
  83. bool contains(T x, T y) const;
  84. bool contains(const Point<T>& pos) const;
  85. bool containsX(T x) const;
  86. bool containsY(T y) const;
  87. void setX(T x);
  88. void setY(T y);
  89. void setPos(T x, T y);
  90. void setPos(const Point<T>& pos);
  91. void move(T x, T y);
  92. void move(const Point<T>& pos);
  93. void setWidth(T width);
  94. void setHeight(T height);
  95. void setSize(T width, T height);
  96. void setSize(const Size<T>& size);
  97. Rectangle<T>& operator=(const Rectangle<T>& rect);
  98. private:
  99. Point<T> fPos;
  100. Size<T> fSize;
  101. };
  102. // -----------------------------------------------------------------------
  103. END_NAMESPACE_DGL
  104. #endif // DGL_GEOMETRY_HPP_INCLUDED