You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should implement the official darklaf-compliant icon loading procedure for utiLITI.
In this discussion, Jannis has suggested a better way to load our icons for different themes:
From what I can see you only differentiate between light and dark icons (correct me if I am wrong here). In this case there is a simple mechanism build into darklaf to handle different icons. Here are some possible approaches:
* Using the `IconLoader`:
For this you will need change up your folder structure as light/dark resource paths are handled differently in darklaf. Instead of using a suffix a folder prefix is used, so `some/path/icon_dark.png` and `some/path/icon_light.png` become `dark/some/path/icon.png` and `light/some/path/icon.png`.
```java
Icon icon = IconLoader.get(resourceClass).getUIAwareIcon(path, width, height);
// Here resourceClass is the class to which the icons will be resolved. In your case this can be null or simply IconLoader.get() with no argument.
// The path is relative to the light/, dark/ folders.
```
* Using `DarkUIAwareIcon`:
This is basically the implementation used by the `IconLoader` but you have more control over the resource path.
```java
Icon icon = new DarkUIAwareIcon(dark_icon_path, light_icon_path, resourceClass, width, height);
// Again resourceClass can be null in your case
```
DarkUIAwareIcon holds a reference the the current AwareIconStyle which is managed by the IconLader. When a darklaf theme is loaded it sets this key appropriately. Both versions above the icons will be loaded lazily as needed. As long as you load .png files (or any other image based file) the width and height parameters will actually have no effect as they are only a suggestion.
If you want to be independent of darklaf in terms of when which icon is used you can (with the next release of darklaf) subclass DarkUIAwareIcon:
We should implement the official darklaf-compliant icon loading procedure for utiLITI.
In this discussion, Jannis has suggested a better way to load our icons for different themes:
The text was updated successfully, but these errors were encountered: