| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/controls/progress_bar.h" | 5 #include "views/controls/progress_bar.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 p[1].set(SkIntToScalar(x + w), SkIntToScalar(y)); | 74 p[1].set(SkIntToScalar(x + w), SkIntToScalar(y)); |
| 75 } else { | 75 } else { |
| 76 p[1].set(SkIntToScalar(x), SkIntToScalar(y + h)); | 76 p[1].set(SkIntToScalar(x), SkIntToScalar(y + h)); |
| 77 } | 77 } |
| 78 SkShader* s = SkGradientShader::CreateLinear( | 78 SkShader* s = SkGradientShader::CreateLinear( |
| 79 p, colors, points, count, SkShader::kClamp_TileMode, NULL); | 79 p, colors, points, count, SkShader::kClamp_TileMode, NULL); |
| 80 paint.setShader(s); | 80 paint.setShader(s); |
| 81 // Need to unref shader, otherwise never deleted. | 81 // Need to unref shader, otherwise never deleted. |
| 82 s->unref(); | 82 s->unref(); |
| 83 | 83 |
| 84 canvas->AsCanvasSkia()->drawPath(path, paint); | 84 canvas->AsCanvasSkia()->skia_canvas()->drawPath(path, paint); |
| 85 } | 85 } |
| 86 | 86 |
| 87 static void FillRoundRect(gfx::Canvas* canvas, | 87 static void FillRoundRect(gfx::Canvas* canvas, |
| 88 int x, int y, | 88 int x, int y, |
| 89 int w, int h, | 89 int w, int h, |
| 90 int corner_radius, | 90 int corner_radius, |
| 91 SkColor gradient_start_color, | 91 SkColor gradient_start_color, |
| 92 SkColor gradient_end_color, | 92 SkColor gradient_end_color, |
| 93 bool gradient_horizontal) { | 93 bool gradient_horizontal) { |
| 94 if (gradient_start_color != gradient_end_color) { | 94 if (gradient_start_color != gradient_end_color) { |
| 95 SkColor colors[2] = { gradient_start_color, gradient_end_color }; | 95 SkColor colors[2] = { gradient_start_color, gradient_end_color }; |
| 96 FillRoundRect(canvas, x, y, w, h, corner_radius, | 96 FillRoundRect(canvas, x, y, w, h, corner_radius, |
| 97 colors, NULL, 2, gradient_horizontal); | 97 colors, NULL, 2, gradient_horizontal); |
| 98 } else { | 98 } else { |
| 99 SkPath path; | 99 SkPath path; |
| 100 AddRoundRectPath(x, y, w, h, corner_radius, &path); | 100 AddRoundRectPath(x, y, w, h, corner_radius, &path); |
| 101 SkPaint paint; | 101 SkPaint paint; |
| 102 paint.setStyle(SkPaint::kFill_Style); | 102 paint.setStyle(SkPaint::kFill_Style); |
| 103 paint.setFlags(SkPaint::kAntiAlias_Flag); | 103 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 104 paint.setColor(gradient_start_color); | 104 paint.setColor(gradient_start_color); |
| 105 canvas->AsCanvasSkia()->drawPath(path, paint); | 105 canvas->AsCanvasSkia()->skia_canvas()->drawPath(path, paint); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 static void StrokeRoundRect(gfx::Canvas* canvas, | 109 static void StrokeRoundRect(gfx::Canvas* canvas, |
| 110 int x, int y, | 110 int x, int y, |
| 111 int w, int h, | 111 int w, int h, |
| 112 int corner_radius, | 112 int corner_radius, |
| 113 SkColor stroke_color, | 113 SkColor stroke_color, |
| 114 int stroke_width) { | 114 int stroke_width) { |
| 115 SkPath path; | 115 SkPath path; |
| 116 AddRoundRectPath(x, y, w, h, corner_radius, &path); | 116 AddRoundRectPath(x, y, w, h, corner_radius, &path); |
| 117 SkPaint paint; | 117 SkPaint paint; |
| 118 paint.setShader(NULL); | 118 paint.setShader(NULL); |
| 119 paint.setColor(stroke_color); | 119 paint.setColor(stroke_color); |
| 120 paint.setStyle(SkPaint::kStroke_Style); | 120 paint.setStyle(SkPaint::kStroke_Style); |
| 121 paint.setFlags(SkPaint::kAntiAlias_Flag); | 121 paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 122 paint.setStrokeWidth(SkIntToScalar(stroke_width)); | 122 paint.setStrokeWidth(SkIntToScalar(stroke_width)); |
| 123 canvas->AsCanvasSkia()->drawPath(path, paint); | 123 canvas->AsCanvasSkia()->skia_canvas()->drawPath(path, paint); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // anonymous namespace | 126 } // anonymous namespace |
| 127 | 127 |
| 128 namespace views { | 128 namespace views { |
| 129 | 129 |
| 130 // static | 130 // static |
| 131 const char ProgressBar::kViewClassName[] = "views/ProgressBar"; | 131 const char ProgressBar::kViewClassName[] = "views/ProgressBar"; |
| 132 // static: progress bar's maximum value. | 132 // static: progress bar's maximum value. |
| 133 const int ProgressBar::kMaxProgress = 100; | 133 const int ProgressBar::kMaxProgress = 100; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 View::SetEnabled(enabled); | 310 View::SetEnabled(enabled); |
| 311 // TODO(denisromanov): Need to switch progress bar color here? | 311 // TODO(denisromanov): Need to switch progress bar color here? |
| 312 } | 312 } |
| 313 | 313 |
| 314 void ProgressBar::GetAccessibleState(ui::AccessibleViewState* state) { | 314 void ProgressBar::GetAccessibleState(ui::AccessibleViewState* state) { |
| 315 state->role = ui::AccessibilityTypes::ROLE_PROGRESSBAR; | 315 state->role = ui::AccessibilityTypes::ROLE_PROGRESSBAR; |
| 316 state->state = ui::AccessibilityTypes::STATE_READONLY; | 316 state->state = ui::AccessibilityTypes::STATE_READONLY; |
| 317 } | 317 } |
| 318 | 318 |
| 319 } // namespace views | 319 } // namespace views |
| OLD | NEW |