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.

juce_RelativePoint.h 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2020 - Raw Material Software Limited
  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 6 End-User License
  8. Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
  9. End User License Agreement: www.juce.com/juce-6-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. An X-Y position stored as a pair of RelativeCoordinate values.
  23. @see RelativeCoordinate, RelativeRectangle
  24. @tags{GUI}
  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