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

Display hide/show buttons in review mode #6808

Merged
merged 2 commits into from
Sep 6, 2023
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## \[Unreleased\]
### Added
- TDB
- Ability to hide/show an object in review mode (<https://github.com/opencv/cvat/pull/6808>)

### Changed
- \[Helm\] Database migrations now run in a separate job instead of the server pod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,13 @@ function ItemButtonsComponent(props: Props): JSX.Element {
<NavigateLastKeyframe {...props} />
</Col>
</Row>
{!readonly && (
{readonly ? (
<Row justify='space-around'>
<Col>
<SwitchHidden {...props} />
</Col>
</Row>
) : (
<Row justify='space-around'>
<Col>
<SwitchOutside {...props} />
Expand Down Expand Up @@ -284,47 +290,55 @@ function ItemButtonsComponent(props: Props): JSX.Element {
);
}

if (readonly) {
return <div />;
}

if (objectType === ObjectType.TAG) {
if (objectType === ObjectType.SHAPE) {
return (
<Row align='middle' justify='space-around'>
<Col span={20} style={{ textAlign: 'center' }}>
<Row justify='space-around'>
<Col>
<SwitchLock {...props} />
</Col>
</Row>
{ readonly ? (
<Row justify='space-around'>
<Col>
<SwitchHidden {...props} />
</Col>
</Row>
) : (
<Row justify='space-around'>
{ Number.isInteger(parentID) && (
<Col>
<SwitchOutside {...props} />
</Col>
)}
<Col>
<SwitchLock {...props} />
</Col>
<Col>
<SwitchOccluded {...props} />
</Col>
<Col>
<SwitchHidden {...props} />
</Col>
{shapeType !== ShapeType.POINTS && (
<Col>
<SwitchPinned {...props} />
</Col>
)}
</Row>
)}
</Col>
</Row>
);
}

if (readonly) {
return <div />;
}

return (
<Row align='middle' justify='space-around'>
<Col span={20} style={{ textAlign: 'center' }}>
<Row justify='space-around'>
{ Number.isInteger(parentID) && (
<Col>
<SwitchOutside {...props} />
</Col>
)}
<Col>
<SwitchLock {...props} />
</Col>
<Col>
<SwitchOccluded {...props} />
</Col>
<Col>
<SwitchHidden {...props} />
</Col>
{shapeType !== ShapeType.POINTS && (
<Col>
<SwitchPinned {...props} />
</Col>
)}
</Row>
</Col>
</Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,12 @@ function ObjectListHeader(props: Props): JSX.Element {
return (
<div className='cvat-objects-sidebar-states-header'>
<Row justify='space-between' align='middle'>
{!readonly && (
<>
<LockAllSwitcher {...props} />
<HideAllSwitcher {...props} />
</>
{!readonly && <LockAllSwitcher {...props} />}
<HideAllSwitcher {...props} />
{ workspace === Workspace.REVIEW_WORKSPACE && (
<GTSwitcher {...props} />
)}
<Row>
{ workspace === Workspace.REVIEW_WORKSPACE && (
<GTSwitcher {...props} />
)}
<CollapseAllSwitcher {...props} />
</Row>
<CollapseAllSwitcher {...props} />
<StatesOrderingSelector statesOrdering={statesOrdering} changeStatesOrdering={changeStatesOrdering} />
</Row>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,15 @@ class ItemButtonsWrapper extends React.PureComponent<StateToProps & DispatchToPr
};

private show = (): void => {
const { objectState, readonly } = this.props;
if (!readonly) {
objectState.hidden = false;
this.commit();
}
const { objectState } = this.props;
objectState.hidden = false;
this.commit();
};

private hide = (): void => {
const { objectState, readonly } = this.props;
if (!readonly) {
objectState.hidden = true;
this.commit();
}
const { objectState } = this.props;
objectState.hidden = true;
this.commit();
};

private setOccluded = (): void => {
Expand Down Expand Up @@ -210,11 +206,8 @@ class ItemButtonsWrapper extends React.PureComponent<StateToProps & DispatchToPr
};

private commit(): void {
const { objectState, readonly, updateAnnotations } = this.props;

if (!readonly) {
updateAnnotations([objectState]);
}
const { objectState, updateAnnotations } = this.props;
updateAnnotations([objectState]);
}

private changeFrame(frame: number): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,14 @@ class ObjectsListContainer extends React.PureComponent<Props, State> {
}

private hideAllStates(hidden: boolean): void {
const { updateAnnotations, readonly } = this.props;
const { updateAnnotations } = this.props;
const { filteredStates } = this.state;

if (!readonly) {
for (const objectState of filteredStates) {
objectState.hidden = hidden;
}

updateAnnotations(filteredStates);
for (const objectState of filteredStates) {
objectState.hidden = hidden;
}

updateAnnotations(filteredStates);
}

private collapseAllStates(collapsed: boolean): void {
Expand Down Expand Up @@ -416,14 +414,12 @@ class ObjectsListContainer extends React.PureComponent<Props, State> {
},
SWITCH_ALL_HIDDEN: (event: KeyboardEvent | undefined) => {
preventDefault(event);
if (!readonly) {
this.hideAllStates(!statesHidden);
}
this.hideAllStates(!statesHidden);
},
SWITCH_HIDDEN: (event: KeyboardEvent | undefined) => {
preventDefault(event);
const state = activatedState();
if (state && !readonly) {
if (state) {
state.hidden = !state.hidden;
updateAnnotations([state]);
}
Expand Down
Loading