adium 3784:6433a4fcfe52: Rounded user icon in the chat window to...
commits at adium.im
commits at adium.im
Sun Mar 27 23:25:09 UTC 2011
details: http://hg.adium.im/adium/rev/6433a4fcfe52
revision: 3784:6433a4fcfe52
branch: (none)
author: Adrian Godoroja <robotive at me.com>
date: Mon Mar 28 02:24:35 2011 +0300
Rounded user icon in the chat window toolbar. Fixed #3757
Minor clean-ups.
diffs (292 lines):
diff -r e4ee1e095b3a -r 6433a4fcfe52 Frameworks/AIUtilities Framework/Source/AIFloater.h
--- a/Frameworks/AIUtilities Framework/Source/AIFloater.h Fri Mar 25 15:53:48 2011 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AIFloater.h Mon Mar 28 02:24:35 2011 +0300
@@ -23,11 +23,11 @@
* <tt>AIFloater</tt> allows for the display of an <tt>NSImage</tt>, including an animating one, anywhere on the screen. The image can be easily moved programatically and will fade into and out of view as requested.
*/
@interface AIFloater : NSObject {
- NSImageView *staticView;
- NSPanel *panel;
- BOOL windowIsVisible;
- NSViewAnimation *fadeAnimation;
- CGFloat maxOpacity;
+ NSImageView *staticView;
+ NSPanel *panel;
+ BOOL windowIsVisible;
+ NSViewAnimation *fadeAnimation;
+ CGFloat maxOpacity;
}
/*!
diff -r e4ee1e095b3a -r 6433a4fcfe52 Frameworks/AIUtilities Framework/Source/AIFloater.m
--- a/Frameworks/AIUtilities Framework/Source/AIFloater.m Fri Mar 25 15:53:48 2011 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AIFloater.m Mon Mar 28 02:24:35 2011 +0300
@@ -17,12 +17,12 @@
#import "AIFloater.h"
#import "AIEventAdditions.h"
-#define WINDOW_FADE_FPS 24.0f
-#define WINDOW_FADE_STEP 0.3f
-#define WINDOW_FADE_SLOW_STEP 0.1f
-#define WINDOW_FADE_MAX 1.0f
-#define WINDOW_FADE_MIN 0.0f
-#define WINDOW_FADE_SNAP 0.05f //How close to min/max we must get before fade is finished
+#define WINDOW_FADE_FPS 24.0f
+#define WINDOW_FADE_STEP 0.3f
+#define WINDOW_FADE_SLOW_STEP 0.1f
+#define WINDOW_FADE_MAX 1.0f
+#define WINDOW_FADE_MIN 0.0f
+#define WINDOW_FADE_SNAP 0.05f // How close to min/max we must get before fade is finished
@interface AIFloater ()
- (id)initWithImage:(NSImage *)inImage styleMask:(unsigned int)styleMask;
@@ -31,7 +31,7 @@
@implementation AIFloater
-//Because the floater can control its own display, it retains itself and releases when it closes.
+// Because the floater can control its own display, it retains itself and releases when it closes.
+ (id)floaterWithImage:(NSImage *)inImage styleMask:(unsigned int)styleMask
{
return [[self alloc] initWithImage:inImage styleMask:styleMask];
@@ -45,8 +45,9 @@
fadeAnimation = nil;
maxOpacity = WINDOW_FADE_MAX;
- //Set up the panel
- frame = NSMakeRect(0, 0, [inImage size].width, [inImage size].height);
+ // Set up the panel
+ frame = NSMakeRect(0, 0, [inImage size].width, [inImage size].height);
+
panel = [[NSPanel alloc] initWithContentRect:frame
styleMask:styleMask
backing:NSBackingStoreBuffered
@@ -55,9 +56,11 @@
[panel setIgnoresMouseEvents:YES];
[panel setLevel:NSStatusWindowLevel];
[panel setHasShadow:YES];
+ [panel setOpaque:NO];
+ [panel setBackgroundColor:[NSColor clearColor]];
[self _setWindowOpacity:WINDOW_FADE_MIN];
-
- //Setup the static view
+
+ // Setup the static view
staticView = [[NSImageView alloc] initWithFrame:frame];
[staticView setImage:inImage];
[staticView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
@@ -106,8 +109,9 @@
if (windowIsVisible) [self _setWindowOpacity:maxOpacity];
}
-//Window Visibility --------------------------------------------------------------------------------------------------
-//Update the visibility of this window (Window is visible if there are any tabs present)
+#pragma mark Window Visibility
+
+// Update the visibility of this window (Window is visible if there are any tabs present)
- (void)setVisible:(BOOL)inVisible animate:(BOOL)animate
{
if (inVisible != windowIsVisible) {
@@ -121,9 +125,9 @@
nil];
fadeAnimation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:animDict]];
- //1.0f / FPS = duration per step
- //1.0f / step = number of steps (e.g.: If step = 0.1f, 1.0f / step = 10 steps)
- //duration per step * number of steps = total duration
+ // 1.0f / FPS = duration per step
+ // 1.0f / step = number of steps (e.g.: If step = 0.1f, 1.0f / step = 10 steps)
+ // duration per step * number of steps = total duration
NSTimeInterval step = [[NSApp currentEvent] shiftKey] ? WINDOW_FADE_SLOW_STEP : WINDOW_FADE_STEP;
fadeAnimation.duration = (1.0f / step) * (1.0f / WINDOW_FADE_FPS);
@@ -140,8 +144,4 @@
[panel setAlphaValue:opacity];
}
-
@end
-
-
-
diff -r e4ee1e095b3a -r 6433a4fcfe52 Frameworks/AIUtilities Framework/Source/AIImageButton.h
--- a/Frameworks/AIUtilities Framework/Source/AIImageButton.h Fri Mar 25 15:53:48 2011 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AIImageButton.h Mon Mar 28 02:24:35 2011 +0300
@@ -26,7 +26,10 @@
*/
@interface AIImageButton : MVMenuButton {
AIFloater *imageFloater;
- BOOL imageFloaterShouldBeOpen; //Track if the image float should currently be open; useful since the floater is desroyed on a delay.
+ BOOL imageFloaterShouldBeOpen; // Track if the image float should currently be open; useful since the floater is desroyed on a delay.
+ CGFloat cornerRadius;
}
+ at property (assign) CGFloat cornerRadius;
+
@end
diff -r e4ee1e095b3a -r 6433a4fcfe52 Frameworks/AIUtilities Framework/Source/AIImageButton.m
--- a/Frameworks/AIUtilities Framework/Source/AIImageButton.m Fri Mar 25 15:53:48 2011 -0500
+++ b/Frameworks/AIUtilities Framework/Source/AIImageButton.m Mon Mar 28 02:24:35 2011 +0300
@@ -23,6 +23,8 @@
@implementation AIImageButton
+ at synthesize cornerRadius;
+
- (id)initWithFrame:(NSRect)frame
{
if ((self = [super initWithFrame:frame])) {
@@ -34,9 +36,9 @@
- (id)copyWithZone:(NSZone *)zone
{
- AIImageButton *newButton = [super copyWithZone:zone];
-
+ AIImageButton *newButton = [super copyWithZone:zone];
newButton->imageFloater = [imageFloater retain];
+ [newButton setCornerRadius:[self cornerRadius]];
return newButton;
}
@@ -49,6 +51,18 @@
[super dealloc];
}
+#pragma mark Drawing
+
+- (void)drawRect:(NSRect)rect
+{
+ // Rounded corners
+ if (cornerRadius > 0.0f) {
+ [[NSBezierPath bezierPathWithRoundedRect:[self bounds] xRadius:[self cornerRadius] yRadius:[self cornerRadius]] addClip];
+ }
+
+ [super drawRect:rect];
+}
+
//Mouse Tracking -------------------------------------------------------------------------------------------------------
#pragma mark Mouse Tracking
//Custom mouse down tracking to display our image and highlight
@@ -72,6 +86,25 @@
[imageFloater close:nil];
[imageFloater release];
}
+
+ // Rounded corners
+ if ([self cornerRadius] > 0.0f) {
+ NSImage *roundedImage = [[NSImage alloc] initWithSize:[bigImage size]];
+ NSRect imageFrame = NSMakeRect(0.0f, 0.0f, [bigImage size].width, [bigImage size].height);
+
+ [roundedImage lockFocus];
+
+ [[NSBezierPath bezierPathWithRoundedRect:imageFrame
+ xRadius:[self cornerRadius]
+ yRadius:[self cornerRadius]] addClip];
+
+ [bigImage drawInRect:imageFrame fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0f];
+
+ [roundedImage unlockFocus];
+
+ [self setImage:roundedImage];
+ [roundedImage release];
+ }
/* If the image would go off the right side of the screen from its origin, shift the origin left
* so it won't.
@@ -82,9 +115,10 @@
}
imageFloater = [[AIFloater floaterWithImage:bigImage styleMask:NSBorderlessWindowMask] retain];
- [imageFloater setMaxOpacity:1.00f];
+ [imageFloater setMaxOpacity:1.0f];
[imageFloater moveFloaterToPoint:point];
[imageFloater setVisible:YES animate:NO];
+
imageFloaterShouldBeOpen = TRUE;
}
}
diff -r e4ee1e095b3a -r 6433a4fcfe52 Frameworks/AIUtilities Framework/Source/MVMenuButton.m
--- a/Frameworks/AIUtilities Framework/Source/MVMenuButton.m Fri Mar 25 15:53:48 2011 -0500
+++ b/Frameworks/AIUtilities Framework/Source/MVMenuButton.m Mon Mar 28 02:24:35 2011 +0300
@@ -167,13 +167,13 @@
arrowPath = [[NSBezierPath bezierPath] retain];
if (controlSize == NSRegularControlSize) {
- [arrowPath moveToPoint:NSMakePoint(NSWidth(frame)-6, NSHeight(frame)-3)];
+ [arrowPath moveToPoint:NSMakePoint(NSWidth(frame)-9, NSHeight(frame)-5)];
+ [arrowPath relativeLineToPoint:NSMakePoint( 8, 0)];
+ [arrowPath relativeLineToPoint:NSMakePoint(-4, 5)];
+ } else if (controlSize == NSSmallControlSize) {
+ [arrowPath moveToPoint:NSMakePoint(NSWidth(frame)-7, NSHeight(frame)-5)];
[arrowPath relativeLineToPoint:NSMakePoint( 6, 0)];
- [arrowPath relativeLineToPoint:NSMakePoint(-3, 3)];
- } else if (controlSize == NSSmallControlSize) {
- [arrowPath moveToPoint:NSMakePoint(NSWidth(frame)-4, NSHeight(frame)-3)];
- [arrowPath relativeLineToPoint:NSMakePoint( 4, 0)];
- [arrowPath relativeLineToPoint:NSMakePoint(-2, 3)];
+ [arrowPath relativeLineToPoint:NSMakePoint(-3, 4)];
}
[arrowPath closePath];
}
diff -r e4ee1e095b3a -r 6433a4fcfe52 Plugins/Dual Window Interface/AIMessageViewController.m
--- a/Plugins/Dual Window Interface/AIMessageViewController.m Fri Mar 25 15:53:48 2011 -0500
+++ b/Plugins/Dual Window Interface/AIMessageViewController.m Mon Mar 28 02:24:35 2011 +0300
@@ -29,7 +29,6 @@
#import <Adium/AIContactAlertsControllerProtocol.h>
#import <Adium/AIContactControllerProtocol.h>
#import <Adium/AIContentControllerProtocol.h>
-#import <Adium/AIContentControllerProtocol.h>
#import <Adium/AIInterfaceControllerProtocol.h>
#import <Adium/AIMenuControllerProtocol.h>
#import <Adium/AIToolbarControllerProtocol.h>
@@ -53,19 +52,19 @@
#import "RBSplitView.h"
//Heights and Widths
-#define MESSAGE_VIEW_MIN_HEIGHT_RATIO .50f //Mininum height ratio of the message view
-#define MESSAGE_VIEW_MIN_WIDTH_RATIO .50f //Mininum width ratio of the message view
-#define ENTRY_TEXTVIEW_MIN_HEIGHT 20 //Mininum height of the text entry view
-#define USER_LIST_DEFAULT_WIDTH 120 //Default width of the user list
+#define MESSAGE_VIEW_MIN_HEIGHT_RATIO 0.5f // Mininum height ratio of the message view
+#define MESSAGE_VIEW_MIN_WIDTH_RATIO 0.5f // Mininum width ratio of the message view
+#define ENTRY_TEXTVIEW_MIN_HEIGHT 20 // Mininum height of the text entry view
+#define USER_LIST_DEFAULT_WIDTH 120 // Default width of the user list
//Preferences and files
-#define MESSAGE_VIEW_NIB @"MessageView" //Filename of the message view nib
-#define USERLIST_THEME @"UserList Theme" //File name of the user list theme
-#define USERLIST_LAYOUT @"UserList Layout" //File name of the user list layout
-#define KEY_ENTRY_TEXTVIEW_MIN_HEIGHT @"Minimum Text Height" //Preference key for text entry height
-#define KEY_ENTRY_USER_LIST_MIN_WIDTH @"UserList Minimum Width" //Preference key for user list width
-#define KEY_USER_LIST_VISIBLE_PREFIX @"Userlist Visible Chat:" //Preference key prefix for user list visibility
-#define KEY_USER_LIST_ON_RIGHT @"UserList On Right" // Preference key for user list being on the right
+#define MESSAGE_VIEW_NIB @"MessageView" // Filename of the message view nib
+#define USERLIST_THEME @"UserList Theme" // File name of the user list theme
+#define USERLIST_LAYOUT @"UserList Layout" // File name of the user list layout
+#define KEY_ENTRY_TEXTVIEW_MIN_HEIGHT @"Minimum Text Height" // Preference key for text entry height
+#define KEY_ENTRY_USER_LIST_MIN_WIDTH @"UserList Minimum Width" // Preference key for user list width
+#define KEY_USER_LIST_VISIBLE_PREFIX @"Userlist Visible Chat:" // Preference key prefix for user list visibility
+#define KEY_USER_LIST_ON_RIGHT @"UserList On Right" // Preference key for user list being on the right
#define TEXTVIEW_HEIGHT_DEBUG
diff -r e4ee1e095b3a -r 6433a4fcfe52 Source/ESUserIconHandlingPlugin.m
--- a/Source/ESUserIconHandlingPlugin.m Fri Mar 25 15:53:48 2011 -0500
+++ b/Source/ESUserIconHandlingPlugin.m Mon Mar 28 02:24:35 2011 +0300
@@ -133,6 +133,7 @@
object:nil];
button = [[AIImageButton alloc] initWithFrame:NSMakeRect(0,0,32,32)];
+
toolbarItem = [AIToolbarUtilities toolbarItemWithIdentifier:@"UserIcon"
label:AILocalizedString(@"Icon",nil)
paletteLabel:AILocalizedString(@"Contact Icon",nil)
@@ -145,6 +146,8 @@
[toolbarItem setMinSize:NSMakeSize(32,32)];
[toolbarItem setMaxSize:NSMakeSize(32,32)];
+
+ [button setCornerRadius:3.0f];
[button setToolbarItem:toolbarItem];
[button setImage:[NSImage imageNamed:@"userIconToolbar" forClass:[self class] loadLazily:YES]];
[button release];
More information about the commits
mailing list