blob: 6af8fbb1989ae2615bb0b36de634a3be142978e5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/cocoa/infobar_gradient_view.h"
#import "chrome/browser/browser_theme_provider.h"
#import "chrome/browser/cocoa/themed_window.h"
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 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 {
ThemeProvider* themeProvider = [[self window] themeProvider];
if (!themeProvider)
return [NSColor blackColor];
BOOL active = [[self window] isMainWindow];
return themeProvider->GetNSColor(
active ? BrowserThemeProvider::COLOR_TOOLBAR_STROKE :
BrowserThemeProvider::COLOR_TOOLBAR_STROKE_INACTIVE,
true);
}
- (void)drawRect:(NSRect)rect {
[gradient_ drawInRect:[self bounds] angle:270];
// Draw bottom stroke
[[self strokeColor] set];
NSRect borderRect, contentRect;
NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMinYEdge);
NSRectFillUsingOperation(borderRect, NSCompositeSourceOver);
}
- (BOOL)mouseDownCanMoveWindow {
return NO;
}
// This view is intentionally not opaque because it overlaps with the findbar.
- (BOOL)accessibilityIsIgnored {
return NO;
}
- (id)accessibilityAttributeValue:(NSString*)attribute {
if ([attribute isEqual:NSAccessibilityRoleAttribute])
return NSAccessibilityGroupRole;
return [super accessibilityAttributeValue:attribute];
}
@end
|