Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Interfaces/AboutWindow.xib
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<rect key="frame" x="181" y="361" width="389" height="27"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="iTerm2" id="U4n-GV-8aZ">
<font key="font" metaFont="system" size="22"/>
<font key="font" metaFont="systemBold" size="26"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
Expand Down Expand Up @@ -97,7 +97,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="By George Nachman and Contributors" id="XAW-F5-RXa">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
Expand Down
4 changes: 4 additions & 0 deletions sources/iTermAboutWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ - (IBAction)closeCurrentSession:(id)sender {
[self close];
}

- (BOOL)isOpaque {
return NO;
}

- (BOOL)autoHidesHotKeyWindow {
return NO;
}
Expand Down
87 changes: 87 additions & 0 deletions sources/iTermAboutWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@
#import "iTermAboutWindowController.h"

#import "iTerm2SharedARC-Swift.h"
#import "iTermController.h"
#import "iTermLaunchExperienceController.h"
#import "iTermPreferences.h"
#import "NSAppearance+iTerm.h"
#import "NSArray+iTerm.h"
#import "NSMutableAttributedString+iTerm.h"
#import "NSObject+iTerm.h"
#import "NSStringITerm.h"
#import "PreferencePanel.h"
#import "PTYWindow.h"
#import "PseudoTerminal.h"

static NSString *iTermAboutWindowControllerWhatsNewURLString = @"iterm2://whats-new/";

@interface iTermAboutWindowContentView : NSVisualEffectView
- (void)configureForDark:(BOOL)dark;
@end

@interface iTermSponsor: NSObject
Expand Down Expand Up @@ -71,6 +78,7 @@ @implementation iTermAboutWindowContentView {
IBOutlet NSView *_serpApi;

NSArray<iTermSponsor *> *_sponsors;
NSView *_sponsorWrapper;
}

- (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
Expand All @@ -79,10 +87,15 @@ - (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
CGFloat topMargin = oldSize.height - NSMaxY(frame);
frame.origin.y = self.frame.size.height - topMargin - frame.size.height;
_bottomAlignedScrollView.frame = frame;
[self updateSponsorWrapperLayout];
}

- (void)awakeFromNib {
[super awakeFromNib];
self.material = NSVisualEffectMaterialHUDWindow;
self.blendingMode = NSVisualEffectBlendingModeBehindWindow;
self.state = NSVisualEffectStateActive;

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.alignment = NSTextAlignmentCenter;
_sponsorsHeading.selectable = YES;
Expand All @@ -105,6 +118,55 @@ - (void)awakeFromNib {
url:@"https://serpapi.com/?utm_source=iterm"]];
}

- (void)updateSponsorWrapperLayout {
if (!_sponsorWrapper) {
return;
}
CGFloat sponsorLogoMinY = MIN(MIN(_whitebox.frame.origin.y, _codeRabbit.frame.origin.y),
_serpApi.frame.origin.y);
CGFloat headingTop = NSMaxY(_sponsorsHeading.frame);
if (sponsorLogoMinY == 0 || headingTop == 0) {
return;
}
const CGFloat kWrapperInset = 16;
const CGFloat kWrapperGap = 12;
CGFloat wrapperY = sponsorLogoMinY - kWrapperGap;
CGFloat wrapperHeight = (headingTop + kWrapperGap) - wrapperY;
_sponsorWrapper.frame = NSMakeRect(kWrapperInset,
wrapperY,
self.frame.size.width - kWrapperInset * 2,
wrapperHeight);
}

- (void)configureForDark:(BOOL)dark {
_bottomAlignedScrollView.drawsBackground = NO;
_bottomAlignedScrollView.contentView.drawsBackground = NO;
_bottomAlignedScrollView.hasVerticalScroller = YES;
_bottomAlignedScrollView.autohidesScrollers = YES;
_bottomAlignedScrollView.wantsLayer = YES;
_bottomAlignedScrollView.layer.cornerRadius = 10;
_bottomAlignedScrollView.layer.masksToBounds = YES;
_bottomAlignedScrollView.layer.backgroundColor = dark
? [NSColor colorWithWhite:0 alpha:0.18].CGColor
: [NSColor colorWithWhite:1 alpha:0.22].CGColor;

if (!_sponsorWrapper) {
const CGFloat kWrapperInset = 16;
_sponsorWrapper = [[NSView alloc] initWithFrame:NSMakeRect(kWrapperInset, 0,
self.frame.size.width - kWrapperInset * 2,
80)];
_sponsorWrapper.wantsLayer = YES;
_sponsorWrapper.layer.cornerRadius = 8;
_sponsorWrapper.autoresizingMask = NSViewNotSizable;
[self addSubview:_sponsorWrapper positioned:NSWindowBelow relativeTo:nil];
}
_sponsorWrapper.layer.backgroundColor = dark
? [NSColor colorWithWhite:1 alpha:0.07].CGColor
: [NSColor colorWithWhite:0 alpha:0.05].CGColor;

[self updateSponsorWrapperLayout];
}


- (void)mouseEntered:(NSEvent *)theEvent {
[NSCursor.pointingHandCursor set];
Expand Down Expand Up @@ -177,6 +239,12 @@ - (instancetype)init {
// Force IBOutlets to be bound by creating window.
[self window];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(themeDidChange:)
name:kRefreshTerminalNotification
object:nil];
[self applyThemeAppearance];

NSDictionary *versionAttributes = @{ NSForegroundColorAttributeName: [NSColor controlTextColor] };
NSAttributedString *bullet = [[NSAttributedString alloc] initWithString:@" βˆ™ "
attributes:versionAttributes];
Expand Down Expand Up @@ -213,6 +281,25 @@ - (instancetype)init {
return self;
}

- (void)themeDidChange:(NSNotification *)notification {
[self applyThemeAppearance];
}

- (void)applyThemeAppearance {
iTermPreferencesTabStyle preferredStyle = [iTermPreferences intForKey:kPreferenceKeyTabStyle];
BOOL isDark = (preferredStyle == TAB_STYLE_DARK || preferredStyle == TAB_STYLE_DARK_HIGH_CONTRAST);
if (preferredStyle == TAB_STYLE_MINIMAL) {
PseudoTerminal *terminal = [[iTermController sharedInstance] currentTerminal];
NSColor *bgColor = [terminal.ptyWindow it_terminalWindowDecorationBackgroundColor];
isDark = bgColor.perceivedBrightness < 0.5;
}

self.window.backgroundColor = [NSColor clearColor];
self.window.appearance = isDark ? [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark] : nil;

[(iTermAboutWindowContentView *)self.window.contentView configureForDark:isDark];
}

- (NSDictionary *)linkTextViewAttributes {
return @{ NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
NSForegroundColorAttributeName: [NSColor linkColor],
Expand Down
Loading