| 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
| 6 | 6 |
| 7 #include "chrome/browser/download/download_shelf.h" | 7 #include "chrome/browser/download/download_shelf.h" |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 const base::TimeDelta& progress_time, | 77 const base::TimeDelta& progress_time, |
| 78 int percent_done) { | 78 int percent_done) { |
| 79 // Draw background (light blue circle). | 79 // Draw background (light blue circle). |
| 80 SkPaint bg_paint; | 80 SkPaint bg_paint; |
| 81 bg_paint.setStyle(SkPaint::kFill_Style); | 81 bg_paint.setStyle(SkPaint::kFill_Style); |
| 82 SkColor indicator_color = | 82 SkColor indicator_color = |
| 83 theme_provider.GetColor(ThemeProperties::COLOR_THROBBER_SPINNING); | 83 theme_provider.GetColor(ThemeProperties::COLOR_THROBBER_SPINNING); |
| 84 bg_paint.setColor(SkColorSetA(indicator_color, 0x33)); | 84 bg_paint.setColor(SkColorSetA(indicator_color, 0x33)); |
| 85 bg_paint.setAntiAlias(true); | 85 bg_paint.setAntiAlias(true); |
| 86 const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f; | 86 const SkScalar kCenterPoint = kProgressIndicatorSize / 2.f; |
| 87 const SkScalar kRadius = 12.5f; | |
| 88 SkPath bg; | 87 SkPath bg; |
| 89 bg.addCircle(kCenterPoint, kCenterPoint, kRadius); | 88 bg.addCircle(kCenterPoint, kCenterPoint, kCenterPoint); |
| 90 canvas->DrawPath(bg, bg_paint); | 89 canvas->DrawPath(bg, bg_paint); |
| 91 | 90 |
| 92 // Calculate progress. | 91 // Calculate progress. |
| 93 SkScalar sweep_angle = 0.f; | 92 SkScalar sweep_angle = 0.f; |
| 94 // Start at 12 o'clock. | 93 // Start at 12 o'clock. |
| 95 SkScalar start_pos = SkIntToScalar(270); | 94 SkScalar start_pos = SkIntToScalar(270); |
| 96 if (percent_done < 0) { | 95 if (percent_done < 0) { |
| 97 // For unknown size downloads, draw a 50 degree sweep that moves at | 96 // For unknown size downloads, draw a 50 degree sweep that moves at |
| 98 // 0.08 degrees per millisecond. | 97 // 0.08 degrees per millisecond. |
| 99 sweep_angle = 50.f; | 98 sweep_angle = 50.f; |
| 100 start_pos += static_cast<SkScalar>(progress_time.InMilliseconds() * 0.08); | 99 start_pos += static_cast<SkScalar>(progress_time.InMilliseconds() * 0.08); |
| 101 } else if (percent_done > 0) { | 100 } else if (percent_done > 0) { |
| 102 sweep_angle = static_cast<SkScalar>(360 * percent_done / 100.0); | 101 sweep_angle = static_cast<SkScalar>(360 * percent_done / 100.0); |
| 103 } | 102 } |
| 104 | 103 |
| 105 // Draw progress. | 104 // Draw progress. |
| 106 SkPath progress; | 105 SkPath progress; |
| 107 progress.addArc(SkRect::MakeLTRB(kCenterPoint - kRadius, | 106 progress.addArc( |
| 108 kCenterPoint - kRadius, | 107 SkRect::MakeLTRB(0, 0, kProgressIndicatorSize, kProgressIndicatorSize), |
| 109 kCenterPoint + kRadius, | 108 start_pos, sweep_angle); |
| 110 kCenterPoint + kRadius), | |
| 111 start_pos, sweep_angle); | |
| 112 SkPaint progress_paint; | 109 SkPaint progress_paint; |
| 113 progress_paint.setColor(indicator_color); | 110 progress_paint.setColor(indicator_color); |
| 114 progress_paint.setStyle(SkPaint::kStroke_Style); | 111 progress_paint.setStyle(SkPaint::kStroke_Style); |
| 115 progress_paint.setStrokeWidth(1.7f); | 112 progress_paint.setStrokeWidth(1.7f); |
| 116 progress_paint.setAntiAlias(true); | 113 progress_paint.setAntiAlias(true); |
| 117 canvas->DrawPath(progress, progress_paint); | 114 canvas->DrawPath(progress, progress_paint); |
| 118 } | 115 } |
| 119 | 116 |
| 120 // static | 117 // static |
| 121 void DownloadShelf::PaintDownloadComplete( | 118 void DownloadShelf::PaintDownloadComplete( |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 content::DownloadManager* download_manager = GetDownloadManager(); | 233 content::DownloadManager* download_manager = GetDownloadManager(); |
| 237 if (!download_manager) | 234 if (!download_manager) |
| 238 return; | 235 return; |
| 239 | 236 |
| 240 DownloadItem* download = download_manager->GetDownload(download_id); | 237 DownloadItem* download = download_manager->GetDownload(download_id); |
| 241 if (!download) | 238 if (!download) |
| 242 return; | 239 return; |
| 243 | 240 |
| 244 ShowDownload(download); | 241 ShowDownload(download); |
| 245 } | 242 } |
| OLD | NEW |