LMMS
Loading...
Searching...
No Matches
juce::Rectangle< ValueType > Class Template Reference

#include <juce_Rectangle.h>

Public Member Functions

 Rectangle ()=default
 Rectangle (const Rectangle &)=default
 Rectangle (ValueType initialX, ValueType initialY, ValueType width, ValueType height) noexcept
 Rectangle (ValueType width, ValueType height) noexcept
 Rectangle (Point< ValueType > corner1, Point< ValueType > corner2) noexcept
Rectangleoperator= (const Rectangle &)=default
 ~Rectangle ()=default
bool isEmpty () const noexcept
bool isFinite () const noexcept
ValueType getX () const noexcept
ValueType getY () const noexcept
ValueType getWidth () const noexcept
ValueType getHeight () const noexcept
ValueType getRight () const noexcept
ValueType getBottom () const noexcept
ValueType getCentreX () const noexcept
ValueType getCentreY () const noexcept
Point< ValueType > getCentre () const noexcept
ValueType getAspectRatio (bool widthOverHeight=true) const noexcept
Point< ValueType > getPosition () const noexcept
void setPosition (Point< ValueType > newPos) noexcept
void setPosition (ValueType newX, ValueType newY) noexcept
Point< ValueType > getTopLeft () const noexcept
Point< ValueType > getTopRight () const noexcept
Point< ValueType > getBottomLeft () const noexcept
Point< ValueType > getBottomRight () const noexcept
Range< ValueType > getHorizontalRange () const noexcept
Range< ValueType > getVerticalRange () const noexcept
void setSize (ValueType newWidth, ValueType newHeight) noexcept
void setBounds (ValueType newX, ValueType newY, ValueType newWidth, ValueType newHeight) noexcept
void setX (ValueType newX) noexcept
void setY (ValueType newY) noexcept
void setWidth (ValueType newWidth) noexcept
void setHeight (ValueType newHeight) noexcept
void setCentre (ValueType newCentreX, ValueType newCentreY) noexcept
void setCentre (Point< ValueType > newCentre) noexcept
void setHorizontalRange (Range< ValueType > range) noexcept
void setVerticalRange (Range< ValueType > range) noexcept
JUCE_NODISCARD Rectangle withX (ValueType newX) const noexcept
JUCE_NODISCARD Rectangle withY (ValueType newY) const noexcept
JUCE_NODISCARD Rectangle withRightX (ValueType newRightX) const noexcept
JUCE_NODISCARD Rectangle withBottomY (ValueType newBottomY) const noexcept
JUCE_NODISCARD Rectangle withPosition (ValueType newX, ValueType newY) const noexcept
JUCE_NODISCARD Rectangle withPosition (Point< ValueType > newPos) const noexcept
JUCE_NODISCARD Rectangle withZeroOrigin () const noexcept
JUCE_NODISCARD Rectangle withCentre (Point< ValueType > newCentre) const noexcept
JUCE_NODISCARD Rectangle withWidth (ValueType newWidth) const noexcept
JUCE_NODISCARD Rectangle withHeight (ValueType newHeight) const noexcept
JUCE_NODISCARD Rectangle withSize (ValueType newWidth, ValueType newHeight) const noexcept
JUCE_NODISCARD Rectangle withSizeKeepingCentre (ValueType newWidth, ValueType newHeight) const noexcept
void setLeft (ValueType newLeft) noexcept
JUCE_NODISCARD Rectangle withLeft (ValueType newLeft) const noexcept
void setTop (ValueType newTop) noexcept
JUCE_NODISCARD Rectangle withTop (ValueType newTop) const noexcept
void setRight (ValueType newRight) noexcept
JUCE_NODISCARD Rectangle withRight (ValueType newRight) const noexcept
void setBottom (ValueType newBottom) noexcept
JUCE_NODISCARD Rectangle withBottom (ValueType newBottom) const noexcept
JUCE_NODISCARD Rectangle withTrimmedLeft (ValueType amountToRemove) const noexcept
JUCE_NODISCARD Rectangle withTrimmedRight (ValueType amountToRemove) const noexcept
JUCE_NODISCARD Rectangle withTrimmedTop (ValueType amountToRemove) const noexcept
JUCE_NODISCARD Rectangle withTrimmedBottom (ValueType amountToRemove) const noexcept
void translate (ValueType deltaX, ValueType deltaY) noexcept
Rectangle translated (ValueType deltaX, ValueType deltaY) const noexcept
Rectangle operator+ (Point< ValueType > deltaPosition) const noexcept
Rectangleoperator+= (Point< ValueType > deltaPosition) noexcept
Rectangle operator- (Point< ValueType > deltaPosition) const noexcept
Rectangleoperator-= (Point< ValueType > deltaPosition) noexcept
template<typename FloatType>
Rectangle operator* (FloatType scaleFactor) const noexcept
template<typename FloatType>
Rectangle operator*= (FloatType scaleFactor) noexcept
template<typename FloatType>
Rectangle operator*= (Point< FloatType > scaleFactor) noexcept
template<typename FloatType>
Rectangle operator/ (FloatType scaleFactor) const noexcept
template<typename FloatType>
Rectangle operator/= (FloatType scaleFactor) noexcept
template<typename FloatType>
Rectangle operator/= (Point< FloatType > scaleFactor) noexcept
void expand (ValueType deltaX, ValueType deltaY) noexcept
Rectangle expanded (ValueType deltaX, ValueType deltaY) const noexcept
Rectangle expanded (ValueType delta) const noexcept
void reduce (ValueType deltaX, ValueType deltaY) noexcept
Rectangle reduced (ValueType deltaX, ValueType deltaY) const noexcept
Rectangle reduced (ValueType delta) const noexcept
Rectangle removeFromTop (ValueType amountToRemove) noexcept
Rectangle removeFromLeft (ValueType amountToRemove) noexcept
Rectangle removeFromRight (ValueType amountToRemove) noexcept
Rectangle removeFromBottom (ValueType amountToRemove) noexcept
Point< ValueType > getConstrainedPoint (Point< ValueType > point) const noexcept
template<typename FloatType>
Point< ValueType > getRelativePoint (FloatType relativeX, FloatType relativeY) const noexcept
template<typename FloatType>
ValueType proportionOfWidth (FloatType proportion) const noexcept
template<typename FloatType>
ValueType proportionOfHeight (FloatType proportion) const noexcept
template<typename FloatType>
Rectangle getProportion (Rectangle< FloatType > proportionalRect) const noexcept
bool operator== (const Rectangle &other) const noexcept
bool operator!= (const Rectangle &other) const noexcept
bool contains (ValueType xCoord, ValueType yCoord) const noexcept
bool contains (Point< ValueType > point) const noexcept
bool contains (Rectangle other) const noexcept
bool intersects (Rectangle other) const noexcept
bool intersects (const Line< ValueType > &line) const noexcept
Rectangle getIntersection (Rectangle other) const noexcept
bool intersectRectangle (ValueType &otherX, ValueType &otherY, ValueType &otherW, ValueType &otherH) const noexcept
bool intersectRectangle (Rectangle< ValueType > &rectangleToClip) const noexcept
Rectangle getUnion (Rectangle other) const noexcept
bool enlargeIfAdjacent (Rectangle other) noexcept
bool reduceIfPartlyContainedIn (Rectangle other) noexcept
Rectangle constrainedWithin (Rectangle areaToFitWithin) const noexcept
Rectangle transformedBy (const AffineTransform &transform) const noexcept
Rectangle< intgetSmallestIntegerContainer () const noexcept
Rectangle< inttoNearestInt () const noexcept
Rectangle< inttoNearestIntEdges () const noexcept
Rectangle< float > toFloat () const noexcept
Rectangle< double > toDouble () const noexcept
template<typename TargetType>
Rectangle< TargetType > toType () const noexcept
String toString () const
Rectangle transformed (const AffineTransform &t) const noexcept
template<typename T>
 Rectangle () noexcept
template<typename T>
 Rectangle (const T &x, const T &y, const T &w, const T &h) noexcept
template<typename T>
 Rectangle (const T &x, const T &y, const Size< T > &s) noexcept
template<typename T>
 Rectangle (const Point< T > &p, const T &w, const T &h) noexcept
template<typename T>
 Rectangle (const Point< T > &p, const Size< T > &s) noexcept
template<typename T>
 Rectangle (const Rectangle< T > &rect) noexcept
template<typename T>
Rectangle< T > & operator*= (double m) noexcept
template<typename T>
Rectangle< T > & operator/= (double d) noexcept

Static Public Member Functions

static Rectangle leftTopRightBottom (ValueType left, ValueType top, ValueType right, ValueType bottom) noexcept
static Rectangle findAreaContainingPoints (const Point< ValueType > *points, int numPoints) noexcept
static bool intersectRectangles (ValueType &x1, ValueType &y1, ValueType &w1, ValueType &h1, ValueType x2, ValueType y2, ValueType w2, ValueType h2) noexcept
static Rectangle fromString (StringRef stringVersion)

Private Member Functions

void copyWithRounding (Rectangle< int > &result) const noexcept
void copyWithRounding (Rectangle< float > &result) const noexcept
void copyWithRounding (Rectangle< double > &result) const noexcept

Private Attributes

Point< ValueType > pos
ValueType w {}
ValueType h {}

Friends

template<typename OtherType>
class Rectangle

Detailed Description

template<typename ValueType>
class juce::Rectangle< ValueType >

Manages a rectangle and allows geometric operations to be performed on it.

See also
RectangleList, Path, Line, Point

@tags{Graphics}

Constructor & Destructor Documentation

◆ Rectangle() [1/11]

template<typename ValueType>
juce::Rectangle< ValueType >::Rectangle ( )
default

Creates a rectangle of zero size. The default coordinates will be (0, 0, 0, 0).

◆ Rectangle() [2/11]

template<typename ValueType>
juce::Rectangle< ValueType >::Rectangle ( const Rectangle< ValueType > & )
default

Creates a copy of another rectangle.

◆ Rectangle() [3/11]

template<typename ValueType>
juce::Rectangle< ValueType >::Rectangle ( ValueType initialX,
ValueType initialY,
ValueType width,
ValueType height )
inlinenoexcept

Creates a rectangle with a given position and size.

◆ Rectangle() [4/11]

template<typename ValueType>
juce::Rectangle< ValueType >::Rectangle ( ValueType width,
ValueType height )
inlinenoexcept

Creates a rectangle with a given size, and a position of (0, 0).

◆ Rectangle() [5/11]

template<typename ValueType>
juce::Rectangle< ValueType >::Rectangle ( Point< ValueType > corner1,
Point< ValueType > corner2 )
inlinenoexcept

Creates a Rectangle from the positions of two opposite corners.

◆ ~Rectangle()

template<typename ValueType>
juce::Rectangle< ValueType >::~Rectangle ( )
default

Destructor.

◆ Rectangle() [6/11]

template<typename ValueType>
template<typename T>
juce::Rectangle< ValueType >::Rectangle ( )
noexcept

◆ Rectangle() [7/11]

template<typename ValueType>
template<typename T>
juce::Rectangle< ValueType >::Rectangle ( const T & x,
const T & y,
const T & w,
const T & h )
noexcept

◆ Rectangle() [8/11]

template<typename ValueType>
template<typename T>
juce::Rectangle< ValueType >::Rectangle ( const T & x,
const T & y,
const Size< T > & s )
noexcept

◆ Rectangle() [9/11]

template<typename ValueType>
template<typename T>
juce::Rectangle< ValueType >::Rectangle ( const Point< T > & p,
const T & w,
const T & h )
noexcept

◆ Rectangle() [10/11]

template<typename ValueType>
template<typename T>
juce::Rectangle< ValueType >::Rectangle ( const Point< T > & p,
const Size< T > & s )
noexcept

◆ Rectangle() [11/11]

template<typename ValueType>
template<typename T>
juce::Rectangle< ValueType >::Rectangle ( const Rectangle< T > & rect)
noexcept

Member Function Documentation

◆ constrainedWithin()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::constrainedWithin ( Rectangle< ValueType > areaToFitWithin) const
inlinenoexcept

Tries to fit this rectangle within a target area, returning the result.

If this rectangle is not completely inside the target area, then it'll be shifted (without changing its size) so that it lies within the target. If it is larger than the target rectangle in either dimension, then that dimension will be reduced to fit within the target.

◆ contains() [1/3]

template<typename ValueType>
bool juce::Rectangle< ValueType >::contains ( Point< ValueType > point) const
inlinenoexcept

Returns true if this coordinate is inside the rectangle.

◆ contains() [2/3]

template<typename ValueType>
bool juce::Rectangle< ValueType >::contains ( Rectangle< ValueType > other) const
inlinenoexcept

Returns true if this other rectangle is completely inside this one.

◆ contains() [3/3]

template<typename ValueType>
bool juce::Rectangle< ValueType >::contains ( ValueType xCoord,
ValueType yCoord ) const
inlinenoexcept

Returns true if this coordinate is inside the rectangle.

◆ copyWithRounding() [1/3]

template<typename ValueType>
void juce::Rectangle< ValueType >::copyWithRounding ( Rectangle< double > & result) const
inlineprivatenoexcept

◆ copyWithRounding() [2/3]

template<typename ValueType>
void juce::Rectangle< ValueType >::copyWithRounding ( Rectangle< float > & result) const
inlineprivatenoexcept

◆ copyWithRounding() [3/3]

template<typename ValueType>
void juce::Rectangle< ValueType >::copyWithRounding ( Rectangle< int > & result) const
inlineprivatenoexcept

◆ enlargeIfAdjacent()

template<typename ValueType>
bool juce::Rectangle< ValueType >::enlargeIfAdjacent ( Rectangle< ValueType > other)
inlinenoexcept

If this rectangle merged with another one results in a simple rectangle, this will set this rectangle to the result, and return true.

Returns false and does nothing to this rectangle if the two rectangles don't overlap, or if they form a complex region.

◆ expand()

template<typename ValueType>
void juce::Rectangle< ValueType >::expand ( ValueType deltaX,
ValueType deltaY )
inlinenoexcept

Expands the rectangle by a given amount.

Effectively, its new size is (x - deltaX, y - deltaY, w + deltaX * 2, h + deltaY * 2).

See also
expanded, reduce, reduced

◆ expanded() [1/2]

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::expanded ( ValueType delta) const
inlinenoexcept

Returns a rectangle that is larger than this one by a given amount.

Effectively, the rectangle returned is (x - delta, y - delta, w + delta * 2, h + delta * 2).

See also
expand, reduce, reduced

◆ expanded() [2/2]

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::expanded ( ValueType deltaX,
ValueType deltaY ) const
inlinenoexcept

Returns a rectangle that is larger than this one by a given amount.

Effectively, the rectangle returned is (x - deltaX, y - deltaY, w + deltaX * 2, h + deltaY * 2).

See also
expand, reduce, reduced

◆ findAreaContainingPoints()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::findAreaContainingPoints ( const Point< ValueType > * points,
int numPoints )
inlinestaticnoexcept

Returns the smallest Rectangle that can contain a set of points.

◆ fromString()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::fromString ( StringRef stringVersion)
inlinestatic

Parses a string containing a rectangle's details.

The string should contain 4 numeric tokens, in the form "x y width height". They can be comma or whitespace separated.

This method is intended to go with the toString() method, to form an easy way of saving/loading rectangles as strings.

See also
toString

◆ getAspectRatio()

template<typename ValueType>
ValueType juce::Rectangle< ValueType >::getAspectRatio ( bool widthOverHeight = true) const
inlinenoexcept

Returns the aspect ratio of the rectangle's width / height. If widthOverHeight is true, it returns width / height; if widthOverHeight is false, it returns height / width.

◆ getBottom()

template<typename ValueType>
ValueType juce::Rectangle< ValueType >::getBottom ( ) const
inlinenoexcept

Returns the y coordinate of the rectangle's bottom edge.

◆ getBottomLeft()

template<typename ValueType>
Point< ValueType > juce::Rectangle< ValueType >::getBottomLeft ( ) const
inlinenoexcept

Returns the rectangle's bottom-left position as a Point.

◆ getBottomRight()

template<typename ValueType>
Point< ValueType > juce::Rectangle< ValueType >::getBottomRight ( ) const
inlinenoexcept

Returns the rectangle's bottom-right position as a Point.

◆ getCentre()

template<typename ValueType>
Point< ValueType > juce::Rectangle< ValueType >::getCentre ( ) const
inlinenoexcept

Returns the centre point of the rectangle.

◆ getCentreX()

template<typename ValueType>
ValueType juce::Rectangle< ValueType >::getCentreX ( ) const
inlinenoexcept

Returns the x coordinate of the rectangle's centre.

◆ getCentreY()

template<typename ValueType>
ValueType juce::Rectangle< ValueType >::getCentreY ( ) const
inlinenoexcept

Returns the y coordinate of the rectangle's centre.

◆ getConstrainedPoint()

template<typename ValueType>
Point< ValueType > juce::Rectangle< ValueType >::getConstrainedPoint ( Point< ValueType > point) const
inlinenoexcept

Returns the nearest point to the specified point that lies within this rectangle.

◆ getHeight()

template<typename ValueType>
const T & Rectangle::getHeight ( ) const
inlinenoexcept

Returns the height of the rectangle.

◆ getHorizontalRange()

template<typename ValueType>
Range< ValueType > juce::Rectangle< ValueType >::getHorizontalRange ( ) const
inlinenoexcept

Returns the rectangle's left and right positions as a Range.

◆ getIntersection()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::getIntersection ( Rectangle< ValueType > other) const
inlinenoexcept

Returns the region that is the overlap between this and another rectangle. If the two rectangles don't overlap, the rectangle returned will be empty.

◆ getPosition()

template<typename ValueType>
Point< ValueType > juce::Rectangle< ValueType >::getPosition ( ) const
inlinenoexcept

Returns the rectangle's top-left position as a Point.

◆ getProportion()

template<typename ValueType>
template<typename FloatType>
Rectangle juce::Rectangle< ValueType >::getProportion ( Rectangle< FloatType > proportionalRect) const
inlinenoexcept

Returns a rectangle based on some proportional coordinates relative to this one. So for example getProportion ({ 0.25f, 0.25f, 0.5f, 0.5f }) would return a rectangle of half the original size, with the same centre.

◆ getRelativePoint()

template<typename ValueType>
template<typename FloatType>
Point< ValueType > juce::Rectangle< ValueType >::getRelativePoint ( FloatType relativeX,
FloatType relativeY ) const
inlinenoexcept

Returns a point within this rectangle, specified as proportional coordinates. The relative X and Y values should be between 0 and 1, where 0 is the left or top of this rectangle, and 1 is the right or bottom. (Out-of-bounds values will return a point outside the rectangle).

◆ getRight()

template<typename ValueType>
ValueType juce::Rectangle< ValueType >::getRight ( ) const
inlinenoexcept

Returns the x coordinate of the rectangle's right-hand-side.

◆ getSmallestIntegerContainer()

template<typename ValueType>
Rectangle< int > juce::Rectangle< ValueType >::getSmallestIntegerContainer ( ) const
inlinenoexcept

Returns the smallest integer-aligned rectangle that completely contains this one. This is only relevant for floating-point rectangles, of course.

See also
toFloat(), toNearestInt(), toNearestIntEdges()

◆ getTopLeft()

template<typename ValueType>
Point< ValueType > juce::Rectangle< ValueType >::getTopLeft ( ) const
inlinenoexcept

Returns the rectangle's top-left position as a Point.

◆ getTopRight()

template<typename ValueType>
Point< ValueType > juce::Rectangle< ValueType >::getTopRight ( ) const
inlinenoexcept

Returns the rectangle's top-right position as a Point.

◆ getUnion()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::getUnion ( Rectangle< ValueType > other) const
inlinenoexcept

Returns the smallest rectangle that contains both this one and the one passed-in.

If either this or the other rectangle are empty, they will not be counted as part of the resulting region.

◆ getVerticalRange()

template<typename ValueType>
Range< ValueType > juce::Rectangle< ValueType >::getVerticalRange ( ) const
inlinenoexcept

Returns the rectangle's top and bottom positions as a Range.

◆ getWidth()

template<typename ValueType>
const T & Rectangle::getWidth ( ) const
inlinenoexcept

Returns the width of the rectangle.

◆ getX()

template<typename ValueType>
const T & Rectangle::getX ( ) const
inlinenoexcept

Returns the x coordinate of the rectangle's left-hand-side.

◆ getY()

template<typename ValueType>
const T & Rectangle::getY ( ) const
inlinenoexcept

Returns the y coordinate of the rectangle's top edge.

◆ intersectRectangle() [1/2]

template<typename ValueType>
bool juce::Rectangle< ValueType >::intersectRectangle ( Rectangle< ValueType > & rectangleToClip) const
inlinenoexcept

Clips a rectangle so that it lies only within this one. Returns false if the two rectangles didn't overlap.

◆ intersectRectangle() [2/2]

template<typename ValueType>
bool juce::Rectangle< ValueType >::intersectRectangle ( ValueType & otherX,
ValueType & otherY,
ValueType & otherW,
ValueType & otherH ) const
inlinenoexcept

Clips a set of rectangle coordinates so that they lie only within this one. This is a non-static version of intersectRectangles(). Returns false if the two rectangles didn't overlap.

◆ intersectRectangles()

template<typename ValueType>
bool juce::Rectangle< ValueType >::intersectRectangles ( ValueType & x1,
ValueType & y1,
ValueType & w1,
ValueType & h1,
ValueType x2,
ValueType y2,
ValueType w2,
ValueType h2 )
inlinestaticnoexcept

Static utility to intersect two sets of rectangular coordinates. Returns false if the two regions didn't overlap.

See also
intersectRectangle

◆ intersects() [1/2]

template<typename ValueType>
bool juce::Rectangle< ValueType >::intersects ( const Line< ValueType > & line) const
inlinenoexcept

Returns true if any part of the given line lies inside this rectangle.

◆ intersects() [2/2]

template<typename ValueType>
bool juce::Rectangle< ValueType >::intersects ( Rectangle< ValueType > other) const
inlinenoexcept

Returns true if any part of another rectangle overlaps this one.

◆ isEmpty()

template<typename ValueType>
bool juce::Rectangle< ValueType >::isEmpty ( ) const
inlinenoexcept

Returns true if the rectangle's width or height are zero or less

◆ isFinite()

template<typename ValueType>
bool juce::Rectangle< ValueType >::isFinite ( ) const
inlinenoexcept

Returns true if the rectangle's values are all finite numbers, i.e. not NaN or infinity.

◆ leftTopRightBottom()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::leftTopRightBottom ( ValueType left,
ValueType top,
ValueType right,
ValueType bottom )
inlinestaticnoexcept

Creates a Rectangle from a set of left, right, top, bottom coordinates. The right and bottom values must be larger than the left and top ones, or the resulting rectangle will have a negative size.

◆ operator!=()

template<typename ValueType>
bool Rectangle::operator!= ( const Rectangle< ValueType > & other) const
inlinenoexcept

Returns true if the two rectangles are not identical.

◆ operator*()

template<typename ValueType>
template<typename FloatType>
Rectangle juce::Rectangle< ValueType >::operator* ( FloatType scaleFactor) const
inlinenoexcept

Returns a rectangle that has been scaled by the given amount, centred around the origin. Note that if the rectangle has int coordinates and it's scaled by a floating-point amount, then the result will be converted back to integer coordinates using getSmallestIntegerContainer().

◆ operator*=() [1/3]

template<typename ValueType>
template<typename T>
Rectangle< T > & juce::Rectangle< ValueType >::operator*= ( double m)
noexcept

◆ operator*=() [2/3]

template<typename ValueType>
template<typename FloatType>
Rectangle juce::Rectangle< ValueType >::operator*= ( FloatType scaleFactor)
inlinenoexcept

Scales this rectangle by the given amount, centred around the origin. Note that if the rectangle has int coordinates and it's scaled by a floating-point amount, then the result will be converted back to integer coordinates using getSmallestIntegerContainer().

◆ operator*=() [3/3]

template<typename ValueType>
template<typename FloatType>
Rectangle juce::Rectangle< ValueType >::operator*= ( Point< FloatType > scaleFactor)
inlinenoexcept

Scales this rectangle by the given X and Y factors, centred around the origin. Note that if the rectangle has int coordinates and it's scaled by a floating-point amount, then the result will be converted back to integer coordinates using getSmallestIntegerContainer().

◆ operator+()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::operator+ ( Point< ValueType > deltaPosition) const
inlinenoexcept

Returns a rectangle which is the same as this one moved by a given amount.

◆ operator+=()

template<typename ValueType>
Rectangle & juce::Rectangle< ValueType >::operator+= ( Point< ValueType > deltaPosition)
inlinenoexcept

Moves this rectangle by a given amount.

◆ operator-()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::operator- ( Point< ValueType > deltaPosition) const
inlinenoexcept

Returns a rectangle which is the same as this one moved by a given amount.

◆ operator-=()

template<typename ValueType>
Rectangle & juce::Rectangle< ValueType >::operator-= ( Point< ValueType > deltaPosition)
inlinenoexcept

Moves this rectangle by a given amount.

◆ operator/()

template<typename ValueType>
template<typename FloatType>
Rectangle juce::Rectangle< ValueType >::operator/ ( FloatType scaleFactor) const
inlinenoexcept

Scales this rectangle by the given amount, centred around the origin.

◆ operator/=() [1/3]

template<typename ValueType>
template<typename T>
Rectangle< T > & juce::Rectangle< ValueType >::operator/= ( double d)
noexcept

◆ operator/=() [2/3]

template<typename ValueType>
template<typename FloatType>
Rectangle juce::Rectangle< ValueType >::operator/= ( FloatType scaleFactor)
inlinenoexcept

Scales this rectangle by the given amount, centred around the origin.

◆ operator/=() [3/3]

template<typename ValueType>
template<typename FloatType>
Rectangle juce::Rectangle< ValueType >::operator/= ( Point< FloatType > scaleFactor)
inlinenoexcept

Scales this rectangle by the given X and Y factors, centred around the origin.

◆ operator=()

template<typename ValueType>
Rectangle< T > & Rectangle::operator= ( const Rectangle< ValueType > & )
defaultnoexcept

Creates a copy of another rectangle.

◆ operator==()

template<typename ValueType>
bool Rectangle::operator== ( const Rectangle< ValueType > & other) const
inlinenoexcept

Returns true if the two rectangles are identical.

◆ proportionOfHeight()

template<typename ValueType>
template<typename FloatType>
ValueType juce::Rectangle< ValueType >::proportionOfHeight ( FloatType proportion) const
inlinenoexcept

Returns a proportion of the height of this rectangle.

◆ proportionOfWidth()

template<typename ValueType>
template<typename FloatType>
ValueType juce::Rectangle< ValueType >::proportionOfWidth ( FloatType proportion) const
inlinenoexcept

Returns a proportion of the width of this rectangle.

◆ reduce()

template<typename ValueType>
void juce::Rectangle< ValueType >::reduce ( ValueType deltaX,
ValueType deltaY )
inlinenoexcept

Shrinks the rectangle by a given amount.

Effectively, its new size is (x + deltaX, y + deltaY, w - deltaX * 2, h - deltaY * 2).

See also
reduced, expand, expanded

◆ reduced() [1/2]

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::reduced ( ValueType delta) const
inlinenoexcept

Returns a rectangle that is smaller than this one by a given amount.

Effectively, the rectangle returned is (x + delta, y + delta, w - delta * 2, h - delta * 2).

See also
reduce, expand, expanded

◆ reduced() [2/2]

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::reduced ( ValueType deltaX,
ValueType deltaY ) const
inlinenoexcept

Returns a rectangle that is smaller than this one by a given amount.

Effectively, the rectangle returned is (x + deltaX, y + deltaY, w - deltaX * 2, h - deltaY * 2).

See also
reduce, expand, expanded

◆ reduceIfPartlyContainedIn()

template<typename ValueType>
bool juce::Rectangle< ValueType >::reduceIfPartlyContainedIn ( Rectangle< ValueType > other)
inlinenoexcept

If after removing another rectangle from this one the result is a simple rectangle, this will set this object's bounds to be the result, and return true.

Returns false and does nothing to this rectangle if the two rectangles don't overlap, or if removing the other one would form a complex region.

◆ removeFromBottom()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::removeFromBottom ( ValueType amountToRemove)
inlinenoexcept

Removes a strip from the bottom of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 350, 300, 50) and leave this rectangle as (100, 100, 300, 250).

If amountToRemove is greater than the height of this rectangle, it'll be clipped to that value.

◆ removeFromLeft()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::removeFromLeft ( ValueType amountToRemove)
inlinenoexcept

Removes a strip from the left-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 100, 50, 300) and leave this rectangle as (150, 100, 250, 300).

If amountToRemove is greater than the width of this rectangle, it'll be clipped to that value.

◆ removeFromRight()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::removeFromRight ( ValueType amountToRemove)
inlinenoexcept

Removes a strip from the right-hand edge of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (350, 100, 50, 300) and leave this rectangle as (100, 100, 250, 300).

If amountToRemove is greater than the width of this rectangle, it'll be clipped to that value.

◆ removeFromTop()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::removeFromTop ( ValueType amountToRemove)
inlinenoexcept

Removes a strip from the top of this rectangle, reducing this rectangle by the specified amount and returning the section that was removed.

E.g. if this rectangle is (100, 100, 300, 300) and amountToRemove is 50, this will return (100, 100, 300, 50) and leave this rectangle as (100, 150, 300, 250).

If amountToRemove is greater than the height of this rectangle, it'll be clipped to that value.

◆ setBottom()

template<typename ValueType>
void juce::Rectangle< ValueType >::setBottom ( ValueType newBottom)
inlinenoexcept

Adjusts the height so that the bottom edge of the rectangle has this new value. If the new bottom is lower than the current Y value, the Y will be pushed down to match it.

See also
getBottom, withBottom

◆ setBounds()

template<typename ValueType>
void juce::Rectangle< ValueType >::setBounds ( ValueType newX,
ValueType newY,
ValueType newWidth,
ValueType newHeight )
inlinenoexcept

Changes all the rectangle's coordinates.

◆ setCentre() [1/2]

template<typename ValueType>
void juce::Rectangle< ValueType >::setCentre ( Point< ValueType > newCentre)
inlinenoexcept

Changes the position of the rectangle's centre (leaving its size unchanged).

◆ setCentre() [2/2]

template<typename ValueType>
void juce::Rectangle< ValueType >::setCentre ( ValueType newCentreX,
ValueType newCentreY )
inlinenoexcept

Changes the position of the rectangle's centre (leaving its size unchanged).

◆ setHeight()

template<typename ValueType>
void Rectangle::setHeight ( ValueType newHeight)
inlinenoexcept

Changes the rectangle's height

◆ setHorizontalRange()

template<typename ValueType>
void juce::Rectangle< ValueType >::setHorizontalRange ( Range< ValueType > range)
inlinenoexcept

Changes the position of the rectangle's left and right edges.

◆ setLeft()

template<typename ValueType>
void juce::Rectangle< ValueType >::setLeft ( ValueType newLeft)
inlinenoexcept

Moves the x position, adjusting the width so that the right-hand edge remains in the same place. If the x is moved to be on the right of the current right-hand edge, the width will be set to zero.

See also
withLeft

◆ setPosition() [1/2]

template<typename ValueType>
void juce::Rectangle< ValueType >::setPosition ( Point< ValueType > newPos)
inlinenoexcept

Changes the position of the rectangle's top-left corner (leaving its size unchanged).

◆ setPosition() [2/2]

template<typename ValueType>
void juce::Rectangle< ValueType >::setPosition ( ValueType newX,
ValueType newY )
inlinenoexcept

Changes the position of the rectangle's top-left corner (leaving its size unchanged).

◆ setRight()

template<typename ValueType>
void juce::Rectangle< ValueType >::setRight ( ValueType newRight)
inlinenoexcept

Adjusts the width so that the right-hand edge of the rectangle has this new value. If the new right is below the current X value, the X will be pushed down to match it.

See also
getRight, withRight

◆ setSize()

template<typename ValueType>
void Rectangle::setSize ( ValueType newWidth,
ValueType newHeight )
inlinenoexcept

Changes the rectangle's size, leaving the position of its top-left corner unchanged.

◆ setTop()

template<typename ValueType>
void juce::Rectangle< ValueType >::setTop ( ValueType newTop)
inlinenoexcept

Moves the y position, adjusting the height so that the bottom edge remains in the same place. If the y is moved to be below the current bottom edge, the height will be set to zero.

See also
withTop

◆ setVerticalRange()

template<typename ValueType>
void juce::Rectangle< ValueType >::setVerticalRange ( Range< ValueType > range)
inlinenoexcept

Changes the position of the rectangle's top and bottom edges.

◆ setWidth()

template<typename ValueType>
void Rectangle::setWidth ( ValueType newWidth)
inlinenoexcept

Changes the rectangle's width

◆ setX()

template<typename ValueType>
void Rectangle::setX ( ValueType newX)
inlinenoexcept

Changes the rectangle's X coordinate

◆ setY()

template<typename ValueType>
void Rectangle::setY ( ValueType newY)
inlinenoexcept

Changes the rectangle's Y coordinate

◆ toDouble()

template<typename ValueType>
Rectangle< double > juce::Rectangle< ValueType >::toDouble ( ) const
inlinenoexcept

Casts this rectangle to a Rectangle<double>.

See also
getSmallestIntegerContainer

◆ toFloat()

template<typename ValueType>
Rectangle< float > juce::Rectangle< ValueType >::toFloat ( ) const
inlinenoexcept

Casts this rectangle to a Rectangle<float>.

See also
getSmallestIntegerContainer

◆ toNearestInt()

template<typename ValueType>
Rectangle< int > juce::Rectangle< ValueType >::toNearestInt ( ) const
inlinenoexcept

Casts this rectangle to a Rectangle<int>. This uses roundToInt to snap x, y, width and height to the nearest integer (losing precision). If the rectangle already uses integers, this will simply return a copy.

See also
getSmallestIntegerContainer(), toNearestIntEdges()

◆ toNearestIntEdges()

template<typename ValueType>
Rectangle< int > juce::Rectangle< ValueType >::toNearestIntEdges ( ) const
inlinenoexcept

Casts this rectangle to a Rectangle<int>. This uses roundToInt to snap top, left, right and bottom to the nearest integer (losing precision). If the rectangle already uses integers, this will simply return a copy.

See also
getSmallestIntegerContainer(), toNearestInt()

◆ toString()

template<typename ValueType>
String juce::Rectangle< ValueType >::toString ( ) const
inline

Creates a string describing this rectangle.

The string will be of the form "x y width height", e.g. "100 100 400 200".

Coupled with the fromString() method, this is very handy for things like storing rectangles (particularly component positions) in XML attributes.

See also
fromString

◆ toType()

template<typename ValueType>
template<typename TargetType>
Rectangle< TargetType > juce::Rectangle< ValueType >::toType ( ) const
inlinenoexcept

Casts this rectangle to a Rectangle with the given type. If the target type is a conversion from float to int, then the conversion will be done using getSmallestIntegerContainer().

◆ transformed()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::transformed ( const AffineTransform & t) const
inlinenoexcept

◆ transformedBy()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::transformedBy ( const AffineTransform & transform) const
inlinenoexcept

Returns the smallest rectangle that can contain the shape created by applying a transform to this rectangle.

This should only be used on floating point rectangles.

◆ translate()

template<typename ValueType>
void juce::Rectangle< ValueType >::translate ( ValueType deltaX,
ValueType deltaY )
inlinenoexcept

Moves the rectangle's position by adding amount to its x and y coordinates.

◆ translated()

template<typename ValueType>
Rectangle juce::Rectangle< ValueType >::translated ( ValueType deltaX,
ValueType deltaY ) const
inlinenoexcept

Returns a rectangle which is the same as this one moved by a given amount.

◆ withBottom()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withBottom ( ValueType newBottom) const
inlinenoexcept

Returns a new rectangle with a different bottom edge position, but the same top edge as this one. If the new y is beyond the bottom of the current rectangle, the height will be set to zero.

See also
setBottom

◆ withBottomY()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withBottomY ( ValueType newBottomY) const
inlinenoexcept

Returns a rectangle which has the same size and x-position as this one, but whose bottom edge has the given position.

◆ withCentre()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withCentre ( Point< ValueType > newCentre) const
inlinenoexcept

Returns a rectangle with the same size as this one, but a new centre position.

◆ withHeight()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withHeight ( ValueType newHeight) const
inlinenoexcept

Returns a rectangle which has the same position and width as this one, but with a different height.

◆ withLeft()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withLeft ( ValueType newLeft) const
inlinenoexcept

Returns a new rectangle with a different x position, but the same right-hand edge as this one. If the new x is beyond the right of the current right-hand edge, the width will be set to zero.

See also
setLeft

◆ withPosition() [1/2]

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withPosition ( Point< ValueType > newPos) const
inlinenoexcept

Returns a rectangle with the same size as this one, but a new position.

◆ withPosition() [2/2]

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withPosition ( ValueType newX,
ValueType newY ) const
inlinenoexcept

Returns a rectangle with the same size as this one, but a new position.

◆ withRight()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withRight ( ValueType newRight) const
inlinenoexcept

Returns a new rectangle with a different right-hand edge position, but the same left-hand edge as this one. If the new right edge is below the current left-hand edge, the width will be set to zero.

See also
setRight

◆ withRightX()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withRightX ( ValueType newRightX) const
inlinenoexcept

Returns a rectangle which has the same size and y-position as this one, but whose right-hand edge has the given position.

◆ withSize()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withSize ( ValueType newWidth,
ValueType newHeight ) const
inlinenoexcept

Returns a rectangle with the same top-left position as this one, but a new size.

◆ withSizeKeepingCentre()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withSizeKeepingCentre ( ValueType newWidth,
ValueType newHeight ) const
inlinenoexcept

Returns a rectangle with the same centre position as this one, but a new size.

◆ withTop()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withTop ( ValueType newTop) const
inlinenoexcept

Returns a new rectangle with a different y position, but the same bottom edge as this one. If the new y is beyond the bottom of the current rectangle, the height will be set to zero.

See also
setTop

◆ withTrimmedBottom()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withTrimmedBottom ( ValueType amountToRemove) const
inlinenoexcept

Returns a version of this rectangle with the given amount removed from its bottom edge.

◆ withTrimmedLeft()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withTrimmedLeft ( ValueType amountToRemove) const
inlinenoexcept

Returns a version of this rectangle with the given amount removed from its left-hand edge.

◆ withTrimmedRight()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withTrimmedRight ( ValueType amountToRemove) const
inlinenoexcept

Returns a version of this rectangle with the given amount removed from its right-hand edge.

◆ withTrimmedTop()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withTrimmedTop ( ValueType amountToRemove) const
inlinenoexcept

Returns a version of this rectangle with the given amount removed from its top edge.

◆ withWidth()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withWidth ( ValueType newWidth) const
inlinenoexcept

Returns a rectangle which has the same position and height as this one, but with a different width.

◆ withX()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withX ( ValueType newX) const
inlinenoexcept

Returns a rectangle which has the same size and y-position as this one, but with a different x-position.

◆ withY()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withY ( ValueType newY) const
inlinenoexcept

Returns a rectangle which has the same size and x-position as this one, but with a different y-position.

◆ withZeroOrigin()

template<typename ValueType>
JUCE_NODISCARD Rectangle juce::Rectangle< ValueType >::withZeroOrigin ( ) const
inlinenoexcept

Returns a rectangle whose size is the same as this one, but whose top-left position is (0, 0).

◆ Rectangle

template<typename ValueType>
template<typename OtherType>
friend class Rectangle
friend

Member Data Documentation

◆ h

template<typename ValueType>
ValueType juce::Rectangle< ValueType >::h {}
private

◆ pos

template<typename ValueType>
Point<ValueType> juce::Rectangle< ValueType >::pos
private

◆ w

template<typename ValueType>
ValueType juce::Rectangle< ValueType >::w {}
private

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