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

Side by Side Diff: chrome/browser/views/tabs/side_tab.cc

Issue 2821011: Removes phantom tabs. (Closed)
Patch Set: Created 10 years, 6 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
« no previous file with comments | « chrome/browser/views/tabs/dragged_tab_controller.cc ('k') | chrome/browser/views/tabs/tab.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/views/tabs/side_tab.h" 5 #include "chrome/browser/views/tabs/side_tab.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "app/theme_provider.h" 8 #include "app/theme_provider.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "gfx/canvas.h" 11 #include "gfx/canvas.h"
12 #include "gfx/favicon_size.h" 12 #include "gfx/favicon_size.h"
13 #include "gfx/path.h" 13 #include "gfx/path.h"
14 #include "gfx/skia_util.h" 14 #include "gfx/skia_util.h"
15 #include "grit/app_resources.h" 15 #include "grit/app_resources.h"
16 #include "views/controls/button/image_button.h" 16 #include "views/controls/button/image_button.h"
17 17
18 namespace { 18 namespace {
19 const int kVerticalTabHeight = 27; 19 const int kVerticalTabHeight = 27;
20 const int kTitleCloseSpacing = 4; 20 const int kTitleCloseSpacing = 4;
21 const SkScalar kRoundRectRadius = 4; 21 const SkScalar kRoundRectRadius = 4;
22 const SkColor kTabBackgroundColor = SK_ColorWHITE; 22 const SkColor kTabBackgroundColor = SK_ColorWHITE;
23 const SkColor kTextColor = SK_ColorBLACK; 23 const SkColor kTextColor = SK_ColorBLACK;
24 const SkColor kPhantomTextColor = SK_ColorGRAY;
25 24
26 // Padding between the edge and the icon. 25 // Padding between the edge and the icon.
27 const int kIconLeftPadding = 5; 26 const int kIconLeftPadding = 5;
28 27
29 // Location the title starts at. 28 // Location the title starts at.
30 const int kTitleX = kIconLeftPadding + kFavIconSize + 5; 29 const int kTitleX = kIconLeftPadding + kFavIconSize + 5;
31
32 // Alpha value phantom tab icons are rendered at.
33 const int kPhantomTabIconAlpha = 100;
34 }; 30 };
35 31
36 //////////////////////////////////////////////////////////////////////////////// 32 ////////////////////////////////////////////////////////////////////////////////
37 // SideTab, public: 33 // SideTab, public:
38 34
39 SideTab::SideTab(TabController* controller) 35 SideTab::SideTab(TabController* controller)
40 : BaseTab(controller, false) { 36 : BaseTab(controller, false) {
41 SetCloseButtonColor(kTextColor); 37 SetCloseButtonColor(kTextColor);
42 } 38 }
43 39
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 if (ShouldPaintHighlight()) { 84 if (ShouldPaintHighlight()) {
89 SkPaint paint; 85 SkPaint paint;
90 paint.setColor(kTabBackgroundColor); 86 paint.setColor(kTabBackgroundColor);
91 paint.setAntiAlias(true); 87 paint.setAntiAlias(true);
92 SkRect border_rect = { SkIntToScalar(0), SkIntToScalar(0), 88 SkRect border_rect = { SkIntToScalar(0), SkIntToScalar(0),
93 SkIntToScalar(width()), SkIntToScalar(height()) }; 89 SkIntToScalar(width()), SkIntToScalar(height()) };
94 canvas->drawRoundRect(border_rect, SkIntToScalar(kRoundRectRadius), 90 canvas->drawRoundRect(border_rect, SkIntToScalar(kRoundRectRadius),
95 SkIntToScalar(kRoundRectRadius), paint); 91 SkIntToScalar(kRoundRectRadius), paint);
96 } 92 }
97 93
98 if (ShouldShowIcon()) { 94 if (ShouldShowIcon())
99 if (data().phantom) { 95 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
100 SkRect bounds;
101 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height()));
102 canvas->saveLayerAlpha(&bounds, kPhantomTabIconAlpha,
103 SkCanvas::kARGB_ClipLayer_SaveFlag);
104 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
105 canvas->restore();
106 } else {
107 PaintIcon(canvas, icon_bounds_.x(), icon_bounds_.y());
108 }
109 }
110 96
111 PaintTitle(canvas, data().phantom ? kPhantomTextColor : kTextColor); 97 PaintTitle(canvas, kTextColor);
112 } 98 }
113 99
114 gfx::Size SideTab::GetPreferredSize() { 100 gfx::Size SideTab::GetPreferredSize() {
115 return gfx::Size(0, GetPreferredHeight()); 101 return gfx::Size(0, GetPreferredHeight());
116 } 102 }
117 103
118 bool SideTab::ShouldPaintHighlight() const { 104 bool SideTab::ShouldPaintHighlight() const {
119 return IsSelected() || !controller(); 105 return IsSelected() || !controller();
120 } 106 }
121 107
122 bool SideTab::ShouldShowIcon() const { 108 bool SideTab::ShouldShowIcon() const {
123 return data().mini || data().show_icon; 109 return data().mini || data().show_icon;
124 } 110 }
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/dragged_tab_controller.cc ('k') | chrome/browser/views/tabs/tab.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698