Commit 1e6e9e83 authored by sdy's avatar sdy Committed by Commit bot

Make the edge where BackgroundGradientView draws a divider selectable.

…and remove the duplicate divider drawing in DownloadShelfView.

BUG=589943

Review-Url: https://codereview.chromium.org/2336463002
Cr-Commit-Position: refs/heads/master@{#418641}
parent 19adc908
......@@ -11,14 +11,14 @@
// A custom view that draws a 'standard' background gradient.
// Base class for other Chromium views.
@interface BackgroundGradientView : NSView<ThemedWindowDrawing> {
@private
BOOL showsDivider_;
}
@interface BackgroundGradientView : NSView<ThemedWindowDrawing>
// Controls whether the bar draws a dividing line at the bottom.
// Controls whether the bar draws a dividing line.
@property(nonatomic, assign) BOOL showsDivider;
// Controls where the bar draws a dividing line.
@property(nonatomic, assign) NSRectEdge dividerEdge;
// The color used for the bottom stroke. Public so subclasses can use.
- (NSColor*)strokeColor;
......
......@@ -12,14 +12,10 @@
#import "ui/base/cocoa/nsview_additions.h"
#include "ui/base/material_design/material_design_controller.h"
@interface BackgroundGradientView (Private)
- (void)commonInit;
- (NSColor*)backgroundImageColor;
@end
@implementation BackgroundGradientView
@synthesize showsDivider = showsDivider_;
@synthesize dividerEdge = dividerEdge_;
- (id)initWithFrame:(NSRect)frameRect {
if ((self = [super initWithFrame:frameRect])) {
......@@ -37,6 +33,7 @@
- (void)commonInit {
showsDivider_ = YES;
dividerEdge_ = NSMinYEdge;
}
- (void)setShowsDivider:(BOOL)show {
......@@ -46,6 +43,13 @@
[self setNeedsDisplay:YES];
}
- (void)setDividerEdge:(NSRectEdge)dividerEdge {
if (dividerEdge_ == dividerEdge)
return;
dividerEdge_ = dividerEdge;
[self setNeedsDisplay:YES];
}
- (NSPoint)patternPhase {
return [[self window]
themeImagePositionForAlignment:THEME_IMAGE_ALIGN_WITH_TAB_STRIP];
......@@ -68,10 +72,10 @@
NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver);
if (showsDivider_) {
// Draw bottom stroke
// Draw stroke
NSRect borderRect, contentRect;
NSDivideRect([self bounds], &borderRect, &contentRect, [self cr_lineWidth],
NSMinYEdge);
dividerEdge_);
if (NSIntersectsRect(borderRect, dirtyRect)) {
[[self strokeColor] set];
NSRectFillUsingOperation(NSIntersectionRect(borderRect, dirtyRect),
......
......@@ -16,7 +16,7 @@
// For programmatic instantiations in unit tests.
- (id)initWithFrame:(NSRect)frameRect {
if ((self = [super initWithFrame:frameRect])) {
[self setShowsDivider:NO];
self.dividerEdge = NSMaxYEdge;
}
return self;
}
......@@ -24,26 +24,11 @@
// For nib instantiations in production.
- (id)initWithCoder:(NSCoder*)decoder {
if ((self = [super initWithCoder:decoder])) {
[self setShowsDivider:NO];
self.dividerEdge = NSMaxYEdge;
}
return self;
}
- (NSColor*)strokeColor {
const ui::ThemeProvider* themeProvider = [[self window] themeProvider];
if (!themeProvider) {
return [NSColor blackColor];
}
if (!ui::MaterialDesignController::IsModeMaterial()) {
BOOL isActive = [[self window] isMainWindow];
return themeProvider->GetNSColor(
isActive ? ThemeProperties::COLOR_TOOLBAR_STROKE :
ThemeProperties::COLOR_TOOLBAR_STROKE_INACTIVE);
}
return themeProvider->GetNSColor(
ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR);
}
- (NSPoint)patternPhase {
// We want our backgrounds for the shelf to be phased from the upper
// left hand corner of the view. Offset it by tab height so that the
......@@ -55,17 +40,10 @@
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// Draw top stroke
// Draw the top highlight
NSRect borderRect, contentRect;
NSDivideRect([self bounds], &borderRect, &contentRect, [self cr_lineWidth],
NSMaxYEdge);
if (NSIntersectsRect(borderRect, dirtyRect)) {
[[self strokeColor] set];
NSRectFillUsingOperation(NSIntersectionRect(borderRect, dirtyRect),
NSCompositeSourceOver);
}
// Draw the top highlight
borderRect.origin.y -= [self cr_lineWidth];
if (NSIntersectsRect(borderRect, dirtyRect)) {
const ui::ThemeProvider* themeProvider = [[self window] themeProvider];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment