| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/style/mac/combobox_background_mac.h" | 5 #include "ui/views/style/mac/combobox_background_mac.h" |
| 6 | 6 |
| 7 #include "third_party/skia/include/core/SkPath.h" | 7 #include "third_party/skia/include/core/SkPath.h" |
| 8 #include "third_party/skia/include/core/SkRRect.h" | 8 #include "third_party/skia/include/core/SkRRect.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/native_theme/native_theme_mac.h" | 10 #include "ui/native_theme/native_theme_mac.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 gfx::RectF bounds(combobox->GetLocalBounds()); | 24 gfx::RectF bounds(combobox->GetLocalBounds()); |
| 25 // Inset the left side far enough to draw only the arrow button, and inset the | 25 // Inset the left side far enough to draw only the arrow button, and inset the |
| 26 // other three sides by half a pixel so the edge of the background doesn't | 26 // other three sides by half a pixel so the edge of the background doesn't |
| 27 // paint outside the border. | 27 // paint outside the border. |
| 28 bounds.Inset(bounds.width() - combobox->GetArrowButtonWidth(), 0.5, 0.5, 0.5); | 28 bounds.Inset(bounds.width() - combobox->GetArrowButtonWidth(), 0.5, 0.5, 0.5); |
| 29 | 29 |
| 30 ui::NativeTheme::State state = ui::NativeTheme::kNormal; | 30 ui::NativeTheme::State state = ui::NativeTheme::kNormal; |
| 31 if (!combobox->enabled()) | 31 if (!combobox->enabled()) |
| 32 state = ui::NativeTheme::kDisabled; | 32 state = ui::NativeTheme::kDisabled; |
| 33 | 33 |
| 34 skia::RefPtr<SkShader> shader = | 34 SkPaint paint; |
| 35 paint.setShader( |
| 35 ui::NativeThemeMac::GetButtonBackgroundShader( | 36 ui::NativeThemeMac::GetButtonBackgroundShader( |
| 36 state, | 37 state, |
| 37 bounds.height()); | 38 bounds.height())); |
| 38 SkPaint paint; | |
| 39 paint.setShader(shader.get()); | |
| 40 paint.setStyle(SkPaint::kFill_Style); | 39 paint.setStyle(SkPaint::kFill_Style); |
| 41 paint.setAntiAlias(true); | 40 paint.setAntiAlias(true); |
| 42 | 41 |
| 43 SkPoint no_curve = SkPoint::Make(0, 0); | 42 SkPoint no_curve = SkPoint::Make(0, 0); |
| 44 SkPoint curve = SkPoint::Make( | 43 SkPoint curve = SkPoint::Make( |
| 45 ui::NativeThemeMac::kComboboxCornerRadius, | 44 ui::NativeThemeMac::kComboboxCornerRadius, |
| 46 ui::NativeThemeMac::kComboboxCornerRadius); | 45 ui::NativeThemeMac::kComboboxCornerRadius); |
| 47 SkVector curves[4] = { no_curve, curve, curve, no_curve }; | 46 SkVector curves[4] = { no_curve, curve, curve, no_curve }; |
| 48 | 47 |
| 49 SkRRect fill_rect; | 48 SkRRect fill_rect; |
| 50 fill_rect.setRectRadii(gfx::RectFToSkRect(bounds), curves); | 49 fill_rect.setRectRadii(gfx::RectFToSkRect(bounds), curves); |
| 51 | 50 |
| 52 SkPath path; | 51 SkPath path; |
| 53 path.addRRect(fill_rect); | 52 path.addRRect(fill_rect); |
| 54 | 53 |
| 55 canvas->DrawPath(path, paint); | 54 canvas->DrawPath(path, paint); |
| 56 } | 55 } |
| 57 | 56 |
| 58 } // namespace views | 57 } // namespace views |
| OLD | NEW |