mirror of https://github.com/bsnes-emu/bsnes.git
Improved Dark Mode support, improved Hex Fiend's general system-native appearance
This commit is contained in:
parent
4a51f5c956
commit
edf7762408
|
@ -647,7 +647,6 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
|||
{
|
||||
hex_controller = [[HFController alloc] init];
|
||||
[hex_controller setBytesPerColumn:1];
|
||||
[hex_controller setFont:[NSFont userFixedPitchFontOfSize:12]];
|
||||
[hex_controller setEditMode:HFOverwriteMode];
|
||||
|
||||
[hex_controller setByteArray:[[GBMemoryByteArray alloc] initWithDocument:self]];
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="EQe-Ad-L7S">
|
||||
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView ambiguous="YES" editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" id="doS-dM-hnl">
|
||||
<rect key="frame" x="0.0" y="0.0" width="591" height="376"/>
|
||||
|
@ -153,7 +153,7 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="YHx-TM-zIC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="329" height="47"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView ambiguous="YES" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" allowsCharacterPickerTouchBarItem="NO" allowsUndo="YES" allowsNonContiguousLayout="YES" textCompletion="NO" spellingCorrection="YES" id="w0g-eK-jM4">
|
||||
<rect key="frame" x="0.0" y="0.0" width="329" height="47"/>
|
||||
|
@ -187,7 +187,7 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" copiesOnScroll="NO" id="Cs9-3x-ATg">
|
||||
<rect key="frame" x="0.0" y="0.0" width="329" height="328"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView ambiguous="YES" editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" baseWritingDirection="leftToRight" findStyle="bar" allowsNonContiguousLayout="YES" spellingCorrection="YES" id="JgV-7E-iwp">
|
||||
<rect key="frame" x="0.0" y="0.0" width="329" height="328"/>
|
||||
|
@ -339,7 +339,7 @@
|
|||
<font key="font" metaFont="system"/>
|
||||
<tabViewItems>
|
||||
<tabViewItem label="Tileset" identifier="1" id="pXb-od-Wb1">
|
||||
<view key="view" ambiguous="YES" id="lCG-Gt-XMF">
|
||||
<view key="view" id="lCG-Gt-XMF">
|
||||
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
|
@ -505,9 +505,9 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" ambiguous="YES" drawsBackground="NO" id="3VT-AA-xVT">
|
||||
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView appearanceType="vibrantLight" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="18" headerView="of1-KC-dXC" id="TOc-XJ-w9w">
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="18" headerView="of1-KC-dXC" id="TOc-XJ-w9w">
|
||||
<rect key="frame" x="0.0" y="0.0" width="512" height="391"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
|
@ -640,7 +640,7 @@
|
|||
</view>
|
||||
</tabViewItem>
|
||||
<tabViewItem label="Palettes" identifier="" id="vLb-Nh-UYE">
|
||||
<view key="view" id="qIg-ci-WTA">
|
||||
<view key="view" ambiguous="YES" id="qIg-ci-WTA">
|
||||
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
|
@ -649,7 +649,7 @@
|
|||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" ambiguous="YES" id="bP9-su-zQw">
|
||||
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="18" id="gfC-d3-dmq">
|
||||
<rect key="frame" x="0.0" y="0.0" width="512" height="408"/>
|
||||
|
@ -800,7 +800,7 @@
|
|||
<point key="canvasLocation" x="-159" y="356"/>
|
||||
</window>
|
||||
<button verticalHuggingPriority="750" id="RLc-0I-sYZ">
|
||||
<rect key="frame" x="0.5" y="0.0" width="48" height="25"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="48" height="25"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" title="Save" bezelStyle="texturedRounded" alignment="center" controlSize="mini" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="shw-MJ-B3T">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
|
@ -896,7 +896,7 @@
|
|||
</connections>
|
||||
</textField>
|
||||
<button verticalHuggingPriority="750" id="C3V-Ep-bMj">
|
||||
<rect key="frame" x="202.5" y="12" width="82" height="23"/>
|
||||
<rect key="frame" x="203" y="12" width="82" height="23"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="roundTextured" title="Import" bezelStyle="texturedRounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="mMP-KW-YNy">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
|
@ -970,7 +970,7 @@
|
|||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" id="mzf-yu-RID">
|
||||
<rect key="frame" x="1" y="0.0" width="398" height="274"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="none" alternatingRowBackgroundColors="YES" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" headerView="pvX-uJ-qK5" id="tA3-8T-bxb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="398" height="249"/>
|
||||
|
|
|
@ -13,8 +13,14 @@ static inline double scale_channel(uint8_t x)
|
|||
|
||||
- (void)setObjectValue:(id)objectValue
|
||||
{
|
||||
|
||||
_integerValue = [objectValue integerValue];
|
||||
super.objectValue = [NSString stringWithFormat:@"$%04x", (uint16_t)(_integerValue & 0x7FFF)];
|
||||
uint8_t r = _integerValue & 0x1F,
|
||||
g = (_integerValue >> 5) & 0x1F,
|
||||
b = (_integerValue >> 10) & 0x1F;
|
||||
super.objectValue = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"$%04x", (uint16_t)(_integerValue & 0x7FFF)] attributes:@{
|
||||
NSForegroundColorAttributeName: r * 3 + g * 4 + b * 2 > 120? [NSColor blackColor] : [NSColor whiteColor]
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSInteger)integerValue
|
||||
|
|
|
@ -164,6 +164,20 @@
|
|||
return GBGameBoyButtonCount;
|
||||
}
|
||||
|
||||
- (unsigned) usesForKey:(unsigned) key
|
||||
{
|
||||
unsigned ret = 0;
|
||||
for (unsigned player = 4; player--;) {
|
||||
for (unsigned button = player == 0? GBButtonCount:GBGameBoyButtonCount; button--;) {
|
||||
NSNumber *other = [[NSUserDefaults standardUserDefaults] valueForKey:button_to_preference_name(button, player)];
|
||||
if (other && [other unsignedIntValue] == key) {
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
|
||||
{
|
||||
if ([tableColumn.identifier isEqualToString:@"keyName"]) {
|
||||
|
@ -176,6 +190,12 @@
|
|||
|
||||
NSNumber *key = [[NSUserDefaults standardUserDefaults] valueForKey:button_to_preference_name(row, self.playerListButton.selectedTag)];
|
||||
if (key) {
|
||||
if ([self usesForKey:[key unsignedIntValue]] > 1) {
|
||||
return [[NSAttributedString alloc] initWithString:[NSString displayStringForKeyCode: [key unsignedIntegerValue]]
|
||||
attributes:@{NSForegroundColorAttributeName: [NSColor colorWithRed:0.9375 green:0.25 blue:0.25 alpha:1.0],
|
||||
NSFontAttributeName: [NSFont boldSystemFontOfSize:[NSFont systemFontSize]]
|
||||
}];
|
||||
}
|
||||
return [NSString displayStringForKeyCode: [key unsignedIntegerValue]];
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.0 KiB |
|
@ -0,0 +1,42 @@
|
|||
#import <AppKit/AppKit.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
@interface NSImageRep(PrivateAPI)
|
||||
@property(setter=_setAppearanceName:) NSString *_appearanceName;
|
||||
@end
|
||||
|
||||
static NSImage * (*imageNamed)(Class self, SEL _cmd, NSString *name);
|
||||
|
||||
@implementation NSImage(DarkHooks)
|
||||
|
||||
+ (NSImage *)imageNamedWithDark:(NSImageName)name
|
||||
{
|
||||
NSImage *light = imageNamed(self, _cmd, name);
|
||||
if (@available(macOS 10.14, *)) {
|
||||
NSImage *dark = imageNamed(self, _cmd, [name stringByAppendingString:@"~dark"]);
|
||||
if (!dark) {
|
||||
return light;
|
||||
}
|
||||
NSImage *ret = [[NSImage alloc] initWithSize:light.size];
|
||||
for (NSImageRep *rep in light.representations) {
|
||||
[rep _setAppearanceName:NSAppearanceNameAqua];
|
||||
[ret addRepresentation:rep];
|
||||
}
|
||||
for (NSImageRep *rep in dark.representations) {
|
||||
[rep _setAppearanceName:NSAppearanceNameDarkAqua];
|
||||
[ret addRepresentation:rep];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return light;
|
||||
}
|
||||
|
||||
+(void)load
|
||||
{
|
||||
if (@available(macOS 10.14, *)) {
|
||||
imageNamed = (void *)[self methodForSelector:@selector(imageNamed:)];
|
||||
method_setImplementation(class_getClassMethod(self, @selector(imageNamed:)),
|
||||
[self methodForSelector:@selector(imageNamedWithDark:)]);
|
||||
}
|
||||
}
|
||||
@end
|
|
@ -492,7 +492,7 @@
|
|||
<rect key="frame" x="1" y="1" width="238" height="209"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView focusRingType="none" appearanceType="vibrantLight" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" id="UDd-IJ-fxX">
|
||||
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" id="UDd-IJ-fxX">
|
||||
<rect key="frame" x="0.0" y="0.0" width="238" height="209"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
|
@ -507,8 +507,8 @@
|
|||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="mqT-jD-eXS">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
</tableColumn>
|
||||
|
@ -520,8 +520,8 @@
|
|||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" identifier="keyValue" title="Text Cell" id="tn8-0i-1q1">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
</tableColumn>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
|
@ -4,7 +4,7 @@
|
|||
#import <libkern/OSAtomic.h>
|
||||
|
||||
#define HFDEFAULT_FONT (@"Monaco")
|
||||
#define HFDEFAULT_FONTSIZE ((CGFloat)10.)
|
||||
#define HFDEFAULT_FONTSIZE ((CGFloat)11.)
|
||||
|
||||
#define HFZeroRange (HFRange){0, 0}
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ static CGFloat maximumDigitAdvanceForFont(NSFont *font) {
|
|||
interiorShadowEdge = NSMaxXEdge;
|
||||
|
||||
_borderedEdges = (1 << NSMaxXEdge);
|
||||
_borderColor = [[NSColor darkGrayColor] retain];
|
||||
_backgroundColor = [[NSColor colorWithCalibratedWhite:(CGFloat).87 alpha:1] retain];
|
||||
_borderColor = [[NSColor controlShadowColor] retain];
|
||||
_backgroundColor = [[NSColor windowBackgroundColor] retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -82,9 +82,9 @@ static CGFloat maximumDigitAdvanceForFont(NSFont *font) {
|
|||
lineNumberFormat = (HFLineNumberFormat)[coder decodeInt64ForKey:@"HFLineNumberFormat"];
|
||||
|
||||
_borderedEdges = [coder decodeObjectForKey:@"HFBorderedEdges"] ? (NSInteger)[coder decodeInt64ForKey:@"HFBorderedEdges"] : 0;
|
||||
_borderColor = [[coder decodeObjectForKey:@"HFBorderColor"] ?: [NSColor darkGrayColor] retain];
|
||||
_backgroundColor = [[coder decodeObjectForKey:@"HFBackgroundColor"] ?: [NSColor colorWithCalibratedWhite:(CGFloat).87 alpha:1] retain];
|
||||
|
||||
_borderColor = [[NSColor controlShadowColor] retain];
|
||||
_backgroundColor = [[NSColor windowBackgroundColor] retain];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,20 +119,6 @@
|
|||
[super viewWillMoveToWindow:newWindow];
|
||||
}
|
||||
|
||||
- (void)drawGradientWithClip:(NSRect)clip {
|
||||
[_representer.backgroundColor set];
|
||||
NSRectFill(clip);
|
||||
|
||||
NSInteger shadowEdge = _representer.interiorShadowEdge;
|
||||
|
||||
if (shadowEdge >= 0) {
|
||||
const CGFloat shadowWidth = 6;
|
||||
NSWindow *window = self.window;
|
||||
BOOL drawActive = (window == nil || [window isKeyWindow] || [window isMainWindow]);
|
||||
HFDrawShadow([[NSGraphicsContext currentContext] graphicsPort], self.bounds, shadowWidth, shadowEdge, drawActive, clip);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)drawDividerWithClip:(NSRect)clipRect {
|
||||
USE(clipRect);
|
||||
|
||||
|
@ -267,7 +253,7 @@ static inline int common_prefix_length(const char *a, const char *b) {
|
|||
NSUInteger glyphCount;
|
||||
[textStorage replaceCharactersInRange:replacementRange withString:replacementCharacters];
|
||||
if (previousTextStorageCharacterCount == 0) {
|
||||
NSDictionary *atts = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor colorWithCalibratedWhite:(CGFloat).1 alpha:(CGFloat).8], NSForegroundColorAttributeName, nil];
|
||||
NSDictionary *atts = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor controlTextColor], NSForegroundColorAttributeName, nil];
|
||||
[textStorage setAttributes:atts range:NSMakeRange(0, newStringLength)];
|
||||
[atts release];
|
||||
}
|
||||
|
@ -305,7 +291,7 @@ static inline int common_prefix_length(const char *a, const char *b) {
|
|||
[mutableStyle setAlignment:NSRightTextAlignment];
|
||||
NSParagraphStyle *paragraphStyle = [mutableStyle copy];
|
||||
[mutableStyle release];
|
||||
textAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor colorWithCalibratedWhite:(CGFloat).1 alpha:(CGFloat).8], NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
textAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor controlTextColor], NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
[paragraphStyle release];
|
||||
}
|
||||
|
||||
|
@ -456,12 +442,12 @@ static inline int common_prefix_length(const char *a, const char *b) {
|
|||
}
|
||||
}
|
||||
|
||||
if (! textAttributes) {
|
||||
if (!textAttributes) {
|
||||
NSMutableParagraphStyle *mutableStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
[mutableStyle setAlignment:NSRightTextAlignment];
|
||||
NSParagraphStyle *paragraphStyle = [mutableStyle copy];
|
||||
[mutableStyle release];
|
||||
textAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor colorWithCalibratedWhite:(CGFloat).1 alpha:(CGFloat).8], NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
textAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor controlTextColor], NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
[paragraphStyle release];
|
||||
[textStorage setAttributes:textAttributes range:NSMakeRange(0, [textStorage length])];
|
||||
}
|
||||
|
@ -489,27 +475,28 @@ static inline int common_prefix_length(const char *a, const char *b) {
|
|||
NSUInteger linesRemaining = ll2l(HFFPToUL(ceill(_lineRangeToDraw.length + _lineRangeToDraw.location) - floorl(_lineRangeToDraw.location)));
|
||||
|
||||
CGFloat linesToVerticallyOffset = ld2f(_lineRangeToDraw.location - floorl(_lineRangeToDraw.location));
|
||||
CGFloat verticalOffset = linesToVerticallyOffset * _lineHeight + 1;
|
||||
CGFloat verticalOffset = linesToVerticallyOffset * _lineHeight + 1.5;
|
||||
NSRect textRect = self.bounds;
|
||||
textRect.size.width -= 5;
|
||||
textRect.origin.y -= verticalOffset;
|
||||
textRect.size.height += verticalOffset;
|
||||
|
||||
if (! textAttributes) {
|
||||
NSMutableParagraphStyle *mutableStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
[mutableStyle setAlignment:NSRightTextAlignment];
|
||||
[mutableStyle setMinimumLineHeight:_lineHeight];
|
||||
[mutableStyle setMaximumLineHeight:_lineHeight];
|
||||
NSParagraphStyle *paragraphStyle = [mutableStyle copy];
|
||||
[mutableStyle release];
|
||||
textAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor colorWithCalibratedWhite:(CGFloat).1 alpha:(CGFloat).8], NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
[paragraphStyle release];
|
||||
}
|
||||
textRect.size.height += verticalOffset + _lineHeight;
|
||||
|
||||
NSMutableParagraphStyle *mutableStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
[mutableStyle setAlignment:NSRightTextAlignment];
|
||||
[mutableStyle setMinimumLineHeight:_lineHeight];
|
||||
[mutableStyle setMaximumLineHeight:_lineHeight];
|
||||
NSParagraphStyle *paragraphStyle = [mutableStyle copy];
|
||||
[mutableStyle release];
|
||||
NSColor *color = [[NSColor textColor] colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
|
||||
color = [NSColor colorWithRed:color.redComponent green:color.greenComponent blue:color.blueComponent alpha:0.75];
|
||||
NSDictionary *_textAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[NSFont fontWithName:_font.fontName size:9], NSFontAttributeName, color, NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
[paragraphStyle release];
|
||||
|
||||
|
||||
NSString *string = [self newLineStringForRange:HFRangeMake(lineIndex, linesRemaining)];
|
||||
[string drawInRect:textRect withAttributes:textAttributes];
|
||||
[string drawInRect:textRect withAttributes:_textAttributes];
|
||||
[string release];
|
||||
[_textAttributes release];
|
||||
}
|
||||
|
||||
- (void)drawLineNumbersWithClipSingleStringCellDrawing:(NSRect)clipRect {
|
||||
|
@ -533,7 +520,7 @@ static inline int common_prefix_length(const char *a, const char *b) {
|
|||
[mutableStyle setMaximumLineHeight:_lineHeight];
|
||||
NSParagraphStyle *paragraphStyle = [mutableStyle copy];
|
||||
[mutableStyle release];
|
||||
textAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor colorWithCalibratedWhite:(CGFloat).1 alpha:(CGFloat).8], NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
textAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:_font, NSFontAttributeName, [NSColor controlTextColor], NSForegroundColorAttributeName, paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
[paragraphStyle release];
|
||||
}
|
||||
|
||||
|
@ -568,7 +555,7 @@ static inline int common_prefix_length(const char *a, const char *b) {
|
|||
#if TIME_LINE_NUMBERS
|
||||
CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent();
|
||||
#endif
|
||||
NSInteger drawingMode = (useStringDrawingPath ? 1 : 3);
|
||||
NSInteger drawingMode = 3; // (useStringDrawingPath ? 1 : 3);
|
||||
switch (drawingMode) {
|
||||
// Drawing can't be done right if fonts are wider than expected, but all
|
||||
// of these have rather nasty behavior in that case. I've commented what
|
||||
|
@ -606,7 +593,6 @@ static inline int common_prefix_length(const char *a, const char *b) {
|
|||
}
|
||||
|
||||
- (void)drawRect:(NSRect)clipRect {
|
||||
[self drawGradientWithClip:clipRect];
|
||||
[self drawDividerWithClip:clipRect];
|
||||
[self drawLineNumbersWithClip:clipRect];
|
||||
}
|
||||
|
|
|
@ -441,7 +441,7 @@ enum LineCoverage_t {
|
|||
- (void)drawCaretIfNecessaryWithClip:(NSRect)clipRect {
|
||||
NSRect caretRect = NSIntersectionRect(caretRectToDraw, clipRect);
|
||||
if (! NSIsEmptyRect(caretRect)) {
|
||||
[[NSColor blackColor] set];
|
||||
[[NSColor controlTextColor] set];
|
||||
NSRectFill(caretRect);
|
||||
lastDrawnCaretRect = caretRect;
|
||||
}
|
||||
|
@ -456,12 +456,18 @@ enum LineCoverage_t {
|
|||
|
||||
/* This is the color when we are not in the key window */
|
||||
- (NSColor *)inactiveTextSelectionColor {
|
||||
if (@available(macOS 10.14, *)) {
|
||||
return [NSColor unemphasizedSelectedTextBackgroundColor];
|
||||
}
|
||||
return [NSColor colorWithCalibratedWhite: (CGFloat)(212./255.) alpha:1];
|
||||
}
|
||||
|
||||
/* This is the color when we are not the first responder, but we are in the key window */
|
||||
- (NSColor *)secondaryTextSelectionColor {
|
||||
return [[self primaryTextSelectionColor] blendedColorWithFraction:.66 ofColor:[NSColor colorWithCalibratedWhite:.8f alpha:1]];
|
||||
if (@available(macOS 10.14, *)) {
|
||||
return [NSColor unemphasizedSelectedTextBackgroundColor];
|
||||
}
|
||||
return [NSColor colorWithCalibratedWhite: (CGFloat)(212./255.) alpha:1];
|
||||
}
|
||||
|
||||
- (NSColor *)textSelectionColor {
|
||||
|
@ -826,7 +832,7 @@ enum LineCoverage_t {
|
|||
- (HFTextVisualStyleRun *)styleRunForByteAtIndex:(NSUInteger)byteIndex {
|
||||
HFTextVisualStyleRun *run = [[HFTextVisualStyleRun alloc] init];
|
||||
[run setRange:NSMakeRange(0, NSUIntegerMax)];
|
||||
[run setForegroundColor:[NSColor blackColor]];
|
||||
[run setForegroundColor:[NSColor textColor]];
|
||||
return [run autorelease];
|
||||
}
|
||||
|
||||
|
@ -902,8 +908,8 @@ static size_t unionAndCleanLists(NSRect *rectList, id *valueList, size_t count)
|
|||
guideIndex++;
|
||||
}
|
||||
if (rectIndex > 0) {
|
||||
[[NSColor colorWithCalibratedWhite:(CGFloat).8 alpha:1] set];
|
||||
NSRectFillListUsingOperation(lineRects, rectIndex, NSCompositePlusDarker);
|
||||
[[NSColor gridColor] set];
|
||||
NSRectFillListUsingOperation(lineRects, rectIndex, NSCompositeSourceOver);
|
||||
}
|
||||
FREE_ARRAY(lineRects);
|
||||
}
|
||||
|
@ -1344,7 +1350,7 @@ static size_t unionAndCleanLists(NSRect *rectList, id *valueList, size_t count)
|
|||
[self _drawDefaultLineBackgrounds:clip withLineHeight:[self lineHeight] maxLines:ll2l(HFRoundUpToNextMultipleSaturate(byteCount, bytesPerLine) / bytesPerLine)];
|
||||
[self drawSelectionIfNecessaryWithClip:clip];
|
||||
|
||||
NSColor *textColor = [NSColor blackColor];
|
||||
NSColor *textColor = [NSColor textColor];
|
||||
[textColor set];
|
||||
|
||||
if (! antialias) {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
- (void)_sharedInitStatusBarView {
|
||||
NSMutableParagraphStyle *style = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
|
||||
[style setAlignment:NSCenterTextAlignment];
|
||||
cellAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[NSColor colorWithCalibratedWhite:(CGFloat).15 alpha:1], NSForegroundColorAttributeName, [NSFont labelFontOfSize:10], NSFontAttributeName, style, NSParagraphStyleAttributeName, nil];
|
||||
cellAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[NSColor windowFrameTextColor], NSForegroundColorAttributeName, [NSFont labelFontOfSize:[NSFont smallSystemFontSize]], NSFontAttributeName, style, NSParagraphStyleAttributeName, nil];
|
||||
cell = [[NSCell alloc] initTextCell:@""];
|
||||
[cell setAlignment:NSCenterTextAlignment];
|
||||
[cell setBackgroundStyle:NSBackgroundStyleRaised];
|
||||
|
@ -62,51 +62,24 @@
|
|||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)drawDividerWithClip:(NSRect)clipRect {
|
||||
[[NSColor lightGrayColor] set];
|
||||
NSRect bounds = [self bounds];
|
||||
NSRect lineRect = bounds;
|
||||
lineRect.size.height = 1;
|
||||
NSRectFill(NSIntersectionRect(lineRect, clipRect));
|
||||
}
|
||||
|
||||
|
||||
- (NSGradient *)getGradient:(BOOL)active {
|
||||
static NSGradient *sActiveGradient;
|
||||
static NSGradient *sInactiveGradient;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sActiveGradient = [[NSGradient alloc] initWithColorsAndLocations:
|
||||
[NSColor colorWithCalibratedWhite:.89 alpha:1.], 0.00,
|
||||
[NSColor colorWithCalibratedWhite:.77 alpha:1.], 0.9,
|
||||
[NSColor colorWithCalibratedWhite:.82 alpha:1.], 1.0,
|
||||
nil];
|
||||
|
||||
sInactiveGradient = [[NSGradient alloc] initWithColorsAndLocations:
|
||||
[NSColor colorWithCalibratedWhite:.93 alpha:1.], 0.00,
|
||||
[NSColor colorWithCalibratedWhite:.87 alpha:1.], 0.9,
|
||||
[NSColor colorWithCalibratedWhite:.90 alpha:1.], 1.0,
|
||||
nil];
|
||||
});
|
||||
return active ? sActiveGradient : sInactiveGradient;
|
||||
}
|
||||
|
||||
|
||||
- (void)drawRect:(NSRect)clip {
|
||||
USE(clip);
|
||||
NSRect bounds = [self bounds];
|
||||
// [[NSColor colorWithCalibratedWhite:(CGFloat).91 alpha:1] set];
|
||||
// NSRectFill(clip);
|
||||
|
||||
NSWindow *window = [self window];
|
||||
BOOL drawActive = (window == nil || [window isMainWindow] || [window isKeyWindow]);
|
||||
[[self getGradient:drawActive] drawInRect:bounds angle:90.];
|
||||
|
||||
[self drawDividerWithClip:clip];
|
||||
NSRect cellRect = NSMakeRect(NSMinX(bounds), HFCeil(NSMidY(bounds) - cellSize.height / 2), NSWidth(bounds), cellSize.height);
|
||||
[cell drawWithFrame:cellRect inView:self];
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)frame
|
||||
{
|
||||
[super setFrame:frame];
|
||||
[self.window setContentBorderThickness:frame.origin.y + frame.size.height forEdge:NSMinYEdge];
|
||||
}
|
||||
|
||||
|
||||
- (void)mouseDown:(NSEvent *)event {
|
||||
USE(event);
|
||||
HFStatusBarMode newMode = ([representer statusMode] + 1) % HFSTATUSMODECOUNT;
|
||||
|
@ -122,6 +95,7 @@
|
|||
- (void)viewDidMoveToWindow {
|
||||
HFRegisterViewForWindowAppearanceChanges(self, @selector(windowDidChangeKeyStatus:), !registeredForAppNotifications);
|
||||
registeredForAppNotifications = YES;
|
||||
[self.window setContentBorderThickness:self.frame.origin.y + self.frame.size.height forEdge:NSMinYEdge];
|
||||
[super viewDidMoveToWindow];
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,13 @@
|
|||
- (instancetype)init {
|
||||
self = [super init];
|
||||
|
||||
NSColor *color1 = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
|
||||
NSColor *color2 = [NSColor colorWithCalibratedRed:.87 green:.89 blue:1. alpha:1.];
|
||||
_rowBackgroundColors = [@[color1, color2] retain];
|
||||
if (@available(macOS 10.14, *)) {
|
||||
_rowBackgroundColors = [[NSColor alternatingContentBackgroundColors] retain];
|
||||
} else {
|
||||
NSColor *color1 = [NSColor windowBackgroundColor];
|
||||
NSColor *color2 = [NSColor colorWithDeviceWhite:0.96 alpha:1];
|
||||
_rowBackgroundColors = [@[color1, color2] retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -237,7 +241,7 @@
|
|||
FOREACH(HFRangeWrapper *, wrapper, selectedRanges) {
|
||||
HFRange selectedRange = [wrapper HFRange];
|
||||
BOOL clippedRangeIsVisible;
|
||||
NSRange clippedSelectedRange;
|
||||
NSRange clippedSelectedRange = {0,};
|
||||
/* Necessary because zero length ranges do not intersect anything */
|
||||
if (selectedRange.length == 0) {
|
||||
/* Remember that {6, 0} is considered a subrange of {3, 3} */
|
||||
|
|
Loading…
Reference in New Issue