feat: separator with direction flip
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
/// Draw separator line in @c NSOutlineView
|
/// Draw separator line in @c NSOutlineView
|
||||||
IB_DESIGNABLE
|
IB_DESIGNABLE
|
||||||
@interface DrawSeparator : NSView
|
@interface DrawSeparator : NSView
|
||||||
|
@property (assign) BOOL invert;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
@implementation DrawSeparator
|
@implementation DrawSeparator
|
||||||
- (void)drawRect:(NSRect)r {
|
- (void)drawRect:(NSRect)r {
|
||||||
NSColor *color = [NSColor darkGrayColor];
|
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);
|
NSRect separatorRect = NSMakeRect(1, NSMidY(self.bounds) - 1, NSWidth(self.bounds) - 2, 2);
|
||||||
NSBezierPath *rounded = [NSBezierPath bezierPathWithRoundedRect:separatorRect xRadius:1 yRadius:1];
|
NSBezierPath *rounded = [NSBezierPath bezierPathWithRoundedRect:separatorRect xRadius:1 yRadius:1];
|
||||||
[grdnt drawInBezierPath:rounded angle:0];
|
[grdnt drawInBezierPath:rounded angle:0];
|
||||||
|
|||||||
Reference in New Issue
Block a user