From 1b8d41ae815a5c12ec6f718640beb42a9657d0af Mon Sep 17 00:00:00 2001
From: NoMathExpectation <85624722+NoMathExpectation@users.noreply.github.com>
Date: Thu, 12 Mar 2026 12:53:51 +0800
Subject: [PATCH] Added docs for setting themes.
---
.../cn/rdlevel/rdkt/core/data/Easing.kt | 5 +++
.../cn/rdlevel/rdkt/core/data/action/Theme.kt | 33 +++++++++++++++++++
.../rdlevel/rdkt/core/events/SetThemeEvent.kt | 5 +++
3 files changed, 43 insertions(+)
diff --git a/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/data/Easing.kt b/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/data/Easing.kt
index 1374f0f..f2e06a2 100644
--- a/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/data/Easing.kt
+++ b/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/data/Easing.kt
@@ -3,6 +3,11 @@ package cn.rdlevel.rdkt.core.data
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
+/**
+ * The easing function to use for some animations.
+ *
+ * @see Easings.net for more details on the easing functions.
+ */
@Serializable
public enum class Easing {
@SerialName("Linear")
diff --git a/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/data/action/Theme.kt b/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/data/action/Theme.kt
index 077389c..76e3f8a 100644
--- a/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/data/action/Theme.kt
+++ b/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/data/action/Theme.kt
@@ -12,6 +12,9 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonClassDiscriminator
import kotlinx.serialization.json.JsonIgnoreUnknownKeys
+/**
+ * Themes that can be used to set theme in [SetThemeEvent][cn.rdlevel.rdkt.core.events.SetThemeEvent].
+ */
@OptIn(ExperimentalSerializationApi::class)
@Serializable
@JsonClassDiscriminator("preset")
@@ -353,19 +356,49 @@ public sealed interface Theme {
public class ProceduralTree : AbstractTheme()
}
+/**
+ * A theme that has variants.
+ *
+ * @property variant The variant of the theme.
+ */
public sealed interface VariedTheme> : Theme {
public var variant: E
}
+/**
+ * A theme that can have its position adjusted.
+ */
public sealed interface PositionedTheme : Theme {
+ /**
+ * Whether to enable position adjustment for the theme. If false, the position of the theme will be default or unchanged.
+ */
public var enablePosition: Boolean
+ /**
+ * The valid range for the [positionX].
+ */
public val positionXRange: ClosedFloatingPointRange
+ /**
+ * The X position of the theme pixels. The default position is 0.
+ * The valid range depends on the theme, and should be within [positionXRange].
+ *
+ * Will be ignored if [enablePosition] is false.
+ */
public var positionX: Double
+ /**
+ * The duration of the position change animation in beats.
+ *
+ * Will be ignored if [enablePosition] is false.
+ */
public var positionDuration: Double
+ /**
+ * The easing function for the position change animation.
+ *
+ * Will be ignored if [enablePosition] is false.
+ */
public var positionEase: Easing
}
diff --git a/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/events/SetThemeEvent.kt b/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/events/SetThemeEvent.kt
index 493605a..e7c784a 100644
--- a/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/events/SetThemeEvent.kt
+++ b/core/src/commonMain/kotlin/cn/rdlevel/rdkt/core/events/SetThemeEvent.kt
@@ -11,6 +11,11 @@ import cn.rdlevel.rdkt.core.serialization.Flatten
import cn.rdlevel.rdkt.core.serialization.flatten
import kotlinx.serialization.*
+/**
+ * Sets the theme for the selected rooms.
+ *
+ * @property theme The theme to set.
+ */
@OptIn(ExperimentalSerializationApi::class)
@Serializable(SetThemeEvent.Serializer::class)
@KeepGeneratedSerializer