summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/infobar_gradient_view.h11
-rw-r--r--chrome/browser/cocoa/infobar_gradient_view.mm46
2 files changed, 41 insertions, 16 deletions
diff --git a/chrome/browser/cocoa/infobar_gradient_view.h b/chrome/browser/cocoa/infobar_gradient_view.h
index 59d411d..f80650d 100644
--- a/chrome/browser/cocoa/infobar_gradient_view.h
+++ b/chrome/browser/cocoa/infobar_gradient_view.h
@@ -7,10 +7,17 @@
#import <Cocoa/Cocoa.h>
-// A custom view that draws the yellow background gradient for an infobar.
-
+// A custom view that draws the background gradient for an infobar.
+// The default is a yellow gradient, but a custom gradient can also be set.
@interface InfoBarGradientView : NSView {
+ @private
+ // The gradient to draw.
+ NSGradient* gradient_;
}
+
+// Set a custom gradient for the view.
+- (void)setGradient:(NSGradient*)gradient;
+
@end
#endif // CHROME_BROWSER_COCOA_INFOBAR_GRADIENT_VIEW_H_
diff --git a/chrome/browser/cocoa/infobar_gradient_view.mm b/chrome/browser/cocoa/infobar_gradient_view.mm
index cdd648b..a5422c5 100644
--- a/chrome/browser/cocoa/infobar_gradient_view.mm
+++ b/chrome/browser/cocoa/infobar_gradient_view.mm
@@ -11,26 +11,44 @@ const double kBackgroundColorBottom[3] =
{250.0 / 255.0, 230.0 / 255.0, 145.0 / 255.0};
@implementation InfoBarGradientView
+
+- (id)initWithFrame:(NSRect)frameRect {
+ if ((self = [super initWithFrame:frameRect])) {
+ 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];
+ gradient_ =
+ [[NSGradient alloc] initWithStartingColor:startingColor
+ endingColor:endingColor];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [gradient_ release];
+ [super dealloc];
+}
+
+- (void)setGradient:(NSGradient*)gradient {
+ [gradient retain];
+ [gradient_ release];
+ gradient_ = gradient;
+}
+
- (NSColor*)strokeColor {
return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar
state:[[self window] isKeyWindow]];
}
- (void)drawRect:(NSRect)rect {
- 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];
+ [gradient_ drawInRect:[self bounds] angle:270];
// Draw bottom stroke
[[self strokeColor] set];