Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visibility toggle to register toggle with sciview #599

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/kotlin/sc/iview/SciView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class SciView : SceneryBase, CalibratedRealInterval<CalibratedAxis> {
private lateinit var io: IOService

@Parameter
private lateinit var eventService: EventService
internal lateinit var eventService: EventService

@Parameter
private lateinit var lutService: LUTService
Expand Down
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
Loading