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.

95 lines
2.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. namespace RelativePointHelpers
  18. {
  19. inline void skipComma (String::CharPointerType& s)
  20. {
  21. s = s.findEndOfWhitespace();
  22. if (*s == ',')
  23. ++s;
  24. }
  25. }
  26. //==============================================================================
  27. RelativePoint::RelativePoint()
  28. {
  29. }
  30. RelativePoint::RelativePoint (Point<float> absolutePoint)
  31. : x (absolutePoint.x), y (absolutePoint.y)
  32. {
  33. }
  34. RelativePoint::RelativePoint (const float x_, const float y_)
  35. : x (x_), y (y_)
  36. {
  37. }
  38. RelativePoint::RelativePoint (const RelativeCoordinate& x_, const RelativeCoordinate& y_)
  39. : x (x_), y (y_)
  40. {
  41. }
  42. RelativePoint::RelativePoint (const String& s)
  43. {
  44. String::CharPointerType text (s.getCharPointer());
  45. x = RelativeCoordinate (Expression::parse (text));
  46. RelativePointHelpers::skipComma (text);
  47. y = RelativeCoordinate (Expression::parse (text));
  48. }
  49. bool RelativePoint::operator== (const RelativePoint& other) const noexcept
  50. {
  51. return x == other.x && y == other.y;
  52. }
  53. bool RelativePoint::operator!= (const RelativePoint& other) const noexcept
  54. {
  55. return ! operator== (other);
  56. }
  57. Point<float> RelativePoint::resolve (const Expression::Scope* scope) const
  58. {
  59. return Point<float> ((float) x.resolve (scope),
  60. (float) y.resolve (scope));
  61. }
  62. void RelativePoint::moveToAbsolute (Point<float> newPos, const Expression::Scope* scope)
  63. {
  64. x.moveToAbsolute (newPos.x, scope);
  65. y.moveToAbsolute (newPos.y, scope);
  66. }
  67. String RelativePoint::toString() const
  68. {
  69. return x.toString() + ", " + y.toString();
  70. }
  71. bool RelativePoint::isDynamic() const
  72. {
  73. return x.isDynamic() || y.isDynamic();
  74. }