| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/profiles/avatar_label_button.h" | 5 #import "chrome/browser/ui/cocoa/profiles/avatar_label_button.h" |
| 6 | 6 |
| 7 #include "chrome/browser/themes/theme_properties.h" | 7 #include "chrome/browser/themes/theme_properties.h" |
| 8 #include "chrome/browser/ui/cocoa/themed_window.h" | 8 #include "chrome/browser/ui/cocoa/themed_window.h" |
| 9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 - (NSRect)drawTitle:(NSAttributedString*)title | 77 - (NSRect)drawTitle:(NSAttributedString*)title |
| 78 withFrame:(NSRect)frame | 78 withFrame:(NSRect)frame |
| 79 inView:(NSView*)controlView { | 79 inView:(NSView*)controlView { |
| 80 base::scoped_nsobject<NSMutableAttributedString> themedTitle( | 80 base::scoped_nsobject<NSMutableAttributedString> themedTitle( |
| 81 [[NSMutableAttributedString alloc] initWithAttributedString:title]); | 81 [[NSMutableAttributedString alloc] initWithAttributedString:title]); |
| 82 ui::ThemeProvider* themeProvider = [[controlView window] themeProvider]; | 82 ui::ThemeProvider* themeProvider = [[controlView window] themeProvider]; |
| 83 if (themeProvider) { | 83 if (themeProvider) { |
| 84 NSColor* textColor = themeProvider->GetNSColor( | 84 NSColor* textColor = themeProvider->GetNSColor( |
| 85 ThemeProperties::COLOR_MANAGED_USER_LABEL); | 85 ThemeProperties::COLOR_SUPERVISED_USER_LABEL); |
| 86 [themedTitle addAttribute:NSForegroundColorAttributeName | 86 [themedTitle addAttribute:NSForegroundColorAttributeName |
| 87 value:textColor | 87 value:textColor |
| 88 range:NSMakeRange(0, title.length)]; | 88 range:NSMakeRange(0, title.length)]; |
| 89 } | 89 } |
| 90 [themedTitle drawInRect:frame]; | 90 [themedTitle drawInRect:frame]; |
| 91 return frame; | 91 return frame; |
| 92 } | 92 } |
| 93 | 93 |
| 94 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { | 94 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { |
| 95 ui::ThemeProvider* themeProvider = [[controlView window] themeProvider]; | 95 ui::ThemeProvider* themeProvider = [[controlView window] themeProvider]; |
| 96 if (themeProvider) { | 96 if (themeProvider) { |
| 97 // Draw the label button background using the color provided by | 97 // Draw the label button background using the color provided by |
| 98 // |themeProvider|. First paint the border. | 98 // |themeProvider|. First paint the border. |
| 99 NSColor* borderColor = themeProvider->GetNSColor( | 99 NSColor* borderColor = themeProvider->GetNSColor( |
| 100 ThemeProperties::COLOR_MANAGED_USER_LABEL_BORDER); | 100 ThemeProperties::COLOR_SUPERVISED_USER_LABEL_BORDER); |
| 101 if ([self isHighlighted]) { | 101 if ([self isHighlighted]) { |
| 102 borderColor = [borderColor blendedColorWithFraction:0.5 | 102 borderColor = [borderColor blendedColorWithFraction:0.5 |
| 103 ofColor:[NSColor blackColor]]; | 103 ofColor:[NSColor blackColor]]; |
| 104 } | 104 } |
| 105 NSSize frameSize = cellFrame.size; | 105 NSSize frameSize = cellFrame.size; |
| 106 NSRect backgroundRect; | 106 NSRect backgroundRect; |
| 107 backgroundRect.origin = NSMakePoint(1, 1); | 107 backgroundRect.origin = NSMakePoint(1, 1); |
| 108 backgroundRect.size = NSMakeSize(frameSize.width - 2, frameSize.height - 2); | 108 backgroundRect.size = NSMakeSize(frameSize.width - 2, frameSize.height - 2); |
| 109 NSBezierPath* path = | 109 NSBezierPath* path = |
| 110 [NSBezierPath bezierPathWithRoundedRect:backgroundRect | 110 [NSBezierPath bezierPathWithRoundedRect:backgroundRect |
| 111 xRadius:2.0 | 111 xRadius:2.0 |
| 112 yRadius:2.0]; | 112 yRadius:2.0]; |
| 113 [borderColor set]; | 113 [borderColor set]; |
| 114 [path fill]; | 114 [path fill]; |
| 115 | 115 |
| 116 // Now paint the background. | 116 // Now paint the background. |
| 117 NSColor* backgroundColor = themeProvider->GetNSColor( | 117 NSColor* backgroundColor = themeProvider->GetNSColor( |
| 118 ThemeProperties::COLOR_MANAGED_USER_LABEL_BACKGROUND); | 118 ThemeProperties::COLOR_SUPERVISED_USER_LABEL_BACKGROUND); |
| 119 if ([self isHighlighted]) { | 119 if ([self isHighlighted]) { |
| 120 backgroundColor = | 120 backgroundColor = |
| 121 [backgroundColor blendedColorWithFraction:0.5 | 121 [backgroundColor blendedColorWithFraction:0.5 |
| 122 ofColor:[NSColor blackColor]]; | 122 ofColor:[NSColor blackColor]]; |
| 123 } | 123 } |
| 124 backgroundRect.origin = NSMakePoint(2, 2); | 124 backgroundRect.origin = NSMakePoint(2, 2); |
| 125 backgroundRect.size = NSMakeSize(frameSize.width - 4, frameSize.height - 4); | 125 backgroundRect.size = NSMakeSize(frameSize.width - 4, frameSize.height - 4); |
| 126 path = [NSBezierPath bezierPathWithRoundedRect:backgroundRect | 126 path = [NSBezierPath bezierPathWithRoundedRect:backgroundRect |
| 127 xRadius:2.0 | 127 xRadius:2.0 |
| 128 yRadius:2.0]; | 128 yRadius:2.0]; |
| 129 [backgroundColor set]; | 129 [backgroundColor set]; |
| 130 [path fill]; | 130 [path fill]; |
| 131 } | 131 } |
| 132 [super drawInteriorWithFrame:cellFrame inView:controlView]; | 132 [super drawInteriorWithFrame:cellFrame inView:controlView]; |
| 133 } | 133 } |
| 134 | 134 |
| 135 @end | 135 @end |
| OLD | NEW |