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 9e52f9b..1542cd7 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/app/Main.kt @@ -1,10 +1,13 @@ package org.hso.texturesyncclient.app +import org.hso.texturesyncclient.controller.Controller import org.hso.texturesyncclient.view.importView.ImportView import org.hso.texturesyncclient.view.mainView.MainView import org.hso.texturesyncclient.view.startupView.StartupView import tornadofx.App -class Main: App(StartupView::class){ +class Main: App(MainView::class){ + + val controller = Controller() } \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt index d16af3a..5a3f19e 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt @@ -1,7 +1,26 @@ package org.hso.texturesyncclient.controller -class Controller { +import javafx.scene.image.Image +import org.hso.texturesyncclient.model.GUIModel +import org.hso.texturesyncclient.view.mainView.MainViewController +import tornadofx.Controller +class Controller : Controller() { + private val mvc: MainViewController by inject() + //private val mvc: = MainViewController() + //private val mvc: = MainViewController() + + init { + var test1 = GUIModel() // TODO get image from server with get_texture_preview + test1.setImage(Image("textures/sample_texture_1.jpg")) + test1.setText("Texture 1") + mvc.addElement(test1) + + var test2 = GUIModel() + test2.setImage(Image("textures/sample_texture_2.jpg")) + test2.setText("Texture 2") + mvc.addElement(test2) + } } \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt index 25c898d..8b8eff4 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt @@ -1,14 +1,53 @@ package org.hso.texturesyncclient.model +import javafx.geometry.Insets +import javafx.geometry.Pos +import javafx.scene.control.ContextMenu +import javafx.scene.control.Label +import javafx.scene.control.MenuItem +import javafx.scene.image.Image +import javafx.scene.image.ImageView +import javafx.scene.layout.Background +import javafx.scene.layout.BackgroundFill +import javafx.scene.layout.CornerRadii +import javafx.scene.layout.VBox +import javafx.scene.paint.Paint import tornadofx.* -class GUIModel : View("GUIModel"){ +class GUIModel constructor(data: Texture, img: Image) : VBox(){ - var data = DataModel() + private var image = ImageView() + private var label = Label() + private var contextMenu = ContextMenu() + private var exportItem = MenuItem("exportiern") + init { + super.getChildren().addAll(image, label) + super.setOnContextMenuRequested { p0 -> contextMenu.show(this@GUIModel, p0.screenX, p0.screenY) } - override val root = vbox() { + label.paddingTop = 5.0 + label.prefWidth = 128.0 + label.alignment = Pos.CENTER + label.text = data.name + label.background = Background(BackgroundFill(Paint.valueOf("#FFFF2b"), CornerRadii.EMPTY, Insets.EMPTY)) + image.fitHeight = 128.0 + image.fitWidth = 128.0 + image.image = img + + contextMenu.items.add(exportItem) + exportItem.setOnAction { + println("I bims 1 export: ${label.text}") + println(data.name) + } + } + + fun setText(text: String) { + label.text = text + } + + fun setImage(img: Image) { + image.image = img } } \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/FolderView.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/FolderView.kt index a025996..22ef8d6 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/FolderView.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/FolderView.kt @@ -1,8 +1,6 @@ package org.hso.texturesyncclient.view.mainView -import com.jfoenix.controls.JFXButton import javafx.geometry.Insets -import javafx.scene.control.TextField import javafx.scene.layout.Background import javafx.scene.layout.BackgroundFill import javafx.scene.layout.CornerRadii @@ -11,22 +9,15 @@ import tornadofx.* class FolderView : View("FolderView"){ - val btn1 = JFXButton("Button 1") - val btn2 = JFXButton("Button 2") - override val root = flowpane { - hgap = 5.0 - vgap = 5.0 + hgap = 10.0 + vgap = 10.0 paddingAll = 5.0 prefWidth = 750.0 background = Background(BackgroundFill(Paint.valueOf("#cfcfcf"), CornerRadii.EMPTY, Insets.EMPTY)) - add(btn1) - add(btn2) - style { - btn1.style = "-fx-button-type: RAISED; -fx-background-color: #3c3f41; -fx-text-fill: #2b7bbb;" - btn2.style = "-fx-button-type: RAISED; -fx-background-color: #3c3f41; -fx-text-fill: #2b7bbb;" + } } } \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainView.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainView.kt index b3dc78d..e2ad7bc 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainView.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainView.kt @@ -23,17 +23,11 @@ class MainView : View() { } // actions - folderView.btn1.setOnAction { - mvc.setPreview3DTexture(Image("textures/sample_texture_1.jpg")) - mvc.setMeta("texture 1", "8MP", "Quelle: wikipedia") - mvc.setTags(observableList("Stein", "Rot", "super")) - } - - folderView.btn2.setOnAction { - mvc.setPreview3DTexture(Image("textures/sample_texture_2.jpg")) - mvc.setMeta("texture 2", "300 x 400", "Quelle: Internet") - mvc.setTags(observableList("Reality", "is", "an", "illusion")) - } +// folderView.btn1.setOnAction { +// mvc.setPreview3DTexture(Image("textures/sample_texture_1.jpg")) +// mvc.setMeta("texture 1", "8MP", "Quelle: wikipedia") +// mvc.setTags(observableList("Stein", "Rot", "super")) +// } detailView.cvTags.chips.addListener { change: ListChangeListener.Change? -> mvc.updateTags() diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt index 1c7c328..1307a8e 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt @@ -2,13 +2,16 @@ package org.hso.texturesyncclient.view.mainView import javafx.collections.ObservableList import javafx.scene.image.Image +import org.hso.texturesyncclient.model.GUIModel import tornadofx.Controller +import tornadofx.add class MainViewController : Controller() { private val mv = find(MainView::class) // FolderView elements + private val folderView = mv.folderView.root // DetailView elements private val preview = mv.detailView.preview @@ -16,6 +19,13 @@ class MainViewController : Controller() { private val cvTags = mv.detailView.cvTags + // FolderView functions + fun addElement(element: GUIModel) { + folderView.add(element) + } + + + // DetailView functions fun setPreview3DTexture(img: Image) { preview.setTexture(img) }