Home | History | Annotate | Download | only in menu
      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.
      4 
      5 #include "ui/views/controls/menu/menu_config.h"
      6 
      7 #include "build/build_config.h"
      8 #include "ui/base/layout.h"
      9 #include "ui/native_theme/native_theme.h"
     10 
     11 namespace views {
     12 
     13 MenuConfig::MenuConfig(const ui::NativeTheme* theme)
     14     : text_color(SK_ColorBLACK),
     15       arrow_color(SK_ColorBLACK),
     16       menu_vertical_border_size(7),
     17       menu_horizontal_border_size(0),
     18       submenu_horizontal_inset(3),
     19       item_top_margin(7),
     20       item_bottom_margin(6),
     21       item_no_icon_top_margin(7),
     22       item_no_icon_bottom_margin(7),
     23       item_left_margin(10),
     24       label_to_arrow_padding(10),
     25       arrow_to_edge_padding(5),
     26       icon_to_label_padding(10),
     27       gutter_to_label(5),
     28       check_width(16),
     29       check_height(16),
     30       radio_width(16),
     31       radio_height(16),
     32       arrow_height(9),
     33       arrow_width(9),
     34       gutter_width(0),
     35       separator_height(15),
     36       separator_upper_height(3),
     37       separator_lower_height(4),
     38       separator_spacing_height(3),
     39       render_gutter(false),
     40       show_mnemonics(false),
     41       scroll_arrow_height(3),
     42       label_to_minor_text_padding(10),
     43       item_min_height(0),
     44       show_accelerators(true),
     45       always_use_icon_to_label_padding(false),
     46       align_arrow_and_shortcut(false),
     47       offset_context_menus(false),
     48       native_theme(theme),
     49       show_delay(400),
     50       corner_radius(0) {
     51   AdjustForMenuVariations();
     52   // Use 40px tall menu items when running in touch optimized mode.
     53   // For Windows use 40px tall menu items when running in touch optimized mode.
     54   if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) {
     55     item_top_margin = item_no_icon_top_margin = 12;
     56     item_bottom_margin = item_no_icon_bottom_margin = 13;
     57   }
     58   Init(theme);
     59 }
     60 
     61 MenuConfig::~MenuConfig() {}
     62 
     63 void MenuConfig::AdjustForMenuVariations() {
     64   switch (ui::NativeTheme::GetMenuVariation()) {
     65     case ui::NativeTheme::MENU_VARIATION_COMPACT_1:
     66     case ui::NativeTheme::MENU_VARIATION_CONTRAST:
     67       item_top_margin = 5;
     68       item_bottom_margin = 4;
     69       item_no_icon_top_margin = 5;
     70       item_no_icon_bottom_margin = 5;
     71       separator_height = 11;
     72       menu_vertical_border_size = 5;
     73       break;
     74     case ui::NativeTheme::MENU_VARIATION_COMPACT_2:
     75       item_top_margin = 4;
     76       item_bottom_margin = 3;
     77       item_no_icon_top_margin = 4;
     78       item_no_icon_bottom_margin = 4;
     79       separator_height = 11;
     80       menu_vertical_border_size = 3;
     81       break;
     82     default:
     83       break;
     84   }
     85 }
     86 
     87 }  // namespace views
     88