Chromium Code Reviews| 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" |
| 11 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" | 11 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" |
| 12 #include "ui/base/material_design/material_design_controller.h" | |
| 12 | 13 |
| 13 using bookmarks::kBookmarkBarMenuCornerRadius; | 14 using bookmarks::kBookmarkBarMenuCornerRadius; |
| 14 | 15 |
| 16 namespace { | |
| 17 | |
| 18 // Material Design bookmark folder window background white. | |
| 19 const CGFloat kMDFolderWindowBackgroundColor = 237. / 255.; | |
| 20 | |
| 21 } // namespace | |
| 22 | |
|
tapted
2016/08/09 02:52:03
nit: remove extra blank line
(also technically th
shrike
2016/08/09 16:28:50
Done. And I will leave the namespace as is.
| |
| 23 | |
| 15 @implementation BookmarkBarFolderWindow | 24 @implementation BookmarkBarFolderWindow |
| 16 | 25 |
| 17 - (id)initWithContentRect:(NSRect)contentRect | 26 - (id)initWithContentRect:(NSRect)contentRect |
| 18 styleMask:(NSUInteger)windowStyle | 27 styleMask:(NSUInteger)windowStyle |
| 19 backing:(NSBackingStoreType)bufferingType | 28 backing:(NSBackingStoreType)bufferingType |
| 20 defer:(BOOL)deferCreation { | 29 defer:(BOOL)deferCreation { |
| 21 if ((self = [super initWithContentRect:contentRect | 30 if ((self = [super initWithContentRect:contentRect |
| 22 styleMask:NSBorderlessWindowMask // override | 31 styleMask:NSBorderlessWindowMask // override |
| 23 backing:bufferingType | 32 backing:bufferingType |
| 24 defer:deferCreation])) { | 33 defer:deferCreation])) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 38 | 47 |
| 39 // Override of keyDown as the NSWindow default implementation beeps. | 48 // Override of keyDown as the NSWindow default implementation beeps. |
| 40 - (void)keyDown:(NSEvent *)theEvent { | 49 - (void)keyDown:(NSEvent *)theEvent { |
| 41 } | 50 } |
| 42 | 51 |
| 43 @end | 52 @end |
| 44 | 53 |
| 45 | 54 |
| 46 @implementation BookmarkBarFolderWindowContentView | 55 @implementation BookmarkBarFolderWindowContentView |
| 47 | 56 |
| 57 + (NSColor*)backgroundColor { | |
| 58 DCHECK(ui::MaterialDesignController::IsModeMaterial()); | |
| 59 static NSColor* backgroundColor = | |
| 60 [[NSColor colorWithGenericGamma22White:kMDFolderWindowBackgroundColor | |
| 61 alpha:1.0] retain]; | |
| 62 return backgroundColor; | |
| 63 } | |
| 64 | |
| 48 - (void)drawRect:(NSRect)rect { | 65 - (void)drawRect:(NSRect)rect { |
| 49 // Like NSMenus, only the bottom corners are rounded. | 66 // Like NSMenus, only the bottom corners are rounded. |
| 50 NSBezierPath* bezier = | 67 NSBezierPath* bezier = |
| 51 [NSBezierPath bezierPathWithRoundedRect:[self bounds] | 68 [NSBezierPath bezierPathWithRoundedRect:[self bounds] |
| 52 xRadius:kBookmarkBarMenuCornerRadius | 69 xRadius:kBookmarkBarMenuCornerRadius |
| 53 yRadius:kBookmarkBarMenuCornerRadius]; | 70 yRadius:kBookmarkBarMenuCornerRadius]; |
| 54 NSColor* startColor = [NSColor colorWithCalibratedWhite:0.91 alpha:1.0]; | 71 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 55 NSColor* midColor = | 72 [[BookmarkBarFolderWindowContentView backgroundColor] set]; |
| 56 [startColor gtm_colorAdjustedFor:GTMColorationLightMidtone faded:YES]; | 73 [bezier fill]; |
| 57 NSColor* endColor = | 74 } else { |
| 58 [startColor gtm_colorAdjustedFor:GTMColorationLightPenumbra faded:YES]; | 75 NSColor* startColor = [NSColor colorWithCalibratedWhite:0.91 alpha:1.0]; |
| 76 NSColor* midColor = | |
| 77 [startColor gtm_colorAdjustedFor:GTMColorationLightMidtone faded:YES]; | |
| 78 NSColor* endColor = | |
| 79 [startColor gtm_colorAdjustedFor:GTMColorationLightPenumbra faded:YES]; | |
| 59 | 80 |
| 60 base::scoped_nsobject<NSGradient> gradient( | 81 base::scoped_nsobject<NSGradient> gradient( |
| 61 [[NSGradient alloc] initWithColorsAndLocations:startColor, 0.0, | 82 [[NSGradient alloc] initWithColorsAndLocations:startColor, 0.0, |
| 62 midColor, 0.25, | 83 midColor, 0.25, |
| 63 endColor, 0.5, | 84 endColor, 0.5, |
| 64 midColor, 0.75, | 85 midColor, 0.75, |
| 65 startColor, 1.0, | 86 startColor, 1.0, |
| 66 nil]); | 87 nil]); |
| 67 [gradient drawInBezierPath:bezier angle:0.0]; | 88 [gradient drawInBezierPath:bezier angle:0.0]; |
| 89 } | |
| 68 } | 90 } |
| 69 | 91 |
| 70 @end | 92 @end |
| 71 | 93 |
| 72 | 94 |
| 73 @implementation BookmarkBarFolderWindowScrollView | 95 @implementation BookmarkBarFolderWindowScrollView |
| 74 | 96 |
| 75 // We want "draw background" of the NSScrollView in the xib to be NOT | 97 // We want "draw background" of the NSScrollView in the xib to be NOT |
| 76 // checked. That allows us to round the bottom corners of the folder | 98 // checked. That allows us to round the bottom corners of the folder |
| 77 // window. However that also allows some scrollWheel: events to leak | 99 // window. However that also allows some scrollWheel: events to leak |
| 78 // into the NSWindow behind it (even in a different application). | 100 // into the NSWindow behind it (even in a different application). |
| 79 // Better to plug the scroll leak than to round corners for M5. | 101 // Better to plug the scroll leak than to round corners for M5. |
| 80 - (void)scrollWheel:(NSEvent *)theEvent { | 102 - (void)scrollWheel:(NSEvent *)theEvent { |
| 81 DCHECK([[[self window] windowController] | 103 DCHECK([[[self window] windowController] |
| 82 respondsToSelector:@selector(scrollWheel:)]); | 104 respondsToSelector:@selector(scrollWheel:)]); |
| 83 [[[self window] windowController] scrollWheel:theEvent]; | 105 [[[self window] windowController] scrollWheel:theEvent]; |
| 84 } | 106 } |
| 85 | 107 |
| 86 @end | 108 @end |
| OLD | NEW |