Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1320)

Unified Diff: chrome/browser/cocoa/infobar_gradient_view.mm

Issue 155788: Infobar UI cleanup on Mac. Adds the yellow background gradient and... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/infobar_gradient_view.mm
===================================================================
--- chrome/browser/cocoa/infobar_gradient_view.mm (revision 21067)
+++ chrome/browser/cocoa/infobar_gradient_view.mm (working copy)
@@ -2,79 +2,47 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/cocoa/background_gradient_view.h"
+#include "chrome/browser/cocoa/infobar_gradient_view.h"
+#import "third_party/GTM/AppKit/GTMTheme.h"
-#define kToolbarTopOffset 12
-#define kToolbarMaxHeight 128
+const double kBackgroundColorTop[3] =
+ {255.0 / 255.0, 242.0 / 255.0, 183.0 / 255.0};
+const double kBackgroundColorBottom[3] =
+ {250.0 / 255.0, 230.0 / 255.0, 145.0 / 255.0};
-@implementation BackgroundGradientView
-@synthesize showsDivider = showsDivider_;
-
-- (id)initWithFrame:(NSRect)frameRect {
- self = [super initWithFrame:frameRect];
- if (self != nil) {
- showsDivider_ = YES;
- }
- return self;
+@implementation InfoBarGradientView
+- (NSColor*)strokeColor {
+ return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar
+ state:[[self window] isKeyWindow]];
}
-- (void)awakeFromNib {
- showsDivider_ = YES;
-}
-
-- (void)setShowsDivider:(BOOL)show {
- showsDivider_ = show;
- [self setNeedsDisplay:YES];
-}
-
-// The offset of this pattern to make it line up with the top of the window.
-- (NSPoint)patternPhase {
- NSPoint phase = NSZeroPoint;
- phase.y += NSHeight([[self window] frame]) - kToolbarTopOffset;
- return phase;
-}
-
- (void)drawRect:(NSRect)rect {
- BOOL isKey = [[self window] isKeyWindow];
+ NSColor* startingColor =
+ [NSColor colorWithCalibratedRed:kBackgroundColorTop[0]
+ green:kBackgroundColorTop[1]
+ blue:kBackgroundColorTop[2]
+ alpha:1.0];
+ NSColor* endingColor =
+ [NSColor colorWithCalibratedRed:kBackgroundColorBottom[0]
+ green:kBackgroundColorBottom[1]
+ blue:kBackgroundColorBottom[2]
+ alpha:1.0];
+ NSGradient* gradient =
+ [[[NSGradient alloc] initWithStartingColor:startingColor
+ endingColor:endingColor] autorelease];
+ [gradient drawInRect:[self bounds] angle:270];
- GTMTheme *theme = [self gtm_theme];
-
- NSImage *backgroundImage = [theme backgroundImageForStyle:GTMThemeStyleToolBar
- state:GTMThemeStateActiveWindow];
- if (backgroundImage) {
- NSPoint phase = [self patternPhase];
- [[NSGraphicsContext currentContext] setPatternPhase:phase];
-
- NSColor *color = [NSColor colorWithPatternImage:backgroundImage];
- [color set];
- NSRectFill([self bounds]);
- } else {
- CGFloat winHeight = NSHeight([[self window] frame]);
- NSGradient *gradient = [theme gradientForStyle:GTMThemeStyleToolBar
- state:isKey];
- NSPoint startPoint = [self convertPointFromBase:
- NSMakePoint(0, winHeight - kToolbarTopOffset)];
- NSPoint endPoint = [self convertPointFromBase:
- NSMakePoint(0, winHeight - kToolbarTopOffset - kToolbarMaxHeight)];
-
- [gradient drawFromPoint:startPoint
- toPoint:endPoint
- options:NSGradientDrawsBeforeStartingLocation |
- NSGradientDrawsAfterEndingLocation];
- }
-
- if (showsDivider_) {
- // Draw bottom stroke
- [[self strokeColor] set];
- NSRect borderRect, contentRect;
- NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMinYEdge);
- NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
- }
+ // Draw bottom stroke
+ [[self strokeColor] set];
+ NSRect borderRect, contentRect;
+ NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMinYEdge);
+ NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
}
-- (NSColor*)strokeColor {
- return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar
- state:[[self window] isKeyWindow]];
+- (BOOL)mouseDownCanMoveWindow {
+ return NO;
}
+// This view is intentionally not opaque because it overlaps with the findbar.
+
@end
« no previous file with comments | « chrome/browser/cocoa/infobar_gradient_view.h ('k') | chrome/browser/cocoa/infobar_gradient_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698