| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/menu/menu_separator.h" | 5 #include "ui/views/controls/menu/menu_separator.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/native_theme/native_theme.h" | 10 #include "ui/native_theme/native_theme.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 float device_scale = display::win::GetDPIScale(); | 45 float device_scale = display::win::GetDPIScale(); |
| 46 bool is_fractional_scale = | 46 bool is_fractional_scale = |
| 47 (device_scale - static_cast<int>(device_scale) != 0); | 47 (device_scale - static_cast<int>(device_scale) != 0); |
| 48 if (is_fractional_scale && paint_rect.y() == 0) | 48 if (is_fractional_scale && paint_rect.y() == 0) |
| 49 paint_rect.set_y(1); | 49 paint_rect.set_y(1); |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 ui::NativeTheme::ExtraParams params; | 52 ui::NativeTheme::ExtraParams params; |
| 53 params.menu_separator.paint_rect = &paint_rect; | 53 params.menu_separator.paint_rect = &paint_rect; |
| 54 params.menu_separator.type = type_; | 54 params.menu_separator.type = type_; |
| 55 GetNativeTheme()->Paint( | 55 GetNativeTheme()->Paint(canvas->sk_canvas(), |
| 56 canvas->sk_canvas(), ui::NativeTheme::kMenuPopupSeparator, | 56 ui::NativeTheme::kMenuPopupSeparator, |
| 57 ui::NativeTheme::kNormal, gfx::Rect(bounds().size()), params); | 57 ui::NativeTheme::kNormal, GetLocalBounds(), params); |
| 58 } | 58 } |
| 59 | 59 |
| 60 gfx::Size MenuSeparator::GetPreferredSize() const { | 60 gfx::Size MenuSeparator::GetPreferredSize() const { |
| 61 const MenuConfig& menu_config = MenuConfig::instance(); | 61 const MenuConfig& menu_config = MenuConfig::instance(); |
| 62 int height = menu_config.separator_height; | 62 int height = menu_config.separator_height; |
| 63 switch (type_) { | 63 switch (type_) { |
| 64 case ui::SPACING_SEPARATOR: | 64 case ui::SPACING_SEPARATOR: |
| 65 height = menu_config.separator_spacing_height; | 65 height = menu_config.separator_spacing_height; |
| 66 break; | 66 break; |
| 67 case ui::LOWER_SEPARATOR: | 67 case ui::LOWER_SEPARATOR: |
| 68 height = menu_config.separator_lower_height; | 68 height = menu_config.separator_lower_height; |
| 69 break; | 69 break; |
| 70 case ui::UPPER_SEPARATOR: | 70 case ui::UPPER_SEPARATOR: |
| 71 height = menu_config.separator_upper_height; | 71 height = menu_config.separator_upper_height; |
| 72 break; | 72 break; |
| 73 default: | 73 default: |
| 74 height = menu_config.separator_height; | 74 height = menu_config.separator_height; |
| 75 break; | 75 break; |
| 76 } | 76 } |
| 77 return gfx::Size(10, // Just in case we're the only item in a menu. | 77 return gfx::Size(10, // Just in case we're the only item in a menu. |
| 78 height); | 78 height); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace views | 81 } // namespace views |
| OLD | NEW |