diff options
author | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 23:56:13 +0000 |
---|---|---|
committer | jennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 23:56:13 +0000 |
commit | 0230169e78cea495e00e8346d52d0acaf5febd59 (patch) | |
tree | 8312c31c8f093aabca0783a30f424bab5b5ff0dd /ui/views | |
parent | 26a796c36e649acb6329f5355a5224b935e8a495 (diff) | |
download | chromium_src-0230169e78cea495e00e8346d52d0acaf5febd59.zip chromium_src-0230169e78cea495e00e8346d52d0acaf5febd59.tar.gz chromium_src-0230169e78cea495e00e8346d52d0acaf5febd59.tar.bz2 |
Implement part of auea menu spec:
http://www.corp.google.com/~kenmoore/mocks/chromeos/Misc_2012/Menus/markup1/menu4.html
Menu top/bottom padding: 2 pixels.
No left/right padding around menu item, edge to edge hover highlight.
Menu item height and hover highlight height: 30 pixels.
BUG=122858
TEST=Aura menu UI change according to the details in cl description.
Review URL: http://codereview.chromium.org/10330002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r-- | ui/views/controls/menu/menu_config.cc | 3 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_config.h | 11 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_config_views.cc | 3 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_controller.cc | 3 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_item_view.cc | 6 | ||||
-rw-r--r-- | ui/views/controls/menu/menu_scroll_view_container.cc | 8 | ||||
-rw-r--r-- | ui/views/controls/menu/submenu_view.cc | 5 | ||||
-rw-r--r-- | ui/views/controls/menu/submenu_view.h | 3 |
8 files changed, 26 insertions, 16 deletions
diff --git a/ui/views/controls/menu/menu_config.cc b/ui/views/controls/menu/menu_config.cc index f11d139..4f62288 100644 --- a/ui/views/controls/menu/menu_config.cc +++ b/ui/views/controls/menu/menu_config.cc @@ -14,6 +14,8 @@ static MenuConfig* config_instance = NULL; MenuConfig::MenuConfig() : text_color(SK_ColorBLACK), + submenu_horizontal_margin_size(3), + submenu_vertical_margin_size(3), item_top_margin(3), item_bottom_margin(4), item_no_icon_top_margin(1), @@ -35,6 +37,7 @@ MenuConfig::MenuConfig() show_mnemonics(false), scroll_arrow_height(3), label_to_accelerator_padding(10), + item_min_height(0), show_accelerators(true) { // Use 40px tall menu items when running in touch optimized mode. if (CommandLine::ForCurrentProcess()->HasSwitch( diff --git a/ui/views/controls/menu/menu_config.h b/ui/views/controls/menu/menu_config.h index ac568b0..5659214 100644 --- a/ui/views/controls/menu/menu_config.h +++ b/ui/views/controls/menu/menu_config.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -31,6 +31,12 @@ struct VIEWS_EXPORT MenuConfig { // Normal text color. SkColor text_color; + // Submenu horizontal margin size. + int submenu_horizontal_margin_size; + + // Submenu vertical margin size. + int submenu_vertical_margin_size; + // Margins between the top of the item and the label. int item_top_margin; @@ -88,6 +94,9 @@ struct VIEWS_EXPORT MenuConfig { // accelerator. int label_to_accelerator_padding; + // Minimum height of menu item. + int item_min_height; + // Whether the keyboard accelerators are visible. bool show_accelerators; diff --git a/ui/views/controls/menu/menu_config_views.cc b/ui/views/controls/menu/menu_config_views.cc index 74645db..3f40629 100644 --- a/ui/views/controls/menu/menu_config_views.cc +++ b/ui/views/controls/menu/menu_config_views.cc @@ -17,6 +17,8 @@ MenuConfig* MenuConfig::Create() { MenuConfig* config = new MenuConfig(); config->text_color = gfx::NativeTheme::instance()->GetSystemColor( gfx::NativeTheme::kColorId_EnabledMenuItemForegroundColor); + config->submenu_horizontal_margin_size = 0; + config->submenu_vertical_margin_size = 2; ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); config->font = rb.GetFont(ResourceBundle::BaseFont); config->arrow_width = rb.GetImageNamed(IDR_MENU_ARROW).ToSkBitmap()->width(); @@ -24,6 +26,7 @@ MenuConfig* MenuConfig::Create() { // Add 4 to force some padding between check and label. config->check_width = check->width() + 4; config->check_height = check->height(); + config->item_min_height = 30; return config; } diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index 298e1bf..fd34193 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -16,6 +16,7 @@ #include "ui/gfx/canvas.h" #include "ui/gfx/screen.h" #include "ui/views/controls/button/menu_button.h" +#include "ui/views/controls/menu/menu_config.h" #include "ui/views/controls/menu/menu_controller_delegate.h" #include "ui/views/controls/menu/menu_scroll_view_container.h" #include "ui/views/controls/menu/submenu_view.h" @@ -1596,7 +1597,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item, x = item_loc.x() + item->width() - kSubmenuHorizontalInset; } } - y = item_loc.y() - SubmenuView::kSubmenuBorderSize; + y = item_loc.y() - MenuConfig::instance().submenu_vertical_margin_size; if (state_.monitor_bounds.width() != 0) { pref.set_height(std::min(pref.height(), state_.monitor_bounds.height())); if (y + pref.height() > state_.monitor_bounds.bottom()) diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc index 59f36db..04ec3ce 100644 --- a/ui/views/controls/menu/menu_item_view.cc +++ b/ui/views/controls/menu/menu_item_view.cc @@ -748,12 +748,12 @@ gfx::Size MenuItemView::CalculatePreferredSize() { } const gfx::Font& font = GetFont(); - int height = font.GetHeight(); + int menu_item_height = std::max(font.GetHeight(), child_size.height()) + + GetBottomMargin() + GetTopMargin(); return gfx::Size( font.GetStringWidth(title_) + label_start_ + item_right_margin_ + child_size.width(), - std::max(height, child_size.height()) + GetBottomMargin() + - GetTopMargin()); + std::max(menu_item_height, MenuConfig::instance().item_min_height)); } string16 MenuItemView::GetAcceleratorText() { diff --git a/ui/views/controls/menu/menu_scroll_view_container.cc b/ui/views/controls/menu/menu_scroll_view_container.cc index 5d6c414..f8f36b8 100644 --- a/ui/views/controls/menu/menu_scroll_view_container.cc +++ b/ui/views/controls/menu/menu_scroll_view_container.cc @@ -166,10 +166,10 @@ MenuScrollViewContainer::MenuScrollViewContainer(SubmenuView* content_view) AddChildView(scroll_view_); set_border(Border::CreateEmptyBorder( - SubmenuView::kSubmenuBorderSize, - SubmenuView::kSubmenuBorderSize, - SubmenuView::kSubmenuBorderSize, - SubmenuView::kSubmenuBorderSize)); + MenuConfig::instance().submenu_vertical_margin_size, + MenuConfig::instance().submenu_horizontal_margin_size, + MenuConfig::instance().submenu_vertical_margin_size, + MenuConfig::instance().submenu_horizontal_margin_size)); } void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) { diff --git a/ui/views/controls/menu/submenu_view.cc b/ui/views/controls/menu/submenu_view.cc index 07fe8a7..5b33f84 100644 --- a/ui/views/controls/menu/submenu_view.cc +++ b/ui/views/controls/menu/submenu_view.cc @@ -29,9 +29,6 @@ const SkColor kDropIndicatorColor = SK_ColorBLACK; namespace views { // static -const int SubmenuView::kSubmenuBorderSize = 3; - -// static const char SubmenuView::kViewClassName[] = "views/SubmenuView"; SubmenuView::SubmenuView(MenuItemView* parent) @@ -146,7 +143,7 @@ gfx::Size SubmenuView::GetPreferredSize() { gfx::Insets insets = GetInsets(); return gfx::Size( std::max(max_width + max_accelerator_width_ + insets.width(), - minimum_preferred_width_ - 2 * kSubmenuBorderSize), + minimum_preferred_width_ - 2 * insets.width()), height + insets.height()); } diff --git a/ui/views/controls/menu/submenu_view.h b/ui/views/controls/menu/submenu_view.h index 40981a2..ec32a8b 100644 --- a/ui/views/controls/menu/submenu_view.h +++ b/ui/views/controls/menu/submenu_view.h @@ -148,9 +148,6 @@ class VIEWS_EXPORT SubmenuView : public View, resize_open_menu_ = resize_open_menu; } - // Padding around the edges of the submenu. - static const int kSubmenuBorderSize; - protected: // View override. virtual std::string GetClassName() const OVERRIDE; |