I can’t seem to get our new .svg cursors to load in our plugin. It worked fine when using .png files, but this code fails now that we switched to .svgs:
juce::Image image = juce::ImageCache::getFromMemory( BinaryData::AdjustNote_svg, BinaryData::AdjustNote_svgSize );
return new juce::MouseCursor( image, hitX, hitY );
The image object is always null. I know the data is there in the Binary Data, as it compiles are those symbols (BinaryData::AdjustNote_svg and BinaryData::AdjustNote_svgSize) resolve properly.
Is there an extra intermediate step or something I need to load SVGs instead of PNGs when making custom cursors?
Guessing completely here, but do I have to somehow render the svg into an Image before creating a cursor for it? Our goal is to have cursors that are no longer just 16x16 pixellated bitmaps, but more modern, smooth cursors. Not sure if this is the way to approach that or not. Is there a better way? Just use larger png images, so that they scale down (somehow)? Or…?
This code seems to work, but I don’t know if this is the best way to do it or not.
juce::Image img(juce::Image::ARGB, 48, 48, true);
std::unique_ptr<juce::Drawable> drawable = juce::DrawableImage::createFromImageData( cachedImgName, cachedImgSize );
if (drawable != nullptr)
return new juce::MouseCursor( img, hitX, hitY );
Part of what we want to accomplish is making the cursors to “look nicer on larger displays”, but I don’t know exactly what that means. How are people making custom cursors like this?
I tried just using .pngs that are larger, but they just show up as larger. They don’t automatically scale down or anything. And I don’t see any look&feel code that allows for scaling them when drawing. Really kind of lost here.
I think you should look at the
MouseCursor constructor that takes a
ScaledImage instead of a regular
IIRC, that constructor was added specifically to support HiDPI displays
Are there any examples of using that anywhere? Or for using .svgs? Or for making and using custom cursors in the first place? The header files don’t give any real information as to how to create and use these objects.
This code seems to work for (.png) images that are 3x the original (16x16) size. I don’t have a separate 4k monitor to test it with, but it seems to be creating the cursors I need properly as far as I can tell.
juce::Image img = juce::ImageCache::getFromMemory( cachedImgName, cachedImgSize );
return new juce::MouseCursor(scimg,juce::Point<int>(hitX,hitY));