[vlc-commits] macOS: Draw focus ring for VLCHUDSegmentedCell

Marvin Scholz git at videolan.org
Wed Jun 21 00:35:55 CEST 2017


vlc | branch: master | Marvin Scholz <epirat07 at gmail.com> | Wed Jun 21 00:23:01 2017 +0200| [a3b6d42301e1a93904144f092e15ab6b7a35d8b5] | committer: Marvin Scholz

macOS: Draw focus ring for VLCHUDSegmentedCell

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a3b6d42301e1a93904144f092e15ab6b7a35d8b5
---

 modules/gui/macosx/VLCHUDSegmentedCell.m | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/modules/gui/macosx/VLCHUDSegmentedCell.m b/modules/gui/macosx/VLCHUDSegmentedCell.m
index cb4cc027df..ee44485190 100644
--- a/modules/gui/macosx/VLCHUDSegmentedCell.m
+++ b/modules/gui/macosx/VLCHUDSegmentedCell.m
@@ -38,6 +38,7 @@
 @interface NSSegmentedCell (Private)
 
 - (NSRect)rectForSegment:(NSInteger)segment inFrame:(NSRect)frame;
+- (NSInteger)_keySegment;
 
 @end
 
@@ -116,6 +117,15 @@
 
     if (segment > 0 && segment < (self.segmentCount - 1)) {
         // Middle segments
+        [NSGraphicsContext saveGraphicsState];
+        if ([super showsFirstResponder] && [[[self controlView] window] isKeyWindow] &&
+            ([self focusRingType] == NSFocusRingTypeDefault ||
+             [self focusRingType] == NSFocusRingTypeExterior) &&
+            [self respondsToSelector:@selector(_keySegment)] && self._keySegment == segment) {
+            NSSetFocusRingStyle(NSFocusRingOnly);
+            NSRectFill(frame);
+        }
+        [NSGraphicsContext restoreGraphicsState];
         [gradient drawInRect:frame angle:90];
         return;
     }
@@ -137,6 +147,15 @@
         [fillPath lineToPoint: NSMakePoint(NSMinX(frame), NSMaxY(frame))];
     }
     [fillPath closePath];
+    [NSGraphicsContext saveGraphicsState];
+    if ([super showsFirstResponder] && [[[self controlView] window] isKeyWindow] &&
+        ([self focusRingType] == NSFocusRingTypeDefault ||
+         [self focusRingType] == NSFocusRingTypeExterior) &&
+        [self respondsToSelector:@selector(_keySegment)] && self._keySegment == segment) {
+        NSSetFocusRingStyle(NSFocusRingOnly);
+        [fillPath fill];
+    }
+    [NSGraphicsContext restoreGraphicsState];
     [gradient drawInBezierPath:fillPath angle:90];
 }
 



More information about the vlc-commits mailing list