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.4KB

9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. #ifndef JUCE_RELATIVEPOINT_H_INCLUDED
  18. #define JUCE_RELATIVEPOINT_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. An X-Y position stored as a pair of RelativeCoordinate values.
  22. @see RelativeCoordinate, RelativeRectangle
  23. */
  24. class JUCE_API RelativePoint
  25. {
  26. public:
  27. /** Creates a point at the origin. */
  28. RelativePoint();
  29. /** Creates an absolute point, relative to the origin. */
  30. RelativePoint (Point<float> absolutePoint);
  31. /** Creates an absolute point, relative to the origin. */
  32. RelativePoint (float absoluteX, float absoluteY);
  33. /** Creates an absolute point from two coordinates. */
  34. RelativePoint (const RelativeCoordinate& x, const RelativeCoordinate& y);
  35. /** Creates a point from a stringified representation.
  36. The string must contain a pair of coordinates, separated by space or a comma. The syntax for the coordinate
  37. strings is explained in the RelativeCoordinate class.
  38. @see toString
  39. */
  40. RelativePoint (const String& stringVersion);
  41. bool operator== (const RelativePoint&) const noexcept;
  42. bool operator!= (const RelativePoint&) const noexcept;
  43. /** Calculates the absolute position of this point.
  44. You'll need to provide a suitable Expression::Scope for looking up any coordinates that may
  45. be needed to calculate the result.
  46. */
  47. Point<float> resolve (const Expression::Scope* evaluationContext) const;
  48. /** Changes the values of this point's coordinates to make it resolve to the specified position.
  49. Calling this will leave any anchor points unchanged, but will set any absolute
  50. or relative positions to whatever values are necessary to make the resultant position
  51. match the position that is provided.
  52. */
  53. void moveToAbsolute (Point<float> newPos, const Expression::Scope* evaluationContext);
  54. /** Returns a string which represents this point.
  55. This returns a comma-separated pair of coordinates. For details of the string syntax used by the
  56. coordinates, see the RelativeCoordinate constructor notes.
  57. The string that is returned can be passed to the RelativePoint constructor to recreate the point.
  58. */
  59. String toString() const;
  60. /** Returns true if this point depends on any other coordinates for its position. */
  61. bool isDynamic() const;
  62. // The actual X and Y coords...
  63. RelativeCoordinate x, y;
  64. };
  65. #endif // JUCE_RELATIVEPOINT_H_INCLUDED