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
Classes | Public Member Functions | List of all members
juce::RelativeCoordinate Class Reference

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.
 
 RelativeCoordinate (const Expression &expression)
 
 RelativeCoordinate (const RelativeCoordinate &)
 
RelativeCoordinateoperator= (const RelativeCoordinate &)
 
 RelativeCoordinate (RelativeCoordinate &&) noexcept
 
RelativeCoordinateoperator= (RelativeCoordinate &&) noexcept
 
 RelativeCoordinate (double absoluteDistanceFromOrigin)
 Creates an absolute position from the parent origin on either the X or Y axis.
 
 RelativeCoordinate (const String &stringVersion)
 Recreates a coordinate from a string description.
 
 ~RelativeCoordinate ()
 Destructor.
 
bool operator== (const RelativeCoordinate &) const noexcept
 
bool operator!= (const RelativeCoordinate &) const noexcept
 
double resolve (const Expression::Scope *evaluationScope) const
 Calculates the absolute position of this coordinate.
 
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.
 
bool isRecursive (const Expression::Scope *evaluationScope) const
 Returns true if there's a recursive loop when trying to resolve this coordinate's position.
 
bool isDynamic () const
 Returns true if this coordinate depends on any other coordinates for its position.
 
void moveToAbsolute (double absoluteTargetPosition, const Expression::Scope *evaluationScope)
 Changes the value of this coord to make it resolve to the specified position.
 
const ExpressiongetExpression () const
 Returns the expression that defines this coordinate.
 
String toString () const
 Returns a string which represents this coordinate.
 

Detailed Description

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:

myComp.setBounds (RelativeBounds ("parent.width / 2 - 50, parent.height / 2 - 50, left + 100, top + 100"));
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

..or an alternative way to achieve the same thing:

myComp.setBounds (RelativeBounds ("right - 100, bottom - 100, parent.width / 2 + 50, parent.height / 2 + 50"));

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:

myComp.setBounds (RelativeBounds ("otherComp.right + 50, topMarker, left + 100, top + 100"));

Be careful not to make your coordinate expressions recursive, though, or exceptions and assertions will be thrown!

See also
RelativePoint, RelativeRectangle

@tags{GUI}

Definition at line 72 of file juce_RelativeCoordinate.h.

Constructor & Destructor Documentation

◆ RelativeCoordinate() [1/6]

juce::RelativeCoordinate::RelativeCoordinate ( )

Creates a zero coordinate.

Definition at line 54 of file juce_RelativeCoordinate.cpp.

◆ RelativeCoordinate() [2/6]

juce::RelativeCoordinate::RelativeCoordinate ( const Expression expression)

Definition at line 58 of file juce_RelativeCoordinate.cpp.

◆ RelativeCoordinate() [3/6]

juce::RelativeCoordinate::RelativeCoordinate ( const RelativeCoordinate other)

Definition at line 63 of file juce_RelativeCoordinate.cpp.

◆ RelativeCoordinate() [4/6]

juce::RelativeCoordinate::RelativeCoordinate ( RelativeCoordinate &&  other)
noexcept

Definition at line 74 of file juce_RelativeCoordinate.cpp.

◆ RelativeCoordinate() [5/6]

juce::RelativeCoordinate::RelativeCoordinate ( double  absoluteDistanceFromOrigin)

Creates an absolute position from the parent origin on either the X or Y axis.

Parameters
absoluteDistanceFromOriginthe distance from the origin

Definition at line 85 of file juce_RelativeCoordinate.cpp.

◆ RelativeCoordinate() [6/6]

juce::RelativeCoordinate::RelativeCoordinate ( const String stringVersion)

Recreates a coordinate from a string description.

The string will be parsed by ExpressionParser::parse().

Parameters
stringVersionthe expression to use
See also
toString

Definition at line 90 of file juce_RelativeCoordinate.cpp.

◆ ~RelativeCoordinate()

juce::RelativeCoordinate::~RelativeCoordinate ( )

Destructor.

Definition at line 96 of file juce_RelativeCoordinate.cpp.

Member Function Documentation

◆ getExpression()

const Expression & juce::RelativeCoordinate::getExpression ( ) const

Returns the expression that defines this coordinate.

Definition at line 132 of file juce_RelativeCoordinate.h.

◆ isDynamic()

bool juce::RelativeCoordinate::isDynamic ( ) const

Returns true if this coordinate depends on any other coordinates for its position.

Definition at line 143 of file juce_RelativeCoordinate.cpp.

◆ isRecursive()

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.

Definition at line 118 of file juce_RelativeCoordinate.cpp.

◆ moveToAbsolute()

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.

Definition at line 130 of file juce_RelativeCoordinate.cpp.

◆ operator!=()

bool juce::RelativeCoordinate::operator!= ( const RelativeCoordinate other) const
noexcept

Definition at line 105 of file juce_RelativeCoordinate.cpp.

◆ operator=() [1/2]

RelativeCoordinate & juce::RelativeCoordinate::operator= ( const RelativeCoordinate other)

Definition at line 68 of file juce_RelativeCoordinate.cpp.

◆ operator=() [2/2]

RelativeCoordinate & juce::RelativeCoordinate::operator= ( RelativeCoordinate &&  other)
noexcept

Definition at line 79 of file juce_RelativeCoordinate.cpp.

◆ operator==()

bool juce::RelativeCoordinate::operator== ( const RelativeCoordinate other) const
noexcept

Definition at line 100 of file juce_RelativeCoordinate.cpp.

◆ references()

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.

◆ resolve()

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.

Definition at line 110 of file juce_RelativeCoordinate.cpp.

◆ toString()

String juce::RelativeCoordinate::toString ( ) const

Returns a string which represents this coordinate.

For details of the string syntax, see the constructor notes.

Definition at line 148 of file juce_RelativeCoordinate.cpp.


The documentation for this class was generated from the following files: