OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/defaults.h" | 10 #include "chrome/browser/defaults.h" |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 case chrome::search::Mode::MODE_SEARCH: | 511 case chrome::search::Mode::MODE_SEARCH: |
512 case chrome::search::Mode::MODE_DEFAULT: | 512 case chrome::search::Mode::MODE_DEFAULT: |
513 default: | 513 default: |
514 return tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR_SEARCH); | 514 return tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR_SEARCH); |
515 } | 515 } |
516 } | 516 } |
517 | 517 |
518 void Tab::PaintTabBackground(gfx::Canvas* canvas) { | 518 void Tab::PaintTabBackground(gfx::Canvas* canvas) { |
519 if (IsActive()) { | 519 if (IsActive()) { |
520 bool fading_in = false; | 520 bool fading_in = false; |
521 // If mode is SEARCH, we might be waiting to fade in or fading in new | 521 // If |gradient_background_opacity| < 1f, paint flat background at full |
522 // background, in which case, the previous background needs to be painted. | 522 // opacity, and only paint gradient background if |
523 if (data().mode == chrome::search::Mode::MODE_SEARCH && | 523 // |gradient_background_opacity| is not 0f; |
524 data().background_state & | 524 // if |gradient_opacity| is 1f, paint the background for the current mode |
525 chrome::search::ToolbarSearchAnimator::BACKGROUND_STATE_NTP) { | 525 // at full opacity. |
526 // Paint background for NTP mode. | 526 if (data().gradient_background_opacity < 1.0f) { |
| 527 // Paint flat background of NTP mode. |
527 PaintActiveTabBackground(canvas, | 528 PaintActiveTabBackground(canvas, |
528 GetTabBackgroundImage(chrome::search::Mode::MODE_NTP)); | 529 GetTabBackgroundImage(chrome::search::Mode::MODE_NTP)); |
529 // We're done if we're not showing background for |MODE_SEARCH|. | 530 // We're done if we're not showing gradient background. |
530 if (!(data().background_state & chrome::search::ToolbarSearchAnimator:: | 531 if (data().gradient_background_opacity == 0.0f) |
531 BACKGROUND_STATE_SEARCH)) { | |
532 return; | 532 return; |
533 } | 533 // Otherwise, we're fading in the gradient background at |
534 // Otherwise, we're fading in the background for |MODE_SEARCH| at | 534 // |data().gradient_background_opacity|. |
535 // |data().search_background_opacity|. | |
536 fading_in = true; | 535 fading_in = true; |
537 canvas->SaveLayerAlpha( | 536 canvas->SaveLayerAlpha( |
538 static_cast<uint8>(data().search_background_opacity * 0xFF), | 537 static_cast<uint8>(data().gradient_background_opacity * 0xFF), |
539 gfx::Rect(width(), height())); | 538 gfx::Rect(width(), height())); |
540 } | 539 } |
541 // Paint the background for the current mode. | 540 // Paint the background for the current mode. |
542 PaintActiveTabBackground(canvas, GetTabBackgroundImage(data().mode)); | 541 PaintActiveTabBackground(canvas, GetTabBackgroundImage(data().mode)); |
543 // If we're fading in and have saved canvas, restore it now. | 542 // If we're fading and have saved canvas, restore it now. |
544 if (fading_in) | 543 if (fading_in) |
545 canvas->Restore(); | 544 canvas->Restore(); |
546 } else { | 545 } else { |
547 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) | 546 if (mini_title_animation_.get() && mini_title_animation_->is_animating()) |
548 PaintInactiveTabBackgroundWithTitleChange(canvas); | 547 PaintInactiveTabBackgroundWithTitleChange(canvas); |
549 else | 548 else |
550 PaintInactiveTabBackground(canvas); | 549 PaintInactiveTabBackground(canvas); |
551 | 550 |
552 double throb_value = GetThrobValue(); | 551 double throb_value = GetThrobValue(); |
553 if (throb_value > 0) { | 552 if (throb_value > 0) { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 rb.GetImageSkiaNamed(IDR_TAB_ACTIVE_RIGHT_SEARCH); | 814 rb.GetImageSkiaNamed(IDR_TAB_ACTIVE_RIGHT_SEARCH); |
816 tab_active_search_.l_width = tab_active_search_.image_l->width(); | 815 tab_active_search_.l_width = tab_active_search_.image_l->width(); |
817 tab_active_search_.r_width = tab_active_search_.image_r->width(); | 816 tab_active_search_.r_width = tab_active_search_.image_r->width(); |
818 | 817 |
819 tab_inactive_.image_l = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_LEFT); | 818 tab_inactive_.image_l = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_LEFT); |
820 tab_inactive_.image_c = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_CENTER); | 819 tab_inactive_.image_c = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_CENTER); |
821 tab_inactive_.image_r = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_RIGHT); | 820 tab_inactive_.image_r = rb.GetImageSkiaNamed(IDR_TAB_INACTIVE_RIGHT); |
822 tab_inactive_.l_width = tab_inactive_.image_l->width(); | 821 tab_inactive_.l_width = tab_inactive_.image_l->width(); |
823 tab_inactive_.r_width = tab_inactive_.image_r->width(); | 822 tab_inactive_.r_width = tab_inactive_.image_r->width(); |
824 } | 823 } |
OLD | NEW |