Get ExampleProject compiling with the TUIImage changes
This commit is contained in:
@@ -67,14 +67,17 @@
|
||||
CGRect b = v.bounds;
|
||||
CGContextRef ctx = TUIGraphicsGetCurrentContext();
|
||||
|
||||
TUIImage *image = [TUIImage imageNamed:@"clock.png" cache:YES];
|
||||
NSImage *image = [NSImage imageNamed:@"clock.png"];
|
||||
CGRect imageRect = ABIntegralRectWithSizeCenteredInRect([image size], b);
|
||||
|
||||
if([v.nsView isTrackingSubviewOfView:v]) { // simple way to check if the mouse is currently down inside of 'v'. See the other methods in TUINSView for more.
|
||||
|
||||
// first draw a slight white emboss below
|
||||
CGContextSaveGState(ctx);
|
||||
CGContextClipToMask(ctx, CGRectOffset(imageRect, 0, -1), image.CGImage);
|
||||
|
||||
CGImageRef cgImage = [image CGImageForProposedRect:&imageRect context:nil hints:nil];
|
||||
CGContextClipToMask(ctx, CGRectOffset(imageRect, 0, -1), cgImage);
|
||||
|
||||
CGContextSetRGBFillColor(ctx, 1, 1, 1, 0.5);
|
||||
CGContextFillRect(ctx, b);
|
||||
CGContextRestoreGState(ctx);
|
||||
@@ -82,6 +85,9 @@
|
||||
// replace image with a dynamically generated fancy inset image
|
||||
// 1. use the image as a mask to draw a blue gradient
|
||||
// 2. generate an inner shadow image based on the mask, then overlay that on top
|
||||
|
||||
// TODO: Refactor this to use NSImage.
|
||||
#if 0
|
||||
image = [TUIImage imageWithSize:imageRect.size drawing:^(CGContextRef ctx) {
|
||||
CGRect r;
|
||||
r.origin = CGPointZero;
|
||||
@@ -93,9 +99,10 @@
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeOverlay);
|
||||
CGContextDrawImage(ctx, r, innerShadow.CGImage);
|
||||
}];
|
||||
#endif
|
||||
}
|
||||
|
||||
[image drawInRect:imageRect]; // draw 'image' (might be the regular one, or the dynamically generated one)
|
||||
[image drawInRect:imageRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; // draw 'image' (might be the regular one, or the dynamically generated one)
|
||||
|
||||
// draw the index
|
||||
TUIAttributedString *s = [TUIAttributedString stringWithString:[NSString stringWithFormat:@"%ld", v.tag]];
|
||||
|
||||
Reference in New Issue
Block a user