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