refactor(ui): add scaled bbox state

This commit is contained in:
psychedelicious 2024-06-15 23:04:21 +10:00
parent 0833dbb19d
commit fdf347af26
2 changed files with 23 additions and 10 deletions

View File

@ -44,6 +44,11 @@ const initialState: CanvasV2State = {
width: 512, width: 512,
height: 512, height: 512,
}, },
scaledBbox: {
width: 512,
height: 512,
scaleMethod: 'auto',
},
controlAdapters: [], controlAdapters: [],
ipAdapters: [], ipAdapters: [],
regions: [], regions: [],

View File

@ -1,10 +1,7 @@
import { deepClone } from 'common/util/deepClone'; import { deepClone } from 'common/util/deepClone';
import { zModelIdentifierField } from 'features/nodes/types/common'; import { zModelIdentifierField } from 'features/nodes/types/common';
import type { AspectRatioState } from 'features/parameters/components/ImageSize/types'; import type { AspectRatioState } from 'features/parameters/components/ImageSize/types';
import type { import type { ParameterHeight, ParameterWidth } from 'features/parameters/types/parameterSchemas';
ParameterHeight,
ParameterWidth,
} from 'features/parameters/types/parameterSchemas';
import { import {
zAutoNegative, zAutoNegative,
zParameterNegativePrompt, zParameterNegativePrompt,
@ -748,9 +745,19 @@ export const imageDTOToImageWithDims = ({ image_name, width, height }: ImageDTO)
height, height,
}); });
const zBoundingBoxScaleMethod = z.enum(['none', 'auto', 'manual']);
export type BoundingBoxScaleMethod = z.infer<typeof zBoundingBoxScaleMethod>;
export const isBoundingBoxScaleMethod = (v: unknown): v is BoundingBoxScaleMethod =>
zBoundingBoxScaleMethod.safeParse(v).success;
export type CanvasEntity = LayerData | IPAdapterData | ControlAdapterData | RegionalGuidanceData | InpaintMaskData; export type CanvasEntity = LayerData | IPAdapterData | ControlAdapterData | RegionalGuidanceData | InpaintMaskData;
export type CanvasEntityIdentifier = Pick<CanvasEntity, 'id' | 'type'>; export type CanvasEntityIdentifier = Pick<CanvasEntity, 'id' | 'type'>;
export type Dimensions = {
width: number;
height: number;
};
export type CanvasV2State = { export type CanvasV2State = {
_version: 3; _version: 3;
selectedEntityIdentifier: CanvasEntityIdentifier | null; selectedEntityIdentifier: CanvasEntityIdentifier | null;
@ -758,12 +765,8 @@ export type CanvasV2State = {
selected: Tool; selected: Tool;
selectedBuffer: Tool | null; selectedBuffer: Tool | null;
invertScroll: boolean; invertScroll: boolean;
brush: { brush: { width: number };
width: number; eraser: { width: number };
};
eraser: {
width: number;
};
fill: RgbaColor; fill: RgbaColor;
}; };
document: { document: {
@ -772,6 +775,11 @@ export type CanvasV2State = {
aspectRatio: AspectRatioState; aspectRatio: AspectRatioState;
}; };
bbox: IRect; bbox: IRect;
scaledBbox: {
scaleMethod: BoundingBoxScaleMethod;
width: ParameterWidth;
height: ParameterHeight;
};
layers: LayerData[]; layers: LayerData[];
controlAdapters: ControlAdapterData[]; controlAdapters: ControlAdapterData[];
ipAdapters: IPAdapterData[]; ipAdapters: IPAdapterData[];