adium 3791:5c875f570d55: Image Wells for changing "User Picture"...

commits at adium.im commits at adium.im
Tue Mar 29 22:30:18 UTC 2011


details:	http://hg.adium.im/adium/rev/5c875f570d55
revision:	3791:5c875f570d55
branch:		(none)
author:		Adrian Godoroja <robotive at me.com>
date:		Wed Mar 30 01:29:40 2011 +0300

Image Wells for changing "User Picture" will open Image Picker to edit the image if it's too large or not of square shape (~20% off shape).

diffs (94 lines):

diff -r f9f2af0426a5 -r 5c875f570d55 ChangeLogs/Changes.txt
--- a/ChangeLogs/Changes.txt	Tue Mar 29 04:13:18 2011 +0200
+++ b/ChangeLogs/Changes.txt	Wed Mar 30 01:29:40 2011 +0300
@@ -12,6 +12,7 @@
   * The contact list search now treats whitespace-separated words as keywords. (Paul Vet) (#14354)
   * Improved the logic for the display of tooltips. (Matthew Plough) (#12774)
   * "User Picture Change" menu now looks native on Leopard and newer systems (Adrian Godoroja) (#11964)
+  * "User Picture" - image well, supports drag and drop
   * Fixed positioning of selected icon in Recent Icons not being reapplied when icon is reselected. (#9908)
 
  Dock icon
@@ -50,6 +51,7 @@
 
  User Picture (Buddy Icons)
  * Ability to resize animated gifs that are too large (#9885)
+ * Image wells for changing User Picture support drag & drop and will also open Image Picker to edit the image if it's too large or not of square shape (20% off shape)
 
  AIM
   * Added a preference for AIM: "allow multiple sign in locations" defaulting to true. (Josh Perry) (#5790)
diff -r f9f2af0426a5 -r 5c875f570d55 Frameworks/AIUtilities Framework/Source/AIImageViewWithImagePicker.m
--- a/Frameworks/AIUtilities Framework/Source/AIImageViewWithImagePicker.m	Tue Mar 29 04:13:18 2011 +0200
+++ b/Frameworks/AIUtilities Framework/Source/AIImageViewWithImagePicker.m	Wed Mar 30 01:29:40 2011 +0300
@@ -139,7 +139,7 @@
 {
 	[super setImage:inImage];
 	
-	//Inform the picker controller of a changed selection if it is open, for live updating
+	// Inform the picker controller of a changed selection if it is open, for live updating
 	if (pictureTaker) {
 		[pictureTaker setInputImage:inImage];
 	}
@@ -355,35 +355,46 @@
 /*
  * @brief Conclude a drag operation
  *
- * A new image was dragged into our view.  -[super concludeDragOperation:] will change [self image] to match it.
+ * A new image was dragged into our view.
+ * We want to edit a dropped image if it doesn't correspond to our needs (too large or not of desired shape).
  * We then want to update our pictureTaker's selection if it is open.
- * Also, if we're dropped a promised file, use its data directly as it may be better than what NSImageView's natural
- * loading retrieves... this way we can get transparency or animation data, for example.
- * Also we want the image to be added to the recent repository
+ * Also we want the image to be added to the recent repository.
  */
 - (void)concludeDragOperation:(id <NSDraggingInfo>)sender
 {
-	[super concludeDragOperation:sender];
-	
-	NSImage *droppedImage = [self image];
-	NSSize droppedImageSize = [droppedImage size];
+	NSImage *droppedImage = [[[NSImage alloc] initWithPasteboard:[sender draggingPasteboard]] autorelease];
+    
+    if (!droppedImage) {
+        return;
+    }
+    
+    NSSize droppedImageSize = [droppedImage size];
 	NSSize mSize = [self maxSize];
 	
 	IKPictureTakerRecentPicture *recentPicture = [IKPictureTakerRecentPicture defaultRecentPictureWithOriginalImage:droppedImage cropSize:CGSizeZero];
 	
+    // We want to edit a dropped image if it is:
+    // - larger then desired max size
+    // - width/height proportions are ~20% off the squre shape
 	if ((mSize.width > 0.0f && droppedImageSize.width > mSize.width) ||
-		(mSize.height > 0.0f && droppedImageSize.height > mSize.height)) {
+		(mSize.height > 0.0f && droppedImageSize.height > mSize.height) ||
+        (droppedImageSize.width / droppedImageSize.height > 1.2f ||
+         droppedImageSize.width / droppedImageSize.height < 0.8f)) {
 
-		droppedImage = [droppedImage imageByScalingToSize:mSize];
-
-		// This will notify the picker controller that the selection changed, as well
-		[self setImage:droppedImage];
-	}
+        // Set recent picture and open Image Picker
+        [self setRecentPictureAsImageInput:recentPicture];
+        [self showPictureTaker];
+            
+        return;
+    } else if ([self pictureTaker]) {
+        // Update an open Image Picker
+        [self setRecentPictureAsImageInput:recentPicture];
+    }
 	
 	// Inform the delegate
 	if ([[self delegate] respondsToSelector:@selector(imageViewWithImagePicker:didChangeToImageData:)]) {
-		[[self delegate] imageViewWithImagePicker:self didChangeToImageData:[[[NSImage alloc] initWithPasteboard:[sender draggingPasteboard]] bestRepresentationByType]];
-	} else if ([[self delegate] respondsToSelector:@selector(imageViewWithImagePicker:didChangeToImage:)]) {
+        [[self delegate] imageViewWithImagePicker:self didChangeToImageData:[droppedImage bestRepresentationByType]];
+    } else if ([[self delegate] respondsToSelector:@selector(imageViewWithImagePicker:didChangeToImage:)]) {
 		[[self delegate] imageViewWithImagePicker:self didChangeToImage:droppedImage];
 	}
 




More information about the commits mailing list