OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" |
6 | 6 |
7 #import "base/logging.h" | 7 #import "base/logging.h" |
8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 - (NSString*)accessibilityTitle { | 61 - (NSString*)accessibilityTitle { |
62 return l10n_util::GetNSString(IDS_ACCNAME_BOOKMARKS_MENU); | 62 return l10n_util::GetNSString(IDS_ACCNAME_BOOKMARKS_MENU); |
63 } | 63 } |
64 | 64 |
65 @end | 65 @end |
66 | 66 |
67 | 67 |
68 @implementation BookmarkBarFolderWindowContentView | 68 @implementation BookmarkBarFolderWindowContentView |
69 | 69 |
70 + (NSColor*)backgroundColor { | 70 + (NSColor*)backgroundColor { |
71 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | |
72 static NSColor* backgroundColor = | 71 static NSColor* backgroundColor = |
73 [[NSColor colorWithGenericGamma22White:kMDFolderWindowBackgroundColor | 72 [[NSColor colorWithGenericGamma22White:kMDFolderWindowBackgroundColor |
74 alpha:1.0] retain]; | 73 alpha:1.0] retain]; |
75 return backgroundColor; | 74 return backgroundColor; |
76 } | 75 } |
77 | 76 |
78 - (void)drawRect:(NSRect)rect { | 77 - (void)drawRect:(NSRect)rect { |
79 // Like NSMenus, only the bottom corners are rounded. | 78 // Like NSMenus, only the bottom corners are rounded. |
80 NSBezierPath* bezier = | 79 NSBezierPath* bezier = |
81 [NSBezierPath bezierPathWithRoundedRect:[self bounds] | 80 [NSBezierPath bezierPathWithRoundedRect:[self bounds] |
82 xRadius:kBookmarkBarMenuCornerRadius | 81 xRadius:kBookmarkBarMenuCornerRadius |
83 yRadius:kBookmarkBarMenuCornerRadius]; | 82 yRadius:kBookmarkBarMenuCornerRadius]; |
84 if (ui::MaterialDesignController::IsModeMaterial()) { | 83 [[BookmarkBarFolderWindowContentView backgroundColor] set]; |
85 [[BookmarkBarFolderWindowContentView backgroundColor] set]; | 84 [bezier fill]; |
86 [bezier fill]; | |
87 } else { | |
88 NSColor* startColor = [NSColor colorWithCalibratedWhite:0.91 alpha:1.0]; | |
89 NSColor* midColor = | |
90 [startColor gtm_colorAdjustedFor:GTMColorationLightMidtone faded:YES]; | |
91 NSColor* endColor = | |
92 [startColor gtm_colorAdjustedFor:GTMColorationLightPenumbra faded:YES]; | |
93 | |
94 base::scoped_nsobject<NSGradient> gradient( | |
95 [[NSGradient alloc] initWithColorsAndLocations:startColor, 0.0, | |
96 midColor, 0.25, | |
97 endColor, 0.5, | |
98 midColor, 0.75, | |
99 startColor, 1.0, | |
100 nil]); | |
101 [gradient drawInBezierPath:bezier angle:0.0]; | |
102 } | |
103 } | 85 } |
104 | 86 |
105 @end | 87 @end |
106 | 88 |
107 | 89 |
108 @implementation BookmarkBarFolderWindowScrollView | 90 @implementation BookmarkBarFolderWindowScrollView |
109 | 91 |
110 // We want "draw background" of the NSScrollView in the xib to be NOT | 92 // We want "draw background" of the NSScrollView in the xib to be NOT |
111 // checked. That allows us to round the bottom corners of the folder | 93 // checked. That allows us to round the bottom corners of the folder |
112 // window. However that also allows some scrollWheel: events to leak | 94 // window. However that also allows some scrollWheel: events to leak |
113 // into the NSWindow behind it (even in a different application). | 95 // into the NSWindow behind it (even in a different application). |
114 // Better to plug the scroll leak than to round corners for M5. | 96 // Better to plug the scroll leak than to round corners for M5. |
115 - (void)scrollWheel:(NSEvent *)theEvent { | 97 - (void)scrollWheel:(NSEvent *)theEvent { |
116 DCHECK([[[self window] windowController] | 98 DCHECK([[[self window] windowController] |
117 respondsToSelector:@selector(scrollWheel:)]); | 99 respondsToSelector:@selector(scrollWheel:)]); |
118 [[[self window] windowController] scrollWheel:theEvent]; | 100 [[[self window] windowController] scrollWheel:theEvent]; |
119 } | 101 } |
120 | 102 |
121 @end | 103 @end |
OLD | NEW |