Merge branch 'master' of git.mosad.xyz:localhorst/TextureSync

This commit is contained in:
CodeSteak 2019-06-03 15:34:13 +02:00
commit d1f2f42511
6 changed files with 84 additions and 28 deletions

View File

@ -1,10 +1,13 @@
package org.hso.texturesyncclient.app package org.hso.texturesyncclient.app
import org.hso.texturesyncclient.controller.Controller
import org.hso.texturesyncclient.view.importView.ImportView import org.hso.texturesyncclient.view.importView.ImportView
import org.hso.texturesyncclient.view.mainView.MainView import org.hso.texturesyncclient.view.mainView.MainView
import org.hso.texturesyncclient.view.startupView.StartupView import org.hso.texturesyncclient.view.startupView.StartupView
import tornadofx.App import tornadofx.App
class Main: App(StartupView::class){ class Main: App(MainView::class){
val controller = Controller()
} }

View File

@ -1,7 +1,26 @@
package org.hso.texturesyncclient.controller 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)
}
} }

View File

@ -1,14 +1,53 @@
package org.hso.texturesyncclient.model 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.* 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
} }
} }

View File

@ -1,8 +1,6 @@
package org.hso.texturesyncclient.view.mainView package org.hso.texturesyncclient.view.mainView
import com.jfoenix.controls.JFXButton
import javafx.geometry.Insets import javafx.geometry.Insets
import javafx.scene.control.TextField
import javafx.scene.layout.Background import javafx.scene.layout.Background
import javafx.scene.layout.BackgroundFill import javafx.scene.layout.BackgroundFill
import javafx.scene.layout.CornerRadii import javafx.scene.layout.CornerRadii
@ -11,22 +9,15 @@ import tornadofx.*
class FolderView : View("FolderView"){ class FolderView : View("FolderView"){
val btn1 = JFXButton("Button 1")
val btn2 = JFXButton("Button 2")
override val root = flowpane { override val root = flowpane {
hgap = 5.0 hgap = 10.0
vgap = 5.0 vgap = 10.0
paddingAll = 5.0 paddingAll = 5.0
prefWidth = 750.0 prefWidth = 750.0
background = Background(BackgroundFill(Paint.valueOf("#cfcfcf"), CornerRadii.EMPTY, Insets.EMPTY)) background = Background(BackgroundFill(Paint.valueOf("#cfcfcf"), CornerRadii.EMPTY, Insets.EMPTY))
add(btn1)
add(btn2)
style { 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;"
} }
} }
} }

View File

@ -23,17 +23,11 @@ class MainView : View() {
} }
// actions // actions
folderView.btn1.setOnAction { // folderView.btn1.setOnAction {
mvc.setPreview3DTexture(Image("textures/sample_texture_1.jpg")) // mvc.setPreview3DTexture(Image("textures/sample_texture_1.jpg"))
mvc.setMeta("texture 1", "8MP", "Quelle: wikipedia") // mvc.setMeta("texture 1", "8MP", "Quelle: wikipedia")
mvc.setTags(observableList("Stein", "Rot", "super")) // 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"))
}
detailView.cvTags.chips.addListener { change: ListChangeListener.Change<out String>? -> detailView.cvTags.chips.addListener { change: ListChangeListener.Change<out String>? ->
mvc.updateTags() mvc.updateTags()

View File

@ -2,13 +2,16 @@ package org.hso.texturesyncclient.view.mainView
import javafx.collections.ObservableList import javafx.collections.ObservableList
import javafx.scene.image.Image import javafx.scene.image.Image
import org.hso.texturesyncclient.model.GUIModel
import tornadofx.Controller import tornadofx.Controller
import tornadofx.add
class MainViewController : Controller() { class MainViewController : Controller() {
private val mv = find(MainView::class) private val mv = find(MainView::class)
// FolderView elements // FolderView elements
private val folderView = mv.folderView.root
// DetailView elements // DetailView elements
private val preview = mv.detailView.preview private val preview = mv.detailView.preview
@ -16,6 +19,13 @@ class MainViewController : Controller() {
private val cvTags = mv.detailView.cvTags private val cvTags = mv.detailView.cvTags
// FolderView functions
fun addElement(element: GUIModel) {
folderView.add(element)
}
// DetailView functions
fun setPreview3DTexture(img: Image) { fun setPreview3DTexture(img: Image) {
preview.setTexture(img) preview.setTexture(img)
} }