Skip to content

Remember the forcefully disabled tool and reenable it if possible #6362

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

Merged
merged 6 commits into from
Aug 3, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released

### Added
- The owner of an annotation can allow other users, who may see the annotation, to also edit it. Note that parallel writes are not supported and would lead to conflicts. [#6236](https://github.com/scalableminds/webknossos/pull/6236)
- WebKnossos now remembers the tool that was active in between disabling and enabling the segmentation layer. [#6362](https://github.com/scalableminds/webknossos/pull/6362)
- Segmentation layers which were not previously editable now show an (un)lock icon button which shortcuts to the Add Volume Layer modal with the layer being preselected. [#6330](https://github.com/scalableminds/webknossos/pull/6330)
- The NML file in volume annotation download now includes segment metadata like names and anchor positions. [#6347](https://github.com/scalableminds/webknossos/pull/6347)

Expand Down
17 changes: 16 additions & 1 deletion frontend/javascripts/oxalis/view/action-bar/toolbar_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ export default function ToolbarView() {
const visibleSegmentationLayer = getVisibleSegmentationLayer(state);
return (visibleSegmentationLayer?.agglomerates?.length ?? 0) > 0;
});
const [lastForcefulDisabledTool, setLastForcefulDisabledTool] = useState<AnnotationTool | null>(
null,
);
const isVolumeModificationAllowed = useSelector(
(state: OxalisState) => !hasEditableMapping(state),
);
Expand Down Expand Up @@ -546,9 +549,21 @@ export default function ToolbarView() {
const disabledInfoForCurrentTool = disabledInfosForTools[activeTool];
useEffect(() => {
if (disabledInfoForCurrentTool.isDisabled) {
setLastForcefulDisabledTool(activeTool);
Store.dispatch(setToolAction(AnnotationToolEnum.MOVE));
} else if (
lastForcefulDisabledTool != null &&
!disabledInfosForTools[lastForcefulDisabledTool].isDisabled &&
activeTool === AnnotationToolEnum.MOVE
) {
// Reenable the tool that was disabled before.
setLastForcefulDisabledTool(null);
Store.dispatch(setToolAction(lastForcefulDisabledTool));
} else if (activeTool !== AnnotationToolEnum.MOVE) {
// Forget the last disabled tool as another tool besides the move tool was selected.
setLastForcefulDisabledTool(null);
}
}, [activeTool, disabledInfoForCurrentTool]);
}, [activeTool, disabledInfoForCurrentTool, lastForcefulDisabledTool]);
const isShiftPressed = useKeyPress("Shift");
const isControlPressed = useKeyPress("Control");
const isAltPressed = useKeyPress("Alt");
Expand Down