summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/autocomplete_text_field_cell.mm42
-rw-r--r--chrome/browser/cocoa/styled_text_field_cell.mm42
2 files changed, 29 insertions, 55 deletions
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell.mm b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
index 1cb9d96..5afcf10 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_cell.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_cell.mm
@@ -405,48 +405,6 @@ CGFloat WidthForKeyword(NSAttributedString* keywordString) {
fraction:1.0];
}
-- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
- [NSGraphicsContext saveGraphicsState];
-
- GTMTheme* theme = [controlView gtm_theme];
-
- NSRect drawFrame = NSInsetRect(cellFrame, 0.5, 1.5);
- // TODO(viettrungluu): It's hard to do pixel-perfect drawing in Cocoa 'cause
- // rounding kills you (obviously, the constants below should be 0.5, but then
- // it doesn't draw correctly).
- NSRect innerFrame = NSInsetRect(drawFrame, 0.5001, 0.5001);
- NSBezierPath* innerPath = [NSBezierPath bezierPathWithRect:drawFrame];
-
- // Paint button background image if there is one (otherwise the border won't
- // look right).
- NSImage* backgroundImage =
- [theme backgroundImageForStyle:GTMThemeStyleToolBarButton state:YES];
- if (backgroundImage) {
- NSColor* patternColor = [NSColor colorWithPatternImage:backgroundImage];
- [patternColor set];
- // Set the phase to match window.
- NSRect trueRect = [controlView convertRectToBase:cellFrame];
- [[NSGraphicsContext currentContext]
- setPatternPhase:NSMakePoint(NSMinX(trueRect), NSMaxY(trueRect))];
- [innerPath fill];
- }
-
- // Draw the outer stroke (over the background).
- [[theme strokeColorForStyle:GTMThemeStyleToolBarButton state:YES] setStroke];
- [innerPath setLineWidth:1];
- [innerPath stroke];
-
- // Fill the inside if we're told to.
- if ([self drawsBackground]) {
- [[self backgroundColor] setFill];
- [NSBezierPath fillRect:innerFrame];
- }
-
- [NSGraphicsContext restoreGraphicsState];
-
- [self drawInteriorWithFrame:cellFrame inView:controlView];
-}
-
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
if (hintString_) {
[self drawHintWithFrame:cellFrame inView:controlView];
diff --git a/chrome/browser/cocoa/styled_text_field_cell.mm b/chrome/browser/cocoa/styled_text_field_cell.mm
index 79b1adf..60418d9 100644
--- a/chrome/browser/cocoa/styled_text_field_cell.mm
+++ b/chrome/browser/cocoa/styled_text_field_cell.mm
@@ -47,30 +47,46 @@
// incorrect. I know that this affects -drawingRectForBounds:.
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
DCHECK([controlView isFlipped]);
- [[NSColor colorWithCalibratedWhite:1.0 alpha:0.25] set];
- NSFrameRectWithWidthUsingOperation(cellFrame, 1, NSCompositeSourceOver);
// TODO(shess): This inset is also reflected in ToolbarController
// -autocompletePopupPosition.
NSRect frame = NSInsetRect(cellFrame, 0, 1);
- [[self backgroundColor] setFill];
+ NSRect midFrame = NSInsetRect(frame, 0.5, 0.5);
NSRect innerFrame = NSInsetRect(frame, 1, 1);
- NSRectFill(innerFrame);
- NSRect shadowFrame, restFrame;
- NSDivideRect(innerFrame, &shadowFrame, &restFrame, 1, NSMinYEdge);
+ // Paint button background image if there is one (otherwise the border won't
+ // look right).
+ GTMTheme* theme = [controlView gtm_theme];
+ NSImage* backgroundImage =
+ [theme backgroundImageForStyle:GTMThemeStyleToolBarButton state:YES];
+ if (backgroundImage) {
+ NSColor* patternColor = [NSColor colorWithPatternImage:backgroundImage];
+ [patternColor set];
+ // Set the phase to match window.
+ NSRect trueRect = [controlView convertRectToBase:cellFrame];
+ [[NSGraphicsContext currentContext]
+ setPatternPhase:NSMakePoint(NSMinX(trueRect), NSMaxY(trueRect))];
+ NSRectFillUsingOperation(midFrame, NSCompositeCopy);
+ }
+
+ // Draw the outer stroke (over the background).
+ BOOL active = [[controlView window] isMainWindow];
+ [[theme strokeColorForStyle:GTMThemeStyleToolBarButton state:active] set];
+ NSFrameRectWithWidthUsingOperation(frame, 1, NSCompositeSourceOver);
- BOOL isMainWindow = [[controlView window] isMainWindow];
- GTMTheme *theme = [controlView gtm_theme];
- NSColor* stroke = [theme strokeColorForStyle:GTMThemeStyleToolBarButton
- state:isMainWindow];
- [stroke set];
- NSFrameRectWithWidthUsingOperation(frame, 1.0, NSCompositeSourceOver);
+ // Draw the background for the interior.
+ [[self backgroundColor] setFill];
+ NSRectFill(innerFrame);
// Draw the shadow.
+ NSRect topShadowFrame, leftShadowFrame, restFrame;
+ NSDivideRect(innerFrame, &topShadowFrame, &restFrame, 1, NSMinYEdge);
+ NSDivideRect(restFrame, &leftShadowFrame, &restFrame, 1, NSMinXEdge);
[[NSColor colorWithCalibratedWhite:0.0 alpha:0.05] setFill];
- NSRectFillUsingOperation(shadowFrame, NSCompositeSourceOver);
+ NSRectFillUsingOperation(topShadowFrame, NSCompositeSourceOver);
+ NSRectFillUsingOperation(leftShadowFrame, NSCompositeSourceOver);
+ // Draw the focus ring if needed.
if ([self showsFirstResponder]) {
[[[NSColor keyboardFocusIndicatorColor] colorWithAlphaComponent:0.5] set];
NSFrameRectWithWidthUsingOperation(NSInsetRect(frame, 0, 0), 2,