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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tabpose_window.h" 5 #import "chrome/browser/ui/cocoa/tabpose_window.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 19 matching lines...) Expand all
30 #include "content/browser/renderer_host/render_view_host.h" 30 #include "content/browser/renderer_host/render_view_host.h"
31 #include "content/browser/tab_contents/tab_contents.h" 31 #include "content/browser/tab_contents/tab_contents.h"
32 #include "grit/app_resources.h" 32 #include "grit/app_resources.h"
33 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
34 #include "skia/ext/skia_utils_mac.h" 34 #include "skia/ext/skia_utils_mac.h"
35 #include "third_party/skia/include/utils/mac/SkCGUtils.h" 35 #include "third_party/skia/include/utils/mac/SkCGUtils.h"
36 #include "ui/base/resource/resource_bundle.h" 36 #include "ui/base/resource/resource_bundle.h"
37 #include "ui/gfx/image.h" 37 #include "ui/gfx/image.h"
38 #include "ui/gfx/scoped_cg_context_state_mac.h" 38 #include "ui/gfx/scoped_cg_context_state_mac.h"
39 39
40 const int kTopGradientHeight = 15; 40 const int kTopShadowGradientHeight = 15;
41 41
42 NSString* const kAnimationIdKey = @"AnimationId"; 42 NSString* const kAnimationIdKey = @"AnimationId";
43 NSString* const kAnimationIdFadeIn = @"FadeIn"; 43 NSString* const kAnimationIdFadeIn = @"FadeIn";
44 NSString* const kAnimationIdFadeOut = @"FadeOut"; 44 NSString* const kAnimationIdFadeOut = @"FadeOut";
45 45
46 const CGFloat kDefaultAnimationDuration = 0.25; // In seconds. 46 const CGFloat kDefaultAnimationDuration = 0.25; // In seconds.
47 const CGFloat kSlomoFactor = 4; 47 const CGFloat kSlomoFactor = 4;
48 const CGFloat kObserverChangeAnimationDuration = 0.25; // In seconds. 48 const CGFloat kObserverChangeAnimationDuration = 0.25; // In seconds.
49 const CGFloat kSelectionInset = 5; 49 const CGFloat kSelectionInset = 5;
50 50
51 // CAGradientLayer is 10.6-only -- roll our own. 51 // CAGradientLayer is 10.6-only -- roll our own.
52 @interface DarkGradientLayer : CALayer 52 @interface DarkGradientLayer : CALayer
53 - (void)drawInContext:(CGContextRef)context; 53 - (void)drawInContext:(CGContextRef)context;
54 @end 54 @end
55 55
56 @implementation DarkGradientLayer 56 @implementation DarkGradientLayer
57 - (void)drawInContext:(CGContextRef)context { 57 - (void)drawInContext:(CGContextRef)context {
58 base::mac::ScopedCFTypeRef<CGColorSpaceRef> grayColorSpace( 58 base::mac::ScopedCFTypeRef<CGColorSpaceRef> grayColorSpace(
59 CGColorSpaceCreateWithName(kCGColorSpaceGenericGray)); 59 CGColorSpaceCreateWithName(kCGColorSpaceGenericGray));
60 CGFloat grays[] = { 0.277, 1.0, 0.39, 1.0 }; 60 CGFloat grays[] = { 0.277, 1.0, 0.39, 1.0 };
61 CGFloat locations[] = { 0, 1 }; 61 CGFloat locations[] = { 0, 1 };
62 base::mac::ScopedCFTypeRef<CGGradientRef> gradient( 62 base::mac::ScopedCFTypeRef<CGGradientRef> gradient(
63 CGGradientCreateWithColorComponents( 63 CGGradientCreateWithColorComponents(
64 grayColorSpace.get(), grays, locations, arraysize(locations))); 64 grayColorSpace.get(), grays, locations, arraysize(locations)));
65 CGPoint topLeft = CGPointMake(0.0, kTopGradientHeight); 65 CGPoint topLeft = CGPointMake(0.0, self.bounds.size.height);
viettrungluu 2011/03/08 01:02:32 NSHeight?
66 CGContextDrawLinearGradient(context, gradient.get(), topLeft, CGPointZero, 0); 66 CGContextDrawLinearGradient(context, gradient.get(), topLeft, CGPointZero, 0);
67 } 67 }
68 @end 68 @end
69
70 // This is similar to DarkGradientLayer at the moment, but it will probably get
71 // differently rounded edges, so it's a separate class.
viettrungluu 2011/03/08 01:02:32 Should this be a TODO? Should there be a bug for t
72 @interface GrayLayer : CALayer
73 - (void)drawInContext:(CGContextRef)context;
74 @end
75
76 @implementation GrayLayer
77 - (void)drawInContext:(CGContextRef)context {
78 base::mac::ScopedCFTypeRef<CGColorSpaceRef> grayColorSpace(
79 CGColorSpaceCreateWithName(kCGColorSpaceGenericGray));
80 CGFloat grays[] = { 204/255.0, 0.0, 175/255.0, 0.8 , 145/255.0, 0.8};
81 CGFloat locations[] = { 0, 0.5, 1 };
82 base::mac::ScopedCFTypeRef<CGGradientRef> gradient(
83 CGGradientCreateWithColorComponents(
84 grayColorSpace.get(), grays, locations, arraysize(locations)));
85 CGPoint topLeft = CGPointMake(0.0, self.bounds.size.height);
86 CGContextDrawLinearGradient(context, gradient.get(), topLeft, CGPointZero, 0);
87 }
88 @end
69 89
70 namespace tabpose { 90 namespace tabpose {
71 class ThumbnailLoader; 91 class ThumbnailLoader;
72 } 92 }
73 93
74 // A CALayer that draws a thumbnail for a TabContents object. The layer tries 94 // A CALayer that draws a thumbnail for a TabContents object. The layer tries
75 // to draw the TabContents's backing store directly if possible, and requests 95 // to draw the TabContents's backing store directly if possible, and requests
76 // a thumbnail bitmap from the TabContents's renderer process if not. 96 // a thumbnail bitmap from the TabContents's renderer process if not.
77 @interface ThumbnailLayer : CALayer { 97 @interface ThumbnailLayer : CALayer {
78 // The TabContents the thumbnail is for. 98 // The TabContents the thumbnail is for.
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 1146
1127 // Selection highlight layer. 1147 // Selection highlight layer.
1128 darkBlue_.reset(CGColorCreateGenericRGB(0.25, 0.34, 0.86, 1.0)); 1148 darkBlue_.reset(CGColorCreateGenericRGB(0.25, 0.34, 0.86, 1.0));
1129 selectionHighlight_ = [CALayer layer]; 1149 selectionHighlight_ = [CALayer layer];
1130 selectionHighlight_.backgroundColor = darkBlue_; 1150 selectionHighlight_.backgroundColor = darkBlue_;
1131 selectionHighlight_.cornerRadius = 5.0; 1151 selectionHighlight_.cornerRadius = 5.0;
1132 selectionHighlight_.zPosition = -1; // Behind other layers. 1152 selectionHighlight_.zPosition = -1; // Behind other layers.
1133 selectionHighlight_.hidden = YES; 1153 selectionHighlight_.hidden = YES;
1134 [bgLayer_ addSublayer:selectionHighlight_]; 1154 [bgLayer_ addSublayer:selectionHighlight_];
1135 1155
1136 // Top gradient. 1156 // Top shadow gradient. Needs to paint below the thumbs, so this can't
1157 // be part of grayLayer.
1137 CALayer* gradientLayer = [DarkGradientLayer layer]; 1158 CALayer* gradientLayer = [DarkGradientLayer layer];
1138 gradientLayer.frame = CGRectMake( 1159 gradientLayer.frame = CGRectMake(
1139 0, 1160 0,
1140 NSHeight(containingRect_) - kTopGradientHeight, 1161 NSHeight(containingRect_) - kTopShadowGradientHeight,
1141 NSWidth(containingRect_), 1162 NSWidth(containingRect_),
1142 kTopGradientHeight); 1163 kTopShadowGradientHeight);
1143 [gradientLayer setNeedsDisplay]; // Draw once. 1164 [gradientLayer setNeedsDisplay]; // Draw once.
1144 [bgLayer_ addSublayer:gradientLayer]; 1165 [bgLayer_ addSublayer:gradientLayer];
1166
1167 // Top gray gradient.
1168 // bgLayer_ has to clip its children (for the thumbs), so this can't be
1169 // a child of bgLayer_.
1170 CGFloat toolbarHeight =
1171 NSHeight([[self contentView] bounds]) - NSHeight(containingRect_);
1172 CALayer* grayLayer = [GrayLayer layer];
1173 grayLayer.frame = CGRectMake(
1174 0,
1175 NSHeight([[self contentView] bounds]) - toolbarHeight,
1176 NSWidth(containingRect_),
1177 toolbarHeight);
1178 [grayLayer setNeedsDisplay]; // Draw once.
1179 [rootLayer_ addSublayer:grayLayer];
1145 } 1180 }
1146 1181
1147 // Layers for the tab thumbnails. 1182 // Layers for the tab thumbnails.
1148 tileSet_->Build(tabStripModel_); 1183 tileSet_->Build(tabStripModel_);
1149 tileSet_->Layout(containingRect_); 1184 tileSet_->Layout(containingRect_);
1150 allThumbnailLayers_.reset( 1185 allThumbnailLayers_.reset(
1151 [[NSMutableArray alloc] initWithCapacity:tabStripModel_->count()]); 1186 [[NSMutableArray alloc] initWithCapacity:tabStripModel_->count()]);
1152 allFaviconLayers_.reset( 1187 allFaviconLayers_.reset(
1153 [[NSMutableArray alloc] initWithCapacity:tabStripModel_->count()]); 1188 [[NSMutableArray alloc] initWithCapacity:tabStripModel_->count()]);
1154 allTitleLayers_.reset( 1189 allTitleLayers_.reset(
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 tile.set_tab_contents(contents->tab_contents()); 1692 tile.set_tab_contents(contents->tab_contents());
1658 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; 1693 ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index];
1659 [thumbLayer setTabContents:contents->tab_contents()]; 1694 [thumbLayer setTabContents:contents->tab_contents()];
1660 } 1695 }
1661 1696
1662 - (void)tabStripModelDeleted { 1697 - (void)tabStripModelDeleted {
1663 [self close]; 1698 [self close];
1664 } 1699 }
1665 1700
1666 @end 1701 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698