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

change cursor according to annotation tool #6132

Merged
merged 24 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3be92bd
change cursor according to annotation tool
Dagobert42 Mar 31, 2022
6adad36
update cursor icons
Dagobert42 Apr 1, 2022
d9ac9ac
Merge branch 'master' into change-cursor-according-to-tool
Dagobert42 Apr 6, 2022
48cffa1
update click positions
Dagobert42 Apr 6, 2022
07b490a
pretty
Dagobert42 Apr 6, 2022
362c566
fix cursor switches to auto from Bounding Box tool to Move tool
Dagobert42 Apr 6, 2022
2b1eb9d
fix CI tests
Dagobert42 Apr 6, 2022
c5e4e18
fix CI tests 2
Dagobert42 Apr 6, 2022
5815f24
Merge branch 'master' into change-cursor-according-to-tool
Dagobert42 Apr 13, 2022
9f65696
add new icons for testing
Dagobert42 Apr 13, 2022
e1d71d9
pretty
Dagobert42 Apr 13, 2022
11da035
edit trace tool icons
Dagobert42 Apr 13, 2022
bdd92ea
adjust click positions
Dagobert42 Apr 13, 2022
0695f80
Merge branch 'master' into change-cursor-according-to-tool
Dagobert42 Apr 13, 2022
9b62631
convert InputCatcher to function
Dagobert42 Apr 20, 2022
13a7e74
Merge branch 'master' into change-cursor-according-to-tool
Dagobert42 Apr 20, 2022
71c6454
Merge branch 'master' into change-cursor-according-to-tool
Dagobert42 Apr 20, 2022
0cda5bf
remove unused prop
Dagobert42 Apr 20, 2022
cd245de
extract dict to module level
Dagobert42 Apr 20, 2022
dc8d80a
pretty
Dagobert42 Apr 20, 2022
f62d152
Merge branch 'master' into change-cursor-according-to-tool
Dagobert42 Apr 20, 2022
a4d9290
Merge branch 'master' of github.com:scalableminds/webknossos into cha…
philippotto Apr 20, 2022
8ffaeda
Merge branch 'master' into change-cursor-according-to-tool
Dagobert42 Apr 20, 2022
ab90e33
edit changelog
Dagobert42 Apr 21, 2022
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 @@ -13,6 +13,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
### Added

### Changed
- The mouse cursor now changes appearance to indicate the currently selected annotation tool [#6132](https://github.com/scalableminds/webknossos/pull/6132)
- Various changes to the Dataset table in the dashboard [#6131](https://github.com/scalableminds/webknossos/pull/6131):
- Renamed "Allowed Teams" column to "Access Permissions".
- Add filter functionality to "Access Permissions" column to filter for public datasets.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export const highlightAndSetCursorOnHoveredBoundingBox = _.throttle(
getSceneController().highlightUserBoundingBox(null);

if (inputCatcher != null) {
inputCatcher.style.cursor = "auto";
inputCatcher.style.cursor = "move";
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import type { ModifierKeys } from "libs/input";
import type { OrthoView, Point2, ShowContextMenuFunction, AnnotationTool } from "oxalis/constants";
import {
OrthoViews,
ContourModeEnum,
AnnotationToolEnum,
OrthoViewValuesWithoutTDView,
} from "oxalis/constants";
import { OrthoViews, ContourModeEnum, AnnotationToolEnum } from "oxalis/constants";
import {
enforceActiveVolumeTracing,
getContourTracingMode,
Expand Down Expand Up @@ -619,15 +614,6 @@ export class BoundingBoxTool {
if (body == null) {
return;
}

for (const planeId of OrthoViewValuesWithoutTDView) {
const inputCatcher = document.getElementById(`inputcatcher_${planeId}`);

if (inputCatcher) {
inputCatcher.style.cursor = "auto";
}
}

getSceneController().highlightUserBoundingBox(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ export default function ToolbarView() {
className="fas fa-fill-drip"
style={{
opacity: disabledInfosForTools[AnnotationToolEnum.FILL_CELL].isDisabled ? 0.5 : 1,
transform: "scaleX(-1)",
}}
/>
{adaptedActiveTool === AnnotationToolEnum.FILL_CELL
Expand Down
117 changes: 73 additions & 44 deletions frontend/javascripts/oxalis/view/input_catcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ import { ArbitraryViewport } from "oxalis/constants";
import { setInputCatcherRects } from "oxalis/model/actions/view_mode_actions";
import Scalebar from "oxalis/view/scalebar";
import ViewportStatusIndicator from "oxalis/view/viewport_status_indicator";
import type { BusyBlockingInfo } from "oxalis/store";
import type { BusyBlockingInfo, OxalisState } from "oxalis/store";
import Store from "oxalis/store";
import makeRectRelativeToCanvas from "oxalis/view/layouting/layout_canvas_adapter";
import { waitForCondition } from "libs/utils";
import { useKeyPress } from "libs/react_hooks";
import { useEffect, useRef } from "react";
import { useSelector } from "react-redux";
import { adaptActiveToolToShortcuts } from "oxalis/model/accessors/tool_accessor";

const emptyViewportRect = {
top: 0,
left: 0,
width: 0,
height: 0,
};
type Props = {
viewportID: Viewport;
children?: React.ReactNode;
displayScalebars?: boolean;
busyBlockingInfo: BusyBlockingInfo;
};

function ignoreContextMenu(event: React.SyntheticEvent) {
function ignoreContextMenu(event: React.MouseEvent) {
// hide contextmenu, while rightclicking a canvas
event.preventDefault();
}
Expand Down Expand Up @@ -85,47 +84,77 @@ export function recalculateInputCatcherSizes() {
Store.dispatch(setInputCatcherRects(viewportRects));
}

class InputCatcher extends React.PureComponent<Props, {}> {
domElement: HTMLElement | null | undefined;
const cursorForTool = {
MOVE: "move",
SKELETON: "crosshair",
BRUSH: "url(/assets/images/paint-brush-solid-border.svg) 0 10,auto",
ERASE_BRUSH: "url(/assets/images/eraser-solid-border.svg) 0 8,auto",
TRACE: "url(/assets/images/lasso-pointed-solid-border.svg) 0 14,auto",
ERASE_TRACE: "url(/assets/images/eraser-pointed-solid-border.svg) 0 16,auto",
FILL_CELL: "url(/assets/images/fill-pointed-solid-border.svg) 0 16,auto",
PICK_CELL: "url(/assets/images/eye-dropper-solid-border.svg) 0 12,auto",
BOUNDING_BOX: "move",
};

componentDidMount() {
if (this.domElement) {
renderedInputCatchers.set(this.props.viewportID, this.domElement);
function InputCatcher({
viewportID,
children,
displayScalebars,
busyBlockingInfo,
}: {
viewportID: Viewport;
children?: React.ReactNode;
displayScalebars?: boolean;
busyBlockingInfo: BusyBlockingInfo;
}) {
const domElementRef = useRef<HTMLElement | null>(null);
useEffect(() => {
if (domElementRef.current) {
renderedInputCatchers.set(viewportID, domElementRef.current);
}
}
return () => {
if (domElementRef.current) {
renderedInputCatchers.delete(viewportID);
}
};
}, []);

componentWillUnmount() {
if (this.domElement) {
renderedInputCatchers.delete(this.props.viewportID);
}
}
const activeTool = useSelector((state: OxalisState) => state.uiInformation.activeTool);

const isShiftPressed = useKeyPress("Shift");
const isControlPressed = useKeyPress("Control");
const isAltPressed = useKeyPress("Alt");

render() {
const { viewportID } = this.props;
return (
<div className="flexlayout-dont-overflow">
<div
id={`inputcatcher_${viewportID}`}
ref={(domElement) => {
this.domElement = domElement;
}}
onContextMenu={ignoreContextMenu}
data-value={viewportID}
className={`inputcatcher ${viewportID}`}
style={{
position: "relative",
cursor: this.props.busyBlockingInfo.isBusy ? "wait" : "auto",
}}
>
<ViewportStatusIndicator />
{this.props.displayScalebars && viewportID !== "arbitraryViewport" ? (
<Scalebar viewportID={viewportID} />
) : null}
{this.props.children}
</div>
const adaptedTool = adaptActiveToolToShortcuts(
activeTool,
isShiftPressed,
isControlPressed,
isAltPressed,
);

return (
<div className="flexlayout-dont-overflow">
<div
id={`inputcatcher_${viewportID}`}
ref={(domElement) => {
domElementRef.current = domElement;
}}
onContextMenu={ignoreContextMenu}
data-value={viewportID}
className={`inputcatcher ${viewportID}`}
style={{
position: "relative",
cursor: busyBlockingInfo.isBusy ? "wait" : cursorForTool[adaptedTool],
}}
>
<ViewportStatusIndicator />
{displayScalebars && viewportID !== "arbitraryViewport" ? (
<Scalebar viewportID={viewportID} />
) : null}
{children}
</div>
);
}
</div>
);
}

export default InputCatcher;
12 changes: 12 additions & 0 deletions public/images/eraser-pointed-solid-border.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/images/eraser-solid-border.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/images/eye-dropper-solid-border.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading