-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathiTermOpenQuicklyView.m
More file actions
80 lines (69 loc) · 2.49 KB
/
Copy pathiTermOpenQuicklyView.m
File metadata and controls
80 lines (69 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// iTermOpenQuicklyView.m
// iTerm
//
// Created by George Nachman on 7/13/14.
//
//
#import "iTermOpenQuicklyView.h"
#import "NSView+iTerm.h"
#import "NSColor+iTerm.h"
@implementation iTermOpenQuicklyView {
NSView *_backgroundEffectView;
NSView *_glassContentView;
NSView *_container;
}
- (BOOL)isFlipped {
return YES;
}
- (void)awakeFromNib {
// Flip subviews
NSArray *subviews = [self subviews];
CGFloat height = self.bounds.size.height;
for (NSView *view in subviews) {
NSRect frame = view.frame;
frame.origin.y = height - NSMaxY(frame);
view.frame = frame;
}
_container = [[NSView alloc] initWithFrame:self.bounds];
[self insertSubview:_container atIndex:0];
if (@available(macOS 26, *)) {
NSGlassEffectView *glassView = [[NSGlassEffectView alloc] initWithFrame:self.bounds];
_backgroundEffectView = glassView;
glassView.tintColor = [NSColor it_dynamicColorForLightMode:[NSColor colorWithWhite:0.95 alpha:0.55]
darkMode:[NSColor colorWithWhite:0.08 alpha:0.88]];
_glassContentView = [[NSView alloc] initWithFrame:_backgroundEffectView.bounds];
glassView.contentView = _glassContentView;
[_container addSubview:_backgroundEffectView];
} else {
// Fallback for older macOS versions: use NSVisualEffectView
NSVisualEffectView *visual = [[NSVisualEffectView alloc] initWithFrame:self.bounds];
visual.blendingMode = NSVisualEffectBlendingModeBehindWindow;
if (@available(macOS 10.16, *)) {
visual.material = NSVisualEffectMaterialMenu;
} else {
visual.material = NSVisualEffectMaterialSheet;
}
visual.state = NSVisualEffectStateActive;
_backgroundEffectView = visual;
[_container addSubview:_backgroundEffectView];
}
// Even though this is set in IB, we have to set it manually.
self.autoresizesSubviews = NO;
}
- (void)drawRect:(NSRect)dirtyRect {
return;
}
- (void)setFrameSize:(NSSize)newSize {
[super setFrameSize:newSize];
_container.frame = self.bounds;
_backgroundEffectView.frame = _container.bounds;
_glassContentView.frame = _backgroundEffectView.bounds;
}
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize {
[super resizeWithOldSuperviewSize:oldSize];
_container.frame = self.bounds;
_backgroundEffectView.frame = _container.bounds;
_glassContentView.frame = _backgroundEffectView.bounds;
}
@end