mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Update ViewportControls.tsx
This commit is contained in:
parent
32994a261a
commit
bc3aab93f1
@ -2,9 +2,18 @@ import { ButtonGroup } from '@chakra-ui/react';
|
|||||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||||
import IAIIconButton from 'common/components/IAIIconButton';
|
import IAIIconButton from 'common/components/IAIIconButton';
|
||||||
import { memo, useCallback } from 'react';
|
import { memo, useCallback } from 'react';
|
||||||
import { FaCode, FaExpand, FaMinus, FaPlus } from 'react-icons/fa';
|
import {
|
||||||
|
FaCode,
|
||||||
|
FaExpand,
|
||||||
|
FaMinus,
|
||||||
|
FaPlus,
|
||||||
|
FaGripVertical,
|
||||||
|
} from 'react-icons/fa';
|
||||||
import { useReactFlow } from 'reactflow';
|
import { useReactFlow } from 'reactflow';
|
||||||
import { shouldShowGraphOverlayChanged } from '../store/nodesSlice';
|
import {
|
||||||
|
shouldShowGraphOverlayChanged,
|
||||||
|
shouldShowFieldTypeLegendChanged,
|
||||||
|
} from '../store/nodesSlice';
|
||||||
|
|
||||||
const ViewportControls = () => {
|
const ViewportControls = () => {
|
||||||
const { zoomIn, zoomOut, fitView } = useReactFlow();
|
const { zoomIn, zoomOut, fitView } = useReactFlow();
|
||||||
@ -12,6 +21,9 @@ const ViewportControls = () => {
|
|||||||
const shouldShowGraphOverlay = useAppSelector(
|
const shouldShowGraphOverlay = useAppSelector(
|
||||||
(state) => state.nodes.shouldShowGraphOverlay
|
(state) => state.nodes.shouldShowGraphOverlay
|
||||||
);
|
);
|
||||||
|
const shouldShowFieldTypeLegend = useAppSelector(
|
||||||
|
(state) => state.nodes.shouldShowFieldTypeLegend
|
||||||
|
);
|
||||||
|
|
||||||
const handleClickedZoomIn = useCallback(() => {
|
const handleClickedZoomIn = useCallback(() => {
|
||||||
zoomIn();
|
zoomIn();
|
||||||
@ -29,6 +41,10 @@ const ViewportControls = () => {
|
|||||||
dispatch(shouldShowGraphOverlayChanged(!shouldShowGraphOverlay));
|
dispatch(shouldShowGraphOverlayChanged(!shouldShowGraphOverlay));
|
||||||
}, [shouldShowGraphOverlay, dispatch]);
|
}, [shouldShowGraphOverlay, dispatch]);
|
||||||
|
|
||||||
|
const handleClickedToggleFieldTypeLegend = useCallback(() => {
|
||||||
|
dispatch(shouldShowFieldTypeLegendChanged(!shouldShowFieldTypeLegend));
|
||||||
|
}, [shouldShowFieldTypeLegend, dispatch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ButtonGroup isAttached orientation="vertical">
|
<ButtonGroup isAttached orientation="vertical">
|
||||||
<IAIIconButton
|
<IAIIconButton
|
||||||
@ -52,6 +68,12 @@ const ViewportControls = () => {
|
|||||||
aria-label="Show/Hide Graph"
|
aria-label="Show/Hide Graph"
|
||||||
icon={<FaCode />}
|
icon={<FaCode />}
|
||||||
/>
|
/>
|
||||||
|
<IAIIconButton
|
||||||
|
isChecked={shouldShowFieldTypeLegend}
|
||||||
|
onClick={handleClickedToggleFieldTypeLegend}
|
||||||
|
aria-label="Show/Hide Field Type Legend"
|
||||||
|
icon={<FaGripVertical />}
|
||||||
|
/>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user