Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: chrome/browser/cocoa/download_shelf_view.mm

Issue 260009: Several background pattern fixes on the Mac.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #import "third_party/GTM/AppKit/GTMTheme.h"
9 9
10 @implementation DownloadShelfView 10 @implementation DownloadShelfView
11 11
12 - (NSColor*)strokeColor { 12 - (NSColor*)strokeColor {
13 return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar 13 return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar
14 state:[[self window] isKeyWindow]]; 14 state:[[self window] isKeyWindow]];
15 } 15 }
16 16
17 - (void)drawRect:(NSRect)rect { 17 - (void)drawRect:(NSRect)rect {
18 BOOL isKey = [[self window] isKeyWindow]; 18 BOOL isKey = [[self window] isKeyWindow];
19 19
20 GTMTheme *theme = [self gtm_theme]; 20 GTMTheme* theme = [self gtm_theme];
21 21
22 NSImage *backgroundImage = [theme backgroundImageForStyle:GTMThemeStyleToolBar 22 NSImage* backgroundImage = [theme backgroundImageForStyle:GTMThemeStyleToolBar
23 state:GTMThemeStateActiveWindow]; 23 state:GTMThemeStateActiveWindow];
24 if (backgroundImage) { 24 if (backgroundImage) {
25 [[NSGraphicsContext currentContext] setPatternPhase:NSZeroPoint]; 25 // We want our backgrounds for the shelf to be phased from the upper
26 NSColor *color = [NSColor colorWithPatternImage:backgroundImage]; 26 // left hand corner of the view.
27 NSPoint phase = NSMakePoint(0, NSHeight([self bounds]));
28 [[NSGraphicsContext currentContext] setPatternPhase:phase];
29 NSColor* color = [NSColor colorWithPatternImage:backgroundImage];
27 [color set]; 30 [color set];
28 NSRectFill([self bounds]); 31 NSRectFill([self bounds]);
29 } else { 32 } else {
30 NSGradient *gradient = [theme gradientForStyle:GTMThemeStyleToolBar 33 NSGradient* gradient = [theme gradientForStyle:GTMThemeStyleToolBar
31 state:isKey]; 34 state:isKey];
32 NSPoint startPoint = [self convertPointFromBase:NSMakePoint(0, 0)]; 35 NSPoint startPoint = [self convertPointFromBase:NSMakePoint(0, 0)];
33 NSPoint endPoint = [self convertPointFromBase: 36 NSPoint endPoint = [self convertPointFromBase:
34 NSMakePoint(0, [self frame].size.height)]; 37 NSMakePoint(0, [self frame].size.height)];
35 38
36 [gradient drawFromPoint:startPoint 39 [gradient drawFromPoint:startPoint
37 toPoint:endPoint 40 toPoint:endPoint
38 options:NSGradientDrawsBeforeStartingLocation | 41 options:NSGradientDrawsBeforeStartingLocation |
39 NSGradientDrawsAfterEndingLocation]; 42 NSGradientDrawsAfterEndingLocation];
40 } 43 }
41 44
42 // Draw top stroke 45 // Draw top stroke
43 [[self strokeColor] set]; 46 [[self strokeColor] set];
44 NSRect borderRect, contentRect; 47 NSRect borderRect, contentRect;
45 NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMaxYEdge); 48 NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMaxYEdge);
46 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); 49 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
47 } 50 }
48 51
49 // Mouse down events on the download shelf should not allow dragging the parent 52 // Mouse down events on the download shelf should not allow dragging the parent
50 // window around. 53 // window around.
51 - (BOOL)mouseDownCanMoveWindow { 54 - (BOOL)mouseDownCanMoveWindow {
52 return NO; 55 return NO;
53 } 56 }
54 57
55 @end 58 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/chrome_browser_window_unittest.mm ('k') | chrome/browser/cocoa/find_bar_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698