Skip to content

Commit

Permalink
Fix visibility toggle to register toggle with sciview
Browse files Browse the repository at this point in the history
  • Loading branch information
kephale authored and skalarproduktraum committed Jul 2, 2024
1 parent 4b4bd8c commit 8eb605f
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/main/kotlin/sc/iview/ui/SwingNodePropertyEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,21 @@ class SwingNodePropertyEditor(private val sciView: SciView, val nodeSpecificProp
} else {
hideShow.text = "Show"
}
hideShow.addActionListener { _: ActionEvent? -> obj.node.visible = !obj.node.visible }
hideShow.addActionListener { _: ActionEvent? ->
val newVisibility = !obj.node.visible
obj.node.visible = newVisibility

// Notify SciView about the visibility change
sciView.requestPropEditorRefresh(obj.node)

// Publish a NodeChangedEvent
sciView.eventService.publish(NodeChangedEvent(obj.node))

// If the node is now invisible, deselect it
if (!newVisibility) {
sciView.setActiveNode(null)
}
}
popup.add(hideShow)
val removeItem = JMenuItem("Remove")
removeItem.foreground = Color.RED
Expand All @@ -244,7 +258,20 @@ class SwingNodePropertyEditor(private val sciView: SciView, val nodeSpecificProp
if (n != null) {
val node = n.node
if (node != null && node !is Camera && node !is Scene) {
node.visible = !node.visible
val newVisibility = !node.visible
node.visible = newVisibility

// Notify SciView about the visibility change
sciView.requestPropEditorRefresh(node)

// Publish a NodeChangedEvent
sciView.eventService.publish(NodeChangedEvent(node))

// If the node is now invisible, deselect it
if (!newVisibility) {
sciView.setActiveNode(null)
}

tree.repaint()
}
}
Expand Down Expand Up @@ -279,7 +306,7 @@ class SwingNodePropertyEditor(private val sciView: SciView, val nodeSpecificProp

/** Generates a properties panel for the given node. */
fun updateProperties(sceneNode: Node?, rebuild: Boolean = false) {
if (sceneNode == null) {
if (sceneNode == null || !sceneNode.visible) {
try {
if (updateLock.tryLock() || updateLock.tryLock(200, TimeUnit.MILLISECONDS)) {
updatePropertiesPanel(null)
Expand Down

0 comments on commit 8eb605f

Please sign in to comment.