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

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

Issue 2407343002: cocoa browser: fix meaning of "continuous pulsing" (Closed)
Patch Set: setIsContinuousPulsing -> setPulseIsStuckOn Created 4 years, 2 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/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 387770be62f9c927b0ed8d3545989ebaaa5c2d45..4827cef0a613467092a3308d79a75041ec3da203 100644
--- a/chrome/browser/ui/cocoa/gradient_button_cell.mm
+++ b/chrome/browser/ui/cocoa/gradient_button_cell.mm
@@ -50,8 +50,6 @@ - (void)updateTrackingAreas;
// now so we don't suck. -jrg
static const NSTimeInterval kAnimationHideDuration = 0.4;
-static const NSTimeInterval kAnimationContinuousCycleDuration = 0.4;
-
@implementation GradientButtonCell
@synthesize hoverAlpha = hoverAlpha_;
@@ -83,8 +81,7 @@ - (void)dealloc {
// Return YES if we are pulsing (towards another state or continuously).
- (BOOL)pulsing {
if ((pulseState_ == gradient_button_cell::kPulsingOn) ||
- (pulseState_ == gradient_button_cell::kPulsingOff) ||
- (pulseState_ == gradient_button_cell::kPulsingContinuous))
+ (pulseState_ == gradient_button_cell::kPulsingOff))
return YES;
return NO;
}
@@ -112,16 +109,8 @@ - (void)performOnePulseStep {
return;
}
break;
- case gradient_button_cell::kPulsingContinuous:
- opacity += elapsed / kAnimationContinuousCycleDuration * pulseMultiplier_;
- if (opacity > 1.0) {
- opacity = 1.0;
- pulseMultiplier_ *= -1.0;
- } else if (opacity < 0.0) {
- opacity = 0.0;
- pulseMultiplier_ *= -1.0;
- }
- outerStrokeAlphaMult_ = opacity;
+ case gradient_button_cell::kPulsingStuckOn:
+ outerStrokeAlphaMult_ = 1.0;
break;
default:
NOTREACHED() << "unknown pulse state";
@@ -147,7 +136,6 @@ - (void)performOnePulseStep {
// state change.
- (void)setPulseState:(gradient_button_cell::PulseState)pstate {
pulseState_ = pstate;
- pulseMultiplier_ = 0.0;
[NSObject cancelPreviousPerformRequestsWithTarget:self];
lastHoverUpdate_ = [NSDate timeIntervalSinceReferenceDate];
@@ -167,10 +155,9 @@ - (void)setPulseState:(gradient_button_cell::PulseState)pstate {
0.0 : 1.0)];
[self performOnePulseStep];
break;
- case gradient_button_cell::kPulsingContinuous:
+ case gradient_button_cell::kPulsingStuckOn:
// Semantics of continuous pulsing are that we pulse independent
// of mouse position.
- pulseMultiplier_ = 1.0;
[self performOnePulseStep];
break;
default:
@@ -183,19 +170,19 @@ - (void)safelyStopPulsing {
[NSObject cancelPreviousPerformRequestsWithTarget:self];
}
-- (void)setIsContinuousPulsing:(BOOL)continuous {
- if (!continuous && pulseState_ != gradient_button_cell::kPulsingContinuous)
+- (void)setPulseIsStuckOn:(BOOL)on {
+ if (!on && pulseState_ != gradient_button_cell::kPulsingStuckOn)
return;
- if (continuous) {
- [self setPulseState:gradient_button_cell::kPulsingContinuous];
+ if (on) {
+ [self setPulseState:gradient_button_cell::kPulsingStuckOn];
} else {
[self setPulseState:(isMouseInside_ ? gradient_button_cell::kPulsedOn :
gradient_button_cell::kPulsedOff)];
}
}
-- (BOOL)isContinuousPulsing {
- return (pulseState_ == gradient_button_cell::kPulsingContinuous) ?
+- (BOOL)isPulseStuckOn {
+ return (pulseState_ == gradient_button_cell::kPulsingStuckOn) ?
YES : NO;
}
@@ -204,7 +191,7 @@ - (BOOL)isContinuousPulsing {
// reflect our new state.
- (void)setMouseInside:(BOOL)flag animate:(BOOL)animated {
isMouseInside_ = flag;
- if (pulseState_ != gradient_button_cell::kPulsingContinuous) {
+ if (pulseState_ != gradient_button_cell::kPulsingStuckOn) {
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.
@@ -290,7 +277,6 @@ - (NSGradient*)gradientForHoverAlpha:(CGFloat)hoverAlpha
- (void)sharedInit {
shouldTheme_ = YES;
pulseState_ = gradient_button_cell::kPulsedOff;
- pulseMultiplier_ = 1.0;
outerStrokeAlphaMult_ = 1.0;
gradient_.reset([[self gradientForHoverAlpha:0.0 isThemed:NO] retain]);
}
@@ -603,11 +589,11 @@ - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
![self showsBorderOnlyWhileMouseInside] &&
enabled;
if (([self isBordered] && ![self showsBorderOnlyWhileMouseInside]) ||
- pressed || [self isMouseInside] || [self isContinuousPulsing] ||
+ pressed || [self isMouseInside] || [self isPulseStuckOn] ||
hasMaterialHighlight) {
// When pulsing we want the bookmark to stand out a little more.
BOOL showClickedGradient = pressed ||
- (pulseState_ == gradient_button_cell::kPulsingContinuous);
+ (pulseState_ == gradient_button_cell::kPulsingStuckOn);
BOOL showHighlightGradient = [self isHighlighted] || hasMaterialHighlight;
[self drawBorderAndFillForTheme:themeProvider
« no previous file with comments | « chrome/browser/ui/cocoa/gradient_button_cell.h ('k') | chrome/browser/ui/cocoa/gradient_button_cell_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698