OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" | 5 #import "chrome/browser/ui/cocoa/history_overlay_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/image/image.h" | 10 #include "ui/gfx/image/image.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 | 105 |
106 - (void)setProgress:(CGFloat)gestureAmount { | 106 - (void)setProgress:(CGFloat)gestureAmount { |
107 NSRect parentFrame = [parent_ frame]; | 107 NSRect parentFrame = [parent_ frame]; |
108 // Scale the gesture amount so that the progress is indicative of the gesture | 108 // Scale the gesture amount so that the progress is indicative of the gesture |
109 // being completed. | 109 // being completed. |
110 gestureAmount = std::abs(gestureAmount) / kGestureCompleteProgress; | 110 gestureAmount = std::abs(gestureAmount) / kGestureCompleteProgress; |
111 | 111 |
112 // When tracking the gesture, the height is constant and the alpha value | 112 // When tracking the gesture, the height is constant and the alpha value |
113 // changes from [0.25, 0.65]. | 113 // changes from [0.25, 0.65]. |
114 CGFloat height = kShieldHeight; | 114 CGFloat height = kShieldHeight; |
115 CGFloat shieldAlpha = std::min(0.65f, std::max(gestureAmount, 0.25f)); | 115 CGFloat shieldAlpha = std::min(static_cast<CGFloat>(0.65f), |
Mark Mentovai
2012/08/20 13:25:58
Again.
| |
116 std::max(gestureAmount, | |
117 static_cast<CGFloat>(0.25f))); | |
116 | 118 |
117 // When the gesture is very likely to be completed (90% in this case), grow | 119 // When the gesture is very likely to be completed (90% in this case), grow |
118 // the semicircle's height and lock the alpha to 0.75. | 120 // the semicircle's height and lock the alpha to 0.75. |
119 if (gestureAmount > 0.9) { | 121 if (gestureAmount > 0.9) { |
120 height += kShieldHeightCompletionAdjust; | 122 height += kShieldHeightCompletionAdjust; |
121 shieldAlpha = 0.75; | 123 shieldAlpha = 0.75; |
122 } | 124 } |
123 | 125 |
124 // Compute the new position based on the progress. | 126 // Compute the new position based on the progress. |
125 NSRect frame = self.view.frame; | 127 NSRect frame = self.view.frame; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 [dictionary setObject:animation forKey:@"alphaValue"]; | 161 [dictionary setObject:animation forKey:@"alphaValue"]; |
160 [overlay setAnimations:dictionary]; | 162 [overlay setAnimations:dictionary]; |
161 [[overlay animator] setAlphaValue:0.0]; | 163 [[overlay animator] setAlphaValue:0.0]; |
162 } | 164 } |
163 | 165 |
164 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { | 166 - (void)animationDidStop:(CAAnimation*)theAnimation finished:(BOOL)finished { |
165 [self.view removeFromSuperview]; | 167 [self.view removeFromSuperview]; |
166 } | 168 } |
167 | 169 |
168 @end | 170 @end |
OLD | NEW |