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
3 // found in the LICENSE file.
5 #include "ui/views/controls/menu/menu_separator.h"
7 #include "third_party/skia/include/core/SkColor.h"
8 #include "ui/gfx/canvas.h"
9 #include "ui/native_theme/native_theme.h"
10 #include "ui/views/controls/menu/menu_config.h"
11 #include "ui/views/controls/menu/menu_item_view.h"
15 const int kSeparatorHeight = 1;
22 void MenuSeparator::OnPaint(gfx::Canvas* canvas) {
26 gfx::Size MenuSeparator::GetPreferredSize() {
27 return GetPreferredSizeAura();
31 void MenuSeparator::OnPaintAura(gfx::Canvas* canvas) {
34 case ui::LOWER_SEPARATOR:
35 pos = height() - kSeparatorHeight;
37 case ui::SPACING_SEPARATOR:
39 case ui::UPPER_SEPARATOR:
45 canvas->FillRect(gfx::Rect(0, pos, width(), kSeparatorHeight),
46 GetNativeTheme()->GetSystemColor(
47 ui::NativeTheme::kColorId_MenuSeparatorColor));
50 gfx::Size MenuSeparator::GetPreferredSizeAura() {
51 const MenuConfig& menu_config = parent_menu_item_->GetMenuConfig();
52 int height = menu_config.separator_height;
54 case ui::SPACING_SEPARATOR:
55 height = menu_config.separator_spacing_height;
57 case ui::LOWER_SEPARATOR:
58 height = menu_config.separator_lower_height;
60 case ui::UPPER_SEPARATOR:
61 height = menu_config.separator_upper_height;
64 height = menu_config.separator_height;
67 return gfx::Size(10, // Just in case we're the only item in a menu.