From da153091bd576e8f4a0e61eee1d301dca8bc73b1 Mon Sep 17 00:00:00 2001 From: Seil0 Date: Sat, 8 Jun 2019 12:25:20 +0200 Subject: [PATCH] highlight the selected element, closes #9 --- .../org/hso/texturesyncclient/model/GUIModel.kt | 11 +++++++++-- .../hso/texturesyncclient/model/GUIModelController.kt | 3 +++ .../hso/texturesyncclient/view/mainView/FolderView.kt | 6 +++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt index 72a540b..74edfa2 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt @@ -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) } diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModelController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModelController.kt index 49bdcac..ca6d150 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModelController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModelController.kt @@ -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) } diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/FolderView.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/FolderView.kt index f878dd0..5bf7ef3 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/FolderView.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/FolderView.kt @@ -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))