41 jassert (maxH >= minimumHeight);
42 jassert (minimumWidth > 0 && minimumHeight > 0);
47 if (minW > maxW) maxW = minW;
48 if (minH > maxH) maxH = minH;
54 jassert (maximumHeight >= minH);
55 jassert (maximumWidth > 0 && maximumHeight > 0);
57 maxW =
jmax (minW, maximumWidth);
58 maxH =
jmax (minH, maximumHeight);
64 int maximumHeight)
noexcept
66 jassert (maximumWidth >= minimumWidth);
67 jassert (maximumHeight >= minimumHeight);
68 jassert (maximumWidth > 0 && maximumHeight > 0);
69 jassert (minimumWidth > 0 && minimumHeight > 0);
71 minW =
jmax (0, minimumWidth);
72 minH =
jmax (0, minimumHeight);
73 maxW =
jmax (minW, maximumWidth);
74 maxH =
jmax (minH, maximumHeight);
78 int minimumWhenOffTheLeft,
79 int minimumWhenOffTheBottom,
80 int minimumWhenOffTheRight)
noexcept
82 minOffTop = minimumWhenOffTheTop;
83 minOffLeft = minimumWhenOffTheLeft;
84 minOffBottom = minimumWhenOffTheBottom;
85 minOffRight = minimumWhenOffTheRight;
90 aspectRatio =
jmax (0.0, widthOverHeight);
100 bool isStretchingTop,
101 bool isStretchingLeft,
102 bool isStretchingBottom,
103 bool isStretchingRight)
105 jassert (component !=
nullptr);
107 auto bounds = targetBounds;
112 return { parent->
getWidth(), parent->getHeight() };
126 if (
auto* peer = component->
getPeer())
127 if (
const auto frameSize = peer->getFrameSizeIfPresent())
133 border.
addTo (bounds);
136 border.addedTo (component->
getBounds()), limits,
137 isStretchingTop, isStretchingLeft,
138 isStretchingBottom, isStretchingRight);
140 border.subtractFrom (bounds);
148 false,
false,
false,
false);
154 positioner->applyNewBounds (bounds);
172 bool isStretchingTop,
173 bool isStretchingLeft,
174 bool isStretchingBottom,
175 bool isStretchingRight)
177 if (isStretchingLeft)
194 if (bounds.
getY() < limit)
207 if (bounds.
getX() < limit)
209 if (isStretchingLeft)
216 if (minOffBottom > 0)
220 if (bounds.
getY() > limit)
222 if (isStretchingBottom)
233 if (bounds.
getX() > limit)
235 if (isStretchingRight)
243 if (aspectRatio > 0.0)
247 if ((isStretchingTop || isStretchingBottom) && ! (isStretchingLeft || isStretchingRight))
251 else if ((isStretchingLeft || isStretchingRight) && ! (isStretchingTop || isStretchingBottom))
258 const double newRatio = std::abs (bounds.
getWidth() / (
double) bounds.
getHeight());
260 adjustWidth = (oldRatio > newRatio);
284 if ((isStretchingTop || isStretchingBottom) && ! (isStretchingLeft || isStretchingRight))
288 else if ((isStretchingLeft || isStretchingRight) && ! (isStretchingTop || isStretchingBottom))
294 if (isStretchingLeft)
Specifies a set of gaps to be left around the sides of a rectangle.
void addTo(Rectangle< ValueType > &rectangle) const noexcept
Adds this border around a given rectangle.
double getFixedAspectRatio() const noexcept
Returns the aspect ratio that was set with setFixedAspectRatio().
void setMaximumHeight(int maximumHeight) noexcept
Imposes a maximum height limit.
void setMinimumSize(int minimumWidth, int minimumHeight) noexcept
Imposes a minimum width and height limit.
void setFixedAspectRatio(double widthOverHeight) noexcept
Specifies a width-to-height ratio that the resizer should always maintain.
void setMinimumOnscreenAmounts(int minimumWhenOffTheTop, int minimumWhenOffTheLeft, int minimumWhenOffTheBottom, int minimumWhenOffTheRight) noexcept
Sets the amount by which the component is allowed to go off-screen.
void setBoundsForComponent(Component *component, Rectangle< int > bounds, bool isStretchingTop, bool isStretchingLeft, bool isStretchingBottom, bool isStretchingRight)
Checks the given bounds, and then sets the component to the corrected size.
void setMinimumWidth(int minimumWidth) noexcept
Imposes a minimum width limit.
void setMaximumSize(int maximumWidth, int maximumHeight) noexcept
Imposes a maximum width and height limit.
void setMinimumHeight(int minimumHeight) noexcept
Imposes a minimum height limit.
virtual void resizeEnd()
This callback happens when the resizer has finished dragging.
virtual void applyBoundsToComponent(Component &, Rectangle< int > bounds)
Called by setBoundsForComponent() to apply a new constrained size to a component.
void setMaximumWidth(int maximumWidth) noexcept
Imposes a maximum width limit.
virtual ~ComponentBoundsConstrainer()
Destructor.
ComponentBoundsConstrainer() noexcept
When first created, the object will not impose any restrictions on the components.
void setSizeLimits(int minimumWidth, int minimumHeight, int maximumWidth, int maximumHeight) noexcept
Set all the maximum and minimum dimensions.
virtual void resizeStart()
This callback happens when the resizer is about to start dragging.
void checkComponentBounds(Component *component)
Performs a check on the current size of a component, and moves or resizes it if it fails the constrai...
virtual void checkBounds(Rectangle< int > &bounds, const Rectangle< int > &previousBounds, const Rectangle< int > &limits, bool isStretchingTop, bool isStretchingLeft, bool isStretchingBottom, bool isStretchingRight)
This callback changes the given coordinates to impose whatever the current constraints are set to be.
The base class for all JUCE user-interface objects.
Component * getParentComponent() const noexcept
Returns the component which this component is inside.
Point< int > getPosition() const noexcept
Returns the component's top-left position as a Point.
Rectangle< int > getLocalArea(const Component *sourceComponent, Rectangle< int > areaRelativeToSourceComponent) const
Converts a rectangle to be relative to this component's coordinate space.
Positioner * getPositioner() const noexcept
Returns the Positioner object that has been set for this component.
Rectangle< int > getBounds() const noexcept
Returns this component's bounding box.
Rectangle< int > localAreaToGlobal(Rectangle< int > localArea) const
Converts a rectangle from this component's coordinate space to a screen coordinate.
void setBounds(int x, int y, int width, int height)
Changes the component's position and size.
ComponentPeer * getPeer() const
Returns the heavyweight window that contains this component.
const Displays & getDisplays() const noexcept
Returns the Displays object representing the connected displays.
static Desktop &JUCE_CALLTYPE getInstance()
There's only one desktop object, and this method will return it.
const Display * getDisplayForPoint(Point< int > point, bool isPhysical=false) const noexcept
Returns the Display object representing the display containing a given Point (either in logical or ph...
Manages a rectangle and allows geometric operations to be performed on it.
ValueType getRight() const noexcept
Returns the x coordinate of the rectangle's right-hand-side.
void setLeft(ValueType newLeft) noexcept
Moves the x position, adjusting the width so that the right-hand edge remains in the same place.
void setY(ValueType newY) noexcept
Changes the rectangle's Y coordinate.
ValueType getX() const noexcept
Returns the x coordinate of the rectangle's left-hand-side.
void setRight(ValueType newRight) noexcept
Adjusts the width so that the right-hand edge of the rectangle has this new value.
void setHeight(ValueType newHeight) noexcept
Changes the rectangle's height.
void setBottom(ValueType newBottom) noexcept
Adjusts the height so that the bottom edge of the rectangle has this new value.
ValueType getBottom() const noexcept
Returns the y coordinate of the rectangle's bottom edge.
ValueType getWidth() const noexcept
Returns the width of the rectangle.
void setTop(ValueType newTop) noexcept
Moves the y position, adjusting the height so that the bottom edge remains in the same place.
ValueType getY() const noexcept
Returns the y coordinate of the rectangle's top edge.
bool isEmpty() const noexcept
Returns true if the rectangle's width or height are zero or less.
void setX(ValueType newX) noexcept
Changes the rectangle's X coordinate.
void setWidth(ValueType newWidth) noexcept
Changes the rectangle's width.
ValueType getHeight() const noexcept
Returns the height of the rectangle.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.