| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/cocoa/download_shelf_view.h" | 5 #import "chrome/browser/cocoa/download_shelf_view.h" |
| 6 | 6 |
| 7 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
| 8 #import "third_party/GTM/AppKit/GTMTheme.h" |
| 8 | 9 |
| 9 @implementation DownloadShelfView | 10 @implementation DownloadShelfView |
| 10 | 11 |
| 12 - (NSColor*)strokeColor { |
| 13 return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar |
| 14 state:[[self window] isKeyWindow]]; |
| 15 } |
| 16 |
| 11 - (void)drawRect:(NSRect)rect { | 17 - (void)drawRect:(NSRect)rect { |
| 12 rect = [self bounds]; | 18 BOOL isKey = [[self window] isKeyWindow]; |
| 13 | 19 |
| 14 // TODO(thakis): Once this has its final look, it also needs an | 20 GTMTheme *theme = [self gtm_theme]; |
| 15 // "inactive" state. | |
| 16 | 21 |
| 17 #if 0 | 22 NSImage *backgroundImage = [theme backgroundImageForStyle:GTMThemeStyleToolBar |
| 18 // Grey Finder/iCal-like bottom bar with dark gradient, dark/light lines | 23 state:GTMThemeStateActiveWindow]; |
| 19 NSColor* start = | 24 if (backgroundImage) { |
| 20 [NSColor colorWithCalibratedWhite: 0.75 alpha:1.0]; | 25 [[NSGraphicsContext currentContext] setPatternPhase:NSZeroPoint]; |
| 21 NSColor* end = [NSColor colorWithCalibratedWhite:0.59 alpha:1.0]; | 26 NSColor *color = [NSColor colorWithPatternImage:backgroundImage]; |
| 22 scoped_nsobject<NSGradient> gradient( | 27 [color set]; |
| 23 [[NSGradient alloc] initWithStartingColor:start endingColor:end]); | 28 NSRectFill([self bounds]); |
| 24 [gradient drawInRect:[self bounds] angle:270.0]; | 29 } else { |
| 30 NSGradient *gradient = [theme gradientForStyle:GTMThemeStyleToolBar |
| 31 state:isKey]; |
| 32 NSPoint startPoint = [self convertPointFromBase:NSMakePoint(0, 0)]; |
| 33 NSPoint endPoint = [self convertPointFromBase: |
| 34 NSMakePoint(0, [self frame].size.height)]; |
| 25 | 35 |
| 36 [gradient drawFromPoint:startPoint |
| 37 toPoint:endPoint |
| 38 options:NSGradientDrawsBeforeStartingLocation | |
| 39 NSGradientDrawsAfterEndingLocation]; |
| 40 } |
| 41 |
| 42 // Draw top stroke |
| 43 [[self strokeColor] set]; |
| 26 NSRect borderRect, contentRect; | 44 NSRect borderRect, contentRect; |
| 27 NSDivideRect(rect, &borderRect, &contentRect, 1, NSMaxYEdge); | 45 NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMaxYEdge); |
| 28 [[NSColor colorWithDeviceWhite:0.25 alpha:1.0] set]; | |
| 29 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); | 46 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); |
| 30 | |
| 31 NSDivideRect(contentRect, &borderRect, &contentRect, 1, NSMaxYEdge); | |
| 32 [[NSColor colorWithDeviceWhite:0.85 alpha:1.0] set]; | |
| 33 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); | |
| 34 #else | |
| 35 // Glossy two-color bar with only light line at top (Mail.app/HitList-style) | |
| 36 // Doesn't mesh with the matte look of the toolbar. | |
| 37 | |
| 38 NSRect topRect, bottomRect; | |
| 39 NSDivideRect(rect, &topRect, &bottomRect, rect.size.height/2, NSMaxYEdge); | |
| 40 | |
| 41 // 1px line at top | |
| 42 NSRect borderRect, contentRect; | |
| 43 NSDivideRect(topRect, &borderRect, &contentRect, 1, NSMaxYEdge); | |
| 44 [[NSColor colorWithDeviceWhite:0.69 alpha:1.0] set]; | |
| 45 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); | |
| 46 | |
| 47 // Gradient for upper half | |
| 48 NSColor* start = | |
| 49 [NSColor colorWithCalibratedWhite: 1.0 alpha:1.0]; | |
| 50 NSColor* end = [NSColor colorWithCalibratedWhite:0.94 alpha:1.0]; | |
| 51 scoped_nsobject<NSGradient> gradient( | |
| 52 [[NSGradient alloc] initWithStartingColor:start endingColor:end]); | |
| 53 [gradient drawInRect:contentRect angle:270.0]; | |
| 54 | |
| 55 // Fill lower half with solid color | |
| 56 [[NSColor colorWithDeviceWhite:0.9 alpha:1.0] set]; | |
| 57 NSRectFillUsingOperation(bottomRect, NSCompositeSourceOver); | |
| 58 #endif | |
| 59 } | 47 } |
| 60 | 48 |
| 61 @end | 49 @end |
| OLD | NEW |