diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-24 19:26:36 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-24 19:26:36 +0000 |
commit | 2f48b4046e418b7399d91b4d3ede0159d35c6e64 (patch) | |
tree | 21dd6c98416fec38c5b7cb4f75aa872eb1772fc7 /ash | |
parent | 1c24b2c9e6205fb3030ded1141c6c6f225e09274 (diff) | |
download | chromium_src-2f48b4046e418b7399d91b4d3ede0159d35c6e64.zip chromium_src-2f48b4046e418b7399d91b4d3ede0159d35c6e64.tar.gz chromium_src-2f48b4046e418b7399d91b4d3ede0159d35c6e64.tar.bz2 |
Replace dropdown meny with right-click
BUG=144548
Review URL: https://chromiumcodereview.appspot.com/10867045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@153256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/system/web_notification/web_notification_tray.cc | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc index 8a1952b..307f9a5 100644 --- a/ash/system/web_notification/web_notification_tray.cc +++ b/ash/system/web_notification/web_notification_tray.cc @@ -336,7 +336,6 @@ class WebNotificationMenuModel : public ui::SimpleMenuModel, // The view for a notification entry (icon + message + buttons). class WebNotificationView : public views::View, public views::ButtonListener, - public views::MenuButtonListener, public ui::ImplicitAnimationObserver { public: WebNotificationView(WebNotificationTray* tray, @@ -344,7 +343,6 @@ class WebNotificationView : public views::View, : tray_(tray), notification_(notification), icon_(NULL), - menu_button_(NULL), close_button_(NULL), scroller_(NULL), gesture_scroll_amount_(0.f) { @@ -386,12 +384,6 @@ class WebNotificationView : public views::View, close_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); - if (!notification.extension_id.empty() || - !notification.display_source.empty()) { - menu_button_ = new views::MenuButton(NULL, string16(), this, true); - menu_button_->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 2)); - } - views::GridLayout* layout = new views::GridLayout(this); SetLayoutManager(layout); @@ -417,7 +409,7 @@ class WebNotificationView : public views::View, columns->AddPaddingColumn(0, padding_width); - // Close and menu buttons. + // Close button. columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING, 0, /* resize percent */ views::GridLayout::FIXED, @@ -435,13 +427,15 @@ class WebNotificationView : public views::View, layout->StartRow(0, 0); layout->SkipColumns(2); layout->AddView(message, 1, 1); - if (menu_button_) - layout->AddView(menu_button_, 1, 1); layout->AddPaddingRow(0, kTrayPopupPaddingBetweenItems); } // views::View overrides. virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { + if (event.flags() & ui::EF_RIGHT_MOUSE_BUTTON) { + ShowMenu(event.location()); + return true; + } tray_->OnClicked(notification_.id); return true; } @@ -454,7 +448,7 @@ class WebNotificationView : public views::View, } if (event.type() == ui::ET_GESTURE_LONG_PRESS) { - ShowMenu(); + ShowMenu(event.location()); return ui::GESTURE_STATUS_CONSUMED; } @@ -508,14 +502,6 @@ class WebNotificationView : public views::View, tray_->SendRemoveNotification(notification_.id); } - // Overridden from MenuButtonListener. - virtual void OnMenuButtonClicked(View* source, - const gfx::Point& point) OVERRIDE { - if (source != menu_button_) - return; - ShowMenu(); - } - // Overridden from ImplicitAnimationObserver. virtual void OnImplicitAnimationsCompleted() OVERRIDE { tray_->SendRemoveNotification(notification_.id); @@ -527,20 +513,20 @@ class WebNotificationView : public views::View, SLIDE_RIGHT }; - // Shows the menu (if there is one) for the notification. - void ShowMenu() { - if (!menu_button_) - return; + // Shows the menu for the notification. + void ShowMenu(gfx::Point screen_location) { WebNotificationMenuModel menu_model(tray_, notification_); + if (menu_model.GetItemCount() == 0) + return; + views::MenuModelAdapter menu_model_adapter(&menu_model); views::MenuRunner menu_runner(menu_model_adapter.CreateMenu()); - gfx::Point screen_location; - views::View::ConvertPointToScreen(menu_button_, &screen_location); + views::View::ConvertPointToScreen(this, &screen_location); ignore_result(menu_runner.RunMenuAt( - menu_button_->GetWidget()->GetTopLevelWidget(), - menu_button_, - gfx::Rect(screen_location, menu_button_->size()), + GetWidget()->GetTopLevelWidget(), + NULL, + gfx::Rect(screen_location, gfx::Size()), views::MenuItemView::TOPRIGHT, views::MenuRunner::HAS_MNEMONICS)); } @@ -574,7 +560,6 @@ class WebNotificationView : public views::View, WebNotificationTray* tray_; WebNotification notification_; views::ImageView* icon_; - views::MenuButton* menu_button_; views::ImageButton* close_button_; views::ScrollView* scroller_; |