From 25af82850347b3fec95a0c04c3277942f41db2c5 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Wed, 24 Dec 2014 07:13:08 +0000 Subject: Refinement of custom scrollbars on Tk-Cocoa; now more centered, virtually identical to scrollbars in Safari, etc. --- macosx/tkMacOSXScrlbr.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index bd05df8..6b4d1ff 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -39,6 +39,7 @@ NSRect TkMacOSXGetScrollFrame(TkScrollbar *scrlPtr); * graphical-glitches-lag. Only supported on 10.7 and above. */ + @interface TkNSScroller: NSScroller -(void) drawRect:(NSRect)dirtyRect; #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 @@ -91,7 +92,7 @@ NSRect TkMacOSXGetScrollFrame(TkScrollbar *scrlPtr); } #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 -- (BOOL)isHorizontal { +- (BOOL)isVertical { NSRect bounds = [self bounds]; return NSWidth(bounds) < NSHeight (bounds); } @@ -101,18 +102,18 @@ NSRect TkMacOSXGetScrollFrame(TkScrollbar *scrlPtr); { NSRect knobRect = [self rectForPart:NSScrollerKnob]; - if ([self isHorizontal]) { - NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y, knobRect.size.width - 5, knobRect.size.height); - NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:7 yRadius:7]; + if ([self isVertical]) { + NSRect newRect = NSMakeRect(knobRect.origin.x + 3, knobRect.origin.y, knobRect.size.width - 6, knobRect.size.height); + NSBezierPath *scrollerPath = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:4 yRadius:4]; [[NSColor lightGrayColor] set]; - [path fill]; + [scrollerPath fill]; } else { - NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y, knobRect.size.width, knobRect.size.height - 5); - NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:7 yRadius:7]; + NSRect newRect = NSMakeRect(knobRect.origin.x, knobRect.origin.y + 3, knobRect.size.width, knobRect.size.height - 6); + NSBezierPath *scrollerPath = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:4 yRadius:4]; [[NSColor lightGrayColor] set]; - [path fill]; + [scrollerPath fill]; } } @@ -124,8 +125,9 @@ NSRect TkMacOSXGetScrollFrame(TkScrollbar *scrlPtr); - (void)drawKnobSlotInRect:(NSRect)rect highlight:(BOOL)highlight { - + } + #endif @end -- cgit v0.12