From: <ho...@us...> - 2009-03-10 15:14:46
|
Revision: 14667 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14667&view=rev Author: hofman Date: 2009-03-10 15:14:37 +0000 (Tue, 10 Mar 2009) Log Message: ----------- replace Null values in group cell by nil. Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-03-10 13:53:02 UTC (rev 14666) +++ trunk/bibdesk/BDSKGroupCell.m 2009-03-10 15:14:37 UTC (rev 14667) @@ -156,30 +156,35 @@ return string; } +- (id)objectValueForKey:(NSString *)key { + id value = [[self objectValue] valueForKey:key]; + return [value isEqual:[NSNull null]] ? nil : value; +} + - (void)setObjectValue:(id <NSCopying>)obj { // we should not set a derived value such as the group name here, otherwise NSTableView will call tableView:setObjectValue:forTableColumn:row: whenever a cell is selected BDSKASSERT([(id)obj isKindOfClass:[NSDictionary class]]); [super setObjectValue:obj]; - [label replaceCharactersInRange:NSMakeRange(0, [label length]) withString:([(id)obj valueForKey:BDSKGroupCellStringKey] ?: @"")]; - [countString replaceCharactersInRange:NSMakeRange(0, [countString length]) withString:countStringWithNumber([(id)obj valueForKey:BDSKGroupCellImageKey])]; + [label replaceCharactersInRange:NSMakeRange(0, [label length]) withString:[self objectValueForKey:BDSKGroupCellStringKey] ?: @""]; + [countString replaceCharactersInRange:NSMakeRange(0, [countString length]) withString:countStringWithNumber([self objectValueForKey:BDSKGroupCellCountKey])]; } - (NSImage *)icon { - return [[self objectValue] valueForKey:BDSKGroupCellImageKey]; + return [self objectValueForKey:BDSKGroupCellImageKey]; } - (int)count { - return [[[self objectValue] valueForKey:BDSKGroupCellCountKey] intValue]; + return [[self objectValueForKey:BDSKGroupCellCountKey] intValue]; } - (BOOL)failedDownload { - return [[[self objectValue] valueForKey:BDSKGroupCellFailedDownloadKey] boolValue]; + return [[self objectValueForKey:BDSKGroupCellFailedDownloadKey] boolValue]; } - (BOOL)isRetrieving { - return [[[self objectValue] valueForKey:BDSKGroupCellIsRetrievingKey] boolValue]; + return [[self objectValueForKey:BDSKGroupCellIsRetrievingKey] boolValue]; } #pragma mark Drawing This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-03-11 12:32:15
|
Revision: 14679 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14679&view=rev Author: hofman Date: 2009-03-11 12:32:07 +0000 (Wed, 11 Mar 2009) Log Message: ----------- return string when the group value is not a dictionary Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-03-11 12:19:56 UTC (rev 14678) +++ trunk/bibdesk/BDSKGroupCell.m 2009-03-11 12:32:07 UTC (rev 14679) @@ -379,7 +379,7 @@ // this is actually never used, as BDSKGroupCell doesn't go through the formatter for display - (NSString *)stringForObjectValue:(id)obj{ BDSKASSERT([obj isKindOfClass:[NSDictionary class]]); - return nonNullObjectValueForKey(obj, BDSKGroupCellStringKey); + return [obj isKindOfClass:[NSString class]] ? obj : nonNullObjectValueForKey(obj, BDSKGroupCellStringKey); } - (NSString *)editingStringForObjectValue:(id)obj{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-03-25 17:43:27
|
Revision: 14864 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14864&view=rev Author: hofman Date: 2009-03-25 17:43:19 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Draw text in group cell up to the end when there's no count Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-03-25 17:29:31 UTC (rev 14863) +++ trunk/bibdesk/BDSKGroupCell.m 2009-03-25 17:43:19 UTC (rev 14864) @@ -229,19 +229,26 @@ countSize = [countString boundingRectWithSize:aRect.size options:0].size; } NSRect countRect, ignored; - // set countRect origin to the string drawing origin (number has countSep on either side for oval padding) - NSDivideRect(aRect, &ignored, &countRect, countSep + BORDER_BETWEEN_EDGE_AND_COUNT, NSMaxXEdge); - NSDivideRect(countRect, &countRect, &ignored, countSize.width, NSMaxXEdge); - // now set the size of it to the string size - countRect = BDSKCenterRect(countRect, countSize, YES); + if (countSize.width > 0.0) { + // set countRect origin to the string drawing origin (number has countSep on either side for oval padding) + NSDivideRect(aRect, &ignored, &countRect, countSep + BORDER_BETWEEN_EDGE_AND_COUNT, NSMaxXEdge); + NSDivideRect(countRect, &countRect, &ignored, countSize.width, NSMaxXEdge); + // now set the size of it to the string size + countRect = BDSKCenterRect(countRect, countSize, YES); + } else { + NSDivideRect(aRect, &countRect, &ignored, 0.0, NSMaxXEdge); + } return countRect; } - (NSRect)textRectForBounds:(NSRect)aRect; { - NSRect textRect = aRect; + NSRect textRect = aRect, countRect = [self countRectForBounds:aRect]; textRect.origin.x = NSMaxX([self iconRectForBounds:aRect]) + BORDER_BETWEEN_IMAGE_AND_TEXT; - textRect.size.width = NSMinX([self countRectForBounds:aRect]) - BORDER_BETWEEN_COUNT_AND_TEXT - [self countPaddingForCellSize:aRect.size] - NSMinX(textRect); + if (NSWidth(countRect) > 0.0) + textRect.size.width = NSMinX(countRect) - BORDER_BETWEEN_COUNT_AND_TEXT - [self countPaddingForCellSize:aRect.size] - NSMinX(textRect); + else + textRect.size.width = NSMaxX(aRect) - NSMinX(textRect); return textRect; } @@ -250,16 +257,14 @@ NSSize cellSize = [super cellSize]; NSSize countSize = NSZeroSize; float countSep = [self countPaddingForCellSize:cellSize]; - if ([self isRetrieving] || [self failedDownload]) { + if ([self isRetrieving] || [self failedDownload]) countSize = NSMakeSize(16, 16); - } - else if ([self count] > 0) { + else if ([self count] > 0) countSize = [countString boundingRectWithSize:cellSize options:0].size; - } - float countWidth = countSize.width + 2 * countSep + BORDER_BETWEEN_EDGE_AND_COUNT; // cellSize.height approximates the icon size - cellSize.width += cellSize.height + countWidth; - cellSize.width += BORDER_BETWEEN_EDGE_AND_IMAGE + BORDER_BETWEEN_IMAGE_AND_TEXT + BORDER_BETWEEN_COUNT_AND_TEXT; + cellSize.width += BORDER_BETWEEN_EDGE_AND_IMAGE + cellSize.height + BORDER_BETWEEN_IMAGE_AND_TEXT; + if (countSize.width > 0.0) + cellSize.width += BORDER_BETWEEN_COUNT_AND_TEXT + countSize.width + 2 * countSep + BORDER_BETWEEN_EDGE_AND_COUNT; return cellSize; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-03-27 14:27:40
|
Revision: 14875 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14875&view=rev Author: hofman Date: 2009-03-27 14:27:36 +0000 (Fri, 27 Mar 2009) Log Message: ----------- Move some preparation of the count string for group cell drawing into an if-block to avoid doing it when we don't need to Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-03-27 14:13:06 UTC (rev 14874) +++ trunk/bibdesk/BDSKGroupCell.m 2009-03-27 14:27:36 UTC (rev 14875) @@ -280,41 +280,39 @@ } - (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView { - - NSRange labelRange = NSMakeRange(0, [label length]); - [label addAttribute:NSFontAttributeName value:[self font] range:labelRange]; - [label addAttribute:NSForegroundColorAttributeName value:[self textColor] range:labelRange]; - - BOOL highlighted = [self isHighlighted]; - NSColor *bgColor = [NSColor disabledControlTextColor]; + // we have to do this first, otherwise the size calculation may be wrong NSRange countRange = NSMakeRange(0, [countString length]); [countString addAttributes:countAttributes range:countRange]; - - if (highlighted) { - [countString addAttribute:NSForegroundColorAttributeName value:[NSColor disabledControlTextColor] range:countRange]; - bgColor = [[NSColor alternateSelectedControlTextColor] colorWithAlphaComponent:0.8]; - } else { - [countString addAttribute:NSForegroundColorAttributeName value:[NSColor alternateSelectedControlTextColor] range:countRange]; - bgColor = [bgColor colorWithAlphaComponent:0.7]; - } - + // Draw the text // @@ Mail.app uses NSLineBreakByTruncatingTail for this - [label addAttribute:NSParagraphStyleAttributeName value:[NSParagraphStyle defaultTruncatingTailParagraphStyle] range:labelRange]; NSRect textRect = NSInsetRect([self textRectForBounds:aRect], SIZE_OF_TEXT_FIELD_BORDER, 0.0); + NSRange labelRange = NSMakeRange(0, [label length]); + [label addAttribute:NSFontAttributeName value:[self font] range:labelRange]; + [label addAttribute:NSForegroundColorAttributeName value:[self textColor] range:labelRange]; + [label addAttribute:NSParagraphStyleAttributeName value:[NSParagraphStyle defaultTruncatingTailParagraphStyle] range:labelRange]; [label drawWithRect:textRect options:NSStringDrawingUsesLineFragmentOrigin]; BOOL controlViewIsFlipped = [controlView isFlipped]; - NSRect countRect = [self countRectForBounds:aRect]; if ([self isRetrieving] == NO) { + NSRect countRect = [self countRectForBounds:aRect]; if ([self failedDownload]) { NSImage *cautionImage = [NSImage imageNamed:@"BDSKSmallCautionIcon"]; NSSize cautionImageSize = [cautionImage size]; NSRect cautionIconRect = NSMakeRect(0, 0, cautionImageSize.width, cautionImageSize.height); [cautionImage drawFlipped:controlViewIsFlipped inRect:countRect fromRect:cautionIconRect operation:NSCompositeSourceOver fraction:1.0]; } else if ([self count] > 0) { + NSColor *bgColor = [NSColor disabledControlTextColor]; + if ([self isHighlighted]) { + [countString addAttribute:NSForegroundColorAttributeName value:[NSColor disabledControlTextColor] range:countRange]; + bgColor = [[NSColor alternateSelectedControlTextColor] colorWithAlphaComponent:0.8]; + } else { + [countString addAttribute:NSForegroundColorAttributeName value:[NSColor alternateSelectedControlTextColor] range:countRange]; + bgColor = [bgColor colorWithAlphaComponent:0.7]; + } + [NSGraphicsContext saveGraphicsState]; [bgColor setFill]; [NSBezierPath fillHorizontalOvalAroundRect:countRect]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-03-27 15:20:41
|
Revision: 14876 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14876&view=rev Author: hofman Date: 2009-03-27 15:20:23 +0000 (Fri, 27 Mar 2009) Log Message: ----------- add shadow and make text bold in selected group cell, as NSTableView with source list style does with NSTextFieldCell Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-03-27 14:27:36 UTC (rev 14875) +++ trunk/bibdesk/BDSKGroupCell.m 2009-03-27 15:20:23 UTC (rev 14876) @@ -285,10 +285,19 @@ [countString addAttributes:countAttributes range:countRange]; // Draw the text - // @@ Mail.app uses NSLineBreakByTruncatingTail for this NSRect textRect = NSInsetRect([self textRectForBounds:aRect], SIZE_OF_TEXT_FIELD_BORDER, 0.0); NSRange labelRange = NSMakeRange(0, [label length]); - [label addAttribute:NSFontAttributeName value:[self font] range:labelRange]; + NSFont *font = [self font]; + if ([self isHighlighted]) { + font = [[NSFontManager sharedFontManager] convertFont:font toHaveTrait:NSBoldFontMask]; + NSShadow *shade = [[NSShadow alloc] init]; + [shade setShadowOffset:NSMakeSize(0.0, -1.0)]; + [label addAttribute:NSShadowAttributeName value:shade range:labelRange]; + [shade release]; + } else { + [label removeAttribute:NSShadowAttributeName range:labelRange]; + } + [label addAttribute:NSFontAttributeName value:font range:labelRange]; [label addAttribute:NSForegroundColorAttributeName value:[self textColor] range:labelRange]; [label addAttribute:NSParagraphStyleAttributeName value:[NSParagraphStyle defaultTruncatingTailParagraphStyle] range:labelRange]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-03-27 21:38:51
|
Revision: 14878 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14878&view=rev Author: hofman Date: 2009-03-27 21:38:34 +0000 (Fri, 27 Mar 2009) Log Message: ----------- Update group count attributes in setObjectValue, because it's relevant for the layout Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-03-27 16:11:23 UTC (rev 14877) +++ trunk/bibdesk/BDSKGroupCell.m 2009-03-27 21:38:34 UTC (rev 14878) @@ -171,6 +171,7 @@ - (void)setFont:(NSFont *)font { [super setFont:font]; [self recacheCountAttributes]; + [countString addAttributes:countAttributes range:NSMakeRange(0, [countString length])]; } @@ -198,6 +199,7 @@ [label replaceCharactersInRange:NSMakeRange(0, [label length]) withString:nonNullObjectValueForKey(obj, BDSKGroupCellStringKey) ?: @""]; [countString replaceCharactersInRange:NSMakeRange(0, [countString length]) withString:stringWithNumber(nonNullObjectValueForKey(obj, BDSKGroupCellCountKey))]; + [countString addAttributes:countAttributes range:NSMakeRange(0, [countString length])]; } #pragma mark Drawing @@ -280,10 +282,6 @@ } - (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView { - // we have to do this first, otherwise the size calculation may be wrong - NSRange countRange = NSMakeRange(0, [countString length]); - [countString addAttributes:countAttributes range:countRange]; - // Draw the text NSRect textRect = NSInsetRect([self textRectForBounds:aRect], SIZE_OF_TEXT_FIELD_BORDER, 0.0); NSRange labelRange = NSMakeRange(0, [label length]); @@ -292,6 +290,7 @@ font = [[NSFontManager sharedFontManager] convertFont:font toHaveTrait:NSBoldFontMask]; NSShadow *shade = [[NSShadow alloc] init]; [shade setShadowOffset:NSMakeSize(0.0, -1.0)]; + [shade setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.5]]; [label addAttribute:NSShadowAttributeName value:shade range:labelRange]; [shade release]; } else { @@ -313,13 +312,14 @@ NSRect cautionIconRect = NSMakeRect(0, 0, cautionImageSize.width, cautionImageSize.height); [cautionImage drawFlipped:controlViewIsFlipped inRect:countRect fromRect:cautionIconRect operation:NSCompositeSourceOver fraction:1.0]; } else if ([self count] > 0) { - NSColor *bgColor = [NSColor disabledControlTextColor]; + NSColor *fgColor; + NSColor *bgColor; if ([self isHighlighted]) { - [countString addAttribute:NSForegroundColorAttributeName value:[NSColor disabledControlTextColor] range:countRange]; + fgColor = [NSColor disabledControlTextColor]; bgColor = [[NSColor alternateSelectedControlTextColor] colorWithAlphaComponent:0.8]; } else { - [countString addAttribute:NSForegroundColorAttributeName value:[NSColor alternateSelectedControlTextColor] range:countRange]; - bgColor = [bgColor colorWithAlphaComponent:0.7]; + fgColor = [NSColor alternateSelectedControlTextColor]; + bgColor = [[NSColor disabledControlTextColor] colorWithAlphaComponent:0.7]; } [NSGraphicsContext saveGraphicsState]; @@ -327,6 +327,7 @@ [NSBezierPath fillHorizontalOvalAroundRect:countRect]; [NSGraphicsContext restoreGraphicsState]; + [countString addAttribute:NSForegroundColorAttributeName value:fgColor range:NSMakeRange(0, [countString length])]; [countString drawWithRect:countRect options:NSStringDrawingUsesLineFragmentOrigin]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-05 16:20:42
|
Revision: 14937 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14937&view=rev Author: hofman Date: 2009-04-05 16:20:35 +0000 (Sun, 05 Apr 2009) Log Message: ----------- use different colors for count bubble on Leopard Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-05 11:56:42 UTC (rev 14936) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-05 16:20:35 UTC (rev 14937) @@ -315,19 +315,39 @@ } else if ([self count] > 0) { NSColor *fgColor; NSColor *bgColor; - if ([self isHighlighted]) { - fgColor = [NSColor disabledControlTextColor]; - bgColor = [[NSColor alternateSelectedControlTextColor] colorWithAlphaComponent:0.8]; + if ([controlView respondsToSelector:@selector(setSelectionHighlightStyle:)]) { + if ([[controlView window] isMainWindow]) { + if ([self isHighlighted]) { + fgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.9]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.9]; + } + } else { + if ([self isHighlighted]) { + fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.9]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:0.9]; + } + } } else { - fgColor = [NSColor alternateSelectedControlTextColor]; - bgColor = [[NSColor disabledControlTextColor] colorWithAlphaComponent:0.7]; + if ([self isHighlighted]) { + fgColor = [NSColor disabledControlTextColor]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.8]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [[NSColor disabledControlTextColor] colorWithAlphaComponent:0.7]; + } } - + [NSGraphicsContext saveGraphicsState]; [bgColor setFill]; [NSBezierPath fillHorizontalOvalAroundRect:countRect]; [NSGraphicsContext restoreGraphicsState]; - + [countString addAttribute:NSForegroundColorAttributeName value:fgColor range:NSMakeRange(0, [countString length])]; [countString drawWithRect:countRect options:NSStringDrawingUsesLineFragmentOrigin]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-06 16:28:11
|
Revision: 14947 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14947&view=rev Author: hofman Date: 2009-04-06 16:27:55 +0000 (Mon, 06 Apr 2009) Log Message: ----------- smaller icon in groupcell, and offset by 1px for better alignment with text Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-06 16:07:54 UTC (rev 14946) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-06 16:27:55 UTC (rev 14947) @@ -210,10 +210,11 @@ #define SIZE_OF_TEXT_FIELD_BORDER (1.0) #define BORDER_BETWEEN_EDGE_AND_COUNT (2.0) #define BORDER_BETWEEN_COUNT_AND_TEXT (1.0) +#define IMAGE_OFFSET (1.0) - (NSSize)iconSizeForBounds:(NSRect)aRect; { - return NSMakeSize(NSHeight(aRect) + 1, NSHeight(aRect) + 1); + return NSMakeSize(NSHeight(aRect) - 1.0, NSHeight(aRect) - 1.0); } - (NSRect)iconRectForBounds:(NSRect)aRect; @@ -225,12 +226,6 @@ return imageRect; } -// compute the oval padding based on the overall height of the cell -- (float)countPaddingForCellSize:(NSSize)aSize; -{ - return ([self failedDownload] || [self isRetrieving]) ? 1.0 : 0.5 * aSize.height + 0.5; -} - - (NSRect)countRectForBounds:(NSRect)aRect; { NSSize countSize = NSZeroSize; @@ -356,6 +351,7 @@ // Draw the image NSRect imageRect = BDSKCenterRect([self iconRectForBounds:aRect], [self iconSizeForBounds:aRect], controlViewIsFlipped); + imageRect.origin.y += [controlView isFlipped] ? -IMAGE_OFFSET : IMAGE_OFFSET; [NSGraphicsContext saveGraphicsState]; [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh]; [[self icon] drawFlipped:controlViewIsFlipped inRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-08 09:41:38
|
Revision: 14966 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14966&view=rev Author: hofman Date: 2009-04-08 09:41:33 +0000 (Wed, 08 Apr 2009) Log Message: ----------- simplify hit test for group cell, and use backgroundCell to decide about state of cell on Leopard Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-08 05:00:45 UTC (rev 14965) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-08 09:41:33 UTC (rev 14966) @@ -277,12 +277,20 @@ return cellSize; } +- (NSRect)drawingRectForBounds:(NSRect)theRect { + return [self textRectForBounds:theRect]; +} + - (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView { // Draw the text NSRect textRect = NSInsetRect([self textRectForBounds:aRect], SIZE_OF_TEXT_FIELD_BORDER, 0.0); NSRange labelRange = NSMakeRange(0, [label length]); NSFont *font = [self font]; - if ([self isHighlighted]) { + BOOL isHighlighted = [self isHighlighted]; + if ([self respondsToSelector:@selector(backgroundStyle)]) + isHighlighted = ([self backgroundStyle] == NSBackgroundStyleDark || [self backgroundStyle] == NSBackgroundStyleLowered); + + if (isHighlighted) { font = [[NSFontManager sharedFontManager] convertFont:font toHaveTrait:NSBoldFontMask]; NSShadow *shade = [[NSShadow alloc] init]; [shade setShadowOffset:NSMakeSize(0.0, -1.0)]; @@ -309,7 +317,7 @@ NSColor *bgColor; if ([controlView respondsToSelector:@selector(setSelectionHighlightStyle:)]) { if ([[controlView window] isMainWindow]) { - if ([self isHighlighted]) { + if (isHighlighted) { fgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:1.0]; bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.9]; } else { @@ -317,7 +325,7 @@ bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.9]; } } else { - if ([self isHighlighted]) { + if (isHighlighted) { fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.9]; } else { @@ -326,7 +334,7 @@ } } } else { - if ([self isHighlighted]) { + if (isHighlighted) { fgColor = [NSColor disabledControlTextColor]; bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.8]; } else { @@ -362,20 +370,13 @@ - (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView { - NSUInteger hit = [super hitTestForEvent:event inRect:cellFrame ofView:controlView]; - // super returns 0 for button clicks, so -[NSTableView mouseDown:] doesn't track the cell - NSRect iconRect = [self iconRectForBounds:cellFrame]; + NSRect textRect = [self textRectForBounds:cellFrame]; NSPoint mouseLoc = [controlView convertPoint:[event locationInWindow] fromView:nil]; - if (NSMouseInRect(mouseLoc, iconRect, [controlView isFlipped])) { + NSUInteger hit = NSCellHitNone; + if (NSMouseInRect(mouseLoc, textRect, [controlView isFlipped])) + hit = [super hitTestForEvent:event inRect:textRect ofView:controlView]; + else if (NSMouseInRect(mouseLoc, [self iconRectForBounds:cellFrame], [controlView isFlipped])) hit = NSCellHitContentArea; - } else { - NSRect textRect = [self textRectForBounds:cellFrame]; - float textWidth = [super cellSize].width; - if (textWidth < NSWidth(textRect) && [NSString isEmptyString:[self stringValue]] == NO) - textRect.size.width = textWidth; - if (NSMouseInRect(mouseLoc, textRect, [controlView isFlipped])) - hit = NSCellHitContentArea | NSCellHitEditableTextArea; - } return hit; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-08 09:52:55
|
Revision: 14967 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14967&view=rev Author: hofman Date: 2009-04-08 09:52:53 +0000 (Wed, 08 Apr 2009) Log Message: ----------- Use brighter background of count bubble in group cell and use different text color in count bubble when the view is key Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-08 09:41:33 UTC (rev 14966) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-08 09:52:53 UTC (rev 14967) @@ -316,21 +316,29 @@ NSColor *fgColor; NSColor *bgColor; if ([controlView respondsToSelector:@selector(setSelectionHighlightStyle:)]) { - if ([[controlView window] isMainWindow]) { + if ([[controlView window] isMainWindow] == NO) { if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.9]; + fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; } else { fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.9]; + bgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:0.95]; } + } else if ([[controlView window] isKeyWindow] && [[controlView window] firstResponder] == controlView) { + if (isHighlighted) { + fgColor = [NSColor colorWithDeviceRed:14135.0/65535.0 green:29298.0/65535.0 blue:48830.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.95]; + } } else { if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.9]; + fgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; } else { fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:0.9]; + bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.95]; } } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-08 12:42:15
|
Revision: 14969 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14969&view=rev Author: hofman Date: 2009-04-08 12:32:58 +0000 (Wed, 08 Apr 2009) Log Message: ----------- don't define drawing rect for group cell, as this messes up editing of the cell Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-08 11:49:27 UTC (rev 14968) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-08 12:32:58 UTC (rev 14969) @@ -277,10 +277,6 @@ return cellSize; } -- (NSRect)drawingRectForBounds:(NSRect)theRect { - return [self textRectForBounds:theRect]; -} - - (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView { // Draw the text NSRect textRect = NSInsetRect([self textRectForBounds:aRect], SIZE_OF_TEXT_FIELD_BORDER, 0.0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-08 16:55:51
|
Revision: 14971 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14971&view=rev Author: hofman Date: 2009-04-08 16:55:43 +0000 (Wed, 08 Apr 2009) Log Message: ----------- don't cache attributes for count string separately and reorganize code a bit Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-08 13:01:31 UTC (rev 14970) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-08 16:55:43 UTC (rev 14971) @@ -53,33 +53,18 @@ NSString *BDSKGroupCellIsRetrievingKey = @"isRetrieving"; NSString *BDSKGroupCellFailedDownloadKey = @"failedDownload"; -static id nonNullObjectValueForKey(id object, NSString *key) { - id value = [object valueForKey:key]; - return [value isEqual:[NSNull null]] ? nil : value; -} - @interface BDSKGroupCellFormatter : NSFormatter @end #pragma mark -@interface BDSKGroupCell (Private) -- (void)recacheCountAttributes; -- (NSImage *)icon; -- (int)count; -- (BOOL)isRetrieving; -- (BOOL)failedDownload; -@end - @implementation BDSKGroupCell static NSMutableDictionary *numberStringDictionary = nil; static BDSKGroupCellFormatter *groupCellFormatter = nil; -+ (void)initialize; -{ ++ (void)initialize { BDSKINITIALIZE; - numberStringDictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"", [NSNumber numberWithInt:0], nil]; groupCellFormatter = [[BDSKGroupCellFormatter alloc] init]; @@ -87,15 +72,10 @@ - (id)init { if (self = [super initTextCell:@""]) { - [self setEditable:YES]; [self setScrollable:YES]; - - countString = [[NSMutableAttributedString alloc] initWithString:@""]; - - countAttributes = [[NSMutableDictionary alloc] initWithCapacity:5]; - [self recacheCountAttributes]; - + [self setWraps:NO]; + countString = [[NSMutableAttributedString alloc] init]; [self setFormatter:groupCellFormatter]; } return self; @@ -105,37 +85,23 @@ - (id)initWithCoder:(NSCoder *)coder { if (self = [super initWithCoder:coder]) { - // recreates the dictionary - countAttributes = [[NSMutableDictionary alloc] initWithCapacity:5]; - [self recacheCountAttributes]; - - countString = [[NSMutableAttributedString alloc] initWithString:@""]; - + countString = [[NSMutableAttributedString alloc] init]; if ([self formatter] == nil) [self setFormatter:groupCellFormatter]; } return self; } -- (void)encodeWithCoder:(NSCoder *)encoder { - [super encodeWithCoder:encoder]; -} - // NSCopying - (id)copyWithZone:(NSZone *)zone { BDSKGroupCell *copy = [super copyWithZone:zone]; - - // count attributes are shared between this cell and all copies, but not with new instances - copy->countAttributes = [countAttributes retain]; copy->countString = [countString mutableCopyWithZone:zone]; - return copy; } - (void)dealloc { [countString release]; - [countAttributes release]; [super dealloc]; } @@ -143,13 +109,18 @@ return nil; } +- (void)updateCountAttributes { + NSFont *countFont = [NSFont fontWithName:@"Helvetica-Bold" size:([[self font] pointSize] - 1)] ?: [NSFont boldSystemFontOfSize:([[self font] pointSize] - 1)]; + BDSKPRECONDITION(countFont); + [countString addAttribute:NSFontAttributeName value:countFont range:NSMakeRange(0, [countString length])]; + [countString addAttribute:NSKernAttributeName value:[NSNumber numberWithFloat:-1.0] range:NSMakeRange(0, [countString length])]; +} + - (void)setFont:(NSFont *)font { [super setFont:font]; - [self recacheCountAttributes]; - [countString addAttributes:countAttributes range:NSMakeRange(0, [countString length])]; + [self updateCountAttributes]; } - // all the -[NSNumber stringValue] does is create a string with a localized format description, so we'll cache more strings than Foundation does, since this shows up in Shark as a bottleneck static NSString *stringWithNumber(NSNumber *number) { @@ -163,6 +134,11 @@ return string; } +static id nonNullObjectValueForKey(id object, NSString *key) { + id value = [object valueForKey:key]; + return [value isEqual:[NSNull null]] ? nil : value; +} + - (void)setObjectValue:(id <NSCopying>)obj { // we should not set a derived value such as the group name here, otherwise NSTableView will call tableView:setObjectValue:forTableColumn:row: whenever a cell is selected @@ -173,9 +149,25 @@ [super setObjectValue:obj]; [countString replaceCharactersInRange:NSMakeRange(0, [countString length]) withString:stringWithNumber(nonNullObjectValueForKey(obj, BDSKGroupCellCountKey))]; - [countString addAttributes:countAttributes range:NSMakeRange(0, [countString length])]; + [self updateCountAttributes]; } +- (NSImage *)icon { + return nonNullObjectValueForKey([self objectValue], BDSKGroupCellImageKey); +} + +- (int)count { + return [nonNullObjectValueForKey([self objectValue], BDSKGroupCellCountKey) intValue]; +} + +- (BOOL)isRetrieving { + return [nonNullObjectValueForKey([self objectValue], BDSKGroupCellIsRetrievingKey) boolValue]; +} + +- (BOOL)failedDownload { + return [nonNullObjectValueForKey([self objectValue], BDSKGroupCellFailedDownloadKey) boolValue]; +} + #pragma mark Drawing #define BORDER_BETWEEN_EDGE_AND_IMAGE (3.0) @@ -185,13 +177,11 @@ #define BORDER_BETWEEN_COUNT_AND_TEXT (1.0) #define IMAGE_OFFSET (1.0) -- (NSSize)iconSizeForBounds:(NSRect)aRect; -{ +- (NSSize)iconSizeForBounds:(NSRect)aRect { return NSMakeSize(NSHeight(aRect) - 1.0, NSHeight(aRect) - 1.0); } -- (NSRect)iconRectForBounds:(NSRect)aRect; -{ +- (NSRect)iconRectForBounds:(NSRect)aRect { NSSize imageSize = [self iconSizeForBounds:aRect]; NSRect imageRect, ignored; NSDivideRect(aRect, &ignored, &imageRect, BORDER_BETWEEN_EDGE_AND_IMAGE, NSMinXEdge); @@ -199,8 +189,7 @@ return imageRect; } -- (NSRect)countRectForBounds:(NSRect)aRect; -{ +- (NSRect)countRectForBounds:(NSRect)aRect { NSSize countSize = NSZeroSize; if([self failedDownload] || [self isRetrieving]) { @@ -221,8 +210,7 @@ return countRect; } -- (NSRect)textRectForBounds:(NSRect)aRect; -{ +- (NSRect)textRectForBounds:(NSRect)aRect { NSRect textRect = aRect, countRect = [self countRectForBounds:aRect]; textRect.origin.x = NSMaxX([self iconRectForBounds:aRect]) + BORDER_BETWEEN_IMAGE_AND_TEXT; if (NSWidth(countRect) > 0.0) @@ -232,8 +220,7 @@ return textRect; } -- (NSSize)cellSize; -{ +- (NSSize)cellSize { NSSize cellSize = [super cellSize]; NSSize countSize = NSZeroSize; if ([self isRetrieving] || [self failedDownload]) { @@ -340,13 +327,11 @@ [self drawIcon:[self icon] withFrame:imageRect inView:controlView]; } -- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength; -{ +- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength { [super selectWithFrame:[self textRectForBounds:aRect] inView:controlView editor:textObj delegate:anObject start:selStart length:selLength]; } -- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView -{ +- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView { NSRect textRect = [self textRectForBounds:cellFrame]; NSPoint mouseLoc = [controlView convertPoint:[event locationInWindow] fromView:nil]; NSUInteger hit = NSCellHitNone; @@ -359,53 +344,22 @@ @end -@implementation BDSKGroupCell (Private) - -- (void)recacheCountAttributes { - NSFont *countFont = [NSFont fontWithName:@"Helvetica-Bold" size:([[self font] pointSize] - 1)] ?: [NSFont boldSystemFontOfSize:([[self font] pointSize] - 1)]; - BDSKPRECONDITION(countFont); - - [countAttributes removeAllObjects]; - [countAttributes setObject:[NSColor alternateSelectedControlTextColor] forKey:NSForegroundColorAttributeName]; - [countAttributes setObject:countFont forKey:NSFontAttributeName]; - [countAttributes setObject:[NSNumber numberWithFloat:-1.0] forKey:NSKernAttributeName]; - [countAttributes setObject:[NSParagraphStyle defaultClippingParagraphStyle] forKey:NSParagraphStyleAttributeName]; -} - -- (NSImage *)icon { - return nonNullObjectValueForKey([self objectValue], BDSKGroupCellImageKey); -} - -- (int)count { - return [nonNullObjectValueForKey([self objectValue], BDSKGroupCellCountKey) intValue]; -} - -- (BOOL)isRetrieving { - return [nonNullObjectValueForKey([self objectValue], BDSKGroupCellIsRetrievingKey) boolValue]; -} - -- (BOOL)failedDownload { - return [nonNullObjectValueForKey([self objectValue], BDSKGroupCellFailedDownloadKey) boolValue]; -} - -@end - #pragma mark - @implementation BDSKGroupCellFormatter // this is actually never used, as BDSKGroupCell doesn't go through the formatter for display -- (NSString *)stringForObjectValue:(id)obj{ +- (NSString *)stringForObjectValue:(id)obj { BDSKASSERT([obj isKindOfClass:[NSDictionary class]]); return [obj isKindOfClass:[NSString class]] ? obj : nonNullObjectValueForKey(obj, BDSKGroupCellStringKey); } -- (NSString *)editingStringForObjectValue:(id)obj{ +- (NSString *)editingStringForObjectValue:(id)obj { BDSKASSERT([obj isKindOfClass:[NSDictionary class]]); return nonNullObjectValueForKey(obj, BDSKGroupCellEditingStringKey) ?: nonNullObjectValueForKey(obj, BDSKGroupCellStringKey); } -- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error{ +- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString **)error { // even though 'string' is reported as immutable, it's actually changed after this method returns and before it's returned by the control! string = [[string copy] autorelease]; *obj = [NSDictionary dictionaryWithObjectsAndKeys:string, BDSKGroupCellStringKey, string, BDSKGroupCellEditingStringKey, nil]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-08 17:15:20
|
Revision: 14973 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14973&view=rev Author: hofman Date: 2009-04-08 17:15:04 +0000 (Wed, 08 Apr 2009) Log Message: ----------- use super to draw text in group cell, and fix bold font when highlighted because the source list table misses the general case Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-08 16:56:46 UTC (rev 14972) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-08 17:15:04 UTC (rev 14973) @@ -236,6 +236,16 @@ return cellSize; } +- (NSColor *)textColor { + if ([self respondsToSelector:@selector(backgroundStyle)] == NO) { + if (settingUpFieldEditor) + return [NSColor blackColor]; + else if ([self isHighlighted]) + return [NSColor textBackgroundColor]; + } + return [super textColor]; +} + - (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView { BOOL isHighlighted; if ([self respondsToSelector:@selector(backgroundStyle)]) @@ -245,22 +255,18 @@ // Draw the text NSRect textRect = NSInsetRect([self textRectForBounds:aRect], SIZE_OF_TEXT_FIELD_BORDER, 0.0); + NSFont *font = nil; NSAttributedString *label = [self attributedStringValue]; if (isHighlighted) { - // reproduce the bold shadowed color normally used by the source list highlight style - NSMutableAttributedString *mutableLabel = [label mutableCopy]; - NSRange labelRange = NSMakeRange(0, [label length]); - NSFont *font = [[NSFontManager sharedFontManager] convertFont:[self font] toHaveTrait:NSBoldFontMask]; - NSShadow *shade = [[NSShadow alloc] init]; - [shade setShadowOffset:NSMakeSize(0.0, -1.0)]; - [shade setShadowColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.5]]; - [mutableLabel addAttribute:NSFontAttributeName value:font range:labelRange]; - [mutableLabel addAttribute:NSForegroundColorAttributeName value:[NSColor whiteColor] range:labelRange]; - [mutableLabel addAttribute:NSShadowAttributeName value:shade range:labelRange]; - [shade release]; - label = [mutableLabel autorelease]; + // source list draws selected text bold, but only when the passing an NSString to setObjectValue: + font = [[self font] retain]; + [super setFont:[[NSFontManager sharedFontManager] convertFont:font toHaveTrait:NSBoldFontMask]]; } - [label drawWithRect:textRect options:NSStringDrawingUsesLineFragmentOrigin]; + [super drawInteriorWithFrame:textRect inView:controlView]; + if (font) { + [super setFont:font]; + [font release]; + } // Draw the count bubble or caution icon, when we're retrieving we don't draw to leave space for the spinner if ([self isRetrieving] == NO) { @@ -328,7 +334,9 @@ } - (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength { + settingUpFieldEditor = YES; [super selectWithFrame:[self textRectForBounds:aRect] inView:controlView editor:textObj delegate:anObject start:selStart length:selLength]; + settingUpFieldEditor = NO; } - (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-08 17:30:52
|
Revision: 14975 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14975&view=rev Author: hofman Date: 2009-04-08 17:30:47 +0000 (Wed, 08 Apr 2009) Log Message: ----------- fix cellSize for group cell with large count Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-08 17:19:27 UTC (rev 14974) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-08 17:30:47 UTC (rev 14975) @@ -227,7 +227,7 @@ countSize = NSMakeSize(16, 16); } else if ([self count] > 0) { countSize = [countString boundingRectWithSize:cellSize options:0].size; - countSize.width += countSize.height; + countSize.width += [self count] < 100 ? countSize.height : 0.5 * countSize.height; // add oval pading around count } // cellSize.height approximates the icon size cellSize.width += BORDER_BETWEEN_EDGE_AND_IMAGE + cellSize.height + BORDER_BETWEEN_IMAGE_AND_TEXT; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-08 22:58:12
|
Revision: 14977 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=14977&view=rev Author: hofman Date: 2009-04-08 22:58:11 +0000 (Wed, 08 Apr 2009) Log Message: ----------- edit group name over count bubble, as Mail does Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-08 21:02:49 UTC (rev 14976) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-08 22:58:11 UTC (rev 14977) @@ -334,8 +334,10 @@ } - (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength { + NSRect editRect = [self textRectForBounds:aRect]; + editRect.size.width = NSMaxX(aRect) - NSMinX(editRect); settingUpFieldEditor = YES; - [super selectWithFrame:[self textRectForBounds:aRect] inView:controlView editor:textObj delegate:anObject start:selStart length:selLength]; + [super selectWithFrame:editRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength]; settingUpFieldEditor = NO; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-17 22:02:57
|
Revision: 15099 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15099&view=rev Author: hofman Date: 2009-04-17 22:02:53 +0000 (Fri, 17 Apr 2009) Log Message: ----------- source list highlight colors depend on the control tint, so do the same in the group cell for consistency Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-17 21:26:15 UTC (rev 15098) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-17 22:02:53 UTC (rev 15099) @@ -281,29 +281,57 @@ NSColor *bgColor; if ([controlView respondsToSelector:@selector(setSelectionHighlightStyle:)]) { // On Leopard, use the blue or gray color taken from the center of the gradient highlight - if ([[controlView window] isMainWindow] == NO) { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + if ([NSColor currentControlTint] == NSGraphiteControlTint) { + if ([[controlView window] isMainWindow] == NO) { + if (isHighlighted) { + fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:0.95]; + } + } else if ([[controlView window] isKeyWindow] && [[controlView window] firstResponder] == controlView) { + if (isHighlighted) { + fgColor = [NSColor colorWithDeviceRed:24672.0/65535.0 green:29812.0/65535.0 blue:35466.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:24672.0/65535.0 green:29812.0/65535.0 blue:35466.0/65535.0 alpha:0.95]; + } } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:0.95]; + if (isHighlighted) { + fgColor = [NSColor colorWithDeviceRed:37779.0/65535.0 green:41634.0/65535.0 blue:45489.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:37779.0/65535.0 green:41634.0/65535.0 blue:45489.0/65535.0 alpha:0.95]; + } } - } else if ([[controlView window] isKeyWindow] && [[controlView window] firstResponder] == controlView) { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:14135.0/65535.0 green:29298.0/65535.0 blue:48830.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; - } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.95]; - } } else { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + if ([[controlView window] isMainWindow] == NO) { + if (isHighlighted) { + fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:0.95]; + } + } else if ([[controlView window] isKeyWindow] && [[controlView window] firstResponder] == controlView) { + if (isHighlighted) { + fgColor = [NSColor colorWithDeviceRed:14135.0/65535.0 green:29298.0/65535.0 blue:48830.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:14135.0/65535.0 green:29298.0/65535.0 blue:48830.0/65535.0 alpha:0.95]; + } } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.95]; + if (isHighlighted) { + fgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; + } else { + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.95]; + } } } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-18 17:30:39
|
Revision: 15101 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15101&view=rev Author: hofman Date: 2009-04-18 17:30:31 +0000 (Sat, 18 Apr 2009) Log Message: ----------- define static c-arrays for source list highlight colors Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-18 04:58:43 UTC (rev 15100) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-18 17:30:31 UTC (rev 15101) @@ -248,6 +248,13 @@ return [super textColor]; } +static CGFloat keyColorBlue[3] = {14135.0/65535.0, 29298.0/65535.0, 48830.0/65535.0}; +static CGFloat mainColorBlue[3] = {37779.0/65535.0, 41634.0/65535.0, 45489.0/65535.0}; +static CGFloat disabledColorBlue[3] = {40606.0/65535.0, 40606.0/65535.0, 40606.0/65535.0}; +static CGFloat keyColorGraphite[3] = {24672.0/65535.0, 29812.0/65535.0, 35466.0/65535.0}; +static CGFloat mainColorGraphite[3] = {37779.0/65535.0, 41634.0/65535.0, 45489.0/65535.0}; +static CGFloat disabledColorGraphite[3] = {40606.0/65535.0, 40606.0/65535.0, 40606.0/65535.0}; + - (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView { BOOL isHighlighted; if ([self respondsToSelector:@selector(backgroundStyle)]) @@ -281,58 +288,21 @@ NSColor *bgColor; if ([controlView respondsToSelector:@selector(setSelectionHighlightStyle:)]) { // On Leopard, use the blue or gray color taken from the center of the gradient highlight - if ([NSColor currentControlTint] == NSGraphiteControlTint) { - if ([[controlView window] isMainWindow] == NO) { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; - } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:0.95]; - } - } else if ([[controlView window] isKeyWindow] && [[controlView window] firstResponder] == controlView) { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:24672.0/65535.0 green:29812.0/65535.0 blue:35466.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; - } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:24672.0/65535.0 green:29812.0/65535.0 blue:35466.0/65535.0 alpha:0.95]; - } - } else { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:37779.0/65535.0 green:41634.0/65535.0 blue:45489.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; - } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:37779.0/65535.0 green:41634.0/65535.0 blue:45489.0/65535.0 alpha:0.95]; - } - } + CGFloat *color; + BOOL isGraphite = [NSColor currentControlTint] == NSGraphiteControlTint; + if ([[controlView window] isMainWindow] == NO) + color = isGraphite ? disabledColorGraphite : disabledColorBlue; + else if ([[controlView window] isKeyWindow] && [[controlView window] firstResponder] == controlView) + // the key state color does not look nice for the count bubble background + color = isHighlighted ? (isGraphite ? keyColorGraphite : keyColorBlue) : (isGraphite ? mainColorGraphite : mainColorBlue); + else + color = isGraphite ? mainColorGraphite : mainColorBlue; + if (isHighlighted) { + fgColor = [NSColor colorWithDeviceRed:color[0] green:color[1] blue:color[2] alpha:1.0]; + bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; } else { - if ([[controlView window] isMainWindow] == NO) { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; - } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:40606.0/65535.0 green:40606.0/65535.0 blue:40606.0/65535.0 alpha:0.95]; - } - } else if ([[controlView window] isKeyWindow] && [[controlView window] firstResponder] == controlView) { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:14135.0/65535.0 green:29298.0/65535.0 blue:48830.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; - } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:14135.0/65535.0 green:29298.0/65535.0 blue:48830.0/65535.0 alpha:0.95]; - } - } else { - if (isHighlighted) { - fgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceWhite:1.0 alpha:0.95]; - } else { - fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; - bgColor = [NSColor colorWithDeviceRed:34695.0/65535.0 green:39064.0/65535.0 blue:48316.0/65535.0 alpha:0.95]; - } - } + fgColor = [NSColor colorWithDeviceWhite:1.0 alpha:1.0]; + bgColor = [NSColor colorWithDeviceRed:color[0] green:color[1] blue:color[2] alpha:0.95]; } } else { // On Tiger use gray This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-29 17:20:07
|
Revision: 15239 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15239&view=rev Author: hofman Date: 2009-04-29 17:19:53 +0000 (Wed, 29 Apr 2009) Log Message: ----------- use the same font size for the count bubble as the text Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-29 17:11:35 UTC (rev 15238) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-29 17:19:53 UTC (rev 15239) @@ -110,7 +110,7 @@ } - (void)updateCountAttributes { - NSFont *countFont = [NSFont fontWithName:@"Helvetica-Bold" size:([[self font] pointSize] - 1)] ?: [NSFont boldSystemFontOfSize:([[self font] pointSize] - 1)]; + NSFont *countFont = [NSFont fontWithName:@"Helvetica-Bold" size:[[self font] pointSize]] ?: [NSFont boldSystemFontOfSize:[[self font] pointSize]]; BDSKPRECONDITION(countFont); [countString addAttribute:NSFontAttributeName value:countFont range:NSMakeRange(0, [countString length])]; [countString addAttribute:NSKernAttributeName value:[NSNumber numberWithFloat:-1.0] range:NSMakeRange(0, [countString length])]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-29 17:33:51
|
Revision: 15240 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15240&view=rev Author: hofman Date: 2009-04-29 17:33:43 +0000 (Wed, 29 Apr 2009) Log Message: ----------- slightly larger count bubbles for large counts Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-29 17:19:53 UTC (rev 15239) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-29 17:33:43 UTC (rev 15240) @@ -198,7 +198,7 @@ countSize = [self iconSizeForBounds:aRect]; } else if ([self count] > 0) { countSize = [countString boundingRectWithSize:aRect.size options:0].size; - countSize.width += [self count] < 100 ? countSize.height : 0.5 * countSize.height; // add oval pading around count + countSize.width += [self count] < 100 ? countSize.height : 0.7 * countSize.height; // add oval pading around count } NSRect countRect, ignored; if (countSize.width > 0.0) { @@ -229,7 +229,7 @@ countSize = NSMakeSize(16, 16); } else if ([self count] > 0) { countSize = [countString boundingRectWithSize:cellSize options:0].size; - countSize.width += [self count] < 100 ? countSize.height : 0.5 * countSize.height; // add oval pading around count + countSize.width += [self count] < 100 ? countSize.height : 0.7 * countSize.height; // add oval pading around count } // cellSize.height approximates the icon size cellSize.width += BORDER_BETWEEN_EDGE_AND_IMAGE + cellSize.height + BORDER_BETWEEN_IMAGE_AND_TEXT; @@ -283,7 +283,7 @@ if ([self failedDownload]) { [self drawIcon:[NSImage imageNamed:@"BDSKSmallCautionIcon"] withFrame:countRect inView:controlView]; } else if (count > 0) { - CGFloat countInset = count < 100 ? 0.5 * NSHeight(countRect) : 0.25 * NSHeight(countRect); + CGFloat countInset = count < 100 ? 0.5 * NSHeight(countRect) : 0.35 * NSHeight(countRect); NSColor *fgColor; NSColor *bgColor; if ([controlView respondsToSelector:@selector(setSelectionHighlightStyle:)]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-04-29 17:39:49
|
Revision: 15241 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15241&view=rev Author: hofman Date: 2009-04-29 17:39:29 +0000 (Wed, 29 Apr 2009) Log Message: ----------- reduce count bubble size for small count Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-04-29 17:33:43 UTC (rev 15240) +++ trunk/bibdesk/BDSKGroupCell.m 2009-04-29 17:39:29 UTC (rev 15241) @@ -198,7 +198,7 @@ countSize = [self iconSizeForBounds:aRect]; } else if ([self count] > 0) { countSize = [countString boundingRectWithSize:aRect.size options:0].size; - countSize.width += [self count] < 100 ? countSize.height : 0.7 * countSize.height; // add oval pading around count + countSize.width += ([self count] < 100 ? 0.9 : 0.7) * countSize.height; // add oval pading around count } NSRect countRect, ignored; if (countSize.width > 0.0) { @@ -229,7 +229,7 @@ countSize = NSMakeSize(16, 16); } else if ([self count] > 0) { countSize = [countString boundingRectWithSize:cellSize options:0].size; - countSize.width += [self count] < 100 ? countSize.height : 0.7 * countSize.height; // add oval pading around count + countSize.width += ([self count] < 100 ? 0.9 : 0.7) * countSize.height; // add oval pading around count } // cellSize.height approximates the icon size cellSize.width += BORDER_BETWEEN_EDGE_AND_IMAGE + cellSize.height + BORDER_BETWEEN_IMAGE_AND_TEXT; @@ -283,7 +283,7 @@ if ([self failedDownload]) { [self drawIcon:[NSImage imageNamed:@"BDSKSmallCautionIcon"] withFrame:countRect inView:controlView]; } else if (count > 0) { - CGFloat countInset = count < 100 ? 0.5 * NSHeight(countRect) : 0.35 * NSHeight(countRect); + CGFloat countInset = (count < 100 ? 0.45 : 0.35) * NSHeight(countRect); NSColor *fgColor; NSColor *bgColor; if ([controlView respondsToSelector:@selector(setSelectionHighlightStyle:)]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-05-01 09:54:50
|
Revision: 15249 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15249&view=rev Author: hofman Date: 2009-05-01 09:54:28 +0000 (Fri, 01 May 2009) Log Message: ----------- separate method to get the count padding for group count bubble Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-05-01 04:59:06 UTC (rev 15248) +++ trunk/bibdesk/BDSKGroupCell.m 2009-05-01 09:54:28 UTC (rev 15249) @@ -177,6 +177,11 @@ #define TEXT_INSET (2.0) #define IMAGE_SIZE_OFFSET (2.0) +- (CGFloat)countPaddingForSize:(NSSize)countSize { + NSInteger count = [self count]; + return (count < 10 ? 1.0 : count < 100 ? 0.9 : 0.7) * countSize.height; +} + - (NSSize)iconSizeForBounds:(NSRect)aRect { return NSMakeSize(NSHeight(aRect) - IMAGE_SIZE_OFFSET, NSHeight(aRect) - IMAGE_SIZE_OFFSET); } @@ -198,7 +203,7 @@ countSize = [self iconSizeForBounds:aRect]; } else if ([self count] > 0) { countSize = [countString boundingRectWithSize:aRect.size options:0].size; - countSize.width += ([self count] < 100 ? 0.9 : 0.7) * countSize.height; // add oval pading around count + countSize.width += [self countPaddingForSize:countSize]; // add oval pading around count } NSRect countRect, ignored; if (countSize.width > 0.0) { @@ -229,7 +234,7 @@ countSize = NSMakeSize(16, 16); } else if ([self count] > 0) { countSize = [countString boundingRectWithSize:cellSize options:0].size; - countSize.width += ([self count] < 100 ? 0.9 : 0.7) * countSize.height; // add oval pading around count + countSize.width += [self countPaddingForSize:countSize]; // add oval pading around count } // cellSize.height approximates the icon size cellSize.width += BORDER_BETWEEN_EDGE_AND_IMAGE + cellSize.height + BORDER_BETWEEN_IMAGE_AND_TEXT; @@ -283,7 +288,7 @@ if ([self failedDownload]) { [self drawIcon:[NSImage imageNamed:@"BDSKSmallCautionIcon"] withFrame:countRect inView:controlView]; } else if (count > 0) { - CGFloat countInset = (count < 100 ? 0.45 : 0.35) * NSHeight(countRect); + CGFloat countInset = 0.5 * [self countPaddingForSize:countRect.size]; NSColor *fgColor; NSColor *bgColor; if ([controlView respondsToSelector:@selector(setSelectionHighlightStyle:)]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-06-10 14:41:25
|
Revision: 15403 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15403&view=rev Author: hofman Date: 2009-06-10 14:41:23 +0000 (Wed, 10 Jun 2009) Log Message: ----------- don't make group cel count narrower Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-06-10 05:01:04 UTC (rev 15402) +++ trunk/bibdesk/BDSKGroupCell.m 2009-06-10 14:41:23 UTC (rev 15403) @@ -113,7 +113,6 @@ NSFont *countFont = [NSFont fontWithName:@"Helvetica-Bold" size:[[self font] pointSize]] ?: [NSFont boldSystemFontOfSize:[[self font] pointSize]]; BDSKPRECONDITION(countFont); [countString addAttribute:NSFontAttributeName value:countFont range:NSMakeRange(0, [countString length])]; - [countString addAttribute:NSKernAttributeName value:[NSNumber numberWithFloat:-1.0] range:NSMakeRange(0, [countString length])]; } - (void)setFont:(NSFont *)font { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-11-05 20:22:01
|
Revision: 15987 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15987&view=rev Author: hofman Date: 2009-11-05 20:21:54 +0000 (Thu, 05 Nov 2009) Log Message: ----------- draw an alert icon in badge colors for groups with failed download Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-11-05 19:15:54 UTC (rev 15986) +++ trunk/bibdesk/BDSKGroupCell.m 2009-11-05 20:21:54 UTC (rev 15987) @@ -274,7 +274,7 @@ NSRect countRect = [self countRectForBounds:aRect]; NSInteger count = [self count]; if (count > 0 || [self failedDownload]) { - CGFloat countInset = 0.5 * [self countPaddingForSize:countRect.size]; + NSColor *fgColor; NSColor *bgColor; // On Leopard, use the blue or gray color taken from the center of the gradient highlight @@ -296,17 +296,49 @@ } [NSGraphicsContext saveGraphicsState]; - [bgColor setFill]; + if ([self failedDownload]) { + + [bgColor setFill]; [[NSBezierPath bezierPathWithOvalInRect:countRect] fill]; - countInset = 0.5 * (NSWidth(countRect) - NSWidth([countString boundingRectWithSize:countRect.size options:0])); + [fgColor setFill]; + CGFloat u = NSWidth(countRect) / 16.0; + NSBezierPath *path = [NSBezierPath bezierPath]; + [path moveToPoint:NSMakePoint(NSMidX(countRect), NSMinY(countRect) + u)]; + [path relativeLineToPoint:NSMakePoint(-6.0 * u, 12.0 * u)]; + [path relativeLineToPoint:NSMakePoint(12.0 * u, 0)]; + [path closePath]; + [path fill]; + [bgColor setFill]; + path = [NSBezierPath bezierPath]; + [path moveToPoint:NSMakePoint(NSMidX(countRect) - u / 2.0, NSMinY(countRect) + 4.0 * u)]; + [path relativeLineToPoint:NSMakePoint(u, 0)]; + [path relativeLineToPoint:NSMakePoint(0, 5.0 * u)]; + [path relativeLineToPoint:NSMakePoint(-u, 0)]; + [path closePath]; + [path relativeMoveToPoint:NSMakePoint(0, 6.0 * u)]; + [path relativeLineToPoint:NSMakePoint(u, 0)]; + [path relativeLineToPoint:NSMakePoint(0, u)]; + [path relativeLineToPoint:NSMakePoint(-u, 0)]; + [path closePath]; + [path setWindingRule:NSEvenOddWindingRule]; + [path fill]; + [path fill]; + } else { + + CGFloat countInset = 0.5 * [self countPaddingForSize:countRect.size]; + + [bgColor setFill]; [NSBezierPath fillHorizontalOvalInRect:countRect]; + [NSGraphicsContext restoreGraphicsState]; + + [countString addAttribute:NSForegroundColorAttributeName value:fgColor range:NSMakeRange(0, [countString length])]; + [countString drawWithRect:NSInsetRect(countRect, countInset, 0.0) options:NSStringDrawingUsesLineFragmentOrigin]; + } + [NSGraphicsContext restoreGraphicsState]; - - [countString addAttribute:NSForegroundColorAttributeName value:fgColor range:NSMakeRange(0, [countString length])]; - [countString drawWithRect:NSInsetRect(countRect, countInset, 0.0) options:NSStringDrawingUsesLineFragmentOrigin]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-11-05 21:04:48
|
Revision: 15988 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15988&view=rev Author: hofman Date: 2009-11-05 21:04:35 +0000 (Thu, 05 Nov 2009) Log Message: ----------- take flipped into account for alert badge drawing Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-11-05 20:21:54 UTC (rev 15987) +++ trunk/bibdesk/BDSKGroupCell.m 2009-11-05 21:04:35 UTC (rev 15988) @@ -124,7 +124,7 @@ static NSString *stringWithNumber(NSNumber *number) { if (number == nil) - return @""; + return @"0"; NSString *string = [numberStringDictionary objectForKey:number]; if (string == nil) { string = [number stringValue]; @@ -199,8 +199,6 @@ if ([self isRetrieving]) { countSize = NSMakeSize(16.0, 16.0); } else if ([self failedDownload]) { - [countString replaceCharactersInRange:NSMakeRange(0, [countString length]) withString:@"!"]; - [self updateCountAttributes]; countSize = [countString boundingRectWithSize:aRect.size options:0].size; countSize.width = countSize.height; } else if ([self count] > 0) { @@ -302,16 +300,17 @@ [bgColor setFill]; [[NSBezierPath bezierPathWithOvalInRect:countRect] fill]; [fgColor setFill]; - CGFloat u = NSWidth(countRect) / 16.0; + CGFloat u = [controlView isFlipped] ? NSWidth(countRect) / 16.0 : NSWidth(countRect) / -16.0; + NSPoint top = NSMakePoint(NSMidX(countRect), [controlView isFlipped] ? NSMinY(countRect) : NSMaxY(countRect)); NSBezierPath *path = [NSBezierPath bezierPath]; - [path moveToPoint:NSMakePoint(NSMidX(countRect), NSMinY(countRect) + u)]; + [path moveToPoint:NSMakePoint(top.x, top.y + u)]; [path relativeLineToPoint:NSMakePoint(-6.0 * u, 12.0 * u)]; [path relativeLineToPoint:NSMakePoint(12.0 * u, 0)]; [path closePath]; [path fill]; [bgColor setFill]; path = [NSBezierPath bezierPath]; - [path moveToPoint:NSMakePoint(NSMidX(countRect) - u / 2.0, NSMinY(countRect) + 4.0 * u)]; + [path moveToPoint:NSMakePoint(top.x - u / 2.0, top.y + 4.0 * u)]; [path relativeLineToPoint:NSMakePoint(u, 0)]; [path relativeLineToPoint:NSMakePoint(0, 5.0 * u)]; [path relativeLineToPoint:NSMakePoint(-u, 0)]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2009-11-05 22:19:16
|
Revision: 15989 http://bibdesk.svn.sourceforge.net/bibdesk/?rev=15989&view=rev Author: hofman Date: 2009-11-05 22:19:08 +0000 (Thu, 05 Nov 2009) Log Message: ----------- make sure we don't have a non-empty count string so we have a relevant font Modified Paths: -------------- trunk/bibdesk/BDSKGroupCell.m Modified: trunk/bibdesk/BDSKGroupCell.m =================================================================== --- trunk/bibdesk/BDSKGroupCell.m 2009-11-05 21:04:35 UTC (rev 15988) +++ trunk/bibdesk/BDSKGroupCell.m 2009-11-05 22:19:08 UTC (rev 15989) @@ -65,7 +65,7 @@ + (void)initialize { BDSKINITIALIZE; - numberStringDictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:@"", [NSNumber numberWithInt:0], nil]; + numberStringDictionary = [[NSMutableDictionary alloc] init]; groupCellFormatter = [[BDSKGroupCellFormatter alloc] init]; } @@ -230,11 +230,14 @@ - (NSSize)cellSize { NSSize cellSize = [super cellSize]; NSSize countSize = NSZeroSize; - if ([self isRetrieving] || [self failedDownload]) { + if ([self isRetrieving]) { countSize = NSMakeSize(16, 16); - } else if ([self count] > 0) { + } else if ([self count] > 0 || [self failedDownload]) { countSize = [countString boundingRectWithSize:cellSize options:0].size; - countSize.width += [self countPaddingForSize:countSize]; // add oval pading around count + if ([self failedDownload]) + countSize.width = countSize.height; + else + countSize.width += [self countPaddingForSize:countSize]; // add oval pading around count } // cellSize.height approximates the icon size cellSize.width += BORDER_BETWEEN_EDGE_AND_IMAGE + cellSize.height + BORDER_BETWEEN_IMAGE_AND_TEXT; @@ -312,10 +315,10 @@ path = [NSBezierPath bezierPath]; [path moveToPoint:NSMakePoint(top.x - u / 2.0, top.y + 4.0 * u)]; [path relativeLineToPoint:NSMakePoint(u, 0)]; - [path relativeLineToPoint:NSMakePoint(0, 5.0 * u)]; + [path relativeLineToPoint:NSMakePoint(0, 6.0 * u)]; [path relativeLineToPoint:NSMakePoint(-u, 0)]; [path closePath]; - [path relativeMoveToPoint:NSMakePoint(0, 6.0 * u)]; + [path relativeMoveToPoint:NSMakePoint(0, 7.0 * u)]; [path relativeLineToPoint:NSMakePoint(u, 0)]; [path relativeLineToPoint:NSMakePoint(0, u)]; [path relativeLineToPoint:NSMakePoint(-u, 0)]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |