| 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/app_list/views/page_switcher.h" | 5 #include "ui/app_list/views/page_switcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "third_party/skia/include/core/SkPath.h" | 10 #include "third_party/skia/include/core/SkPath.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Paints a button that has two rounded corner at bottom. | 76 // Paints a button that has two rounded corner at bottom. |
| 77 void PaintButton(gfx::Canvas* canvas, SkColor base_color) { | 77 void PaintButton(gfx::Canvas* canvas, SkColor base_color) { |
| 78 gfx::Rect rect(GetContentsBounds()); | 78 gfx::Rect rect(GetContentsBounds()); |
| 79 rect.ClampToCenteredSize(gfx::Size(button_width_, kButtonHeight)); | 79 rect.ClampToCenteredSize(gfx::Size(button_width_, kButtonHeight)); |
| 80 | 80 |
| 81 SkPath path; | 81 SkPath path; |
| 82 path.addRoundRect(gfx::RectToSkRect(rect), | 82 path.addRoundRect(gfx::RectToSkRect(rect), |
| 83 SkIntToScalar(kButtonCornerRadius), | 83 SkIntToScalar(kButtonCornerRadius), |
| 84 SkIntToScalar(kButtonCornerRadius)); | 84 SkIntToScalar(kButtonCornerRadius)); |
| 85 | 85 |
| 86 SkPaint paint; | 86 cc::PaintFlags flags; |
| 87 paint.setAntiAlias(true); | 87 flags.setAntiAlias(true); |
| 88 paint.setStyle(SkPaint::kFill_Style); | 88 flags.setStyle(cc::PaintFlags::kFill_Style); |
| 89 paint.setColor(base_color); | 89 flags.setColor(base_color); |
| 90 canvas->DrawPath(path, paint); | 90 canvas->DrawPath(path, flags); |
| 91 | 91 |
| 92 int selected_start_x = 0; | 92 int selected_start_x = 0; |
| 93 int selected_width = 0; | 93 int selected_width = 0; |
| 94 if (selected_range_ > 0) { | 94 if (selected_range_ > 0) { |
| 95 selected_width = selected_range_ * rect.width(); | 95 selected_width = selected_range_ * rect.width(); |
| 96 } else if (selected_range_ < 0) { | 96 } else if (selected_range_ < 0) { |
| 97 selected_width = -selected_range_ * rect.width(); | 97 selected_width = -selected_range_ * rect.width(); |
| 98 selected_start_x = rect.right() - selected_width; | 98 selected_start_x = rect.right() - selected_width; |
| 99 } | 99 } |
| 100 | 100 |
| 101 if (selected_width) { | 101 if (selected_width) { |
| 102 gfx::Rect selected_rect(rect); | 102 gfx::Rect selected_rect(rect); |
| 103 selected_rect.set_x(selected_start_x); | 103 selected_rect.set_x(selected_start_x); |
| 104 selected_rect.set_width(selected_width); | 104 selected_rect.set_width(selected_width); |
| 105 | 105 |
| 106 SkPath selected_path; | 106 SkPath selected_path; |
| 107 selected_path.addRoundRect(gfx::RectToSkRect(selected_rect), | 107 selected_path.addRoundRect(gfx::RectToSkRect(selected_rect), |
| 108 SkIntToScalar(kButtonCornerRadius), | 108 SkIntToScalar(kButtonCornerRadius), |
| 109 SkIntToScalar(kButtonCornerRadius)); | 109 SkIntToScalar(kButtonCornerRadius)); |
| 110 paint.setColor(kPagerSelectedColor); | 110 flags.setColor(kPagerSelectedColor); |
| 111 canvas->DrawPath(selected_path, paint); | 111 canvas->DrawPath(selected_path, flags); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 int button_width_; | 115 int button_width_; |
| 116 | 116 |
| 117 // [-1, 1] range that represents the portion of the button that should be | 117 // [-1, 1] range that represents the portion of the button that should be |
| 118 // painted with kSelectedColor. Positive range starts from left side and | 118 // painted with kSelectedColor. Positive range starts from left side and |
| 119 // negative range starts from the right side. | 119 // negative range starts from the right side. |
| 120 double selected_range_; | 120 double selected_range_; |
| 121 | 121 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 remaining = -remaining; | 270 remaining = -remaining; |
| 271 progress = -progress; | 271 progress = -progress; |
| 272 } | 272 } |
| 273 | 273 |
| 274 GetButtonByIndex(buttons_, current_page)->SetSelectedRange(remaining); | 274 GetButtonByIndex(buttons_, current_page)->SetSelectedRange(remaining); |
| 275 if (model_->is_valid_page(target_page)) | 275 if (model_->is_valid_page(target_page)) |
| 276 GetButtonByIndex(buttons_, target_page)->SetSelectedRange(progress); | 276 GetButtonByIndex(buttons_, target_page)->SetSelectedRange(progress); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace app_list | 279 } // namespace app_list |
| OLD | NEW |