Revision: 12865
http://sourceforge.net/p/skim-app/code/12865
Author: hofman
Date: 2022-04-27 21:38:17 +0000 (Wed, 27 Apr 2022)
Log Message:
-----------
Add filters to reflectionview in some cases
Modified Paths:
--------------
trunk/SKFindController.m
trunk/SKLeftSideViewController.m
trunk/SKReflectionView.h
trunk/SKReflectionView.m
trunk/SKRightSideViewController.m
trunk/SKSideViewController.h
trunk/SKSideViewController.m
trunk/SKTopBarView.h
trunk/SKTopBarView.m
Modified: trunk/SKFindController.m
===================================================================
--- trunk/SKFindController.m 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKFindController.m 2022-04-27 21:38:17 UTC (rev 12865)
@@ -157,7 +157,7 @@
[messageField setHidden:YES];
if (visible == NO)
- [(SKTopBarView *)[self view] reflectView:nil animate:NO];
+ [(SKTopBarView *)[self view] reflectView:nil animate:NO
wantsFilters:YES];
if (animate) {
animating = YES;
@@ -172,7 +172,7 @@
}
NSWindow *window = [[self view] window];
if (visible) {
- [(SKTopBarView *)findBar reflectView:view animate:NO];
+ [(SKTopBarView *)findBar reflectView:view animate:NO
wantsFilters:YES];
} else {
[findBar removeFromSuperview];
[NSLayoutConstraint activateConstraints:constraints];
@@ -182,7 +182,7 @@
}];
} else {
if (visible) {
- [(SKTopBarView *)findBar reflectView:view animate:NO];
+ [(SKTopBarView *)findBar reflectView:view animate:NO
wantsFilters:YES];
} else {
[findBar removeFromSuperview];
[NSLayoutConstraint activateConstraints:constraints];
@@ -195,7 +195,7 @@
- (void)setDelegate:(id <SKFindControllerDelegate>)newDelegate {
if (delegate && newDelegate == nil) {
[ownerController setContent:nil];
- [(SKTopBarView *)[self view] reflectView:nil animate:NO];
+ [(SKTopBarView *)[self view] reflectView:nil animate:NO
wantsFilters:YES];
}
delegate = newDelegate;
}
Modified: trunk/SKLeftSideViewController.m
===================================================================
--- trunk/SKLeftSideViewController.m 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKLeftSideViewController.m 2022-04-27 21:38:17 UTC (rev 12865)
@@ -173,6 +173,10 @@
return [findTableView isDescendantOf:aView] || [groupedFindTableView
isDescendantOf:aView];
}
+- (BOOL)wantsFiltersForView:(NSView *)aView {
+ return [thumbnailTableView isDescendantOf:aView];
+}
+
- (void)applySearchTableHeader:(NSString *)message {
[[[findTableView tableColumnWithIdentifier:RESULTS_COLUMNID] headerCell]
setStringValue:message];
[[findTableView headerView] setNeedsDisplay:YES];
Modified: trunk/SKReflectionView.h
===================================================================
--- trunk/SKReflectionView.h 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKReflectionView.h 2022-04-27 21:38:17 UTC (rev 12865)
@@ -41,9 +41,11 @@
@interface SKReflectionView : NSView {
NSScrollView *reflectedScrollView;
+ BOOL wantsFilters;
}
@property (nonatomic, retain) NSScrollView *reflectedScrollView;
+@property (nonatomic) BOOL wantsFilters;
@end
Modified: trunk/SKReflectionView.m
===================================================================
--- trunk/SKReflectionView.m 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKReflectionView.m 2022-04-27 21:38:17 UTC (rev 12865)
@@ -38,18 +38,55 @@
#import "SKReflectionView.h"
#import "NSView_SKExtensions.h"
+#import "NSGraphics_SKExtensions.h"
+#import "NSUserDefaultsController_SKExtensions.h"
+#import "SKStringConstants.h"
+static char SKReflectionViewDefaultsObservationContext;
@implementation SKReflectionView
-@synthesize reflectedScrollView;
+@synthesize reflectedScrollView,wantsFilters;
- (void)dealloc {
+ if (wantsFilters) {
+ @try { [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKeys:[NSArray
arrayWithObjects:SKInvertColorsInDarkModeKey, SKSepiaToneKey, nil]
context:&SKReflectionViewDefaultsObservationContext]; }
+ @catch (id e) {}
+ }
[[NSNotificationCenter defaultCenter] removeObserver:self];
SKDESTROY(reflectedScrollView);
[super dealloc];
}
+- (void)setWantsFilters:(BOOL)flag {
+ if (flag != wantsFilters) {
+ wantsFilters = flag;
+ if (wantsFilters) {
+ [self setContentFilters:SKColorEffectFilters()];
+ [[NSUserDefaultsController sharedUserDefaultsController]
addObserver:self forKeys:[NSArray arrayWithObjects:SKInvertColorsInDarkModeKey,
SKSepiaToneKey, nil] context:&SKReflectionViewDefaultsObservationContext];
+ } else {
+ [self setContentFilters:[NSArray array]];
+ [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKeys:[NSArray
arrayWithObjects:SKInvertColorsInDarkModeKey, SKSepiaToneKey, nil]
context:&SKReflectionViewDefaultsObservationContext];
+ }
+ }
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context {
+ if (context == &SKReflectionViewDefaultsObservationContext)
+ [self setContentFilters:SKColorEffectFilters()];
+ else
+ [super observeValueForKeyPath:keyPath ofObject:object change:change
context:context];
+}
+
+- (void)viewDidChangeEffectiveAppearance {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ [super viewDidChangeEffectiveAppearance];
+#pragma clang diagnostic pop
+ if (wantsFilters)
+ [self setContentFilters:SKColorEffectFilters()];
+}
+
- (void)drawRect:(NSRect)dirtyRect {
if ([reflectedScrollView window] == nil || [reflectedScrollView window] !=
[self window])
return;
Modified: trunk/SKRightSideViewController.m
===================================================================
--- trunk/SKRightSideViewController.m 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKRightSideViewController.m 2022-04-27 21:38:17 UTC (rev 12865)
@@ -133,4 +133,8 @@
[super setMainController:newMainController];
}
+- (BOOL)wantsFiltersForView:(NSView *)aView {
+ return [noteOutlineView isDescendantOf:aView];
+}
+
@end
Modified: trunk/SKSideViewController.h
===================================================================
--- trunk/SKSideViewController.h 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKSideViewController.h 2022-04-27 21:38:17 UTC (rev 12865)
@@ -57,6 +57,7 @@
@property (nonatomic, retain) IBOutlet NSView *currentView;
- (BOOL)requiresAlternateButtonForView:(NSView *)aView;
+- (BOOL)wantsFiltersForView:(NSView *)aView;
- (void)replaceSideView:(NSView *)newView animate:(BOOL)animate;
Modified: trunk/SKSideViewController.m
===================================================================
--- trunk/SKSideViewController.m 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKSideViewController.m 2022-04-27 21:38:17 UTC (rev 12865)
@@ -68,7 +68,7 @@
- (void)setMainController:(SKMainWindowController *)newMainController {
if (mainController && newMainController == nil) {
- [[self topBar] reflectView:nil animate:NO];
+ [[self topBar] reflectView:nil animate:NO wantsFilters:NO];
}
mainController = newMainController;
}
@@ -79,6 +79,10 @@
return NO;
}
+- (BOOL)wantsFiltersForView:(NSView *)aView {
+ return NO;
+}
+
- (void)replaceSideView:(NSView *)newView animate:(BOOL)animate {
if ([newView superview] != nil)
return;
@@ -92,6 +96,7 @@
BOOL wasAlternate = [self requiresAlternateButtonForView:oldView];
BOOL isAlternate = [self requiresAlternateButtonForView:newView];
+ BOOL wantsFilters = [self wantsFiltersForView:newView];
BOOL changeButton = wasAlternate != isAlternate;
NSSegmentedControl *oldButton = wasAlternate ? alternateButton : button;
NSSegmentedControl *newButton = isAlternate ? alternateButton : button;
@@ -124,7 +129,7 @@
}
[[firstResponder window] makeFirstResponder:firstResponder];
[[contentView window] recalculateKeyViewLoop];
- [[self topBar] reflectView:newView animate:NO];
+ [[self topBar] reflectView:newView animate:NO
wantsFilters:wantsFilters];
} else {
isAnimating = YES;
@@ -152,7 +157,7 @@
[context setDuration:DURATION];
[[contentView animator] replaceSubview:oldView with:newView];
[NSLayoutConstraint activateConstraints:constraints];
- [[self topBar] reflectView:newView animate:YES];
+ [[self topBar] reflectView:newView animate:YES
wantsFilters:wantsFilters];
if (changeButton) {
[[newButton animator] setHidden:NO];
[[oldButton animator] setHidden:YES];
Modified: trunk/SKTopBarView.h
===================================================================
--- trunk/SKTopBarView.h 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKTopBarView.h 2022-04-27 21:38:17 UTC (rev 12865)
@@ -38,9 +38,12 @@
#import <Cocoa/Cocoa.h>
+@class SKReflectionView;
+
@interface SKTopBarView : NSView {
NSView *contentView;
- NSView *backgroundView;
+ NSVisualEffectView *backgroundView;
+ SKReflectionView *reflectionView;
NSArray *backgroundColors;
NSArray *alternateBackgroundColors;
NSColor *separatorColor;
@@ -57,6 +60,6 @@
@property (nonatomic) NSRectEdge overflowEdge;
@property (nonatomic) BOOL hasSeparator, drawsBackground;
-- (void)reflectView:(NSView *)view animate:(BOOL)animate;
+- (void)reflectView:(NSView *)view animate:(BOOL)animate
wantsFilters:(BOOL)wantsFilters;
@end
Modified: trunk/SKTopBarView.m
===================================================================
--- trunk/SKTopBarView.m 2022-04-25 08:57:22 UTC (rev 12864)
+++ trunk/SKTopBarView.m 2022-04-27 21:38:17 UTC (rev 12865)
@@ -65,20 +65,12 @@
#pragma clang diagnostic ignored "-Wpartial-availability"
separatorColor = [[NSColor separatorColor] retain];
#pragma clang diagnostic pop
- NSVisualEffectView *view = [[NSVisualEffectView alloc] init];
+ backgroundView = [[NSVisualEffectView alloc] initWithFrame:[self
contentRect]];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
- [view setMaterial:RUNNING_AFTER(10_15) ?
NSVisualEffectMaterialTitlebar : NSVisualEffectMaterialHeaderView];
+ [backgroundView setMaterial:RUNNING_AFTER(10_15) ?
NSVisualEffectMaterialTitlebar : NSVisualEffectMaterialHeaderView];
#pragma clang diagnostic pop
- [view setBlendingMode:NSVisualEffectBlendingModeWithinWindow];
- if ([[NSUserDefaults standardUserDefaults]
boolForKey:SKDisableSearchBarBlurringKey]) {
- backgroundView = [view retain];
- } else {
- backgroundView = [[SKReflectionView alloc] init];
- [view setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
- [backgroundView addSubview:view];
- }
- [backgroundView setFrame:[self contentRect]];
+ [backgroundView
setBlendingMode:NSVisualEffectBlendingModeWithinWindow];
[super addSubview:backgroundView];
} else {
static CGFloat defaultGrays[5] = {0.85, 0.9, 0.9, 0.95, 0.8};
@@ -100,6 +92,7 @@
// this decodes only the reference, the actual view should
already be decoded as a subview
contentView = [[decoder decodeObjectForKey:@"contentView"] retain];
backgroundView = [[decoder decodeObjectForKey:@"backgroundView"]
retain];
+ reflectionView = [[decoder decodeObjectForKey:@"reflectionView"]
retain];
backgroundColors = [[decoder decodeObjectForKey:@"backgroundColors"]
retain];
alternateBackgroundColors = [[decoder
decodeObjectForKey:@"alternateBackgroundColors"] retain];
separatorColor = [[decoder decodeObjectForKey:@"separatorColor"]
retain];
@@ -116,6 +109,7 @@
// this encodes only a reference, the actual contentView should already be
encoded because it's a subview
[coder encodeConditionalObject:contentView forKey:@"contentView"];
[coder encodeConditionalObject:backgroundView forKey:@"backgroundView"];
+ [coder encodeConditionalObject:reflectionView forKey:@"reflectionView"];
[coder encodeObject:backgroundColors forKey:@"backgroundColors"];
[coder encodeObject:alternateBackgroundColors
forKey:@"alternateBackgroundColors"];
[coder encodeInteger:overflowEdge forKey:@"overflowEdge"];
@@ -127,6 +121,7 @@
[[NSNotificationCenter defaultCenter] removeObserver:self];
SKDESTROY(contentView);
SKDESTROY(backgroundView);
+ SKDESTROY(reflectionView);
SKDESTROY(backgroundColors);
SKDESTROY(alternateBackgroundColors);
SKDESTROY(separatorColor);
@@ -135,6 +130,7 @@
- (void)resizeSubviewsWithOldSize:(NSSize)size {
[backgroundView setFrame:[self contentRect]];
+ [reflectionView setFrame:[self contentRect]];
[contentView setFrame:[self contentRect]];
}
@@ -230,6 +226,7 @@
if (flag != hasSeparator) {
hasSeparator = flag;
[backgroundView setFrame:[self contentRect]];
+ [reflectionView setFrame:[self contentRect]];
[contentView setFrame:[self contentRect]];
[self setNeedsDisplay:YES];
}
@@ -245,6 +242,7 @@
}
drawsBackground = flag;
[backgroundView setHidden:drawsBackground == NO];
+ [reflectionView setHidden:drawsBackground == NO];
[self setNeedsDisplay:YES];
}
}
@@ -269,22 +267,39 @@
return rect;
}
-- (void)reflectView:(NSView *)view animate:(BOOL)animate {
- if ([backgroundView respondsToSelector:@selector(setReflectedScrollView:)]
== NO)
+- (void)reflectView:(NSView *)view animate:(BOOL)animate
wantsFilters:(BOOL)wantsFilters {
+ if (RUNNING_BEFORE(10_14) || [[NSUserDefaults standardUserDefaults]
boolForKey:SKDisableSearchBarBlurringKey])
return;
NSScrollView *scrollView = [view descendantOfClass:[NSScrollView class]];
- if (scrollView == [(SKReflectionView *)backgroundView reflectedScrollView])
+ if (scrollView == [reflectionView reflectedScrollView]) {
+ [reflectionView setWantsFilters:wantsFilters];
return;
+ }
if (animate == NO || [self drawsBackground] == NO) {
- [(SKReflectionView *)backgroundView setReflectedScrollView:scrollView];
+ if (reflectionView == nil) {
+ reflectionView = [[SKReflectionView alloc] initWithFrame:[self
contentRect]];
+ [reflectionView setHidden:drawsBackground == NO];
+ [reflectionView setReflectedScrollView:scrollView];
+ wantsSubviews = YES;
+ [super addSubview:reflectionView positioned:NSWindowBelow
relativeTo:nil];
+ wantsSubviews = NO;
+ } else {
+ [reflectionView setReflectedScrollView:scrollView];
+ }
+ [reflectionView setWantsFilters:wantsFilters];
} else {
- SKReflectionView *bgView = [NSKeyedUnarchiver
unarchiveObjectWithData:[NSKeyedArchiver
archivedDataWithRootObject:backgroundView]];
- [bgView setReflectedScrollView:scrollView];
+ SKReflectionView *newView = [[SKReflectionView alloc]
initWithFrame:[self contentRect]];
+ [newView setHidden:drawsBackground == NO];
+ [newView setReflectedScrollView:scrollView];
+ [newView setWantsFilters:wantsFilters];
wantsSubviews = YES;
- [[self animator] replaceSubview:backgroundView with:bgView];
+ if (reflectionView)
+ [[self animator] replaceSubview:reflectionView with:newView];
+ else
+ [[self animator] addSubview:newView positioned:NSWindowBelow
relativeTo:nil];
wantsSubviews = NO;
- [backgroundView release];
- backgroundView = [bgView retain];
+ [reflectionView release];
+ reflectionView = newView;
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit