From d9d0f37b5a419f1a8b4b2b35a3d42f83d7bddca6 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Fri, 2 Feb 2018 22:23:49 +0100 Subject: [PATCH] Dialog column wraps its text --- .../rhubarb_for_spine/MainView.kt | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/extras/rhubarb-for-spine/src/main/kotlin/com/rhubarb_lip_sync/rhubarb_for_spine/MainView.kt b/extras/rhubarb-for-spine/src/main/kotlin/com/rhubarb_lip_sync/rhubarb_for_spine/MainView.kt index 7b24be0..e15a50a 100644 --- a/extras/rhubarb-for-spine/src/main/kotlin/com/rhubarb_lip_sync/rhubarb_for_spine/MainView.kt +++ b/extras/rhubarb-for-spine/src/main/kotlin/com/rhubarb_lip_sync/rhubarb_for_spine/MainView.kt @@ -3,12 +3,11 @@ package com.rhubarb_lip_sync.rhubarb_for_spine import javafx.beans.property.SimpleStringProperty import javafx.event.ActionEvent import javafx.event.EventHandler -import javafx.scene.control.Button -import javafx.scene.control.TableCell -import javafx.scene.control.TableView -import javafx.scene.control.TextField +import javafx.scene.control.* import javafx.scene.input.DragEvent import javafx.scene.input.TransferMode +import javafx.scene.paint.Paint +import javafx.scene.text.Text import javafx.stage.FileChooser import tornadofx.* import java.io.File @@ -81,9 +80,22 @@ class MainView : View() { columnResizePolicy = TableView.CONSTRAINED_RESIZE_POLICY column("Event", AudioFileModel::eventNameProperty) column("Audio file", AudioFileModel::displayFilePathProperty) - column("Dialog", AudioFileModel::dialogProperty) + column("Dialog", AudioFileModel::dialogProperty).apply { + // Make dialog column wrap + setCellFactory { tableColumn -> + return@setCellFactory TableCell().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("", AudioFileModel::actionLabelProperty).apply { + // Show button setCellFactory { tableColumn -> return@setCellFactory object : TableCell() { override fun updateItem(item: String?, empty: Boolean) {