mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Use NSImage’s respectFlipped: parameter instead of custom code
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
@interface NSImage (ImageFromBundle)
|
||||
+ (NSImage*)imageNamed:(NSString*)aName inSameBundleAsClass:(id)anObject;
|
||||
|
||||
- (void)drawAdjustedAtPoint:(NSPoint)aPoint fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta;
|
||||
- (void)drawAdjustedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta;
|
||||
@end
|
||||
|
||||
@@ -21,36 +21,4 @@
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
// ===================================================
|
||||
// = Gracefully draw in potentially flipped contexts =
|
||||
// ===================================================
|
||||
|
||||
- (void)drawAdjustedAtPoint:(NSPoint)aPoint fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta
|
||||
{
|
||||
[self drawAdjustedInRect:(NSRect){ aPoint, [self size] } fromRect:srcRect operation:op fraction:delta];
|
||||
}
|
||||
|
||||
- (void)drawAdjustedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta
|
||||
{
|
||||
NSGraphicsContext* context = [NSGraphicsContext currentContext];
|
||||
if([context isFlipped])
|
||||
{
|
||||
[context saveGraphicsState];
|
||||
|
||||
NSAffineTransform* transform = [NSAffineTransform transform];
|
||||
[transform translateXBy:0 yBy:NSMaxY(dstRect)];
|
||||
[transform scaleXBy:1 yBy:-1];
|
||||
[transform concat];
|
||||
|
||||
dstRect.origin.y = 0; // The transform above places the y-origin right where the image should be drawn.
|
||||
[self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
|
||||
|
||||
[context restoreGraphicsState];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];
|
||||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#import "OakImageAndTextCell.h"
|
||||
#import "NSImage Additions.h"
|
||||
|
||||
@implementation OakImageAndTextCell
|
||||
{
|
||||
@@ -62,7 +61,7 @@
|
||||
[[self backgroundColor] set];
|
||||
NSRectFill(imageRect);
|
||||
}
|
||||
[self.image drawAdjustedInRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
|
||||
[self.image drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil];
|
||||
}
|
||||
|
||||
[super drawWithFrame:[self textFrameWithFrame:cellFrame inControlView:controlView] inView:controlView];
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#import "OakPopOutAnimation.h"
|
||||
#import "NSImage Additions.h"
|
||||
#import <oak/algorithm.h>
|
||||
#import <oak/debug.h>
|
||||
|
||||
@@ -128,7 +127,7 @@ static double bounce_curve (double t)
|
||||
[[NSColor whiteColor] set];
|
||||
[roundedRect stroke];
|
||||
|
||||
[self.contentImage drawAdjustedInRect:NSInsetRect([self bounds], kExtendWidth, kExtendHeight) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
|
||||
[self.contentImage drawInRect:NSInsetRect([self bounds], kExtendWidth, kExtendHeight) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1 respectFlipped:YES hints:nil];
|
||||
|
||||
[super drawRect:aRect];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user