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

Unified Diff: chrome/browser/ui/cocoa/extensions/browser_action_button.mm

Issue 820713008: [Extensions Toolbar Mac] Implement drag-and-drop for the overflow menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/browser_actions_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/extensions/browser_action_button.mm
diff --git a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
index 9a97f24db7ed8563343c15c0307f2b4d68c8c3f6..371eef8d027992359d62805cabaf4ad68bbbe8ee 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
@@ -220,14 +220,22 @@ void ToolbarActionViewDelegateBridge::SetContextMenuController(
NSRect buttonFrame = [self frame];
// The desired x is the current mouse point, minus the original offset of the
// mouse into the button.
- CGFloat desiredX = [[self superview] convertPoint:eventPoint fromView:nil].x -
- dragStartPoint_.x;
+ NSPoint localPoint = [[self superview] convertPoint:eventPoint fromView:nil];
+ CGFloat desiredX = localPoint.x - dragStartPoint_.x;
// Clamp the button to be within its superview along the X-axis.
NSRect containerBounds = [[self superview] bounds];
desiredX = std::min(std::max(NSMinX(containerBounds), desiredX),
NSMaxX(containerBounds) - NSWidth(buttonFrame));
-
buttonFrame.origin.x = desiredX;
+
+ // If the button is in the overflow menu, it could move along the y-axis, too.
+ if ([browserActionsController_ isOverflow]) {
+ CGFloat desiredY = localPoint.y - dragStartPoint_.y;
+ desiredY = std::min(std::max(NSMinY(containerBounds), desiredY),
+ NSMaxY(containerBounds) - NSHeight(buttonFrame));
+ buttonFrame.origin.y = desiredY;
+ }
+
[self setFrame:buttonFrame];
[self setNeedsDisplay:YES];
[[NSNotificationCenter defaultCenter]
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/extensions/browser_actions_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698