| 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/styled_text_field_cell.h" | 5 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/themes/theme_properties.h" | 8 #include "chrome/browser/themes/theme_properties.h" |
| 9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 10 #import "chrome/browser/ui/cocoa/themed_window.h" | 10 #import "chrome/browser/ui/cocoa/themed_window.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 rect_path_utils::RoundedCornerFlags roundedCornerFlags = | 83 rect_path_utils::RoundedCornerFlags roundedCornerFlags = |
| 84 [self roundedCornerFlags]; | 84 [self roundedCornerFlags]; |
| 85 | 85 |
| 86 // TODO(shess): This inset is also reflected by |kFieldVisualInset| | 86 // TODO(shess): This inset is also reflected by |kFieldVisualInset| |
| 87 // in omnibox_popup_view_mac.mm. | 87 // in omnibox_popup_view_mac.mm. |
| 88 const NSRect frame = NSInsetRect(cellFrame, 0, lineWidth); | 88 const NSRect frame = NSInsetRect(cellFrame, 0, lineWidth); |
| 89 const CGFloat radius = [self cornerRadius]; | 89 const CGFloat radius = [self cornerRadius]; |
| 90 | 90 |
| 91 // Paint button background image if there is one (otherwise the border won't | 91 // Paint button background image if there is one (otherwise the border won't |
| 92 // look right). | 92 // look right). |
| 93 ThemeService* themeProvider = | 93 ui::ThemeProvider* themeProvider = [[controlView window] themeProvider]; |
| 94 static_cast<ThemeService*>([[controlView window] themeProvider]); | |
| 95 if (themeProvider) { | 94 if (themeProvider) { |
| 96 NSColor* backgroundImageColor = nil; | 95 NSColor* backgroundImageColor = nil; |
| 97 if (themeProvider->HasCustomImage(IDR_THEME_BUTTON_BACKGROUND)) { | 96 if (themeProvider->HasCustomImage(IDR_THEME_BUTTON_BACKGROUND)) { |
| 98 backgroundImageColor = | 97 backgroundImageColor = |
| 99 themeProvider->GetNSImageColorNamed(IDR_THEME_BUTTON_BACKGROUND); | 98 themeProvider->GetNSImageColorNamed(IDR_THEME_BUTTON_BACKGROUND); |
| 100 } | 99 } |
| 101 if (backgroundImageColor) { | 100 if (backgroundImageColor) { |
| 102 // Set the phase to match window. | 101 // Set the phase to match window. |
| 103 NSRect trueRect = [controlView convertRect:cellFrame toView:nil]; | 102 NSRect trueRect = [controlView convertRect:cellFrame toView:nil]; |
| 104 NSPoint midPoint = NSMakePoint(NSMinX(trueRect), NSMaxY(trueRect)); | 103 NSPoint midPoint = NSMakePoint(NSMinX(trueRect), NSMaxY(trueRect)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 NSColor* shadowShade = [NSColor colorWithCalibratedWhite:0.0 | 140 NSColor* shadowShade = [NSColor colorWithCalibratedWhite:0.0 |
| 142 alpha:0.05 / lineWidth]; | 141 alpha:0.05 / lineWidth]; |
| 143 rect_path_utils::FrameRectWithInset(roundedCornerFlags, shadowFrame, | 142 rect_path_utils::FrameRectWithInset(roundedCornerFlags, shadowFrame, |
| 144 halfLineWidth, halfLineWidth, | 143 halfLineWidth, halfLineWidth, |
| 145 radius - halfLineWidth, lineWidth, | 144 radius - halfLineWidth, lineWidth, |
| 146 shadowShade); | 145 shadowShade); |
| 147 } | 146 } |
| 148 | 147 |
| 149 // Draw optional bezel below bottom stroke. | 148 // Draw optional bezel below bottom stroke. |
| 150 if ([self shouldDrawBezel] && themeProvider && | 149 if ([self shouldDrawBezel] && themeProvider && |
| 151 themeProvider->UsingDefaultTheme()) { | 150 themeProvider->UsingSystemTheme()) { |
| 152 | |
| 153 NSColor* bezelColor = themeProvider->GetNSColor( | 151 NSColor* bezelColor = themeProvider->GetNSColor( |
| 154 ThemeProperties::COLOR_TOOLBAR_BEZEL); | 152 ThemeProperties::COLOR_TOOLBAR_BEZEL); |
| 155 [[bezelColor colorWithAlphaComponent:0.5 / lineWidth] set]; | 153 [[bezelColor colorWithAlphaComponent:0.5 / lineWidth] set]; |
| 156 NSRect bezelRect = NSMakeRect(cellFrame.origin.x, | 154 NSRect bezelRect = NSMakeRect(cellFrame.origin.x, |
| 157 NSMaxY(cellFrame) - lineWidth, | 155 NSMaxY(cellFrame) - lineWidth, |
| 158 NSWidth(cellFrame), | 156 NSWidth(cellFrame), |
| 159 lineWidth); | 157 lineWidth); |
| 160 bezelRect = NSInsetRect(bezelRect, radius - halfLineWidth, 0.0); | 158 bezelRect = NSInsetRect(bezelRect, radius - halfLineWidth, 0.0); |
| 161 NSRectFillUsingOperation(bezelRect, NSCompositeSourceOver); | 159 NSRectFillUsingOperation(bezelRect, NSCompositeSourceOver); |
| 162 } | 160 } |
| 163 | 161 |
| 164 // Draw the interior before the focus ring, to make sure nothing overlaps it. | 162 // Draw the interior before the focus ring, to make sure nothing overlaps it. |
| 165 ui::ScopedCGContextSmoothFonts fontSmoothing; | 163 ui::ScopedCGContextSmoothFonts fontSmoothing; |
| 166 [self drawInteriorWithFrame:cellFrame inView:controlView]; | 164 [self drawInteriorWithFrame:cellFrame inView:controlView]; |
| 167 | 165 |
| 168 // Draw the focus ring if needed. | 166 // Draw the focus ring if needed. |
| 169 if ([self showsFirstResponder]) { | 167 if ([self showsFirstResponder]) { |
| 170 NSColor* color = [[NSColor keyboardFocusIndicatorColor] | 168 NSColor* color = [[NSColor keyboardFocusIndicatorColor] |
| 171 colorWithAlphaComponent:0.5 / lineWidth]; | 169 colorWithAlphaComponent:0.5 / lineWidth]; |
| 172 rect_path_utils::FrameRectWithInset(roundedCornerFlags, frame, 0.0, 0.0, | 170 rect_path_utils::FrameRectWithInset(roundedCornerFlags, frame, 0.0, 0.0, |
| 173 radius, lineWidth * 2, color); | 171 radius, lineWidth * 2, color); |
| 174 } | 172 } |
| 175 } | 173 } |
| 176 | 174 |
| 177 @end | 175 @end |
| OLD | NEW |