Merge remote-tracking branch 'cappuccino/master'

This commit is contained in:
Didier Korthoudt
2018-05-29 12:04:40 +02:00
13 changed files with 176 additions and 71 deletions
+12 -5
View File
@@ -1057,14 +1057,21 @@ var CPControlBlackColor = [CPColor blackColor];
@end
@implementation CPControl (CPTrackingArea)
{
CPTrackingArea _controlTrackingArea;
}
- (void)updateTrackingAreas
{
[self removeAllTrackingAreas];
[self addTrackingArea:[[CPTrackingArea alloc] initWithRect:CGRectMakeZero()
options:CPTrackingMouseEnteredAndExited | CPTrackingActiveInKeyWindow | CPTrackingInVisibleRect
owner:self
userInfo:nil]];
if (_controlTrackingArea)
[self removeTrackingArea:_controlTrackingArea];
_controlTrackingArea = [[CPTrackingArea alloc] initWithRect:CGRectMakeZero()
options:CPTrackingMouseEnteredAndExited | CPTrackingActiveInKeyWindow | CPTrackingInVisibleRect
owner:self
userInfo:nil];
[self addTrackingArea:_controlTrackingArea];
[super updateTrackingAreas];
}
@end
+10 -8
View File
@@ -380,9 +380,10 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
effectiveIncrementLineHeight = incrementLineSize.height + trackInset.bottom,
slotSize = height - effectiveDecrementLineHeight - effectiveIncrementLineHeight,
minimumKnobLength = [self currentValueForThemeAttribute:"minimum-knob-length"],
knobVerticalInset = knobInset.top + knobInset.bottom,
knobWidth = width - knobInset.left - knobInset.right,
knobHeight = MAX(minimumKnobLength, (slotSize * _knobProportion)),
knobLocation = effectiveDecrementLineHeight + (slotSize - knobHeight) * [self floatValue];
knobHeight = MAX(minimumKnobLength, ((slotSize - knobVerticalInset) * _knobProportion)),
knobLocation = effectiveDecrementLineHeight + (slotSize - knobHeight - knobVerticalInset) * [self floatValue] + knobInset.top;
_partRects[CPScrollerDecrementPage] = CGRectMake(0.0, effectiveDecrementLineHeight, width, knobLocation - effectiveDecrementLineHeight);
_partRects[CPScrollerKnob] = CGRectMake(knobInset.left, knobLocation, knobWidth, knobHeight);
@@ -409,9 +410,10 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
effectiveIncrementLineWidth = incrementLineSize.width + trackInset.right,
slotSize = width - effectiveDecrementLineWidth - effectiveIncrementLineWidth,
minimumKnobLength = [self currentValueForThemeAttribute:"minimum-knob-length"],
knobWidth = MAX(minimumKnobLength, (slotSize * _knobProportion)),
knobHorizontalInset = knobInset.left + knobInset.right,
knobWidth = MAX(minimumKnobLength, ((slotSize - knobHorizontalInset) * _knobProportion)),
knobHeight = height - knobInset.top - knobInset.bottom,
knobLocation = effectiveDecrementLineWidth + (slotSize - knobWidth) * [self floatValue];
knobLocation = effectiveDecrementLineWidth + (slotSize - knobWidth - knobHorizontalInset) * [self floatValue] + knobInset.left;
_partRects[CPScrollerDecrementPage] = CGRectMake(effectiveDecrementLineWidth, 0.0, knobLocation - effectiveDecrementLineWidth, height);
_partRects[CPScrollerKnob] = CGRectMake(knobLocation, knobInset.top, knobWidth, knobHeight);
@@ -460,9 +462,6 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
*/
- (void)fadeOut
{
if ([self hasThemeState:CPThemeStateScrollViewLegacy])
return;
[_animationScroller startAnimation];
}
@@ -765,7 +764,10 @@ CPThemeStateScrollerKnobDark = CPThemeState("scroller-knob-dark");
if (_timerFadeOut)
[_timerFadeOut invalidate];
_timerFadeOut = [CPTimer scheduledTimerWithTimeInterval:1.2 target:self selector:@selector(_performFadeOut:) userInfo:nil repeats:NO];
if ([self hasThemeState:CPThemeStateScrollViewLegacy])
[self unsetThemeState:CPThemeStateSelected];
else
_timerFadeOut = [CPTimer scheduledTimerWithTimeInterval:1.2 target:self selector:@selector(_performFadeOut:) userInfo:nil repeats:NO];
}
+57 -4
View File
@@ -88,10 +88,6 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat
_recentsAutosaveName = nil;
[self _init];
#if PLATFORM(DOM)
_cancelButton._DOMElement.style.cursor = "default";
_searchButton._DOMElement.style.cursor = "default";
#endif
}
return self;
@@ -766,6 +762,63 @@ var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotificat
@end
#pragma mark -
@implementation CPSearchField (CPTrackingArea)
{
CPTrackingArea _searchButtonTrackingArea;
CPTrackingArea _cancelButtonTrackingArea;
}
- (void)updateTrackingAreas
{
if (_searchButtonTrackingArea)
{
[self removeTrackingArea:_searchButtonTrackingArea];
_searchButtonTrackingArea = nil;
}
if (_cancelButtonTrackingArea)
{
[self removeTrackingArea:_cancelButtonTrackingArea];
_cancelButtonTrackingArea = nil;
}
if (_searchButton)
{
_searchButtonTrackingArea = [[CPTrackingArea alloc] initWithRect:[_searchButton frame]
options:CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow
owner:self
userInfo:@{ @"isButton": YES }];
[self addTrackingArea:_searchButtonTrackingArea];
}
if (_cancelButton)
{
_cancelButtonTrackingArea = [[CPTrackingArea alloc] initWithRect:[_cancelButton frame]
options:CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow
owner:self
userInfo:@{ @"isButton": YES }];
[self addTrackingArea:_cancelButtonTrackingArea];
}
[super updateTrackingAreas];
}
- (void)cursorUpdate:(CPEvent)anEvent
{
if ([[[anEvent trackingArea] userInfo] objectForKey:@"isButton"])
[[CPCursor arrowCursor] set];
else
[super cursorUpdate:anEvent];
}
@end
#pragma mark -
var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
CPSendsWholeSearchStringKey = @"CPSendsWholeSearchStringKey",
CPSendsSearchStringImmediatelyKey = @"CPSendsSearchStringImmediatelyKey",
+22 -5
View File
@@ -1201,18 +1201,35 @@ The sum of the views and the sum of the dividers should be equal to the size of
@end
@implementation CPSplitView (CPTrackingArea)
{
CPMutableArray _splitViewTrackingAreas;
}
- (void)updateTrackingAreas
{
[self removeAllTrackingAreas];
if (_splitViewTrackingAreas)
{
for (var i = 0, count = [_splitViewTrackingAreas count]; i < count; i++)
[self removeTrackingArea:_splitViewTrackingAreas[i]];
_splitViewTrackingAreas = nil;
}
var options = CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow;
_splitViewTrackingAreas = @[];
for (var i = 0; i < _subviews.length - 1; i++)
[self addTrackingArea:[[CPTrackingArea alloc] initWithRect:[self effectiveRectOfDividerAtIndex:i]
options:options
owner:self
userInfo:nil]];
{
[_splitViewTrackingAreas addObject:[[CPTrackingArea alloc] initWithRect:[self effectiveRectOfDividerAtIndex:i]
options:options
owner:self
userInfo:nil]];
[self addTrackingArea:_splitViewTrackingAreas[i]];
}
[super updateTrackingAreas];
}
- (void)cursorUpdate:(CPEvent)anEvent
+22 -5
View File
@@ -461,21 +461,38 @@ var CPTableHeaderViewResizeZone = 3.0,
@end
@implementation CPTableHeaderView (CPTrackingArea)
{
CPMutableArray _tableHeaderViewTrackingAreas;
}
- (void)updateTrackingAreas
{
[self removeAllTrackingAreas];
if (_tableHeaderViewTrackingAreas)
{
for (var i = 0, count = [_tableHeaderViewTrackingAreas count]; i < count; i++)
[self removeTrackingArea:_tableHeaderViewTrackingAreas[i]];
_tableHeaderViewTrackingAreas = nil;
}
var options = CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow;
if (!_tableView)
return;
_tableHeaderViewTrackingAreas = @[];
for (var i = 0; i < _tableView._tableColumns.length; i++)
[self addTrackingArea:[[CPTrackingArea alloc] initWithRect:[self _cursorRectForColumn:i]
options:options
owner:self
userInfo:nil]];
{
[_tableHeaderViewTrackingAreas addObject:[[CPTrackingArea alloc] initWithRect:[self _cursorRectForColumn:i]
options:options
owner:self
userInfo:nil]];
[self addTrackingArea:_tableHeaderViewTrackingAreas[i]];
}
[super updateTrackingAreas];
}
- (void)cursorUpdate:(CPEvent)anEvent
+16 -5
View File
@@ -2183,21 +2183,32 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey",
@end
@implementation CPTextField (CPTrackingArea)
{
CPTrackingArea _textFieldTrackingArea;
}
- (void)updateTrackingAreas
{
[self removeAllTrackingAreas];
if (_textFieldTrackingArea)
{
[self removeTrackingArea:_textFieldTrackingArea];
_textFieldTrackingArea = nil;
}
if ([self isEnabled] && (_isEditable || _isSelectable))
{
var myBounds = CGRectMakeCopy([self bounds]),
contentInset = [self currentValueForThemeAttribute:@"content-inset"];
_textFieldTrackingArea = [[CPTrackingArea alloc] initWithRect:CGRectInsetByInset(myBounds, contentInset)
options:CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow
owner:self
userInfo:nil];
[self addTrackingArea:[[CPTrackingArea alloc] initWithRect:CGRectInsetByInset(myBounds, contentInset)
options:CPTrackingMouseEnteredAndExited | CPTrackingCursorUpdate | CPTrackingActiveInKeyWindow
owner:self
userInfo:nil]];
[self addTrackingArea:_textFieldTrackingArea];
}
[super updateTrackingAreas];
}
- (void)cursorUpdate:(CPEvent)anEvent
+9 -22
View File
@@ -428,7 +428,12 @@ var CPViewHighDPIDrawingEnabled = YES;
_inhibitDOMUpdates = NO;
_forceUpdates = NO;
}
// We force here an updateTrackingAreas in order to let the view install its own tracking areas
// in the case where an externally owned tracking area is installed on this view before putting
// it in the view hierarchy.
[self updateTrackingAreas];
}
return self;
}
@@ -3600,11 +3605,12 @@ setBoundsOrigin:
/*!
Invoked automatically when the views geometry changes such that its tracking areas need to be recalculated.
You should override this method to remove out of date tracking areas and add recomputed tracking areas;
You should override this method to remove out of date tracking areas, add recomputed tracking areas and then call super;
Cocoa calls this on every view, whereas they have tracking area(s) or not.
Cappuccino behaves differently :
- updateTrackingAreas is called when placing a view in the view hierarchy (that is in a window)
- updateTrackingAreas is called during initWithFrame
- updateTrackingAreas is also called when placing a view in the view hierarchy (that is in a window)
- if you have only CPTrackingInVisibleRect tracking areas attached to a view, it will not be called again (until you move the view in the hierarchy)
- if you have at least one non-CPTrackingInVisibleRect tracking area attached, it will be called every time the view geometry could be modified
You don't have to touch to CPTrackingInVisibleRect tracking areas, they will be automatically updated
@@ -3618,25 +3624,6 @@ setBoundsOrigin:
}
/*!
This utility method is intended for CPView subclasses overriding updateTrackingAreas
Typical use would be :
- (void)updateTrackingAreas
{
[self removeAllTrackingAreas];
... add your specific updated tracking areas ...
}
*/
- (void)removeAllTrackingAreas
{
while (_trackingAreas.length > 0)
[self _removeTrackingArea:_trackingAreas[0]];
}
// Internal methods
- (void)_removeTrackingArea:(CPTrackingArea)trackingArea
+1 -5
View File
@@ -1851,16 +1851,12 @@ CPTexturedBackgroundWindowMask
// CPLeftMouseDown is needed for window moving and resizing to work.
// CPMouseMoved is needed for rollover effects on title bar buttons.
if (sheet)
if (sheet && _sheetContext["isAttached"])
{
switch (type)
{
case CPLeftMouseDown:
// This is needed when a doubleClick occurs when the sheet is closing or opening
if (!_parentWindow)
return;
[_windowView mouseDown:anEvent];
// -dw- if the window is clicked, the sheet should come to front, and become key,
+12 -5
View File
@@ -984,15 +984,22 @@ _CPWindowViewResizeSlop = 3;
@end
@implementation _CPWindowView (TrackingAreaAdditions)
{
CPTrackingArea _windowViewTrackingArea;
}
- (void)updateTrackingAreas
{
[self removeAllTrackingAreas];
if (_windowViewTrackingArea)
[self removeTrackingArea:_windowViewTrackingArea];
[self addTrackingArea:[[CPTrackingArea alloc] initWithRect:[self contentRectForFrameRect:[self frame]]
options:CPTrackingCursorUpdate | CPTrackingActiveInActiveApp
owner:self
userInfo:nil]];
_windowViewTrackingArea = [[CPTrackingArea alloc] initWithRect:[self contentRectForFrameRect:[self frame]]
options:CPTrackingCursorUpdate | CPTrackingActiveInActiveApp
owner:self
userInfo:nil];
[self addTrackingArea:_windowViewTrackingArea];
[super updateTrackingAreas];
}
@end
+2 -2
View File
@@ -534,7 +534,7 @@ var themedButtonValues = nil,
// Overlay
[@"scroller-width", 14.0, CPThemeStateVertical],
[@"knob-inset", CGInsetMake(2.0, 0.0, 0.0, 0.0), CPThemeStateVertical],
[@"knob-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateVertical],
[@"track-inset", CGInsetMake(2.0, 0.0, 2.0, 0.0), CPThemeStateVertical],
[@"track-border-overlay", 12.0, CPThemeStateVertical],
[@"knob-slot-color", [CPNull null], CPThemeStateVertical],
@@ -610,7 +610,7 @@ var themedButtonValues = nil,
// Overlay
[@"scroller-width", 9.0],
[@"knob-inset", CGInsetMake(0.0, 0.0, 0.0, 2.0)],
[@"knob-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0)],
[@"track-inset", CGInsetMake(0.0, 2.0, 0.0, 2.0)],
[@"track-border-overlay", 12.0],
[@"knob-slot-color", [CPNull null]],
+7 -4
View File
@@ -1047,7 +1047,8 @@ var updateTrackingAreasCalls,
//
[view removeAllTrackingAreas];
[view removeTrackingArea:trackingArea];
[view removeTrackingArea:trackingArea2];
[self assert:0 equals:[[view trackingAreas] count] message:@"After removing all tracking areas"];
[self assert:nil equals:[trackingArea view] message:@"Tracking area should be unlinked"];
[self assert:nil equals:[trackingArea2 view] message:@"Tracking area should be unlinked"];
@@ -1069,7 +1070,8 @@ var updateTrackingAreasCalls,
[contentView addSubview:view];
[self assert:1 equals:updateTrackingAreasCalls message:@"Putting a view with a non CPTrackingAreaInVisibleRect in a window should call updateTrackingAreas"];
[view removeAllTrackingAreas];
[view removeTrackingArea:trackingArea];
[view removeTrackingArea:trackingArea2];
//
@@ -1099,7 +1101,8 @@ var updateTrackingAreasCalls,
var trackingAreaAll = [[CPTrackingArea alloc] initWithRect:CGRectMakeZero() options:CPTrackingMouseEnteredAndExited | CPTrackingMouseMoved | CPTrackingCursorUpdate | CPTrackingActiveInActiveApp | CPTrackingInVisibleRect owner:viewTA userInfo:nil];
[viewTA removeAllTrackingAreas];
[viewTA removeTrackingArea:trackingArea];
[viewTA removeTrackingArea:trackingArea2];
[viewTA addTrackingArea:trackingAreaAll];
// Mouse enters the tracking area
@@ -1160,7 +1163,7 @@ var updateTrackingAreasCalls,
var trackingAreaAllWithDrag = [[CPTrackingArea alloc] initWithRect:CGRectMakeZero() options:CPTrackingMouseEnteredAndExited | CPTrackingMouseMoved | CPTrackingCursorUpdate | CPTrackingActiveInActiveApp | CPTrackingInVisibleRect | CPTrackingEnabledDuringMouseDrag owner:viewTA userInfo:nil];
[viewTA removeAllTrackingAreas];
[viewTA removeTrackingArea:trackingAreaAll];
[viewTA addTrackingArea:trackingAreaAllWithDrag];
// Mouse enters the tracking area while dragging (option set)
File diff suppressed because one or more lines are too long
+5
View File
@@ -450,6 +450,11 @@ var NSButtonIsBorderedMask = 0x00800000,
_normalImage = [aCoder decodeObjectForKey:@"NSNormalImage"];
_alternateImage = [aCoder decodeObjectForKey:@"NSAlternateImage"];
// this check is needed to work around an IB issue that sometimes archives a NSFont into the _alternateImage
if (![_alternateImage isKindOfClass:[NSButtonImageSource class]])
_alternateImage = nil;
_allowsMixedState = (cellFlags2 & NSButtonAllowsMixedStateMask) ? YES : NO;
// Test in decreasing order of mask value to ensure the correct match,