From 8dfbbae559985bbaa0a32dcd51c6f543e709d332 Mon Sep 17 00:00:00 2001 From: CodeSteak Date: Wed, 12 Jun 2019 22:42:28 +0200 Subject: [PATCH] fix #28 --- .../kotlin/org/hso/texturesyncclient/app/Main.kt | 4 ++-- .../view/importView/ImportView.kt | 7 +++++++ .../view/importView/ImportViewController.kt | 16 +++++++++++++++- .../texturesyncclient/view/mainView/Preview3D.kt | 1 - 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt b/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt index 80aed7d..0c4a162 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt @@ -20,9 +20,9 @@ class Main : App(StartupView::class) { super.start(stage) stage.minWidth = 1008.00 - stage.minHeight = 535.00 + stage.minHeight = 700.00 stage.width = 1008.00 - stage.height = 535.00 + stage.height = 700.00 stage.isResizable = true stage.icons.add(Image("icons/TextureSync_Icon_256x256.png")) stage.setOnCloseRequest { System.exit(0) } diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportView.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportView.kt index 20f4ede..ddaee6f 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportView.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportView.kt @@ -10,6 +10,7 @@ import javafx.scene.layout.BackgroundFill import javafx.scene.layout.CornerRadii import javafx.scene.paint.Paint import javafx.scene.layout.Priority +import org.hso.texturesyncclient.view.mainView.Preview3D import tornadofx.* class ImportView : View("TextureSync") { @@ -18,12 +19,16 @@ class ImportView : View("TextureSync") { val tfName = JFXTextField() val cvTags = JFXChipView() val btnImport = JFXButton("Importieren") + + val preview = Preview3D() + private val btnBack = JFXButton("Zurück") private val ivc: ImportViewController by inject() init { btnImport.isVisible = false + preview.root.isVisible = false } override val root = borderpane { @@ -39,6 +44,8 @@ class ImportView : View("TextureSync") { style = "-fx-font: 20px Verdana; -fx-text-fill: #2b7bbb;" } + add(preview) + vbox(20) { hbox(10) { add(tfFilePath) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt index 84025c2..5814216 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt @@ -1,9 +1,11 @@ package org.hso.texturesyncclient.view.importView +import javafx.scene.image.Image +import javafx.stage.FileChooser import org.hso.texturesyncclient.controller.RootController import tornadofx.Controller -import javafx.stage.FileChooser import java.io.File +import java.io.FileInputStream class ImportViewController : Controller() { @@ -29,6 +31,18 @@ class ImportViewController : Controller() { iv.tfFilePath.text = file.absolutePath iv.tfName.text = file.nameWithoutExtension lastImportDir = file.parent.toString() //store last user chosen dir + + runAsync { + try { + val fileInput = FileInputStream(file.absolutePath) + val img = Image(fileInput) + iv.preview.setTexture(img) + iv.preview.root.isVisible = true + } catch (e: Exception) { + // Got a catch'em all + println(e.message) + } + } } } diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/Preview3D.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/Preview3D.kt index 5496717..b1115aa 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/Preview3D.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/Preview3D.kt @@ -36,7 +36,6 @@ class Preview3D : View("Preview3D") { pointLightFront.rotate = 90.0 } - override val root = stackpane { add(dBox).apply {