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

Side by Side 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, 7 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 | « chrome/browser/views/tabs/tab_renderer.h ('k') | 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) 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/tab_renderer.h" 5 #include "chrome/browser/views/tabs/tab_renderer.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/animation_container.h" 9 #include "app/animation_container.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 static int waiting_to_loading_frame_count_ratio = 0; 83 static int waiting_to_loading_frame_count_ratio = 0;
84 84
85 // Used when |render_as_new_tab| is true. 85 // Used when |render_as_new_tab| is true.
86 static SkBitmap* new_tab_mask = NULL; 86 static SkBitmap* new_tab_mask = NULL;
87 static SkBitmap* new_tab_shadow = NULL; 87 static SkBitmap* new_tab_shadow = NULL;
88 88
89 TabRenderer::TabImage TabRenderer::tab_alpha = {0}; 89 TabRenderer::TabImage TabRenderer::tab_alpha = {0};
90 TabRenderer::TabImage TabRenderer::tab_active = {0}; 90 TabRenderer::TabImage TabRenderer::tab_active = {0};
91 TabRenderer::TabImage TabRenderer::tab_active_nano = {0}; 91 TabRenderer::TabImage TabRenderer::tab_active_nano = {0};
92 TabRenderer::TabImage TabRenderer::tab_inactive = {0}; 92 TabRenderer::TabImage TabRenderer::tab_inactive = {0};
93 TabRenderer::TabImage TabRenderer::tab_inactive_nano = {0};
93 TabRenderer::TabImage TabRenderer::tab_alpha_nano = {0}; 94 TabRenderer::TabImage TabRenderer::tab_alpha_nano = {0};
94 95
95 // Max opacity for the mini-tab title change animation. 96 // Max opacity for the mini-tab title change animation.
96 const double kMiniTitleChangeThrobOpacity = 0.75; 97 const double kMiniTitleChangeThrobOpacity = 0.75;
97 98
98 // Duration for when the title of an inactive mini-tab changes. 99 // Duration for when the title of an inactive mini-tab changes.
99 const int kMiniTitleChangeThrobDuration = 1000; 100 const int kMiniTitleChangeThrobDuration = 1000;
100 101
101 // When the title of a mini-tab in the background changes the size of the icon 102 // When the title of a mini-tab in the background changes the size of the icon
102 // animates. This is the max size we let the icon go to. 103 // animates. This is the max size we let the icon go to.
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 if (GetWidget() && 729 if (GetWidget() &&
729 GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) { 730 GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) {
730 tab_id = IDR_THEME_TAB_BACKGROUND_V; 731 tab_id = IDR_THEME_TAB_BACKGROUND_V;
731 } else { 732 } else {
732 tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : 733 tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO :
733 IDR_THEME_TAB_BACKGROUND; 734 IDR_THEME_TAB_BACKGROUND;
734 } 735 }
735 736
736 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id); 737 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id);
737 738
739 // App tabs are drawn slightly differently (as nano tabs).
740 TabImage* tab_image = data_.app ? &tab_active_nano : &tab_active;
741 TabImage* tab_inactive_image = data_.app ? &tab_inactive_nano :
742 &tab_inactive;
743 TabImage* alpha = data_.app ? &tab_alpha_nano : &tab_alpha;
744
738 // If the theme is providing a custom background image, then its top edge 745 // If the theme is providing a custom background image, then its top edge
739 // should be at the top of the tab. Otherwise, we assume that the background 746 // should be at the top of the tab. Otherwise, we assume that the background
740 // image is a composited foreground + frame image. 747 // image is a composited foreground + frame image.
741 int bg_offset_y = GetThemeProvider()->HasCustomImage(tab_id) ? 748 int bg_offset_y = GetThemeProvider()->HasCustomImage(tab_id) ?
742 0 : background_offset_.y(); 749 0 : background_offset_.y();
743 750
744 if (!data_.app) { 751 // Draw left edge. Don't draw over the toolbar, as we're not the foreground
745 // Draw left edge. Don't draw over the toolbar, as we're not the foreground 752 // tab.
746 // tab. 753 SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap(
747 SkBitmap tab_l = SkBitmapOperations::CreateTiledBitmap( 754 *tab_bg, offset, bg_offset_y, tab_image->l_width, height());
748 *tab_bg, offset, bg_offset_y, tab_active.l_width, height()); 755 SkBitmap theme_l =
749 SkBitmap theme_l = 756 SkBitmapOperations::CreateMaskedBitmap(tab_l, *alpha->image_l);
750 SkBitmapOperations::CreateMaskedBitmap(tab_l, *tab_alpha.image_l); 757 canvas->DrawBitmapInt(theme_l,
751 canvas->DrawBitmapInt(theme_l, 758 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
752 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, 759 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap,
753 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, 760 false);
754 false);
755 761
756 // Draw right edge. Again, don't draw over the toolbar. 762 // Draw right edge. Again, don't draw over the toolbar.
757 SkBitmap tab_r = SkBitmapOperations::CreateTiledBitmap(*tab_bg, 763 SkBitmap tab_r = SkBitmapOperations::CreateTiledBitmap(*tab_bg,
758 offset + width() - tab_active.r_width, bg_offset_y, 764 offset + width() - tab_image->r_width, bg_offset_y,
759 tab_active.r_width, height()); 765 tab_image->r_width, height());
760 SkBitmap theme_r = 766 SkBitmap theme_r =
761 SkBitmapOperations::CreateMaskedBitmap(tab_r, *tab_alpha.image_r); 767 SkBitmapOperations::CreateMaskedBitmap(tab_r, *alpha->image_r);
762 canvas->DrawBitmapInt(theme_r, 768 canvas->DrawBitmapInt(theme_r,
763 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, 769 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap,
764 width() - theme_r.width(), 0, theme_r.width(), 770 width() - theme_r.width(), 0, theme_r.width(),
765 theme_r.height() - kToolbarOverlap, false); 771 theme_r.height() - kToolbarOverlap, false);
766 772
767 // Draw center. Instead of masking out the top portion we simply skip over 773 // Draw center. Instead of masking out the top portion we simply skip over
768 // it by incrementing by kDropShadowHeight, since it's a simple rectangle. 774 // it by incrementing by kDropShadowHeight, since it's a simple rectangle.
769 // And again, don't draw over the toolbar. 775 // And again, don't draw over the toolbar.
770 canvas->TileImageInt(*tab_bg, 776 canvas->TileImageInt(*tab_bg,
771 offset + tab_active.l_width, bg_offset_y + kDropShadowHeight, 777 offset + tab_image->l_width,
772 tab_active.l_width, kDropShadowHeight, 778 bg_offset_y + kDropShadowHeight + tab_image->y_offset,
773 width() - tab_active.l_width - tab_active.r_width, 779 tab_image->l_width,
774 height() - kDropShadowHeight - kToolbarOverlap); 780 kDropShadowHeight + tab_image->y_offset,
781 width() - tab_image->l_width - tab_image->r_width,
782 height() - kDropShadowHeight - kToolbarOverlap - tab_image->y_offset);
775 783
776 // Now draw the highlights/shadows around the tab edge. 784 // Now draw the highlights/shadows around the tab edge.
777 canvas->DrawBitmapInt(*tab_inactive.image_l, 0, 0); 785 canvas->DrawBitmapInt(*tab_inactive_image->image_l, 0, 0);
778 canvas->TileImageInt(*tab_inactive.image_c, 786 canvas->TileImageInt(*tab_inactive_image->image_c,
779 tab_inactive.l_width, 0, 787 tab_inactive_image->l_width, 0,
780 width() - tab_inactive.l_width - tab_inactive.r_width, 788 width() - tab_inactive_image->l_width -
781 height()); 789 tab_inactive_image->r_width,
782 canvas->DrawBitmapInt(*tab_inactive.image_r, 790 height());
783 width() - tab_inactive.r_width, 0); 791 canvas->DrawBitmapInt(*tab_inactive_image->image_r,
784 } 792 width() - tab_inactive_image->r_width, 0);
785 } 793 }
786 794
787 void TabRenderer::PaintActiveTabBackground(gfx::Canvas* canvas) { 795 void TabRenderer::PaintActiveTabBackground(gfx::Canvas* canvas) {
788 int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + 796 int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) +
789 background_offset_.x(); 797 background_offset_.x();
790 ThemeProvider* tp = GetThemeProvider(); 798 ThemeProvider* tp = GetThemeProvider();
791 if (!tp) 799 if (!tp)
792 NOTREACHED() << "Unable to get theme provider"; 800 NOTREACHED() << "Unable to get theme provider";
793 801
794 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR); 802 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(IDR_THEME_TOOLBAR);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 tab_active_nano.l_width = tab_active_nano.image_l->width(); 998 tab_active_nano.l_width = tab_active_nano.image_l->width();
991 tab_active_nano.r_width = tab_active_nano.image_r->width(); 999 tab_active_nano.r_width = tab_active_nano.image_r->width();
992 tab_active_nano.y_offset = kMiniTabDiffHeight; 1000 tab_active_nano.y_offset = kMiniTabDiffHeight;
993 1001
994 tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); 1002 tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
995 tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); 1003 tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
996 tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); 1004 tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
997 tab_inactive.l_width = tab_inactive.image_l->width(); 1005 tab_inactive.l_width = tab_inactive.image_l->width();
998 tab_inactive.r_width = tab_inactive.image_r->width(); 1006 tab_inactive.r_width = tab_inactive.image_r->width();
999 1007
1008 tab_inactive_nano.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_LEFT);
1009 tab_inactive_nano.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_CENTER);
1010 tab_inactive_nano.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_RIGHT);
1011 tab_inactive_nano.l_width = tab_inactive_nano.image_l->width();
1012 tab_inactive_nano.r_width = tab_inactive_nano.image_r->width();
1013 tab_inactive_nano.y_offset = kMiniTabDiffHeight;
1014
1000 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); 1015 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER);
1001 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); 1016 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING);
1002 1017
1003 new_tab_mask = rb.GetBitmapNamed(IDR_TAB_ALPHA_NEW_TAB); 1018 new_tab_mask = rb.GetBitmapNamed(IDR_TAB_ALPHA_NEW_TAB);
1004 new_tab_shadow = rb.GetBitmapNamed(IDR_TAB_NEW_TAB_SHADOW); 1019 new_tab_shadow = rb.GetBitmapNamed(IDR_TAB_NEW_TAB_SHADOW);
1005 } 1020 }
1006 1021
1007 void TabRenderer::SetBlocked(bool blocked) { 1022 void TabRenderer::SetBlocked(bool blocked) {
1008 if (data_.blocked == blocked) 1023 if (data_.blocked == blocked)
1009 return; 1024 return;
1010 data_.blocked = blocked; 1025 data_.blocked = blocked;
1011 if (blocked) 1026 if (blocked)
1012 StartPulse(); 1027 StartPulse();
1013 else 1028 else
1014 StopPulse(); 1029 StopPulse();
1015 } 1030 }
OLDNEW
« 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