make window resizable, rework MainView code

This commit is contained in:
Jannik 2019-06-09 13:12:56 +02:00
parent 15cbbb1bac
commit 5d223ba72b
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
4 changed files with 45 additions and 51 deletions

View File

@ -13,9 +13,11 @@ class Main: App(StartupView::class){
override fun start(stage: Stage) { override fun start(stage: Stage) {
stage.minWidth = 1000.00 stage.minWidth = 1008.00
stage.minHeight = 500.00 stage.minHeight = 535.00
stage.isResizable = false stage.width = 1008.00
stage.height = 535.00
stage.isResizable = true
stage.icons.add(Image("icons/TextureSync_Icon_256x256.jpeg")) stage.icons.add(Image("icons/TextureSync_Icon_256x256.jpeg"))
stage.setOnCloseRequest { System.exit(0) } stage.setOnCloseRequest { System.exit(0) }

View File

@ -1,10 +1,8 @@
package org.hso.texturesyncclient.view.mainView package org.hso.texturesyncclient.view.mainView
import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXChipView import com.jfoenix.controls.JFXChipView
import javafx.geometry.Insets import javafx.geometry.Insets
import javafx.geometry.Orientation import javafx.geometry.Orientation
import javafx.geometry.Pos
import javafx.scene.control.Label import javafx.scene.control.Label
import javafx.scene.image.Image import javafx.scene.image.Image
import javafx.scene.layout.Background import javafx.scene.layout.Background
@ -18,7 +16,6 @@ class DetailView: View() {
val preview = Preview3D() val preview = Preview3D()
val metaLabel = Label("Auflösung: 8MP\nName: Texture.png\nAndere: was anderes\nEinfügedatum: 31.02.2019") val metaLabel = Label("Auflösung: 8MP\nName: Texture.png\nAndere: was anderes\nEinfügedatum: 31.02.2019")
val cvTags = JFXChipView<String>() val cvTags = JFXChipView<String>()
val btnImport = JFXButton("+")
init { init {
// set a default texture // set a default texture
@ -49,12 +46,6 @@ class DetailView: View() {
} }
field {
hbox(alignment = Pos.CENTER_RIGHT) {
add(btnImport)
}
}
} }
style { style {
@ -63,9 +54,6 @@ class DetailView: View() {
cvTags.minHeight = 145.0 cvTags.minHeight = 145.0
cvTags.paddingAll = 3.0 cvTags.paddingAll = 3.0
cvTags.style = "-fx-background-color: #53585b; -fx-text-inner-color: #b15b2e;" cvTags.style = "-fx-background-color: #53585b; -fx-text-inner-color: #b15b2e;"
btnImport.buttonType = JFXButton.ButtonType.RAISED
btnImport.styleClass.add("jfx-floating-action-button")
} }
} }

View File

@ -13,12 +13,7 @@ class FolderView : View("FolderView"){
hgap = 5.0 hgap = 5.0
vgap = 5.0 vgap = 5.0
paddingAll = 10.0 paddingAll = 10.0
prefWidth = 732.0
prefHeight = 401.0
background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY)) background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
style {
}
} }
} }

View File

@ -1,8 +1,8 @@
package org.hso.texturesyncclient.view.mainView package org.hso.texturesyncclient.view.mainView
import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXChipView import com.jfoenix.controls.JFXChipView
import javafx.geometry.Insets import javafx.geometry.Insets
import javafx.scene.control.ScrollPane
import javafx.scene.layout.Background import javafx.scene.layout.Background
import javafx.scene.layout.BackgroundFill import javafx.scene.layout.BackgroundFill
@ -13,51 +13,60 @@ import tornadofx.*
class MainView : View("TextureSync") { class MainView : View("TextureSync") {
val cvSearch = JFXChipView<String>() val cvSearch = JFXChipView<String>()
val btnImport = JFXButton("+")
val folderView = find(FolderView::class) val folderView = find(FolderView::class)
val detailView = find(DetailView::class) val detailView = find(DetailView::class)
private val mvc: MainViewController by inject() private val mvc: MainViewController by inject()
override val root = borderpane { override val root = anchorpane {
background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY)) background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
minWidth = 1000.0 prefWidth = FX.primaryStage.width
maxWidth = 1000.0 prefHeight = FX.primaryStage.height
minHeight = 500.0
maxHeight = 500.0
left = vbox {
//background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
anchorpane{
this.fitToParentWidth()
paddingAll = 5.0
add(cvSearch) add(cvSearch)
}
anchorpane {
scrollpane { scrollpane {
this.fitToParentSize() style = "-fx-background-color:transparent;"
this.vbarPolicy = ScrollPane.ScrollBarPolicy.ALWAYS isFitToWidth = true
isFitToHeight = true
add(folderView.root) add(folderView.root)
style = "-fx-background-color:transparent;" anchorpaneConstraints {
topAnchor = 106
bottomAnchor = 0
leftAnchor = 0
rightAnchor = 255
} }
} }
} add(detailView)
add(btnImport)
right = detailView.root
style { style {
cvSearch.promptText = "Suche" cvSearch.promptText = "Suche"
cvSearch.paddingAll = 5.0 cvSearch.paddingAll = 5.0
cvSearch.minHeight = 70.0 cvSearch.minHeight = 65.0
cvSearch.style = "-fx-background-color: #53585b; -fx-text-inner-color: #b15b2e;" cvSearch.style = "-fx-background-color: #53585b; -fx-text-inner-color: #b15b2e;"
cvSearch.anchorpaneConstraints { cvSearch.anchorpaneConstraints {
topAnchor = 3 topAnchor = 3
bottomAnchor = 3
leftAnchor = 3 leftAnchor = 3
rightAnchor = -5 rightAnchor = 253
} }
detailView.root.anchorpaneConstraints {
topAnchor = 0
bottomAnchor = 0
rightAnchor = 0
}
btnImport.buttonType = JFXButton.ButtonType.RAISED
btnImport.styleClass.add("jfx-floating-action-button")
btnImport.anchorpaneConstraints {
bottomAnchor = 5
rightAnchor = 5
}
} }
// actions // actions
@ -65,12 +74,12 @@ class MainView : View("TextureSync") {
mvc.cvSearchAction(cvSearch.chips) mvc.cvSearchAction(cvSearch.chips)
} }
detailView.cvTags.chips.onChange { btnImport.setOnAction {
mvc.updateTags() mvc.btnImportAction()
} }
detailView.btnImport.setOnAction { detailView.cvTags.chips.onChange {
mvc.btnImportAction() mvc.updateTags()
} }
} }