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

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

Issue 2200303004: [Mac][Material Design] Adjust bookmark spacing and folder menu drawing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests, changes for icon-only items. Created 4 years, 4 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
« no previous file with comments | « chrome/browser/ui/cocoa/gradient_button_cell.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/gradient_button_cell.mm
diff --git a/chrome/browser/ui/cocoa/gradient_button_cell.mm b/chrome/browser/ui/cocoa/gradient_button_cell.mm
index 0709ad34d03dbc63391384f4184ceae20ff05acc..7a57305914157e6932af1b335c136a0ee5e7eefb 100644
--- a/chrome/browser/ui/cocoa/gradient_button_cell.mm
+++ b/chrome/browser/ui/cocoa/gradient_button_cell.mm
@@ -208,7 +208,7 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
if (animated) {
// In Material Design, if the button is already fully on, don't pulse it
// on again if the mouse is within its bounds.
- if ([self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback &&
+ if ([self tag] == [self isMaterialDesignButtonType] &&
isMouseInside_ && pulseState_ == gradient_button_cell::kPulsedOn) {
return;
}
@@ -327,7 +327,7 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
}
- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView {
- if ([self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback) {
+ if ([self isMaterialDesignButtonType]) {
// The user has just clicked down in the button. In Material Design, set the
// pulsed (hover) state to off now so that if the user keeps the mouse held
// down while dragging it out of the button's bounds, the button will draw
@@ -370,7 +370,7 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
defaultGradient:(NSGradient*)defaultGradient {
// For Material Design, draw a solid rounded rect behind the button, based on
// the hover and pressed states.
- if ([self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback) {
+ if ([self isMaterialDesignButtonType]) {
const CGFloat kEightPercentAlpha = 0.08;
const CGFloat kFourPercentAlpha = 0.04;
@@ -517,7 +517,7 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
NSRect drawFrame = NSZeroRect;
NSRect innerFrame = NSZeroRect;
CGFloat cornerRadius = 2;
- if ([self tag] != kMaterialStandardButtonTypeWithLimitedClickFeedback) {
+ if (![self isMaterialDesignButtonType]) {
drawFrame = NSInsetRect(cellFrame, 1.5 * kLineWidth, 1.5 * kLineWidth);
innerFrame = NSInsetRect(cellFrame, kLineWidth, kLineWidth);
cornerRadius = 3;
@@ -557,9 +557,13 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
drawFrame.origin.y +=
[self hoverBackgroundVerticalOffsetInControlView:controlView];
- *returnInnerPath = [NSBezierPath bezierPathWithRoundedRect:drawFrame
- xRadius:cornerRadius
- yRadius:cornerRadius];
+ if ([self tag] == kMaterialMenuButtonTypeWithLimitedClickFeedback) {
+ *returnInnerPath = [NSBezierPath bezierPathWithRect:drawFrame];
+ } else {
+ *returnInnerPath = [NSBezierPath bezierPathWithRoundedRect:drawFrame
+ xRadius:cornerRadius
+ yRadius:cornerRadius];
+ }
[*returnInnerPath setLineWidth:kLineWidth];
}
if (returnClipPath) {
@@ -595,7 +599,7 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
// actually a highlight, which should be drawn if
// |showsBorderOnlyWhileMouseInside| is true.
BOOL hasMaterialHighlight =
- [self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback &&
+ [self isMaterialDesignButtonType] &&
![self showsBorderOnlyWhileMouseInside] &&
enabled;
if (([self isBordered] && ![self showsBorderOnlyWhileMouseInside]) ||
@@ -709,6 +713,11 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
return 0.0;
}
+- (BOOL)isMaterialDesignButtonType {
+ return [self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback ||
+ [self tag] == kMaterialMenuButtonTypeWithLimitedClickFeedback;
+}
+
// Overriden from NSButtonCell so we can display a nice fadeout effect for
// button titles that overflow.
// This method is copied in the most part from GTMFadeTruncatingTextFieldCell,
@@ -725,8 +734,7 @@ static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
// Empirically, Cocoa will draw an extra 2 pixels past NSWidth(cellFrame)
// before it clips the text.
const CGFloat kOverflowBeforeClip = 2;
- BOOL isModeMaterial =
- [self tag] == kMaterialStandardButtonTypeWithLimitedClickFeedback;
+ BOOL isModeMaterial = [self isMaterialDesignButtonType];
// For Material Design we don't want to clip the text. For all other button
// cell modes, we do.
BOOL shouldClipTheTitle = !isModeMaterial;
« no previous file with comments | « chrome/browser/ui/cocoa/gradient_button_cell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698