Chromium Code Reviews| Index: ui/views/style/mac/combobox_background_mac.cc |
| diff --git a/ui/views/style/mac/combobox_background_mac.cc b/ui/views/style/mac/combobox_background_mac.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..89a14765cfc4dd96bb85381d48665168dd6db805 |
| --- /dev/null |
| +++ b/ui/views/style/mac/combobox_background_mac.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "ui/views/style/mac/combobox_background_mac.h" |
| + |
| +#include "third_party/skia/include/core/SkPath.h" |
| +#include "third_party/skia/include/core/SkRRect.h" |
| +#include "ui/gfx/canvas.h" |
| +#include "ui/native_theme/native_theme_mac.h" |
| +#include "ui/views/controls/combobox/combobox.h" |
| +#include "ui/views/view.h" |
| + |
| +namespace views { |
| + |
| +void ComboboxBackgroundMac::Paint(gfx::Canvas* canvas, View* view) const { |
| + DCHECK_EQ(view->GetClassName(), Combobox::kViewClassName); |
| + Combobox* combobox = static_cast<Combobox*>(view); |
| + |
| + gfx::Rect bounds = combobox->GetLocalBounds(); |
| + 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.
|
| + |
| + ui::NativeTheme::State state = ui::NativeTheme::kNormal; |
| + if (!combobox->enabled()) |
| + state = ui::NativeTheme::kDisabled; |
| + |
| + skia::RefPtr<SkShader> shader = |
| + ui::NativeThemeMac::GetButtonBackgroundShader( |
| + state, |
| + bounds.height()); |
| + SkPaint paint; |
| + paint.setShader(shader.get()); |
| + paint.setStyle(SkPaint::kFill_Style); |
| + paint.setAntiAlias(true); |
| + |
| + SkPoint no_curve = SkPoint::Make(0, 0); |
| + SkPoint curve = SkPoint::Make( |
| + ui::NativeThemeMac::kComboboxCornerRadius, |
| + ui::NativeThemeMac::kComboboxCornerRadius); |
| + SkVector curves[4] = { no_curve, curve, curve, no_curve }; |
| + |
| + SkRRect fill_rect; |
| + 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.
|
| + |
| + SkPath path; |
| + path.addRRect(fill_rect); |
| + |
| + canvas->DrawPath(path, paint); |
| +} |
| + |
| +} // namespace views |