hidpi/dark images in Plugins

Oxygen general issues.
patrick
Posts: 96
Joined: Mon May 09, 2011 11:54 am

hidpi/dark images in Plugins

Post by patrick »

Hi,

how to use images/icons in plugins that automatically will be changed in hidpi/dark settings?

Best regards,
Patrick
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: hidpi/dark images in Plugins

Post by Radu »

Hi Patrick,

So let's say your plugin adds a new toolbar button with your custom image.
Somewhere in an "images" folder you have an image called let's say myImage.png which you currently use for that button.
Besides that image in the same folder you should have another image called myImagee@2x.png which should be twice as large as the original image (both vertically and horizontally). This image will be used for Mac Retina displays for example.
And you should also create and have in the same folder the equivalent images to be used for the dark themes: myImage_dark.png and myImage_dark@2x.png.

Then you can use our API ro.sync.ui.Icons.getIcon(String iconKey). The icon key should be an URL pointing to the original image myImage.png. Depending on whether Oxygen is running in retina display with or without dark theme, the API will load either the original image or one of the other images located in the same place.
If you do not want to manually create the dark image, we have an API which would allow you to check if Oxygen is running in dark mode:

WorkspaceUtilities.getColorTheme()

and we also have an image inverter API:

WorkspaceUtilities.getImageInverter()

but for supporting hidpi you will need to create the larger icon by yourself.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9055
Joined: Fri Jul 09, 2004 5:18 pm

Re: hidpi/dark images in Plugins

Post by Radu »

One more thing:

A similar procedure is done if you have a framework and use in the CSS various icons:

https://www.oxygenxml.com/doc/versions/ ... mages.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply