Commits

Anonymous committed 40be6e0

Anchored button & pop up button - fixed bug where certain images would draw upside-down

Comments (0)

Files changed (2)

BWAnchoredButtonCell.m

 		drawPoint.x = roundf(drawPoint.x);
 		drawPoint.y = roundf(drawPoint.y);
 		
+		NSAffineTransform* xform = [NSAffineTransform transform];
+		[xform translateXBy:0.0 yBy:cellFrame.size.height];
+		[xform scaleXBy:1.0 yBy:-1.0];
+		[xform concat];
+		
 		if ([image isTemplate])
 		{
 			NSImage *glyphImage = [image tintedImageWithColor:imageColor];
 			NSPoint shadowPoint = drawPoint;
 			shadowPoint.y--;
 			
-			NSAffineTransform* xform = [NSAffineTransform transform];
-			[xform translateXBy:0.0 yBy:cellFrame.size.height];
-			[xform scaleXBy:1.0 yBy:-1.0];
-			[xform concat];
-			
 			[shadowImage drawAtPoint:shadowPoint fromRect:sourceRect operation:NSCompositeSourceOver fraction:1];		
 			
 			if ([self isEnabled])

BWAnchoredPopUpButtonCell.m

 		
 		drawPoint.x = IMAGE_INSET;
 		
+		NSAffineTransform* transform = [NSAffineTransform transform];
+		[transform translateXBy:0.0 yBy:cellFrame.size.height];
+		[transform scaleXBy:1.0 yBy:-1.0];
+		[transform concat];
+		
 		if ([image isTemplate])
 		{
 			NSImage *glyphImage = [image tintedImageWithColor:imageColor];
 			NSPoint shadowPoint = drawPoint;
 			shadowPoint.y--;
 			
-			NSAffineTransform* transform = [NSAffineTransform transform];
-			[transform translateXBy:0.0 yBy:cellFrame.size.height];
-			[transform scaleXBy:1.0 yBy:-1.0];
-			[transform concat];
-			
 			[shadowImage drawAtPoint:shadowPoint fromRect:sourceRect operation:NSCompositeSourceOver fraction:1];		
 			
 			if ([self isEnabled])
 				[image drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1];
 			else
 				[image drawAtPoint:drawPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:0.5];
+			
+			// Run the flip transform again so the arrow doesn't draw upside-down
+			NSAffineTransform* transform = [NSAffineTransform transform];
+			[transform translateXBy:0.0 yBy:cellFrame.size.height];
+			[transform scaleXBy:1.0 yBy:-1.0];
+			[transform concat];
 		}
 	}
 }