Skip to content

Commit

Permalink
added undo and redo
Browse files Browse the repository at this point in the history
  • Loading branch information
hxhxhx88 committed Feb 3, 2024
1 parent 5430d79 commit 6911ff2
Show file tree
Hide file tree
Showing 3 changed files with 734 additions and 264 deletions.
14 changes: 14 additions & 0 deletions app/frontend/src/common/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ export function initialVertexBezier(vertexIndex: number, vertices: Vertex[]): No
};
}

export function getEntityCategory(
e: Entity,
category: string,
sliceIndex: SliceIndex | undefined = undefined
): string[] {
if (sliceIndex !== undefined) {
const val = e.sliceCategories?.[sliceIndex]?.[category];
return Object.keys(val ?? {});
}

const val = e.globalCategories?.[category];
return Object.keys(val ?? {});
}

export function setEntityCategory(
e: Entity,
category: string,
Expand Down
6 changes: 3 additions & 3 deletions app/frontend/src/component/panel/ActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const ActionBar: FC<Props> = ({...baseProps}) => {
const focusAreas = useFocusAreas(canvasSize);

// redo and undo
const {pastStates, futureStates, redo, undo} = useTemporalAnnoStore();
const {undoCount, redoCount, redo, undo} = useTemporalAnnoStore();

return (
<div {...baseProps}>
Expand Down Expand Up @@ -249,14 +249,14 @@ export const ActionBar: FC<Props> = ({...baseProps}) => {
helpCode="action.undo"
hotKey="⌘/⌃ + Z"
icon={<FontAwesomeIcon icon={faRotateLeft} />}
disabled={isDrawing || pastStates.length === 0}
disabled={isDrawing || undoCount === 0}
onClick={() => undo()}
/>
<ActionButton
helpCode="action.redo"
hotKey="⌘/⌃ + ⇧ + Z"
icon={<FontAwesomeIcon icon={faRotateRight} />}
disabled={isDrawing || futureStates.length === 0}
disabled={isDrawing || redoCount === 0}
onClick={() => redo()}
/>
<ActionButton
Expand Down
Loading

0 comments on commit 6911ff2

Please sign in to comment.