Revision: 12900
http://sourceforge.net/p/skim-app/code/12900
Author: hofman
Date: 2022-05-08 16:48:07 +0000 (Sun, 08 May 2022)
Log Message:
-----------
Move content behind title bar and top bars also on 10.13-, draw transparent
white over title bar material tomakeit lighter, and use light material for pdf
control background
Modified Paths:
--------------
trunk/SKFindController.m
trunk/SKMainWindowController.m
trunk/SKMainWindowController_FullScreen.m
trunk/SKSecondaryPDFView.m
trunk/SKSideViewController.m
trunk/SKSnapshotPDFView.m
trunk/SKTopBarView.h
trunk/SKTopBarView.m
Modified: trunk/SKFindController.m
===================================================================
--- trunk/SKFindController.m 2022-05-07 18:06:18 UTC (rev 12899)
+++ trunk/SKFindController.m 2022-05-08 16:48:07 UTC (rev 12900)
@@ -68,8 +68,6 @@
- (void)viewDidLoad {
[super viewDidLoad];
- [(SKTopBarView *)[self view] setHasSeparator:YES];
-
NSMenu *menu = [NSMenu menu];
[menu addItemWithTitle:NSLocalizedString(@"Ignore Case", @"Menu item
title") action:@selector(toggleCaseInsensitiveFind:) target:self];
[[findField cell] setSearchMenuTemplate:menu];
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2022-05-07 18:06:18 UTC (rev 12899)
+++ trunk/SKMainWindowController.m 2022-05-08 16:48:07 UTC (rev 12900)
@@ -249,7 +249,7 @@
searchResults = [[NSMutableArray alloc] init];
searchResultIndex = 0;
memset(&mwcFlags, 0, sizeof(mwcFlags));
- mwcFlags.fullSizeContent = RUNNING_AFTER(10_13);
+ mwcFlags.fullSizeContent = 1;
mwcFlags.caseInsensitiveSearch = [[NSUserDefaults
standardUserDefaults] boolForKey:SKCaseInsensitiveSearchKey];
mwcFlags.wholeWordSearch = [[NSUserDefaults standardUserDefaults]
boolForKey:SKWholeWordSearchKey];
mwcFlags.caseInsensitiveFilter = [[NSUserDefaults
standardUserDefaults] boolForKey:SKCaseInsensitiveFilterKey];
Modified: trunk/SKMainWindowController_FullScreen.m
===================================================================
--- trunk/SKMainWindowController_FullScreen.m 2022-05-07 18:06:18 UTC (rev
12899)
+++ trunk/SKMainWindowController_FullScreen.m 2022-05-08 16:48:07 UTC (rev
12900)
@@ -112,7 +112,6 @@
if (sideWindow == nil)
sideWindow = [[SKSideWindow alloc]
initWithView:leftSideController.view];
- [leftSideController.topBar setHasSeparator:NO];
if (mwcFlags.fullSizeContent) {
[leftSideController.topBar applyPresentationBackground];
[leftSideController setTopInset:0.0];
@@ -132,7 +131,6 @@
if ([[sideWindow firstResponder]
isDescendantOf:leftSideController.view])
[sideWindow makeFirstResponder:nil];
- [leftSideController.topBar setHasSeparator:YES];
if (mwcFlags.fullSizeContent) {
[leftSideController.topBar applyDefaultBackground];
[leftSideController setTopInset:titleBarHeight];
Modified: trunk/SKSecondaryPDFView.m
===================================================================
--- trunk/SKSecondaryPDFView.m 2022-05-07 18:06:18 UTC (rev 12899)
+++ trunk/SKSecondaryPDFView.m 2022-05-08 16:48:07 UTC (rev 12900)
@@ -52,7 +52,6 @@
#import "NSImage_SKExtensions.h"
#import "SKPDFView.h"
#import "SKTopBarView.h"
-#import "NSColor_SKExtensions.h"
@interface SKSecondaryPDFView (SKPrivate)
@@ -266,10 +265,7 @@
if (controlView == nil) {
SKTopBarView *topBar = [[SKTopBarView alloc]
initWithFrame:NSMakeRect(0.0, 0.0, CONTROL_HEIGHT, CONTROL_HEIGHT)];
- if (RUNNING_BEFORE(10_14)) {
- [topBar setBackgroundColors:[NSArray arrayWithObjects:[NSColor
pdfControlBackgroundColor], nil]];
- [topBar setAlternateBackgroundColors:nil];
- }
+ [topBar applyPdfControlBackground];
[toolModeButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[pagePopUpButton setTranslatesAutoresizingMaskIntoConstraints:NO];
Modified: trunk/SKSideViewController.m
===================================================================
--- trunk/SKSideViewController.m 2022-05-07 18:06:18 UTC (rev 12899)
+++ trunk/SKSideViewController.m 2022-05-08 16:48:07 UTC (rev 12900)
@@ -62,12 +62,6 @@
[super dealloc];
}
-- (void)viewDidLoad {
- [super viewDidLoad];
-
- [topBar setHasSeparator:YES];
-}
-
#pragma mark Accessors
- (NSArray *)tableViews { return nil; }
Modified: trunk/SKSnapshotPDFView.m
===================================================================
--- trunk/SKSnapshotPDFView.m 2022-05-07 18:06:18 UTC (rev 12899)
+++ trunk/SKSnapshotPDFView.m 2022-05-08 16:48:07 UTC (rev 12900)
@@ -48,7 +48,6 @@
#import "PDFView_SKExtensions.h"
#import "NSGeometry_SKExtensions.h"
#import "NSMenu_SKExtensions.h"
-#import "NSColor_SKExtensions.h"
#import "SKPDFView.h"
@@ -180,10 +179,7 @@
[scalePopUpButton setRefusesFirstResponder:YES];
SKTopBarView *topBar = [[SKTopBarView alloc]
initWithFrame:NSMakeRect(0.0, 0.0, 0.0, CONTROL_HEIGHT)];
- if (RUNNING_BEFORE(10_14)) {
- [topBar setBackgroundColors:[NSArray arrayWithObjects:[NSColor
pdfControlBackgroundColor], nil]];
- [topBar setAlternateBackgroundColors:nil];
- }
+ [topBar applyPdfControlBackground];
[scalePopUpButton setTranslatesAutoresizingMaskIntoConstraints:NO];
[topBar addSubview:scalePopUpButton];
Modified: trunk/SKTopBarView.h
===================================================================
--- trunk/SKTopBarView.h 2022-05-07 18:06:18 UTC (rev 12899)
+++ trunk/SKTopBarView.h 2022-05-08 16:48:07 UTC (rev 12900)
@@ -38,23 +38,20 @@
#import <Cocoa/Cocoa.h>
+@class SKBackgroundView;
@interface SKTopBarView : NSView {
NSView *contentView;
- NSVisualEffectView *backgroundView;
- NSBox *separatorView;
- NSArray *backgroundColors;
- NSArray *alternateBackgroundColors;
- BOOL hasSeparator;
+ NSVisualEffectView *blurView;
+ SKBackgroundView *backgroundView;
BOOL drawsBackground;
BOOL wantsSubviews;
}
-@property (nonatomic, readonly) NSView *contentView;
-@property (nonatomic, copy) NSArray *backgroundColors,
*alternateBackgroundColors;
-@property (nonatomic) BOOL hasSeparator, drawsBackground;
+@property (nonatomic) BOOL drawsBackground;
- (void)applyDefaultBackground;
- (void)applyPresentationBackground;
+- (void)applyPdfControlBackground;
@end
Modified: trunk/SKTopBarView.m
===================================================================
--- trunk/SKTopBarView.m 2022-05-07 18:06:18 UTC (rev 12899)
+++ trunk/SKTopBarView.m 2022-05-08 16:48:07 UTC (rev 12900)
@@ -45,20 +45,29 @@
#define SEPARATOR_WIDTH 1.0
+@interface SKBackgroundView : NSView {
+ NSColor *backgroundColor;
+ NSColor *separatorColor;
+}
+@property (nonatomic, retain) NSColor *backgroundColor;
+@property (nonatomic, retain) NSColor *separatorColor;
+@end
+
+#pragma mark -
+
@implementation SKTopBarView
-@synthesize contentView, backgroundColors, alternateBackgroundColors,
hasSeparator, drawsBackground;
+@synthesize drawsBackground;
- (id)initWithFrame:(NSRect)frame {
wantsSubviews = YES;
self = [super initWithFrame:frame];
if (self) {
- hasSeparator = NO;
drawsBackground = YES;
- if (RUNNING_AFTER(10_13)) {
- backgroundView = [[NSVisualEffectView alloc] initWithFrame:[self
bounds]];
- [super addSubview:backgroundView];
- }
+ blurView = [[NSVisualEffectView alloc] initWithFrame:[self bounds]];
+ [super addSubview:blurView];
+ backgroundView = [[SKBackgroundView alloc] initWithFrame:[self
bounds]];
+ [super addSubview:backgroundView];
contentView = [[NSView alloc] initWithFrame:[self bounds]];
[super addSubview:contentView];
wantsSubviews = NO;
@@ -67,41 +76,11 @@
return self;
}
-- (id)initWithCoder:(NSCoder *)decoder {
- wantsSubviews = YES;
- self = [super initWithCoder:decoder];
- if (self) {
- // 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];
- separatorView = [[decoder decodeObjectForKey:@"separatorView"] retain];
- backgroundColors = [[decoder decodeObjectForKey:@"backgroundColors"]
retain];
- alternateBackgroundColors = [[decoder
decodeObjectForKey:@"alternateBackgroundColors"] retain];
- hasSeparator = [decoder decodeBoolForKey:@"hasSeparator"];
- drawsBackground = [decoder decodeBoolForKey:@"drawsBackground"];
- wantsSubviews = NO;
- }
- return self;
-}
-
-- (void)encodeWithCoder:(NSCoder *)coder {
- [super encodeWithCoder:coder];
- // 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 encodeObject:backgroundColors forKey:@"backgroundColors"];
- [coder encodeObject:alternateBackgroundColors
forKey:@"alternateBackgroundColors"];
- [coder encodeBool:hasSeparator forKey:@"hasSeparator"];
- [coder encodeBool:drawsBackground forKey:@"drawsBackground"];
-}
-
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
SKDESTROY(contentView);
+ SKDESTROY(blurView);
SKDESTROY(backgroundView);
- SKDESTROY(separatorView);
- SKDESTROY(backgroundColors);
- SKDESTROY(alternateBackgroundColors);
[super dealloc];
}
@@ -108,9 +87,9 @@
- (void)resizeSubviewsWithOldSize:(NSSize)size {
[super resizeSubviewsWithOldSize:size];
NSRect rect = [self bounds];
+ [blurView setFrame:rect];
[backgroundView setFrame:rect];
[contentView setFrame:rect];
- [separatorView setFrame:SKSliceRect(rect, SEPARATOR_WIDTH, NSMinYEdge)];
}
- (void)addSubview:(NSView *)aView {
@@ -135,146 +114,97 @@
}
-- (void)drawRect:(NSRect)aRect {
- if (drawsBackground == NO)
- return;
-
- NSArray *colors = backgroundColors;
- if (alternateBackgroundColors && [[self window] isMainWindow] == NO &&
[[self window] isKeyWindow] == NO)
- colors = alternateBackgroundColors;
-
- if ([colors count] == 0)
- return;
-
- NSRect rect = [self bounds];
- NSRect sepRect = NSZeroRect;
- if (hasSeparator)
- NSDivideRect(rect, &sepRect, &rect, SEPARATOR_WIDTH, NSMinYEdge);
-
- [NSGraphicsContext saveGraphicsState];
-
- if ([colors count] > 1) {
- NSGradient *aGradient = [[NSGradient alloc] initWithColors:colors];
- [aGradient drawInRect:rect angle:90.0];
- [aGradient release];
- } else if ([colors count] == 1) {
- [[colors firstObject] setFill];
- [NSBezierPath fillRect:rect];
- }
-
- if (RUNNING_BEFORE(10_14) && hasSeparator) {
- [[NSColor colorWithGenericGamma22White:0.8 alpha:1.0] setFill];
- [NSBezierPath fillRect:rect];
- }
-
- [NSGraphicsContext restoreGraphicsState];
-}
-
-- (void)handleKeyOrMainStateChangedNotification:(NSNotification *)note {
- [self setNeedsDisplay:YES];
-}
-
-- (void)startObservingWindow:(NSWindow *)window {
- NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- [nc addObserver:self
selector:@selector(handleKeyOrMainStateChangedNotification:)
name:NSWindowDidBecomeMainNotification object:window];
- [nc addObserver:self
selector:@selector(handleKeyOrMainStateChangedNotification:)
name:NSWindowDidResignMainNotification object:window];
- [nc addObserver:self
selector:@selector(handleKeyOrMainStateChangedNotification:)
name:NSWindowDidBecomeKeyNotification object:window];
- [nc addObserver:self
selector:@selector(handleKeyOrMainStateChangedNotification:)
name:NSWindowDidResignKeyNotification object:window];
-}
-
-- (void)stopObservingWindow:(NSWindow *)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 (alternateBackgroundColors) {
- NSWindow *oldWindow = [self window];
- if (oldWindow)
- [self stopObservingWindow:oldWindow];
- if (newWindow)
- [self startObservingWindow:newWindow];
- }
- [super viewWillMoveToWindow:newWindow];
-}
-
-- (void)setHasSeparator:(BOOL)flag {
- if (flag != hasSeparator) {
- hasSeparator = flag;
- if (RUNNING_AFTER(10_13)) {
- if (separatorView == nil && hasSeparator) {
- separatorView = [[NSBox alloc] initWithFrame:SKSliceRect([self
bounds], SEPARATOR_WIDTH, NSMinYEdge)];
- [separatorView setBoxType:NSBoxCustom];
- [separatorView setBorderType:NSNoBorder];
- [separatorView setTitlePosition:NSNoTitle];
- [separatorView setBorderWidth:0.0];
- [separatorView setContentViewMargins:NSZeroSize];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpartial-availability"
- [separatorView setFillColor:[NSColor separatorColor]];
-#pragma clang diagnostic pop
- wantsSubviews = YES;
- [super addSubview:separatorView positioned:NSWindowBelow
relativeTo:contentView];
- wantsSubviews = NO;
- }
- [separatorView setHidden:hasSeparator == NO];
- } else {
- [self setNeedsDisplay:YES];
- }
- }
-}
-
- (void)setDrawsBackground:(BOOL)flag {
if (drawsBackground != flag) {
drawsBackground = flag;
+ [blurView setHidden:drawsBackground == NO];
[backgroundView setHidden:drawsBackground == NO];
- [separatorView setHidden:drawsBackground == NO];
- if (RUNNING_BEFORE(10_14))
- [self setNeedsDisplay:YES];
}
}
-- (void)setAlternateBackgroundColors:(NSArray *)colors {
- if (colors != alternateBackgroundColors) {
- if ([self window]) {
- if (alternateBackgroundColors && colors == nil)
- [self stopObservingWindow:[self window]];
- else if (alternateBackgroundColors == nil && colors)
- [self startObservingWindow:[self window]];
- }
- [alternateBackgroundColors release];
- alternateBackgroundColors = [colors copy];
+- (void)applyDefaultBackground {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ [blurView setMaterial:RUNNING_AFTER(10_15) || RUNNING_BEFORE(10_13) ?
NSVisualEffectMaterialTitlebar : NSVisualEffectMaterialHeaderView];
+#pragma clang diagnostic pop
+ [blurView setBlendingMode:NSVisualEffectBlendingModeWithinWindow];
+ if (RUNNING_AFTER(10_13)) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ [backgroundView setSeparatorColor:[NSColor separatorColor]];
+#pragma clang diagnostic pop
+ } else{
+ [backgroundView setBackgroundColor:[NSColor
colorWithGenericGamma22White:1.0 alpha:0.25]];
+ [backgroundView setSeparatorColor:[NSColor
colorWithGenericGamma22White:0.8 alpha:0.35]];
}
+ [backgroundView setNeedsDisplay:YES];
}
-- (void)applyDefaultBackground {
+- (void)applyPresentationBackground {
if (RUNNING_AFTER(10_13)) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
- [backgroundView setMaterial:RUNNING_AFTER(10_15) ?
NSVisualEffectMaterialTitlebar : NSVisualEffectMaterialHeaderView];
+ [blurView setMaterial:NSVisualEffectMaterialSidebar];
#pragma clang diagnostic pop
- [backgroundView
setBlendingMode:NSVisualEffectBlendingModeWithinWindow];
+ [blurView setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
} else {
- static CGFloat defaultGrays[5] = {0.85, 0.9, 0.9, 0.95};
- [self setBackgroundColors:[NSArray arrayWithObjects:[NSColor
colorWithGenericGamma22White:defaultGrays[0] alpha:1.0], [NSColor
colorWithGenericGamma22White:defaultGrays[1] alpha:1.0], nil]];
- [self setAlternateBackgroundColors:[NSArray arrayWithObjects:[NSColor
colorWithGenericGamma22White:defaultGrays[2] alpha:1.0], [NSColor
colorWithGenericGamma22White:defaultGrays[3] alpha:1.0], nil]];
+ [backgroundView setBackgroundColor:[NSColor windowBackgroundColor]];
}
+ [backgroundView setSeparatorColor:nil];
+ [backgroundView setNeedsDisplay:YES];
}
-- (void)applyPresentationBackground {
+- (void)applyPdfControlBackground {
if (RUNNING_AFTER(10_13)) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
- [backgroundView setMaterial:NSVisualEffectMaterialSidebar];
+ [blurView setMaterial:RUNNING_AFTER(10_15) || RUNNING_BEFORE(10_13) ?
NSVisualEffectMaterialTitlebar : NSVisualEffectMaterialHeaderView];
#pragma clang diagnostic pop
- [backgroundView
setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
+ [blurView setBlendingMode:NSVisualEffectBlendingModeWithinWindow];
} else {
- [self setBackgroundColors:[NSArray arrayWithObjects:[NSColor
windowBackgroundColor], nil]];
- [self setAlternateBackgroundColors:nil];
+ [blurView setMaterial:NSVisualEffectMaterialLight];
+ [blurView setBlendingMode:NSVisualEffectBlendingModeWithinWindow];
+ [backgroundView setBackgroundColor:[NSColor
colorWithGenericGamma22White:0.98 alpha:0.5]];
+ [backgroundView setNeedsDisplay:YES];
}
+ [backgroundView setSeparatorColor:nil];
+ [backgroundView setNeedsDisplay:YES];
}
@end
+
+#pragma mark -
+
+@implementation SKBackgroundView
+
+@synthesize backgroundColor, separatorColor;
+
+- (void)dealloc {
+ SKDESTROY(backgroundColor);
+ SKDESTROY(separatorColor);
+ [super dealloc];
+}
+
+- (void)drawRect:(NSRect)aRect {
+ NSRect rect = [self bounds];
+ NSRect sepRect = NSZeroRect;
+ if ([self separatorColor])
+ NSDivideRect(rect, &sepRect, &rect, SEPARATOR_WIDTH, NSMinYEdge);
+
+ [NSGraphicsContext saveGraphicsState];
+
+ if ([self backgroundColor]) {
+ [[self backgroundColor] setFill];
+ [NSBezierPath fillRect:rect];
+ }
+
+ if ([self separatorColor]) {
+ [[self separatorColor] setFill];
+ [NSBezierPath fillRect:sepRect];
+ }
+
+ [NSGraphicsContext restoreGraphicsState];
+}
+
+@end
+
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