| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
| 10 #include "app/gfx/font.h" | 10 #include "app/gfx/font.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "views/window/window.h" | 24 #include "views/window/window.h" |
| 25 | 25 |
| 26 #ifdef WIN32 | 26 #ifdef WIN32 |
| 27 #include "app/win_util.h" | 27 #include "app/win_util.h" |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 static const int kLeftPadding = 16; | 30 static const int kLeftPadding = 16; |
| 31 static const int kTopPadding = 6; | 31 static const int kTopPadding = 6; |
| 32 static const int kRightPadding = 15; | 32 static const int kRightPadding = 15; |
| 33 static const int kBottomPadding = 5; | 33 static const int kBottomPadding = 5; |
| 34 static const int kDropShadowHeight = 2; |
| 35 static const int kToolbarOverlap = 1; |
| 34 static const int kFavIconTitleSpacing = 4; | 36 static const int kFavIconTitleSpacing = 4; |
| 35 static const int kTitleCloseButtonSpacing = 5; | 37 static const int kTitleCloseButtonSpacing = 5; |
| 36 static const int kStandardTitleWidth = 175; | 38 static const int kStandardTitleWidth = 175; |
| 37 static const int kCloseButtonVertFuzz = 0; | 39 static const int kCloseButtonVertFuzz = 0; |
| 38 static const int kCloseButtonHorzFuzz = 5; | 40 static const int kCloseButtonHorzFuzz = 5; |
| 39 static const int kFaviconSize = 16; | 41 static const int kFaviconSize = 16; |
| 40 static const int kSelectedTitleColor = SK_ColorBLACK; | 42 static const int kSelectedTitleColor = SK_ColorBLACK; |
| 41 | 43 |
| 42 // How long the hover state takes. | 44 // How long the hover state takes. |
| 43 static const int kHoverDurationMs = 90; | 45 static const int kHoverDurationMs = 90; |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 PaintActiveTabBackground(canvas); | 603 PaintActiveTabBackground(canvas); |
| 602 canvas->restore(); | 604 canvas->restore(); |
| 603 } | 605 } |
| 604 } | 606 } |
| 605 } | 607 } |
| 606 | 608 |
| 607 void TabRenderer::PaintInactiveTabBackground(gfx::Canvas* canvas) { | 609 void TabRenderer::PaintInactiveTabBackground(gfx::Canvas* canvas) { |
| 608 bool is_otr = data_.off_the_record; | 610 bool is_otr = data_.off_the_record; |
| 609 | 611 |
| 610 // The tab image needs to be lined up with the background image | 612 // The tab image needs to be lined up with the background image |
| 611 // so that it feels partially transparent. | 613 // so that it feels partially transparent. These offsets represent the tab |
| 614 // position within the frame background image. |
| 612 int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + 1; | 615 int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + 1; |
| 616 // TODO(glen): http://crbug.com/12761 This should use |
| 617 // BrowserView::GetTabstripBounds() instead of a hardcoded constant. |
| 613 int offset_y = 20; | 618 int offset_y = 20; |
| 614 | 619 |
| 615 int tab_id; | 620 int tab_id; |
| 616 if (GetWidget() && | 621 if (GetWidget() && |
| 617 GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) { | 622 GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) { |
| 618 tab_id = IDR_THEME_TAB_BACKGROUND_V; | 623 tab_id = IDR_THEME_TAB_BACKGROUND_V; |
| 619 } else { | 624 } else { |
| 620 tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : | 625 tab_id = is_otr ? IDR_THEME_TAB_BACKGROUND_INCOGNITO : |
| 621 IDR_THEME_TAB_BACKGROUND; | 626 IDR_THEME_TAB_BACKGROUND; |
| 622 } | 627 } |
| 623 | 628 |
| 624 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id); | 629 SkBitmap* tab_bg = GetThemeProvider()->GetBitmapNamed(tab_id); |
| 625 | 630 |
| 626 // Draw left edge. | 631 // Draw left edge. Don't draw over the toolbar, as we're not the foreground |
| 632 // tab. |
| 627 SkBitmap tab_l = skia::ImageOperations::CreateTiledBitmap( | 633 SkBitmap tab_l = skia::ImageOperations::CreateTiledBitmap( |
| 628 *tab_bg, offset, offset_y, | 634 *tab_bg, offset, offset_y, |
| 629 tab_active.l_width, height()); | 635 tab_active.l_width, height()); |
| 630 SkBitmap theme_l = skia::ImageOperations::CreateMaskedBitmap( | 636 SkBitmap theme_l = skia::ImageOperations::CreateMaskedBitmap( |
| 631 tab_l, *tab_alpha.image_l); | 637 tab_l, *tab_alpha.image_l); |
| 632 canvas->DrawBitmapInt(theme_l, | 638 canvas->DrawBitmapInt(theme_l, |
| 633 0, 0, theme_l.width(), theme_l.height() - 1, | 639 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, |
| 634 0, 0, theme_l.width(), theme_l.height() - 1, | 640 0, 0, theme_l.width(), theme_l.height() - kToolbarOverlap, |
| 635 false); | 641 false); |
| 636 | 642 |
| 637 // Draw right edge. | 643 // Draw right edge. Again, don't draw over the toolbar. |
| 638 SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap( | 644 SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap( |
| 639 *tab_bg, | 645 *tab_bg, |
| 640 offset + width() - tab_active.r_width, offset_y, | 646 offset + width() - tab_active.r_width, offset_y, |
| 641 tab_active.r_width, height()); | 647 tab_active.r_width, height()); |
| 642 SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap( | 648 SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap( |
| 643 tab_r, *tab_alpha.image_r); | 649 tab_r, *tab_alpha.image_r); |
| 644 canvas->DrawBitmapInt(theme_r, | 650 canvas->DrawBitmapInt(theme_r, |
| 645 0, 0, theme_r.width(), theme_r.height() - 1, | 651 0, 0, theme_r.width(), theme_r.height() - kToolbarOverlap, |
| 646 width() - theme_r.width(), 0, theme_r.width(), theme_r.height() - 1, | 652 width() - theme_r.width(), 0, theme_r.width(), |
| 647 false); | 653 theme_r.height() - kToolbarOverlap, false); |
| 648 | 654 |
| 649 // Draw center. | 655 // Draw center. Instead of masking out the top portion we simply skip over it |
| 656 // by incrementing by kDropShadowHeight, since it's a simple rectangle. And |
| 657 // again, don't draw over the toolbar. |
| 650 canvas->TileImageInt(*tab_bg, | 658 canvas->TileImageInt(*tab_bg, |
| 651 offset + tab_active.l_width, 2 + offset_y, // 2 is the drop shadow offset. | 659 offset + tab_active.l_width, offset_y + kDropShadowHeight, |
| 652 tab_active.l_width, 2, | 660 tab_active.l_width, kDropShadowHeight, |
| 653 width() - tab_active.l_width - tab_active.r_width, height() - 3); | 661 width() - tab_active.l_width - tab_active.r_width, |
| 662 height() - kDropShadowHeight - kToolbarOverlap); |
| 654 | 663 |
| 664 // Now draw the highlights/shadows around the tab edge. |
| 655 canvas->DrawBitmapInt(*tab_inactive.image_l, 0, 0); | 665 canvas->DrawBitmapInt(*tab_inactive.image_l, 0, 0); |
| 656 canvas->TileImageInt(*tab_inactive.image_c, | 666 canvas->TileImageInt(*tab_inactive.image_c, |
| 657 tab_inactive.l_width, 0, | 667 tab_inactive.l_width, 0, |
| 658 width() - tab_inactive.l_width - tab_inactive.r_width, | 668 width() - tab_inactive.l_width - tab_inactive.r_width, |
| 659 height()); | 669 height()); |
| 660 canvas->DrawBitmapInt(*tab_inactive.image_r, | 670 canvas->DrawBitmapInt(*tab_inactive.image_r, |
| 661 width() - tab_inactive.r_width, 0); | 671 width() - tab_inactive.r_width, 0); |
| 662 } | 672 } |
| 663 | 673 |
| 664 void TabRenderer::PaintActiveTabBackground(gfx::Canvas* canvas) { | 674 void TabRenderer::PaintActiveTabBackground(gfx::Canvas* canvas) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 678 | 688 |
| 679 // Draw right edge. | 689 // Draw right edge. |
| 680 SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap( | 690 SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap( |
| 681 *tab_bg, | 691 *tab_bg, |
| 682 offset + width() - tab_active.r_width, 0, | 692 offset + width() - tab_active.r_width, 0, |
| 683 tab_active.r_width, height()); | 693 tab_active.r_width, height()); |
| 684 SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap( | 694 SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap( |
| 685 tab_r, *tab_alpha.image_r); | 695 tab_r, *tab_alpha.image_r); |
| 686 canvas->DrawBitmapInt(theme_r, width() - tab_active.r_width, 0); | 696 canvas->DrawBitmapInt(theme_r, width() - tab_active.r_width, 0); |
| 687 | 697 |
| 688 // Draw center. | 698 // Draw center. Instead of masking out the top portion we simply skip over it |
| 699 // by incrementing by kDropShadowHeight, since it's a simple rectangle. |
| 689 canvas->TileImageInt(*tab_bg, | 700 canvas->TileImageInt(*tab_bg, |
| 690 offset + tab_active.l_width, 2, | 701 offset + tab_active.l_width, kDropShadowHeight, |
| 691 tab_active.l_width, 2, | 702 tab_active.l_width, kDropShadowHeight, |
| 692 width() - tab_active.l_width - tab_active.r_width, height() - 2); | 703 width() - tab_active.l_width - tab_active.r_width, |
| 704 height() - kDropShadowHeight); |
| 693 | 705 |
| 706 // Now draw the highlights/shadows around the tab edge. |
| 694 canvas->DrawBitmapInt(*tab_active.image_l, 0, 0); | 707 canvas->DrawBitmapInt(*tab_active.image_l, 0, 0); |
| 695 canvas->TileImageInt(*tab_active.image_c, tab_active.l_width, 0, | 708 canvas->TileImageInt(*tab_active.image_c, tab_active.l_width, 0, |
| 696 width() - tab_active.l_width - tab_active.r_width, height()); | 709 width() - tab_active.l_width - tab_active.r_width, height()); |
| 697 canvas->DrawBitmapInt(*tab_active.image_r, width() - tab_active.r_width, 0); | 710 canvas->DrawBitmapInt(*tab_active.image_r, width() - tab_active.r_width, 0); |
| 698 } | 711 } |
| 699 | 712 |
| 700 void TabRenderer::PaintHoverTabBackground(gfx::Canvas* canvas, | 713 void TabRenderer::PaintHoverTabBackground(gfx::Canvas* canvas, |
| 701 double opacity) { | 714 double opacity) { |
| 702 SkBitmap left = skia::ImageOperations::CreateBlendedBitmap( | 715 SkBitmap left = skia::ImageOperations::CreateBlendedBitmap( |
| 703 *tab_inactive.image_l, *tab_active.image_l, opacity); | 716 *tab_inactive.image_l, *tab_active.image_l, opacity); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); | 818 tab_inactive.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); |
| 806 tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); | 819 tab_inactive.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); |
| 807 tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); | 820 tab_inactive.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); |
| 808 | 821 |
| 809 tab_inactive.l_width = tab_inactive.image_l->width(); | 822 tab_inactive.l_width = tab_inactive.image_l->width(); |
| 810 tab_inactive.r_width = tab_inactive.image_r->width(); | 823 tab_inactive.r_width = tab_inactive.image_r->width(); |
| 811 | 824 |
| 812 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); | 825 loading_animation_frames = rb.GetBitmapNamed(IDR_THROBBER); |
| 813 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); | 826 waiting_animation_frames = rb.GetBitmapNamed(IDR_THROBBER_WAITING); |
| 814 } | 827 } |
| OLD | NEW |