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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 378333003: Allow menus to stay open during a child view's drag and drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/ui/views/toolbar/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 24 matching lines...) Expand all
35 #include "ui/accessibility/ax_view_state.h" 35 #include "ui/accessibility/ax_view_state.h"
36 #include "ui/base/dragdrop/drag_utils.h" 36 #include "ui/base/dragdrop/drag_utils.h"
37 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/nine_image_painter_factory.h" 38 #include "ui/base/nine_image_painter_factory.h"
39 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
40 #include "ui/base/theme_provider.h" 40 #include "ui/base/theme_provider.h"
41 #include "ui/gfx/animation/slide_animation.h" 41 #include "ui/gfx/animation/slide_animation.h"
42 #include "ui/gfx/canvas.h" 42 #include "ui/gfx/canvas.h"
43 #include "ui/gfx/geometry/rect.h" 43 #include "ui/gfx/geometry/rect.h"
44 #include "ui/views/controls/button/label_button_border.h" 44 #include "ui/views/controls/button/label_button_border.h"
45 #include "ui/views/controls/menu/menu_controller.h"
45 #include "ui/views/controls/resize_area.h" 46 #include "ui/views/controls/resize_area.h"
46 #include "ui/views/metrics.h" 47 #include "ui/views/metrics.h"
47 #include "ui/views/painter.h" 48 #include "ui/views/painter.h"
48 #include "ui/views/widget/widget.h" 49 #include "ui/views/widget/widget.h"
49 50
50 using extensions::Extension; 51 using extensions::Extension;
51 52
52 namespace { 53 namespace {
53 54
54 // Horizontal spacing between most items in the container, as well as after the 55 // Horizontal spacing between most items in the container, as well as after the
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // the center of the drop indicator at the midpoint of the space before our 458 // the center of the drop indicator at the midpoint of the space before our
458 // chosen icon. 459 // chosen icon.
459 SetDropIndicator(width_before_icons + (before_icon * IconWidth(true)) - 460 SetDropIndicator(width_before_icons + (before_icon * IconWidth(true)) -
460 (kItemSpacing / 2)); 461 (kItemSpacing / 2));
461 462
462 return ui::DragDropTypes::DRAG_MOVE; 463 return ui::DragDropTypes::DRAG_MOVE;
463 } 464 }
464 465
465 void BrowserActionsContainer::OnDragExited() { 466 void BrowserActionsContainer::OnDragExited() {
466 StopShowFolderDropMenuTimer(); 467 StopShowFolderDropMenuTimer();
468 if (in_overflow_mode()) {
sky 2014/07/09 16:09:16 This is too fragile. The menu code should change s
Devlin 2014/07/09 18:03:41 Okay - let's try this approach. It seems to fit t
469 views::MenuController* controller =
470 views::MenuController::GetActiveInstance();
471 // Notify the controller that we finished our drag.
472 if (controller)
473 controller->set_drag_in_progress(false);
474 // During the drag, the widget lost mouse capture (even though it
475 // conceptually retained it). Reset the capture to this so that future
476 // capture losses (like clicking outside of the menu) register again.
477 GetWidget()->SetCapture(this);
478 }
467 drop_indicator_position_ = -1; 479 drop_indicator_position_ = -1;
468 SchedulePaint(); 480 SchedulePaint();
469 } 481 }
470 482
471 int BrowserActionsContainer::OnPerformDrop( 483 int BrowserActionsContainer::OnPerformDrop(
472 const ui::DropTargetEvent& event) { 484 const ui::DropTargetEvent& event) {
473 BrowserActionDragData data; 485 BrowserActionDragData data;
474 if (!data.Read(event.data())) 486 if (!data.Read(event.data()))
475 return ui::DragDropTypes::DRAG_NONE; 487 return ui::DragDropTypes::DRAG_NONE;
476 488
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 overflow_menu_->set_observer(this); 536 overflow_menu_->set_observer(this);
525 overflow_menu_->RunMenu(GetWidget(), false); 537 overflow_menu_->RunMenu(GetWidget(), false);
526 } 538 }
527 } 539 }
528 540
529 void BrowserActionsContainer::WriteDragDataForView(View* sender, 541 void BrowserActionsContainer::WriteDragDataForView(View* sender,
530 const gfx::Point& press_pt, 542 const gfx::Point& press_pt,
531 OSExchangeData* data) { 543 OSExchangeData* data) {
532 DCHECK(data); 544 DCHECK(data);
533 545
546 if (in_overflow_mode()) {
547 views::MenuController* controller =
548 views::MenuController::GetActiveInstance();
549 // Notify the controller that a drag is in progress so that reported
550 // capture losses are ignored appropriately.
551 if (controller)
552 controller->set_drag_in_progress(true);
553 }
534 for (size_t i = 0; i < browser_action_views_.size(); ++i) { 554 for (size_t i = 0; i < browser_action_views_.size(); ++i) {
535 BrowserActionButton* button = browser_action_views_[i]->button(); 555 BrowserActionButton* button = browser_action_views_[i]->button();
536 if (button == sender) { 556 if (button == sender) {
537 // Set the dragging image for the icon. 557 // Set the dragging image for the icon.
538 gfx::ImageSkia badge(browser_action_views_[i]->GetIconWithBadge()); 558 gfx::ImageSkia badge(browser_action_views_[i]->GetIconWithBadge());
539 drag_utils::SetDragImageOnDataObject(badge, 559 drag_utils::SetDragImageOnDataObject(badge,
540 press_pt.OffsetFromOrigin(), 560 press_pt.OffsetFromOrigin(),
541 data); 561 data);
542 562
543 // Fill in the remaining info. 563 // Fill in the remaining info.
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 views::BubbleBorder::TOP_RIGHT, 1073 views::BubbleBorder::TOP_RIGHT,
1054 show_action); 1074 show_action);
1055 popup_->GetWidget()->AddObserver(this); 1075 popup_->GetWidget()->AddObserver(this);
1056 popup_button_ = button; 1076 popup_button_ = button;
1057 1077
1058 // Only set button as pushed if it was triggered by a user click. 1078 // Only set button as pushed if it was triggered by a user click.
1059 if (should_grant) 1079 if (should_grant)
1060 popup_button_->SetButtonPushed(); 1080 popup_button_->SetButtonPushed();
1061 return true; 1081 return true;
1062 } 1082 }
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698