| Index: ui/views/controls/menu/menu_separator.cc
|
| diff --git a/ui/views/controls/menu/menu_separator_views.cc b/ui/views/controls/menu/menu_separator.cc
|
| similarity index 64%
|
| rename from ui/views/controls/menu/menu_separator_views.cc
|
| rename to ui/views/controls/menu/menu_separator.cc
|
| index 86f794ad0af5cc7150b916cdc71395effdfc1537..d3d532e2fb5d7f6d75232bc207845dda4e276378 100644
|
| --- a/ui/views/controls/menu/menu_separator_views.cc
|
| +++ b/ui/views/controls/menu/menu_separator.cc
|
| @@ -10,20 +10,57 @@
|
| #include "ui/native_theme/native_theme.h"
|
| #include "ui/views/controls/menu/menu_config.h"
|
|
|
| +#if defined(OS_WIN)
|
| +#include "ui/display/win/dpi.h"
|
| +#endif
|
| +
|
| namespace views {
|
|
|
| -#if !defined(OS_WIN)
|
| void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
|
| - canvas->FillRect(GetPaintBounds(),
|
| - GetNativeTheme()->GetSystemColor(
|
| - ui::NativeTheme::kColorId_MenuSeparatorColor));
|
| -}
|
| + if (type_ == ui::SPACING_SEPARATOR)
|
| + return;
|
| +
|
| + const MenuConfig& menu_config = MenuConfig::instance();
|
| + int pos = 0;
|
| + int separator_thickness = menu_config.separator_thickness;
|
| + switch (type_) {
|
| + case ui::LOWER_SEPARATOR:
|
| + pos = height() - separator_thickness;
|
| + break;
|
| + case ui::UPPER_SEPARATOR:
|
| + break;
|
| + default:
|
| + pos = height() / 2;
|
| + break;
|
| + }
|
| +
|
| + gfx::Rect paint_rect(0, pos, width(), separator_thickness);
|
| + if (menu_config.use_outer_border)
|
| + paint_rect.Inset(1, 0);
|
| +
|
| +#if defined(OS_WIN)
|
| + // Hack to get the separator to display correctly on Windows where we may
|
| + // have fractional scales. We move the separator 1 pixel down to ensure that
|
| + // it falls within the clipping rect which is scaled up.
|
| + float device_scale = display::win::GetDPIScale();
|
| + bool is_fractional_scale =
|
| + (device_scale - static_cast<int>(device_scale) != 0);
|
| + if (is_fractional_scale && paint_rect.y() == 0)
|
| + paint_rect.set_y(1);
|
| #endif
|
|
|
| + ui::NativeTheme::ExtraParams params;
|
| + params.menu_separator.paint_rect = &paint_rect;
|
| + params.menu_separator.type = type_;
|
| + GetNativeTheme()->Paint(
|
| + canvas->sk_canvas(), ui::NativeTheme::kMenuPopupSeparator,
|
| + ui::NativeTheme::kNormal, gfx::Rect(bounds().size()), params);
|
| +}
|
| +
|
| gfx::Size MenuSeparator::GetPreferredSize() const {
|
| const MenuConfig& menu_config = MenuConfig::instance();
|
| int height = menu_config.separator_height;
|
| - switch(type_) {
|
| + switch (type_) {
|
| case ui::SPACING_SEPARATOR:
|
| height = menu_config.separator_spacing_height;
|
| break;
|
| @@ -41,27 +78,4 @@ gfx::Size MenuSeparator::GetPreferredSize() const {
|
| height);
|
| }
|
|
|
| -gfx::Rect MenuSeparator::GetPaintBounds() {
|
| - int pos = 0;
|
| - const MenuConfig& menu_config = MenuConfig::instance();
|
| - int separator_thickness = menu_config.separator_thickness;
|
| - switch (type_) {
|
| - case ui::LOWER_SEPARATOR:
|
| - pos = height() - separator_thickness;
|
| - break;
|
| - case ui::SPACING_SEPARATOR:
|
| - return gfx::Rect();
|
| - case ui::UPPER_SEPARATOR:
|
| - break;
|
| - default:
|
| - pos = height() / 2;
|
| - break;
|
| - }
|
| -
|
| - gfx::Rect paint_rect(0, pos, width(), separator_thickness);
|
| - if (menu_config.use_outer_border)
|
| - paint_rect.Inset(1, 0);
|
| - return paint_rect;
|
| -}
|
| -
|
| } // namespace views
|
|
|