Revision: 29170
http://sourceforge.net/p/bibdesk/svn/29170
Author: hofman
Date: 2025-04-22 15:49:17 +0000 (Tue, 22 Apr 2025)
Log Message:
-----------
Use visual effect view for selection highllight on 11.0+ when using sidebar
visual effect view as background
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-22
14:48:50 UTC (rev 29169)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h 2025-04-22
15:49:17 UTC (rev 29170)
@@ -223,6 +223,7 @@
NSUInteger _lastClickedIndex;
NSView *_contentView;
NSView *_rubberBandView;
+ NSView *_highlightView;
FVDropHighlightView *_dropHighlightView;
struct __fvFlags {
unsigned int displayMode:2;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2025-04-22
14:48:50 UTC (rev 29169)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2025-04-22
15:49:17 UTC (rev 29170)
@@ -268,6 +268,8 @@
- (void)handlePreviewerWillClose:(NSNotification *)aNote;
- (void)_registerForKeyOrMainStateNotifications;
- (void)_unregisterForKeyOrMainStateNotifications;
+- (void)_addHighlightView;
+- (void)_updateHighlightViewMask;
@end
@@ -520,6 +522,14 @@
_fvFlags.unborderedHighlight =
_allowsUnborderedHighlight(_backgroundColor);
CGLayerRelease(_selectionOverlay);
_selectionOverlay = NULL;
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_15) {
+ if (_backgroundColor == nil && _backgroundView) {
+ [self _addHighlightView];
+ } else if (_highlightView) {
+ [_highlightView removeFromSuperview];
+ _highlightView = nil;
+ }
+ }
}
}
}
@@ -840,7 +850,10 @@
if (indexSet != _selectionIndexes) {
_selectionIndexes = [[NSIndexSet alloc] initWithIndexSet:indexSet];
- [self setNeedsDisplay:YES];
+ if (_highlightView)
+ [self _updateHighlightViewMask];
+ else
+ [self setNeedsDisplay:YES];
NSAccessibilityPostNotification(NSAccessibilityUnignoredAncestor(self),
NSAccessibilityFocusedUIElementChangedNotification);
@@ -1101,6 +1114,10 @@
if (_backgroundView) {
[_backgroundView removeFromSuperview];
_backgroundView = nil;
+ if (_highlightView) {
+ [_highlightView removeFromSuperview];
+ _highlightView = nil;
+ }
}
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSViewFrameDidChangeNotification object:nil];
@@ -1126,6 +1143,14 @@
[_backgroundView setBackgroundColor:_backgroundColor];
[scrollView addSubview:_backgroundView
positioned:NSWindowBelow relativeTo:nil];
[scrollView setDrawsBackground:NO];
+ if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_15)
{
+ if (_backgroundColor == nil) {
+ [self _addHighlightView];
+ } else if (_highlightView) {
+ [_highlightView removeFromSuperview];
+ _highlightView = nil;
+ }
+ }
}
}
}
@@ -1467,8 +1492,11 @@
[super setFrame:frame];
}
}
- }
-}
+
+ [self _updateHighlightViewMask];
+ }
+
+}
- (NSUInteger)_indexForGridRow:(NSUInteger)rowIndex
column:(NSUInteger)colIndex;
{
@@ -2006,6 +2034,42 @@
}
}
+#pragma mark Highlight view layout
+
+- (void)_updateHighlightViewMask {
+ if (_highlightView) {
+ NSImage *image = nil;
+ NSRect bounds = [self bounds];
+ if (NSIsEmptyRect(bounds) == NO) {
+ image = [[NSImage alloc] initWithSize:bounds.size];
+ if ([_selectionIndexes count]) {
+ [image lockFocusFlipped:YES];
+ [[NSColor blackColor] setFill];
+ [_selectionIndexes enumerateIndexesUsingBlock:^(NSUInteger i,
BOOL *stop){
+ NSRect highlightRect = [self _rectOfIconAtIndex:i];
+ if (NSIsEmptyRect(highlightRect) == NO) {
+ highlightRect = NSInsetRect(highlightRect,
HIGHLIGHT_INSET, HIGHLIGHT_INSET);
+ [[NSBezierPath bezierPathWithRoundedRect:highlightRect
xRadius:6.0 yRadius:6.0] fill];
+ }
+ }];
+ [image unlockFocus];
+ }
+ [image setTemplate:YES];
+ }
+ [_highlightView setValue:image forKey:@"maskImage"];
+ }
+}
+
+- (void)_addHighlightView {
+ if (_highlightView == nil) {
+ _highlightView = [[NSClassFromString(@"NSVisualEffectView") alloc]
initWithFrame:[self bounds]];
+ [_highlightView setValue:[NSNumber numberWithInteger:4]
forKey:@"material"];
+ [_highlightView setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
+ [self _updateHighlightViewMask];
+ [self addSubview:_highlightView positioned:NSWindowBelow
relativeTo:nil];
+ }
+}
+
#pragma mark Cache thread
- (void)_enqueueReleaseOperationForIcons:(NSArray *)icons;
@@ -2641,7 +2705,7 @@
FVFillBackgroundColorOrGradient(_backgroundColor, rect, [self
visibleRect], [self window]);
}
- if ([_selectionIndexes count] > 0) {
+ if ([_selectionIndexes count] > 0 && _highlightView == nil) {
CGContextRef context = [[NSGraphicsContext currentContext]
graphicsPort];
CGContextSaveGState(context);
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