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 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_CONFIG_H_
      6 #define UI_VIEWS_CONTROLS_MENU_MENU_CONFIG_H_
      7 
      8 #include "third_party/skia/include/core/SkColor.h"
      9 #include "ui/gfx/font.h"
     10 #include "ui/views/views_export.h"
     11 
     12 namespace ui {
     13 class NativeTheme;
     14 }
     15 
     16 namespace views {
     17 
     18 // Layout type information for menu items. Use the instance() method to obtain
     19 // the MenuConfig for the current platform.
     20 struct VIEWS_EXPORT MenuConfig {
     21   explicit MenuConfig(const ui::NativeTheme* theme);
     22   ~MenuConfig();
     23 
     24   static const MenuConfig& instance(const ui::NativeTheme* theme);
     25 
     26   // Font used by menus.
     27   gfx::Font font;
     28 
     29   // Normal text color.
     30   SkColor text_color;
     31 
     32   // Color for the arrow to scroll bookmarks.
     33   SkColor arrow_color;
     34 
     35   // Menu border sizes.
     36   int menu_vertical_border_size;
     37   int menu_horizontal_border_size;
     38 
     39   // Submenu horizontal inset with parent menu. This is the horizontal overlap
     40   // between the submenu and its parent menu, not including the borders of
     41   // submenu and parent menu.
     42   int submenu_horizontal_inset;
     43 
     44   // Margins between the top of the item and the label.
     45   int item_top_margin;
     46 
     47   // Margins between the bottom of the item and the label.
     48   int item_bottom_margin;
     49 
     50   // Margins used if the menu doesn't have icons.
     51   int item_no_icon_top_margin;
     52   int item_no_icon_bottom_margin;
     53 
     54   // Margins between the left of the item and the icon.
     55   int item_left_margin;
     56 
     57   // Padding between the label and submenu arrow.
     58   int label_to_arrow_padding;
     59 
     60   // Padding between the arrow and the edge.
     61   int arrow_to_edge_padding;
     62 
     63   // Padding between the icon and label.
     64   int icon_to_label_padding;
     65 
     66   // Padding between the gutter and label.
     67   int gutter_to_label;
     68 
     69   // Size of the check.
     70   int check_width;
     71   int check_height;
     72 
     73   // Size of the radio bullet.
     74   int radio_width;
     75   int radio_height;
     76 
     77   // Size of the submenu arrow.
     78   int arrow_height;
     79   int arrow_width;
     80 
     81   // Width of the gutter. Only used if render_gutter is true.
     82   int gutter_width;
     83 
     84   // Height of a normal separator (ui::NORMAL_SEPARATOR).
     85   int separator_height;
     86 
     87   // Height of a ui::UPPER_SEPARATOR.
     88   int separator_upper_height;
     89 
     90   // Height of a ui::LOWER_SEPARATOR.
     91   int separator_lower_height;
     92 
     93   // Height of a ui::SPACING_SEPARATOR.
     94   int separator_spacing_height;
     95 
     96   // Whether or not the gutter should be rendered. The gutter is specific to
     97   // Vista.
     98   bool render_gutter;
     99 
    100   // Are mnemonics shown?
    101   bool show_mnemonics;
    102 
    103   // Height of the scroll arrow.
    104   int scroll_arrow_height;
    105 
    106   // Padding between the label and minor text. Only used if there is an
    107   // accelerator or sublabel.
    108   int label_to_minor_text_padding;
    109 
    110   // Minimum height of menu item.
    111   int item_min_height;
    112 
    113   // Whether the keyboard accelerators are visible.
    114   bool show_accelerators;
    115 
    116   // True if icon to label padding is always added with or without icon.
    117   bool always_use_icon_to_label_padding;
    118 
    119   // True if submenu arrow and shortcut right edge should be aligned.
    120   bool align_arrow_and_shortcut;
    121 
    122   // True if the context menu's should be offset from the cursor position.
    123   bool offset_context_menus;
    124 
    125   const ui::NativeTheme* native_theme;
    126 
    127   // Delay, in ms, between when menus are selected or moused over and the menu
    128   // appears.
    129   int show_delay;
    130 
    131   // Radius of the rounded corners of the menu border. Must be >= 0.
    132   int corner_radius;
    133 
    134  private:
    135   // Configures a MenuConfig as appropriate for the current platform.
    136   void Init(const ui::NativeTheme* theme);
    137 
    138   // TODO: temporary until we standardize.
    139 #if defined(USE_AURA)
    140   void InitAura(const ui::NativeTheme* theme);
    141 #endif
    142 };
    143 
    144 }  // namespace views
    145 
    146 #endif  // UI_VIEWS_CONTROLS_MENU_MENU_CONFIG_H_
    147