littlektframework / littlekt

A multiplatform WebGPU 2D game framework written in Kotlin. Build your own game engine on top.
https://littlekt.com
Apache License 2.0
321 stars 12 forks source link

Add theme related caching to `Control` nodes #165

Closed LeHaine closed 2 years ago

LeHaine commented 2 years ago

A new cache for each of the theme types (drawable, font, color, constants) have a new map collection in the Control node. This cache is populated the first time getThemeX is called.

For example:

getThemeDrawable() will return a result and then is cached in the drawableCache map. Any subsequent calls to getThemeDrawable() will first check in the drawableCache map and return a result if it exists.

When a theme owners theme changes, the theme owners and its child control nodes will all have their caches cleared.

When a theme value is overridden, any calls to getThemeX will pull from the overridden maps first and then the cache maps before searching for a theme owner / fallback value.