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

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 2861873002: Align the base of the shelf's context menu to the top edge of the shelf. (Closed)
Patch Set: nits. Created 3 years, 7 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
« no previous file with comments | « chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc ('k') | ui/views/controls/menu/menu_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_controller.cc
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index f9aac0a605a8bc1c51c65f28c3bce22e55c81e27..a5ecb7df05c4a3fc1bda4e00ee870b38a24475e9 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -1950,15 +1950,19 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
if (menu_config.offset_context_menus && state_.context_menu)
x -= 1;
} else if (state_.anchor == MENU_ANCHOR_BOTTOMCENTER) {
- x = x - (pref.width() - state_.initial_bounds.width()) / 2;
+ x += (state_.initial_bounds.width() - pref.width()) / 2;
if (pref.height() >
state_.initial_bounds.y() + kCenteredContextMenuYOffset) {
- // Menu does not fit above the anchor. We move it to below.
+ // Place the menu below if it does not fit above.
y = state_.initial_bounds.y() - kCenteredContextMenuYOffset;
} else {
y = std::max(0, state_.initial_bounds.y() - pref.height()) +
kCenteredContextMenuYOffset;
}
+ } else if (state_.anchor == MENU_ANCHOR_FIXED_BOTTOMCENTER) {
+ x += (state_.initial_bounds.width() - pref.width()) / 2;
+ } else if (state_.anchor == MENU_ANCHOR_FIXED_SIDECENTER) {
+ y += (state_.initial_bounds.height() - pref.height()) / 2;
}
if (!state_.monitor_bounds.IsEmpty() &&
« no previous file with comments | « chrome/browser/ui/window_sizer/window_sizer_ash_uitest.cc ('k') | ui/views/controls/menu/menu_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698