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

Unified Diff: chrome/browser/ui/cocoa/background_gradient_view.mm

Issue 2336463002: Make the edge where BackgroundGradientView draws a divider selectable. (Closed)
Patch Set: Created 4 years, 3 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/ui/cocoa/background_gradient_view.mm
diff --git a/chrome/browser/ui/cocoa/background_gradient_view.mm b/chrome/browser/ui/cocoa/background_gradient_view.mm
index 6458533dbc51ed8db54c04fa93f229d46d37d96d..e0ee183f5c16c7243492e2f94fb0d6e4d95aabf5 100644
--- a/chrome/browser/ui/cocoa/background_gradient_view.mm
+++ b/chrome/browser/ui/cocoa/background_gradient_view.mm
@@ -12,31 +12,16 @@
#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 divider = divider_;
@synthesize showsDivider = showsDivider_;
-- (id)initWithFrame:(NSRect)frameRect {
- if ((self = [super initWithFrame:frameRect])) {
- [self commonInit];
- }
- return self;
-}
-
-- (id)initWithCoder:(NSCoder*)decoder {
- if ((self = [super initWithCoder:decoder])) {
- [self commonInit];
- }
- return self;
-}
-
-- (void)commonInit {
- showsDivider_ = YES;
Nico 2016/09/12 13:45:55 This used to default to divider-on, now it default
Sidney San Martín 2016/09/14 17:46:59 Fixed, thanks.
+- (void)setDivider:(BackgroundGradientViewDivider)divider {
+ if (divider_ == divider)
+ return;
+ divider_ = divider;
+ [self setNeedsDisplay:YES];
}
- (void)setShowsDivider:(BOOL)show {
@@ -68,10 +53,16 @@
NSRectFillUsingOperation(dirtyRect, NSCompositeSourceOver);
if (showsDivider_) {
- // Draw bottom stroke
- NSRect borderRect, contentRect;
- NSDivideRect([self bounds], &borderRect, &contentRect, [self cr_lineWidth],
- NSMinYEdge);
+ CGFloat lineWidth = [self cr_lineWidth];
+ NSRect borderRect = NSMakeRect(0, 0, self.bounds.size.width, lineWidth);
+
+ switch (divider_) {
+ case BackgroundGradientViewDivider::Bottom:
+ break;
+ case BackgroundGradientViewDivider::Top:
+ borderRect.origin.y = self.bounds.size.height - lineWidth;
+ break;
+ }
Nico 2016/09/12 13:45:55 These 7 lines are shorter as if (divider_ == Ba
Sidney San Martín 2016/09/14 17:46:59 I think I had an incomplete understanding of NSDiv
if (NSIntersectsRect(borderRect, dirtyRect)) {
[[self strokeColor] set];
NSRectFillUsingOperation(NSIntersectionRect(borderRect, dirtyRect),

Powered by Google App Engine
This is Rietveld 408576698