mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-29 02:40:05 +00:00
DocumentWindow: Made macOS windows respect constrainer minSize when in split screen
This commit is contained in:
parent
46aa467303
commit
f9532f609e
1 changed files with 37 additions and 31 deletions
|
|
@ -1074,11 +1074,13 @@ public:
|
|||
|
||||
void liveResizingStart()
|
||||
{
|
||||
if (constrainer != nullptr)
|
||||
{
|
||||
constrainer->resizeStart();
|
||||
isFirstLiveResize = true;
|
||||
}
|
||||
if (constrainer == nullptr)
|
||||
return;
|
||||
|
||||
constrainer->resizeStart();
|
||||
isFirstLiveResize = true;
|
||||
|
||||
setFullScreenSizeConstraints (*constrainer);
|
||||
}
|
||||
|
||||
void liveResizingEnd()
|
||||
|
|
@ -1087,37 +1089,34 @@ public:
|
|||
constrainer->resizeEnd();
|
||||
}
|
||||
|
||||
NSRect constrainRect (NSRect r)
|
||||
NSRect constrainRect (const NSRect r)
|
||||
{
|
||||
if (constrainer != nullptr && ! isKioskMode())
|
||||
if (constrainer == nullptr || isKioskMode())
|
||||
return r;
|
||||
|
||||
const auto scale = getComponent().getDesktopScaleFactor();
|
||||
|
||||
auto pos = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r)));
|
||||
const auto original = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame])));
|
||||
|
||||
const auto screenBounds = Desktop::getInstance().getDisplays().getTotalBounds (true);
|
||||
|
||||
const bool inLiveResize = [window inLiveResize];
|
||||
|
||||
if (! inLiveResize || isFirstLiveResize)
|
||||
{
|
||||
auto scale = getComponent().getDesktopScaleFactor();
|
||||
isFirstLiveResize = false;
|
||||
|
||||
auto pos = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r)));
|
||||
auto original = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame])));
|
||||
|
||||
auto screenBounds = Desktop::getInstance().getDisplays().getTotalBounds (true);
|
||||
|
||||
const bool inLiveResize = [window inLiveResize];
|
||||
|
||||
if (! inLiveResize || isFirstLiveResize)
|
||||
{
|
||||
isFirstLiveResize = false;
|
||||
|
||||
isStretchingTop = (pos.getY() != original.getY() && pos.getBottom() == original.getBottom());
|
||||
isStretchingLeft = (pos.getX() != original.getX() && pos.getRight() == original.getRight());
|
||||
isStretchingBottom = (pos.getY() == original.getY() && pos.getBottom() != original.getBottom());
|
||||
isStretchingRight = (pos.getX() == original.getX() && pos.getRight() != original.getRight());
|
||||
}
|
||||
|
||||
constrainer->checkBounds (pos, original, screenBounds,
|
||||
isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight);
|
||||
|
||||
pos = ScalingHelpers::scaledScreenPosToUnscaled (scale, pos);
|
||||
r = flippedScreenRect (makeNSRect (pos));
|
||||
isStretchingTop = (pos.getY() != original.getY() && pos.getBottom() == original.getBottom());
|
||||
isStretchingLeft = (pos.getX() != original.getX() && pos.getRight() == original.getRight());
|
||||
isStretchingBottom = (pos.getY() == original.getY() && pos.getBottom() != original.getBottom());
|
||||
isStretchingRight = (pos.getX() == original.getX() && pos.getRight() != original.getRight());
|
||||
}
|
||||
|
||||
return r;
|
||||
constrainer->checkBounds (pos, original, screenBounds,
|
||||
isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight);
|
||||
|
||||
return flippedScreenRect (makeNSRect (ScalingHelpers::scaledScreenPosToUnscaled (scale, pos)));
|
||||
}
|
||||
|
||||
static void showArrowCursorIfNeeded()
|
||||
|
|
@ -1563,6 +1562,13 @@ private:
|
|||
return true;
|
||||
}
|
||||
|
||||
void setFullScreenSizeConstraints (const ComponentBoundsConstrainer& c)
|
||||
{
|
||||
const auto minSize = NSMakeSize (static_cast<float> (c.getMinimumWidth()),
|
||||
0.0f);
|
||||
[window setMinFullScreenContentSize: minSize];
|
||||
}
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NSViewComponentPeer)
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue