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