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

Unified Diff: views/controls/button/button_dropdown.cc

Issue 126092: Begin to upgrade BackForwardMenuModelViews to use new menu API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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: views/controls/button/button_dropdown.cc
===================================================================
--- views/controls/button/button_dropdown.cc (revision 18347)
+++ views/controls/button/button_dropdown.cc (working copy)
@@ -23,9 +23,9 @@
////////////////////////////////////////////////////////////////////////////////
ButtonDropDown::ButtonDropDown(ButtonListener* listener,
- Menu::Delegate* menu_delegate)
+ Menu2Model* model)
: ImageButton(listener),
- menu_delegate_(menu_delegate),
+ model_(model),
y_position_on_lbuttondown_(0),
ALLOW_THIS_IN_INITIALIZER_LIST(show_menu_factory_(this)) {
}
@@ -112,7 +112,7 @@
}
void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) {
- if (menu_delegate_) {
+ if (model_) {
gfx::Rect lb = GetLocalBounds(true);
// Both the menu position and the menu anchor type change if the UI layout
@@ -122,10 +122,6 @@
if (UILayoutIsRightToLeft())
menu_position.Offset(lb.width() - 1, 0);
- Menu::AnchorPoint anchor = Menu::TOPLEFT;
- if (UILayoutIsRightToLeft())
- anchor = Menu::TOPRIGHT;
-
View::ConvertPointToScreen(this, &menu_position);
#if defined(OS_WIN)
@@ -137,25 +133,12 @@
if (menu_position.x() < left_bound)
menu_position.set_x(left_bound);
- scoped_ptr<Menu> menu(Menu::Create(menu_delegate_, anchor, window));
+ menu_.reset(new Menu2(model_));
+ Menu2::Alignment align = Menu2::ALIGN_TOPLEFT;
+ if (UILayoutIsRightToLeft())
+ align = Menu2::ALIGN_TOPLEFT;
+ menu_->RunMenuAt(menu_position, align);
- // ID's for AppendMenu is 1-based because RunMenu will ignore the user
- // selection if id=0 is selected (0 = NO-OP) so we add 1 here and subtract 1
- // in the handlers above to get the actual index
- int item_count = menu_delegate_->GetItemCount();
- for (int i = 0; i < item_count; i++) {
- if (menu_delegate_->IsItemSeparator(i + 1)) {
- menu->AppendSeparator();
- } else {
- if (menu_delegate_->HasIcon(i + 1))
- menu->AppendMenuItemWithIcon(i + 1, L"", SkBitmap());
- else
- menu->AppendMenuItem(i+1, L"", Menu::NORMAL);
- }
- }
-
- menu->RunMenuAt(menu_position.x(), menu_position.y());
-
// Need to explicitly clear mouse handler so that events get sent
// properly after the menu finishes running. If we don't do this, then
// the first click to other parts of the UI is eaten.

Powered by Google App Engine
This is Rietveld 408576698