Titles in attribute annotations mode

main
Boris Sekachev 6 years ago
parent 6d3b53876e
commit 609f0bd1e4

@ -226,6 +226,7 @@ function AttributeAnnotationSidebar(props: StateToProps & DispatchToProps): JSX.
occluded={activeObjectState.occluded} occluded={activeObjectState.occluded}
objectsCount={states.length} objectsCount={states.length}
currentIndex={states.indexOf(activeObjectState)} currentIndex={states.indexOf(activeObjectState)}
keyMap={keyMap}
nextObject={nextObject} nextObject={nextObject}
/> />
<ObjectBasicsEditor <ObjectBasicsEditor
@ -253,6 +254,7 @@ function AttributeAnnotationSidebar(props: StateToProps & DispatchToProps): JSX.
currentIndex={activeObjectState.label.attributes currentIndex={activeObjectState.label.attributes
.indexOf(activeAttribute)} .indexOf(activeAttribute)}
attributesCount={activeObjectState.label.attributes.length} attributesCount={activeObjectState.label.attributes.length}
keyMap={keyMap}
nextAttribute={nextAttribute} nextAttribute={nextAttribute}
/> />
<AttributeEditor <AttributeEditor

@ -3,15 +3,19 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import React from 'react'; import React from 'react';
import { ExtendedKeyMapOptions } from 'react-hotkeys';
import Icon from 'antd/lib/icon'; import Icon from 'antd/lib/icon';
import Text from 'antd/lib/typography/Text'; import Text from 'antd/lib/typography/Text';
import Tooltip from 'antd/lib/tooltip'; import Tooltip from 'antd/lib/tooltip';
import Button from 'antd/lib/button'; import Button from 'antd/lib/button';
import { formatShortcuts } from 'utils/shortcuts';
interface Props { interface Props {
currentAttribute: string; currentAttribute: string;
currentIndex: number; currentIndex: number;
attributesCount: number; attributesCount: number;
keyMap: Record<string, ExtendedKeyMapOptions>;
nextAttribute(step: number): void; nextAttribute(step: number): void;
} }
@ -21,21 +25,26 @@ function AttributeSwitcher(props: Props): JSX.Element {
currentIndex, currentIndex,
attributesCount, attributesCount,
nextAttribute, nextAttribute,
keyMap,
} = props; } = props;
const title = `${currentAttribute} [${currentIndex + 1}/${attributesCount}]`; const title = `${currentAttribute} [${currentIndex + 1}/${attributesCount}]`;
return ( return (
<div className='attribute-annotation-sidebar-switcher'> <div className='attribute-annotation-sidebar-switcher'>
<Button disabled={attributesCount <= 1} onClick={() => nextAttribute(-1)}> <Tooltip title={`Previous attribute ${formatShortcuts(keyMap.PREVIOUS_ATTRIBUTE)}`}>
<Icon type='left' /> <Button disabled={attributesCount <= 1} onClick={() => nextAttribute(-1)}>
</Button> <Icon type='left' />
</Button>
</Tooltip>
<Tooltip title={title}> <Tooltip title={title}>
<Text className='cvat-text'>{currentAttribute}</Text> <Text className='cvat-text'>{currentAttribute}</Text>
<Text strong>{` [${currentIndex + 1}/${attributesCount}]`}</Text> <Text strong>{` [${currentIndex + 1}/${attributesCount}]`}</Text>
</Tooltip> </Tooltip>
<Button disabled={attributesCount <= 1} onClick={() => nextAttribute(1)}> <Tooltip title={`Next attribute ${formatShortcuts(keyMap.NEXT_ATTRIBUTE)}`}>
<Icon type='right' /> <Button disabled={attributesCount <= 1} onClick={() => nextAttribute(1)}>
</Button> <Icon type='right' />
</Button>
</Tooltip>
</div> </div>
); );
} }

@ -3,17 +3,21 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
import React from 'react'; import React from 'react';
import { ExtendedKeyMapOptions } from 'react-hotkeys';
import Icon from 'antd/lib/icon'; import Icon from 'antd/lib/icon';
import Text from 'antd/lib/typography/Text'; import Text from 'antd/lib/typography/Text';
import Tooltip from 'antd/lib/tooltip'; import Tooltip from 'antd/lib/tooltip';
import Button from 'antd/lib/button'; import Button from 'antd/lib/button';
import { formatShortcuts } from 'utils/shortcuts';
interface Props { interface Props {
currentLabel: string; currentLabel: string;
clientID: number; clientID: number;
occluded: boolean; occluded: boolean;
objectsCount: number; objectsCount: number;
currentIndex: number; currentIndex: number;
keyMap: Record<string, ExtendedKeyMapOptions>;
nextObject(step: number): void; nextObject(step: number): void;
} }
@ -24,23 +28,28 @@ function ObjectSwitcher(props: Props): JSX.Element {
objectsCount, objectsCount,
currentIndex, currentIndex,
nextObject, nextObject,
keyMap,
} = props; } = props;
const title = `${currentLabel} ${clientID} [${currentIndex + 1}/${objectsCount}]`; const title = `${currentLabel} ${clientID} [${currentIndex + 1}/${objectsCount}]`;
return ( return (
<div className='attribute-annotation-sidebar-switcher'> <div className='attribute-annotation-sidebar-switcher'>
<Button disabled={objectsCount <= 1} onClick={() => nextObject(-1)}> <Tooltip title={`Previous object ${formatShortcuts(keyMap.PREVIOUS_OBJECT)}`}>
<Icon type='left' /> <Button disabled={objectsCount <= 1} onClick={() => nextObject(-1)}>
</Button> <Icon type='left' />
</Button>
</Tooltip>
<Tooltip title={title}> <Tooltip title={title}>
<Text className='cvat-text'>{currentLabel}</Text> <Text className='cvat-text'>{currentLabel}</Text>
<Text className='cvat-text'>{` ${clientID} `}</Text> <Text className='cvat-text'>{` ${clientID} `}</Text>
<Text strong>{`[${currentIndex + 1}/${objectsCount}]`}</Text> <Text strong>{`[${currentIndex + 1}/${objectsCount}]`}</Text>
</Tooltip> </Tooltip>
<Button disabled={objectsCount <= 1} onClick={() => nextObject(1)}> <Tooltip title={`Next object ${formatShortcuts(keyMap.NEXT_OBJECT)}`}>
<Icon type='right' /> <Button disabled={objectsCount <= 1} onClick={() => nextObject(1)}>
</Button> <Icon type='right' />
</Button>
</Tooltip>
</div> </div>
); );
} }

Loading…
Cancel
Save