Draw white circle around label swatch when row is selected

We previously did this when the background style was set to dark, but the code for this only works when the view is a direct descendent of the NSTableCellView and also, when a row is selected in an inactive table view, the background style is not set to dark.
This commit is contained in:
Allan Odgaard
2015-07-29 23:19:34 +02:00
parent 5b357d58c2
commit d40d9b0f24

View File

@@ -28,7 +28,6 @@
@interface OakLabelSwatchView : NSView
@property (nonatomic) NSInteger labelIndex;
@property (nonatomic) NSBackgroundStyle backgroundStyle;
@end
@implementation OakLabelSwatchView
@@ -42,6 +41,14 @@
}
}
- (BOOL)isSelected
{
NSView* view = self;
while(view && ![view isKindOfClass:[NSTableRowView class]])
view = [view superview];
return [view isKindOfClass:[NSTableRowView class]] && ((NSTableRowView*)view).isSelected;
}
- (void)drawRect:(NSRect)aRect
{
if(_labelIndex == 0)
@@ -56,7 +63,7 @@
NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:r];
[path fill];
if(_backgroundStyle == NSBackgroundStyleDark)
if(self.isSelected)
{
[[NSColor whiteColor] set];
[path stroke];