diff options
author | hajimehoshi@chromium.org <hajimehoshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-26 19:03:11 +0000 |
---|---|---|
committer | hajimehoshi@chromium.org <hajimehoshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-26 19:03:11 +0000 |
commit | 2f42285deb96a498d3cbdb1a71455c3e539b8981 (patch) | |
tree | 340b637744c45f3390708f5bf81a91a57799ff1a /ui | |
parent | ca1f874b4dedec0bf0a067b408bbc162274486e3 (diff) | |
download | chromium_src-2f42285deb96a498d3cbdb1a71455c3e539b8981.zip chromium_src-2f42285deb96a498d3cbdb1a71455c3e539b8981.tar.gz chromium_src-2f42285deb96a498d3cbdb1a71455c3e539b8981.tar.bz2 |
Combobox: Have the first item not rendered for an action combobox
This CL skips rendering the first item and separators on the dropdown
menu for an 'action' combobox.
BUG=341994
TEST=manual
Review URL: https://codereview.chromium.org/178003009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253531 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/controls/combobox/combobox.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc index d87825d..95f4908 100644 --- a/ui/views/controls/combobox/combobox.cc +++ b/ui/views/controls/combobox/combobox.cc @@ -589,9 +589,14 @@ void Combobox::UpdateFromModel() { int num_items = model()->GetItemCount(); int width = 0; + bool text_item_appended = false; for (int i = 0; i < num_items; ++i) { + // When STYLE_ACTION is used, the first item and the following separators + // are not added to the dropdown menu. It is assumed that the first item is + // always selected and rendered on the top of the action button. if (model()->IsItemSeparatorAt(i)) { - menu->AppendSeparator(); + if (text_item_appended || style_ != STYLE_ACTION) + menu->AppendSeparator(); continue; } @@ -601,7 +606,10 @@ void Combobox::UpdateFromModel() { // text is displayed correctly in right-to-left UIs. base::i18n::AdjustStringForLocaleDirection(&text); - menu->AppendMenuItem(i + kFirstMenuItemId, text, MenuItemView::NORMAL); + if (style_ != STYLE_ACTION || i > 0) { + menu->AppendMenuItem(i + kFirstMenuItemId, text, MenuItemView::NORMAL); + text_item_appended = true; + } if (style_ != STYLE_ACTION || i == selected_index_) width = std::max(width, gfx::GetStringWidth(text, font_list)); |