| 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 #include "ui/views/controls/progress_bar.h" | 5 #include "ui/views/controls/progress_bar.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "third_party/skia/include/core/SkPaint.h" | 13 #include "third_party/skia/include/core/SkPaint.h" |
| 14 #include "third_party/skia/include/core/SkPath.h" | 14 #include "third_party/skia/include/core/SkPath.h" |
| 15 #include "third_party/skia/include/core/SkXfermode.h" | 15 #include "third_party/skia/include/core/SkXfermode.h" |
| 16 #include "third_party/skia/include/effects/SkGradientShader.h" | 16 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 17 #include "ui/accessibility/ax_view_state.h" | 17 #include "ui/accessibility/ax_node_data.h" |
| 18 #include "ui/gfx/animation/linear_animation.h" | 18 #include "ui/gfx/animation/linear_animation.h" |
| 19 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 20 #include "ui/gfx/color_utils.h" | 20 #include "ui/gfx/color_utils.h" |
| 21 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
| 22 | 22 |
| 23 namespace views { | 23 namespace views { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // In DP, the amount to round the corners of the progress bar (both bg and | 27 // In DP, the amount to round the corners of the progress bar (both bg and |
| (...skipping 14 matching lines...) Expand all Loading... |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 const char ProgressBar::kViewClassName[] = "ProgressBar"; | 44 const char ProgressBar::kViewClassName[] = "ProgressBar"; |
| 45 | 45 |
| 46 ProgressBar::ProgressBar(int preferred_height) | 46 ProgressBar::ProgressBar(int preferred_height) |
| 47 : preferred_height_(preferred_height) {} | 47 : preferred_height_(preferred_height) {} |
| 48 | 48 |
| 49 ProgressBar::~ProgressBar() { | 49 ProgressBar::~ProgressBar() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 void ProgressBar::GetAccessibleState(ui::AXViewState* state) { | 52 void ProgressBar::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 53 state->role = ui::AX_ROLE_PROGRESS_INDICATOR; | 53 node_data->role = ui::AX_ROLE_PROGRESS_INDICATOR; |
| 54 state->AddStateFlag(ui::AX_STATE_READ_ONLY); | 54 node_data->AddStateFlag(ui::AX_STATE_READ_ONLY); |
| 55 } | 55 } |
| 56 | 56 |
| 57 gfx::Size ProgressBar::GetPreferredSize() const { | 57 gfx::Size ProgressBar::GetPreferredSize() const { |
| 58 // The width will typically be ignored. | 58 // The width will typically be ignored. |
| 59 gfx::Size pref_size(1, preferred_height_); | 59 gfx::Size pref_size(1, preferred_height_); |
| 60 gfx::Insets insets = GetInsets(); | 60 gfx::Insets insets = GetInsets(); |
| 61 pref_size.Enlarge(insets.width(), insets.height()); | 61 pref_size.Enlarge(insets.width(), insets.height()); |
| 62 return pref_size; | 62 return pref_size; |
| 63 } | 63 } |
| 64 | 64 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 AddPossiblyRoundRectToPath(slice_bounds, &slice_path); | 199 AddPossiblyRoundRectToPath(slice_bounds, &slice_path); |
| 200 | 200 |
| 201 SkPaint slice_paint; | 201 SkPaint slice_paint; |
| 202 slice_paint.setStyle(SkPaint::kFill_Style); | 202 slice_paint.setStyle(SkPaint::kFill_Style); |
| 203 slice_paint.setFlags(SkPaint::kAntiAlias_Flag); | 203 slice_paint.setFlags(SkPaint::kAntiAlias_Flag); |
| 204 slice_paint.setColor(GetForegroundColor()); | 204 slice_paint.setColor(GetForegroundColor()); |
| 205 canvas->DrawPath(slice_path, slice_paint); | 205 canvas->DrawPath(slice_path, slice_paint); |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace views | 208 } // namespace views |
| OLD | NEW |