diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.json index e163194aa4..55d1256de2 100644 --- a/invokeai/frontend/web/public/locales/en.json +++ b/invokeai/frontend/web/public/locales/en.json @@ -1713,6 +1713,7 @@ "disableTransparencyEffect": "Disable Transparency Effect", "hidingType": "Hiding {{type}}", "showingType": "Showing {{type}}", + "dynamicGrid": "Dynamic Grid", "fill": { "fillStyle": "Fill Style", "solid": "Solid", @@ -1732,12 +1733,6 @@ "transform": "Transform", "eyeDropper": "Eye Dropper" }, - "background": { - "backgroundStyle": "Background Style", - "solid": "Solid", - "checkerboard": "Checkerboard", - "dynamicGrid": "Dynamic Grid" - }, "filter": { "filter": "Filter", "filters": "Filters", diff --git a/invokeai/frontend/web/src/features/controlLayers/components/CanvasSettingsBackgroundStyle.tsx b/invokeai/frontend/web/src/features/controlLayers/components/CanvasSettingsBackgroundStyle.tsx deleted file mode 100644 index 20ea323680..0000000000 --- a/invokeai/frontend/web/src/features/controlLayers/components/CanvasSettingsBackgroundStyle.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import type { ComboboxOnChange, ComboboxOption } from '@invoke-ai/ui-library'; -import { Combobox, FormControl, FormLabel } from '@invoke-ai/ui-library'; -import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; -import { canvasBackgroundStyleChanged } from 'features/controlLayers/store/canvasV2Slice'; -import { isCanvasBackgroundStyle } from 'features/controlLayers/store/types'; -import { memo, useCallback, useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; - -export const CanvasSettingsBackgroundStyle = memo(() => { - const { t } = useTranslation(); - const dispatch = useAppDispatch(); - const canvasBackgroundStyle = useAppSelector((s) => s.canvasV2.settings.canvasBackgroundStyle); - const onChange = useCallback( - (v) => { - if (!isCanvasBackgroundStyle(v?.value)) { - return; - } - dispatch(canvasBackgroundStyleChanged(v.value)); - }, - [dispatch] - ); - - const options = useMemo(() => { - return [ - { - value: 'solid', - label: t('controlLayers.background.solid'), - }, - { - value: 'checkerboard', - label: t('controlLayers.background.checkerboard'), - }, - { - value: 'dynamicGrid', - label: t('controlLayers.background.dynamicGrid'), - }, - ]; - }, [t]); - - const value = useMemo(() => options.find((o) => o.value === canvasBackgroundStyle), [options, canvasBackgroundStyle]); - - return ( - - {t('controlLayers.background.backgroundStyle')} - - - ); -}); - -CanvasSettingsBackgroundStyle.displayName = 'CanvasSettingsBackgroundStyle'; diff --git a/invokeai/frontend/web/src/features/controlLayers/components/CanvasSettingsDynamicGridToggle.tsx b/invokeai/frontend/web/src/features/controlLayers/components/CanvasSettingsDynamicGridToggle.tsx new file mode 100644 index 0000000000..916abc5574 --- /dev/null +++ b/invokeai/frontend/web/src/features/controlLayers/components/CanvasSettingsDynamicGridToggle.tsx @@ -0,0 +1,25 @@ +import { FormControl, FormLabel, Switch } from '@invoke-ai/ui-library'; +import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; +import { settingsDynamicGridToggled } from 'features/controlLayers/store/canvasV2Slice'; +import { memo, useCallback } from 'react'; +import { useTranslation } from 'react-i18next'; + +export const CanvasSettingsDynamicGridToggle = memo(() => { + const { t } = useTranslation(); + const dispatch = useAppDispatch(); + const dynamicGrid = useAppSelector((s) => s.canvasV2.settings.dynamicGrid); + const onChange = useCallback(() => { + dispatch(settingsDynamicGridToggled()); + }, [dispatch]); + + return ( + + + {t('controlLayers.dynamicGrid')} + + + + ); +}); + +CanvasSettingsDynamicGridToggle.displayName = 'CanvasSettingsDynamicGridToggle'; diff --git a/invokeai/frontend/web/src/features/controlLayers/components/ControlLayersSettingsPopover.tsx b/invokeai/frontend/web/src/features/controlLayers/components/ControlLayersSettingsPopover.tsx index 7e1191d2f1..58942034bc 100644 --- a/invokeai/frontend/web/src/features/controlLayers/components/ControlLayersSettingsPopover.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/components/ControlLayersSettingsPopover.tsx @@ -12,7 +12,7 @@ import { } from '@invoke-ai/ui-library'; import { useStore } from '@nanostores/react'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; -import { CanvasSettingsBackgroundStyle } from 'features/controlLayers/components/CanvasSettingsBackgroundStyle'; +import { CanvasSettingsDynamicGridToggle } from 'features/controlLayers/components/CanvasSettingsDynamicGridToggle'; import { $canvasManager } from 'features/controlLayers/konva/CanvasManager'; import { clipToBboxChanged, invertScrollChanged } from 'features/controlLayers/store/canvasV2Slice'; import type { ChangeEvent } from 'react'; @@ -67,7 +67,7 @@ const ControlLayersSettingsPopover = () => { {t('unifiedCanvas.clipToBbox')} - + diff --git a/invokeai/frontend/web/src/features/controlLayers/components/StageComponent.tsx b/invokeai/frontend/web/src/features/controlLayers/components/StageComponent.tsx index f374988277..48a1dbc9f0 100644 --- a/invokeai/frontend/web/src/features/controlLayers/components/StageComponent.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/components/StageComponent.tsx @@ -53,7 +53,7 @@ type Props = { }; export const StageComponent = memo(({ asPreview = false }: Props) => { - const canvasBackgroundStyle = useAppSelector((s) => s.canvasV2.settings.canvasBackgroundStyle); + const dynamicGrid = useAppSelector((s) => s.canvasV2.settings.dynamicGrid); const [stage] = useState( () => @@ -79,8 +79,8 @@ export const StageComponent = memo(({ asPreview = false }: Props) => { ); return ( - - {canvasBackgroundStyle === 'checkerboard' && ( + + {!dynamicGrid && ( { - if (!prevState || state.settings.canvasBackgroundStyle !== prevState.settings.canvasBackgroundStyle) { + if (!prevState || state.settings.dynamicGrid !== prevState.settings.dynamicGrid) { this.manager.background.render(); } }; diff --git a/invokeai/frontend/web/src/features/controlLayers/store/canvasV2Slice.ts b/invokeai/frontend/web/src/features/controlLayers/store/canvasV2Slice.ts index fd373c9bcf..7d6e19179f 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/canvasV2Slice.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/canvasV2Slice.ts @@ -89,7 +89,7 @@ const initialState: CanvasV2State = { showHUD: true, clipToBbox: false, cropToBboxOnSave: false, - canvasBackgroundStyle: 'checkerboard', + dynamicGrid: false, }, compositing: { maskBlur: 16, @@ -473,7 +473,7 @@ export const { allEntitiesDeleted, clipToBboxChanged, canvasReset, - canvasBackgroundStyleChanged, + settingsDynamicGridToggled, // All entities entitySelected, entityNameChanged, diff --git a/invokeai/frontend/web/src/features/controlLayers/store/settingsReducers.ts b/invokeai/frontend/web/src/features/controlLayers/store/settingsReducers.ts index 50870bfa4f..5001c2f06a 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/settingsReducers.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/settingsReducers.ts @@ -1,11 +1,11 @@ import type { PayloadAction, SliceCaseReducers } from '@reduxjs/toolkit'; -import type { CanvasBackgroundStyle, CanvasV2State } from 'features/controlLayers/store/types'; +import type { CanvasV2State } from 'features/controlLayers/store/types'; export const settingsReducers = { clipToBboxChanged: (state, action: PayloadAction) => { state.settings.clipToBbox = action.payload; }, - canvasBackgroundStyleChanged: (state, action: PayloadAction) => { - state.settings.canvasBackgroundStyle = action.payload; + settingsDynamicGridToggled: (state) => { + state.settings.dynamicGrid = !state.settings.dynamicGrid; }, } satisfies SliceCaseReducers; diff --git a/invokeai/frontend/web/src/features/controlLayers/store/types.ts b/invokeai/frontend/web/src/features/controlLayers/store/types.ts index d0d291ef13..8b483d7899 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/types.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/types.ts @@ -834,11 +834,6 @@ export type StagingAreaImage = { offsetY: number; }; -const zCanvasBackgroundStyle = z.enum(['checkerboard', 'dynamicGrid', 'solid']); -export type CanvasBackgroundStyle = z.infer; -export const isCanvasBackgroundStyle = (v: unknown): v is CanvasBackgroundStyle => - zCanvasBackgroundStyle.safeParse(v).success; - export type CanvasV2State = { _version: 3; selectedEntityIdentifier: CanvasEntityIdentifier | null; @@ -877,7 +872,7 @@ export type CanvasV2State = { preserveMaskedArea: boolean; cropToBboxOnSave: boolean; clipToBbox: boolean; - canvasBackgroundStyle: CanvasBackgroundStyle; + dynamicGrid: boolean; }; bbox: { rect: {