-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Hide mask during editing #8554
Hide mask during editing #8554
Changes from 17 commits
b1b89e7
dc04778
65a13b2
0684a9a
c6aecf3
60005d0
a47e5e7
c7a2ac2
0b81b8b
dd28e80
2f8f8db
15d0c0b
58f970a
920dbc1
0610dd4
cc3a215
70b65cf
b662c37
8866cac
8ef68c9
bda9424
2548ed6
4a658ae
c05f45b
3c7d622
6b1c612
1770803
9ecfc2c
617569c
b908ccf
6ad833e
c00529c
6f06e91
56e6f0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
### Added | ||
|
||
- Feature to hide a mask during editing (<https://github.com/cvat-ai/cvat/pull/8554>) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,9 @@ export enum AnnotationActionTypes { | |
COLLAPSE_APPEARANCE = 'COLLAPSE_APPEARANCE', | ||
COLLAPSE_OBJECT_ITEMS = 'COLLAPSE_OBJECT_ITEMS', | ||
ACTIVATE_OBJECT = 'ACTIVATE_OBJECT', | ||
UPDATE_EDITED_STATE = 'UPDATE_EDITED_STATE', | ||
HIDE_EDITED_STATE = 'HIDE_EDITED_STATE', | ||
RESET_EDITED_STATE = 'RESET_EDITED_STATE', | ||
REMOVE_OBJECT = 'REMOVE_OBJECT', | ||
REMOVE_OBJECT_SUCCESS = 'REMOVE_OBJECT_SUCCESS', | ||
REMOVE_OBJECT_FAILED = 'REMOVE_OBJECT_FAILED', | ||
|
@@ -1608,3 +1611,84 @@ export function restoreFrameAsync(frame: number): ThunkAction { | |
} | ||
}; | ||
} | ||
|
||
export function updateEditedStateAsync( | ||
shapeType: ShapeType | null, | ||
editedStateInstance: ObjectState | null, | ||
): ThunkAction { | ||
return async (dispatch: ThunkDispatch, getState): Promise<void> => { | ||
if (editedStateInstance) { | ||
const state = getState(); | ||
const { instance: canvas } = state.annotation.canvas; | ||
if (canvas) { | ||
(canvas as Canvas).configure({ | ||
hideEditedObject: editedStateInstance.hidden, | ||
}); | ||
} | ||
|
||
dispatch({ | ||
type: AnnotationActionTypes.HIDE_EDITED_STATE, | ||
payload: { | ||
hide: editedStateInstance.hidden, | ||
}, | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we have three actions Probably we may combine them to reduce the code duplication. Let it accept There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Considering my general review comment it should only accept There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now we have two actions: |
||
dispatch({ | ||
type: AnnotationActionTypes.UPDATE_EDITED_STATE, | ||
payload: { | ||
shapeType, | ||
editedStateInstance, | ||
}, | ||
}); | ||
}; | ||
} | ||
|
||
export function resetEditedStateAsync(): ThunkAction { | ||
return async (dispatch: ThunkDispatch, getState): Promise<void> => { | ||
const state = getState(); | ||
const { instance: canvas } = state.annotation.canvas; | ||
const { editedStateHidden } = state.annotation.editing; | ||
if (canvas && editedStateHidden) { | ||
(canvas as Canvas).configure({ | ||
hideEditedObject: false, | ||
}); | ||
} | ||
|
||
dispatch({ | ||
type: AnnotationActionTypes.RESET_EDITED_STATE, | ||
payload: {}, | ||
}); | ||
klakhov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
} | ||
|
||
export function resetEditedState(): AnyAction { | ||
return { | ||
type: AnnotationActionTypes.RESET_EDITED_STATE, | ||
payload: {}, | ||
}; | ||
} | ||
|
||
export function changeHideEditedStateAsync(hide: boolean): ThunkAction { | ||
return async (dispatch: ThunkDispatch, getState): Promise<void> => { | ||
const state = getState(); | ||
const { instance: canvas } = state.annotation.canvas; | ||
if (canvas) { | ||
(canvas as Canvas).configure({ | ||
hideEditedObject: hide, | ||
}); | ||
|
||
dispatch({ | ||
type: AnnotationActionTypes.HIDE_EDITED_STATE, | ||
payload: { | ||
hide, | ||
}, | ||
}); | ||
|
||
const { editedStateInstance } = state.annotation.editing; | ||
if (editedStateInstance) { | ||
editedStateInstance.hidden = hide; | ||
await dispatch(updateAnnotationsAsync([editedStateInstance])); | ||
} | ||
} | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that creating a new object already hidden makes sense as it confuses the user
They press N and expect a new object to be appear, I think.
If the object is hidden, they may think that something is going wrong and start drawing it again (especially when there are a lot of objects in the sidebar, newly added is not visible in the list)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, maybe it is for new objects.
But what about edited ones? Should this hide feature affect state.hidden at all then?