Nicely visualizing progress
This commit is contained in:
parent
b75a3ca1d9
commit
19a6b77529
|
@ -69,7 +69,7 @@ class AudioFileModel(
|
||||||
private val futureProperty = SimpleObjectProperty<Future<*>?>()
|
private val futureProperty = SimpleObjectProperty<Future<*>?>()
|
||||||
private var future by futureProperty
|
private var future by futureProperty
|
||||||
|
|
||||||
private val audioFileStateProperty = SimpleObjectProperty<AudioFileState>().apply {
|
val audioFileStateProperty = SimpleObjectProperty<AudioFileState>().apply {
|
||||||
bind(object : ObjectBinding<AudioFileState>() {
|
bind(object : ObjectBinding<AudioFileState>() {
|
||||||
init {
|
init {
|
||||||
super.bind(animatedProperty, futureProperty, animationProgressProperty)
|
super.bind(animatedProperty, futureProperty, animationProgressProperty)
|
||||||
|
@ -92,7 +92,7 @@ class AudioFileModel(
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
private val audioFileState by audioFileStateProperty
|
val audioFileState by audioFileStateProperty
|
||||||
|
|
||||||
val busyProperty = SimpleBooleanProperty().apply {
|
val busyProperty = SimpleBooleanProperty().apply {
|
||||||
bind(object : BooleanBinding() {
|
bind(object : BooleanBinding() {
|
||||||
|
@ -107,24 +107,6 @@ class AudioFileModel(
|
||||||
}
|
}
|
||||||
val busy by busyProperty
|
val busy by busyProperty
|
||||||
|
|
||||||
val statusLabelProperty = SimpleStringProperty().apply {
|
|
||||||
bind(object : StringBinding() {
|
|
||||||
init {
|
|
||||||
super.bind(audioFileStateProperty)
|
|
||||||
}
|
|
||||||
override fun computeValue(): String {
|
|
||||||
return when (audioFileState.status) {
|
|
||||||
AudioFileStatus.NotAnimated -> "Not animated"
|
|
||||||
AudioFileStatus.Pending -> "Waiting"
|
|
||||||
AudioFileStatus.Animating -> "${((animationProgress ?: 0.0) * 100).toInt()}%"
|
|
||||||
AudioFileStatus.Canceling -> "Canceling"
|
|
||||||
AudioFileStatus.Done -> "Done"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
val statusLabel by statusLabelProperty
|
|
||||||
|
|
||||||
val actionLabelProperty = SimpleStringProperty().apply {
|
val actionLabelProperty = SimpleStringProperty().apply {
|
||||||
bind(object : StringBinding() {
|
bind(object : StringBinding() {
|
||||||
init {
|
init {
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
package com.rhubarb_lip_sync.rhubarb_for_spine
|
package com.rhubarb_lip_sync.rhubarb_for_spine
|
||||||
|
|
||||||
import javafx.beans.binding.Bindings
|
|
||||||
import javafx.beans.property.Property
|
import javafx.beans.property.Property
|
||||||
import javafx.beans.property.SimpleBooleanProperty
|
import javafx.beans.property.SimpleBooleanProperty
|
||||||
import javafx.beans.property.SimpleStringProperty
|
import javafx.beans.property.SimpleStringProperty
|
||||||
import javafx.event.ActionEvent
|
import javafx.event.ActionEvent
|
||||||
import javafx.event.EventHandler
|
import javafx.event.EventHandler
|
||||||
|
import javafx.geometry.Pos
|
||||||
import javafx.scene.control.*
|
import javafx.scene.control.*
|
||||||
import javafx.scene.input.DragEvent
|
import javafx.scene.input.DragEvent
|
||||||
import javafx.scene.input.TransferMode
|
import javafx.scene.input.TransferMode
|
||||||
|
import javafx.scene.layout.*
|
||||||
|
import javafx.scene.paint.Color
|
||||||
|
import javafx.scene.text.Font
|
||||||
|
import javafx.scene.text.FontWeight
|
||||||
import javafx.scene.text.Text
|
import javafx.scene.text.Text
|
||||||
import javafx.stage.FileChooser
|
import javafx.stage.FileChooser
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
|
@ -110,8 +114,45 @@ class MainView : View() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
column("Status", AudioFileModel::statusLabelProperty)
|
column("Status", AudioFileModel::audioFileStateProperty).apply {
|
||||||
.weigthedWidth(1.0)
|
weigthedWidth(1.0)
|
||||||
|
setCellFactory { tableColumn ->
|
||||||
|
return@setCellFactory object : TableCell<AudioFileModel, AudioFileState>() {
|
||||||
|
override fun updateItem(state: AudioFileState?, empty: Boolean) {
|
||||||
|
super.updateItem(state, empty)
|
||||||
|
graphic = if (state != null) {
|
||||||
|
when (state.status) {
|
||||||
|
AudioFileStatus.NotAnimated -> Text("Not animated").apply {
|
||||||
|
fill = Color.GRAY
|
||||||
|
}
|
||||||
|
AudioFileStatus.Pending -> ProgressBar().apply {
|
||||||
|
progress = -1.0 // Indeterminate
|
||||||
|
maxWidth = Double.MAX_VALUE
|
||||||
|
}
|
||||||
|
AudioFileStatus.Animating -> HBox().apply {
|
||||||
|
val progress = state.progress ?: 0.0
|
||||||
|
val bar = progressbar(progress) {
|
||||||
|
maxWidth = Double.MAX_VALUE
|
||||||
|
}
|
||||||
|
HBox.setHgrow(bar, Priority.ALWAYS)
|
||||||
|
val progressString = "${(progress * 100).toInt()}%"
|
||||||
|
hbox {
|
||||||
|
minWidth = 30.0
|
||||||
|
text(progressString) {
|
||||||
|
alignment = Pos.BASELINE_RIGHT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AudioFileStatus.Canceling -> Text("Canceling")
|
||||||
|
AudioFileStatus.Done -> Text("Done").apply {
|
||||||
|
font = Font.font(font.family, FontWeight.BOLD, font.size)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
column("", AudioFileModel::actionLabelProperty).apply {
|
column("", AudioFileModel::actionLabelProperty).apply {
|
||||||
weigthedWidth(1.0)
|
weigthedWidth(1.0)
|
||||||
// Show button
|
// Show button
|
||||||
|
|
Loading…
Reference in New Issue