JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_RelativePoint.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29namespace RelativePointHelpers
30{
31 inline void skipComma (String::CharPointerType& s)
32 {
33 s.incrementToEndOfWhitespace();
34
35 if (*s == ',')
36 ++s;
37 }
38}
39
40//==============================================================================
44
49
50RelativePoint::RelativePoint (const float x_, const float y_)
51 : x (x_), y (y_)
52{
53}
54
59
61{
62 String error;
64 x = RelativeCoordinate (Expression::parse (text, error));
65 RelativePointHelpers::skipComma (text);
66 y = RelativeCoordinate (Expression::parse (text, error));
67}
68
69bool RelativePoint::operator== (const RelativePoint& other) const noexcept
70{
71 return x == other.x && y == other.y;
72}
73
74bool RelativePoint::operator!= (const RelativePoint& other) const noexcept
75{
76 return ! operator== (other);
77}
78
80{
81 return Point<float> ((float) x.resolve (scope),
82 (float) y.resolve (scope));
83}
84
90
92{
93 return x.toString() + ", " + y.toString();
94}
95
97{
98 return x.isDynamic() || y.isDynamic();
99}
100
101} // namespace juce
Wraps a pointer to a null-terminated UTF-8 character string, and provides various methods to operate ...
When evaluating an Expression object, this class is used to resolve symbols and perform functions tha...
static Expression parse(String::CharPointerType &stringToParse, String &parseError)
Returns an Expression which parses a string from a character pointer, and updates the pointer to indi...
A pair of (x, y) coordinates.
Definition juce_Point.h:42
Expresses a coordinate as a dynamically evaluated expression.
void moveToAbsolute(double absoluteTargetPosition, const Expression::Scope *evaluationScope)
Changes the value of this coord to make it resolve to the specified position.
bool isDynamic() const
Returns true if this coordinate depends on any other coordinates for its position.
String toString() const
Returns a string which represents this coordinate.
double resolve(const Expression::Scope *evaluationScope) const
Calculates the absolute position of this coordinate.
An X-Y position stored as a pair of RelativeCoordinate values.
RelativePoint()
Creates a point at the origin.
void moveToAbsolute(Point< float > newPos, const Expression::Scope *evaluationContext)
Changes the values of this point's coordinates to make it resolve to the specified position.
Point< float > resolve(const Expression::Scope *evaluationContext) const
Calculates the absolute position of this point.
bool isDynamic() const
Returns true if this point depends on any other coordinates for its position.
String toString() const
Returns a string which represents this point.
The JUCE String class!
Definition juce_String.h:53
CharPointerType getCharPointer() const noexcept
Returns the character pointer currently being used to store this string.
CharPointer_UTF8 CharPointerType
This is the character encoding type used internally to store the string.
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88