diff options
49 files changed, 323 insertions, 225 deletions
diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc index bde489c..9aa3132 100644 --- a/chrome/browser/background/background_mode_manager.cc +++ b/chrome/browser/background/background_mode_manager.cc @@ -699,7 +699,7 @@ void BackgroundModeManager::UpdateStatusTrayIconContextMenu() { // Add About item menu->AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); menu->AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); - menu->AddSeparator(); + menu->AddSeparator(ui::NORMAL_SEPARATOR); if (profile_cache_->GetNumberOfProfiles() > 1) { std::vector<BackgroundModeData*> bmd_vector; @@ -735,7 +735,7 @@ void BackgroundModeManager::UpdateStatusTrayIconContextMenu() { DCHECK(profile_cache_->GetNumberOfProfiles() == size_t(1) || keep_alive_for_test_); background_mode_data_.begin()->second->BuildProfileMenu(menu, NULL); - menu->AddSeparator(); + menu->AddSeparator(ui::NORMAL_SEPARATOR); } menu->AddCheckItemWithStringId( IDC_STATUS_TRAY_KEEP_CHROME_RUNNING_IN_BACKGROUND, diff --git a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc index 1fc7cda..fbe8e26 100644 --- a/chrome/browser/bookmarks/bookmark_context_menu_controller.cc +++ b/chrome/browser/bookmarks/bookmark_context_menu_controller.cc @@ -99,7 +99,7 @@ void BookmarkContextMenuController::AddItem(int id, int localization_id) { } void BookmarkContextMenuController::AddSeparator() { - menu_model_->AddSeparator(); + menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); } void BookmarkContextMenuController::AddCheckboxItem(int id, diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc index 2aa7096..2fde2c7 100644 --- a/chrome/browser/chromeos/status/network_menu.cc +++ b/chrome/browser/chromeos/status/network_menu.cc @@ -146,6 +146,7 @@ class NetworkMenuModel : public ui::MenuModel { virtual bool HasIcons() const OVERRIDE; virtual int GetItemCount() const OVERRIDE; virtual ui::MenuModel::ItemType GetTypeAt(int index) const OVERRIDE; + virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE; virtual string16 GetLabelAt(int index) const OVERRIDE; virtual bool IsItemDynamicAt(int index) const OVERRIDE; virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE; @@ -343,6 +344,10 @@ ui::MenuModel::ItemType NetworkMenuModel::GetTypeAt(int index) const { return menu_items_[index].type; } +ui::MenuSeparatorType NetworkMenuModel::GetSeparatorTypeAt(int index) const { + return ui::NORMAL_SEPARATOR; +} + string16 NetworkMenuModel::GetLabelAt(int index) const { return menu_items_[index].label; } diff --git a/chrome/browser/download/download_shelf_context_menu.cc b/chrome/browser/download/download_shelf_context_menu.cc index c3b0aba..095ca15 100644 --- a/chrome/browser/download/download_shelf_context_menu.cc +++ b/chrome/browser/download/download_shelf_context_menu.cc @@ -192,12 +192,12 @@ ui::SimpleMenuModel* DownloadShelfContextMenu::GetInProgressMenuModel() { OPEN_WHEN_COMPLETE, IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE); in_progress_download_menu_model_->AddCheckItemWithStringId( ALWAYS_OPEN_TYPE, IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE); - in_progress_download_menu_model_->AddSeparator(); + in_progress_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); in_progress_download_menu_model_->AddItemWithStringId( TOGGLE_PAUSE, IDS_DOWNLOAD_MENU_PAUSE_ITEM); in_progress_download_menu_model_->AddItemWithStringId( SHOW_IN_FOLDER, IDS_DOWNLOAD_MENU_SHOW); - in_progress_download_menu_model_->AddSeparator(); + in_progress_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); in_progress_download_menu_model_->AddItemWithStringId( CANCEL, IDS_DOWNLOAD_MENU_CANCEL); @@ -214,10 +214,10 @@ ui::SimpleMenuModel* DownloadShelfContextMenu::GetFinishedMenuModel() { OPEN_WHEN_COMPLETE, IDS_DOWNLOAD_MENU_OPEN); finished_download_menu_model_->AddCheckItemWithStringId( ALWAYS_OPEN_TYPE, IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE); - finished_download_menu_model_->AddSeparator(); + finished_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); finished_download_menu_model_->AddItemWithStringId( SHOW_IN_FOLDER, IDS_DOWNLOAD_MENU_SHOW); - finished_download_menu_model_->AddSeparator(); + finished_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); finished_download_menu_model_->AddItemWithStringId( CANCEL, IDS_DOWNLOAD_MENU_CANCEL); @@ -234,7 +234,7 @@ ui::SimpleMenuModel* DownloadShelfContextMenu::GetMaliciousMenuModel() { DISCARD, IDS_DOWNLOAD_MENU_DISCARD); malicious_download_menu_model_->AddItemWithStringId( KEEP, IDS_DOWNLOAD_MENU_KEEP); - malicious_download_menu_model_->AddSeparator(); + malicious_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); malicious_download_menu_model_->AddItemWithStringId( LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE); diff --git a/chrome/browser/extensions/extension_context_menu_model.cc b/chrome/browser/extensions/extension_context_menu_model.cc index c9b26cf..91b3d27 100644 --- a/chrome/browser/extensions/extension_context_menu_model.cc +++ b/chrome/browser/extensions/extension_context_menu_model.cc @@ -42,7 +42,7 @@ ExtensionContextMenuModel::ExtensionContextMenuModel( if (profile_->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode) && delegate_) { - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(INSPECT_POPUP, IDS_EXTENSION_ACTION_INSPECT_POPUP); } } @@ -165,13 +165,13 @@ void ExtensionContextMenuModel::InitMenu(const Extension* extension) { extension_action_ = extension->page_action(); AddItem(NAME, UTF8ToUTF16(extension->name())); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS_MENU_ITEM); AddItemWithStringId(DISABLE, IDS_EXTENSIONS_DISABLE); AddItem(UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL)); if (extension->browser_action()) AddItemWithStringId(HIDE, IDS_EXTENSIONS_HIDE_BUTTON); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(MANAGE, IDS_MANAGE_EXTENSIONS); } diff --git a/chrome/browser/media/media_stream_devices_menu_model.cc b/chrome/browser/media/media_stream_devices_menu_model.cc index 8006807..ca322bd 100644 --- a/chrome/browser/media/media_stream_devices_menu_model.cc +++ b/chrome/browser/media/media_stream_devices_menu_model.cc @@ -26,7 +26,7 @@ MediaStreamDevicesMenuModel::MediaStreamDevicesMenuModel( selected_command_id_video_ = commands_.size(); AddDevices(delegate->GetVideoDevices()); if (audio) - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); } if (audio) { // The default command ID is the first element that will be inserted. @@ -112,6 +112,6 @@ void MediaStreamDevicesMenuModel::AddAlwaysAllowOption(bool audio, bool video) { else if (!audio && video) message_id = IDS_MEDIA_CAPTURE_ALWAYS_ALLOW_VIDEO_ONLY; - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddCheckItem(command_id, l10n_util::GetStringUTF16(message_id)); } diff --git a/chrome/browser/notifications/notification_options_menu_model.cc b/chrome/browser/notifications/notification_options_menu_model.cc index c59565e..dd49e08 100644 --- a/chrome/browser/notifications/notification_options_menu_model.cc +++ b/chrome/browser/notifications/notification_options_menu_model.cc @@ -48,7 +48,7 @@ CornerSelectionMenuModel::CornerSelectionMenuModel(Balloon* balloon) AddRadioItem(kCornerDefault, l10n_util::GetStringUTF16(IDS_NOTIFICATION_POSITION_DEFAULT), kCornerGroupId); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddRadioItem(kCornerUpperLeft, l10n_util::GetStringUTF16(IDS_NOTIFICATION_POSITION_UPPER_LEFT), kCornerGroupId); diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 3ca6165..f52881b 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -191,7 +191,7 @@ void AddCustomItemsToMenu(const std::vector<WebMenuItem>& items, NOTREACHED(); break; case WebMenuItem::SEPARATOR: - menu_model->AddSeparator(); + menu_model->AddSeparator(ui::NORMAL_SEPARATOR); break; case WebMenuItem::SUBMENU: { ui::SimpleMenuModel* submenu = new ui::SimpleMenuModel(delegate); @@ -390,7 +390,7 @@ void RenderViewContextMenu::AppendExtensionItems( // If this is the first extension-provided menu item, and there are other // items in the menu, add a separator. if (*index == 0 && menu_model_.GetItemCount()) - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); int menu_id = IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST + (*index)++; @@ -441,7 +441,7 @@ void RenderViewContextMenu::RecursivelyAppendExtensionItems( // a separator. The converse case is handled below. if (last_type == MenuItem::RADIO && item->type() != MenuItem::RADIO) { - menu_model->AddSeparator(); + menu_model->AddSeparator(ui::NORMAL_SEPARATOR); last_type = MenuItem::SEPARATOR; } @@ -473,13 +473,13 @@ void RenderViewContextMenu::RecursivelyAppendExtensionItems( // Auto-append a separator if needed. if (last_type != MenuItem::SEPARATOR) - menu_model->AddSeparator(); + menu_model->AddSeparator(ui::NORMAL_SEPARATOR); } menu_model->AddRadioItem(menu_id, title, radio_group_id); } else if (item->type() == MenuItem::SEPARATOR) { if (i != items.begin() && last_type != MenuItem::SEPARATOR) { - menu_model->AddSeparator(); + menu_model->AddSeparator(ui::NORMAL_SEPARATOR); } } last_type = item->type(); @@ -554,7 +554,7 @@ void RenderViewContextMenu::InitMenu() { // If there's a selection, don't early return when there are custom items, // but fall through to adding the normal ones after the custom ones. if (has_selection) { - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } else { // Don't add items for Pepper menu. if (!params_.custom_context.is_pepper_menu) @@ -577,7 +577,7 @@ void RenderViewContextMenu::InitMenu() { if (!params_.frame_url.is_empty()) { is_devtools = IsDevToolsURL(params_.frame_url); if (!is_devtools && !IsInternalResourcesURL(params_.frame_url)) { - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); AppendFrameItems(); } } @@ -590,7 +590,7 @@ void RenderViewContextMenu::InitMenu() { if (has_link) { AppendLinkItems(); if (params_.media_type != WebContextMenuData::MediaTypeNone) - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } switch (params_.media_type) { @@ -688,7 +688,7 @@ void RenderViewContextMenu::AddCheckItem(int command_id, } void RenderViewContextMenu::AddSeparator() { - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } void RenderViewContextMenu::AddSubMenu(int command_id, @@ -743,7 +743,7 @@ void RenderViewContextMenu::AppendDeveloperItems() { // In the DevTools popup menu, "developer items" is normally the only // section, so omit the separator there. if (menu_model_.GetItemCount() > 0) - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_INSPECTELEMENT, IDS_CONTENT_CONTEXT_INSPECTELEMENT); } @@ -786,7 +786,7 @@ void RenderViewContextMenu::AppendImageItems() { void RenderViewContextMenu::AppendAudioItems() { AppendMediaItems(); - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, IDS_CONTENT_CONTEXT_SAVEAUDIOAS); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, @@ -797,7 +797,7 @@ void RenderViewContextMenu::AppendAudioItems() { void RenderViewContextMenu::AppendVideoItems() { AppendMediaItems(); - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SAVEAVAS, IDS_CONTENT_CONTEXT_SAVEVIDEOAS); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPYAVLOCATION, @@ -840,7 +840,7 @@ void RenderViewContextMenu::AppendPluginItems() { if (params_.media_flags & WebContextMenuData::MediaCanRotate) { if (menu_model_.GetItemCount() > 0) - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECW, IDS_CONTENT_CONTEXT_ROTATECW); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ROTATECCW, @@ -852,7 +852,7 @@ void RenderViewContextMenu::AppendPageItems() { menu_model_.AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); menu_model_.AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); menu_model_.AddItemWithStringId(IDC_RELOAD, IDS_CONTENT_CONTEXT_RELOAD); - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_SAVE_PAGE, IDS_CONTENT_CONTEXT_SAVEPAGEAS); menu_model_.AddItemWithStringId(IDC_PRINT, IDS_CONTENT_CONTEXT_PRINT); @@ -954,7 +954,7 @@ void RenderViewContextMenu::AppendEditableItems() { IDS_CONTENT_CONTEXT_UNDO); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_REDO, IDS_CONTENT_CONTEXT_REDO); - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_CUT, IDS_CONTENT_CONTEXT_CUT); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_COPY, @@ -965,12 +965,12 @@ void RenderViewContextMenu::AppendEditableItems() { IDS_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_DELETE, IDS_CONTENT_CONTEXT_DELETE); - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); if (!params_.keyword_url.is_empty()) { menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_ADDSEARCHENGINE, IDS_CONTENT_CONTEXT_ADDSEARCHENGINE); - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); } AppendSpellcheckOptionsSubMenu(); @@ -983,7 +983,7 @@ void RenderViewContextMenu::AppendEditableItems() { AppendBidiSubMenu(); #endif // OS_MACOSX - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SELECTALL, IDS_CONTENT_CONTEXT_SELECTALL); } @@ -1050,7 +1050,7 @@ void RenderViewContextMenu::AppendProtocolHandlerSubMenu() { IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_FIRST + i, handlers[i].title()); } - protocol_handler_submenu_model_.AddSeparator(); + protocol_handler_submenu_model_.AddSeparator(ui::NORMAL_SEPARATOR); protocol_handler_submenu_model_.AddItem( IDC_CONTENT_CONTEXT_PROTOCOL_HANDLER_SETTINGS, l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_OPENLINKWITH_CONFIGURE)); diff --git a/chrome/browser/tab_contents/spellchecker_submenu_observer_hunspell.cc b/chrome/browser/tab_contents/spellchecker_submenu_observer_hunspell.cc index 78c64db..5d563d0 100644 --- a/chrome/browser/tab_contents/spellchecker_submenu_observer_hunspell.cc +++ b/chrome/browser/tab_contents/spellchecker_submenu_observer_hunspell.cc @@ -57,7 +57,7 @@ void SpellCheckerSubMenuObserver::InitMenu( } // Add an item that opens the 'fonts and languages options' page. - submenu_model_.AddSeparator(); + submenu_model_.AddSeparator(ui::NORMAL_SEPARATOR); submenu_model_.AddItemWithStringId( IDC_CONTENT_CONTEXT_LANGUAGE_SETTINGS, IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS); diff --git a/chrome/browser/tab_contents/spellchecker_submenu_observer_mac.cc b/chrome/browser/tab_contents/spellchecker_submenu_observer_mac.cc index 70b413c..f110bde 100644 --- a/chrome/browser/tab_contents/spellchecker_submenu_observer_mac.cc +++ b/chrome/browser/tab_contents/spellchecker_submenu_observer_mac.cc @@ -44,7 +44,7 @@ void SpellCheckerSubMenuObserver::InitMenu( spellcheck_mac::SpellingPanelVisible() ? IDS_CONTENT_CONTEXT_HIDE_SPELLING_PANEL : IDS_CONTENT_CONTEXT_SHOW_SPELLING_PANEL)); - submenu_model_.AddSeparator(); + submenu_model_.AddSeparator(ui::NORMAL_SEPARATOR); // Add a 'Check Spelling While Typing' item in the sub menu. submenu_model_.AddCheckItem( diff --git a/chrome/browser/translate/options_menu_model.cc b/chrome/browser/translate/options_menu_model.cc index 9631d8a..960bc60 100644 --- a/chrome/browser/translate/options_menu_model.cc +++ b/chrome/browser/translate/options_menu_model.cc @@ -45,7 +45,7 @@ OptionsMenuModel::OptionsMenuModel( AddCheckItem(IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE, l10n_util::GetStringUTF16( IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE)); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); } AddItem(IDC_TRANSLATE_REPORT_BAD_LANGUAGE_DETECTION, l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_REPORT_ERROR, diff --git a/chrome/browser/ui/ash/app_list/extension_app_item.cc b/chrome/browser/ui/ash/app_list/extension_app_item.cc index 9d5405f..a31110e 100644 --- a/chrome/browser/ui/ash/app_list/extension_app_item.cc +++ b/chrome/browser/ui/ash/app_list/extension_app_item.cc @@ -275,13 +275,13 @@ ui::MenuModel* ExtensionAppItem::GetContextMenuModel() { if (!context_menu_model_.get()) { context_menu_model_.reset(new ui::SimpleMenuModel(this)); context_menu_model_->AddItem(LAUNCH, UTF8ToUTF16(title())); - context_menu_model_->AddSeparator(); + context_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_model_->AddItemWithStringId( TOGGLE_PIN, controller_->IsAppPinned(extension_id_) ? IDS_APP_LIST_CONTEXT_MENU_UNPIN : IDS_APP_LIST_CONTEXT_MENU_PIN); - context_menu_model_->AddSeparator(); + context_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_model_->AddCheckItemWithStringId( LAUNCH_TYPE_REGULAR_TAB, IDS_APP_CONTEXT_MENU_OPEN_REGULAR); @@ -296,7 +296,7 @@ ui::MenuModel* ExtensionAppItem::GetContextMenuModel() { context_menu_model_->AddCheckItemWithStringId( LAUNCH_TYPE_FULLSCREEN, IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED); - context_menu_model_->AddSeparator(); + context_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_model_->AddItemWithStringId(OPTIONS, IDS_NEW_TAB_APP_OPTIONS); context_menu_model_->AddItemWithStringId(DETAILS, IDS_NEW_TAB_APP_DETAILS); context_menu_model_->AddItemWithStringId(UNINSTALL, diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc index 9023255..ca1b3ca 100644 --- a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc +++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc @@ -31,7 +31,7 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, AddItem(MENU_CLOSE, l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); } - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddCheckItemWithStringId( LAUNCH_TYPE_REGULAR_TAB, IDS_APP_CONTEXT_MENU_OPEN_REGULAR); @@ -65,7 +65,7 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_CLOSE)); } } - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); } AddCheckItemWithStringId( MENU_AUTO_HIDE, ash::LauncherContextMenu::GetAutoHideResourceStringId()); diff --git a/chrome/browser/ui/cocoa/menu_controller_unittest.mm b/chrome/browser/ui/cocoa/menu_controller_unittest.mm index c275005..446a6569 100644 --- a/chrome/browser/ui/cocoa/menu_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/menu_controller_unittest.mm @@ -108,7 +108,7 @@ TEST_F(MenuControllerTest, BasicCreation) { model.AddItem(1, ASCIIToUTF16("one")); model.AddItem(2, ASCIIToUTF16("two")); model.AddItem(3, ASCIIToUTF16("three")); - model.AddSeparator(); + model.AddSeparator(ui::NORMAL_SEPARATOR); model.AddItem(4, ASCIIToUTF16("four")); model.AddItem(5, ASCIIToUTF16("five")); diff --git a/chrome/browser/ui/cocoa/tab_contents/render_view_context_menu_mac.mm b/chrome/browser/ui/cocoa/tab_contents/render_view_context_menu_mac.mm index 698ac03..a2c7eee 100644 --- a/chrome/browser/ui/cocoa/tab_contents/render_view_context_menu_mac.mm +++ b/chrome/browser/ui/cocoa/tab_contents/render_view_context_menu_mac.mm @@ -170,7 +170,7 @@ void RenderViewContextMenuMac::InitPlatformMenu() { bool has_selection = !params_.selection_text.empty(); if (has_selection) { - menu_model_.AddSeparator(); + menu_model_.AddSeparator(ui::NORMAL_SEPARATOR); menu_model_.AddItemWithStringId( IDC_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY, IDS_CONTENT_CONTEXT_LOOK_UP_IN_DICTIONARY); diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_sub_menu_model_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_sub_menu_model_gtk.cc index 43f0473..3499c1a 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_sub_menu_model_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_sub_menu_model_gtk.cc @@ -168,7 +168,7 @@ void BookmarkSubMenuModel::MenuWillShow() { return; // The node count includes the node itself, so 1 means empty. if (model()->bookmark_bar_node()->GetTotalNodeCount() > 1) { - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); fixed_items_ = GetItemCount(); if (!node()) set_node(model()->bookmark_bar_node()); @@ -180,13 +180,13 @@ void BookmarkSubMenuModel::MenuWillShow() { // other node and/or mobile node. Keep track of whether we've added it yet. bool added_separator = false; if (model()->other_node()->GetTotalNodeCount() > 1) { - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); added_separator = true; AddSubMenuForNode(model()->other_node()); } if (model()->mobile_node()->GetTotalNodeCount() > 1) { if (!added_separator) - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddSubMenuForNode(model()->mobile_node()); } } diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc index 8a37565..23874b4 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.cc +++ b/chrome/browser/ui/gtk/browser_titlebar.cc @@ -176,13 +176,13 @@ void PopupPageMenuModel::Build() { AddItemWithStringId(IDC_BACK, IDS_CONTENT_CONTEXT_BACK); AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); AddItemWithStringId(IDC_RELOAD, IDS_APP_MENU_RELOAD); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(IDC_SHOW_AS_TAB, IDS_SHOW_AS_TAB); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(IDC_CUT, IDS_CUT); AddItemWithStringId(IDC_COPY, IDS_COPY); AddItemWithStringId(IDC_PASTE, IDS_PASTE); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(IDC_FIND, IDS_FIND); AddItemWithStringId(IDC_PRINT, IDS_PRINT); zoom_menu_model_.reset(new ZoomMenuModel(delegate())); @@ -192,7 +192,7 @@ void PopupPageMenuModel::Build() { AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, encoding_menu_model_.get()); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(IDC_CLOSE_WINDOW, IDS_CLOSE); } @@ -1048,9 +1048,9 @@ BrowserTitlebar::ContextMenuModel::ContextMenuModel( : SimpleMenuModel(delegate) { AddItemWithStringId(IDC_NEW_TAB, IDS_TAB_CXMENU_NEWTAB); AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddCheckItemWithStringId(kShowWindowDecorationsCommand, IDS_SHOW_WINDOW_DECORATIONS_MENU); } diff --git a/chrome/browser/ui/tabs/tab_menu_model.cc b/chrome/browser/ui/tabs/tab_menu_model.cc index caf66a8..14e4e1f 100644 --- a/chrome/browser/ui/tabs/tab_menu_model.cc +++ b/chrome/browser/ui/tabs/tab_menu_model.cc @@ -21,7 +21,7 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) { (tab_strip->IsTabSelected(index) && tab_strip->selection_model().selected_indices().size() > 1); AddItemWithStringId(TabStripModel::CommandNewTab, IDS_TAB_CXMENU_NEWTAB); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(TabStripModel::CommandReload, IDS_TAB_CXMENU_RELOAD); AddItemWithStringId(TabStripModel::CommandDuplicate, IDS_TAB_CXMENU_DUPLICATE); @@ -35,7 +35,7 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) { TabStripModel::CommandTogglePinned, will_pin ? IDS_TAB_CXMENU_PIN_TAB : IDS_TAB_CXMENU_UNPIN_TAB); } - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); if (affects_multiple_tabs) { AddItemWithStringId(TabStripModel::CommandCloseTab, IDS_TAB_CXMENU_CLOSETABS); @@ -47,13 +47,13 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) { IDS_TAB_CXMENU_CLOSEOTHERTABS); AddItemWithStringId(TabStripModel::CommandCloseTabsToRight, IDS_TAB_CXMENU_CLOSETABSTORIGHT); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(TabStripModel::CommandRestoreTab, IDS_RESTORE_TAB); AddItemWithStringId(TabStripModel::CommandBookmarkAllTabs, IDS_TAB_CXMENU_BOOKMARK_ALL_TABS); if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableTabGroupsContextMenu)) { - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(TabStripModel::CommandSelectByDomain, IDS_TAB_CXMENU_SELECT_BY_DOMAIN); AddItemWithStringId(TabStripModel::CommandSelectByOpener, diff --git a/chrome/browser/ui/toolbar/action_box_menu_model.cc b/chrome/browser/ui/toolbar/action_box_menu_model.cc index fcd5a85..4f63a38 100644 --- a/chrome/browser/ui/toolbar/action_box_menu_model.cc +++ b/chrome/browser/ui/toolbar/action_box_menu_model.cc @@ -42,7 +42,7 @@ ActionBoxMenuModel::ActionBoxMenuModel(Browser* browser, int command_id = kFirstExtensionCommandId; const extensions::ExtensionList& action_box_items = action_box_menu_items(); if (!action_box_items.empty()) { - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); for (size_t i = 0; i < action_box_items.size(); ++i) { const extensions::Extension* extension = action_box_items[i]; AddItem(command_id, UTF8ToUTF16(extension->name())); diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.cc b/chrome/browser/ui/toolbar/back_forward_menu_model.cc index 87b4a70..3c343f5 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.cc @@ -82,6 +82,11 @@ ui::MenuModel::ItemType BackForwardMenuModel::GetTypeAt(int index) const { return IsSeparator(index) ? TYPE_SEPARATOR : TYPE_COMMAND; } +ui::MenuSeparatorType BackForwardMenuModel::GetSeparatorTypeAt( + int index) const { + return ui::NORMAL_SEPARATOR; +} + int BackForwardMenuModel::GetCommandIdAt(int index) const { return index; } diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.h b/chrome/browser/ui/toolbar/back_forward_menu_model.h index 8145fb9..97f1155 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model.h +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.h @@ -53,6 +53,7 @@ class BackForwardMenuModel : public ui::MenuModel { // out the total number of items to show. virtual int GetItemCount() const OVERRIDE; virtual ItemType GetTypeAt(int index) const OVERRIDE; + virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE; virtual int GetCommandIdAt(int index) const OVERRIDE; virtual string16 GetLabelAt(int index) const OVERRIDE; virtual bool IsItemDynamicAt(int index) const OVERRIDE; diff --git a/chrome/browser/ui/toolbar/bookmark_sub_menu_model.cc b/chrome/browser/ui/toolbar/bookmark_sub_menu_model.cc index 5c4f528..df0c884 100644 --- a/chrome/browser/ui/toolbar/bookmark_sub_menu_model.cc +++ b/chrome/browser/ui/toolbar/bookmark_sub_menu_model.cc @@ -31,6 +31,6 @@ void BookmarkSubMenuModel::Build(Browser* browser) { AddItemWithStringId(IDC_IMPORT_SETTINGS, IDS_IMPORT_SETTINGS_MENU_LABEL); #endif #if defined(OS_MACOSX) - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); #endif } diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc index 7f76e60..7b7e1f4 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model.cc +++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc @@ -97,7 +97,7 @@ void EncodingMenuModel::Build() { int id = it->first; string16& label = it->second; if (id == 0) { - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); } else { if (id == IDC_ENCODING_AUTO_DETECT) { AddCheckItem(id, label); @@ -172,7 +172,7 @@ ToolsMenuModel::~ToolsMenuModel() {} void ToolsMenuModel::Build(Browser* browser) { #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX) AddItemWithStringId(IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); #endif AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS); @@ -182,12 +182,12 @@ void ToolsMenuModel::Build(Browser* browser) { AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); #if !defined(OS_CHROMEOS) // Show IDC_FEEDBACK in "Tools" menu for non-ChromeOS platforms. AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); #endif encoding_menu_model_.reset(new EncodingMenuModel(browser)); @@ -198,7 +198,7 @@ void ToolsMenuModel::Build(Browser* browser) { AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC) - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); #endif } @@ -450,7 +450,14 @@ WrenchMenuModel::WrenchMenuModel() } void WrenchMenuModel::Build() { - bool is_touch_menu = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH; + // TODO(skuhne): Remove special casing when only the new menu style is left. +#if defined(USE_AURA) + bool is_new_menu = true; +#else + bool is_new_menu = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH; +#endif + if (is_new_menu) + AddSeparator(ui::SPACING_SEPARATOR); AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); @@ -468,10 +475,10 @@ void WrenchMenuModel::Build() { // Append the full menu including separators. The final separator only gets // appended when this is a touch menu - otherwise it would get added twice. - CreateCutCopyPasteMenu(is_touch_menu); + CreateCutCopyPasteMenu(is_new_menu); - if (!is_touch_menu) - CreateZoomMenu(); + if (!is_new_menu) + CreateZoomMenu(is_new_menu); AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); AddItemWithStringId(IDC_FIND, IDS_FIND); @@ -479,19 +486,19 @@ void WrenchMenuModel::Build() { tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); // In case of touch this is the last item. - if (!is_touch_menu) { + if (!is_new_menu) { AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_TOOLS_MENU, tools_menu_model_.get()); } - if (is_touch_menu) - CreateZoomMenu(); + if (is_new_menu) + CreateZoomMenu(is_new_menu); else - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); if (browser_defaults::kShowSyncSetupMenuItem && browser_->profile()->GetOriginalProfile()->IsSyncAccessible()) { @@ -499,14 +506,14 @@ void WrenchMenuModel::Build() { l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); } AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); // On ChromeOS-Touch, we don't want the about/background pages menu options. #if defined(OS_CHROMEOS) - if (!is_touch_menu) + if (!is_new_menu) #endif { AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); @@ -530,7 +537,7 @@ void WrenchMenuModel::Build() { GetNativeImageNamed(IDR_CONFLICT_MENU)); #endif - if (!is_touch_menu) { + if (!is_new_menu) { AddItemWithStringId(IDC_HELP_PAGE_VIA_MENU, IDS_HELP_PAGE); if (browser_defaults::kShowHelpMenuItemIcon) { @@ -545,7 +552,7 @@ void WrenchMenuModel::Build() { AddGlobalErrorMenuItems(); - if (is_touch_menu) { + if (is_new_menu) { AddSubMenuWithStringId(IDC_ZOOM_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); } @@ -555,10 +562,13 @@ void WrenchMenuModel::Build() { if (!base::win::IsMetroProcess()) #endif { - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItemWithStringId(IDC_EXIT, IDS_EXIT); } } + + if (is_new_menu) + AddSeparator(ui::SPACING_SEPARATOR); } void WrenchMenuModel::AddGlobalErrorMenuItems() { @@ -584,8 +594,8 @@ void WrenchMenuModel::AddGlobalErrorMenuItems() { } } -void WrenchMenuModel::CreateCutCopyPasteMenu(bool append_final_separator) { - AddSeparator(); +void WrenchMenuModel::CreateCutCopyPasteMenu(bool new_menu) { + AddSeparator(new_menu ? ui::LOWER_SEPARATOR: ui::NORMAL_SEPARATOR); #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the @@ -604,13 +614,13 @@ void WrenchMenuModel::CreateCutCopyPasteMenu(bool append_final_separator) { AddItemWithStringId(IDC_PASTE, IDS_PASTE); #endif - if (append_final_separator) - AddSeparator(); + if (new_menu) + AddSeparator(ui::UPPER_SEPARATOR); } -void WrenchMenuModel::CreateZoomMenu() { +void WrenchMenuModel::CreateZoomMenu(bool new_menu) { // This menu needs to be enclosed by separators. - AddSeparator(); + AddSeparator(new_menu ? ui::LOWER_SEPARATOR: ui::NORMAL_SEPARATOR); #if defined(OS_POSIX) && !defined(TOOLKIT_VIEWS) // WARNING: Mac does not use the ButtonMenuItemModel, but instead defines the @@ -636,7 +646,7 @@ void WrenchMenuModel::CreateZoomMenu() { AddItemWithStringId(IDC_FULLSCREEN, IDS_FULLSCREEN); #endif - AddSeparator(); + AddSeparator(new_menu ? ui::UPPER_SEPARATOR: ui::NORMAL_SEPARATOR); } void WrenchMenuModel::UpdateZoomControls() { diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.h b/chrome/browser/ui/toolbar/wrench_menu_model.h index 490c7ec..8f8d5a8 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model.h +++ b/chrome/browser/ui/toolbar/wrench_menu_model.h @@ -133,13 +133,14 @@ class WrenchMenuModel : public ui::SimpleMenuModel, // Appends everything needed for the clipboard menu: a menu break, the // clipboard menu content and the finalizing menu break. If the last break - // is not needed it can be suppressed by setting |append_final_separator| + // is not needed it can be suppressed by setting |new_menu| // to false. - void CreateCutCopyPasteMenu(bool append_final_separator); + void CreateCutCopyPasteMenu(bool new_menu); // Appends everything needed for the zoom menu: a menu break, then the zoom - // menu content and then another menu break. - void CreateZoomMenu(); + // menu content and then another menu break. If the new menu type is used, + // |new_menu| should be set to true. + void CreateZoomMenu(bool new_menu); string16 GetSyncMenuLabel() const; diff --git a/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc b/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc index c3472c1..30e3821 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc @@ -132,8 +132,9 @@ TEST_F(WrenchMenuModelTest, Basics) { // Execute a couple of the items and make sure it gets back to our delegate. // We can't use CountEnabledExecutable() here because the encoding menu's // delegate is internal, it doesn't use the one we pass in. - model.ActivatedAt(0); - EXPECT_TRUE(model.IsEnabledAt(0)); + // Note: The new menu has a spacing separator at the first slot. + model.ActivatedAt(1); + EXPECT_TRUE(model.IsEnabledAt(1)); // Make sure to use the index that is not separator in all configurations. model.ActivatedAt(2); EXPECT_TRUE(model.IsEnabledAt(2)); diff --git a/chrome/browser/ui/views/frame/browser_frame_aura.cc b/chrome/browser/ui/views/frame/browser_frame_aura.cc index 8f0fae7..bbea5f0 100644 --- a/chrome/browser/ui/views/frame/browser_frame_aura.cc +++ b/chrome/browser/ui/views/frame/browser_frame_aura.cc @@ -115,7 +115,7 @@ void BrowserFrameAura::ShowContextMenuForView(views::View* source, ui::SimpleMenuModel model(&menu_delegate); model.AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); model.AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); - model.AddSeparator(); + model.AddSeparator(ui::NORMAL_SEPARATOR); model.AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); views::MenuModelAdapter menu_adapter(&model); menu_runner_.reset(new views::MenuRunner(menu_adapter.CreateMenu())); diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc index 6e03e5b..e6c3e58 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_win.cc @@ -443,13 +443,13 @@ void BrowserFrameWin::UpdateDWMFrame() { } void BrowserFrameWin::BuildSystemMenuForBrowserWindow() { - system_menu_contents_->AddSeparator(); + system_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); if (chrome::CanOpenTaskManager()) { system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); } - system_menu_contents_->AddSeparator(); + system_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); system_menu_contents_->AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); AddFrameToggleItems(); @@ -460,11 +460,11 @@ void BrowserFrameWin::BuildSystemMenuForBrowserWindow() { void BrowserFrameWin::BuildSystemMenuForAppOrPopupWindow() { Browser* browser = browser_view()->browser(); if (browser->is_app() && chrome::CanOpenTaskManager()) { - system_menu_contents_->AddSeparator(); + system_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); } - system_menu_contents_->AddSeparator(); + system_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); encoding_menu_contents_.reset(new EncodingMenuModel(browser)); system_menu_contents_->AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, @@ -474,11 +474,11 @@ void BrowserFrameWin::BuildSystemMenuForAppOrPopupWindow() { zoom_menu_contents_.get()); system_menu_contents_->AddItemWithStringId(IDC_PRINT, IDS_PRINT); system_menu_contents_->AddItemWithStringId(IDC_FIND, IDS_FIND); - system_menu_contents_->AddSeparator(); + system_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); system_menu_contents_->AddItemWithStringId(IDC_PASTE, IDS_PASTE); system_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY); system_menu_contents_->AddItemWithStringId(IDC_CUT, IDS_CUT); - system_menu_contents_->AddSeparator(); + system_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); if (browser->is_app()) { system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_APP_MENU_NEW_WEB_PAGE); @@ -486,7 +486,7 @@ void BrowserFrameWin::BuildSystemMenuForAppOrPopupWindow() { system_menu_contents_->AddItemWithStringId(IDC_SHOW_AS_TAB, IDS_SHOW_AS_TAB); } - system_menu_contents_->AddSeparator(); + system_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); system_menu_contents_->AddItemWithStringId(IDC_RELOAD, IDS_APP_MENU_RELOAD); system_menu_contents_->AddItemWithStringId(IDC_FORWARD, IDS_CONTENT_CONTEXT_FORWARD); @@ -498,7 +498,7 @@ void BrowserFrameWin::BuildSystemMenuForAppOrPopupWindow() { void BrowserFrameWin::AddFrameToggleItems() { if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kDebugEnableFrameToggle)) { - system_menu_contents_->AddSeparator(); + system_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); system_menu_contents_->AddItem(IDC_DEBUG_FRAME_TOGGLE, L"Toggle Frame Type"); } diff --git a/chrome/browser/ui/views/menu_item_view_test.cc b/chrome/browser/ui/views/menu_item_view_test.cc index d2f6c19..83476c9 100644 --- a/chrome/browser/ui/views/menu_item_view_test.cc +++ b/chrome/browser/ui/views/menu_item_view_test.cc @@ -216,7 +216,8 @@ class MenuItemViewTestInsert : public MenuItemViewTestBase { 1000, ASCIIToUTF16("inserted item"), gfx::ImageSkia(), - views::MenuItemView::NORMAL); + views::MenuItemView::NORMAL, + ui::NORMAL_SEPARATOR); ASSERT_TRUE(inserted_item_); menu_->ChildrenChanged(); @@ -326,7 +327,8 @@ class MenuItemViewTestInsertWithSubmenu : public MenuItemViewTestBase { 1000, ASCIIToUTF16("inserted item"), gfx::ImageSkia(), - views::MenuItemView::NORMAL); + views::MenuItemView::NORMAL, + ui::NORMAL_SEPARATOR); ASSERT_TRUE(inserted_item_); menu_->ChildrenChanged(); diff --git a/chrome/browser/ui/views/menu_model_adapter_test.cc b/chrome/browser/ui/views/menu_model_adapter_test.cc index 9dd7fb5..94c00be 100644 --- a/chrome/browser/ui/views/menu_model_adapter_test.cc +++ b/chrome/browser/ui/views/menu_model_adapter_test.cc @@ -135,6 +135,10 @@ class CommonMenuModel : public ui::MenuModel { return false; } + virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE { + return ui::NORMAL_SEPARATOR; + } + virtual bool IsItemCheckedAt(int index) const OVERRIDE { return false; } diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc index 6f1df80..546be9c 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc @@ -2584,7 +2584,7 @@ void OmniboxViewWin::BuildContextMenu() { context_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY); } else { context_menu_contents_->AddItemWithStringId(IDS_UNDO, IDS_UNDO); - context_menu_contents_->AddSeparator(); + context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_contents_->AddItemWithStringId(IDC_CUT, IDS_CUT); context_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY); context_menu_contents_->AddItemWithStringId(IDC_PASTE, IDS_PASTE); @@ -2592,9 +2592,9 @@ void OmniboxViewWin::BuildContextMenu() { // IDS_PASTE_AND_SEARCH label as needed. context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); - context_menu_contents_->AddSeparator(); + context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); - context_menu_contents_->AddSeparator(); + context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, IDS_EDIT_SEARCH_ENGINES); } diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc index c01ea82..6ca5a5b 100644 --- a/chrome/browser/ui/views/wrench_menu.cc +++ b/chrome/browser/ui/views/wrench_menu.cc @@ -78,15 +78,24 @@ const SkColor kHotTouchBackgroundColor = SkColorSetARGB(247, 242, 242, 242); const SkColor kPushedTouchBackgroundColor = SkColorSetARGB(247, 235, 235, 235); const SkColor kTouchButtonText = 0xff5a5a5a; -const SkColor kTouchImageBrighten = 0x80ffffff; // Horizontal padding on the edges of the buttons. const int kHorizontalPadding = 6; // Horizontal padding for a touch enabled menu. const int kHorizontalTouchPadding = 15; -// For touch menu items we want to have this height in pixels. -const int kTouchItemHeight = 47; +// Menu items which have embedded buttons should have this height in pixel. +const int kMenuItemContainingButtonsHeight = 43; + +// Returns true when the new menu style is used. +// TODO(skuhne): Remove when only the new menu style is left. +bool IsNewMenu() { +#if defined(USE_AURA) + return true; +#else + return ui::GetDisplayLayout() == ui::LAYOUT_TOUCH; +#endif +} // Subclass of ImageButton whose preferred size includes the size of the border. class FullscreenButton : public ImageButton { @@ -113,7 +122,7 @@ class FullscreenButton : public ImageButton { class MenuButtonBorder : public views::Border { public: MenuButtonBorder() - : horizontal_padding_(ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ? + : horizontal_padding_(IsNewMenu() ? kHorizontalTouchPadding : kHorizontalPadding) {} @@ -175,7 +184,7 @@ class MenuButtonBackground : public views::Background { // Windows is drawing its own separators and we cannot use the touch button // for that. #if !defined(OS_WIN) - if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { + if (IsNewMenu()) { // Normal buttons get a border drawn on the right side and the rest gets // filled in. The left button however does not get a line to combine // buttons. @@ -402,36 +411,6 @@ class ButtonContainerMenuItemView : public MenuItemView { DISALLOW_COPY_AND_ASSIGN(ButtonContainerMenuItemView); }; -class TintedImageSource: public gfx::CanvasImageSource { - public: - TintedImageSource(gfx::ImageSkia& image, SkColor tint_value) - : CanvasImageSource(image.size(), false), - image_(image), - tint_value_(tint_value) { - } - - virtual ~TintedImageSource() { - } - - // Overridden from gfx::CanvasImageSource. - virtual void Draw(gfx::Canvas* canvas) OVERRIDE { - canvas->DrawImageInt(image_, 0, 0); - SkPaint paint; - // We leave the old alpha alone and add the new color multiplied - // with the source alpha to the existing alpha. Thus: We brighten - // the image up - but only the non transparent pixels. - paint.setXfermodeMode(SkXfermode::kDstATop_Mode); - paint.setColor(tint_value_); - canvas->sk_canvas()->drawPaint(paint); - } - - private: - const gfx::ImageSkia image_; - const SkColor tint_value_; - - DISALLOW_COPY_AND_ASSIGN(TintedImageSource); -}; - } // namespace // CutCopyPasteView ------------------------------------------------------------ @@ -453,17 +432,17 @@ class WrenchMenu::CutCopyPasteView : public WrenchMenuView { IDS_COPY, MenuButtonBackground::CENTER_BUTTON, copy_index, ©_background); - bool is_touch = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH; + bool is_new_menu = IsNewMenu(); TextButton* paste = CreateAndConfigureButton( IDS_PASTE, #if !defined(OS_WIN) - is_touch ? MenuButtonBackground::CENTER_BUTTON : + is_new_menu ? MenuButtonBackground::CENTER_BUTTON : #endif MenuButtonBackground::RIGHT_BUTTON, paste_index, NULL); - if (is_touch) { + if (is_new_menu) { cut->SetEnabledColor(kTouchButtonText); copy->SetEnabledColor(kTouchButtonText); paste->SetEnabledColor(kTouchButtonText); @@ -536,11 +515,11 @@ class WrenchMenu::ZoomView : public WrenchMenuView, zoom_label_->SetAutoColorReadabilityEnabled(false); zoom_label_->SetHorizontalAlignment(Label::ALIGN_RIGHT); - bool is_touch = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH; + bool is_new_menu = IsNewMenu(); MenuButtonBackground* center_bg = new MenuButtonBackground( #if !defined(OS_WIN) - is_touch ? MenuButtonBackground::RIGHT_BUTTON : + is_new_menu ? MenuButtonBackground::RIGHT_BUTTON : #endif MenuButtonBackground::CENTER_BUTTON); zoom_label_->set_background(center_bg); @@ -560,18 +539,8 @@ class WrenchMenu::ZoomView : public WrenchMenuView, gfx::ImageSkia* full_screen_image = ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( IDR_FULLSCREEN_MENU_BUTTON); - if (is_touch) { - // In case of touch, the menu needs to be brightened up a bit. - gfx::CanvasImageSource* source = new TintedImageSource( - *full_screen_image, kTouchImageBrighten); - // ImageSkia takes ownership of |source|. - tinted_fullscreen_image_ = gfx::ImageSkia(source, source->size()); - fullscreen_button_->SetImage(ImageButton::BS_NORMAL, - &tinted_fullscreen_image_); - } else { - fullscreen_button_->SetImage(ImageButton::BS_NORMAL, full_screen_image); - } - if (is_touch) { + fullscreen_button_->SetImage(ImageButton::BS_NORMAL, full_screen_image); + if (is_new_menu) { zoom_label_->SetEnabledColor(kTouchButtonText); decrement_button_->SetEnabledColor(kTouchButtonText); increment_button_->SetEnabledColor(kTouchButtonText); @@ -584,7 +553,7 @@ class WrenchMenu::ZoomView : public WrenchMenuView, fullscreen_button_->set_tag(fullscreen_index); fullscreen_button_->SetImageAlignment( ImageButton::ALIGN_CENTER, ImageButton::ALIGN_MIDDLE); - int horizontal_padding = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ? + int horizontal_padding = IsNewMenu() ? kHorizontalTouchPadding : kHorizontalPadding; fullscreen_button_->set_border(views::Border::CreateEmptyBorder( 0, horizontal_padding, 0, horizontal_padding)); @@ -608,8 +577,7 @@ class WrenchMenu::ZoomView : public WrenchMenuView, // The increment/decrement button are forced to the same width. int button_width = std::max(increment_button_->GetPreferredSize().width(), decrement_button_->GetPreferredSize().width()); - int zoom_padding = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ? - kTouchZoomPadding : kZoomPadding; + int zoom_padding = IsNewMenu() ? kTouchZoomPadding : kZoomPadding; int fullscreen_width = fullscreen_button_->GetPreferredSize().width() + zoom_padding; // Returned height doesn't matter as MenuItemView forces everything to the @@ -637,11 +605,11 @@ class WrenchMenu::ZoomView : public WrenchMenuView, bounds.set_width(button_width); increment_button_->SetBoundsRect(bounds); - bool is_touch = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH; - x += bounds.width() + (is_touch ? 0 : kZoomPadding); + bool is_new_menu = IsNewMenu(); + x += bounds.width() + (is_new_menu ? 0 : kZoomPadding); bounds.set_x(x); bounds.set_width(fullscreen_button_->GetPreferredSize().width() + - (is_touch ? kTouchZoomPadding : 0)); + (is_new_menu ? kTouchZoomPadding : 0)); fullscreen_button_->SetBoundsRect(bounds); } @@ -735,9 +703,6 @@ class WrenchMenu::ZoomView : public WrenchMenuView, ImageButton* fullscreen_button_; - // The tinted bitmap of the fullscreen button. - gfx::ImageSkia tinted_fullscreen_image_; - // Width given to |zoom_label_|. This is the width at 100%. int zoom_label_width_; @@ -998,7 +963,7 @@ void WrenchMenu::Observe(int type, void WrenchMenu::PopulateMenu(MenuItemView* parent, MenuModel* model, int* next_id) { - bool is_touch = ui::GetDisplayLayout() == ui::LAYOUT_TOUCH; + bool is_new_menu = IsNewMenu(); int index_offset = model->GetFirstItemIndex(NULL); for (int i = 0, max = model->GetItemCount(); i < max; ++i) { @@ -1007,10 +972,10 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent, // The button container menu items have a special height which we have to // use instead of the normal height. int height = 0; - if (is_touch && + if (is_new_menu && (model->GetCommandIdAt(index) == IDC_CUT || model->GetCommandIdAt(index) == IDC_ZOOM_MINUS)) - height = kTouchItemHeight; + height = kMenuItemContainingButtonsHeight; MenuItemView* item = AppendMenuItem( parent, model, index, model->GetTypeAt(index), next_id, height); @@ -1080,9 +1045,9 @@ MenuItemView* WrenchMenu::AppendMenuItem(MenuItemView* parent, } if (menu_item) { - // Flush all buttons to the right side of the menu for touch menus. - menu_item->set_use_right_margin( - ui::GetDisplayLayout() != ui::LAYOUT_TOUCH); + bool is_new_menu = IsNewMenu(); + // Flush all buttons to the right side of the menu for the new menu type. + menu_item->set_use_right_margin(!is_new_menu); menu_item->SetVisible(model->IsVisibleAt(index)); if (menu_type == MenuModel::TYPE_COMMAND && model->HasIcons()) { diff --git a/ui/base/models/menu_model.h b/ui/base/models/menu_model.h index bad38a7..ef8f76c 100644 --- a/ui/base/models/menu_model.h +++ b/ui/base/models/menu_model.h @@ -7,6 +7,7 @@ #include "base/string16.h" #include "ui/base/models/menu_model_delegate.h" +#include "ui/base/models/menu_separator_types.h" #include "ui/base/ui_export.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/native_widget_types.h" @@ -57,6 +58,9 @@ class UI_EXPORT MenuModel { // Returns the type of item at the specified index. virtual ItemType GetTypeAt(int index) const = 0; + // Returns the separator type at the specified index. + virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const = 0; + // Returns the command id of the item at the specified index. virtual int GetCommandIdAt(int index) const = 0; diff --git a/ui/base/models/menu_separator_types.h b/ui/base/models/menu_separator_types.h new file mode 100644 index 0000000..217bcee --- /dev/null +++ b/ui/base/models/menu_separator_types.h @@ -0,0 +1,24 @@ +// 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. + +#ifndef UI_BASE_MODELS_MENU_SEPARATOR_TYPES_H_ +#define UI_BASE_MODELS_MENU_SEPARATOR_TYPES_H_ + +namespace ui { + +// For a separator we have the following types. +enum MenuSeparatorType { + // Normal - top to bottom: Spacing, line, spacing + NORMAL_SEPARATOR, + // Upper - top to bottom: Line, spacing + UPPER_SEPARATOR, + // Lower - top to bottom: Spacing, line + LOWER_SEPARATOR, + // Spacing - top to bottom: Spacing only. + SPACING_SEPARATOR +}; + +} // namespace ui + +#endif // UI_BASE_MODELS_MENU_SEPARATOR_TYPES_H_ diff --git a/ui/base/models/simple_menu_model.cc b/ui/base/models/simple_menu_model.cc index 511b44e..e83fa6a 100644 --- a/ui/base/models/simple_menu_model.cc +++ b/ui/base/models/simple_menu_model.cc @@ -21,6 +21,7 @@ struct SimpleMenuModel::Item { int group_id; MenuModel* submenu; ButtonMenuItemModel* button_model; + MenuSeparatorType separator_type; }; //////////////////////////////////////////////////////////////////////////////// @@ -72,7 +73,7 @@ SimpleMenuModel::~SimpleMenuModel() { void SimpleMenuModel::AddItem(int command_id, const string16& label) { Item item = { command_id, label, gfx::Image(), TYPE_COMMAND, -1, NULL, - NULL }; + NULL, NORMAL_SEPARATOR }; AppendItem(item); } @@ -80,15 +81,20 @@ void SimpleMenuModel::AddItemWithStringId(int command_id, int string_id) { AddItem(command_id, l10n_util::GetStringUTF16(string_id)); } -void SimpleMenuModel::AddSeparator() { - Item item = { kSeparatorId, string16(), gfx::Image(), TYPE_SEPARATOR, -1, - NULL, NULL }; +void SimpleMenuModel::AddSeparator(MenuSeparatorType separator_type) { +#if !defined(USE_AURA) + if (separator_type != NORMAL_SEPARATOR) { + NOTIMPLEMENTED(); + } +#endif + Item item = { kSeparatorId, string16(), gfx::Image(), TYPE_SEPARATOR, + -1, NULL, NULL , separator_type }; AppendItem(item); } void SimpleMenuModel::AddCheckItem(int command_id, const string16& label) { Item item = { command_id, label, gfx::Image(), TYPE_CHECK, -1, NULL, - NULL }; + NULL, NORMAL_SEPARATOR }; AppendItem(item); } @@ -99,7 +105,7 @@ void SimpleMenuModel::AddCheckItemWithStringId(int command_id, int string_id) { void SimpleMenuModel::AddRadioItem(int command_id, const string16& label, int group_id) { Item item = { command_id, label, gfx::Image(), TYPE_RADIO, group_id, NULL, - NULL }; + NULL, NORMAL_SEPARATOR }; AppendItem(item); } @@ -111,14 +117,14 @@ void SimpleMenuModel::AddRadioItemWithStringId(int command_id, int string_id, void SimpleMenuModel::AddButtonItem(int command_id, ButtonMenuItemModel* model) { Item item = { command_id, string16(), gfx::Image(), TYPE_BUTTON_ITEM, -1, - NULL, model }; + NULL, model, NORMAL_SEPARATOR }; AppendItem(item); } void SimpleMenuModel::AddSubMenu(int command_id, const string16& label, MenuModel* model) { Item item = { command_id, label, gfx::Image(), TYPE_SUBMENU, -1, model, - NULL }; + NULL, NORMAL_SEPARATOR }; AppendItem(item); } @@ -130,7 +136,7 @@ void SimpleMenuModel::AddSubMenuWithStringId(int command_id, void SimpleMenuModel::InsertItemAt( int index, int command_id, const string16& label) { Item item = { command_id, label, gfx::Image(), TYPE_COMMAND, -1, NULL, - NULL }; + NULL, NORMAL_SEPARATOR }; InsertItemAtIndex(item, index); } @@ -139,16 +145,22 @@ void SimpleMenuModel::InsertItemWithStringIdAt( InsertItemAt(index, command_id, l10n_util::GetStringUTF16(string_id)); } -void SimpleMenuModel::InsertSeparatorAt(int index) { - Item item = { kSeparatorId, string16(), gfx::Image(), TYPE_SEPARATOR, -1, - NULL, NULL }; +void SimpleMenuModel::InsertSeparatorAt(int index, + MenuSeparatorType separator_type) { +#if !defined(USE_AURA) + if (separator_type != NORMAL_SEPARATOR) { + NOTIMPLEMENTED(); + } +#endif + Item item = { kSeparatorId, string16(), gfx::Image(), TYPE_SEPARATOR, + -1, NULL, NULL, separator_type }; InsertItemAtIndex(item, index); } void SimpleMenuModel::InsertCheckItemAt( int index, int command_id, const string16& label) { Item item = { command_id, label, gfx::Image(), TYPE_CHECK, -1, NULL, - NULL }; + NULL, NORMAL_SEPARATOR }; InsertItemAtIndex(item, index); } @@ -161,7 +173,7 @@ void SimpleMenuModel::InsertCheckItemWithStringIdAt( void SimpleMenuModel::InsertRadioItemAt( int index, int command_id, const string16& label, int group_id) { Item item = { command_id, label, gfx::Image(), TYPE_RADIO, group_id, NULL, - NULL }; + NULL, NORMAL_SEPARATOR }; InsertItemAtIndex(item, index); } @@ -174,7 +186,7 @@ void SimpleMenuModel::InsertRadioItemWithStringIdAt( void SimpleMenuModel::InsertSubMenuAt( int index, int command_id, const string16& label, MenuModel* model) { Item item = { command_id, label, gfx::Image(), TYPE_SUBMENU, -1, model, - NULL }; + NULL, NORMAL_SEPARATOR }; InsertItemAtIndex(item, index); } @@ -221,6 +233,10 @@ MenuModel::ItemType SimpleMenuModel::GetTypeAt(int index) const { return items_[ValidateItemIndex(FlipIndex(index))].type; } +ui::MenuSeparatorType SimpleMenuModel::GetSeparatorTypeAt(int index) const { + return items_[ValidateItemIndex(FlipIndex(index))].separator_type; +} + int SimpleMenuModel::GetCommandIdAt(int index) const { return items_[ValidateItemIndex(FlipIndex(index))].command_id; } diff --git a/ui/base/models/simple_menu_model.h b/ui/base/models/simple_menu_model.h index c62fb22..23bc886 100644 --- a/ui/base/models/simple_menu_model.h +++ b/ui/base/models/simple_menu_model.h @@ -74,7 +74,7 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { // Methods for adding items to the model. void AddItem(int command_id, const string16& label); void AddItemWithStringId(int command_id, int string_id); - void AddSeparator(); + void AddSeparator(MenuSeparatorType separator_type); void AddCheckItem(int command_id, const string16& label); void AddCheckItemWithStringId(int command_id, int string_id); void AddRadioItem(int command_id, const string16& label, int group_id); @@ -89,7 +89,7 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { // Methods for inserting items into the model. void InsertItemAt(int index, int command_id, const string16& label); void InsertItemWithStringIdAt(int index, int command_id, int string_id); - void InsertSeparatorAt(int index); + void InsertSeparatorAt(int index, MenuSeparatorType separator_type); void InsertCheckItemAt(int index, int command_id, const string16& label); void InsertCheckItemWithStringIdAt(int index, int command_id, int string_id); void InsertRadioItemAt( @@ -115,6 +115,7 @@ class UI_EXPORT SimpleMenuModel : public MenuModel { virtual bool HasIcons() const OVERRIDE; virtual int GetItemCount() const OVERRIDE; virtual ItemType GetTypeAt(int index) const OVERRIDE; + virtual ui::MenuSeparatorType GetSeparatorTypeAt(int index) const OVERRIDE; virtual int GetCommandIdAt(int index) const OVERRIDE; virtual string16 GetLabelAt(int index) const OVERRIDE; virtual bool IsItemDynamicAt(int index) const OVERRIDE; diff --git a/ui/base/native_theme/native_theme_aura.cc b/ui/base/native_theme/native_theme_aura.cc index 40c2d5f..f632808 100644 --- a/ui/base/native_theme/native_theme_aura.cc +++ b/ui/base/native_theme/native_theme_aura.cc @@ -107,8 +107,12 @@ SkColor NativeThemeAura::GetSystemColor(ColorId color_id) const { case kColorId_FocusedMenuItemBackgroundColor: return kFocusedMenuItemBackgroundColor; case kColorId_MenuSeparatorColor: +#if defined(USE_AURA) + return kMenuSeparatorColorTouch; +#else return ui::GetDisplayLayout() == ui::LAYOUT_TOUCH ? kMenuSeparatorColorTouch : kMenuSeparatorColor; +#endif // Label case kColorId_LabelEnabledColor: @@ -245,6 +245,7 @@ 'base/models/menu_model.cc', 'base/models/menu_model.h', 'base/models/menu_model_delegate.h', + 'base/models/menu_separator_types.h', 'base/models/simple_menu_model.cc', 'base/models/simple_menu_model.h', 'base/models/table_model.cc', diff --git a/ui/views/controls/menu/menu_config.cc b/ui/views/controls/menu/menu_config.cc index 55ad7a0..8cd3a8f 100644 --- a/ui/views/controls/menu/menu_config.cc +++ b/ui/views/controls/menu/menu_config.cc @@ -33,6 +33,9 @@ MenuConfig::MenuConfig() arrow_width(9), gutter_width(0), separator_height(6), + separator_upper_height(3), + separator_lower_height(4), + separator_spacing_height(3), render_gutter(false), show_mnemonics(false), scroll_arrow_height(3), @@ -43,6 +46,7 @@ MenuConfig::MenuConfig() align_arrow_and_shortcut(false), offset_context_menus(false) { // Use 40px tall menu items when running in touch optimized mode. + // For Windows use 40px tall menu items when running in touch optimized mode. if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) { item_top_margin = item_no_icon_top_margin = 12; item_bottom_margin = item_no_icon_bottom_margin = 13; diff --git a/ui/views/controls/menu/menu_config.h b/ui/views/controls/menu/menu_config.h index cce8673..32d26e7 100644 --- a/ui/views/controls/menu/menu_config.h +++ b/ui/views/controls/menu/menu_config.h @@ -81,9 +81,18 @@ struct VIEWS_EXPORT MenuConfig { // Width of the gutter. Only used if render_gutter is true. int gutter_width; - // Height of the separator. + // Height of a normal separator (ui::NORMAL_SEPARATOR). int separator_height; + // Height of a ui::UPPER_SEPARATOR. + int separator_upper_height; + + // Height of a ui::LOWER_SEPARATOR. + int separator_lower_height; + + // Height of a ui::SPACING_SEPARATOR. + int separator_spacing_height; + // Whether or not the gutter should be rendered. The gutter is specific to // Vista. bool render_gutter; diff --git a/ui/views/controls/menu/menu_config_views.cc b/ui/views/controls/menu/menu_config_views.cc index d6943d4..e369c956 100644 --- a/ui/views/controls/menu/menu_config_views.cc +++ b/ui/views/controls/menu/menu_config_views.cc @@ -31,13 +31,7 @@ MenuConfig* MenuConfig::Create() { config->check_height = check->height(); config->item_left_margin = 4; config->item_min_height = 29; - // TODO(skuhne): Separators in menus should have the same padding in touch - // mode but currently the touch wrench menu relies on separators having no - // padding to implement full-height buttons. - if (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) - config->separator_height = 1; - else - config->separator_height = 15; + config->separator_height = 15; config->font = rb.GetFont(ResourceBundle::BaseFont); config->label_to_arrow_padding = 20; config->label_to_accelerator_padding = 20; diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc index cae0382..bc0c1f7 100644 --- a/ui/views/controls/menu/menu_item_view.cc +++ b/ui/views/controls/menu/menu_item_view.cc @@ -206,18 +206,20 @@ void MenuItemView::Cancel() { } } -MenuItemView* MenuItemView::AddMenuItemAt(int index, - int item_id, - const string16& label, - const gfx::ImageSkia& icon, - Type type) { +MenuItemView* MenuItemView::AddMenuItemAt( + int index, + int item_id, + const string16& label, + const gfx::ImageSkia& icon, + Type type, + ui::MenuSeparatorType separator_style) { DCHECK_NE(type, EMPTY); DCHECK_LE(0, index); if (!submenu_) CreateSubmenu(); DCHECK_GE(submenu_->child_count(), index); if (type == SEPARATOR) { - submenu_->AddChildViewAt(new MenuSeparator(), index); + submenu_->AddChildViewAt(new MenuSeparator(separator_style), index); return NULL; } MenuItemView* item = new MenuItemView(this, item_id, type); @@ -251,18 +253,21 @@ void MenuItemView::RemoveMenuItemAt(int index) { MenuItemView* MenuItemView::AppendMenuItem(int item_id, const string16& label, Type type) { - return AppendMenuItemImpl(item_id, label, gfx::ImageSkia(), type); + return AppendMenuItemImpl(item_id, label, gfx::ImageSkia(), type, + ui::NORMAL_SEPARATOR); } MenuItemView* MenuItemView::AppendSubMenu(int item_id, const string16& label) { - return AppendMenuItemImpl(item_id, label, gfx::ImageSkia(), SUBMENU); + return AppendMenuItemImpl(item_id, label, gfx::ImageSkia(), SUBMENU, + ui::NORMAL_SEPARATOR); } MenuItemView* MenuItemView::AppendSubMenuWithIcon(int item_id, const string16& label, const gfx::ImageSkia& icon) { - return AppendMenuItemImpl(item_id, label, icon, SUBMENU); + return AppendMenuItemImpl( + item_id, label, icon, SUBMENU, ui::NORMAL_SEPARATOR); } MenuItemView* MenuItemView::AppendMenuItemWithLabel(int item_id, @@ -275,13 +280,15 @@ MenuItemView* MenuItemView::AppendDelegateMenuItem(int item_id) { } void MenuItemView::AppendSeparator() { - AppendMenuItemImpl(0, string16(), gfx::ImageSkia(), SEPARATOR); + AppendMenuItemImpl( + 0, string16(), gfx::ImageSkia(), SEPARATOR, ui::NORMAL_SEPARATOR); } MenuItemView* MenuItemView::AppendMenuItemWithIcon(int item_id, const string16& label, const gfx::ImageSkia& icon) { - return AppendMenuItemImpl(item_id, label, icon, NORMAL); + return AppendMenuItemImpl( + item_id, label, icon, NORMAL, ui::NORMAL_SEPARATOR); } MenuItemView* MenuItemView::AppendMenuItemFromModel(ui::MenuModel* model, @@ -289,6 +296,7 @@ MenuItemView* MenuItemView::AppendMenuItemFromModel(ui::MenuModel* model, int id) { gfx::Image icon; string16 label; + ui::MenuSeparatorType separator_style = ui::NORMAL_SEPARATOR; MenuItemView::Type type; ui::MenuModel::ItemType menu_type = model->GetTypeAt(index); switch (menu_type) { @@ -307,6 +315,7 @@ MenuItemView* MenuItemView::AppendMenuItemFromModel(ui::MenuModel* model, break; case ui::MenuModel::TYPE_SEPARATOR: type = MenuItemView::SEPARATOR; + separator_style = model->GetSeparatorTypeAt(index); break; case ui::MenuModel::TYPE_SUBMENU: model->GetIconAt(index, &icon); @@ -322,15 +331,18 @@ MenuItemView* MenuItemView::AppendMenuItemFromModel(ui::MenuModel* model, return AppendMenuItemImpl(id, label, icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia(), - type); + type, + separator_style); } -MenuItemView* MenuItemView::AppendMenuItemImpl(int item_id, - const string16& label, - const gfx::ImageSkia& icon, - Type type) { +MenuItemView* MenuItemView::AppendMenuItemImpl( + int item_id, + const string16& label, + const gfx::ImageSkia& icon, + Type type, + ui::MenuSeparatorType separator_style) { const int index = submenu_ ? submenu_->child_count() : 0; - return AddMenuItemAt(index, item_id, label, icon, type); + return AddMenuItemAt(index, item_id, label, icon, type, separator_style); } SubmenuView* MenuItemView::CreateSubmenu() { diff --git a/ui/views/controls/menu/menu_item_view.h b/ui/views/controls/menu/menu_item_view.h index c80a1d3..bbe258c 100644 --- a/ui/views/controls/menu/menu_item_view.h +++ b/ui/views/controls/menu/menu_item_view.h @@ -12,6 +12,7 @@ #include "base/logging.h" #include "base/string16.h" #include "build/build_config.h" +#include "ui/base/models/menu_separator_types.h" #include "ui/gfx/image/image_skia.h" #include "ui/views/view.h" @@ -133,7 +134,8 @@ class VIEWS_EXPORT MenuItemView : public View { int item_id, const string16& label, const gfx::ImageSkia& icon, - Type type); + Type type, + ui::MenuSeparatorType separator_style); // Remove an item from the menu at a specified index. // ChildrenChanged() should be called after removing menu items (whether @@ -193,7 +195,8 @@ class VIEWS_EXPORT MenuItemView : public View { MenuItemView* AppendMenuItemImpl(int item_id, const string16& label, const gfx::ImageSkia& icon, - Type type); + Type type, + ui::MenuSeparatorType separator_style); // Returns the view that contains child menu items. If the submenu has // not been creates, this creates it. diff --git a/ui/views/controls/menu/menu_model_adapter_unittest.cc b/ui/views/controls/menu/menu_model_adapter_unittest.cc index a371d9a..ee0846f 100644 --- a/ui/views/controls/menu/menu_model_adapter_unittest.cc +++ b/ui/views/controls/menu/menu_model_adapter_unittest.cc @@ -50,6 +50,11 @@ class MenuModelBase : public ui::MenuModel { return items_[index - GetFirstItemIndex(NULL)].type; } + virtual ui::MenuSeparatorType GetSeparatorTypeAt( + int index) const OVERRIDE { + return ui::NORMAL_SEPARATOR; + } + virtual int GetCommandIdAt(int index) const OVERRIDE { return index - GetFirstItemIndex(NULL) + command_id_base_; } diff --git a/ui/views/controls/menu/menu_separator.h b/ui/views/controls/menu/menu_separator.h index f3eabb2..cb48e04 100644 --- a/ui/views/controls/menu/menu_separator.h +++ b/ui/views/controls/menu/menu_separator.h @@ -6,19 +6,23 @@ #define UI_VIEWS_CONTROLS_MENU_MENU_SEPARATOR_H_ #include "base/compiler_specific.h" +#include "ui/base/models/menu_separator_types.h" #include "ui/views/view.h" namespace views { class MenuSeparator : public View { public: - MenuSeparator() {} + explicit MenuSeparator(ui::MenuSeparatorType type) : type_(type) {} // View overrides. virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; virtual gfx::Size GetPreferredSize() OVERRIDE; private: + // The type of the separator. + const ui::MenuSeparatorType type_; + DISALLOW_COPY_AND_ASSIGN(MenuSeparator); }; diff --git a/ui/views/controls/menu/menu_separator_views.cc b/ui/views/controls/menu/menu_separator_views.cc index 61ec07d..4d267df 100644 --- a/ui/views/controls/menu/menu_separator_views.cc +++ b/ui/views/controls/menu/menu_separator_views.cc @@ -18,14 +18,36 @@ const int kSeparatorHeight = 1; namespace views { void MenuSeparator::OnPaint(gfx::Canvas* canvas) { - canvas->FillRect(gfx::Rect(0, height() / 2, width(), kSeparatorHeight), + int pos = 0; + if (type_ == ui::LOWER_SEPARATOR) + pos = height() - kSeparatorHeight; + else if (type_ != ui::SPACING_SEPARATOR) + pos = height() / 2; + else if (type_ != ui::UPPER_SEPARATOR) + return; + canvas->FillRect(gfx::Rect(0, pos, width(), kSeparatorHeight), ui::NativeTheme::instance()->GetSystemColor( - ui::NativeTheme::kColorId_MenuSeparatorColor)); + ui::NativeTheme::kColorId_MenuSeparatorColor)); } gfx::Size MenuSeparator::GetPreferredSize() { + int height = MenuConfig::instance().separator_height; + switch(type_) { + case ui::SPACING_SEPARATOR: + height = MenuConfig::instance().separator_spacing_height; + break; + case ui::LOWER_SEPARATOR: + height = MenuConfig::instance().separator_lower_height; + break; + case ui::UPPER_SEPARATOR: + height = MenuConfig::instance().separator_upper_height; + break; + default: + height = MenuConfig::instance().separator_height; + break; + } return gfx::Size(10, // Just in case we're the only item in a menu. - MenuConfig::instance().separator_height); + height); } } // namespace views diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc index 71c795f85..c1afcea 100644 --- a/ui/views/controls/textfield/native_textfield_views.cc +++ b/ui/views/controls/textfield/native_textfield_views.cc @@ -1069,7 +1069,7 @@ void NativeTextfieldViews::UpdateContextMenu() { context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE); - context_menu_contents_->AddSeparator(); + context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, IDS_APP_SELECT_ALL); TextfieldController* controller = textfield_->GetController(); diff --git a/ui/views/controls/textfield/native_textfield_win.cc b/ui/views/controls/textfield/native_textfield_win.cc index a89896c..6baebf6 100644 --- a/ui/views/controls/textfield/native_textfield_win.cc +++ b/ui/views/controls/textfield/native_textfield_win.cc @@ -1197,11 +1197,11 @@ void NativeTextfieldWin::BuildContextMenu() { return; context_menu_contents_.reset(new ui::SimpleMenuModel(this)); context_menu_contents_->AddItemWithStringId(IDS_APP_UNDO, IDS_APP_UNDO); - context_menu_contents_->AddSeparator(); + context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT); context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY); context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE); - context_menu_contents_->AddSeparator(); + context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, IDS_APP_SELECT_ALL); } diff --git a/ui/views/examples/menu_example.cc b/ui/views/examples/menu_example.cc index b11e90c..cf73038 100644 --- a/ui/views/examples/menu_example.cc +++ b/ui/views/examples/menu_example.cc @@ -81,18 +81,18 @@ ExampleMenuModel::ExampleMenuModel() : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), current_encoding_command_id_(COMMAND_SELECT_ASCII) { AddItem(COMMAND_DO_SOMETHING, ASCIIToUTF16("Do Something")); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddRadioItem(COMMAND_SELECT_ASCII, ASCIIToUTF16("ASCII"), GROUP_MAKE_DECISION); AddRadioItem(COMMAND_SELECT_UTF8, ASCIIToUTF16("UTF-8"), GROUP_MAKE_DECISION); AddRadioItem(COMMAND_SELECT_UTF16, ASCIIToUTF16("UTF-16"), GROUP_MAKE_DECISION); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddCheckItem(COMMAND_CHECK_APPLE, ASCIIToUTF16("Apple")); AddCheckItem(COMMAND_CHECK_ORANGE, ASCIIToUTF16("Orange")); AddCheckItem(COMMAND_CHECK_KIWI, ASCIIToUTF16("Kiwi")); - AddSeparator(); + AddSeparator(ui::NORMAL_SEPARATOR); AddItem(COMMAND_GO_HOME, ASCIIToUTF16("Go Home")); submenu_.reset(new ui::SimpleMenuModel(this)); diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index b99238e..c902b17 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -1553,6 +1553,7 @@ class MockMenuModel : public ui::MenuModel { MOCK_CONST_METHOD1(GetFirstItemIndex, int(gfx::NativeMenu native_menu)); MOCK_CONST_METHOD0(GetItemCount, int()); MOCK_CONST_METHOD1(GetTypeAt, ItemType(int index)); + MOCK_CONST_METHOD1(GetSeparatorTypeAt, ui::MenuSeparatorType(int index)); MOCK_CONST_METHOD1(GetCommandIdAt, int(int index)); MOCK_CONST_METHOD1(GetLabelAt, string16(int index)); MOCK_CONST_METHOD1(IsItemDynamicAt, bool(int index)); |