Revision: 29173
http://sourceforge.net/p/bibdesk/svn/29173
Author: hofman
Date: 2025-04-23 16:11:18 +0000 (Wed, 23 Apr 2025)
Log Message:
-----------
Always draww background in background view. Add it directly above the fileview
when there is no enclosing scroll view. Encode and decode various views and
cells.
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h 2025-04-23
14:32:18 UTC (rev 29172)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h 2025-04-23
16:11:18 UTC (rev 29173)
@@ -216,7 +216,6 @@
NSMapTable *_infoTable;
NSUInteger _numberOfColumns;
NSUInteger _numberOfRows;
- NSColor *_backgroundColor;
CFRunLoopTimerRef _zombieTimer;
NSIndexSet *_selectionIndexes;
CGLayerRef _selectionOverlay;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2025-04-23
14:32:18 UTC (rev 29172)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2025-04-23
16:11:18 UTC (rev 29173)
@@ -149,8 +149,6 @@
@property (nonatomic, strong) NSColor *backgroundColor;
@end
-static void FVFillBackgroundColorOrGradient(NSColor *backgroundColor, NSRect
rect, NSRect bounds, NSWindow *window);
-
#pragma mark -
@interface FVHighlightView : NSView {
@@ -160,6 +158,7 @@
}
@property (nonatomic, copy) NSArray *highlightRects;
@property (nonatomic) FVHighlightStyle highlightStyle;
+- (void)setHighlightStyleFromBackgroundColor:(NSColor *)color;
@end
#pragma mark -
@@ -285,10 +284,7 @@
- (void)_stopPreviewing;
- (void)_updatePreviewer;
- (void)handlePreviewerWillClose:(NSNotification *)aNote;
-- (void)_registerForKeyOrMainStateNotifications;
-- (void)_unregisterForKeyOrMainStateNotifications;
- (void)_updateHighlightRects;
-- (void)_updateHighlightStyle;
@end
@@ -306,7 +302,7 @@
@synthesize numberOfColumns=_numberOfColumns;
@dynamic editable;
@dynamic allowsDownloading;
-@synthesize backgroundColor=_backgroundColor;
+@dynamic backgroundColor;
@dynamic textColor;
@dynamic subtitleColor;
@dynamic font;
@@ -361,15 +357,28 @@
+ (BOOL)accessInstanceVariablesDirectly { return NO; }
- (void)_commonInit {
- _highlightView = [[FVHighlightView alloc] initWithFrame:[self bounds]];
- [_highlightView setHighlightStyle:floor(NSAppKitVersionNumber) >
NSAppKitVersionNumber10_9 ? FVHighlightStyleUnbordered :
FVHighlightStyleBordered];
- [_highlightView setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
- [self addSubview:_highlightView];
+ NSRect frame = [self bounds];
- _contentView = [[FVDisplayView alloc] initWithFrame:[self bounds]
delegate:self];
- [_contentView setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
- [self addSubview:_contentView];
+ if (_backgroundView == nil) {
+ _backgroundView = [[FVBackgroundView alloc] initWithFrame:frame];
+ [_backgroundView setBackgroundColor:[[self class]
defaultBackgroundColor]];
+ [_backgroundView setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
+ [self addSubview:_backgroundView];
+ }
+ if (_highlightView == nil) {
+ _highlightView = [[FVHighlightView alloc] initWithFrame:frame];
+ [_highlightView setHighlightStyleFromBackgroundColor:[_backgroundView
backgroundColor]];
+ [_highlightView setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
+ [self addSubview:_highlightView];
+ }
+
+ if (_contentView == nil) {
+ _contentView = [[FVDisplayView alloc] initWithFrame:frame
delegate:self];
+ [_contentView setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
+ [self addSubview:_contentView];
+ }
+
// Icons keyed by URL; may contain icons that are no longer displayed.
Keeping this as primary storage means that
// rearranging/reloading is relatively cheap, since we don't recreate all
FVIcon instances every time -reload is called.
_iconCache = [[NSMutableDictionary alloc] init];
@@ -389,8 +398,6 @@
_rubberBandView = nil;
_fvFlags.isMouseDown = NO;
_fvFlags.isEditable = NO;
- [self setBackgroundColor:[[self class] defaultBackgroundColor]];
- _selectionOverlay = NULL;
_numberOfColumns = 1;
_numberOfRows = 1;
@@ -430,19 +437,23 @@
// @@ Dark mode
- _titleCell = [[NSTextFieldCell alloc] initTextCell:@""];
- [_titleCell setFont:[NSFont systemFontOfSize:12.0]];
- [_titleCell setTextColor:[NSColor
respondsToSelector:@selector(labelColor)] ? [NSColor labelColor] : [NSColor
darkGrayColor]];
- [_titleCell setLineBreakMode:NSLineBreakByTruncatingTail];
- [_titleCell setAlignment:NSTextAlignmentCenter];
+ if (_titleCell == nil) {
+ _titleCell = [[NSTextFieldCell alloc] initTextCell:@""];
+ [_titleCell setFont:[NSFont systemFontOfSize:12.0]];
+ [_titleCell setTextColor:[NSColor
respondsToSelector:@selector(labelColor)] ? [NSColor labelColor] : [NSColor
darkGrayColor]];
+ [_titleCell setLineBreakMode:NSLineBreakByTruncatingTail];
+ [_titleCell setAlignment:NSTextAlignmentCenter];
+ }
// @@ Dark mode
- _subtitleCell = [[NSTextFieldCell alloc] initTextCell:@""];
- [_subtitleCell setFont:[NSFont systemFontOfSize:10.0]];
- [_subtitleCell setTextColor:[NSColor
respondsToSelector:@selector(secondaryLabelColor)] ? [NSColor
secondaryLabelColor] : [NSColor grayColor]];
- [_subtitleCell setLineBreakMode:NSLineBreakByTruncatingTail];
- [_subtitleCell setAlignment:NSTextAlignmentCenter];
+ if (_subtitleCell == nil) {
+ _subtitleCell = [[NSTextFieldCell alloc] initTextCell:@""];
+ [_subtitleCell setFont:[NSFont systemFontOfSize:10.0]];
+ [_subtitleCell setTextColor:[NSColor
respondsToSelector:@selector(secondaryLabelColor)] ? [NSColor
secondaryLabelColor] : [NSColor grayColor]];
+ [_subtitleCell setLineBreakMode:NSLineBreakByTruncatingTail];
+ [_subtitleCell setAlignment:NSTextAlignmentCenter];
+ }
_leftArrow = nil;
_rightArrow = nil;
@@ -490,16 +501,34 @@
return self;
}
-- (id)initWithCoder:(NSCoder *)coder {
+- (id)initWithCoder:(NSCoder *)coder
+{
self = [super initWithCoder:coder];
if (self) {
- for (NSView *view in [[self subviews] copy])
- [view removeFromSuperview];
+ _backgroundView = [coder decodeObjectForKey:@"backgroundView"];
+ _highlightView = [coder decodeObjectForKey:@"highlightView"];
+ _contentView = [coder decodeObjectForKey:@"contentView"];
+ _titleCell = [coder decodeObjectForKey:@"titleCell"];
+ _subtitleCell = [coder decodeObjectForKey:@"subtitleCell"];
+ for (NSView *view in [[self subviews] copy]) {
+ if ([view class] == [NSButton class])
+ [view removeFromSuperview];
+ }
[self _commonInit];
}
return self;
}
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [super encodeWithCoder:coder];
+ [coder encodeConditionalObject:_backgroundView forKey:@"backgroundView"];
+ [coder encodeConditionalObject:_highlightView forKey:@"highlightView"];
+ [coder encodeConditionalObject:_contentView forKey:@"contentView"];
+ [coder encodeConditionalObject:_titleCell forKey:@"titleCell"];
+ [coder encodeConditionalObject:_subtitleCell forKey:@"subtitleCell"];
+}
+
- (void)dealloc
{
CFRunLoopTimerInvalidate(_zombieTimer);
@@ -512,8 +541,6 @@
// takes care of the timer as well
[self _cancelDownloads];
[_operationQueue terminate];
- CGLayerRelease(_selectionOverlay);
- _selectionOverlay = NULL;
}
- (BOOL)isFlipped { return YES; }
@@ -520,21 +547,17 @@
#pragma mark API
-- (void)setBackgroundColor:(NSColor *)aColor;
+- (void)setBackgroundColor:(NSColor *)backgroundColor;
{
- if (_backgroundColor != aColor) {
- if ([self window]) {
- if (_backgroundColor == nil)
- [self _unregisterForKeyOrMainStateNotifications];
- else if (aColor == nil)
- [self _registerForKeyOrMainStateNotifications];
- }
- _backgroundColor = [aColor copy];
- [_backgroundView setBackgroundColor:_backgroundColor];
- [self _updateHighlightStyle];
- }
+ [_backgroundView setBackgroundColor:backgroundColor];
+ [_highlightView setHighlightStyleFromBackgroundColor:backgroundColor];
}
+- (NSColor *)backgroundColor;
+{
+ return [_backgroundView backgroundColor];
+}
+
- (void)setTextColor:(NSColor *)aColor;
{
[_titleCell setTextColor:aColor];
@@ -675,9 +698,6 @@
// arrows out of place now, they will be added again when required
when resetting the tracking rects
[self _hideArrows];
- CGLayerRelease(_selectionOverlay);
- _selectionOverlay = NULL;
-
NSPoint scrollPoint = [self scrollPercentage];
// the full view will likely need repainting, this also recalculates
the grid
@@ -1078,7 +1098,7 @@
NSScrollView *scrollView = [self enclosingScrollView];
if ((scrollView && [[notification object] isEqual:[self superview]]) ||
(scrollView == nil && [[notification object] isEqual:self])) {
[self _recalculateGridSize];
- if (scrollView && _backgroundView)
+ if (scrollView)
[_backgroundView setFrame:[scrollView bounds]];
}
}
@@ -1109,10 +1129,9 @@
object:nil];
}
- if (_backgroundView) {
- [_backgroundView removeFromSuperview];
- _backgroundView = nil;
- [self _updateHighlightStyle];
+ if ([_backgroundView superview] != self) {
+ [_backgroundView setFrame:[self bounds]];
+ [self addSubview:_backgroundView positioned:NSWindowBelow
relativeTo:nil];
}
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSViewFrameDidChangeNotification object:nil];
@@ -1132,77 +1151,22 @@
if ([self window] && [[self window] isKeyWindow] == NO)
[self resetCursorRects];
- if (scrollView && floor(NSAppKitVersionNumber) >
NSAppKitVersionNumber10_6) {
- if (_backgroundView == nil) {
- _backgroundView = [[FVBackgroundView alloc]
initWithFrame:[scrollView bounds]];
- [_backgroundView setBackgroundColor:_backgroundColor];
- [scrollView addSubview:_backgroundView
positioned:NSWindowBelow relativeTo:nil];
- [scrollView setDrawsBackground:NO];
- }
- [self _updateHighlightStyle];
+ if (scrollView) {
+ [_backgroundView setFrame:[scrollView bounds]];
+ [scrollView addSubview:_backgroundView positioned:NSWindowBelow
relativeTo:nil];
+ [scrollView setDrawsBackground:NO];
}
}
}
-- (void)_handleKeyOrMainStateNotification:(NSNotification *)note {
- if (_backgroundColor == nil) {
- if (_backgroundView == nil)
- [self setNeedsDisplay:YES];
- else if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10)
- [_backgroundView setNeedsDisplay:YES];
- }
-}
-
-- (void)_registerForKeyOrMainStateNotifications {
- NSWindow *window = [self window];
- if (window) {
- NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- [nc addObserver:self
selector:@selector(_handleKeyOrMainStateNotification:)
name:NSWindowDidBecomeMainNotification object:window];
- [nc addObserver:self
selector:@selector(_handleKeyOrMainStateNotification:)
name:NSWindowDidResignMainNotification object:window];
- [nc addObserver:self
selector:@selector(_handleKeyOrMainStateNotification:)
name:NSWindowDidBecomeKeyNotification object:window];
- [nc addObserver:self
selector:@selector(_handleKeyOrMainStateNotification:)
name:NSWindowDidResignKeyNotification object:window];
- }
-}
-
-- (void)_unregisterForKeyOrMainStateNotifications {
- NSWindow *window = [self window];
- if (window) {
- NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- [nc removeObserver:self name:NSWindowDidBecomeMainNotification
object:window];
- [nc removeObserver:self name:NSWindowDidResignMainNotification
object:window];
- [nc removeObserver:self name:NSWindowDidBecomeKeyNotification
object:window];
- [nc removeObserver:self name:NSWindowDidResignKeyNotification
object:window];
- }
-}
-
- (void)viewWillMoveToWindow:(NSWindow *)newWindow {
NSWindow *window = [self window];
if (newWindow == nil && [[_sliderWindow parentWindow] isEqual:window]) {
[_sliderWindow orderOut:nil];
}
- if (window && _backgroundColor == nil) {
- [self _unregisterForKeyOrMainStateNotifications];
- }
[super viewWillMoveToWindow:newWindow];
}
-- (void)viewDidMoveToWindow {
- // for redrawing background color
- if ([self window] && _backgroundColor == nil) {
- [self _registerForKeyOrMainStateNotifications];
- }
- [super viewDidMoveToWindow];
-}
-
-- (void)viewDidChangeEffectiveAppearance {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
- [super viewDidChangeEffectiveAppearance];
-#pragma clang diagnostic pop
- CGLayerRelease(_selectionOverlay);
- _selectionOverlay = NULL;
-}
-
#pragma mark Layout
- (CGFloat)_columnWidth { return _iconSize.width + _padding.width; }
@@ -1378,9 +1342,6 @@
[self willChangeValueForKey:@"iconScale"];
_iconSize = iconSize;
[self didChangeValueForKey:@"iconScale"];
-
- CGLayerRelease(_selectionOverlay);
- _selectionOverlay = NULL;
}
_padding = padding;
@@ -1424,9 +1385,6 @@
[self willChangeValueForKey:@"iconScale"];
_iconSize = iconSize;
[self didChangeValueForKey:@"iconScale"];
-
- CGLayerRelease(_selectionOverlay);
- _selectionOverlay = NULL;
}
padding = _padding;
@@ -2041,30 +1999,6 @@
[_highlightView setHighlightRects:highlightRects];
}
-- (void)_updateHighlightStyle {
- // for generic colors we want a border so always either the fill or the
stroke contrasts
- FVHighlightStyle highlightStyle = FVHighlightStyleBordered;
-
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9) {
- if (_backgroundColor == nil) {
- // with a sidebar visual effect background we want a selection
visual effect highlight
- if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_15 &&
_backgroundView)
- highlightStyle = FVHighlightStyleTranslucent;
- else
- highlightStyle = FVHighlightStyleUnbordered;
- } else if ([[_backgroundColor colorSpaceName]
isEqualToString:NSNamedColorSpace] && [[_backgroundColor catalogNameComponent]
isEqualToString:@"System"]) {
- // for system background colors we can use a highlight without
border
- // except on 10.5- underPageBackgroundColor is very dark (or light
in dark mode)
- NSString *colorName = [_backgroundColor colorNameComponent];
- if (([colorName hasSuffix:@"BackgroundColor"] || [colorName
hasSuffix:@"RowColor"]) &&
- (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_15 ||
[colorName isEqualToString:@"underPageBackgroundColor"] == NO))
- highlightStyle = FVHighlightStyleUnbordered;
- }
- }
-
- [_highlightView setHighlightStyle:highlightStyle];
-}
-
#pragma mark Cache thread
- (void)_enqueueReleaseOperationForIcons:(NSArray *)icons;
@@ -2647,13 +2581,6 @@
- (void)drawRect:(NSRect)rect;
{
- if (_backgroundView == nil && [[NSGraphicsContext currentContext]
isDrawingToScreen]) {
- // otherwise we see a blocky transition, which fades on the redraw
when scrolling stops
- if (_backgroundColor == nil && [[[self enclosingScrollView]
contentView] copiesOnScroll])
- [[[self enclosingScrollView] contentView] setCopiesOnScroll:NO];
- FVFillBackgroundColorOrGradient(_backgroundColor, rect, [self
visibleRect], [self window]);
- }
-
#if DEBUG_GRID
[[NSColor grayColor] set];
NSRect r = NSInsetRect([self bounds], [self _leftMargin], [self
_topMargin]);
@@ -5045,13 +4972,73 @@
return self;
}
+- (id)initWithCoder:(NSCoder *)coder
+{
+ self = [super initWithCoder:coder];
+ if (self) {
+ _backgroundColor = [coder decodeObjectForKey:@"backgroundColor"];
+ [self _updateVisualEffectViewIfNeeded];
+ }
+ return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [super encodeWithCoder:coder];
+ [coder encodeObject:_backgroundColor forKey:@"backgroundColor"];
+}
+
- (BOOL)isFlipped { return YES; }
- (NSView *)hitTest:(NSPoint)point { return nil; }
-- (void)setBackgroundColor:(NSColor *)backgroundColor
-{
+- (void)_handleKeyOrMainStateNotification:(NSNotification *)note {
+ [self setNeedsDisplay:YES];
+}
+
+- (void)_registerForKeyOrMainStateNotifications {
+ NSWindow *window = [self window];
+ if (window) {
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc addObserver:self
selector:@selector(_handleKeyOrMainStateNotification:)
name:NSWindowDidBecomeMainNotification object:window];
+ [nc addObserver:self
selector:@selector(_handleKeyOrMainStateNotification:)
name:NSWindowDidResignMainNotification object:window];
+ [nc addObserver:self
selector:@selector(_handleKeyOrMainStateNotification:)
name:NSWindowDidBecomeKeyNotification object:window];
+ [nc addObserver:self
selector:@selector(_handleKeyOrMainStateNotification:)
name:NSWindowDidResignKeyNotification object:window];
+ }
+}
+
+- (void)_unregisterForKeyOrMainStateNotifications {
+ NSWindow *window = [self window];
+ if (window) {
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+ [nc removeObserver:self name:NSWindowDidBecomeMainNotification
object:window];
+ [nc removeObserver:self name:NSWindowDidResignMainNotification
object:window];
+ [nc removeObserver:self name:NSWindowDidBecomeKeyNotification
object:window];
+ [nc removeObserver:self name:NSWindowDidResignKeyNotification
object:window];
+ }
+}
+
+- (void)viewWillMoveToWindow:(NSWindow *)newWindow {
+ if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10 && [self
window] && _backgroundColor == nil)
+ [self _unregisterForKeyOrMainStateNotifications];
+ [super viewWillMoveToWindow:newWindow];
+}
+
+- (void)viewDidMoveToWindow {
+ if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10 && [self
window] && _backgroundColor == nil)
+ [self _registerForKeyOrMainStateNotifications];
+ [super viewDidMoveToWindow];
+}
+
+- (void)setBackgroundColor:(NSColor *)backgroundColor {
if (backgroundColor != _backgroundColor) {
+ if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10 && [self
window]) {
+ if (_backgroundColor == nil)
+ [self _unregisterForKeyOrMainStateNotifications];
+ else if (backgroundColor == nil)
+ [self _registerForKeyOrMainStateNotifications];
+ }
+
_backgroundColor = backgroundColor;
[self _updateVisualEffectViewIfNeeded];
@@ -5061,24 +5048,10 @@
- (void)drawRect:(NSRect)rect
{
- if ([[self subviews] count] == 0)
- FVFillBackgroundColorOrGradient(_backgroundColor, rect, [self bounds],
[self window]);
-}
-
-@end
-
-static void FVFillBackgroundColorOrGradient(NSColor *backgroundColor, NSRect
rect, NSRect bounds, NSWindow *window) {
- // any solid color background should override the gradient code
- if (backgroundColor) {
- [backgroundColor setFill];
- NSRectFillUsingOperation(rect, NSCompositingOperationSourceOver);
+ if ([[self subviews] count]) {
}
- else if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9) {
- if ([window isKeyWindow] || [window isMainWindow]) {
- [[NSColor colorWithCalibratedWhite:218.0 / 255.0 alpha:1.0]
setFill];
- } else {
- [[NSColor colorWithCalibratedWhite:226.0 / 255.0 alpha:1.0]
setFill];
- }
+ else if (_backgroundColor) {
+ [_backgroundColor setFill];
NSRectFillUsingOperation(rect, NSCompositingOperationSourceOver);
}
else {
@@ -5091,6 +5064,7 @@
color anyway.
*/
FVAPIAssert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6,
@"gradient background is only available on 10.7 and later");
+ FVAPIAssert(floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10,
@"gradient background should not be drawn on 10.10 and later");
// should be RGBA space, since we're drawing to the screen
CGColorSpaceRef cspace =
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
@@ -5098,7 +5072,7 @@
CGGradientRef gradient;
// color values from DigitalColor Meter on 10.7, using Generic RGB
space
- if ([window isKeyWindow] || [window isMainWindow]) {
+ if ([[self window] isKeyWindow] || [[self window] isMainWindow]) {
// ordered as lower/upper
const CGFloat components[8] = { 198.0 / 255.0, 207.0 / 255.0,
216.0 / 255.0, 1.0, 227.0 / 255.0, 232.0 / 255.0, 238.0 / 255.0, 1.0 };
gradient = CGGradientCreateWithColorComponents(cspace, components,
locations, 2);
@@ -5114,7 +5088,7 @@
// only draw the dirty part, but we need to use the full visible
bounds as the gradient extent
CGContextSaveGState(ctxt);
CGContextClipToRect(ctxt, NSRectToCGRect(rect));
- CGContextDrawLinearGradient(ctxt, gradient, CGPointMake(0,
NSMaxY(bounds)), CGPointMake(0, NSMinY(bounds)), 0);
+ CGContextDrawLinearGradient(ctxt, gradient, CGPointMake(0,
NSMaxY([self bounds])), CGPointMake(0, NSMinY([self bounds])), 0);
CGContextRestoreGState(ctxt);
CGGradientRelease(gradient);
@@ -5122,6 +5096,8 @@
}
}
+@end
+
#pragma mark -
@implementation FVHighlightView
@@ -5129,19 +5105,6 @@
@synthesize highlightRects=_highlightRects;
@synthesize highlightStyle=_highlightStyle;
-- (BOOL)isFlipped { return YES; }
-
-- (NSView *)hitTest:(NSPoint)point { return nil; }
-
-- (void)viewDidChangeEffectiveAppearance {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
- [super viewDidChangeEffectiveAppearance];
-#pragma clang diagnostic pop
- CGLayerRelease(_layer);
- _layer = NULL;
-}
-
- (void)_updateMaskImage {
if ([[self subviews] count]) {
NSImage *image = nil;
@@ -5163,6 +5126,35 @@
}
}
+- (id)initWithCoder:(NSCoder *)coder
+{
+ self = [super initWithCoder:coder];
+ if (self) {
+ _highlightStyle = [coder decodeIntegerForKey:@"highlightStyle"];
+ [self _updateMaskImage];
+ }
+ return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [super encodeWithCoder:coder];
+ [coder encodeInteger:_highlightStyle forKey:@"highlightStyle"];
+}
+
+- (BOOL)isFlipped { return YES; }
+
+- (NSView *)hitTest:(NSPoint)point { return nil; }
+
+- (void)viewDidChangeEffectiveAppearance {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ [super viewDidChangeEffectiveAppearance];
+#pragma clang diagnostic pop
+ CGLayerRelease(_layer);
+ _layer = NULL;
+}
+
- (void)setHighlightRects:(NSArray *)array
{
if (array != _highlightRects) {
@@ -5196,8 +5188,33 @@
}
}
-- (void)_drawHighlightInRect:(NSRect)aRect
inContext:(CGContextRef)drawingContext;
+- (void)setHighlightStyleFromBackgroundColor:(NSColor *)color
{
+ // for generic colors we want a border so always either the fill or the
stroke contrasts
+ FVHighlightStyle highlightStyle = FVHighlightStyleBordered;
+
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9) {
+ if (color == nil) {
+ // with a sidebar visual effect background we want a selection
visual effect highlight
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_15)
+ highlightStyle = FVHighlightStyleTranslucent;
+ else
+ highlightStyle = FVHighlightStyleUnbordered;
+ } else if ([[color colorSpaceName] isEqualToString:NSNamedColorSpace]
&& [[color catalogNameComponent] isEqualToString:@"System"]) {
+ // for system background colors we can use a highlight without
border
+ // except on 10.5- underPageBackgroundColor is very dark (or light
in dark mode)
+ NSString *colorName = [color colorNameComponent];
+ if (([colorName hasSuffix:@"BackgroundColor"] || [colorName
hasSuffix:@"RowColor"]) &&
+ (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_15 ||
[colorName isEqualToString:@"underPageBackgroundColor"] == NO))
+ highlightStyle = FVHighlightStyleUnbordered;
+ }
+ }
+
+ [self setHighlightStyle:highlightStyle];
+}
+
+- (void)_drawHighlightInRect:(NSRect)aRect
inContext:(CGContextRef)drawingContext
+{
if (NULL == _layer) {
_layer = CGLayerCreateWithContext(drawingContext,
CGSizeMake(NSWidth(aRect), NSHeight(aRect)), NULL);
@@ -5295,6 +5312,24 @@
return self;
}
+- (id)initWithCoder:(NSCoder *)coder
+{
+ self = [super initWithCoder:coder];
+ if (self) {
+ _delegate = [coder decodeObjectForKey:@"delegate"];
+ for (NSView *view in [[self subviews] copy]) {
+ [view removeFromSuperview];
+ }
+ }
+ return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder
+{
+ [super encodeWithCoder:coder];
+ [coder encodeConditionalObject:_delegate forKey:@"delegate"];
+}
+
- (BOOL)isFlipped { return YES; }
- (NSView *)hitTest:(NSPoint)point { return nil; }
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit