feat: separator with direction flip

This commit is contained in:
relikd
2025-12-09 15:08:20 +01:00
parent 0806003fc3
commit 469d7bcdd4
2 changed files with 3 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
/// Draw separator line in @c NSOutlineView
IB_DESIGNABLE
@interface DrawSeparator : NSView
@property (assign) BOOL invert;
@end

View File

@@ -7,7 +7,8 @@
@implementation DrawSeparator
- (void)drawRect:(NSRect)r {
NSColor *color = [NSColor darkGrayColor];
NSGradient *grdnt = [[NSGradient alloc] initWithStartingColor:color endingColor:[color colorWithAlphaComponent:0.0]];
NSColor *transparent = [color colorWithAlphaComponent:0.0];
NSGradient *grdnt = [[NSGradient alloc] initWithStartingColor:self.invert ? transparent : color endingColor:self.invert ? color : transparent];
NSRect separatorRect = NSMakeRect(1, NSMidY(self.bounds) - 1, NSWidth(self.bounds) - 2, 2);
NSBezierPath *rounded = [NSBezierPath bezierPathWithRoundedRect:separatorRect xRadius:1 yRadius:1];
[grdnt drawInBezierPath:rounded angle:0];