| 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_config.h" | 5 #include "ui/views/controls/menu/menu_config.h" |
| 6 | 6 |
| 7 #include "grit/ui_resources.h" | 7 #include "grit/ui_resources.h" |
| 8 #include "ui/base/layout.h" | 8 #include "ui/base/layout.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/image/image.h" | 10 #include "ui/gfx/image/image.h" |
| 11 #include "ui/gfx/image/image_skia.h" | 11 #include "ui/gfx/image/image_skia.h" |
| 12 #include "ui/native_theme/native_theme_aura.h" | 12 #include "ui/native_theme/native_theme_aura.h" |
| 13 #include "ui/views/controls/menu/menu_image_util.h" | 13 #include "ui/views/controls/menu/menu_image_util.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
| 19 static const int kMenuCornerRadiusForAura = 0; | 19 static const int kMenuCornerRadiusForAura = 0; |
| 20 #else | 20 #else |
| 21 static const int kMenuCornerRadiusForAura = 2; | 21 static const int kMenuCornerRadiusForAura = 2; |
| 22 #endif | 22 #endif |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 #if !defined(OS_WIN) | 25 #if !defined(OS_WIN) |
| 26 void MenuConfig::Init(const ui::NativeTheme* theme) { | 26 void MenuConfig::Init(const ui::NativeTheme* theme) { |
| 27 InitAura(); | 27 InitAura(theme); |
| 28 } | 28 } |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 void MenuConfig::InitAura() { | 31 void MenuConfig::InitAura(const ui::NativeTheme* theme) { |
| 32 ui::NativeTheme* theme = ui::NativeThemeAura::instance(); | |
| 33 text_color = theme->GetSystemColor( | 32 text_color = theme->GetSystemColor( |
| 34 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); | 33 ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor); |
| 35 menu_horizontal_border_size = 0; | 34 menu_horizontal_border_size = 0; |
| 36 menu_vertical_border_size = 0; | 35 menu_vertical_border_size = 0; |
| 37 submenu_horizontal_inset = 1; | 36 submenu_horizontal_inset = 1; |
| 38 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 37 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 39 arrow_to_edge_padding = 20; | 38 arrow_to_edge_padding = 20; |
| 40 icon_to_label_padding = 4; | 39 icon_to_label_padding = 4; |
| 41 arrow_width = | 40 arrow_width = |
| 42 rb.GetImageNamed(IDR_MENU_HIERARCHY_ARROW).ToImageSkia()->width(); | 41 rb.GetImageNamed(IDR_MENU_HIERARCHY_ARROW).ToImageSkia()->width(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 57 corner_radius = kMenuCornerRadiusForAura; | 56 corner_radius = kMenuCornerRadiusForAura; |
| 58 if (ui::NativeTheme::IsNewMenuStyleEnabled()) | 57 if (ui::NativeTheme::IsNewMenuStyleEnabled()) |
| 59 AdjustForCommonTheme(); | 58 AdjustForCommonTheme(); |
| 60 } | 59 } |
| 61 | 60 |
| 62 #if !defined(OS_WIN) | 61 #if !defined(OS_WIN) |
| 63 // static | 62 // static |
| 64 const MenuConfig& MenuConfig::instance(const ui::NativeTheme* theme) { | 63 const MenuConfig& MenuConfig::instance(const ui::NativeTheme* theme) { |
| 65 static MenuConfig* views_instance = NULL; | 64 static MenuConfig* views_instance = NULL; |
| 66 if (!views_instance) | 65 if (!views_instance) |
| 67 views_instance = new MenuConfig(ui::NativeTheme::instance()); | 66 views_instance = new MenuConfig(theme ? |
| 67 theme : ui::NativeTheme::instance()); |
| 68 return *views_instance; | 68 return *views_instance; |
| 69 } | 69 } |
| 70 #endif | 70 #endif |
| 71 | 71 |
| 72 } // namespace views | 72 } // namespace views |
| OLD | NEW |