added import Button

This commit is contained in:
Jannik 2019-06-05 16:23:45 +02:00
parent 8d387250e7
commit d7a67c497e
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
5 changed files with 50 additions and 22 deletions

View File

@ -9,6 +9,7 @@ import org.hso.texturesyncclient.model.GUIModel
import org.hso.texturesyncclient.model.Sha256 import org.hso.texturesyncclient.model.Sha256
import org.hso.texturesyncclient.model.Texture import org.hso.texturesyncclient.model.Texture
import org.hso.texturesyncclient.model.TextureFormat import org.hso.texturesyncclient.model.TextureFormat
import org.hso.texturesyncclient.view.importView.ImportView
import org.hso.texturesyncclient.view.importView.ImportViewController import org.hso.texturesyncclient.view.importView.ImportViewController
import org.hso.texturesyncclient.view.mainView.MainView import org.hso.texturesyncclient.view.mainView.MainView
import org.hso.texturesyncclient.view.mainView.MainViewController import org.hso.texturesyncclient.view.mainView.MainViewController
@ -16,7 +17,6 @@ import org.hso.texturesyncclient.view.startupView.StartupView
import org.hso.texturesyncclient.view.startupView.StartupViewController import org.hso.texturesyncclient.view.startupView.StartupViewController
import tornadofx.Controller import tornadofx.Controller
import tornadofx.observable import tornadofx.observable
import tornadofx.observableList
import java.net.InetAddress import java.net.InetAddress
import java.util.Calendar import java.util.Calendar
import java.io.File import java.io.File
@ -39,14 +39,6 @@ class RootController : Controller() {
var test = GUIModel(data, img) var test = GUIModel(data, img)
test.exportItem.setOnAction { test.exportItem.setOnAction {
}
mvc.addElement(test)
data = Texture()
img = con.getTexturePreview(data.textureHash)
test = GUIModel(data, img)
test.exportItem.setOnAction {
} }
mvc.addElement(test)*/ mvc.addElement(test)*/
} }
@ -117,10 +109,16 @@ class RootController : Controller() {
} }
fun switchToMainView() { fun switchStartupToMain() {
Platform.runLater { //avoid the exception that occurs then this is called from an not tornadoFx thread find(StartupView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true)
find(StartupView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true) }
}
fun switchMainToImport() {
find(MainView::class).replaceWith(ImportView::class, sizeToScene = true, centerOnScreen = true)
}
fun switchImportToMain() {
find(ImportView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true)
} }
/** /**

View File

@ -24,6 +24,7 @@ class ImportViewController : Controller() {
fun btnImportAction() { fun btnImportAction() {
rootc.importTexture(iv.tfFilePath.text, iv.tfName.text, iv.cvTags.chips) rootc.importTexture(iv.tfFilePath.text, iv.tfName.text, iv.cvTags.chips)
rootc.switchImportToMain()
} }
fun validateImport() { fun validateImport() {

View File

@ -1,8 +1,10 @@
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
@ -16,6 +18,7 @@ class DetailView: View() {
val preview = Preview3D() val preview = Preview3D()
val metaLabel = Label("Auflösung: 8MP\nName: Texture.png\nAndere: was anderes") val metaLabel = Label("Auflösung: 8MP\nName: Texture.png\nAndere: was anderes")
val cvTags = JFXChipView<String>() val cvTags = JFXChipView<String>()
val btnImport = JFXButton("+")
init { init {
// set a default texture // set a default texture
@ -39,14 +42,40 @@ class DetailView: View() {
} }
field { field {
minHeight = 145.0
add(cvTags) add(cvTags)
}
field {
hbox(alignment = Pos.CENTER_RIGHT) {
add(btnImport)
}
} }
// TODO add "Import" Btn // TODO add "Import" Btn
} }
style { style {
cvTags.minHeight = 135.0
cvTags.paddingAll = 3.0
cvTags.style = "-fx-background-color: #3c3f41; -fx-text-inner-color: #b15b2e;" cvTags.style = "-fx-background-color: #3c3f41; -fx-text-inner-color: #b15b2e;"
btnImport.buttonType = JFXButton.ButtonType.RAISED
// TODO move this to a css file
btnImport.style = "-fx-background-color: #F1F1F1;\n" +
" -fx-background-radius: 50px;\n" +
" -fx-pref-height: 50px;\n" +
" -fx-pref-width: 50px;\n" +
" -fx-min-width: -fx-pref-width;\n" +
" -fx-max-width: -fx-pref-width;\n" +
" -fx-min-height: -fx-pref-height;\n" +
" -fx-max-height: -fx-pref-height;\n" +
"-jfx-button-type: RAISED;"
}
btnImport.setOnAction {
} }
} }

View File

@ -65,6 +65,10 @@ class MainView : View() {
mvc.updateTags() mvc.updateTags()
} }
detailView.btnImport.setOnAction {
mvc.btnImportAction()
}
} }
} }

View File

@ -3,14 +3,8 @@ 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 org.hso.texturesyncclient.model.GUIModel
import org.hso.texturesyncclient.model.TextureFormat
import tornadofx.Controller import tornadofx.Controller
import javafx.stage.DirectoryChooser
import org.hso.texturesyncclient.controller.RootController import org.hso.texturesyncclient.controller.RootController
import tornadofx.clear
import javax.swing.JColorChooser.showDialog
import java.io.File
class MainViewController : Controller() { class MainViewController : Controller() {
@ -25,7 +19,6 @@ class MainViewController : Controller() {
private val metaLabel = mv.detailView.metaLabel private val metaLabel = mv.detailView.metaLabel
private val cvTags = mv.detailView.cvTags private val cvTags = mv.detailView.cvTags
// FolderView functions // FolderView functions
fun addElement(element: GUIModel) { fun addElement(element: GUIModel) {
folderView.children.add(element) folderView.children.add(element)
@ -50,11 +43,12 @@ class MainViewController : Controller() {
cvTags.chips.addAll(chips) cvTags.chips.addAll(chips)
} }
// update the tags for the selected element
fun updateTags() { fun updateTags() {
println(cvTags.chips) println(cvTags.chips)
} }
// DetailView actions
fun cvSearchAction(tags: ObservableList<String>) { fun cvSearchAction(tags: ObservableList<String>) {
var previewList = arrayListOf<GUIModel>() var previewList = arrayListOf<GUIModel>()
@ -73,6 +67,8 @@ class MainViewController : Controller() {
} }
} }
fun btnImportAction() {
rootc.switchMainToImport()
}
} }