[Editor] Fix Label editor appearance

This commit is contained in:
2023-11-16 10:57:48 +01:00
parent 14dd99f79a
commit ee8f4880d8
3 changed files with 19 additions and 21 deletions

View File

@@ -3,8 +3,12 @@ package com.bartlomiejpluta.base.editor.common.view
import javafx.beans.property.SimpleStringProperty
import tornadofx.*
class StringInputFragment : Fragment("Enter value") {
val valueProperty = SimpleStringProperty()
class StringInputFragment : Fragment("Define value") {
val initialValue by param("")
val fieldsetLabel by param(title)
val label by param("Value: ")
val valueProperty = SimpleStringProperty(initialValue)
var value by valueProperty
private var onCompleteConsumer: ((String) -> Unit)? = null
@@ -13,13 +17,16 @@ class StringInputFragment : Fragment("Enter value") {
this.onCompleteConsumer = consumer
}
override val root = borderpane {
center = textfield(valueProperty) {
whenDocked { requestFocus() }
override val root = form {
fieldset(fieldsetLabel) {
field(label) {
textfield(valueProperty) {
whenDocked { requestFocus() }
}
}
}
bottom = buttonbar {
buttonbar {
button("Apply") {
action {
onCompleteConsumer?.let { it(value) }

View File

@@ -1,8 +0,0 @@
package com.bartlomiejpluta.base.editor.common.viewmodel
import tornadofx.*
class StringVM(value: String = "") : ViewModel() {
val valueProperty = value.toProperty()
val value by valueProperty
}

View File

@@ -1,7 +1,6 @@
package com.bartlomiejpluta.base.editor.map.canvas
import com.bartlomiejpluta.base.editor.common.view.StringInputFragment
import com.bartlomiejpluta.base.editor.common.viewmodel.StringVM
import com.bartlomiejpluta.base.editor.map.model.brush.BrushMode
import com.bartlomiejpluta.base.editor.map.model.layer.ObjectLayer
import com.bartlomiejpluta.base.editor.map.model.obj.MapLabel
@@ -14,7 +13,6 @@ import javafx.collections.ObservableList
import javafx.scene.input.MouseButton
import tornadofx.Scope
import tornadofx.find
import tornadofx.setInScope
class LabelPaintingTrace(
private val projectContext: ProjectContext,
@@ -57,13 +55,14 @@ class LabelPaintingTrace(
private fun showCodeDialog(initialContent: String): String? {
val scope = Scope()
val vm = StringVM(initialContent)
setInScope(vm, scope)
var content: String? = null
find<StringInputFragment>(scope).apply {
title = "Set label"
find<StringInputFragment>(scope,
StringInputFragment::initialValue to initialContent,
StringInputFragment::fieldsetLabel to "Define label",
StringInputFragment::label to "Label: ").apply {
title = "Label"
onComplete {
content = it