hotpocket/services/apple/macOS (App)/WindowContentView.m

43 lines
974 B
Objective-C

//
// WindowContentView.m
// HotPocket (macOS)
//
// Created by Tomek Wójcik on 30/09/2025.
//
#import "WindowContentView.h"
@implementation WindowContentView
-(void)awakeFromNib {
[super awakeFromNib];
self.darkBackgroundColor = [NSColor colorNamed:@"BackgroundColor"];
self.lightBackgroundColor = [NSColor windowBackgroundColor];
}
-(BOOL)isOpaque {
return YES;
}
-(void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
NSAppearance *appearance = self.effectiveAppearance;
NSAppearanceName bestMatch = [appearance bestMatchFromAppearancesWithNames:@[
NSAppearanceNameAqua,
NSAppearanceNameDarkAqua
]];
NSColor *backgroundColor = self.lightBackgroundColor;
if ([bestMatch isEqualToString:NSAppearanceNameDarkAqua] == YES) {
backgroundColor = self.darkBackgroundColor;
}
if (backgroundColor) {
[backgroundColor setFill];
NSRectFill(dirtyRect);
}
}
@end