OLD | NEW |
---|---|
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/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 "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 | 45 |
46 // When a non-mini-tab becomes a mini-tab the width of the tab animates. If | 46 // When a non-mini-tab becomes a mini-tab the width of the tab animates. If |
47 // the width of a mini-tab is >= kMiniTabRendererAsNormalTabWidth then the tab | 47 // the width of a mini-tab is >= kMiniTabRendererAsNormalTabWidth then the tab |
48 // is rendered as a normal tab. This is done to avoid having the title | 48 // is rendered as a normal tab. This is done to avoid having the title |
49 // immediately disappear when transitioning a tab from normal to mini-tab. | 49 // immediately disappear when transitioning a tab from normal to mini-tab. |
50 static const int kMiniTabRendererAsNormalTabWidth = | 50 static const int kMiniTabRendererAsNormalTabWidth = |
51 browser_defaults::kMiniTabWidth + 30; | 51 browser_defaults::kMiniTabWidth + 30; |
52 | 52 |
53 // How opaque to make the hover state (out of 1). | 53 // How opaque to make the hover state (out of 1). |
54 static const double kHoverOpacity = 0.33; | 54 static const double kHoverOpacity = 0.33; |
55 static const double kHoverSlideOpacity = 0.5; | |
55 | 56 |
56 Tab::TabImage Tab::tab_alpha_ = {0}; | 57 Tab::TabImage Tab::tab_alpha_ = {0}; |
57 Tab::TabImage Tab::tab_active_ = {0}; | 58 Tab::TabImage Tab::tab_active_ = {0}; |
58 Tab::TabImage Tab::tab_inactive_ = {0}; | 59 Tab::TabImage Tab::tab_inactive_ = {0}; |
59 | 60 |
60 // Durations for the various parts of the mini tab title animation. | 61 // Durations for the various parts of the mini tab title animation. |
61 static const int kMiniTitleChangeAnimationDuration1MS = 1600; | 62 static const int kMiniTitleChangeAnimationDuration1MS = 1600; |
62 static const int kMiniTitleChangeAnimationStart1MS = 0; | 63 static const int kMiniTitleChangeAnimationStart1MS = 0; |
63 static const int kMiniTitleChangeAnimationEnd1MS = 1900; | 64 static const int kMiniTitleChangeAnimationEnd1MS = 1900; |
64 static const int kMiniTitleChangeAnimationDuration2MS = 0; | 65 static const int kMiniTitleChangeAnimationDuration2MS = 0; |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 offset + tab_image->l_width, | 497 offset + tab_image->l_width, |
497 bg_offset_y + kDropShadowHeight + tab_image->y_offset, | 498 bg_offset_y + kDropShadowHeight + tab_image->y_offset, |
498 tab_image->l_width, | 499 tab_image->l_width, |
499 kDropShadowHeight + tab_image->y_offset, | 500 kDropShadowHeight + tab_image->y_offset, |
500 width() - tab_image->l_width - tab_image->r_width, | 501 width() - tab_image->l_width - tab_image->r_width, |
501 height() - kDropShadowHeight - kToolbarOverlap - tab_image->y_offset); | 502 height() - kDropShadowHeight - kToolbarOverlap - tab_image->y_offset); |
502 | 503 |
503 canvas->DrawBitmapInt(background_canvas.ExtractBitmap(), 0, 0); | 504 canvas->DrawBitmapInt(background_canvas.ExtractBitmap(), 0, 0); |
504 | 505 |
505 if (!GetThemeProvider()->HasCustomImage(tab_id) && | 506 if (!GetThemeProvider()->HasCustomImage(tab_id) && |
506 hover_animation() && hover_animation()->IsShowing()) { | 507 hover_animation() && |
508 (hover_animation()->IsShowing() || hover_animation()->is_animating() )) { | |
sky
2011/01/19 02:36:33
nuke the space between is_animating() and )
| |
507 SkBitmap hover_glow = DrawHoverGlowBitmap(width(), height()); | 509 SkBitmap hover_glow = DrawHoverGlowBitmap(width(), height()); |
508 // Draw the hover glow clipped to the background into hover_image. | 510 // Draw the hover glow clipped to the background into hover_image. |
509 SkBitmap hover_image = SkBitmapOperations::CreateMaskedBitmap( | 511 SkBitmap hover_image = SkBitmapOperations::CreateMaskedBitmap( |
510 hover_glow, background_canvas.ExtractBitmap()); | 512 hover_glow, background_canvas.ExtractBitmap()); |
511 canvas->DrawBitmapInt(hover_image, 0, 0); | 513 canvas->DrawBitmapInt(hover_image, 0, 0); |
512 } | 514 } |
513 | 515 |
514 // Now draw the highlights/shadows around the tab edge. | 516 // Now draw the highlights/shadows around the tab edge. |
515 canvas->DrawBitmapInt(*tab_inactive_image->image_l, 0, 0); | 517 canvas->DrawBitmapInt(*tab_inactive_image->image_l, 0, 0); |
516 canvas->TileImageInt(*tab_inactive_image->image_c, | 518 canvas->TileImageInt(*tab_inactive_image->image_c, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 | 575 |
574 SkPaint paint; | 576 SkPaint paint; |
575 paint.setStyle(SkPaint::kFill_Style); | 577 paint.setStyle(SkPaint::kFill_Style); |
576 paint.setFlags(SkPaint::kAntiAlias_Flag); | 578 paint.setFlags(SkPaint::kAntiAlias_Flag); |
577 SkPoint loc = { SkIntToScalar(hover_point_.x()), | 579 SkPoint loc = { SkIntToScalar(hover_point_.x()), |
578 SkIntToScalar(hover_point_.y()) }; | 580 SkIntToScalar(hover_point_.y()) }; |
579 SkColor colors[2]; | 581 SkColor colors[2]; |
580 const ui::SlideAnimation* hover_slide = hover_animation(); | 582 const ui::SlideAnimation* hover_slide = hover_animation(); |
581 int hover_alpha = 0; | 583 int hover_alpha = 0; |
582 if (hover_slide) { | 584 if (hover_slide) { |
583 hover_alpha = | 585 hover_alpha = static_cast<int>(255 * kHoverSlideOpacity * |
584 static_cast<int>(255 * kHoverOpacity * hover_slide->GetCurrentValue()); | 586 hover_slide->GetCurrentValue()); |
585 } | 587 } |
586 colors[0] = SkColorSetARGB(hover_alpha, 255, 255, 255); | 588 colors[0] = SkColorSetARGB(hover_alpha, 255, 255, 255); |
587 colors[1] = SkColorSetARGB(0, 255, 255, 255); | 589 colors[1] = SkColorSetARGB(0, 255, 255, 255); |
588 SkShader* shader = SkGradientShader::CreateRadial( | 590 SkShader* shader = SkGradientShader::CreateRadial( |
589 loc, | 591 loc, |
590 SkIntToScalar(radius), | 592 SkIntToScalar(radius), |
591 colors, | 593 colors, |
592 NULL, | 594 NULL, |
593 2, | 595 2, |
594 SkShader::kClamp_TileMode); | 596 SkShader::kClamp_TileMode); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); | 667 tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); |
666 tab_active_.l_width = tab_active_.image_l->width(); | 668 tab_active_.l_width = tab_active_.image_l->width(); |
667 tab_active_.r_width = tab_active_.image_r->width(); | 669 tab_active_.r_width = tab_active_.image_r->width(); |
668 | 670 |
669 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); | 671 tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT); |
670 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); | 672 tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER); |
671 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); | 673 tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT); |
672 tab_inactive_.l_width = tab_inactive_.image_l->width(); | 674 tab_inactive_.l_width = tab_inactive_.image_l->width(); |
673 tab_inactive_.r_width = tab_inactive_.image_r->width(); | 675 tab_inactive_.r_width = tab_inactive_.image_r->width(); |
674 } | 676 } |
OLD | NEW |