Skip to content

Commit 179565b

Browse files
committed
Fix bug with two layer visibility buttons
1 parent 4f967e7 commit 179565b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/main/kotlin/solve/settings/visualization/fields/view/VisualizationSettingsLayerCell.kt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class VisualizationSettingsLayerCell(
6868
if (layerType != LandmarkType.Plane) {
6969
add(createLayerEditButton(layerType))
7070
}
71-
add(createLayerVisibilityButton())
71+
add(createLayerVisibilityButtonNode() ?: return@hbox)
7272

7373
alignment = Pos.CENTER_LEFT
7474
paddingRight = LayerFieldHBoxPaddingRight
@@ -131,24 +131,28 @@ class VisualizationSettingsLayerCell(
131131
alignment = Pos.CENTER_RIGHT
132132
}
133133

134-
private fun createLayerVisibilityButton(): Node = hbox {
135-
layerVisibleIconImage ?: return@hbox
136-
layerInvisibleIconImage ?: return@hbox
134+
private fun createLayerVisibilityButtonNode(): Node? {
135+
layerVisibleIconImage ?: return null
136+
layerInvisibleIconImage ?: return null
137137
val layerVisibleImageViewIcon = imageViewIcon(layerVisibleIconImage, LayerVisibilityIconSize)
138138
val layerInvisibleImageViewIcon = imageViewIcon(layerInvisibleIconImage, LayerVisibilityIconSize)
139139

140-
fun getCurrentVisibilityImageViewIcon() =
141-
if (item.enabled) layerVisibleImageViewIcon else layerInvisibleImageViewIcon
140+
val layerVisibilityButtonNode = hbox {
141+
fun getCurrentVisibilityImageViewIcon() =
142+
if (item.enabled) layerVisibleImageViewIcon else layerInvisibleImageViewIcon
142143

143-
button {
144-
graphic = getCurrentVisibilityImageViewIcon()
145-
action {
146-
item.enabled = !item.enabled
144+
button {
147145
graphic = getCurrentVisibilityImageViewIcon()
146+
action {
147+
item.enabled = !item.enabled
148+
graphic = getCurrentVisibilityImageViewIcon()
149+
}
148150
}
151+
alignment = Pos.CENTER_RIGHT
152+
paddingLeft = LayerVisibilityIconPaddingLeft
149153
}
150-
alignment = Pos.CENTER_RIGHT
151-
paddingLeft = LayerVisibilityIconPaddingLeft
154+
155+
return layerVisibilityButtonNode
152156
}
153157

154158
private fun calculatePopOverShowPosition(spawnNode: Node, layerType: LandmarkType): DoublePoint {

0 commit comments

Comments
 (0)