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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 2876203003: Make shelf item can be dragged when context menu is opened.
Patch Set: TransferEvents only if it is needed. 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 394 }
395 395
396 MenuController::State::State(const State& other) = default; 396 MenuController::State::State(const State& other) = default;
397 397
398 MenuController::State::~State() {} 398 MenuController::State::~State() {}
399 399
400 // MenuController ------------------------------------------------------------ 400 // MenuController ------------------------------------------------------------
401 401
402 // static 402 // static
403 MenuController* MenuController::active_instance_ = NULL; 403 MenuController* MenuController::active_instance_ = NULL;
404 bool MenuController::do_cancel_ = true;
404 405
405 // static 406 // static
406 MenuController* MenuController::GetActiveInstance() { 407 MenuController* MenuController::GetActiveInstance() {
407 return active_instance_; 408 return active_instance_;
408 } 409 }
409 410
410 void MenuController::Run(Widget* parent, 411 void MenuController::Run(Widget* parent,
411 MenuButton* button, 412 MenuButton* button,
412 MenuItemView* root, 413 MenuItemView* root,
413 const gfx::Rect& bounds, 414 const gfx::Rect& bounds,
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 // current menu is unset. Make sure the submenu remains open by sending the 814 // current menu is unset. Make sure the submenu remains open by sending the
814 // appropriate SetSelectionTypes flags. 815 // appropriate SetSelectionTypes flags.
815 SetSelection(part.menu->GetParentMenuItem(), 816 SetSelection(part.menu->GetParentMenuItem(),
816 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); 817 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
817 event->StopPropagation(); 818 event->StopPropagation();
818 } 819 }
819 820
820 if (event->stopped_propagation()) 821 if (event->stopped_propagation())
821 return; 822 return;
822 823
823 if (!part.submenu) 824 if (part.submenu) {
825 part.submenu->OnGestureEvent(event);
824 return; 826 return;
825 part.submenu->OnGestureEvent(event); 827 }
828
829 if (!DoCancel()) {
830 event->ConvertLocationToTarget(source->GetWidget()->GetNativeWindow(),
831 owner()->GetNativeWindow());
832 owner()->OnGestureEvent(event);
833 }
826 } 834 }
827 835
828 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { 836 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) {
829 if (event->type() == ui::ET_TOUCH_PRESSED) { 837 if (event->type() == ui::ET_TOUCH_PRESSED) {
830 MenuPart part = GetMenuPart(source, event->location()); 838 MenuPart part = GetMenuPart(source, event->location());
831 if (part.type == MenuPart::NONE) { 839 if (part.type == MenuPart::NONE) {
832 RepostEventAndCancel(source, event); 840 RepostEventAndCancel(source, event);
833 event->SetHandled(); 841 event->SetHandled();
834 } 842 }
835 } 843 }
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 if (hot_button_) 2722 if (hot_button_)
2715 hot_button_->SetHotTracked(false); 2723 hot_button_->SetHotTracked(false);
2716 hot_button_ = hot_button; 2724 hot_button_ = hot_button;
2717 if (hot_button) { 2725 if (hot_button) {
2718 hot_button->SetHotTracked(true); 2726 hot_button->SetHotTracked(true);
2719 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); 2727 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true);
2720 } 2728 }
2721 } 2729 }
2722 2730
2723 } // namespace views 2731 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698