Dialog column wraps its text

This commit is contained in:
Daniel Wolf 2018-02-02 22:23:49 +01:00
parent 6e5af62be7
commit d9d0f37b5a
1 changed files with 17 additions and 5 deletions

View File

@ -3,12 +3,11 @@ package com.rhubarb_lip_sync.rhubarb_for_spine
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.scene.control.Button import javafx.scene.control.*
import javafx.scene.control.TableCell
import javafx.scene.control.TableView
import javafx.scene.control.TextField
import javafx.scene.input.DragEvent import javafx.scene.input.DragEvent
import javafx.scene.input.TransferMode import javafx.scene.input.TransferMode
import javafx.scene.paint.Paint
import javafx.scene.text.Text
import javafx.stage.FileChooser import javafx.stage.FileChooser
import tornadofx.* import tornadofx.*
import java.io.File import java.io.File
@ -81,9 +80,22 @@ class MainView : View() {
columnResizePolicy = TableView.CONSTRAINED_RESIZE_POLICY columnResizePolicy = TableView.CONSTRAINED_RESIZE_POLICY
column("Event", AudioFileModel::eventNameProperty) column("Event", AudioFileModel::eventNameProperty)
column("Audio file", AudioFileModel::displayFilePathProperty) column("Audio file", AudioFileModel::displayFilePathProperty)
column("Dialog", AudioFileModel::dialogProperty) column("Dialog", AudioFileModel::dialogProperty).apply {
// Make dialog column wrap
setCellFactory { tableColumn ->
return@setCellFactory TableCell<AudioFileModel, String>().also { cell ->
cell.graphic = Text().apply {
textProperty().bind(cell.itemProperty())
fillProperty().bind(cell.textFillProperty())
wrappingWidthProperty().bind(tableColumn.widthProperty())
}
cell.prefHeight = Control.USE_COMPUTED_SIZE
}
}
}
column("Status", AudioFileModel::statusLabelProperty) column("Status", AudioFileModel::statusLabelProperty)
column("", AudioFileModel::actionLabelProperty).apply { column("", AudioFileModel::actionLabelProperty).apply {
// Show button
setCellFactory { tableColumn -> setCellFactory { tableColumn ->
return@setCellFactory object : TableCell<AudioFileModel, String>() { return@setCellFactory object : TableCell<AudioFileModel, String>() {
override fun updateItem(item: String?, empty: Boolean) { override fun updateItem(item: String?, empty: Boolean) {