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_RelativeCoordinate.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
29const String RelativeCoordinate::Strings::parent ("parent");
30const String RelativeCoordinate::Strings::left ("left");
31const String RelativeCoordinate::Strings::right ("right");
32const String RelativeCoordinate::Strings::top ("top");
33const String RelativeCoordinate::Strings::bottom ("bottom");
34const String RelativeCoordinate::Strings::x ("x");
35const String RelativeCoordinate::Strings::y ("y");
36const String RelativeCoordinate::Strings::width ("width");
37const String RelativeCoordinate::Strings::height ("height");
38
39RelativeCoordinate::StandardStrings::Type RelativeCoordinate::StandardStrings::getTypeOf (const String& s) noexcept
40{
41 if (s == Strings::left) return left;
42 if (s == Strings::right) return right;
43 if (s == Strings::top) return top;
44 if (s == Strings::bottom) return bottom;
45 if (s == Strings::x) return x;
46 if (s == Strings::y) return y;
47 if (s == Strings::width) return width;
48 if (s == Strings::height) return height;
49 if (s == Strings::parent) return parent;
50 return unknown;
51}
52
53//==============================================================================
57
59 : term (term_)
60{
61}
62
63RelativeCoordinate::RelativeCoordinate (const RelativeCoordinate& other)
64 : term (other.term)
65{
66}
67
68RelativeCoordinate& RelativeCoordinate::operator= (const RelativeCoordinate& other)
69{
70 term = other.term;
71 return *this;
72}
73
74RelativeCoordinate::RelativeCoordinate (RelativeCoordinate&& other) noexcept
75 : term (std::move (other.term))
76{
77}
78
79RelativeCoordinate& RelativeCoordinate::operator= (RelativeCoordinate&& other) noexcept
80{
81 term = std::move (other.term);
82 return *this;
83}
84
89
91{
92 String error;
93 term = Expression (s, error);
94}
95
99
100bool RelativeCoordinate::operator== (const RelativeCoordinate& other) const noexcept
101{
102 return term.toString() == other.term.toString();
103}
104
105bool RelativeCoordinate::operator!= (const RelativeCoordinate& other) const noexcept
106{
107 return ! operator== (other);
108}
109
111{
112 if (scope != nullptr)
113 return term.evaluate (*scope);
114
115 return term.evaluate();
116}
117
119{
120 String error;
121
122 if (scope != nullptr)
123 term.evaluate (*scope, error);
124 else
125 term.evaluate (Expression::Scope(), error);
126
127 return error.isNotEmpty();
128}
129
131{
132 if (scope != nullptr)
133 {
134 term = term.adjustedToGiveNewResult (newPos, *scope);
135 }
136 else
137 {
140 }
141}
142
144{
145 return term.usesAnySymbols();
146}
147
149{
150 return term.toString();
151}
152
153} // namespace juce
When evaluating an Expression object, this class is used to resolve symbols and perform functions tha...
A class for dynamically evaluating simple numeric expressions.
Expression adjustedToGiveNewResult(double targetValue, const Scope &scope) const
Attempts to return an expression which is a copy of this one, but with a constant adjusted to make th...
bool usesAnySymbols() const
Returns true if this expression contains any symbols.
double evaluate() const
Evaluates this expression, without using a Scope.
String toString() const
Returns a string version of the expression.
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.
bool isRecursive(const Expression::Scope *evaluationScope) const
Returns true if there's a recursive loop when trying to resolve this coordinate's position.
String toString() const
Returns a string which represents this coordinate.
RelativeCoordinate()
Creates a zero coordinate.
double resolve(const Expression::Scope *evaluationScope) const
Calculates the absolute position of this coordinate.
The JUCE String class!
Definition juce_String.h:53
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
T left(T... args)
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