From e5b7de79f6951e99439d6376b4ae60d404ae5d5f Mon Sep 17 00:00:00 2001 From: "finnur@chromium.org" Date: Tue, 27 Apr 2010 18:59:59 +0000 Subject: Now drawing background for inactive app tabs. BUG=None TEST=Visual inspection. Review URL: http://codereview.chromium.org/1701015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45731 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/theme/tab_inactive_nano_center.png | Bin 0 -> 190 bytes chrome/app/theme/tab_inactive_nano_left.png | Bin 0 -> 430 bytes chrome/app/theme/tab_inactive_nano_right.png | Bin 0 -> 320 bytes chrome/app/theme/theme_resources.grd | 3 + chrome/browser/views/tabs/tab_renderer.cc | 97 +++++++++++++++----------- chrome/browser/views/tabs/tab_renderer.h | 1 + 6 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 chrome/app/theme/tab_inactive_nano_center.png create mode 100644 chrome/app/theme/tab_inactive_nano_left.png create mode 100644 chrome/app/theme/tab_inactive_nano_right.png (limited to 'chrome') diff --git a/chrome/app/theme/tab_inactive_nano_center.png b/chrome/app/theme/tab_inactive_nano_center.png new file mode 100644 index 0000000..8421530 Binary files /dev/null and b/chrome/app/theme/tab_inactive_nano_center.png differ diff --git a/chrome/app/theme/tab_inactive_nano_left.png b/chrome/app/theme/tab_inactive_nano_left.png new file mode 100644 index 0000000..236f46c Binary files /dev/null and b/chrome/app/theme/tab_inactive_nano_left.png differ diff --git a/chrome/app/theme/tab_inactive_nano_right.png b/chrome/app/theme/tab_inactive_nano_right.png new file mode 100644 index 0000000..6093a9b Binary files /dev/null and b/chrome/app/theme/tab_inactive_nano_right.png differ diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index 4f57a5b..cfa5851 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -89,6 +89,9 @@ + + + diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc index 9f22248..ec43a13 100644 --- a/chrome/browser/views/tabs/tab_renderer.cc +++ b/chrome/browser/views/tabs/tab_renderer.cc @@ -90,6 +90,7 @@ TabRenderer::TabImage TabRenderer::tab_alpha = {0}; 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 @@ void TabRenderer::PaintInactiveTabBackground(gfx::Canvas* canvas) { 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 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 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); - - // 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); - } + // 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_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_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->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 @@ void TabRenderer::LoadTabImages() { 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); diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h index fc01a7a..64938d75 100644 --- a/chrome/browser/views/tabs/tab_renderer.h +++ b/chrome/browser/views/tabs/tab_renderer.h @@ -273,6 +273,7 @@ class TabRenderer : public views::View, static TabImage tab_active; static TabImage tab_active_nano; static TabImage tab_inactive; + static TabImage tab_inactive_nano; static TabImage tab_alpha; static TabImage tab_alpha_nano; -- cgit v1.1