Commit 20551064 authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

Fix RTL when dragging downloads and make dragging more Mac-like.

RTL was missing from this particular part of MD downloads. This change:

1. Adds RTL support.

2. Changes the look slightly overall to match dragging on macOS: instead of a
   representation of the file appearing under the mouse pointer, dragging
   creates a copy of the icon and text seen in the shelf, which start off in
   their original spots. (I tried this while I was working on RTL).

Change-Id: I766d61227d04541f1beecf93adf87464da5a020b
Bug: 825849
Reviewed-on: https://chromium-review.googlesource.com/979195Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545861}
parent ce304523
...@@ -636,12 +636,14 @@ NSTextField* MakeLabel( ...@@ -636,12 +636,14 @@ NSTextField* MakeLabel(
- (void)beginDragFromHoverButton:(HoverButton*)button event:(NSEvent*)event { - (void)beginDragFromHoverButton:(HoverButton*)button event:(NSEvent*)event {
NSAttributedString* filename = filenameView_.attributedStringValue; NSAttributedString* filename = filenameView_.attributedStringValue;
NSSize filenameSize = filename.size; NSRect imageRect = imageView_.frame;
NSRect imageRect = NSMakeRect(0, 0, 32, 32); NSRect labelRect = filenameView_.frame;
NSRect labelRect = [self
backingAlignedRect:NSMakeRect(35, 32 / 2 - filenameSize.height / 2, // Hug the label content in an RTL-friendly way.
filenameSize.width, filenameSize.height) labelRect = [self cr_localizedRect:labelRect];
options:NSAlignAllEdgesOutward]; labelRect.size = filename.size;
labelRect = [self cr_localizedRect:labelRect];
NSDraggingItem* draggingItem = [[[NSDraggingItem alloc] NSDraggingItem* draggingItem = [[[NSDraggingItem alloc]
initWithPasteboardWriter:[NSURL initWithPasteboardWriter:[NSURL
fileURLWithPath:base::SysUTF8ToNSString( fileURLWithPath:base::SysUTF8ToNSString(
...@@ -667,13 +669,6 @@ NSTextField* MakeLabel( ...@@ -667,13 +669,6 @@ NSTextField* MakeLabel(
labelComponent.frame = labelRect; labelComponent.frame = labelRect;
return @[ imageComponent, labelComponent ]; return @[ imageComponent, labelComponent ];
}; };
NSPoint dragOrigin =
[self convertPoint:[self.window mouseLocationOutsideOfEventStream]
fromView:nil];
draggingItem.draggingFrame =
[self backingAlignedRect:NSOffsetRect(imageRect, dragOrigin.x - 16,
dragOrigin.y - 16)
options:NSAlignAllEdgesOutward];
[self beginDraggingSessionWithItems:@[ draggingItem ] [self beginDraggingSessionWithItems:@[ draggingItem ]
event:event event:event
source:self]; source:self];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment