Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1008)

Unified Diff: ui/views/style/mac/combobox_background_mac.cc

Issue 1904753002: MenuButton: support Mac look & feel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix RTL support Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
index 805f97d2751c6aad18effdb7c714467dbef9548d..c1b1de97fd43886b8de197250a59a5fe10f99ca9 100644
--- a/ui/views/style/mac/combobox_background_mac.cc
+++ b/ui/views/style/mac/combobox_background_mac.cc
@@ -7,6 +7,7 @@
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRRect.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/scoped_canvas.h"
#include "ui/native_theme/native_theme_mac.h"
#include "ui/views/controls/combobox/combobox.h"
tapted 2016/04/21 06:06:46 can this be removed now? (or replaced with view.h?
Elly Fong-Jones 2016/04/21 15:30:26 Done.
#include "ui/views/view.h"
@@ -15,26 +16,30 @@ using ui::NativeThemeMac;
namespace views {
-ComboboxBackgroundMac::ComboboxBackgroundMac() {}
+ComboboxBackgroundMac::ComboboxBackgroundMac(int width) : width_(width) {}
ComboboxBackgroundMac::~ComboboxBackgroundMac() {}
void ComboboxBackgroundMac::Paint(gfx::Canvas* canvas, View* view) const {
- DCHECK_EQ(view->GetClassName(), Combobox::kViewClassName);
- Combobox* combobox = static_cast<Combobox*>(view);
+ gfx::RectF bounds(view->GetLocalBounds());
+ gfx::ScopedCanvas scoped_canvas(canvas);
+
+ if (base::i18n::IsRTL()) {
tapted 2016/04/21 06:06:46 Should we plonk this on gfx::ScopedCanvas - Maybe
Elly Fong-Jones 2016/04/21 15:30:26 Done.
+ canvas->Translate(gfx::Vector2d(bounds.width(), 0));
+ canvas->Scale(-1, 1);
+ }
- gfx::RectF bounds(combobox->GetLocalBounds());
// Inset the left side far enough to draw only the arrow button, and inset the
// other three sides by half a pixel so the edge of the background doesn't
// paint outside the border.
- bounds.Inset(bounds.width() - combobox->GetArrowButtonWidth(), 0.5, 0.5, 0.5);
+ bounds.Inset(bounds.width() - width_, 0.5, 0.5, 0.5);
// TODO(tapted): Check whether the Widget is active, and use the NORMAL
// BackgroundType if it is inactive. Handling this properly also requires the
// control to observe the Widget for activation changes and invalidate.
NativeThemeMac::ButtonBackgroundType type =
NativeThemeMac::ButtonBackgroundType::HIGHLIGHTED;
- if (!combobox->enabled())
+ if (!view->enabled())
type = NativeThemeMac::ButtonBackgroundType::DISABLED;
SkPaint paint;

Powered by Google App Engine
This is Rietveld 408576698