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

Unified Diff: ui/views/controls/combobox/combobox.cc

Issue 1819443002: MacViews: draw combobox arrow backgrounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/controls/combobox/combobox.cc
diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc
index 382c6db3ce101d65d28c70c697fb281a6a0fe20c..5b3e483f3511ef5e7ebb9c637d40cb617e8067fa 100644
--- a/ui/views/controls/combobox/combobox.cc
+++ b/ui/views/controls/combobox/combobox.cc
@@ -625,6 +625,9 @@ void Combobox::OnPaint(gfx::Canvas* canvas) {
switch (style_) {
case STYLE_NORMAL: {
OnPaintBackground(canvas);
+ // Painting the arrow background needs to happen before PaintText applies
+ // a clip rect to |canvas| so the background can touch the border.
+ PaintArrowBackground(canvas);
PaintText(canvas);
OnPaintBorder(canvas);
break;
@@ -813,6 +816,29 @@ void Combobox::PaintButtons(gfx::Canvas* canvas) {
}
}
+void Combobox::PaintArrowBackground(gfx::Canvas* canvas) {
+ gfx::Canvas::ScopedState canvas_state(canvas);
+
+ if (base::i18n::IsRTL()) {
+ canvas->Translate(gfx::Vector2d(width(), 0));
+ canvas->Scale(-1, 1);
+ }
+
+ gfx::Rect bounds = GetLocalBounds();
+ gfx::Size arrow_size = ArrowSize();
+ int disclosure_arrow_offset = width() - arrow_size.width() -
+ GetDisclosureArrowLeftPadding() - GetDisclosureArrowRightPadding();
+ bounds.Inset(disclosure_arrow_offset, 0, 0, 0);
+
+ ui::NativeTheme::State state =
+ HasFocus() ? ui::NativeTheme::kHovered : ui::NativeTheme::kNormal;
+ GetNativeTheme()->Paint(canvas->sk_canvas(),
+ ui::NativeTheme::kComboboxArrowBackground,
+ state,
+ bounds,
+ ui::NativeTheme::ExtraParams());
+}
+
void Combobox::ShowDropDownMenu(ui::MenuSourceType source_type) {
gfx::Rect lb = GetLocalBounds();
gfx::Point menu_position(lb.origin());
« ui/native_theme/native_theme_mac.mm ('K') | « ui/views/controls/combobox/combobox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698