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

Unified Diff: chrome/browser/views/tabs/tab_renderer.cc

Issue 1701015: Now drawing background for inactive app tabs.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 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/views/tabs/tab_renderer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/tabs/tab_renderer.cc
===================================================================
--- chrome/browser/views/tabs/tab_renderer.cc (revision 45664)
+++ chrome/browser/views/tabs/tab_renderer.cc (working copy)
@@ -90,6 +90,7 @@
TabRenderer::TabImage TabRenderer::tab_active = {0};
TabRenderer::TabImage TabRenderer::tab_active_nano = {0};
TabRenderer::TabImage TabRenderer::tab_inactive = {0};
+TabRenderer::TabImage TabRenderer::tab_inactive_nano = {0};
TabRenderer::TabImage TabRenderer::tab_alpha_nano = {0};
// Max opacity for the mini-tab title change animation.
@@ -735,53 +736,60 @@
SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id);
+ // App tabs are drawn slightly differently (as nano tabs).
+ TabImage* tab_image = data_.app ? &tab_active_nano : &tab_active;
+ TabImage* tab_inactive_image = data_.app ? &tab_inactive_nano :
+ &tab_inactive;
+ TabImage* alpha = data_.app ? &tab_alpha_nano : &tab_alpha;
+
// If the theme is providing a custom background image, then its top edge
// should be at the top of the tab. Otherwise, we assume that the background
// image is a composited foreground + frame image.
int bg_offset_y = GetThemeProvider()->HasCustomImage(tab_id) ?
0 : background_offset_.y();
- if (!data_.app) {
- // Draw left edge. Don't draw over the toolbar, as we're not the foreground
- // tab.
- SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap(
- *tab_bg, offset, bg_offset_y, tab_active.l_width, height());
- SkBitmap theme_l =
- SkBitmapOperations::CreateMaskedBitmap(tab_l, *tab_alpha.image_l);
- canvas->DrawBitmapInt(theme_l,
- 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
- 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
- false);
+ // Draw left edge. Don't draw over the toolbar, as we're not the foreground
+ // tab.
+ SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap(
+ *tab_bg, offset, bg_offset_y, tab_image->l_width, height());
+ SkBitmap theme_l =
+ SkBitmapOperations::CreateMaskedBitmap(tab_l, *alpha->image_l);
+ canvas->DrawBitmapInt(theme_l,
+ 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
+ 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
+ false);
- // Draw right edge. Again, don't draw over the toolbar.
- SkBitmap tab_r = SkBitmapOperations::CreateTiledBitmap(*tab_bg,
- offset + width() - tab_active.r_width, bg_offset_y,
- tab_active.r_width, height());
- SkBitmap theme_r =
- SkBitmapOperations::CreateMaskedBitmap(tab_r, *tab_alpha.image_r);
- canvas->DrawBitmapInt(theme_r,
- 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap,
- width() - theme_r.width(), 0, theme_r.width(),
- theme_r.height() - kToolbarOverlap, false);
+ // Draw right edge. Again, don't draw over the toolbar.
+ SkBitmap tab_r = SkBitmapOperations::CreateTiledBitmap(*tab_bg,
+ offset + width() - tab_image->r_width, bg_offset_y,
+ tab_image->r_width, height());
+ SkBitmap theme_r =
+ SkBitmapOperations::CreateMaskedBitmap(tab_r, *alpha->image_r);
+ canvas->DrawBitmapInt(theme_r,
+ 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap,
+ width() - theme_r.width(), 0, theme_r.width(),
+ theme_r.height() - kToolbarOverlap, false);
- // Draw center. Instead of masking out the top portion we simply skip over
- // it by incrementing by kDropShadowHeight, since it's a simple rectangle.
- // And again, don't draw over the toolbar.
- canvas->TileImageInt(*tab_bg,
- offset + tab_active.l_width, bg_offset_y + kDropShadowHeight,
- tab_active.l_width, kDropShadowHeight,
- width() - tab_active.l_width - tab_active.r_width,
- height() - kDropShadowHeight - kToolbarOverlap);
+ // Draw center. Instead of masking out the top portion we simply skip over
+ // it by incrementing by kDropShadowHeight, since it's a simple rectangle.
+ // And again, don't draw over the toolbar.
+ canvas->TileImageInt(*tab_bg,
+ offset + tab_image->l_width,
+ bg_offset_y + kDropShadowHeight + tab_image->y_offset,
+ tab_image->l_width,
+ kDropShadowHeight + tab_image->y_offset,
+ width() - tab_image->l_width - tab_image->r_width,
+ height() - kDropShadowHeight - kToolbarOverlap - tab_image->y_offset);
- // Now draw the highlights/shadows around the tab edge.
- canvas->DrawBitmapInt(*tab_inactive.image_l, 0, 0);
- canvas->TileImageInt(*tab_inactive.image_c,
- tab_inactive.l_width, 0,
- width() - tab_inactive.l_width - tab_inactive.r_width,
- height());
- canvas->DrawBitmapInt(*tab_inactive.image_r,
- width() - tab_inactive.r_width, 0);
- }
+ // Now draw the highlights/shadows around the tab edge.
+ canvas->DrawBitmapInt(*tab_inactive_image->image_l, 0, 0);
+ canvas->TileImageInt(*tab_inactive_image->image_c,
+ tab_inactive_image->l_width, 0,
+ width() - tab_inactive_image->l_width -
+ tab_inactive_image->r_width,
+ height());
+ canvas->DrawBitmapInt(*tab_inactive_image->image_r,
+ width() - tab_inactive_image->r_width, 0);
}
void TabRenderer::PaintActiveTabBackground(gfx::Canvas* canvas) {
@@ -997,6 +1005,13 @@
tab_inactive.l_width = tab_inactive.image_l->width();
tab_inactive.r_width = tab_inactive.image_r->width();
+ tab_inactive_nano.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_LEFT);
+ tab_inactive_nano.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_CENTER);
+ tab_inactive_nano.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_RIGHT);
+ tab_inactive_nano.l_width = tab_inactive_nano.image_l->width();
+ tab_inactive_nano.r_width = tab_inactive_nano.image_r->width();
+ tab_inactive_nano.y_offset = kMiniTabDiffHeight;
+
loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER);
waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING);
« no previous file with comments | « chrome/browser/views/tabs/tab_renderer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698