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

Side by Side Diff: chrome/browser/views/tabs/tab_renderer.cc

Issue 27317: Support DWM switching.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« no previous file with comments | « chrome/browser/views/tabs/tab_renderer.h ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | 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) 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 <limits> 5 #include <limits>
6 6
7 #include "chrome/browser/views/tabs/tab_renderer.h" 7 #include "chrome/browser/views/tabs/tab_renderer.h"
8 8
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
11 #include "chrome/browser/tab_contents/tab_contents.h" 11 #include "chrome/browser/tab_contents/tab_contents.h"
12 #include "chrome/browser/tabs/tab_strip_model.h" 12 #include "chrome/browser/tabs/tab_strip_model.h"
13 #include "chrome/common/gfx/chrome_canvas.h" 13 #include "chrome/common/gfx/chrome_canvas.h"
14 #include "chrome/common/gfx/chrome_font.h" 14 #include "chrome/common/gfx/chrome_font.h"
15 #include "chrome/common/l10n_util.h" 15 #include "chrome/common/l10n_util.h"
16 #include "chrome/common/resource_bundle.h" 16 #include "chrome/common/resource_bundle.h"
17 #include "chrome/common/win_util.h" 17 #include "chrome/common/win_util.h"
18 #include "chrome/views/window.h"
18 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
20 #include "skia/ext/image_operations.h" 21 #include "skia/ext/image_operations.h"
21 22
22 static const int kLeftPadding = 16; 23 static const int kLeftPadding = 16;
23 static const int kTopPadding = 6; 24 static const int kTopPadding = 6;
24 static const int kRightPadding = 15; 25 static const int kRightPadding = 15;
25 static const int kBottomPadding = 5; 26 static const int kBottomPadding = 5;
26 static const int kFavIconTitleSpacing = 4; 27 static const int kFavIconTitleSpacing = 4;
27 static const int kTitleCloseButtonSpacing = 5; 28 static const int kTitleCloseButtonSpacing = 5;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 static SkBitmap* crashed_fav_icon = NULL; 72 static SkBitmap* crashed_fav_icon = NULL;
72 static int loading_animation_frame_count = 0; 73 static int loading_animation_frame_count = 0;
73 static int waiting_animation_frame_count = 0; 74 static int waiting_animation_frame_count = 0;
74 static int waiting_to_loading_frame_count_ratio = 0; 75 static int waiting_to_loading_frame_count_ratio = 0;
75 static SkBitmap* download_icon = NULL; 76 static SkBitmap* download_icon = NULL;
76 static int download_icon_width = 0; 77 static int download_icon_width = 0;
77 static int download_icon_height = 0; 78 static int download_icon_height = 0;
78 79
79 namespace { 80 namespace {
80 81
82 // Loads the images to be used for the tab background. Uses the images for
83 // Vista if |use_vista_images| is true.
84 void LoadTabImages(bool use_vista_images) {
85 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
86 if (use_vista_images) {
87 tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
88 tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
89 tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
90
91 // Our Vista frame doesn't change background color to show OTR,
92 // so we continue to use the existing background tabs.
93 tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
94 tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
95 tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
96 } else {
97 tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
98 tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
99 tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
100
101 tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR);
102 tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR);
103 tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR);
104 }
105 }
106
81 void InitResources() { 107 void InitResources() {
82 static bool initialized = false; 108 static bool initialized = false;
83 if (!initialized) { 109 if (!initialized) {
84 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 110 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
85 title_font = rb.GetFont(ResourceBundle::BaseFont); 111 title_font = rb.GetFont(ResourceBundle::BaseFont);
86 title_font_height = title_font.height(); 112 title_font_height = title_font.height();
87 113
88 close_button_n = rb.GetBitmapNamed(IDR_TAB_CLOSE); 114 close_button_n = rb.GetBitmapNamed(IDR_TAB_CLOSE);
89 close_button_h = rb.GetBitmapNamed(IDR_TAB_CLOSE_H); 115 close_button_h = rb.GetBitmapNamed(IDR_TAB_CLOSE_H);
90 close_button_p = rb.GetBitmapNamed(IDR_TAB_CLOSE_P); 116 close_button_p = rb.GetBitmapNamed(IDR_TAB_CLOSE_P);
91 close_button_width = close_button_n->width(); 117 close_button_width = close_button_n->width();
92 close_button_height = close_button_n->height(); 118 close_button_height = close_button_n->height();
93 119
94 tab_active_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_LEFT); 120 tab_active_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_LEFT);
95 tab_active_c = rb.GetBitmapNamed(IDR_TAB_ACTIVE_CENTER); 121 tab_active_c = rb.GetBitmapNamed(IDR_TAB_ACTIVE_CENTER);
96 tab_active_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT); 122 tab_active_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT);
97 tab_active_l_width = tab_active_l->width(); 123 tab_active_l_width = tab_active_l->width();
98 tab_active_r_width = tab_active_r->width(); 124 tab_active_r_width = tab_active_r->width();
99 125
100 if (win_util::ShouldUseVistaFrame()) { 126 LoadTabImages(win_util::ShouldUseVistaFrame());
101 tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
102 tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
103 tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
104
105 // Our Vista frame doesn't change background color to show OTR,
106 // so we continue to use the existing background tabs.
107 tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_V);
108 tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_V);
109 tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_V);
110 } else {
111 tab_inactive_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
112 tab_inactive_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
113 tab_inactive_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
114
115 tab_inactive_otr_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR);
116 tab_inactive_otr_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR);
117 tab_inactive_otr_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR);
118 }
119 127
120 tab_hover_l = rb.GetBitmapNamed(IDR_TAB_HOVER_LEFT); 128 tab_hover_l = rb.GetBitmapNamed(IDR_TAB_HOVER_LEFT);
121 tab_hover_c = rb.GetBitmapNamed(IDR_TAB_HOVER_CENTER); 129 tab_hover_c = rb.GetBitmapNamed(IDR_TAB_HOVER_CENTER);
122 tab_hover_r = rb.GetBitmapNamed(IDR_TAB_HOVER_RIGHT); 130 tab_hover_r = rb.GetBitmapNamed(IDR_TAB_HOVER_RIGHT);
123 131
124 tab_inactive_l_width = tab_inactive_l->width(); 132 tab_inactive_l_width = tab_inactive_l->width();
125 tab_inactive_r_width = tab_inactive_r->width(); 133 tab_inactive_r_width = tab_inactive_r->width();
126 134
127 // The loading animation image is a strip of states. Each state must be 135 // The loading animation image is a strip of states. Each state must be
128 // square, so the height must divide the width evenly. 136 // square, so the height must divide the width evenly.
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 void TabRenderer::OnMouseEntered(const views::MouseEvent& e) { 536 void TabRenderer::OnMouseEntered(const views::MouseEvent& e) {
529 hover_animation_->SetTweenType(SlideAnimation::EASE_OUT); 537 hover_animation_->SetTweenType(SlideAnimation::EASE_OUT);
530 hover_animation_->Show(); 538 hover_animation_->Show();
531 } 539 }
532 540
533 void TabRenderer::OnMouseExited(const views::MouseEvent& e) { 541 void TabRenderer::OnMouseExited(const views::MouseEvent& e) {
534 hover_animation_->SetTweenType(SlideAnimation::EASE_IN); 542 hover_animation_->SetTweenType(SlideAnimation::EASE_IN);
535 hover_animation_->Hide(); 543 hover_animation_->Hide();
536 } 544 }
537 545
546 void TabRenderer::ThemeChanged() {
547 if (GetWidget() && GetWidget()->AsWindow())
548 LoadTabImages(GetWidget()->AsWindow()->UseNativeFrame());
549 View::ThemeChanged();
550 }
551
538 /////////////////////////////////////////////////////////////////////////////// 552 ///////////////////////////////////////////////////////////////////////////////
539 // TabRenderer, AnimationDelegate implementation: 553 // TabRenderer, AnimationDelegate implementation:
540 554
541 void TabRenderer::AnimationProgressed(const Animation* animation) { 555 void TabRenderer::AnimationProgressed(const Animation* animation) {
542 SchedulePaint(); 556 SchedulePaint();
543 } 557 }
544 558
545 void TabRenderer::AnimationCanceled(const Animation* animation) { 559 void TabRenderer::AnimationCanceled(const Animation* animation) {
546 AnimationEnded(animation); 560 AnimationEnded(animation);
547 } 561 }
(...skipping 11 matching lines...) Expand all
559 // as not being selected, so is_drag_clone_ ensures that we always paint 573 // as not being selected, so is_drag_clone_ ensures that we always paint
560 // the active representation for the dragged tab. 574 // the active representation for the dragged tab.
561 PaintActiveTabBackground(canvas); 575 PaintActiveTabBackground(canvas);
562 } else { 576 } else {
563 // Draw our hover state. 577 // Draw our hover state.
564 Animation* animation = hover_animation_.get(); 578 Animation* animation = hover_animation_.get();
565 if (pulse_animation_->IsAnimating()) 579 if (pulse_animation_->IsAnimating())
566 animation = pulse_animation_.get(); 580 animation = pulse_animation_.get();
567 if (animation->GetCurrentValue() > 0) { 581 if (animation->GetCurrentValue() > 0) {
568 PaintHoverTabBackground(canvas, animation->GetCurrentValue() * 582 PaintHoverTabBackground(canvas, animation->GetCurrentValue() *
569 (win_util::ShouldUseVistaFrame() ? 583 (GetWidget()->AsWindow()->UseNativeFrame() ?
570 kHoverOpacityVista : kHoverOpacity)); 584 kHoverOpacityVista : kHoverOpacity));
571 } else { 585 } else {
572 PaintInactiveTabBackground(canvas); 586 PaintInactiveTabBackground(canvas);
573 } 587 }
574 } 588 }
575 } 589 }
576 590
577 void TabRenderer::PaintInactiveTabBackground(ChromeCanvas* canvas) { 591 void TabRenderer::PaintInactiveTabBackground(ChromeCanvas* canvas) {
578 bool is_otr = data_.off_the_record; 592 bool is_otr = data_.off_the_record;
579 canvas->DrawBitmapInt(is_otr ? *tab_inactive_otr_l : *tab_inactive_l, 0, 0); 593 canvas->DrawBitmapInt(is_otr ? *tab_inactive_otr_l : *tab_inactive_l, 0, 0);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 694 }
681 695
682 void TabRenderer::DisplayCrashedFavIcon() { 696 void TabRenderer::DisplayCrashedFavIcon() {
683 should_display_crashed_favicon_ = true; 697 should_display_crashed_favicon_ = true;
684 } 698 }
685 699
686 void TabRenderer::ResetCrashedFavIcon() { 700 void TabRenderer::ResetCrashedFavIcon() {
687 should_display_crashed_favicon_ = false; 701 should_display_crashed_favicon_ = false;
688 } 702 }
689 703
OLDNEW
« no previous file with comments | « chrome/browser/views/tabs/tab_renderer.h ('k') | chrome/browser/views/tabs/tab_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698