Skip to content

Commit fac6c7b

Browse files
committed
More renaming of *Editor variables to mutable*.
1 parent 4092ece commit fac6c7b

File tree

9 files changed

+41
-41
lines changed

9 files changed

+41
-41
lines changed

src/commonMain/kotlin/baaahs/ShowState.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ data class ShowState(
2626
return show.scenes[selectedScene]
2727
}
2828

29-
fun findSceneEditor(showEditor: MutableShow?): MutableShow.MutableScene? {
29+
fun findMutableScene(mutableShow: MutableShow?): MutableShow.MutableScene? {
3030
if (selectedScene == -1) return null
31-
return showEditor?.getSceneEditor(selectedScene)
31+
return mutableShow?.getMutableScene(selectedScene)
3232
}
3333

3434
fun findPatchSet(show: OpenShow): OpenShow.OpenScene.OpenPatchSet? {
@@ -50,11 +50,11 @@ data class ShowState(
5050
return scene.patchSets[selectedPatchSet]
5151
}
5252

53-
fun findPatchSetEditor(showEditor: MutableShow?): MutableShow.MutableScene.MutablePatchSet? {
53+
fun findMutablePatchSet(mutableShow: MutableShow?): MutableShow.MutableScene.MutablePatchSet? {
5454
if (selectedPatchSet == -1) return null
5555

56-
val sceneEditor = findSceneEditor(showEditor)
57-
return sceneEditor?.getPatchSetEditor(selectedPatchSet)
56+
val mutableScene = findMutableScene(mutableShow)
57+
return mutableScene?.getMutablePatchSet(selectedPatchSet)
5858
}
5959

6060
fun selectScene(i: Int) = copy(selectedScene = i)

src/commonMain/kotlin/baaahs/glshaders/AutoWirer.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AutoWirer(val plugins: Plugins) {
4242
)
4343

4444
locallyAvailable.getOrPut(openShader.outputPort.contentType) { mutableSetOf() }
45-
.add(UnresolvedShaderOutPortEditor(unresolvedShaderInstance, openShader.outputPort.id))
45+
.add(UnresolvedShaderOutPort(unresolvedShaderInstance, openShader.outputPort.id))
4646

4747
openShader.shaderType.defaultUpstreams.forEach { (contentType, shaderChannel) ->
4848
locallyAvailable.getOrPut(contentType) { mutableSetOf() }
@@ -74,7 +74,7 @@ class AutoWirer(val plugins: Plugins) {
7474
return UnresolvedPatch(unresolvedShaderInstances, dataSources.toList())
7575
}
7676

77-
data class UnresolvedShaderOutPortEditor(
77+
data class UnresolvedShaderOutPort(
7878
val unresolvedShaderInstance: UnresolvedShaderInstance,
7979
val portId: String
8080
) : MutableLink.Port {
@@ -261,7 +261,7 @@ class AutoWirer(val plugins: Plugins) {
261261
// Second pass: resolve references between shaders to the correct instance editor.
262262
shaderInstances.values.forEach { shaderInstance ->
263263
shaderInstance.incomingLinks.forEach { (toPortId, fromPort) ->
264-
if (fromPort is UnresolvedShaderOutPortEditor) {
264+
if (fromPort is UnresolvedShaderOutPort) {
265265
val fromShader = fromPort.unresolvedShaderInstance.mutableShader.shader
266266
val fromShaderInstance = shaderInstances[fromShader]
267267
?: error(unknown("shader instance editor", fromShader, shaderInstances.keys))

src/commonMain/kotlin/baaahs/show/PortRef.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import kotlinx.serialization.Serializable
77

88
@Serializable
99
sealed class PortRef {
10-
abstract fun dereference(showEditor: MutableShow): MutableLink.Port
10+
abstract fun dereference(mutableShow: MutableShow): MutableLink.Port
1111
}
1212

1313
@Serializable @SerialName("datasource")
1414
data class DataSourceRef(val dataSourceId: String) : PortRef() {
15-
override fun dereference(showEditor: MutableShow): MutableLink.Port =
16-
showEditor.dataSources.getBang(dataSourceId, "datasource")
15+
override fun dereference(mutableShow: MutableShow): MutableLink.Port =
16+
mutableShow.dataSources.getBang(dataSourceId, "datasource")
1717
}
1818

1919
interface ShaderPortRef {
@@ -24,9 +24,9 @@ interface ShaderPortRef {
2424
data class ShaderOutPortRef(val shaderInstanceId: String, val portId: String = ReturnValue) : PortRef() {
2525
fun isReturnValue() = portId == ReturnValue
2626

27-
override fun dereference(showEditor: MutableShow): MutableLink.Port =
27+
override fun dereference(mutableShow: MutableShow): MutableLink.Port =
2828
MutableShaderOutPort(
29-
showEditor.shaderInstances.getBang(
29+
mutableShow.shaderInstances.getBang(
3030
shaderInstanceId,
3131
"shader instance"
3232
), portId
@@ -39,12 +39,12 @@ data class ShaderOutPortRef(val shaderInstanceId: String, val portId: String = R
3939

4040
@Serializable @SerialName("shader-channel")
4141
data class ShaderChannelRef(val shaderChannel: ShaderChannel) : PortRef() {
42-
override fun dereference(showEditor: MutableShow): MutableLink.Port =
42+
override fun dereference(mutableShow: MutableShow): MutableLink.Port =
4343
MutableShaderChannel(shaderChannel)
4444
}
4545

4646
@Serializable @SerialName("output")
4747
data class OutputPortRef(val portId: String) : PortRef() {
48-
override fun dereference(showEditor: MutableShow): MutableLink.Port =
48+
override fun dereference(mutableShow: MutableShow): MutableLink.Port =
4949
MutableOutputPort(portId)
5050
}

src/commonMain/kotlin/baaahs/show/mutable/MutableShow.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ abstract class MutablePatchHolder(
1717
dataSources: Map<String, DataSource>
1818
) {
1919
abstract val displayType: String
20-
protected abstract val showEditor: MutableShow
20+
protected abstract val mutableShow: MutableShow
2121
abstract val descendents: List<MutablePatchHolder>
2222

2323
var title = basePatchHolder.title
2424

2525
val patchMappings by lazy {
26-
basePatchHolder.patches.map { MutablePatch(it, showEditor) }.toMutableList()
26+
basePatchHolder.patches.map { MutablePatch(it, mutableShow) }.toMutableList()
2727
}
2828
val eventBindings = basePatchHolder.eventBindings.toMutableList()
2929

@@ -70,7 +70,7 @@ abstract class MutablePatchHolder(
7070
).toSet()
7171

7272
fun findShaderChannels(): Set<ShaderChannel> =
73-
showEditor.collectShaderChannels()
73+
mutableShow.collectShaderChannels()
7474

7575
protected fun collectShaderChannels(): Set<ShaderChannel> =
7676
(
@@ -115,7 +115,7 @@ class MutableShow(
115115
private val baseShow: Show, baseShowState: ShowState = ShowState.Empty
116116
) : MutablePatchHolder(baseShow, baseShow.dataSources) {
117117
override val displayType: String get() = "Show"
118-
override val showEditor: MutableShow get() = this
118+
override val mutableShow: MutableShow get() = this
119119
override val descendents: List<MutablePatchHolder> get() = scenes
120120

121121
internal val dataSources = baseShow.dataSources
@@ -162,7 +162,7 @@ class MutableShow(
162162
return this
163163
}
164164

165-
fun getSceneEditor(sceneIndex: Int): MutableScene = scenes[sceneIndex]
165+
fun getMutableScene(sceneIndex: Int): MutableScene = scenes[sceneIndex]
166166

167167
fun editScene(sceneIndex: Int, block: MutableScene.() -> Unit): MutableShow {
168168
scenes[sceneIndex].apply(block)
@@ -210,7 +210,7 @@ class MutableShow(
210210

211211
inner class MutableScene(baseScene: Scene) : MutablePatchHolder(baseScene, baseShow.dataSources) {
212212
override val displayType: String get() = "Scene"
213-
override val showEditor: MutableShow get() = this@MutableShow
213+
override val mutableShow: MutableShow get() = this@MutableShow
214214
override val descendents: List<MutablePatchHolder> get() = patchSets
215215

216216
private val patchSets = baseScene.patchSets.map { MutablePatchSet(it) }.toMutableList()
@@ -234,7 +234,7 @@ class MutableShow(
234234
return this
235235
}
236236

237-
fun getPatchSetEditor(index: Int): MutablePatchSet = patchSets[index]
237+
fun getMutablePatchSet(index: Int): MutablePatchSet = patchSets[index]
238238

239239
fun editPatchSet(index: Int, block: MutablePatchSet.() -> Unit): MutableScene {
240240
patchSets[index].block()
@@ -275,7 +275,7 @@ class MutableShow(
275275
baseShow.dataSources
276276
) {
277277
override val displayType: String get() = "Patch"
278-
override val showEditor: MutableShow get() = this@MutableShow
278+
override val mutableShow: MutableShow get() = this@MutableShow
279279
override val descendents: List<MutablePatchHolder> get() = emptyList()
280280

281281
fun build(showBuilder: ShowBuilder): PatchSet {

src/commonTest/kotlin/baaahs/glshaders/PatchLayeringSpec.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ object PatchLayeringSpec : Spek({
3434
val saturationFilter by value {
3535
Shader("// Saturation Filter\nvec4 filterImage(vec4 colorIn) { return colorIn; }")
3636
}
37-
val showEditor by value { MutableShow("test show") }
37+
val mutableShow by value { MutableShow("test show") }
3838
val show by value {
39-
val show = showEditor.build(ShowBuilder())
39+
val show = mutableShow.build(ShowBuilder())
4040
ShowOpener(show, FakeShowPlayer(FakeGlslContext())).openShow()
4141
}
4242

4343
context("with a show, scene, and patchset patch") {
4444
beforeEachTest {
45-
showEditor.apply {
45+
mutableShow.apply {
4646
addPatch(autoWire(uvShader, blackShader))
4747

4848
addScene("scene") {

src/commonTest/kotlin/baaahs/show/ShowEditorSpec.kt

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object ShowEditorSpec : Spek({
1919
val shader1a by value { autoWirer.testPatch("shader 1a") }
2020
val shader2a by value { autoWirer.testPatch("shader 2a") }
2121

22-
val baseShowEditor by value {
22+
val baseMutableShow by value {
2323
MutableShow("test show").apply {
2424
addScene("scene 1") {
2525
addPatchSet("patchset 1a") { addPatch(shader1a) }
@@ -32,12 +32,12 @@ object ShowEditorSpec : Spek({
3232
addControl("Scenes", scenesControl)
3333
}
3434
}
35-
val baseShow by value { baseShowEditor.build(ShowBuilder()) }
35+
val baseShow by value { baseMutableShow.build(ShowBuilder()) }
3636
fun Show.showState() = ShowState.forShow(this).selectScene(1).selectPatchSet(1)
3737
val baseShowState by value { baseShow.showState() }
38-
val showEditor by value { MutableShow(baseShow, baseShowState) }
39-
val show by value { showEditor.build(ShowBuilder()) }
40-
val showState by value { showEditor.getShowState() }
38+
val mutableShow by value { MutableShow(baseShow, baseShowState) }
39+
val show by value { mutableShow.build(ShowBuilder()) }
40+
val showState by value { mutableShow.getShowState() }
4141

4242
context("base show") {
4343
it("has the expected initial scenes and patchsets") {
@@ -70,7 +70,7 @@ object ShowEditorSpec : Spek({
7070

7171
context("adding a patchset") {
7272
beforeEachTest {
73-
showEditor.apply {
73+
mutableShow.apply {
7474
editScene(1) {
7575
addPatchSet("patchset 2b") { addPatch(autoWirer.testPatch("shader 2b")) }
7676
}
@@ -86,7 +86,7 @@ object ShowEditorSpec : Spek({
8686

8787
context("editing a patchset") {
8888
beforeEachTest {
89-
showEditor.editScene(1) {
89+
mutableShow.editScene(1) {
9090
editPatchSet(1) { title = "modified $title" }
9191
}
9292
}
@@ -103,13 +103,13 @@ object ShowEditorSpec : Spek({
103103
val toIndex = 0
104104

105105
beforeEachTest {
106-
baseShowEditor.apply {
106+
baseMutableShow.apply {
107107
addScene("scene 3") {
108108
addPatchSet("patchset 3a") { addPatch(autoWirer.testPatch("shader 3a")) }
109109
}
110110
}
111111

112-
showEditor.moveScene(fromIndex, toIndex)
112+
mutableShow.moveScene(fromIndex, toIndex)
113113
}
114114

115115
it("reorders scenes") {
@@ -156,7 +156,7 @@ object ShowEditorSpec : Spek({
156156
override(baseShowState) { ShowState(1, listOf(2, 0)) }
157157

158158
beforeEachTest {
159-
showEditor.apply {
159+
mutableShow.apply {
160160
editScene(1) { movePatchSet(fromIndex, toIndex) }
161161
}
162162
}

src/jsMain/kotlin/baaahs/app/ui/AppIndex.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ val AppIndex = xComponent<AppIndexProps>("AppIndex") { props ->
361361
val newPatch = autoWirer.autoWire(Shader(shader.src))
362362
.resolve()
363363
val mutableShow = MutableShow(show, showState)
364-
showState.findPatchSetEditor(mutableShow)?.apply {
364+
showState.findMutablePatchSet(mutableShow)?.apply {
365365
patchMappings.clear() // TODO not this.
366366
addPatch(newPatch)
367367
}

src/jsMain/kotlin/baaahs/app/ui/controls/ControlDisplay.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class ControlDisplay(
2727

2828
init {
2929
val scene = showState.findScene(show)
30-
val mutableScene = showState.findSceneEditor(mutableShow)
30+
val mutableScene = showState.findMutableScene(mutableShow)
3131

3232
val patchSet = showState.findPatchSet(show)
33-
val mutablePatchSet = showState.findPatchSetEditor(mutableShow)
33+
val mutablePatchSet = showState.findMutablePatchSet(mutableShow)
3434

3535
allPanelBuckets = show.layouts.panelNames.associateWith { panelTitle ->
3636
PanelBuckets(panelTitle, mutableShow, mutableScene, mutablePatchSet)

src/jsMain/kotlin/baaahs/app/ui/controls/PatchList.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ val PatchSetList = xComponent<SpecialControlProps>("PatchSetList") { props ->
7373

7474
val handleEditButtonClick = useCallback(props.show, props.showState) { event: Event, index: Int ->
7575
props.show.edit(props.showState) {
76-
props.showState.findSceneEditor(this)?.editPatchSet(index) {
76+
props.showState.findMutableScene(this)?.editPatchSet(index) {
7777
mutablePatchHolder = this
7878
}
7979
event.preventDefault()
@@ -142,7 +142,7 @@ val PatchSetList = xComponent<SpecialControlProps>("PatchSetList") { props ->
142142
+"+"
143143
attrs.onClickFunction = { _: Event ->
144144
props.show.edit(props.showState) {
145-
props.showState.findSceneEditor(this)?.apply {
145+
props.showState.findMutableScene(this)?.apply {
146146
addPatchSet("Untitled Patch") {
147147
mutablePatchHolder = this
148148
}

0 commit comments

Comments
 (0)