Skip to content

Commit 8eb605f

Browse files
kephaleskalarproduktraum
authored andcommitted
Fix visibility toggle to register toggle with sciview
1 parent 4b4bd8c commit 8eb605f

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/main/kotlin/sc/iview/ui/SwingNodePropertyEditor.kt

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,21 @@ class SwingNodePropertyEditor(private val sciView: SciView, val nodeSpecificProp
230230
} else {
231231
hideShow.text = "Show"
232232
}
233-
hideShow.addActionListener { _: ActionEvent? -> obj.node.visible = !obj.node.visible }
233+
hideShow.addActionListener { _: ActionEvent? ->
234+
val newVisibility = !obj.node.visible
235+
obj.node.visible = newVisibility
236+
237+
// Notify SciView about the visibility change
238+
sciView.requestPropEditorRefresh(obj.node)
239+
240+
// Publish a NodeChangedEvent
241+
sciView.eventService.publish(NodeChangedEvent(obj.node))
242+
243+
// If the node is now invisible, deselect it
244+
if (!newVisibility) {
245+
sciView.setActiveNode(null)
246+
}
247+
}
234248
popup.add(hideShow)
235249
val removeItem = JMenuItem("Remove")
236250
removeItem.foreground = Color.RED
@@ -244,7 +258,20 @@ class SwingNodePropertyEditor(private val sciView: SciView, val nodeSpecificProp
244258
if (n != null) {
245259
val node = n.node
246260
if (node != null && node !is Camera && node !is Scene) {
247-
node.visible = !node.visible
261+
val newVisibility = !node.visible
262+
node.visible = newVisibility
263+
264+
// Notify SciView about the visibility change
265+
sciView.requestPropEditorRefresh(node)
266+
267+
// Publish a NodeChangedEvent
268+
sciView.eventService.publish(NodeChangedEvent(node))
269+
270+
// If the node is now invisible, deselect it
271+
if (!newVisibility) {
272+
sciView.setActiveNode(null)
273+
}
274+
248275
tree.repaint()
249276
}
250277
}
@@ -279,7 +306,7 @@ class SwingNodePropertyEditor(private val sciView: SciView, val nodeSpecificProp
279306

280307
/** Generates a properties panel for the given node. */
281308
fun updateProperties(sceneNode: Node?, rebuild: Boolean = false) {
282-
if (sceneNode == null) {
309+
if (sceneNode == null || !sceneNode.visible) {
283310
try {
284311
if (updateLock.tryLock() || updateLock.tryLock(200, TimeUnit.MILLISECONDS)) {
285312
updatePropertiesPanel(null)

0 commit comments

Comments
 (0)