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.

Geometry.hpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * DISTRHO Plugin Toolkit (DPT)
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * For a full copy of the license see the LGPL.txt file
  15. */
  16. #ifndef __DGL_GEOMETRY_HPP__
  17. #define __DGL_GEOMETRY_HPP__
  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__