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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 11567057: Improve immersive mode light bar painting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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) 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 #include "chrome/browser/ui/views/tabs/tab.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Max number of images to cache. This has to be at least two since rounding 237 // Max number of images to cache. This has to be at least two since rounding
238 // errors may lead to tabs in the same tabstrip having different sizes. 238 // errors may lead to tabs in the same tabstrip having different sizes.
239 const size_t kMaxImageCacheSize = 4; 239 const size_t kMaxImageCacheSize = 4;
240 240
241 // Height of the colored bar representing the favicon in immersive mode. 241 // Height of the colored bar representing the favicon in immersive mode.
242 const int kImmersiveBarHeight = 2; 242 const int kImmersiveBarHeight = 2;
243 243
244 // Distance between the favicon bar and the tab bar in immersive mode. 244 // Distance between the favicon bar and the tab bar in immersive mode.
245 const int kImmersiveBarSpacing = 2; 245 const int kImmersiveBarSpacing = 2;
246 246
247 // Color for active and inactive tabs in the immersive mode light strip. These
248 // should be similar to the color of the normal art assets for tabs.
249 const SkColor kImmersiveActiveTabColor = SkColorSetRGB(230, 230, 230);
250 const SkColor kImmersiveInactiveTabColor = SkColorSetRGB(184, 184, 184);
251
247 // Scale to resize the current favicon by when projecting. 252 // Scale to resize the current favicon by when projecting.
248 const double kProjectingFaviconResizeScale = 0.75; 253 const double kProjectingFaviconResizeScale = 0.75;
249 254
250 // Scale to resize the projection sheet glow by. 255 // Scale to resize the projection sheet glow by.
251 const double kProjectingGlowResizeScale = 2.0; 256 const double kProjectingGlowResizeScale = 2.0;
252 257
253 // Draws the icon image at the center of |bounds|. 258 // Draws the icon image at the center of |bounds|.
254 void DrawIconCenter(gfx::Canvas* canvas, 259 void DrawIconCenter(gfx::Canvas* canvas,
255 const gfx::ImageSkia& image, 260 const gfx::ImageSkia& image,
256 int image_offset, 261 int image_offset,
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 close_button_color_ = title_color; 1033 close_button_color_ = title_color;
1029 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1034 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1030 close_button_->SetBackground(close_button_color_, 1035 close_button_->SetBackground(close_button_color_,
1031 rb.GetImageSkiaNamed(IDR_TAB_CLOSE), 1036 rb.GetImageSkiaNamed(IDR_TAB_CLOSE),
1032 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_MASK)); 1037 rb.GetImageSkiaNamed(IDR_TAB_CLOSE_MASK));
1033 } 1038 }
1034 } 1039 }
1035 1040
1036 void Tab::PaintTabImmersive(gfx::Canvas* canvas) { 1041 void Tab::PaintTabImmersive(gfx::Canvas* canvas) {
1037 // The main bar is as wide as the normal tab's horizontal top line. 1042 // The main bar is as wide as the normal tab's horizontal top line.
1038 int main_bar_left = tab_active_.l_width; 1043 // This top line of the tab extends a few pixels left and right of the
1039 int main_bar_right = width() - tab_active_.r_width; 1044 // center image due to pixels in the rounded corner images.
1045 const int kBarPadding = 2;
1046 int main_bar_left = tab_active_.l_width - kBarPadding;
1047 int main_bar_right = width() - tab_active_.r_width + kBarPadding;
1040 1048
1041 bool is_active = IsActive(); 1049 bool is_active = IsActive();
1042 if (ShouldShowIcon()) { 1050 if (ShouldShowIcon()) {
1043 // Use the favicon's horizontal position. 1051 // Use the favicon's horizontal position.
1044 gfx::Rect icon_bar_rect(favicon_bounds_.x(), 0, 1052 gfx::Rect icon_bar_rect(favicon_bounds_.x(), 0,
1045 favicon_bounds_.width(), kImmersiveBarHeight); 1053 favicon_bounds_.width(), kImmersiveBarHeight);
1046 canvas->FillRect(icon_bar_rect, icon_dominant_color_); 1054 canvas->FillRect(icon_bar_rect, icon_dominant_color_);
1047 // Start the main bar slightly offset from the icon bar. 1055 // Start the main bar slightly offset from the icon bar.
1048 main_bar_left = icon_bar_rect.right() + kImmersiveBarSpacing; 1056 main_bar_left = icon_bar_rect.right() + kImmersiveBarSpacing;
1049 } 1057 }
1050 1058
1051 // Mini-tabs don't have a main bar. 1059 // Mini-tabs don't have a main bar.
1052 if (!data().mini || width() > kMiniTabRendererAsNormalTabWidth) { 1060 if (!data().mini || width() > kMiniTabRendererAsNormalTabWidth) {
1053 // Active tab has a brighter bar. 1061 // Active tab has a brighter bar.
1054 const TabImage& tab_image = 1062 SkColor color =
1055 is_active ? tab_immersive_active_ : tab_immersive_inactive_; 1063 is_active ? kImmersiveActiveTabColor : kImmersiveInactiveTabColor;
1056 canvas->DrawImageInt(*tab_image.image_l, main_bar_left, 0); 1064 gfx::Rect main_bar_rect(
1057 canvas->TileImageInt(*tab_image.image_c, 1065 main_bar_left, 0, main_bar_right - main_bar_left, kImmersiveBarHeight);
1058 main_bar_left + tab_image.l_width, 1066 canvas->FillRect(main_bar_rect, color);
1059 0,
1060 main_bar_right - main_bar_left - tab_image.l_width - tab_image.r_width,
1061 tab_image.image_c->height());
1062 canvas->DrawImageInt(
1063 *tab_image.image_r, main_bar_right - tab_image.r_width, 0);
1064 } 1067 }
1065 } 1068 }
1066 1069
1067 void Tab::PaintTabBackground(gfx::Canvas* canvas) { 1070 void Tab::PaintTabBackground(gfx::Canvas* canvas) {
1068 if (IsActive()) { 1071 if (IsActive()) {
1069 PaintActiveTabBackground(canvas); 1072 PaintActiveTabBackground(canvas);
1070 } else { 1073 } else {
1071 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) 1074 if (mini_title_animation_.get() && mini_title_animation_->is_animating())
1072 PaintInactiveTabBackgroundWithTitleChange(canvas); 1075 PaintInactiveTabBackgroundWithTitleChange(canvas);
1073 else 1076 else
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 const gfx::ImageSkia& image) { 1630 const gfx::ImageSkia& image) {
1628 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); 1631 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE);
1629 ImageCacheEntry entry; 1632 ImageCacheEntry entry;
1630 entry.resource_id = resource_id; 1633 entry.resource_id = resource_id;
1631 entry.scale_factor = scale_factor; 1634 entry.scale_factor = scale_factor;
1632 entry.image = image; 1635 entry.image = image;
1633 image_cache_->push_front(entry); 1636 image_cache_->push_front(entry);
1634 if (image_cache_->size() > kMaxImageCacheSize) 1637 if (image_cache_->size() > kMaxImageCacheSize)
1635 image_cache_->pop_back(); 1638 image_cache_->pop_back();
1636 } 1639 }
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