summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 18:50:31 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-31 18:50:31 +0000
commitdf1480cfdd3413bddb628726ebd4e65374baaec5 (patch)
treee43a582bb058d7040fdb95d4503680a4964b33c1
parent8a5e980b4daa372c315ab25952928499c9a2002e (diff)
downloadchromium_src-df1480cfdd3413bddb628726ebd4e65374baaec5.zip
chromium_src-df1480cfdd3413bddb628726ebd4e65374baaec5.tar.gz
chromium_src-df1480cfdd3413bddb628726ebd4e65374baaec5.tar.bz2
[Mac] More tweaks to the Lion gesture UI.
* Fade the overlay out before navigating. * When the gesture is "committed," grow the overlay a little and use 75% opacity. * Track the opacity from [0.25, 0.65] before committing. * Increase the fade duration. BUG=93185 TEST=visual Review URL: https://chromiumcodereview.appspot.com/9307001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119927 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm14
-rw-r--r--chrome/browser/ui/cocoa/history_overlay_controller.mm38
2 files changed, 35 insertions, 17 deletions
diff --git a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm
index 792508a..b87b911 100644
--- a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm
+++ b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegate.mm
@@ -257,22 +257,26 @@ class SpellCheckRenderViewObserver : public content::RenderViewHostObserver {
return;
}
+ BOOL ended = phase == NSEventPhaseEnded;
+
+ // Dismiss the panel before navigation for immediate visual feedback.
+ [historyOverlay setProgress:gestureAmount];
+ if (ended)
+ [historyOverlay dismiss];
+
// |gestureAmount| obeys -[NSEvent isDirectionInvertedFromDevice]
// automatically.
Browser* browser = BrowserList::FindBrowserWithWindow(
historyOverlay.view.window);
- if (phase == NSEventPhaseEnded && browser) {
+ if (ended && browser) {
if (goForward)
browser->GoForward(CURRENT_TAB);
else
browser->GoBack(CURRENT_TAB);
}
- [historyOverlay setProgress:gestureAmount];
- if (isComplete) {
- [historyOverlay dismiss];
+ if (isComplete)
[historyOverlay release];
- }
}];
return YES;
}
diff --git a/chrome/browser/ui/cocoa/history_overlay_controller.mm b/chrome/browser/ui/cocoa/history_overlay_controller.mm
index d256452..2620aa8 100644
--- a/chrome/browser/ui/cocoa/history_overlay_controller.mm
+++ b/chrome/browser/ui/cocoa/history_overlay_controller.mm
@@ -24,6 +24,10 @@ const CGFloat kShieldWidth = kShieldRadius * 2;
// The height of the shield.
const CGFloat kShieldHeight = 140;
+// Additional height that is added to kShieldHeight when the gesture is
+// considered complete.
+const CGFloat kShieldHeightCompletionAdjust = 10;
+
// The amount of |gestureAmount| at which AppKit considers the gesture
// completed. This was derived more via art than science.
const CGFloat kGestureCompleteProgress = 0.3;
@@ -34,16 +38,16 @@ const CGFloat kGestureCompleteProgress = 0.3;
@interface HistoryOverlayView : NSView {
@private
HistoryOverlayMode mode_;
- CGFloat progress_;
+ CGFloat shieldAlpha_;
}
-@property(nonatomic) CGFloat progress;
+@property(nonatomic) CGFloat shieldAlpha;
- (id)initWithMode:(HistoryOverlayMode)mode
image:(NSImage*)image;
@end
@implementation HistoryOverlayView
-@synthesize progress = progress_;
+@synthesize shieldAlpha = shieldAlpha_;
- (id)initWithMode:(HistoryOverlayMode)mode
image:(NSImage*)image {
@@ -60,18 +64,15 @@ const CGFloat kGestureCompleteProgress = 0.3;
scoped_nsobject<NSImageView> imageView(
[[NSImageView alloc] initWithFrame:arrowRect]);
[imageView setImage:image];
+ [imageView setAutoresizingMask:NSViewMinYMargin | NSViewMaxYMargin];
[self addSubview:imageView];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
- NSRect ovalRect = NSMakeRect(0, 0, kShieldWidth, kShieldHeight);
- NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:ovalRect];
- NSColor* fillColor =
- // Clamp the minimum ligtness to be 0.666.
- [NSColor colorWithCalibratedWhite:std::min(2.0/3.0 - progress_, 2.0/3.0)
- alpha:0.85];
+ NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:self.bounds];
+ NSColor* fillColor = [NSColor colorWithCalibratedWhite:0 alpha:shieldAlpha_];
[fillColor set];
[path fill];
}
@@ -108,9 +109,22 @@ const CGFloat kGestureCompleteProgress = 0.3;
// being completed.
gestureAmount = std::abs(gestureAmount) / kGestureCompleteProgress;
+ // When tracking the gesture, the height is constant and the alpha value
+ // changes from [0.25, 0.65].
+ CGFloat height = kShieldHeight;
+ CGFloat shieldAlpha = std::min(0.65f, std::max(gestureAmount, 0.25f));
+
+ // When the gesture is very likely to be completed (90% in this case), grow
+ // the semicircle's height and lock the alpha to 0.75.
+ if (gestureAmount > 0.9) {
+ height += kShieldHeightCompletionAdjust;
+ shieldAlpha = 0.75;
+ }
+
// Compute the new position based on the progress.
NSRect frame = self.view.frame;
- frame.origin.y = (NSHeight(parentFrame) / 2) - (kShieldHeight / 2);
+ frame.size.height = height;
+ frame.origin.y = (NSHeight(parentFrame) / 2) - (height / 2);
CGFloat width = std::min(kShieldRadius * gestureAmount, kShieldRadius);
if (mode_ == kHistoryOverlayModeForward)
@@ -119,7 +133,7 @@ const CGFloat kGestureCompleteProgress = 0.3;
frame.origin.x = NSMinX(parentFrame) - kShieldWidth + width;
self.view.frame = frame;
- [contentView_ setProgress:gestureAmount];
+ [contentView_ setShieldAlpha:shieldAlpha];
[contentView_ setNeedsDisplay:YES];
}
@@ -132,7 +146,7 @@ const CGFloat kGestureCompleteProgress = 0.3;
}
- (void)dismiss {
- const CGFloat kFadeOutDurationSeconds = 0.2;
+ const CGFloat kFadeOutDurationSeconds = 0.4;
NSView* overlay = self.view;