Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: ui/views/controls/combobox/native_combobox_views.cc

Issue 10829176: Update drop down menu look & feel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moved offset code Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/combobox/native_combobox_views.cc
diff --git a/ui/views/controls/combobox/native_combobox_views.cc b/ui/views/controls/combobox/native_combobox_views.cc
index e0032c30986a737c102b6d88815f6ef45f1ba760..bd28b4e00ae43d6eea2a5363a0cc67c20efa5216 100644
--- a/ui/views/controls/combobox/native_combobox_views.cc
+++ b/ui/views/controls/combobox/native_combobox_views.cc
@@ -31,6 +31,12 @@ const int kLeftInsetSize = 4;
const int kBottomInsetSize = 4;
const int kRightInsetSize = 4;
+// Menu border widths
+const int kMenuBorderWidthLeft = 1;
+const int kMenuBorderWidthTop = 2;
+const int kMenuBorderWidthRight = 1;
+const int kMenuBorderWidthBottom = 2;
+
// Limit how small a combobox can be.
const int kMinComboboxWidth = 148;
@@ -57,7 +63,7 @@ NativeComboboxViews::NativeComboboxViews(Combobox* combobox)
: combobox_(combobox),
text_border_(new FocusableBorder()),
disclosure_arrow_(ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_DISCLOSURE_ARROW).ToImageSkia()),
+ IDR_MENU_DROPARROW).ToImageSkia()),
dropdown_open_(false),
selected_index_(-1),
content_width_(0),
@@ -324,15 +330,18 @@ void NativeComboboxViews::ShowDropDownMenu() {
// Extend the menu to the width of the combobox.
MenuItemView* menu = dropdown_list_menu_runner_->GetMenu();
SubmenuView* submenu = menu->CreateSubmenu();
- submenu->set_minimum_preferred_width(size().width());
-
-#if defined(USE_AURA)
- // Aura style is to have the menu over the bounds. Below bounds is default.
- menu->set_menu_position(views::MenuItemView::POSITION_OVER_BOUNDS);
-#endif
+ submenu->set_minimum_preferred_width(size().width() -
+ (kMenuBorderWidthLeft + kMenuBorderWidthRight));
gfx::Rect lb = GetLocalBounds();
gfx::Point menu_position(lb.origin());
+
+ // Inset the menu's requested position so the border of the menu lines up
+ // with the border of the combobox.
+ menu_position.set_x(menu_position.x() + kMenuBorderWidthLeft);
+ menu_position.set_y(menu_position.y() + kMenuBorderWidthTop);
+ lb.set_width(lb.width() - (kMenuBorderWidthLeft + kMenuBorderWidthRight));
+
View::ConvertPointToScreen(this, &menu_position);
if (menu_position.x() < 0)
menu_position.set_x(0);

Powered by Google App Engine
This is Rietveld 408576698