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

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

Issue 6621056: mac: UI tweaks to tab overview mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 9 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/tabpose_window.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/tabpose_window.mm
diff --git a/chrome/browser/ui/cocoa/tabpose_window.mm b/chrome/browser/ui/cocoa/tabpose_window.mm
index fa807305655f45d9f4d291ea961e374f940be6b1..8a455de805882ab14a2812177978465861765354 100644
--- a/chrome/browser/ui/cocoa/tabpose_window.mm
+++ b/chrome/browser/ui/cocoa/tabpose_window.mm
@@ -37,7 +37,11 @@
#include "ui/gfx/image.h"
#include "ui/gfx/scoped_cg_context_state_mac.h"
-const int kTopGradientHeight = 15;
+const int kBottomGradientHeight = 50;
viettrungluu 2011/03/08 01:33:40 You really should have some comment about what the
viettrungluu 2011/03/08 01:33:40 Why not a CGFloat?
Nico 2011/03/08 01:47:02 Done. (I maintain that a variable name is a valid
+
+const CGFloat kTopGray = 0.77;
+const CGFloat kCentralGray = 0.6;
+const CGFloat kBottomGray = 0.5;
NSString* const kAnimationIdKey = @"AnimationId";
NSString* const kAnimationIdFadeIn = @"FadeIn";
@@ -49,20 +53,32 @@ const CGFloat kObserverChangeAnimationDuration = 0.25; // In seconds.
const CGFloat kSelectionInset = 5;
// CAGradientLayer is 10.6-only -- roll our own.
-@interface DarkGradientLayer : CALayer
+@interface GrayGradientLayer : CALayer {
+ CGFloat startGray_;
viettrungluu 2011/03/08 01:33:40 @private?
Nico 2011/03/08 01:47:02 Done.
+ CGFloat endGray_;
+}
+- (id)initWithStartGray:(CGFloat)startGray endGray:(CGFloat)endGray;
- (void)drawInContext:(CGContextRef)context;
@end
-@implementation DarkGradientLayer
+@implementation GrayGradientLayer
+- (id)initWithStartGray:(CGFloat)startGray endGray:(CGFloat)endGray {
+ if ((self = [super init])) {
+ startGray_ = startGray;
+ endGray_ = endGray;
+ }
+ return self;
+}
+
- (void)drawInContext:(CGContextRef)context {
base::mac::ScopedCFTypeRef<CGColorSpaceRef> grayColorSpace(
CGColorSpaceCreateWithName(kCGColorSpaceGenericGray));
- CGFloat grays[] = { 0.277, 1.0, 0.39, 1.0 };
+ CGFloat grays[] = { startGray_, 1.0, endGray_, 1.0 };
CGFloat locations[] = { 0, 1 };
base::mac::ScopedCFTypeRef<CGGradientRef> gradient(
CGGradientCreateWithColorComponents(
grayColorSpace.get(), grays, locations, arraysize(locations)));
- CGPoint topLeft = CGPointMake(0.0, kTopGradientHeight);
+ CGPoint topLeft = CGPointMake(0.0, self.bounds.size.height);
viettrungluu 2011/03/08 01:33:40 NSHeight()?
viettrungluu 2011/03/08 01:44:58 Errr, never mind on that.
Nico 2011/03/08 01:47:02 NSHeight still doesn't work with CGRects
CGContextDrawLinearGradient(context, gradient.get(), topLeft, CGPointZero, 0);
}
@end
@@ -1117,7 +1133,7 @@ void AnimateCALayerOpacityFromTo(
{
ScopedCAActionDisabler disabler;
// Background layer -- the visible part of the window.
- gray_.reset(CGColorCreateGenericGray(0.39, 1.0));
+ gray_.reset(CGColorCreateGenericGray(kCentralGray, 1.0));
bgLayer_ = [CALayer layer];
bgLayer_.backgroundColor = gray_;
bgLayer_.frame = NSRectToCGRect(containingRect_);
@@ -1133,16 +1149,31 @@ void AnimateCALayerOpacityFromTo(
selectionHighlight_.hidden = YES;
[bgLayer_ addSublayer:selectionHighlight_];
- // Top gradient.
- CALayer* gradientLayer = [DarkGradientLayer layer];
+ // Bottom gradient.
+ CALayer* gradientLayer = [[[GrayGradientLayer alloc]
+ initWithStartGray:kCentralGray endGray:kBottomGray] autorelease];
gradientLayer.frame = CGRectMake(
0,
- NSHeight(containingRect_) - kTopGradientHeight,
+ 0,
NSWidth(containingRect_),
- kTopGradientHeight);
+ kBottomGradientHeight);
[gradientLayer setNeedsDisplay]; // Draw once.
[bgLayer_ addSublayer:gradientLayer];
}
+ // Top gradient (fades in).
+ CGFloat toolbarHeight = NSHeight([self frame]) - NSHeight(containingRect_);
+ topGradient_ = [[[GrayGradientLayer alloc]
+ initWithStartGray:kTopGray endGray:kCentralGray] autorelease];
+ topGradient_.frame = CGRectMake(
+ 0,
+ NSHeight([self frame]) - toolbarHeight,
+ NSWidth(containingRect_),
+ toolbarHeight);
+ [topGradient_ setNeedsDisplay]; // Draw once.
+ [rootLayer_ addSublayer:topGradient_];
+ NSTimeInterval interval =
+ kDefaultAnimationDuration * (slomo ? kSlomoFactor : 1);
+ AnimateCALayerOpacityFromTo(topGradient_, 0, 1, interval);
// Layers for the tab thumbnails.
tileSet_->Build(tabStripModel_);
@@ -1400,6 +1431,7 @@ void AnimateCALayerOpacityFromTo(
state_ = tabpose::kFadingOut;
[self setAcceptsMouseMovedEvents:NO];
viettrungluu 2011/03/08 01:33:40 wha?
+
// Select chosen tab.
if (tileSet_->selected_index() < tabStripModel_->count()) {
tabStripModel_->SelectTabContentsAt(tileSet_->selected_index(),
@@ -1429,6 +1461,7 @@ void AnimateCALayerOpacityFromTo(
ScopedCAActionSetDuration durationSetter(duration);
for (int i = 0; i < tabStripModel_->count(); ++i)
[self fadeAwayTileAtIndex:i];
+ AnimateCALayerOpacityFromTo(topGradient_, 1, 0, duration);
}
- (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished {
« no previous file with comments | « chrome/browser/ui/cocoa/tabpose_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698