CPWindow: add CPWindowWillStartLiveResizeNotification and CPWindowDidEndLiveResizeNotification

Also fixed CPView -(BOOL)inLiveResize
If a view is added during a live resize, it will not receive a
willStart notif.
If a view is removed during a live resize it will not receive a Didend
notif.
This commit is contained in:
cacaodev committed 2017-05-20 13:52:50 +02:00
1 parent d0cd976246
commit 0f767d9dfc
4 files changed
+33 -2

No files matched your search

+1 -1
View File
@@ -2983,7 +2983,7 @@ setBoundsOrigin:
*/
- (BOOL)inLiveResize
{
return _inLiveResize;
return [self window] && [[self window] _inLiveResize];
}
/*!
+19
View File
@@ -2018,6 +2018,25 @@ CPTexturedBackgroundWindowMask
}
}
- (void)_startLiveResize
{
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowWillStartLiveResizeNotification
object:self];
}
- (void)_endLiveResize
{
[[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidEndLiveResizeNotification
object:self];
}
- (BOOL)_inLiveResize
{
return [_windowView _isTracking];
}
/*!
Returns the window's number in the desktop's screen list
*/
+2
View File
@@ -176,6 +176,8 @@ CPWindowDidEndSheetNotification = @"CPWindowDidEndSheetNotificat
CPWindowDidMiniaturizeNotification = @"CPWindowDidMiniaturizeNotification";
CPWindowWillMiniaturizeNotification = @"CPWindowWillMiniaturizeNotification";
CPWindowDidDeminiaturizeNotification = @"CPWindowDidDeminiaturizeNotification";
CPWindowWillStartLiveResizeNotification = @"CPWindowWillStartLiveResizeNotification";
CPWindowDidEndLiveResizeNotification = @"CPWindowDidEndLiveResizeNotification";
_CPWindowDidChangeFirstResponderNotification = @"_CPWindowDidChangeFirstResponderNotification";
+11 -1
View File
@@ -64,6 +64,8 @@ _CPWindowViewResizeSlop = 3;
CGRect _cachedScreenFrame;
CPView _sheetShadowView;
BOOL _isTracking @accessors(getter=_isTracking);
}
+ (CGRect)contentRectForFrameRect:(CGRect)aFrameRect
@@ -148,6 +150,7 @@ _CPWindowViewResizeSlop = 3;
_styleMask = aStyleMask;
_resizeIndicatorOffset = CGSizeMakeZero();
_toolbarOffset = CGSizeMakeZero();
_isTracking = NO;
}
return self;
@@ -458,6 +461,8 @@ _CPWindowViewResizeSlop = 3;
if (type === CPLeftMouseUp)
{
_cachedScreenFrame = nil;
_isTracking = NO;
[_window _endLiveResize];
return;
}
@@ -474,6 +479,12 @@ _CPWindowViewResizeSlop = 3;
}
else if (type === CPLeftMouseDragged)
{
if (!_isTracking)
{
_isTracking = YES;
[_window _startLiveResize];
}
var deltaX = globalLocation.x - _mouseDraggedPoint.x,
deltaY = globalLocation.y - _mouseDraggedPoint.y,
startX = CGRectGetMinX(_cachedFrame),
@@ -985,4 +996,3 @@ _CPWindowViewResizeSlop = 3;
}
@end