Skip to content

Commit

Permalink
fix: navigation in shape interpolation working correctly
Browse files Browse the repository at this point in the history
when `super.enter()` is called for `ShapeInterpolationMode` it activates the `defaultTool` however, in `enter()` it was also switching to `shapeInterpolationTool` again, which caused it to `deactivate` shape interpolation as well. This caused the `ShapeInterpolationTool` to not be active immediately upon entering ShapeInterpolationMode. Solution is to no double-active the default tool
  • Loading branch information
cmhulbert committed Aug 14, 2024
1 parent f2e05c1 commit 2d77497
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ object NavigationTool : ViewerTool() {

fun scrollActions(translationController: TranslationController): ActionSet {
data class ScrollSpeedStruct(val name: String, val speed: Double, val keysInit: Action<ScrollEvent>.() -> Unit)
return painteraActionSet("scroll translate along normal", NavigationActionType.Slice) {
return painteraActionSet("scroll-translate-along-normal", NavigationActionType.Slice) {
listOf(
ScrollSpeedStruct("default", DEFAULT) { keysDown() },
ScrollSpeedStruct("fast", FAST) { keysDown(KeyCode.SHIFT) },
ScrollSpeedStruct("slow", SLOW) { keysDown(KeyCode.CONTROL) }
).map { (actionName, speed, keysInit) ->
ScrollEvent.SCROLL {
name = actionName
name = "${this@painteraActionSet.name}.$actionName"
onAction {
val delta = -ControlUtils.getBiggestScroll(it).sign * speed
translationController.translate(0.0, 0.0, delta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ class ShapeInterpolationMode<D : IntegerType<D>>(val controller: ShapeInterpolat
controller.apply {
if (!isControllerActive && source.currentMask == null && source.isApplyingMaskProperty.not().get()) {
modifyFragmentAlpha()
switchTool(shapeInterpolationTool)
enterShapeInterpolation(viewerAndTransforms.viewer())
shapeInterpolationTool.apply {
requestEmbedding(currentDepth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ abstract class ViewerTool(protected val mode: ToolMode? = null) : Tool, ToolBarI
fun removeFromAll() {
synchronized(this) {
installedInto.forEach { (node, actions) ->
LOG.debug { "removing $this" }
LOG.debug { "removing $this from all nodes" }
actions.removeIf { actionSet ->
node.removeActionSet(actionSet)
true
Expand All @@ -125,7 +125,7 @@ abstract class ViewerTool(protected val mode: ToolMode? = null) : Tool, ToolBarI
fun removeFrom(node: Node) {
synchronized(this) {
installedInto[node]?.let { actions ->
LOG.debug { "removing $this" }
LOG.debug { "removing $this from node $node" }
actions.removeIf { actionSet ->
node.removeActionSet(actionSet)
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal class ShapeInterpolationTool(
mutableListOf(
*shapeInterpolationActions().filterNotNull().toTypedArray(),
cancelShapeInterpolationTask(),
*NavigationTool.actionSets.filter { "rotat" !in it.name }.toTypedArray() //Kinda ugly to filter like this, but this is a weird case. Still, should do better
*NavigationTool.actionSets.toTypedArray() //Kinda ugly to filter like this, but this is a weird case. Still, should do better
)
}

Expand All @@ -71,8 +71,6 @@ internal class ShapeInterpolationTool(
disabledTranslationActions.forEach { disabledViewer.installActionSet(it) }
}
/* Activate, but we want to bind it to our activeViewer bindings instead of the default. */
NavigationTool.activate()
NavigationTool.activeViewerProperty.unbind()
NavigationTool.activeViewerProperty.bind(activeViewerProperty)
}

Expand Down

0 comments on commit 2d77497

Please sign in to comment.