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.

91 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. An X-Y position stored as a pair of RelativeCoordinate values.
  24. @see RelativeCoordinate, RelativeRectangle
  25. */
  26. class JUCE_API RelativePoint
  27. {
  28. public:
  29. /** Creates a point at the origin. */
  30. RelativePoint();
  31. /** Creates an absolute point, relative to the origin. */
  32. RelativePoint (Point<float> absolutePoint);
  33. /** Creates an absolute point, relative to the origin. */
  34. RelativePoint (float absoluteX, float absoluteY);
  35. /** Creates an absolute point from two coordinates. */
  36. RelativePoint (const RelativeCoordinate& x, const RelativeCoordinate& y);
  37. /** Creates a point from a stringified representation.
  38. The string must contain a pair of coordinates, separated by space or a comma. The syntax for the coordinate
  39. strings is explained in the RelativeCoordinate class.
  40. @see toString
  41. */
  42. RelativePoint (const String& stringVersion);
  43. bool operator== (const RelativePoint&) const noexcept;
  44. bool operator!= (const RelativePoint&) const noexcept;
  45. /** Calculates the absolute position of this point.
  46. You'll need to provide a suitable Expression::Scope for looking up any coordinates that may
  47. be needed to calculate the result.
  48. */
  49. Point<float> resolve (const Expression::Scope* evaluationContext) const;
  50. /** Changes the values of this point's coordinates to make it resolve to the specified position.
  51. Calling this will leave any anchor points unchanged, but will set any absolute
  52. or relative positions to whatever values are necessary to make the resultant position
  53. match the position that is provided.
  54. */
  55. void moveToAbsolute (Point<float> newPos, const Expression::Scope* evaluationContext);
  56. /** Returns a string which represents this point.
  57. This returns a comma-separated pair of coordinates. For details of the string syntax used by the
  58. coordinates, see the RelativeCoordinate constructor notes.
  59. The string that is returned can be passed to the RelativePoint constructor to recreate the point.
  60. */
  61. String toString() const;
  62. /** Returns true if this point depends on any other coordinates for its position. */
  63. bool isDynamic() const;
  64. // The actual X and Y coords...
  65. RelativeCoordinate x, y;
  66. };
  67. } // namespace juce