Skip to content

Allow dragging a folder on the Welcome window to open a repository - Closes #468 and #247 #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

sdrpa
Copy link

@sdrpa sdrpa commented Jul 4, 2018

No description provided.

@sdrpa
Copy link
Author

sdrpa commented Jul 4, 2018

Found a typo. isHiglighted property in DragAndDropImageView.m should be corrected to isHighlighted. Should I close this pull request, correct the typo and submit new one?

@hawkrives
Copy link

If it's a typo you introduced, why not just fix it in this one as another commit?

@sdrpa
Copy link
Author

sdrpa commented Jul 4, 2018

@hawkrives Done. I wasn't sure that new commit would become part of the pull request since I had already created the pull request. Thanks.

if (self.isHighlighted) {
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:dirtyRect xRadius:10 yRadius:10];
// systemBlueColor from https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/color/
NSColor *higlightColor = [NSColor colorWithRed:27.0/255.0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in name, and also, perhaps better to use [NSColor highlightColor] or one of its siblings to have the color change appropriately with dark mode/user preferences?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controlAccentColor should be used when available before falling back to systemBlueColor. (systemBlueColor requires 10.10; see also #534.)

@lucasderraugh
Copy link
Collaborator

lucasderraugh commented Jun 9, 2019

@sdrpa I've recently taken over as temporary maintainer of GitUp. If I can get an overview of visual changes here and squash changes into a single commit, I'd love to start the discussion on merging this in.


- (void)awakeFromNib {
[super awakeFromNib];
[self registerForDraggedTypes:@[NSFilenamesPboardType]];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On modern macOS, drag support should be registered either using one of the non-deprecated pasteboard types (post-10.14) or a UTI. Here, use @[ (__bridge id)kUTTypeFileURL ] or NSURL.readableTypeIdentifiersForItemProvider, whichever you prefer.

- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
BOOL isDragOperationGeneric = (NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric;
NSPasteboard *pasteboard = [sender draggingPasteboard];
if (isDragOperationGeneric && [self directoryURLFromPasteboard:pasteboard]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On modern macOS, drag operations should be validated using the multi-contents support of -[NSPasteboard canReadObjectForClasses:options:].

Here, that would be:

[pasteboard canReadObjectForClasses:@[ NSURL.class ] options:@{
  NSPasteboardURLReadingFileURLsOnlyKey: @YES,
  NSPasteboardURLReadingContentsConformToTypesKey: @[
    (__bridge id)kUTTypeDirectory
  ]
}]


- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
NSPasteboard *pasteboard = [sender draggingPasteboard];
NSURL *directoryURL = [self directoryURLFromPasteboard:pasteboard];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On modern macOS, drag operations should be performed using the multi-contents support of -[NSPasteboard readObjectsForClasses:options:].

Here, that would be:

NSArray* urls = [pasteboard readObjectsForClasses:@[ NSURL.class ] options:@{
  NSPasteboardURLReadingFileURLsOnlyKey: @YES,
  NSPasteboardURLReadingContentsConformToTypesKey: @[
    (__bridge id)kUTTypeDirectory
  ]
}]

[super drawRect:dirtyRect];

if (self.isHighlighted) {
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:dirtyRect xRadius:10 yRadius:10];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dirtyRect can be called with subsections of self. You probably want to still use self.bounds.

if (self.isHighlighted) {
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:dirtyRect xRadius:10 yRadius:10];
// systemBlueColor from https://developer.apple.com/design/human-interface-guidelines/macos/visual-design/color/
NSColor *higlightColor = [NSColor colorWithRed:27.0/255.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controlAccentColor should be used when available before falling back to systemBlueColor. (systemBlueColor requires 10.10; see also #534.)

@lucasderraugh
Copy link
Collaborator

Going to close this out as we need updates to Dark Mode at this point. If somebody makes the changes and wants to reopen, I'll gladly look over it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants