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.

85 lines
3.1KB

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