Plugins/Dock Icon Badging/AIDockNameOverlay.m
author Frank Dowsett <wixardy@adium.im>
Fri, 18 Feb 2011 15:44:06 -0500
changeset 3670 add0c83648a5
child 3688 7e0b0cdfc8ff
permissions -rw-r--r--
Massive changes to dock icon drawing:
- Use NSDockTile for badging fixes #13439
- Remove flashing of the contact name* fixes #14452
- Use a constant size instead of the current screen's size fixes #13088

Fixes #616

*It's superfluous and may have been broken in 1.3 based on the reports from after 1.4 was released.
3670
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     1
#import "AIDockNameOverlay.h"
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     2
#import "AIDockController.h"
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     3
#import <Adium/AIChatControllerProtocol.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     4
#import <Adium/AIContactAlertsControllerProtocol.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     5
#import <Adium/AIStatusControllerProtocol.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     6
#import <AIUtilities/AIParagraphStyleAdditions.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     7
#import <AIUtilities/AIImageAdditions.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     8
#import <Adium/AIChat.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
     9
#import <Adium/AIAccount.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    10
#import <AIUtilities/AIArrayAdditions.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    11
#import <Adium/AIAbstractListController.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    12
#import <AIUtilities/AIColorAdditions.h>
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    13
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    14
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    15
#define DOCK_OVERLAY_ALERT_SHORT	AILocalizedString(@"Display name in the dock icon",nil)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    16
#define DOCK_OVERLAY_ALERT_LONG		DOCK_OVERLAY_ALERT_SHORT
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    17
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    18
@interface AIDockNameOverlay ()
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    19
- (void)flushPreferenceColorCache;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    20
- (void)drawOverlay;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    21
- (void)removeDockOverlay:(NSTimer *)removeTimer;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    22
@end
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    23
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    24
@implementation AIDockNameOverlay
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    25
- (void)installPlugin
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    26
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    27
	//Install our contact alert
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    28
	[adium.contactAlertsController registerActionID:DOCK_OVERLAY_ALERT_IDENTIFIER withHandler:self];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    29
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    30
	overlayObjectsArray = [[NSMutableArray alloc] init];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    31
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    32
	//Register as a contact observer (For signed on / signed off)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    33
	[[AIContactObserverManager sharedManager] registerListObjectObserver:self];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    34
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    35
	[adium.chatController registerChatObserver:self];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    36
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    37
	//Observe pref changes
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    38
	[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_APPEARANCE];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    39
	[adium.preferenceController registerPreferenceObserver:self forGroup:PREF_GROUP_LIST_THEME];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    40
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    41
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    42
- (void)preferencesChangedForGroup:(NSString *)group key:(NSString *)key
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    43
							object:(AIListObject *)object preferenceDict:(NSDictionary *)prefDict firstTime:(BOOL)firstTime
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    44
{	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    45
	if ([group isEqualToString:PREF_GROUP_LIST_THEME]) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    46
		//Grab colors from status coloring plugin's prefs
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    47
		[self flushPreferenceColorCache];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    48
		signedOffColor = [[[prefDict objectForKey:KEY_SIGNED_OFF_COLOR] representedColor] retain];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    49
		signedOnColor = [[[prefDict objectForKey:KEY_SIGNED_ON_COLOR] representedColor] retain];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    50
		unviewedContentColor = [[[prefDict objectForKey:KEY_UNVIEWED_COLOR] representedColor] retain];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    51
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    52
		backSignedOffColor = [[[prefDict objectForKey:KEY_LABEL_SIGNED_OFF_COLOR] representedColor] retain];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    53
		backSignedOnColor = [[[prefDict objectForKey:KEY_LABEL_SIGNED_ON_COLOR] representedColor] retain];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    54
		backUnviewedContentColor = [[[prefDict objectForKey:KEY_LABEL_UNVIEWED_COLOR] representedColor] retain];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    55
	}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    56
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    57
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    58
- (void)flushPreferenceColorCache
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    59
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    60
	[signedOffColor release]; signedOffColor = nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    61
	[signedOnColor release]; signedOnColor = nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    62
	[unviewedContentColor release]; unviewedContentColor = nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    63
	[backSignedOffColor release]; backSignedOffColor = nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    64
	[backSignedOnColor release]; backSignedOnColor = nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    65
	[backUnviewedContentColor release]; backUnviewedContentColor = nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    66
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    67
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    68
- (void)uninstallPlugin
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    69
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    70
	[adium.preferenceController unregisterPreferenceObserver:self];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    71
	[adium.chatController unregisterChatObserver:self];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    72
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    73
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    74
/*!
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    75
 * @brief Short description
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    76
 * @result A short localized description of the action
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    77
 */
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    78
- (NSString *)shortDescriptionForActionID:(NSString *)actionID
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    79
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    80
	return DOCK_OVERLAY_ALERT_SHORT;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    81
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    82
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    83
/*!
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    84
 * @brief Long description
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    85
 * @result A longer localized description of the action which should take into account the details dictionary as appropraite.
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    86
 */
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    87
- (NSString *)longDescriptionForActionID:(NSString *)actionID withDetails:(NSDictionary *)details
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    88
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    89
	return DOCK_OVERLAY_ALERT_LONG;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    90
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    91
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    92
/*!
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    93
 * @brief Image
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    94
 */
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    95
- (NSImage *)imageForActionID:(NSString *)actionID
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    96
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    97
	return [NSImage imageNamed:@"DockAlert" forClass:[self class]];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    98
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
    99
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   100
/*!
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   101
 * @brief Details pane
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   102
 * @result An <tt>AIModularPane</tt> to use for configuring this action, or nil if no configuration is possible.
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   103
 */
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   104
- (AIModularPane *)detailsPaneForActionID:(NSString *)actionID
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   105
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   106
	return nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   107
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   108
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   109
/*!
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   110
 * @brief Perform an action
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   111
 *
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   112
 * @param actionID The ID of the action to perform
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   113
 * @param listObject The listObject associated with the event triggering the action. It may be nil
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   114
 * @param details If set by the details pane when the action was created, the details dictionary for this particular action
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   115
 * @param eventID The eventID which triggered this action
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   116
 * @param userInfo Additional information associated with the event; userInfo's type will vary with the actionID.
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   117
 */
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   118
- (BOOL)performActionID:(NSString *)actionID forListObject:(AIListObject *)listObject withDetails:(NSDictionary *)details triggeringEventID:(NSString *)eventID userInfo:(id)userInfo
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   119
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   120
	BOOL isMessageEvent = [adium.contactAlertsController isMessageEvent:eventID];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   121
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   122
	if (isMessageEvent) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   123
		AIChat *chat;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   124
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   125
		if ((chat = [userInfo objectForKey:@"AIChat"]) &&
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   126
			(chat != adium.interfaceController.activeChat)) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   127
			if (![overlayObjectsArray containsObjectIdenticalTo:chat])
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   128
				[overlayObjectsArray addObject:chat];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   129
			
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   130
			//Wait until the next run loop so that this event is done processing and our unviewed content count is correct
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   131
			[self performSelector:@selector(drawOverlay)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   132
					   withObject:nil
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   133
					   afterDelay:0];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   134
		}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   135
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   136
	} else if (listObject) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   137
		NSTimer *removeTimer;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   138
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   139
		//Clear any current timer for this object to have its overlay removed
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   140
		if ((removeTimer = [listObject valueForProperty:@"DockOverlayRemoveTimer"])) [removeTimer invalidate];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   141
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   142
		//Add a timer to remove this overlay
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   143
		removeTimer = [NSTimer scheduledTimerWithTimeInterval:5
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   144
													   target:self
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   145
													 selector:@selector(removeDockOverlay:)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   146
													 userInfo:listObject
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   147
													  repeats:NO];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   148
		[listObject setValue:removeTimer
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   149
				 forProperty:@"DockOverlayRemoveTimer"
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   150
					  notify:NotifyNever];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   151
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   152
		if (![overlayObjectsArray containsObjectIdenticalTo:listObject])
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   153
			[overlayObjectsArray addObject:listObject];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   154
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   155
		[self drawOverlay];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   156
	}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   157
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   158
	return YES;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   159
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   160
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   161
/*!
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   162
 * @brief Allow multiple actions?
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   163
 *
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   164
 * If this method returns YES, every one of this action associated with the triggering event will be executed.
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   165
 * If this method returns NO, only the first will be.
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   166
 */
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   167
- (BOOL)allowMultipleActionsWithID:(NSString *)actionID
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   168
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   169
	return NO;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   170
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   171
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   172
/*!
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   173
 * @brief When a chat no longer has unviewed content remove it from display
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   174
 */
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   175
- (NSSet *)updateChat:(AIChat *)inChat keys:(NSSet *)inModifiedKeys silent:(BOOL)silent
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   176
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   177
	if (inModifiedKeys == nil || [inModifiedKeys containsObject:KEY_UNVIEWED_CONTENT]) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   178
		if (![inChat unviewedContentCount]) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   179
			[overlayObjectsArray removeObjectIdenticalTo:inChat];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   180
			[self drawOverlay];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   181
		}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   182
	}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   183
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   184
	return nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   185
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   186
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   187
/*!
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   188
 * @brief When an account signs on or off force an overlay update as its contacts statuses may have silently changed
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   189
 */
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   190
- (NSSet *)updateListObject:(AIListObject *)inObject keys:(NSSet *)inModifiedKeys silent:(BOOL)silent
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   191
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   192
	if ([inObject isKindOfClass:[AIAccount class]]) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   193
		if ([inModifiedKeys containsObject:@"isOnline"]) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   194
			BOOL madeChanges = NO;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   195
			
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   196
			for (AIListObject *listObject in [[overlayObjectsArray copy] autorelease]) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   197
				if (([listObject respondsToSelector:@selector(account)]) &&
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   198
					([(id)listObject account] == inObject) &&
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   199
					([overlayObjectsArray containsObjectIdenticalTo:listObject])) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   200
					[overlayObjectsArray removeObjectIdenticalTo:listObject];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   201
					madeChanges = YES;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   202
				}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   203
			}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   204
			
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   205
			if (madeChanges) [self drawOverlay];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   206
		}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   207
	}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   208
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   209
	return nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   210
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   211
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   212
- (void)removeDockOverlay:(NSTimer *)removeTimer
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   213
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   214
	AIListObject *inObject = [removeTimer userInfo];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   215
	[overlayObjectsArray removeObjectIdenticalTo:inObject];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   216
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   217
	[inObject setValue:nil
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   218
		   forProperty:@"DockOverlayRemoveTimer"
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   219
				notify:NotifyNever];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   220
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   221
	[self drawOverlay];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   222
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   223
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   224
- (void)drawOverlay
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   225
{
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   226
	NSFont				*font;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   227
	NSParagraphStyle	*paragraphStyle;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   228
	CGFloat				iconHeight;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   229
	CGFloat				top, bottom;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   230
	NSImage				*image = [[NSImage alloc] initWithSize:NSMakeSize(128, 128)];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   231
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   232
	iconHeight = 30.0f;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   233
	bottom = 2;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   234
	top = bottom + iconHeight;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   235
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   236
	//Set up the string details
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   237
	font = [NSFont boldSystemFontOfSize:24.0f];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   238
	paragraphStyle = [NSParagraphStyle styleWithAlignment:NSCenterTextAlignment lineBreakMode:NSLineBreakByClipping];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   239
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   240
	[image lockFocus];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   241
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   242
	//Clear our image
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   243
	[[NSColor clearColor] set];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   244
	NSRectFillUsingOperation(NSMakeRect(0, 0, 128, 128), NSCompositeCopy);
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   245
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   246
	//Draw overlays for each contact
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   247
	for (ESObjectWithProperties *object in [overlayObjectsArray reverseObjectEnumerator]) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   248
		if (top >= 128)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   249
			break;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   250
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   251
		CGFloat			left, right, arcRadius, stringInset;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   252
		NSBezierPath	*path;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   253
		NSColor			*backColor = nil, *textColor = nil, *borderColor = nil;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   254
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   255
		//Create the pill frame
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   256
		arcRadius = (iconHeight / 2.0f);
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   257
		stringInset = (iconHeight / 4.0f);
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   258
		left = 1 + arcRadius;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   259
		right = 127 - arcRadius;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   260
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   261
		path = [NSBezierPath bezierPath];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   262
		[path setLineWidth:((iconHeight/2.0f) * 0.13333f)];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   263
		//Top
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   264
		[path moveToPoint: NSMakePoint(left, top)];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   265
		[path lineToPoint: NSMakePoint(right, top)];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   266
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   267
		//Right rounded cap
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   268
		[path appendBezierPathWithArcWithCenter:NSMakePoint(right, top - arcRadius)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   269
										 radius:arcRadius
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   270
									 startAngle:90
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   271
									   endAngle:0
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   272
									  clockwise:YES];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   273
		[path lineToPoint: NSMakePoint(right + arcRadius, bottom + arcRadius)];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   274
		[path appendBezierPathWithArcWithCenter:NSMakePoint(right, bottom + arcRadius)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   275
										 radius:arcRadius
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   276
									 startAngle:0
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   277
									   endAngle:270
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   278
									  clockwise:YES];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   279
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   280
		//Bottom
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   281
		[path moveToPoint: NSMakePoint(right, bottom)];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   282
		[path lineToPoint: NSMakePoint(left, bottom)];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   283
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   284
		//Left rounded cap
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   285
		[path appendBezierPathWithArcWithCenter:NSMakePoint(left, bottom + arcRadius)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   286
										 radius:arcRadius
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   287
									 startAngle:270
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   288
									   endAngle:180
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   289
									  clockwise:YES];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   290
		[path lineToPoint: NSMakePoint(left - arcRadius, top - arcRadius)];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   291
		[path appendBezierPathWithArcWithCenter:NSMakePoint(left, top - arcRadius)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   292
										 radius:arcRadius
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   293
									 startAngle:180
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   294
									   endAngle:90
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   295
									  clockwise:YES];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   296
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   297
		if ([object integerValueForProperty:KEY_UNVIEWED_CONTENT]) { //Unviewed
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   298
			backColor = backUnviewedContentColor;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   299
			textColor = unviewedContentColor;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   300
		} else if ([object boolValueForProperty:@"signedOn"]) { //Signed on
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   301
			backColor = backSignedOnColor;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   302
			textColor = signedOnColor;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   303
		} else if ([object boolValueForProperty:@"signedOff"]) { //Signed off
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   304
			backColor = backSignedOffColor;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   305
			textColor = signedOffColor;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   306
		}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   307
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   308
		if (!backColor)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   309
			backColor = [NSColor whiteColor];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   310
		if (!textColor)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   311
			textColor = [NSColor blackColor];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   312
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   313
		//Lighten/Darken the back color slightly
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   314
		if ([backColor colorIsDark]) {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   315
			backColor = [backColor darkenBy:-0.15f];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   316
			borderColor = [backColor darkenBy:-0.3f];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   317
		} else {
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   318
			backColor = [backColor darkenBy:0.15f];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   319
			borderColor = [backColor darkenBy:0.3f];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   320
		}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   321
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   322
		//Draw
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   323
		[backColor set];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   324
		[path fill];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   325
		[borderColor set];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   326
		[path stroke];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   327
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   328
		//Get the object's display name
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   329
		[object.displayName drawInRect:NSMakeRect(stringInset + 1, bottom - 1, 127 - (stringInset * 2), top - bottom)
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   330
						withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, paragraphStyle, NSParagraphStyleAttributeName, textColor, NSForegroundColorAttributeName, nil]];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   331
		
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   332
		//Move up to the next pill
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   333
		bottom = top + 3.0f;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   334
		top = bottom + iconHeight;
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   335
	}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   336
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   337
	[image unlockFocus];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   338
	
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   339
	[adium.dockController setOverlay:image];
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   340
}
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   341
add0c83648a5 Massive changes to dock icon drawing:
Frank Dowsett <wixardy@adium.im>
parents:
diff changeset
   342
@end