Utility for generating the theme based on theme definition file. It also provides macro functions to improve the theme workflow.
Static methods
staticgetFont():Dynamic
Macro to inject the code that will output the current font of the element that's calling this macro.
It is important to first load all font assets before they can get accessed!
// In your code:
g.font = ThemeUtil.getFont();
// Compiles to:
g.font = kha.Assets.fonts.get(style.font.family);
Important: Use this macro on sub-classes of Element
only, otherwise
it will fail. Using it in static functions also does not work!
Returns:
The expression that is injected into the code
staticrequireOptGroups(groups:Dynamic):Dynamic
This macro is used internally by elements to ensure that required optional groups exist.
If there is a definition like the following in the theme file:
?optionalGroup:
value1: Int
value2: Bool
and an element requires that group, it calls
ThemeUtil.requireOptGroups(["optionalGroup"]);
.
For nested groups, write out the path like group.subgroup
.
If any of the groups does not exist for the current tID
, an exception
is thrown.
This macro must not be called outside of Element.onTIDChange()
,
otherwise an exception is thrown.