| 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 <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" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 static const int kHoverDurationMs = 90; | 39 static const int kHoverDurationMs = 90; |
| 40 | 40 |
| 41 // How long the pulse throb takes. | 41 // How long the pulse throb takes. |
| 42 static const int kPulseDurationMs = 200; | 42 static const int kPulseDurationMs = 200; |
| 43 | 43 |
| 44 // How opaque to make the hover state (out of 1). | 44 // How opaque to make the hover state (out of 1). |
| 45 static const double kHoverOpacity = 0.33; | 45 static const double kHoverOpacity = 0.33; |
| 46 static const double kHoverOpacityVista = 0.7; | 46 static const double kHoverOpacityVista = 0.7; |
| 47 | 47 |
| 48 // TODO(beng): (Cleanup) This stuff should move onto the class. | 48 // TODO(beng): (Cleanup) This stuff should move onto the class. |
| 49 static ChromeFont title_font; | 49 static ChromeFont* title_font = NULL; |
| 50 static int title_font_height = 0; | 50 static int title_font_height = 0; |
| 51 static SkBitmap* close_button_n = NULL; | 51 static SkBitmap* close_button_n = NULL; |
| 52 static SkBitmap* close_button_h = NULL; | 52 static SkBitmap* close_button_h = NULL; |
| 53 static SkBitmap* close_button_p = NULL; | 53 static SkBitmap* close_button_p = NULL; |
| 54 static int close_button_height = 0; | 54 static int close_button_height = 0; |
| 55 static int close_button_width = 0; | 55 static int close_button_width = 0; |
| 56 static SkBitmap* waiting_animation_frames = NULL; | 56 static SkBitmap* waiting_animation_frames = NULL; |
| 57 static SkBitmap* loading_animation_frames = NULL; | 57 static SkBitmap* loading_animation_frames = NULL; |
| 58 static SkBitmap* crashed_fav_icon = NULL; | 58 static SkBitmap* crashed_fav_icon = NULL; |
| 59 static int loading_animation_frame_count = 0; | 59 static int loading_animation_frame_count = 0; |
| 60 static int waiting_animation_frame_count = 0; | 60 static int waiting_animation_frame_count = 0; |
| 61 static int waiting_to_loading_frame_count_ratio = 0; | 61 static int waiting_to_loading_frame_count_ratio = 0; |
| 62 static SkBitmap* download_icon = NULL; | 62 static SkBitmap* download_icon = NULL; |
| 63 static int download_icon_width = 0; | 63 static int download_icon_width = 0; |
| 64 static int download_icon_height = 0; | 64 static int download_icon_height = 0; |
| 65 | 65 |
| 66 TabRenderer::TabImage TabRenderer::tab_active = {0}; | 66 TabRenderer::TabImage TabRenderer::tab_active = {0}; |
| 67 TabRenderer::TabImage TabRenderer::tab_inactive = {0}; | 67 TabRenderer::TabImage TabRenderer::tab_inactive = {0}; |
| 68 TabRenderer::TabImage TabRenderer::tab_inactive_otr = {0}; | 68 TabRenderer::TabImage TabRenderer::tab_inactive_otr = {0}; |
| 69 TabRenderer::TabImage TabRenderer::tab_hover = {0}; | 69 TabRenderer::TabImage TabRenderer::tab_hover = {0}; |
| 70 | 70 |
| 71 namespace { | 71 namespace { |
| 72 | 72 |
| 73 void InitResources() { | 73 void InitResources() { |
| 74 static bool initialized = false; | 74 static bool initialized = false; |
| 75 if (!initialized) { | 75 if (!initialized) { |
| 76 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 76 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 77 title_font = rb.GetFont(ResourceBundle::BaseFont); | 77 title_font = new ChromeFont(rb.GetFont(ResourceBundle::BaseFont)); |
| 78 title_font_height = title_font.height(); | 78 title_font_height = title_font->height(); |
| 79 | 79 |
| 80 close_button_n = rb.GetBitmapNamed(IDR_TAB_CLOSE); | 80 close_button_n = rb.GetBitmapNamed(IDR_TAB_CLOSE); |
| 81 close_button_h = rb.GetBitmapNamed(IDR_TAB_CLOSE_H); | 81 close_button_h = rb.GetBitmapNamed(IDR_TAB_CLOSE_H); |
| 82 close_button_p = rb.GetBitmapNamed(IDR_TAB_CLOSE_P); | 82 close_button_p = rb.GetBitmapNamed(IDR_TAB_CLOSE_P); |
| 83 close_button_width = close_button_n->width(); | 83 close_button_width = close_button_n->width(); |
| 84 close_button_height = close_button_n->height(); | 84 close_button_height = close_button_n->height(); |
| 85 | 85 |
| 86 TabRenderer::LoadTabImages(win_util::ShouldUseVistaFrame()); | 86 TabRenderer::LoadTabImages(win_util::ShouldUseVistaFrame()); |
| 87 | 87 |
| 88 // The loading animation image is a strip of states. Each state must be | 88 // The loading animation image is a strip of states. Each state must be |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 title = l10n_util::GetString(IDS_TAB_LOADING_TITLE); | 406 title = l10n_util::GetString(IDS_TAB_LOADING_TITLE); |
| 407 } else { | 407 } else { |
| 408 title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE); | 408 title = l10n_util::GetString(IDS_TAB_UNTITLED_TITLE); |
| 409 } | 409 } |
| 410 } else { | 410 } else { |
| 411 Browser::FormatTitleForDisplay(&title); | 411 Browser::FormatTitleForDisplay(&title); |
| 412 } | 412 } |
| 413 | 413 |
| 414 SkColor title_color = IsSelected() ? kSelectedTitleColor | 414 SkColor title_color = IsSelected() ? kSelectedTitleColor |
| 415 : kUnselectedTitleColor; | 415 : kUnselectedTitleColor; |
| 416 canvas->DrawStringInt(title, title_font, title_color, title_bounds_.x(), | 416 canvas->DrawStringInt(title, *title_font, title_color, title_bounds_.x(), |
| 417 title_bounds_.y(), title_bounds_.width(), | 417 title_bounds_.y(), title_bounds_.width(), |
| 418 title_bounds_.height()); | 418 title_bounds_.height()); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void TabRenderer::Layout() { | 421 void TabRenderer::Layout() { |
| 422 gfx::Rect lb = GetLocalBounds(false); | 422 gfx::Rect lb = GetLocalBounds(false); |
| 423 if (lb.IsEmpty()) | 423 if (lb.IsEmpty()) |
| 424 return; | 424 return; |
| 425 lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); | 425 lb.Inset(kLeftPadding, kTopPadding, kRightPadding, kBottomPadding); |
| 426 | 426 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 tab_inactive_otr.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR); | 699 tab_inactive_otr.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT_OTR); |
| 700 tab_inactive_otr.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR); | 700 tab_inactive_otr.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER_OTR); |
| 701 tab_inactive_otr.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR); | 701 tab_inactive_otr.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT_OTR); |
| 702 } | 702 } |
| 703 | 703 |
| 704 tab_inactive.l_width = tab_inactive.image_l->width(); | 704 tab_inactive.l_width = tab_inactive.image_l->width(); |
| 705 tab_inactive.r_width = tab_inactive.image_r->width(); | 705 tab_inactive.r_width = tab_inactive.image_r->width(); |
| 706 // tab_[hover,inactive_otr] width are not used and are initialized to 0 | 706 // tab_[hover,inactive_otr] width are not used and are initialized to 0 |
| 707 // during static initialization. | 707 // during static initialization. |
| 708 } | 708 } |
| OLD | NEW |