highlight the selected element, closes #9

This commit is contained in:
Jannik 2019-06-08 12:25:20 +02:00
parent 9200e9277a
commit da153091bd
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
3 changed files with 15 additions and 5 deletions

View File

@ -25,11 +25,18 @@ class GUIModel constructor(var data: Texture, img: Image) : VBox(){
private val gmc = find(GUIModelController::class)
init {
//super.setPadding(Insets(10.0, 10.0, 10.0, 10.0))
super.setPadding(Insets(5.0, 5.0, 5.0, 5.0))
super.getChildren().addAll(image, label)
super.setOnContextMenuRequested { p0 -> contextMenu.show(this@GUIModel, p0.screenX, p0.screenY) }
super.setOnMouseClicked{
//this.background = Background(BackgroundFill(Paint.valueOf("#42adaf"), CornerRadii.EMPTY, Insets.EMPTY))
if (gmc.isLastSelectedInitialized()) {
gmc.lastSelected.background = Background.EMPTY
this.background = Background(BackgroundFill(Paint.valueOf("#42adaf"), CornerRadii.EMPTY, Insets.EMPTY))
gmc.lastSelected = this
} else {
this.background = Background(BackgroundFill(Paint.valueOf("#42adaf"), CornerRadii.EMPTY, Insets.EMPTY))
gmc.lastSelected = this
}
gmc.previewSelectedAction(data)
}

View File

@ -7,6 +7,9 @@ class GUIModelController: Controller() {
private val rootc = find(RootController::class)
lateinit var lastSelected: GUIModel
fun isLastSelectedInitialized() = ::lastSelected.isInitialized
fun export(data: Texture) {
rootc.exportTexture(data)
}

View File

@ -10,9 +10,9 @@ import tornadofx.*
class FolderView : View("FolderView"){
override val root = flowpane {
hgap = 15.0
vgap = 15.0
paddingAll = 12.0
hgap = 5.0
vgap = 5.0
paddingAll = 10.0
prefWidth = 732.0
prefHeight = 401.0
background = Background(BackgroundFill(Paint.valueOf("#cfcfcf"), CornerRadii.EMPTY, Insets.EMPTY))