Adium

Changeset 14837

Show
Ignore:
Timestamp:
01/08/2006 07:44:24 PM (3 years ago)
Author:
boredzo
Message:

Got the arrow drawing correctly in both directions. Fixes #2300.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/Adium Framework/ESFileTransfer.m

    r14274 r14837  
    2121static NSBezierPath *arrowPath = nil; 
    2222 
     23#define MAGIC_ARROW_SCALE       0.85 
     24#define MAGIC_ARROW_TRANSLATE_X 2.85 
     25#define MAGIC_ARROW_TRANSLATE_Y 0.75 
     26 
    2327@implementation ESFileTransfer 
    2428//Init 
     
    268272} 
    269273 
    270 - (NSBezierPath *)arrowPathInSize:(NSSize)arrowSize pointingDown:(BOOL)pointItDown 
     274- (NSBezierPath *)arrowPathInSize:(NSSize)arrowSize pointingDown:(BOOL)pointItDown shaftLengthMultiplier:(float)shaftLengthMulti 
    271275{ 
    272276        if(!arrowPath) { 
     
    284288#               define TWO_THIRDS (2.0/3.0) 
    285289#               define ONE_HALF    0.5 
     290                const float shaftLength = ONE_HALF * shaftLengthMulti; 
     291                const float shaftEndY = -(shaftLength - ONE_HALF); //the end of the arrow shaft (points 1-2). 
    286292 
    287293                //start with the bottom vertex. 
    288                 [arrowPath moveToPoint:NSMakePoint(ONE_THIRD,  0.0)]; //1 
    289                 [arrowPath lineToPoint:NSMakePoint(TWO_THIRDS, 0.0)]; //2 
     294                [arrowPath moveToPoint:NSMakePoint(ONE_THIRD,  shaftEndY)]; //1 
     295                [arrowPath lineToPoint:NSMakePoint(TWO_THIRDS, shaftEndY)]; //2 
    290296                //up to the inner right corner. 
    291                 [arrowPath relativeLineToPoint:NSMakePoint(0.0, ONE_HALF)]; //3 
     297                [arrowPath relativeLineToPoint:NSMakePoint(0.0, shaftLength)]; //3 
    292298                //far right. 
    293299                [arrowPath relativeLineToPoint:NSMakePoint(ONE_THIRD,  0.0)]; //4 
     
    323329} 
    324330 
     331- (NSBezierPath *)arrowPathInSize:(NSSize)arrowSize pointingDown:(BOOL)pointItDown 
     332{ 
     333        return [self arrowPathInSize:arrowSize pointingDown:pointItDown shaftLengthMultiplier:1.0f]; 
     334} 
     335 
    325336- (NSImage *)iconImage 
    326337{ 
     
    368379                //and the arrow on top of it. 
    369380                if(drawArrow) { 
    370                         NSBezierPath *arrow = [self arrowPathInSize:bottomRight.size pointingDown:pointingDown]; 
     381                        NSBezierPath *arrow = [self arrowPathInSize:bottomRight.size pointingDown:pointingDown shaftLengthMultiplier:5.0f]; 
    371382 
    372383                        //bring it into position. 
     
    375386                        [arrow transformUsingAffineTransform:transform]; 
    376387 
    377                         NSLog(@"arrow bounds (after): %@", NSStringFromRect([arrow bounds])); 
     388                        //fine-tune size. 
     389                        transform = [NSAffineTransform transform]; 
     390                        [transform scaleBy:MAGIC_ARROW_SCALE]; 
     391                        [arrow transformUsingAffineTransform:transform]; 
     392 
     393                        //fine-tune position. 
     394                        transform = [NSAffineTransform transform]; 
     395                        [transform translateXBy:MAGIC_ARROW_TRANSLATE_X yBy:MAGIC_ARROW_TRANSLATE_Y]; 
     396                        [arrow transformUsingAffineTransform:transform]; 
     397 
     398                        [circle addClip]; 
    378399                        [[NSColor alternateSelectedControlColor] setFill]; 
    379400                        [arrow fill];