mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Add support for retina mouse cursors on OS X
This commit is contained in:
parent
5f748bb7a0
commit
6d56e488dc
2 changed files with 11 additions and 12 deletions
|
|
@ -27,25 +27,24 @@
|
|||
//==============================================================================
|
||||
namespace MouseCursorHelpers
|
||||
{
|
||||
NSImage* createNSImage (const Image&);
|
||||
NSImage* createNSImage (const Image& image)
|
||||
NSImage* createNSImage (const Image&, float scaleFactor = 1.f);
|
||||
NSImage* createNSImage (const Image& image, float scaleFactor)
|
||||
{
|
||||
JUCE_AUTORELEASEPOOL
|
||||
{
|
||||
NSImage* im = [[NSImage alloc] init];
|
||||
[im setSize: NSMakeSize (image.getWidth(), image.getHeight())];
|
||||
[im lockFocus];
|
||||
const NSSize requiredSize = NSMakeSize (image.getWidth() / scaleFactor, image.getHeight() / scaleFactor);
|
||||
|
||||
[im setSize: requiredSize];
|
||||
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
|
||||
CGImageRef imageRef = juce_createCoreGraphicsImage (image, colourSpace, false);
|
||||
CGImageRef imageRef = juce_createCoreGraphicsImage (image, colourSpace, true);
|
||||
CGColorSpaceRelease (colourSpace);
|
||||
|
||||
CGContextRef cg = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];
|
||||
CGContextDrawImage (cg, convertToCGRect (image.getBounds()), imageRef);
|
||||
|
||||
NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithCGImage: imageRef];
|
||||
[imageRep setSize: requiredSize];
|
||||
[im addRepresentation: imageRep];
|
||||
[imageRep release];
|
||||
CGImageRelease (imageRef);
|
||||
[im unlockFocus];
|
||||
|
||||
return im;
|
||||
}
|
||||
}
|
||||
|
|
@ -104,7 +103,7 @@ namespace MouseCursorHelpers
|
|||
|
||||
void* CustomMouseCursorInfo::create() const
|
||||
{
|
||||
return MouseCursorHelpers::fromNSImage (MouseCursorHelpers::createNSImage (image),
|
||||
return MouseCursorHelpers::fromNSImage (MouseCursorHelpers::createNSImage (image, scaleFactor),
|
||||
NSMakePoint (hotspot.x, hotspot.y));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
namespace MouseCursorHelpers
|
||||
{
|
||||
extern NSImage* createNSImage (const Image&);
|
||||
extern NSImage* createNSImage (const Image&, float scaleFactor = 1.f);
|
||||
}
|
||||
|
||||
extern NSMenu* createNSMenu (const PopupMenu&, const String& name, int topLevelMenuId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue