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

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: 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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 // current menu is unset. Make sure the submenu remains open by sending the 813 // current menu is unset. Make sure the submenu remains open by sending the
814 // appropriate SetSelectionTypes flags. 814 // appropriate SetSelectionTypes flags.
815 SetSelection(part.menu->GetParentMenuItem(), 815 SetSelection(part.menu->GetParentMenuItem(),
816 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); 816 SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY);
817 event->StopPropagation(); 817 event->StopPropagation();
818 } 818 }
819 819
820 if (event->stopped_propagation()) 820 if (event->stopped_propagation())
821 return; 821 return;
822 822
823 if (!part.submenu) 823 if (!part.submenu) {
824 event->ConvertLocationToTarget(source->GetWidget()->GetNativeWindow(),
825 owner()->GetNativeWindow());
826 owner()->OnGestureEvent(event);
824 return; 827 return;
828 }
xiyuan 2017/05/12 20:24:56 nit: revist to something like if (part.submenu) {
825 part.submenu->OnGestureEvent(event); 829 part.submenu->OnGestureEvent(event);
826 } 830 }
827 831
828 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) { 832 void MenuController::OnTouchEvent(SubmenuView* source, ui::TouchEvent* event) {
829 if (event->type() == ui::ET_TOUCH_PRESSED) { 833 if (event->type() == ui::ET_TOUCH_PRESSED) {
830 MenuPart part = GetMenuPart(source, event->location()); 834 MenuPart part = GetMenuPart(source, event->location());
831 if (part.type == MenuPart::NONE) { 835 if (part.type == MenuPart::NONE) {
832 RepostEventAndCancel(source, event); 836 RepostEventAndCancel(source, event);
833 event->SetHandled(); 837 event->SetHandled();
834 } 838 }
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 gfx::Rect bounds = MenuItemView::IsBubble(state_.anchor) ? 1821 gfx::Rect bounds = MenuItemView::IsBubble(state_.anchor) ?
1818 CalculateBubbleMenuBounds(item, prefer_leading, &resulting_direction) : 1822 CalculateBubbleMenuBounds(item, prefer_leading, &resulting_direction) :
1819 CalculateMenuBounds(item, prefer_leading, &resulting_direction); 1823 CalculateMenuBounds(item, prefer_leading, &resulting_direction);
1820 state_.open_leading.push_back(resulting_direction); 1824 state_.open_leading.push_back(resulting_direction);
1821 bool do_capture = (!did_capture_ && blocking_run_); 1825 bool do_capture = (!did_capture_ && blocking_run_);
1822 showing_submenu_ = true; 1826 showing_submenu_ = true;
1823 if (show) { 1827 if (show) {
1824 // Menus are the only place using kGroupingPropertyKey, so any value (other 1828 // Menus are the only place using kGroupingPropertyKey, so any value (other
1825 // than 0) is fine. 1829 // than 0) is fine.
1826 const int kGroupingId = 1001; 1830 const int kGroupingId = 1001;
1827 item->GetSubmenu()->ShowAt(owner_, bounds, do_capture); 1831 item->GetSubmenu()->ShowAt(owner_, bounds, do_capture,
1832 cancel_active_touches_);
1828 item->GetSubmenu()->GetWidget()->SetNativeWindowProperty( 1833 item->GetSubmenu()->GetWidget()->SetNativeWindowProperty(
1829 TooltipManager::kGroupingPropertyKey, 1834 TooltipManager::kGroupingPropertyKey,
1830 reinterpret_cast<void*>(kGroupingId)); 1835 reinterpret_cast<void*>(kGroupingId));
1831 } else { 1836 } else {
1832 item->GetSubmenu()->Reposition(bounds); 1837 item->GetSubmenu()->Reposition(bounds);
1833 } 1838 }
1834 showing_submenu_ = false; 1839 showing_submenu_ = false;
1835 } 1840 }
1836 1841
1837 void MenuController::MenuChildrenChanged(MenuItemView* item) { 1842 void MenuController::MenuChildrenChanged(MenuItemView* item) {
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 if (hot_button_) 2719 if (hot_button_)
2715 hot_button_->SetHotTracked(false); 2720 hot_button_->SetHotTracked(false);
2716 hot_button_ = hot_button; 2721 hot_button_ = hot_button;
2717 if (hot_button) { 2722 if (hot_button) {
2718 hot_button->SetHotTracked(true); 2723 hot_button->SetHotTracked(true);
2719 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); 2724 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true);
2720 } 2725 }
2721 } 2726 }
2722 2727
2723 } // namespace views 2728 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698