From 60ad4a761ace5fffb2379b8437c26249e194ad26 Mon Sep 17 00:00:00 2001 From: Yevgeny Makarov Date: Fri, 6 Nov 2020 08:28:58 -0800 Subject: UI: Improved macOS Application Icon Progress Bar Nicer appearance for the progress bar that is drawn over the application icon during long processes on macOS. Differential Revision: https://developer.blender.org/D9398 Reviewed by Brecht Van Lommel --- intern/ghost/intern/GHOST_WindowCocoa.mm | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'intern/ghost') diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index ebc08fb411c..360fe73b648 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -869,28 +869,26 @@ GHOST_TSuccess GHOST_WindowCocoa::setProgressBar(float progress) NSImage *dockIcon = [[NSImage alloc] initWithSize:NSMakeSize(128, 128)]; [dockIcon lockFocus]; - NSRect progressBox = {{4, 4}, {120, 16}}; [[NSImage imageNamed:@"NSApplicationIcon"] drawAtPoint:NSZeroPoint fromRect:NSZeroRect operation:NSCompositingOperationSourceOver fraction:1.0]; - // Track & Outline - [[NSColor blackColor] setFill]; - NSRectFill(progressBox); + NSRect progressRect = {{8, 8}, {112, 14}}; + NSBezierPath *progressPath; - [[NSColor whiteColor] set]; - NSFrameRect(progressBox); + /* Draw white track. */ + [[[NSColor whiteColor] colorWithAlphaComponent: 0.6] setFill]; + progressPath = [NSBezierPath bezierPathWithRoundedRect:progressRect xRadius:7 yRadius:7]; + [progressPath fill]; - // Progress fill - progressBox = NSInsetRect(progressBox, 1, 1); - - progressBox.size.width = progressBox.size.width * progress; - NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor darkGrayColor] - endingColor:[NSColor lightGrayColor]]; - [gradient drawInRect:progressBox angle:90]; - [gradient release]; + /* Black progress fill. */ + [[[NSColor blackColor] colorWithAlphaComponent: 0.7] setFill]; + progressRect = NSInsetRect(progressRect, 2, 2); + progressRect.size.width *= progress; + progressPath = [NSBezierPath bezierPathWithRoundedRect:progressRect xRadius:5 yRadius:5]; + [progressPath fill]; [dockIcon unlockFocus]; -- cgit v1.2.3