From d40d9b0f2440ebf83c8acb1cf9569f0fac441735 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Wed, 29 Jul 2015 23:19:34 +0200 Subject: [PATCH] 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. --- .../OakFileBrowser/src/FSOutlineViewDelegate.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Frameworks/OakFileBrowser/src/FSOutlineViewDelegate.mm b/Frameworks/OakFileBrowser/src/FSOutlineViewDelegate.mm index 807821bb..b042b47a 100644 --- a/Frameworks/OakFileBrowser/src/FSOutlineViewDelegate.mm +++ b/Frameworks/OakFileBrowser/src/FSOutlineViewDelegate.mm @@ -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];