| 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/sad_tab_view.h" | 5 #include "chrome/browser/views/sad_tab_view.h" |
| 6 | 6 |
| 7 #include "base/gfx/size.h" | 7 #include "base/gfx/size.h" |
| 8 #include "chrome/app/theme/theme_resources.h" | 8 #include "chrome/app/theme/theme_resources.h" |
| 9 #include "chrome/common/gfx/chrome_canvas.h" | 9 #include "chrome/common/gfx/chrome_canvas.h" |
| 10 #include "chrome/common/l10n_util.h" | 10 #include "chrome/common/l10n_util.h" |
| 11 #include "chrome/common/resource_bundle.h" | 11 #include "chrome/common/resource_bundle.h" |
| 12 #include "generated_resources.h" | 12 #include "generated_resources.h" |
| 13 #include "skia/ext/skia_utils.h" |
| 13 #include "skia/include/SkGradientShader.h" | 14 #include "skia/include/SkGradientShader.h" |
| 14 | 15 |
| 15 static const int kSadTabOffset = -64; | 16 static const int kSadTabOffset = -64; |
| 16 static const int kIconTitleSpacing = 20; | 17 static const int kIconTitleSpacing = 20; |
| 17 static const int kTitleMessageSpacing = 15; | 18 static const int kTitleMessageSpacing = 15; |
| 18 static const int kMessageBottomMargin = 20; | 19 static const int kMessageBottomMargin = 20; |
| 19 static const float kMessageSize = 0.65f; | 20 static const float kMessageSize = 0.65f; |
| 20 static const SkColor kTitleColor = SK_ColorWHITE; | 21 static const SkColor kTitleColor = SK_ColorWHITE; |
| 21 static const SkColor kMessageColor = SK_ColorWHITE; | 22 static const SkColor kMessageColor = SK_ColorWHITE; |
| 22 static const SkColor kBackgroundColor = SkColorSetRGB(35, 48, 64); | 23 static const SkColor kBackgroundColor = SkColorSetRGB(35, 48, 64); |
| 23 static const SkColor kBackgroundEndColor = SkColorSetRGB(35, 48, 64); | 24 static const SkColor kBackgroundEndColor = SkColorSetRGB(35, 48, 64); |
| 24 | 25 |
| 25 // static | 26 // static |
| 26 SkBitmap* SadTabView::sad_tab_bitmap_ = NULL; | 27 SkBitmap* SadTabView::sad_tab_bitmap_ = NULL; |
| 27 ChromeFont SadTabView::title_font_; | 28 ChromeFont SadTabView::title_font_; |
| 28 ChromeFont SadTabView::message_font_; | 29 ChromeFont SadTabView::message_font_; |
| 29 std::wstring SadTabView::title_; | 30 std::wstring SadTabView::title_; |
| 30 std::wstring SadTabView::message_; | 31 std::wstring SadTabView::message_; |
| 31 int SadTabView::title_width_; | 32 int SadTabView::title_width_; |
| 32 | 33 |
| 33 SadTabView::SadTabView() { | 34 SadTabView::SadTabView() { |
| 34 InitClass(); | 35 InitClass(); |
| 35 } | 36 } |
| 36 | 37 |
| 37 static SkShader* CreateGradientShader(int end_point) { | |
| 38 SkColor grad_colors[2] = { kBackgroundColor, kBackgroundEndColor }; | |
| 39 SkPoint grad_points[2]; | |
| 40 grad_points[0].set(SkIntToScalar(0), SkIntToScalar(0)); | |
| 41 grad_points[1].set(SkIntToScalar(0), SkIntToScalar(end_point)); | |
| 42 return SkGradientShader::CreateLinear( | |
| 43 grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode); | |
| 44 } | |
| 45 | |
| 46 void SadTabView::Paint(ChromeCanvas* canvas) { | 38 void SadTabView::Paint(ChromeCanvas* canvas) { |
| 47 SkShader* background_shader = CreateGradientShader(height()); | 39 SkShader* background_shader = skia::CreateGradientShader( |
| 40 0, height(), kBackgroundColor, kBackgroundEndColor); |
| 48 SkPaint paint; | 41 SkPaint paint; |
| 49 paint.setShader(background_shader); | 42 paint.setShader(background_shader); |
| 50 background_shader->unref(); | 43 background_shader->unref(); |
| 51 paint.setStyle(SkPaint::kFill_Style); | 44 paint.setStyle(SkPaint::kFill_Style); |
| 52 canvas->drawRectCoords(0, 0, | 45 canvas->drawRectCoords(0, 0, |
| 53 SkIntToScalar(width()), SkIntToScalar(height()), | 46 SkIntToScalar(width()), SkIntToScalar(height()), |
| 54 paint); | 47 paint); |
| 55 | 48 |
| 56 canvas->DrawBitmapInt(*sad_tab_bitmap_, icon_bounds_.x(), icon_bounds_.y()); | 49 canvas->DrawBitmapInt(*sad_tab_bitmap_, icon_bounds_.x(), icon_bounds_.y()); |
| 57 | 50 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 93 |
| 101 title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE); | 94 title_ = l10n_util::GetString(IDS_SAD_TAB_TITLE); |
| 102 title_width_ = title_font_.GetStringWidth(title_); | 95 title_width_ = title_font_.GetStringWidth(title_); |
| 103 message_ = l10n_util::GetString(IDS_SAD_TAB_MESSAGE); | 96 message_ = l10n_util::GetString(IDS_SAD_TAB_MESSAGE); |
| 104 | 97 |
| 105 initialized = true; | 98 initialized = true; |
| 106 } | 99 } |
| 107 } | 100 } |
| 108 | 101 |
| 109 | 102 |
| OLD | NEW |