Browse Source

Only detect which corner is being resized on the first live resize callback

tags/2021-05-28
hogliux 9 years ago
parent
commit
437cb4e9a4
1 changed files with 22 additions and 15 deletions
  1. +22
    -15
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm

+ 22
- 15
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -75,7 +75,10 @@ public:
usingCoreGraphics (false), usingCoreGraphics (false),
#endif #endif
isZooming (false), isZooming (false),
isFirstLiveResize (false),
textWasInserted (false), textWasInserted (false),
isStretchingTop (false), isStretchingLeft (false),
isStretchingBottom (false), isStretchingRight (false),
notificationCenter (nil) notificationCenter (nil)
{ {
appFocusChangeCallback = appFocusChanged; appFocusChangeCallback = appFocusChanged;
@@ -986,7 +989,10 @@ public:
void liveResizingStart() void liveResizingStart()
{ {
if (constrainer != nullptr) if (constrainer != nullptr)
{
constrainer->resizeStart(); constrainer->resizeStart();
isFirstLiveResize = true;
}
} }
void liveResizingEnd() void liveResizingEnd()
@@ -1007,26 +1013,26 @@ public:
const Rectangle<int> screenBounds (Desktop::getInstance().getDisplays().getTotalBounds (true)); const Rectangle<int> screenBounds (Desktop::getInstance().getDisplays().getTotalBounds (true));
#if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
if ([window inLiveResize])
const bool inLiveResize = [window inLiveResize];
#else #else
if ([window respondsToSelector: @selector (inLiveResize)]
&& [window performSelector: @selector (inLiveResize)])
const bool inLiveResize = [window respondsToSelector: @selector (inLiveResize)]
&& [window performSelector: @selector (inLiveResize)];
#endif #endif
if (! inLiveResize || isFirstLiveResize)
{ {
constrainer->checkBounds (pos, original, screenBounds,
false, false, true, true);
}
else
{
constrainer->checkBounds (pos, original, screenBounds,
pos.getY() != original.getY() && pos.getBottom() == original.getBottom(),
pos.getX() != original.getX() && pos.getRight() == original.getRight(),
pos.getY() == original.getY() && pos.getBottom() != original.getBottom(),
pos.getX() == original.getX() && pos.getRight() != original.getRight());
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());
} }
pos = ScalingHelpers::scaledScreenPosToUnscaled (scale, pos);
constrainer->checkBounds (pos, original, screenBounds,
isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight);
pos = ScalingHelpers::scaledScreenPosToUnscaled (scale, pos);
r = flippedScreenRect (makeNSRect (pos)); r = flippedScreenRect (makeNSRect (pos));
} }
@@ -1318,7 +1324,8 @@ public:
NSWindow* window; NSWindow* window;
NSView* view; NSView* view;
bool isSharedWindow, fullScreen; bool isSharedWindow, fullScreen;
bool usingCoreGraphics, isZooming, textWasInserted;
bool usingCoreGraphics, isZooming, isFirstLiveResize, textWasInserted;
bool isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight;
String stringBeingComposed; String stringBeingComposed;
NSNotificationCenter* notificationCenter; NSNotificationCenter* notificationCenter;


Loading…
Cancel
Save