2019-04-30 16:49:02 +02:00
package org.hso.texturesyncclient.view.mainView
2019-06-09 13:12:56 +02:00
import com.jfoenix.controls.JFXButton
2019-06-04 18:20:09 +02:00
import com.jfoenix.controls.JFXChipView
import javafx.geometry.Insets
2019-06-04 20:49:07 +02:00
2019-06-04 18:20:09 +02:00
import javafx.scene.layout.Background
import javafx.scene.layout.BackgroundFill
import javafx.scene.layout.CornerRadii
import javafx.scene.paint.Paint
2019-04-30 16:49:02 +02:00
import tornadofx.*
2019-06-08 14:39:18 +02:00
class MainView : View ( " TextureSync " ) {
2019-04-30 16:49:02 +02:00
2019-06-04 18:20:09 +02:00
val cvSearch = JFXChipView < String > ( )
2019-06-09 13:38:11 +02:00
private val btnImport = JFXButton ( " + " )
2019-05-09 15:24:45 +02:00
val folderView = find ( FolderView :: class )
val detailView = find ( DetailView :: class )
2019-04-30 16:49:02 +02:00
2019-05-08 18:12:31 +02:00
private val mvc : MainViewController by inject ( )
2019-06-17 20:19:54 +02:00
fun repeatSearch ( ) {
mvc . cvSearchAction ( cvSearch . chips )
}
2019-06-09 13:12:56 +02:00
override val root = anchorpane {
2019-06-13 18:27:44 +02:00
2019-06-08 13:25:55 +02:00
background = Background ( BackgroundFill ( Paint . valueOf ( " #2b2b2b " ) , CornerRadii . EMPTY , Insets . EMPTY ) )
2019-06-09 13:12:56 +02:00
prefWidth = FX . primaryStage . width
prefHeight = FX . primaryStage . height
2019-06-13 18:27:44 +02:00
borderpane {
right = detailView . root
center = vbox {
add ( cvSearch )
scrollpane {
style = " -fx-background-color:transparent; "
isFitToWidth = true
isFitToHeight = true
add ( folderView . root )
}
}
2019-06-09 13:12:56 +02:00
anchorpaneConstraints {
2019-06-13 18:27:44 +02:00
topAnchor = 0
2019-06-09 13:12:56 +02:00
bottomAnchor = 0
2019-06-13 18:27:44 +02:00
rightAnchor = 0
2019-06-09 13:12:56 +02:00
leftAnchor = 0
}
2019-06-04 18:20:09 +02:00
}
2019-05-08 18:12:31 +02:00
2019-06-09 13:12:56 +02:00
add ( btnImport )
2019-06-08 22:16:47 +02:00
2019-05-08 18:12:31 +02:00
style {
2019-06-08 13:48:16 +02:00
cvSearch . promptText = " Suche "
2019-06-08 13:25:55 +02:00
cvSearch . paddingAll = 5.0
2019-06-09 13:12:56 +02:00
cvSearch . minHeight = 65.0
2019-06-08 13:25:55 +02:00
cvSearch . style = " -fx-background-color: #53585b; -fx-text-inner-color: #b15b2e; "
2019-06-09 13:12:56 +02:00
btnImport . buttonType = JFXButton . ButtonType . RAISED
btnImport . styleClass . add ( " jfx-floating-action-button " )
btnImport . anchorpaneConstraints {
bottomAnchor = 5
rightAnchor = 5
}
2019-05-08 18:12:31 +02:00
}
// actions
2019-06-04 20:49:07 +02:00
cvSearch . chips . onChange {
mvc . cvSearchAction ( cvSearch . chips )
2019-06-04 18:20:09 +02:00
}
2019-05-09 15:24:45 +02:00
2019-06-09 13:12:56 +02:00
btnImport . setOnAction {
mvc . btnImportAction ( )
2019-05-09 15:24:45 +02:00
}
2019-06-13 00:10:00 +02:00
// TODO: on chipview update on name update
2019-06-09 13:12:56 +02:00
detailView . cvTags . chips . onChange {
2019-06-13 21:43:43 +02:00
detailView . btnSubmit . isVisible = true
2019-06-13 00:10:00 +02:00
}
detailView . nameInfo . textProperty ( ) . onChange {
2019-06-13 21:43:43 +02:00
detailView . btnSubmit . isVisible = true
2019-06-13 00:10:00 +02:00
}
2019-06-13 21:43:43 +02:00
detailView . btnSubmit . setOnAction {
2019-06-09 13:12:56 +02:00
mvc . updateTags ( )
2019-06-13 21:43:43 +02:00
detailView . btnSubmit . isVisible = false
2019-06-05 16:23:45 +02:00
}
2019-06-08 22:16:47 +02:00
2019-06-10 12:25:06 +02:00
//keyboard actions
shortcut ( " Ctrl+I " ) {
mvc . btnImportAction ( )
}
2019-06-10 12:41:11 +02:00
shortcut ( " Ctrl+E " ) {
mvc . scExport ( )
}
2019-05-08 18:12:31 +02:00
}
2019-04-30 16:49:02 +02:00
}