Skip to content

Commit 75fee96

Browse files
committed
ComponentBoundsConstrainer: Fix off-by-one when constraining width/height and dragging top/left
1 parent c68c406 commit 75fee96

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

modules/juce_gui_basics/layout/juce_ComponentBoundsConstrainer.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,14 @@ void ComponentBoundsConstrainer::checkBounds (Rectangle<int>& bounds,
183183
bool isStretchingBottom,
184184
bool isStretchingRight)
185185
{
186+
bounds.setWidth (jlimit (minW, maxW, bounds.getWidth()));
187+
bounds.setHeight (jlimit (minH, maxH, bounds.getHeight()));
188+
186189
if (isStretchingLeft)
187-
bounds.setLeft (jlimit (old.getRight() - maxW, old.getRight() - minW, bounds.getX()));
188-
else
189-
bounds.setWidth (jlimit (minW, maxW, bounds.getWidth()));
190+
bounds = bounds.withRightX (old.getRight());
190191

191192
if (isStretchingTop)
192-
bounds.setTop (jlimit (old.getBottom() - maxH, old.getBottom() - minH, bounds.getY()));
193-
else
194-
bounds.setHeight (jlimit (minH, maxH, bounds.getHeight()));
193+
bounds = bounds.withBottomY (old.getBottom());
195194

196195
if (bounds.isEmpty())
197196
return;

0 commit comments

Comments
 (0)