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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 // simply opening the menu (bug 142992). 1943 // simply opening the menu (bug 142992).
1944 if (menu_config.offset_context_menus && state_.context_menu) 1944 if (menu_config.offset_context_menus && state_.context_menu)
1945 x += 1; 1945 x += 1;
1946 1946
1947 y = state_.initial_bounds.bottom(); 1947 y = state_.initial_bounds.bottom();
1948 if (state_.anchor == MENU_ANCHOR_TOPRIGHT) { 1948 if (state_.anchor == MENU_ANCHOR_TOPRIGHT) {
1949 x = x + state_.initial_bounds.width() - pref.width(); 1949 x = x + state_.initial_bounds.width() - pref.width();
1950 if (menu_config.offset_context_menus && state_.context_menu) 1950 if (menu_config.offset_context_menus && state_.context_menu)
1951 x -= 1; 1951 x -= 1;
1952 } else if (state_.anchor == MENU_ANCHOR_BOTTOMCENTER) { 1952 } else if (state_.anchor == MENU_ANCHOR_BOTTOMCENTER) {
1953 x = x - (pref.width() - state_.initial_bounds.width()) / 2; 1953 x += (state_.initial_bounds.width() - pref.width()) / 2;
1954 if (pref.height() > 1954 if (pref.height() >
1955 state_.initial_bounds.y() + kCenteredContextMenuYOffset) { 1955 state_.initial_bounds.y() + kCenteredContextMenuYOffset) {
1956 // Menu does not fit above the anchor. We move it to below. 1956 // Place the menu below if it does not fit above.
1957 y = state_.initial_bounds.y() - kCenteredContextMenuYOffset; 1957 y = state_.initial_bounds.y() - kCenteredContextMenuYOffset;
1958 } else { 1958 } else {
1959 y = std::max(0, state_.initial_bounds.y() - pref.height()) + 1959 y = std::max(0, state_.initial_bounds.y() - pref.height()) +
1960 kCenteredContextMenuYOffset; 1960 kCenteredContextMenuYOffset;
1961 } 1961 }
1962 } else if (state_.anchor == MENU_ANCHOR_FIXED_BOTTOMCENTER) {
1963 x += (state_.initial_bounds.width() - pref.width()) / 2;
1964 } else if (state_.anchor == MENU_ANCHOR_FIXED_SIDECENTER) {
1965 y += (state_.initial_bounds.height() - pref.height()) / 2;
1962 } 1966 }
1963 1967
1964 if (!state_.monitor_bounds.IsEmpty() && 1968 if (!state_.monitor_bounds.IsEmpty() &&
1965 y + pref.height() > state_.monitor_bounds.bottom()) { 1969 y + pref.height() > state_.monitor_bounds.bottom()) {
1966 // The menu doesn't fit fully below the button on the screen. The menu 1970 // The menu doesn't fit fully below the button on the screen. The menu
1967 // position with respect to the bounds will be preserved if it has 1971 // position with respect to the bounds will be preserved if it has
1968 // already been drawn. When the requested positioning is below the bounds 1972 // already been drawn. When the requested positioning is below the bounds
1969 // it will shrink the menu to make it fit below. 1973 // it will shrink the menu to make it fit below.
1970 // If the requested positioning is best fit, it will first try to fit the 1974 // If the requested positioning is best fit, it will first try to fit the
1971 // menu below. If that does not fit it will try to place it above. If 1975 // menu below. If that does not fit it will try to place it above. If
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 if (hot_button_) 2714 if (hot_button_)
2711 hot_button_->SetHotTracked(false); 2715 hot_button_->SetHotTracked(false);
2712 hot_button_ = hot_button; 2716 hot_button_ = hot_button;
2713 if (hot_button) { 2717 if (hot_button) {
2714 hot_button->SetHotTracked(true); 2718 hot_button->SetHotTracked(true);
2715 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); 2719 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true);
2716 } 2720 }
2717 } 2721 }
2718 2722
2719 } // namespace views 2723 } // namespace views
OLDNEW
« 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