net.kernelpanicsoft.archie.gui.theme¶
Types¶
ComposableTheme¶
@Serializable
data class ComposableTheme(
val isNineslice: Boolean = false,
val states: Map<String, ThemeState>,
val variants: Map<String, StatefulTheme> = emptyMap(),
val minSize: Size? = null,
val contentPadding: ThemePadding? = null
)
The full theme definition for a single composable type (e.g. button, slot).
RawComposableTheme¶
@Serializable
data class RawComposableTheme(
val states: Map<String, RawThemeState> = emptyMap(),
val variants: Map<String, Map<String, RawThemeState>> = emptyMap(),
val minSize: Size? = null,
val contentPadding: ThemePadding? = null
)
Raw JSON shape of a theme file, deserialized as-is and resolved by ThemeResourceListener into a ComposableTheme.
RawThemeState¶
@Serializable
data class RawThemeState(
val texture: String? = null,
val textureSize: Size? = null,
val u: Int? = null,
val v: Int? = null,
val width: Int? = null,
val height: Int? = null,
val uWidthSnake: Int? = null,
val vHeightSnake: Int? = null,
val uWidth: Int? = null,
val vHeight: Int? = null
)
Raw JSON shape of a single theme state; fields left null inherit from the state's "default" entry.
SimpleThemeState¶
@Serializable
data class SimpleThemeState(
val texture: SResourceLocation,
val textureSize: Size,
val u: Int = 0,
val v: Int = 0,
val width: Int,
val height: Int,
val uWidth: Int,
val vHeight: Int
) : ThemeState
A fixed-size sprite slice within a sprite atlas or source image.
StatefulTheme¶
@Serializable
data class StatefulTheme(val states: Map<String, ThemeState>)
A map of state-name → ThemeState for a single variant of a composable.
ThemeData¶
Immutable data holder describing the active theme context for composables.
ThemeManifest¶
Resource-pack-defined metadata for a theme (namespace + type), declaring which variant names are valid and how requested modes should resolve to them.
ThemeManifestResourceListener¶
class ThemeManifestResourceListener : SerializationReloadListener<ThemeManifest> , PreparableReloadListener
Loads *.theme.json ThemeManifest resources from the archie_themes directory on resource pack reload, keyed by their resource location.
ThemePadding¶
Inner spacing a composable using a theme should reserve around its own content, so e.g. a button's label never renders flush against the button's edges once it grows past ComposableTheme.minSize to fit a longer label.
ThemeResourceListener¶
class ThemeResourceListener : SerializationReloadListener<RawComposableTheme> , PreparableReloadListener
A client resource-reload listener that loads ComposableTheme definitions from assets/<namespace>/archie_themes/ directories in resource packs.
ThemeState¶
@Serializable
sealed interface ThemeState
Sealed base for composable theme states rendered as sprites.
ThemeVariants¶
object ThemeVariants
Constants for the built-in theme variant names.
Properties¶
LocalTheme¶
val LocalTheme: ProvidableCompositionLocal<ThemeData>
Provides the current ThemeData to composables in the tree.
Functions¶
composableThemeLocation¶
inline fun composableThemeLocation(
namespace: String,
type: String,
composable: String
): ResourceLocation
Builds the ResourceLocation used to look up a composable's default-variant theme definition.
inline fun composableThemeLocation(
namespace: String,
type: String,
mode: String,
composable: String
): ResourceLocation
Builds the ResourceLocation used to look up a composable's theme definition for a specific non-default mode (variant).
Theme¶
Sets the active theme using a pre-built ThemeData.