29namespace RelativeRectangleHelpers
33 s.incrementToEndOfWhitespace();
39 static bool dependsOnSymbolsOtherThanThis (
const Expression& e)
41 if (e.getType() == Expression::operatorType && e.getSymbolOrFunction() ==
".")
44 if (e.getType() == Expression::symbolType)
46 switch (RelativeCoordinate::StandardStrings::getTypeOf (e.getSymbolOrFunction()))
48 case RelativeCoordinate::StandardStrings::x:
49 case RelativeCoordinate::StandardStrings::y:
50 case RelativeCoordinate::StandardStrings::left:
51 case RelativeCoordinate::StandardStrings::right:
52 case RelativeCoordinate::StandardStrings::top:
53 case RelativeCoordinate::StandardStrings::bottom:
return false;
54 case RelativeCoordinate::StandardStrings::width:
55 case RelativeCoordinate::StandardStrings::height:
56 case RelativeCoordinate::StandardStrings::parent:
57 case RelativeCoordinate::StandardStrings::unknown:
66 for (
int i = e.getNumInputs(); --i >= 0;)
67 if (dependsOnSymbolsOtherThanThis (e.getInput (i)))
99 RelativeRectangleHelpers::skipComma (text);
101 RelativeRectangleHelpers::skipComma (text);
103 RelativeRectangleHelpers::skipComma (text);
109 return left ==
other.left && top ==
other.top && right ==
other.right && bottom ==
other.bottom;
112bool RelativeRectangle::operator!= (
const RelativeRectangle&
other)
const noexcept
114 return ! operator== (
other);
126 switch (RelativeCoordinate::StandardStrings::getTypeOf (symbol))
128 case RelativeCoordinate::StandardStrings::x:
129 case RelativeCoordinate::StandardStrings::left:
return rect.left.
getExpression();
130 case RelativeCoordinate::StandardStrings::y:
131 case RelativeCoordinate::StandardStrings::top:
return rect.top.
getExpression();
132 case RelativeCoordinate::StandardStrings::right:
return rect.right.
getExpression();
133 case RelativeCoordinate::StandardStrings::bottom:
return rect.bottom.
getExpression();
134 case RelativeCoordinate::StandardStrings::width:
135 case RelativeCoordinate::StandardStrings::height:
136 case RelativeCoordinate::StandardStrings::parent:
137 case RelativeCoordinate::StandardStrings::unknown:
152 if (scope ==
nullptr)
159 const double l = left.
resolve (scope);
160 const double r = right.
resolve (scope);
161 const double t = top.
resolve (scope);
162 const double b = bottom.
resolve (scope);
178 using namespace RelativeRectangleHelpers;
209 bool registerCoordinates()
override
211 bool ok = addCoordinate (rectangle.left);
212 ok = addCoordinate (rectangle.right) && ok;
213 ok = addCoordinate (rectangle.top) && ok;
214 ok = addCoordinate (rectangle.bottom) && ok;
220 return rectangle ==
other;
223 void applyToComponentBounds()
override
225 for (
int i = 32; --i >= 0;)
246 applyToComponentBounds();
262 if (current ==
nullptr || ! current->isUsingRectangle (*
this))
Wraps a pointer to a null-terminated UTF-8 character string, and provides various methods to operate ...
Component & getComponent() const noexcept
Returns the component that this positioner controls.
The base class for all JUCE user-interface objects.
void setPositioner(Positioner *newPositioner)
Sets a new Positioner object for this component.
Positioner * getPositioner() const noexcept
Returns the Positioner object that has been set for this component.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
When evaluating an Expression object, this class is used to resolve symbols and perform functions tha...
virtual Expression getSymbolValue(const String &symbol) const
Returns the value of a symbol.
A class for dynamically evaluating simple numeric expressions.
Expression withRenamedSymbol(const Symbol &oldSymbol, const String &newName, const Scope &scope) const
Returns a copy of this expression in which all instances of a given symbol have been renamed.
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...
Manages a rectangle and allows geometric operations to be performed on it.
Rectangle< int > getSmallestIntegerContainer() const noexcept
Returns the smallest integer-aligned rectangle that completely contains this one.
Used for resolving a RelativeCoordinate expression in the context of a component.
Base class for Component::Positioners that are based upon relative coordinates.
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.
const Expression & getExpression() const
Returns the expression that defines this coordinate.
String toString() const
Returns a string which represents this coordinate.
double resolve(const Expression::Scope *evaluationScope) const
Calculates the absolute position of this coordinate.
void applyNewBounds(const Rectangle< int > &newBounds) override
Attempts to set the component's position to the given rectangle.
Expression getSymbolValue(const String &symbol) const override
Returns the value of a symbol.
A rectangle stored as a set of RelativeCoordinate values.
RelativeRectangle()
Creates a zero-size rectangle at the origin.
void moveToAbsolute(const Rectangle< float > &newPos, const Expression::Scope *scope)
Changes the values of this rectangle's coordinates to make it resolve to the specified position.
const Rectangle< float > resolve(const Expression::Scope *scope) const
Calculates the absolute position of this rectangle.
void applyToComponent(Component &component) const
Creates and sets an appropriate Component::Positioner object for the given component,...
bool isDynamic() const
Returns true if this rectangle depends on any external symbols for its position.
String toString() const
Returns a string which represents this point.
void renameSymbol(const Expression::Symbol &oldSymbol, const String &newName, const Expression::Scope &scope)
Renames a symbol if it is used by any of the coordinates.
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.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Represents a symbol that is used in an Expression.