| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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/controls/menu/menu_separator.h" | |
| 6 | |
| 7 #include <windows.h> | |
| 8 #include <uxtheme.h> | |
| 9 #include <Vssym32.h> | |
| 10 | |
| 11 #include "ui/display/win/dpi.h" | |
| 12 #include "ui/gfx/canvas.h" | |
| 13 #include "ui/gfx/geometry/rect.h" | |
| 14 #include "ui/native_theme/native_theme.h" | |
| 15 #include "ui/native_theme/native_theme_aura.h" | |
| 16 #include "ui/views/controls/menu/menu_item_view.h" | |
| 17 | |
| 18 namespace views { | |
| 19 | |
| 20 void MenuSeparator::OnPaint(gfx::Canvas* canvas) { | |
| 21 ui::NativeTheme* native_theme = GetNativeTheme(); | |
| 22 gfx::Rect separator_bounds = GetPaintBounds(); | |
| 23 | |
| 24 // Hack to get the separator to display correctly on Windows where we may | |
| 25 // have fractional scales. We move the separator 1 pixel down to ensure that | |
| 26 // it falls within the clipping rect which is scaled up. | |
| 27 float device_scale = display::win::GetDPIScale(); | |
| 28 bool is_fractional_scale = | |
| 29 (device_scale - static_cast<int>(device_scale) != 0); | |
| 30 if (is_fractional_scale && separator_bounds.y() == 0) | |
| 31 separator_bounds.set_y(1); | |
| 32 | |
| 33 ui::NativeTheme::ExtraParams extra; | |
| 34 native_theme->Paint( | |
| 35 canvas->sk_canvas(), ui::NativeTheme::kMenuPopupSeparator, | |
| 36 ui::NativeTheme::kNormal, separator_bounds, extra); | |
| 37 } | |
| 38 | |
| 39 } // namespace views | |
| OLD | NEW |