Skip to content

Commit ea2320c

Browse files
feat(ui): add button ref image layer empty state to pull bbox
1 parent 0ad0016 commit ea2320c

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

invokeai/frontend/web/public/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@
19111911
"resetGenerationSettings": "Reset Generation Settings",
19121912
"replaceCurrent": "Replace Current",
19131913
"controlLayerEmptyState": "<UploadButton>Upload an image</UploadButton>, drag an image from the <GalleryButton>gallery</GalleryButton> onto this layer, or draw on the canvas to get started.",
1914-
"referenceImageEmptyState": "<UploadButton>Upload an image</UploadButton> or drag an image from the <GalleryButton>gallery</GalleryButton> onto this layer to get started.",
1914+
"referenceImageEmptyState": "<UploadButton>Upload an image</UploadButton>, drag an image from the <GalleryButton>gallery</GalleryButton> onto this layer, or <PullBboxButton>pull the bounding box into this layer</PullBboxButton> to get started.",
19151915
"warnings": {
19161916
"problemsFound": "Problems found",
19171917
"unsupportedModel": "layer not supported for selected base model",

invokeai/frontend/web/src/features/controlLayers/components/IPAdapter/IPAdapterSettingsEmptyState.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Button, Flex, Text } from '@invoke-ai/ui-library';
22
import { useAppDispatch } from 'app/store/storeHooks';
33
import { useImageUploadButton } from 'common/hooks/useImageUploadButton';
44
import { useEntityIdentifierContext } from 'features/controlLayers/contexts/EntityIdentifierContext';
5+
import { usePullBboxIntoGlobalReferenceImage } from 'features/controlLayers/hooks/saveCanvasHooks';
56
import { useCanvasIsBusy } from 'features/controlLayers/hooks/useCanvasIsBusy';
67
import type { SetGlobalReferenceImageDndTargetData } from 'features/dnd/dnd';
78
import { setGlobalReferenceImageDndTarget } from 'features/dnd/dnd';
@@ -27,6 +28,7 @@ export const IPAdapterSettingsEmptyState = memo(() => {
2728
const onClickGalleryButton = useCallback(() => {
2829
dispatch(activeTabCanvasRightPanelChanged('gallery'));
2930
}, [dispatch]);
31+
const pullBboxIntoIPAdapter = usePullBboxIntoGlobalReferenceImage(entityIdentifier);
3032

3133
const dndTargetData = useMemo<SetGlobalReferenceImageDndTargetData>(
3234
() => setGlobalReferenceImageDndTarget.getData({ entityIdentifier }),
@@ -41,8 +43,11 @@ export const IPAdapterSettingsEmptyState = memo(() => {
4143
GalleryButton: (
4244
<Button onClick={onClickGalleryButton} isDisabled={isBusy} size="sm" variant="link" color="base.300" />
4345
),
46+
PullBboxButton: (
47+
<Button onClick={pullBboxIntoIPAdapter} isDisabled={isBusy} size="sm" variant="link" color="base.300" />
48+
),
4449
}),
45-
[isBusy, onClickGalleryButton, uploadApi]
50+
[isBusy, onClickGalleryButton, pullBboxIntoIPAdapter, uploadApi]
4651
);
4752

4853
return (

invokeai/frontend/web/src/features/controlLayers/components/RegionalGuidance/RegionalGuidanceIPAdapterSettingsEmptyState.tsx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Button, Flex, IconButton, Spacer, Text } from '@invoke-ai/ui-library';
22
import { useAppDispatch } from 'app/store/storeHooks';
33
import { useImageUploadButton } from 'common/hooks/useImageUploadButton';
44
import { useEntityIdentifierContext } from 'features/controlLayers/contexts/EntityIdentifierContext';
5+
import { usePullBboxIntoRegionalGuidanceReferenceImage } from 'features/controlLayers/hooks/saveCanvasHooks';
56
import { useCanvasIsBusy } from 'features/controlLayers/hooks/useCanvasIsBusy';
67
import { rgIPAdapterDeleted } from 'features/controlLayers/store/canvasSlice';
78
import type { SetRegionalGuidanceReferenceImageDndTargetData } from 'features/dnd/dnd';
@@ -36,6 +37,7 @@ export const RegionalGuidanceIPAdapterSettingsEmptyState = memo(({ referenceImag
3637
const onDeleteIPAdapter = useCallback(() => {
3738
dispatch(rgIPAdapterDeleted({ entityIdentifier, referenceImageId }));
3839
}, [dispatch, entityIdentifier, referenceImageId]);
40+
const pullBboxIntoIPAdapter = usePullBboxIntoRegionalGuidanceReferenceImage(entityIdentifier, referenceImageId);
3941

4042
const dndTargetData = useMemo<SetRegionalGuidanceReferenceImageDndTargetData>(
4143
() =>
@@ -46,6 +48,21 @@ export const RegionalGuidanceIPAdapterSettingsEmptyState = memo(({ referenceImag
4648
[entityIdentifier, referenceImageId]
4749
);
4850

51+
const components = useMemo(
52+
() => ({
53+
UploadButton: (
54+
<Button isDisabled={isBusy} size="sm" variant="link" color="base.300" {...uploadApi.getUploadButtonProps()} />
55+
),
56+
GalleryButton: (
57+
<Button onClick={onClickGalleryButton} isDisabled={isBusy} size="sm" variant="link" color="base.300" />
58+
),
59+
PullBboxButton: (
60+
<Button onClick={pullBboxIntoIPAdapter} isDisabled={isBusy} size="sm" variant="link" color="base.300" />
61+
),
62+
}),
63+
[isBusy, onClickGalleryButton, pullBboxIntoIPAdapter, uploadApi]
64+
);
65+
4966
return (
5067
<Flex flexDir="column" gap={2} position="relative" w="full">
5168
<Flex alignItems="center" gap={2}>
@@ -66,23 +83,7 @@ export const RegionalGuidanceIPAdapterSettingsEmptyState = memo(({ referenceImag
6683
</Flex>
6784
<Flex alignItems="center" gap={2} p={4}>
6885
<Text textAlign="center" color="base.300">
69-
<Trans
70-
i18nKey="controlLayers.referenceImageEmptyState"
71-
components={{
72-
UploadButton: (
73-
<Button
74-
isDisabled={isBusy}
75-
size="sm"
76-
variant="link"
77-
color="base.300"
78-
{...uploadApi.getUploadButtonProps()}
79-
/>
80-
),
81-
GalleryButton: (
82-
<Button onClick={onClickGalleryButton} isDisabled={isBusy} size="sm" variant="link" color="base.300" />
83-
),
84-
}}
85-
/>
86+
<Trans i18nKey="controlLayers.referenceImageEmptyState" components={components} />
8687
</Text>
8788
</Flex>
8889
<input {...uploadApi.getUploadInputProps()} />

0 commit comments

Comments
 (0)