Skip to content

Commit

Permalink
Added more cursor icons
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev committed Feb 6, 2020
1 parent 787e7bc commit a141ea0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 12 additions & 0 deletions cvat-canvas/src/typescript/canvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,25 +754,37 @@ export class CanvasViewImpl implements CanvasView, Listener {
} else if (reason === UpdateReasons.DRAW) {
const data: DrawData = this.controller.drawData;
if (data.enabled) {
this.canvas.style.cursor = 'crosshair';
this.mode = Mode.DRAW;
} else {
this.canvas.style.cursor = '';
}
this.drawHandler.draw(data, this.geometry);
} else if (reason === UpdateReasons.MERGE) {
const data: MergeData = this.controller.mergeData;
if (data.enabled) {
this.canvas.style.cursor = 'copy';
this.mode = Mode.MERGE;
} else {
this.canvas.style.cursor = '';
}
this.mergeHandler.merge(data);
} else if (reason === UpdateReasons.SPLIT) {
const data: SplitData = this.controller.splitData;
if (data.enabled) {
this.canvas.style.cursor = 'copy';
this.mode = Mode.SPLIT;
} else {
this.canvas.style.cursor = '';
}
this.splitHandler.split(data);
} else if (reason === UpdateReasons.GROUP) {
const data: GroupData = this.controller.groupData;
if (data.enabled) {
this.canvas.style.cursor = 'copy';
this.mode = Mode.GROUP;
} else {
this.canvas.style.cursor = '';
}
this.groupHandler.group(data);
} else if (reason === UpdateReasons.SELECT) {
Expand Down
11 changes: 7 additions & 4 deletions cvat-canvas/src/typescript/splitHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export class SplitHandlerImpl implements SplitHandler {
private release(): void {
if (this.initialized) {
this.resetShape();
this.canvas.node.removeEventListener('mousemove', this.onFindObject);
this.canvas.node.removeEventListener('mousemove', this.findObject);
this.initialized = false;
}
}

private initSplitting(): void {
this.canvas.node.addEventListener('mousemove', this.onFindObject);
this.canvas.node.addEventListener('mousemove', this.findObject);
this.initialized = true;
this.splitDone = false;
}
Expand All @@ -47,6 +47,11 @@ export class SplitHandlerImpl implements SplitHandler {
this.release();
}

private findObject = (e: MouseEvent): void => {
this.resetShape();
this.onFindObject(e);
};

public constructor(
onSplitDone: (object: any) => void,
onFindObject: (event: MouseEvent) => void,
Expand Down Expand Up @@ -83,8 +88,6 @@ export class SplitHandlerImpl implements SplitHandler {
once: true,
});
}
} else {
this.resetShape();
}
}

Expand Down

0 comments on commit a141ea0

Please sign in to comment.