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/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
9 #include "ui/native_theme/native_theme.h" | 9 #include "ui/native_theme/native_theme.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" | |
12 | 11 |
13 namespace { | 12 namespace { |
14 | 13 |
15 const int kSeparatorHeight = 1; | 14 const int kSeparatorHeight = 1; |
16 | 15 |
17 } // namespace | 16 } // namespace |
18 | 17 |
19 namespace views { | 18 namespace views { |
20 | 19 |
21 #if !defined(OS_WIN) | 20 #if !defined(OS_WIN) |
22 void MenuSeparator::OnPaint(gfx::Canvas* canvas) { | 21 void MenuSeparator::OnPaint(gfx::Canvas* canvas) { |
23 OnPaintAura(canvas); | 22 OnPaintAura(canvas); |
24 } | 23 } |
25 #endif | 24 #endif |
26 | 25 |
27 gfx::Size MenuSeparator::GetPreferredSize() const { | 26 gfx::Size MenuSeparator::GetPreferredSize() const { |
28 const MenuConfig& menu_config = parent_menu_item_->GetMenuConfig(); | 27 const MenuConfig& menu_config = MenuConfig::instance(); |
29 int height = menu_config.separator_height; | 28 int height = menu_config.separator_height; |
30 switch(type_) { | 29 switch(type_) { |
31 case ui::SPACING_SEPARATOR: | 30 case ui::SPACING_SEPARATOR: |
32 height = menu_config.separator_spacing_height; | 31 height = menu_config.separator_spacing_height; |
33 break; | 32 break; |
34 case ui::LOWER_SEPARATOR: | 33 case ui::LOWER_SEPARATOR: |
35 height = menu_config.separator_lower_height; | 34 height = menu_config.separator_lower_height; |
36 break; | 35 break; |
37 case ui::UPPER_SEPARATOR: | 36 case ui::UPPER_SEPARATOR: |
38 height = menu_config.separator_upper_height; | 37 height = menu_config.separator_upper_height; |
(...skipping 15 matching lines...) Expand all Loading... |
54 case ui::SPACING_SEPARATOR: | 53 case ui::SPACING_SEPARATOR: |
55 return gfx::Rect(); | 54 return gfx::Rect(); |
56 case ui::UPPER_SEPARATOR: | 55 case ui::UPPER_SEPARATOR: |
57 break; | 56 break; |
58 default: | 57 default: |
59 pos = height() / 2; | 58 pos = height() / 2; |
60 break; | 59 break; |
61 } | 60 } |
62 | 61 |
63 gfx::Rect paint_rect(0, pos, width(), kSeparatorHeight); | 62 gfx::Rect paint_rect(0, pos, width(), kSeparatorHeight); |
64 if (parent_menu_item_->GetMenuConfig().use_outer_border) | 63 if (MenuConfig::instance().use_outer_border) |
65 paint_rect.Inset(1, 0); | 64 paint_rect.Inset(1, 0); |
66 return paint_rect; | 65 return paint_rect; |
67 } | 66 } |
68 | 67 |
69 void MenuSeparator::OnPaintAura(gfx::Canvas* canvas) { | 68 void MenuSeparator::OnPaintAura(gfx::Canvas* canvas) { |
70 canvas->FillRect(GetPaintBounds(), | 69 canvas->FillRect(GetPaintBounds(), |
71 GetNativeTheme()->GetSystemColor( | 70 GetNativeTheme()->GetSystemColor( |
72 ui::NativeTheme::kColorId_MenuSeparatorColor)); | 71 ui::NativeTheme::kColorId_MenuSeparatorColor)); |
73 } | 72 } |
74 | 73 |
75 } // namespace views | 74 } // namespace views |
OLD | NEW |