Expresses a coordinate as a dynamically evaluated expression. More...
#include <juce_RelativeCoordinate.h>
Classes | |
struct | StandardStrings |
struct | Strings |
A set of static strings that are commonly used by the RelativeCoordinate class. More... | |
Public Member Functions | |
RelativeCoordinate () | |
Creates a zero coordinate. More... | |
RelativeCoordinate (const Expression &expression) | |
RelativeCoordinate (const RelativeCoordinate &) | |
RelativeCoordinate (const String &stringVersion) | |
Recreates a coordinate from a string description. More... | |
RelativeCoordinate (double absoluteDistanceFromOrigin) | |
Creates an absolute position from the parent origin on either the X or Y axis. More... | |
RelativeCoordinate (RelativeCoordinate &&) noexcept | |
~RelativeCoordinate () | |
Destructor. More... | |
const Expression & | getExpression () const |
Returns the expression that defines this coordinate. More... | |
bool | isDynamic () const |
Returns true if this coordinate depends on any other coordinates for its position. More... | |
bool | isRecursive (const Expression::Scope *evaluationScope) const |
Returns true if there's a recursive loop when trying to resolve this coordinate's position. More... | |
void | moveToAbsolute (double absoluteTargetPosition, const Expression::Scope *evaluationScope) |
Changes the value of this coord to make it resolve to the specified position. More... | |
bool | operator!= (const RelativeCoordinate &) const noexcept |
RelativeCoordinate & | operator= (const RelativeCoordinate &) |
RelativeCoordinate & | operator= (RelativeCoordinate &&) noexcept |
bool | operator== (const RelativeCoordinate &) const noexcept |
bool | references (const String &coordName, const Expression::Scope *evaluationScope) const |
Returns true if this coordinate uses the specified coord name at any level in its evaluation. More... | |
double | resolve (const Expression::Scope *evaluationScope) const |
Calculates the absolute position of this coordinate. More... | |
String | toString () const |
Returns a string which represents this coordinate. More... | |
Private Attributes | |
Expression | term |
Expresses a coordinate as a dynamically evaluated expression.
When using relative coordinates to position components, the following symbols are available:
See the Expression class for details about the operators that are supported, but for example if you wanted to make your component remains centred within its parent with a size of 100, 100, you could express it as:
..or an alternative way to achieve the same thing:
Or if you wanted a 100x100 component whose top edge is lined up to a marker called "topMarker" and which is positioned 50 pixels to the right of another component called "otherComp", you could write:
Be careful not to make your coordinate expressions recursive, though, or exceptions and assertions will be thrown!
@tags{GUI}
juce::RelativeCoordinate::RelativeCoordinate | ( | ) |
Creates a zero coordinate.
juce::RelativeCoordinate::RelativeCoordinate | ( | const Expression & | expression | ) |
juce::RelativeCoordinate::RelativeCoordinate | ( | const RelativeCoordinate & | ) |
|
noexcept |
juce::RelativeCoordinate::RelativeCoordinate | ( | double | absoluteDistanceFromOrigin | ) |
Creates an absolute position from the parent origin on either the X or Y axis.
absoluteDistanceFromOrigin | the distance from the origin |
juce::RelativeCoordinate::RelativeCoordinate | ( | const String & | stringVersion | ) |
Recreates a coordinate from a string description.
The string will be parsed by ExpressionParser::parse().
stringVersion | the expression to use |
juce::RelativeCoordinate::~RelativeCoordinate | ( | ) |
Destructor.
|
inline |
Returns the expression that defines this coordinate.
bool juce::RelativeCoordinate::isDynamic | ( | ) | const |
Returns true if this coordinate depends on any other coordinates for its position.
bool juce::RelativeCoordinate::isRecursive | ( | const Expression::Scope * | evaluationScope | ) | const |
Returns true if there's a recursive loop when trying to resolve this coordinate's position.
void juce::RelativeCoordinate::moveToAbsolute | ( | double | absoluteTargetPosition, |
const Expression::Scope * | evaluationScope | ||
) |
Changes the value of this coord to make it resolve to the specified position.
Calling this will leave the anchor points unchanged, but will set this coordinate's absolute or relative position to whatever value is necessary to make its resultant position match the position that is provided.
|
noexcept |
RelativeCoordinate& juce::RelativeCoordinate::operator= | ( | const RelativeCoordinate & | ) |
|
noexcept |
|
noexcept |
bool juce::RelativeCoordinate::references | ( | const String & | coordName, |
const Expression::Scope * | evaluationScope | ||
) | const |
Returns true if this coordinate uses the specified coord name at any level in its evaluation.
This will recursively check any coordinates upon which this one depends.
double juce::RelativeCoordinate::resolve | ( | const Expression::Scope * | evaluationScope | ) | const |
Calculates the absolute position of this coordinate.
You'll need to provide a suitable Expression::Scope for looking up any coordinates that may be needed to calculate the result.
String juce::RelativeCoordinate::toString | ( | ) | const |
Returns a string which represents this coordinate.
For details of the string syntax, see the constructor notes.
|
private |