| 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 "third_party/skia/include/core/SkColor.h" | 7 #include "third_party/skia/include/core/SkColor.h" |
| 8 #include "ui/base/native_theme/native_theme.h" | 8 #include "ui/base/native_theme/native_theme.h" |
| 9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
| 10 #include "ui/views/controls/menu/menu_config.h" | 10 #include "ui/views/controls/menu/menu_config.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 const int kSeparatorHeight = 1; | 14 const int kSeparatorHeight = 1; |
| 15 | 15 |
| 16 } // namespace | 16 } // namespace |
| 17 | 17 |
| 18 namespace views { | 18 namespace views { |
| 19 | 19 |
| 20 void MenuSeparator::OnPaint(gfx::Canvas* canvas) { | 20 void MenuSeparator::OnPaint(gfx::Canvas* canvas) { |
| 21 canvas->FillRect(gfx::Rect(0, height() / 2, width(), kSeparatorHeight), | 21 int pos = 0; |
| 22 if (type_ == ui::LOWER_SEPARATOR) |
| 23 pos = height() - kSeparatorHeight; |
| 24 else if (type_ != ui::SPACING_SEPARATOR) |
| 25 pos = height() / 2; |
| 26 else if (type_ != ui::UPPER_SEPARATOR) |
| 27 return; |
| 28 canvas->FillRect(gfx::Rect(0, pos, width(), kSeparatorHeight), |
| 22 ui::NativeTheme::instance()->GetSystemColor( | 29 ui::NativeTheme::instance()->GetSystemColor( |
| 23 ui::NativeTheme::kColorId_MenuSeparatorColor)); | 30 ui::NativeTheme::kColorId_MenuSeparatorColor)); |
| 24 } | 31 } |
| 25 | 32 |
| 26 gfx::Size MenuSeparator::GetPreferredSize() { | 33 gfx::Size MenuSeparator::GetPreferredSize() { |
| 34 int height = MenuConfig::instance().separator_height; |
| 35 switch(type_) { |
| 36 case ui::SPACING_SEPARATOR: |
| 37 height = MenuConfig::instance().separator_spacing_height; |
| 38 break; |
| 39 case ui::LOWER_SEPARATOR: |
| 40 height = MenuConfig::instance().separator_lower_height; |
| 41 break; |
| 42 case ui::UPPER_SEPARATOR: |
| 43 height = MenuConfig::instance().separator_upper_height; |
| 44 break; |
| 45 default: |
| 46 height = MenuConfig::instance().separator_height; |
| 47 break; |
| 48 } |
| 27 return gfx::Size(10, // Just in case we're the only item in a menu. | 49 return gfx::Size(10, // Just in case we're the only item in a menu. |
| 28 MenuConfig::instance().separator_height); | 50 height); |
| 29 } | 51 } |
| 30 | 52 |
| 31 } // namespace views | 53 } // namespace views |
| OLD | NEW |