Changeset 3214

Show
Ignore:
Timestamp:
04/20/06 02:30:38 (2 years ago)
Author:
timothy
Message:

New message counts in the drawer/sidebar.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Colloquy.xcodeproj/project.pbxproj

    r3208 r3214  
    650650                1CBA4E64062CCDA90082D1BF /* infoWidget.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = infoWidget.png; path = Resources/infoWidget.png; sourceTree = SOURCE_ROOT; }; 
    651651                1CBA4E65062CCDA90082D1BF /* infoWidgetPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = infoWidgetPressed.png; path = Resources/infoWidgetPressed.png; sourceTree = SOURCE_ROOT; }; 
    652                 1CBB23CD04EFE233000001C8 /* actionWidget.png */ = {isa = PBXFileReference; lastKnownFileType = file; name = actionWidget.png; path = Resources/actionWidget.png; sourceTree = SOURCE_ROOT; }; 
    653                 1CBB23CE04EFE233000001C8 /* actionWidgetPressed.png */ = {isa = PBXFileReference; lastKnownFileType = file; name = actionWidgetPressed.png; path = Resources/actionWidgetPressed.png; sourceTree = SOURCE_ROOT; }; 
     652                1CBB23CD04EFE233000001C8 /* actionWidget.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = actionWidget.png; path = Resources/actionWidget.png; sourceTree = SOURCE_ROOT; }; 
     653                1CBB23CE04EFE233000001C8 /* actionWidgetPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = actionWidgetPressed.png; path = Resources/actionWidgetPressed.png; sourceTree = SOURCE_ROOT; }; 
    654654                1CBB23D504EFE24C000001C8 /* viewAlert.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = viewAlert.png; path = Resources/viewAlert.png; sourceTree = SOURCE_ROOT; }; 
    655655                1CBB23D604EFE24C000001C8 /* viewAlertSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = viewAlertSelected.png; path = Resources/viewAlertSelected.png; sourceTree = SOURCE_ROOT; }; 
     
    29142914                        baseConfigurationReference = 1C6A13ED08666E62009EE6D2 /* Common Settings.xcconfig */; 
    29152915                        buildSettings = { 
     2916                                GCC_ENABLE_FIX_AND_CONTINUE = YES; 
    29162917                                GCC_OPTIMIZATION_LEVEL = 0; 
    29172918                                GCC_PREFIX_HEADER = Colloquy.pch; 
     
    29242925                                PRODUCT_NAME = Colloquy; 
    29252926                                WRAPPER_EXTENSION = app; 
     2927                                ZERO_LINK = YES; 
    29262928                        }; 
    29272929                        name = Development; 
  • trunk/Controllers/JVChatWindowController.m

    r3207 r3214  
    675675                [cell setEnabled:[item isEnabled]]; 
    676676        } else [cell setEnabled:YES]; 
     677 
     678        if( [item respondsToSelector:@selector( newMessagesWaiting )] ) { 
     679                [(JVDetailCell *) cell setStatusNumber:[item newMessagesWaiting]]; 
     680        } else [(JVDetailCell *) cell setStatusNumber:0]; 
     681 
     682        if( [item respondsToSelector:@selector( newHighlightMessagesWaiting )] ) { 
     683                [(JVDetailCell *) cell setImportantStatusNumber:[item newHighlightMessagesWaiting]]; 
     684        } else [(JVDetailCell *) cell setImportantStatusNumber:0]; 
    677685} 
    678686 
  • trunk/Panels/JVDirectChatPanel.m

    r3208 r3214  
    430430                return ( [_waitingAlerts count] ? [NSImage imageNamed:@"AlertCautionIcon"] : ( _newMessageCount ? ( _newHighlightMessageCount ? [NSImage imageNamed:@"privateChatTabNewMessage"] : [NSImage imageNamed:@"privateChatTabNewMessage"] ) : nil ) ); 
    431431 
    432         return ( [_waitingAlerts count] ? [NSImage imageNamed:@"viewAlert"] : ( _newMessageCount ? ( _newHighlightMessageCount ? [NSImage imageNamed:@"newHighlightMessage"] : [NSImage imageNamed:@"newMessage"] ) : nil ) ); 
     432        return ( [_waitingAlerts count] ? [NSImage imageNamed:@"viewAlert"] : nil ); 
    433433} 
    434434 
     
    448448} 
    449449 
     450- (void) willSelect { 
     451        _newMessageCount = 0; 
     452        _newHighlightMessageCount = 0; 
     453} 
     454 
    450455- (void) didSelect { 
    451456        if( ! [[NSUserDefaults standardUserDefaults] boolForKey:@"JVChatInputAutoResizes"] ) { 
     
    456461        _newHighlightMessageCount = 0; 
    457462        _isActive = YES; 
     463 
    458464        [super didSelect]; 
     465 
    459466        [_windowController reloadListItem:self andChildren:NO]; 
    460467        [[[self view] window] makeFirstResponder:send]; 
     468 
    461469        if( [_waitingAlerts count] ) 
    462470                [[NSApplication sharedApplication] beginSheet:[_waitingAlerts objectAtIndex:0] modalForWindow:[_windowController window] modalDelegate:self didEndSelector:@selector( _alertSheetDidEnd:returnCode:contextInfo: ) contextInfo:NULL]; 
  • trunk/Views/JVDetailCell.h

    r3072 r3214  
    66        NSString *_infoText; 
    77        NSLineBreakMode _lineBreakMode; 
     8        unsigned _statusNumber; 
     9        unsigned _importantStatusNumber; 
    810} 
    911- (void) setStatusImage:(NSImage *) image; 
     
    2123- (void) setLineBreakMode:(NSLineBreakMode) mode; 
    2224- (NSLineBreakMode) lineBreakMode; 
     25 
     26- (void) setStatusNumber:(unsigned) number; 
     27- (unsigned) statusNumber; 
     28 
     29- (void) setImportantStatusNumber:(unsigned) number; 
     30- (unsigned) importantStatusNumber; 
    2331@end 
  • trunk/Views/JVDetailCell.m

    r3072 r3214  
    5555#pragma mark - 
    5656 
     57- (void) setStatusNumber:(unsigned) number { 
     58        _statusNumber = number; 
     59} 
     60 
     61- (unsigned) statusNumber { 
     62        return _statusNumber; 
     63} 
     64 
     65#pragma mark - 
     66 
     67- (void) setImportantStatusNumber:(unsigned) number { 
     68        _importantStatusNumber = number; 
     69} 
     70 
     71- (unsigned) importantStatusNumber { 
     72        return _importantStatusNumber; 
     73} 
     74 
     75#pragma mark - 
     76 
    5777- (void) setHighlightedImage:(NSImage *) image { 
    5878        [_altImage autorelease]; 
     
    129149        } 
    130150 
    131         if( [self image] ) switch( [self imageScaling] ) { 
    132         case NSScaleProportionally: 
    133                 if( NSHeight( cellFrame ) < [[self image] size].height ) 
    134                         imageWidth = ( NSHeight( cellFrame ) / [[self image] size].height ) * [[self image] size].width; 
    135                 else imageWidth = [[self image] size].width; 
    136                 break; 
    137         default: 
    138         case NSScaleNone: 
    139                 imageWidth = [[self image] size].width; 
    140                 break; 
    141         case NSScaleToFit: 
    142                 imageWidth = [[self image] size].width; 
    143                 break; 
    144         } 
    145  
    146 #define JVDetailCellLabelPadding 2. 
     151        if( [self image] ) { 
     152                switch( [self imageScaling] ) { 
     153                case NSScaleProportionally: 
     154                        if( NSHeight( cellFrame ) < [[self image] size].height ) 
     155                                imageWidth = ( NSHeight( cellFrame ) / [[self image] size].height ) * [[self image] size].width; 
     156                        else imageWidth = [[self image] size].width; 
     157                        break; 
     158                default: 
     159                case NSScaleNone: 
     160                        imageWidth = [[self image] size].width; 
     161                        break; 
     162                case NSScaleToFit: 
     163                        imageWidth = [[self image] size].width; 
     164                        break; 
     165                } 
     166        } 
     167 
     168#define JVDetailCellLabelPadding 3. 
    147169#define JVDetailCellImageLabelPadding 5. 
    148 #define JVDetailCellTextLeading 2
     170#define JVDetailCellTextLeading 3
    149171#define JVDetailCellStatusImageLeftPadding 2. 
    150172#define JVDetailCellStatusImageRightPadding JVDetailCellStatusImageLeftPadding 
    151173 
     174        float statusWidth = ( _statusImage ? [_statusImage size].width + JVDetailCellStatusImageRightPadding : 0. ); 
     175        if( ! _statusImage && _statusNumber || _importantStatusNumber ) { 
     176                NSColor *textColor = [NSColor whiteColor]; 
     177                NSColor *backgroundColor = [NSColor colorWithCalibratedRed:0.5803921568627451 green:0.6705882352941176 blue:0.7882352941176471 alpha:1.]; 
     178                NSColor *importantColor = [NSColor colorWithCalibratedRed:0.831372549019608 green:0.572549019607843 blue:0.541176470588235 alpha:1.]; 
     179 
     180                if( ! _statusNumber && _importantStatusNumber ) 
     181                        backgroundColor = importantColor; 
     182 
     183                if( [self isHighlighted] ) { 
     184                        textColor = [backgroundColor shadowWithLevel:0.2]; 
     185                        backgroundColor = [backgroundColor highlightWithLevel:0.7]; 
     186                } 
     187 
     188                NSFont *font = [[NSFontManager sharedFontManager] fontWithFamily:@"Helvetica" traits:NSBoldFontMask weight:9 size:11.]; 
     189                NSMutableParagraphStyle *numberParaStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; 
     190                [numberParaStyle setAlignment:NSCenterTextAlignment]; 
     191 
     192                NSDictionary *statusNumberAttributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, numberParaStyle, NSParagraphStyleAttributeName, textColor, NSForegroundColorAttributeName, [NSNumber numberWithFloat:1.0], NSKernAttributeName, nil]; 
     193 
     194                NSString *statusText = [NSString stringWithFormat:@"%d", ( _statusNumber ? _statusNumber : _importantStatusNumber )]; 
     195                NSSize numberSize = [statusText sizeWithAttributes:statusNumberAttributes]; 
     196                statusWidth = numberSize.width + 12.; 
     197 
     198                if( imageWidth + ( imageWidth ? JVDetailCellImageLabelPadding : JVDetailCellLabelPadding ) + statusWidth < NSWidth( cellFrame ) ) { 
     199                        float radius = 8.; 
     200                        NSRect mainRect = NSMakeRect( NSMinX( cellFrame ) + NSWidth( cellFrame ) - statusWidth - 2., NSMinY( cellFrame ) + ( ( NSHeight( cellFrame ) / 2 ) - 8 ), statusWidth, 16. ); 
     201                        NSRect pathRect = NSInsetRect( mainRect, radius, radius ); 
     202 
     203                        NSBezierPath *mainPath = [NSBezierPath bezierPath]; 
     204                        [mainPath appendBezierPathWithArcWithCenter:NSMakePoint( NSMinX( pathRect ), NSMinY( pathRect ) ) radius:radius startAngle:180. endAngle:270.]; 
     205                        [mainPath appendBezierPathWithArcWithCenter:NSMakePoint( NSMaxX( pathRect ), NSMinY( pathRect ) ) radius:radius startAngle:270. endAngle:360.]; 
     206                        [mainPath appendBezierPathWithArcWithCenter:NSMakePoint( NSMaxX( pathRect ), NSMaxY( pathRect ) ) radius:radius startAngle:0. endAngle:90.]; 
     207                        [mainPath appendBezierPathWithArcWithCenter:NSMakePoint( NSMinX( pathRect ), NSMaxY( pathRect ) ) radius:radius startAngle:90. endAngle:180.]; 
     208                        [mainPath closePath]; 
     209 
     210                        if( _importantStatusNumber ) { 
     211                                NSString *importantStatusText = [NSString stringWithFormat:@"%d", _importantStatusNumber]; 
     212                                numberSize = [importantStatusText sizeWithAttributes:statusNumberAttributes]; 
     213                                float mainStatusWidth = statusWidth; 
     214                                statusWidth += numberSize.width + 10.; 
     215                                radius = 7.; 
     216 
     217                                NSRect rect = NSMakeRect( NSMinX( cellFrame ) + NSWidth( cellFrame ) - statusWidth - 2., NSMinY( cellFrame ) + ( ( NSHeight( cellFrame ) / 2 ) - 7 ), statusWidth - mainStatusWidth + 10., 14. ); 
     218                                pathRect = NSInsetRect( rect, radius, radius ); 
     219 
     220                                NSBezierPath *path = [NSBezierPath bezierPath]; 
     221                                [path appendBezierPathWithArcWithCenter:NSMakePoint( NSMinX( pathRect ), NSMinY( pathRect ) ) radius:radius startAngle:180. endAngle:270.]; 
     222                                [path appendBezierPathWithArcWithCenter:NSMakePoint( NSMaxX( pathRect ), NSMinY( pathRect ) ) radius:radius startAngle:270. endAngle:360.]; 
     223                                [path appendBezierPathWithArcWithCenter:NSMakePoint( NSMaxX( pathRect ), NSMaxY( pathRect ) ) radius:radius startAngle:0. endAngle:90.]; 
     224                                [path appendBezierPathWithArcWithCenter:NSMakePoint( NSMinX( pathRect ), NSMaxY( pathRect ) ) radius:radius startAngle:90. endAngle:180.]; 
     225                                [path closePath]; 
     226 
     227                                if( [self isHighlighted] ) [[NSColor whiteColor] set]; 
     228                                else [[NSColor colorWithCalibratedRed:0.92156862745098 green:0.231372549019608 blue:0.243137254901961 alpha:0.85] set]; 
     229                                [path fill]; 
     230 
     231                                rect.origin.x -= 3.; 
     232                                [importantStatusText drawInRect:rect withAttributes:statusNumberAttributes]; 
     233                        } 
     234 
     235                        [backgroundColor set]; 
     236                        [mainPath fill]; 
     237 
     238                        if( _importantStatusNumber ) { 
     239                                if( [self isHighlighted] ) [[NSColor colorWithCalibratedRed:0.5803921568627451 green:0.6705882352941176 blue:0.7882352941176471 alpha:1.] set]; 
     240                                else [[NSColor whiteColor] set]; 
     241 
     242                                [mainPath setLineWidth:1.25]; 
     243                                [mainPath stroke]; 
     244                        } 
     245 
     246                        mainRect.origin.y += 1.; 
     247                        [statusText drawInRect:mainRect withAttributes:statusNumberAttributes]; 
     248 
     249                        statusWidth += JVDetailCellStatusImageRightPadding + 3.; 
     250 
     251                } else statusWidth = 0.; 
     252        } 
     253 
    152254        if( ( ! [_infoText length] && [_mainText length] ) || ( ( subStringSize.height + mainStringSize.height ) >= NSHeight( cellFrame ) - 2. ) ) { 
    153255                float mainYLocation = 0.; 
     
    155257                if( NSHeight( cellFrame ) >= mainStringSize.height ) { 
    156258                        mainYLocation = NSMinY( cellFrame ) + ( NSHeight( cellFrame ) / 2 ) - ( mainStringSize.height / 2 ); 
    157                         [_mainText drawInRect:NSMakeRect( NSMinX( cellFrame ) + imageWidth + ( imageWidth ? JVDetailCellImageLabelPadding : JVDetailCellLabelPadding ), mainYLocation, NSWidth( cellFrame ) - imageWidth - ( JVDetailCellImageLabelPadding * 1. ) - ( _statusImage ? [_statusImage size].width + JVDetailCellStatusImageRightPadding : 0. ), [_mainText sizeWithAttributes:attributes].height ) withAttributes:attributes]; 
     259                        [_mainText drawInRect:NSMakeRect( NSMinX( cellFrame ) + imageWidth + ( imageWidth ? JVDetailCellImageLabelPadding : JVDetailCellLabelPadding ), mainYLocation, NSWidth( cellFrame ) - imageWidth - ( JVDetailCellImageLabelPadding * 1. ) - statusWidth, [_mainText sizeWithAttributes:attributes].height ) withAttributes:attributes]; 
    158260                } 
    159261        } else if( [_infoText length] && [_mainText length] ) { 
     
    162264                if( NSHeight( cellFrame ) >= mainStringSize.height ) { 
    163265                        mainYLocation = NSMinY( cellFrame ) + ( NSHeight( cellFrame ) / 2 ) - mainStringSize.height + ( JVDetailCellTextLeading / 2. ); 
    164                         [_mainText drawInRect:NSMakeRect( cellFrame.origin.x + imageWidth + ( imageWidth ? JVDetailCellImageLabelPadding : JVDetailCellLabelPadding ), mainYLocation, NSWidth( cellFrame ) - imageWidth - ( JVDetailCellImageLabelPadding * 1. ) - ( _statusImage ? [_statusImage size].width + JVDetailCellStatusImageRightPadding : 0. ), [_mainText sizeWithAttributes:attributes].height ) withAttributes:attributes]; 
     266                        [_mainText drawInRect:NSMakeRect( cellFrame.origin.x + imageWidth + ( imageWidth ? JVDetailCellImageLabelPadding : JVDetailCellLabelPadding ), mainYLocation, NSWidth( cellFrame ) - imageWidth - ( JVDetailCellImageLabelPadding * 1. ) - statusWidth, [_mainText sizeWithAttributes:attributes].height ) withAttributes:attributes]; 
    165267 
    166268                        subYLocation = NSMinY( cellFrame ) + ( NSHeight( cellFrame ) / 2 ) + subStringSize.height - mainStringSize.height + ( JVDetailCellTextLeading / 2. ); 
    167                         [_infoText drawInRect:NSMakeRect( NSMinX( cellFrame ) + imageWidth + ( imageWidth ? JVDetailCellImageLabelPadding : JVDetailCellLabelPadding ), subYLocation, NSWidth( cellFrame ) - imageWidth - ( JVDetailCellImageLabelPadding * 1. ) - ( _statusImage ? [_statusImage size].width + JVDetailCellStatusImageRightPadding : 0. ), [_infoText sizeWithAttributes:subAttributes].height ) withAttributes:subAttributes]; 
     269                        [_infoText drawInRect:NSMakeRect( NSMinX( cellFrame ) + imageWidth + ( imageWidth ? JVDetailCellImageLabelPadding : JVDetailCellLabelPadding ), subYLocation, NSWidth( cellFrame ) - imageWidth - ( JVDetailCellImageLabelPadding * 1. ) - statusWidth, [_infoText sizeWithAttributes:subAttributes].height ) withAttributes:subAttributes]; 
    168270                } 
    169271        } 
    170272 
    171273        if( _statusImage && NSHeight( cellFrame ) >= [_statusImage size].height ) { 
    172                 [_statusImage compositeToPoint:NSMakePoint( NSMinX( cellFrame ) + NSWidth( cellFrame ) - [_statusImage size].width - JVDetailCellStatusImageRightPadding, NSMaxY( cellFrame ) - ( ( NSHeight( cellFrame ) / 2 ) - ( [_statusImage size].height / 2 ) ) ) operation:NSCompositeSourceAtop fraction:( [self isEnabled] ? 1. : 0.5)]; 
     274                [_statusImage compositeToPoint:NSMakePoint( NSMinX( cellFrame ) + NSWidth( cellFrame ) - statusWidth, NSMaxY( cellFrame ) - ( ( NSHeight( cellFrame ) / 2 ) - ( [_statusImage size].height / 2 ) ) ) operation:NSCompositeSourceAtop fraction:( [self isEnabled] ? 1. : 0.5)]; 
    173275        } 
    174276} 
     
    190292- (NSLineBreakMode) lineBreakMode { 
    191293        return _lineBreakMode; 
     294} 
     295 
     296- (void) setStringValue:(NSString *) string { 
     297        [self setMainText:string]; 
    192298} 
    193299 
     
    203309        return _mainText; 
    204310} 
    205  
    206 - (void) setStringValue:(NSString *) string { 
    207         [self setMainText:string]; 
    208 } 
    209311@end 
  • trunk/Views/JVSideStatusView.m

    r3206 r3214  
    6464                newFrame.size.width = MIN( max, newFrame.size.width ); 
    6565        } 
    66          
     66 
    6767        [[self superview] setFrame:newFrame]; 
    6868