-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 242 icon loading by providing new key-based API #430
Conversation
This gradle task generates the icon keys for the platform icons that we'll need to load icons from a key instead of a path.
To reduce dependency on IntelliJ platform, maybe current composition context (or something better) could hold something like IconProvider, which can resolve icon by id? Then when used as IJ plugin, it could use IntelliJIconKey.fromPlatformIcon as the IconProvider and in case of desktop jewel, it can use any kind of resource based thing, or it can be even customizable. The Icon api would then accept this id, maybe it can be even same, but we can make the Icon class nullable, to indicate it should be automatically resolved. interface IconProvider {
fun getIconByKey(key: string): ResourcePainter? // or maybe just Painter?
} |
That was an earlier iteration on the design, but it depends on having IJP classes on the classpath (e.g., |
5055272
to
aa0e207
Compare
* Made icon generation more maintainable * Cleanup code * Fix ktlint implicitly trying to check generated code --------- Co-authored-by: Sebastiano Poggi <sebp@google.com>
Out of date, he provided the fix he wanted
* Implement icon keys generator This gradle task generates the icon keys for the platform icons that we'll need to load icons from a key instead of a path. * Define IconIdInterpreter and NewUiChecker * Do icon key generation for AllIcons in ui module * Implement proper key-based icon loading * Remove old TODO and unused code * Undo change to run config * Rename AllIcons to PlatformIcon, move to its own file * Remove unnecessary suppression * Run apiDump * Made icon generation more maintainable (#432) * Made icon generation more maintainable * Cleanup code * Fix ktlint implicitly trying to check generated code --------- Co-authored-by: Sebastiano Poggi <sebp@google.com> --------- Co-authored-by: Lamberto Basti <basti.lamberto@gmail.com>
In IJP 242 the icon loading has changed yet again. Instead of relying on icon mappings like it used to, now New UI icon paths are hardcoded into the
CachedImageIcon
themselves. This breaks Jewel's ability to load New UI icons, resulting in old UI icons being shown instead.With this PR, we set to address this issue, and design an API that improves upon the existing ones. We have created the new
IconKey
, that encapsulates an icon resource path in a better typed and fully portable way allowing the same code to be used both in standalone and in bridge mode.We have a new generation task in the
ui
module that traverses anAllIcons
-style class and an icon mappings json file (likePlatfomIconMappings.json
), and creates an icon keys file with the same structure. These keys are then used to look up icons, simplifying the code. This mechanism should work for 233 and 241 as well, since it bypasses the need for relying on the platform icon mapping, until we get better APIs, hopefully soon.The
Icon
composable now acceptsPainterHint
s and uses them when rendering the icons, too.What used to look like this:
Now looks like this:
Applying hints to
Icon
s andPlatformIcon
s is also much easier now. It was:And now is:
The sample code has been partially updated to the new API, but more work is needed to spread the change throughout existing components and their styling. That will come in a follow-up PR.