Skip to content

Commit

Permalink
Restore in-window drag bounds limits
Browse files Browse the repository at this point in the history
With the corrected zoom drag i lost this feature. Restore it.

Closes surge-synthesizer#5286
  • Loading branch information
baconpaul committed Oct 21, 2021
1 parent 7bd8ce5 commit 9cb34ae
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/surge-xt/gui/overlays/OverlayWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,25 @@ void OverlayWrapper::mouseDrag(const juce::MouseEvent &e)
auto bounds = getBounds();
bounds += getLocalPoint(nullptr, e.source.getScreenPosition()).roundToInt() -
mouseDownWithinTarget;
auto tl = bounds.getTopLeft();
auto pw = 1.f * getParentComponent()->getWidth();
auto ph = 1.f * getParentComponent()->getHeight();
if (tl.x < 0)
bounds = bounds.translated(-tl.x, 0);
if (tl.x + bounds.getWidth() > pw)
{
// tlx + bgw = pw + q
// q = tlx + bgw - pw
auto q = tl.x + bounds.getWidth() - pw;
bounds = bounds.translated(-q, 0);
}
if (tl.y < 0)
bounds = bounds.translated(0, -tl.y);
if (tl.y + bounds.getHeight() > ph)
{
auto q = tl.y + bounds.getHeight() - ph;
bounds = bounds.translated(0, -q);
}
setBounds(bounds);
}
}
Expand Down

0 comments on commit 9cb34ae

Please sign in to comment.