mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 21:27:56 -05:00
fixup! Incorporated scalable icons.
Implemented proper alignment of the icons with the line number font.
This commit is contained in:
committed by
Allan Odgaard
parent
73ff758a52
commit
007e498a02
@@ -343,8 +343,11 @@ static void DrawText (std::string const& text, CGRect const& rect, CGFloat basel
|
||||
NSImage* image = [self imageForColumn:dataSource->identifier atLine:record.lineNumber hovering:isHoveringRect && NSEqualPoints(mouseDownAtPoint, NSMakePoint(-1, -1)) pressed:isHoveringRect && isDownInRect];
|
||||
if([image size].height > 0 && [image size].width > 0)
|
||||
{
|
||||
CGFloat x = round((NSWidth(columnRect) - [image size].width) / 2);
|
||||
CGFloat y = round((NSHeight(columnRect) - [image size].height) / 2);
|
||||
// The placement of the center of image is aligned with the center of the capHeight.
|
||||
CGFloat center = record.baseline - ([self.lineNumberFont capHeight] / 2);
|
||||
|
||||
CGFloat x = round((NSWidth(columnRect) - [image size].width) / 2);
|
||||
CGFloat y = round(center - ([image size].height / 2));
|
||||
|
||||
NSImage* overlayImage = [[[NSImage alloc] initWithSize:[image size]] autorelease];
|
||||
|
||||
|
||||
@@ -173,9 +173,21 @@ private:
|
||||
{
|
||||
if(NSImage* res = [[[NSImage imageNamed:aName inSameBundleAsClass:[self class]] copy] autorelease])
|
||||
{
|
||||
CGFloat height = [gutterView.lineNumberFont xHeight] * ([aName hasPrefix:@"Bookmark"] ? 1.125 : 1.5);
|
||||
// We use capHeight instead of x-height since most fonts have the numbers
|
||||
// extend to this height, so centering around the x-height would look off
|
||||
CGFloat height = [gutterView.lineNumberFont capHeight];
|
||||
CGFloat width = [res size].width * height / [res size].height;
|
||||
[res setSize:NSMakeSize(round(width), round(height))];
|
||||
|
||||
CGFloat scaleFactor = 1.0;
|
||||
|
||||
// Since all images are vector based and don’t contain any spacing to
|
||||
// align it, we need to set the individual scaleFactor per image.
|
||||
if([aName hasPrefix:@"Bookmark"]) scaleFactor = 1.0;
|
||||
if([aName hasPrefix:@"Folding"]) scaleFactor = 1.2;
|
||||
if([aName hasPrefix:@"Search"]) scaleFactor = 1.2;
|
||||
|
||||
[res setSize:NSMakeSize(round(width * scaleFactor), round(height * scaleFactor))];
|
||||
|
||||
return res;
|
||||
}
|
||||
NSLog(@"%s no image named ‘%@’", sel_getName(_cmd), aName);
|
||||
|
||||
Reference in New Issue
Block a user