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

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: Rebased and adressed comments. 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
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..26a44e9cb877753a26effee0e5845ddae9624b40 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;
+ // Place the menu below if it does not fit above.
minch1 2017/05/09 16:25:20 Wrong position of the comment. Will update it in n
if (pref.height() >
state_.initial_bounds.y() + kCenteredContextMenuYOffset) {
- // Menu does not fit above the anchor. We move it to below.
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_SIDECENTER) {
+ y += (state_.initial_bounds.height() - pref.height()) / 2;
}
if (!state_.monitor_bounds.IsEmpty() &&

Powered by Google App Engine
This is Rietveld 408576698