You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
// Copyright (C) 2020 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import React from 'react';
|
|
import Popover from 'antd/lib/popover';
|
|
import Icon from 'antd/lib/icon';
|
|
|
|
import { Canvas } from 'cvat-canvas-wrapper';
|
|
import { RectangleIcon } from 'icons';
|
|
import { ShapeType } from 'reducers/interfaces';
|
|
|
|
import DrawShapePopoverContainer from 'containers/annotation-page/standard-workspace/controls-side-bar/draw-shape-popover';
|
|
|
|
interface Props {
|
|
canvasInstance: Canvas;
|
|
isDrawing: boolean;
|
|
}
|
|
|
|
function DrawRectangleControl(props: Props): JSX.Element {
|
|
const { canvasInstance, isDrawing } = props;
|
|
|
|
const dynamcPopoverPros = isDrawing ? {
|
|
overlayStyle: {
|
|
display: 'none',
|
|
},
|
|
} : {};
|
|
|
|
const dynamicIconProps = isDrawing ? {
|
|
className: 'cvat-active-canvas-control',
|
|
onClick: (): void => {
|
|
canvasInstance.draw({ enabled: false });
|
|
},
|
|
} : {};
|
|
|
|
return (
|
|
<Popover
|
|
{...dynamcPopoverPros}
|
|
overlayClassName='cvat-draw-shape-popover'
|
|
placement='right'
|
|
content={(
|
|
<DrawShapePopoverContainer
|
|
shapeType={ShapeType.RECTANGLE}
|
|
/>
|
|
)}
|
|
>
|
|
<Icon
|
|
className='cvat-draw-rectangle-control'
|
|
{...dynamicIconProps}
|
|
component={RectangleIcon}
|
|
/>
|
|
</Popover>
|
|
);
|
|
}
|
|
|
|
export default React.memo(DrawRectangleControl);
|