Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/views/style/mac/combobox_background_mac.h" | |
| 6 | |
| 7 #include "third_party/skia/include/core/SkPath.h" | |
| 8 #include "third_party/skia/include/core/SkRRect.h" | |
| 9 #include "ui/gfx/canvas.h" | |
| 10 #include "ui/native_theme/native_theme_mac.h" | |
| 11 #include "ui/views/controls/combobox/combobox.h" | |
| 12 #include "ui/views/view.h" | |
| 13 | |
| 14 namespace views { | |
| 15 | |
| 16 void ComboboxBackgroundMac::Paint(gfx::Canvas* canvas, View* view) const { | |
| 17 DCHECK_EQ(view->GetClassName(), Combobox::kViewClassName); | |
| 18 Combobox* combobox = static_cast<Combobox*>(view); | |
| 19 | |
| 20 gfx::Rect bounds = combobox->GetLocalBounds(); | |
| 21 bounds.Inset(bounds.width() - combobox->GetArrowButtonWidth(), 0, 0, 0); | |
|
tapted
2016/03/23 03:08:01
There's a minor visual glitch here -- see the unfo
Elly Fong-Jones
2016/03/23 18:07:44
Done.
| |
| 22 | |
| 23 ui::NativeTheme::State state = ui::NativeTheme::kNormal; | |
| 24 if (!combobox->enabled()) | |
| 25 state = ui::NativeTheme::kDisabled; | |
| 26 | |
| 27 skia::RefPtr<SkShader> shader = | |
| 28 ui::NativeThemeMac::GetButtonBackgroundShader( | |
| 29 state, | |
| 30 bounds.height()); | |
| 31 SkPaint paint; | |
| 32 paint.setShader(shader.get()); | |
| 33 paint.setStyle(SkPaint::kFill_Style); | |
| 34 paint.setAntiAlias(true); | |
| 35 | |
| 36 SkPoint no_curve = SkPoint::Make(0, 0); | |
| 37 SkPoint curve = SkPoint::Make( | |
| 38 ui::NativeThemeMac::kComboboxCornerRadius, | |
| 39 ui::NativeThemeMac::kComboboxCornerRadius); | |
| 40 SkVector curves[4] = { no_curve, curve, curve, no_curve }; | |
| 41 | |
| 42 SkRRect fill_rect; | |
| 43 fill_rect.setRectRadii(gfx::RectToSkRect(bounds), curves); | |
|
tapted
2016/03/23 03:08:01
this will need to be
fill_rect.setRectRadii(gfx:
Elly Fong-Jones
2016/03/23 18:07:44
Done.
| |
| 44 | |
| 45 SkPath path; | |
| 46 path.addRRect(fill_rect); | |
| 47 | |
| 48 canvas->DrawPath(path, paint); | |
| 49 } | |
| 50 | |
| 51 } // namespace views | |
| OLD | NEW |