mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): tidy naming of regional prompt utils
This commit is contained in:
parent
5924dc6ff6
commit
00737efc31
@ -6,9 +6,9 @@ import {
|
||||
BRUSH_PREVIEW_BORDER_OUTER_ID,
|
||||
BRUSH_PREVIEW_FILL_ID,
|
||||
BRUSH_PREVIEW_LAYER_ID,
|
||||
getPromptRegionLayerBboxId,
|
||||
getPromptRegionLayerObjectGroupId,
|
||||
getPromptRegionLayerTransparencyRectId,
|
||||
getLayerBboxId,
|
||||
getLayerObjectGroupId,
|
||||
getLayerTransparencyRectId,
|
||||
REGIONAL_PROMPT_LAYER_BBOX_NAME,
|
||||
REGIONAL_PROMPT_LAYER_LINE_NAME,
|
||||
REGIONAL_PROMPT_LAYER_NAME,
|
||||
@ -177,7 +177,7 @@ export const renderLayers = (
|
||||
|
||||
// The object group holds all of the layer's objects (e.g. lines and rects)
|
||||
const konvaObjectGroup = new Konva.Group({
|
||||
id: getPromptRegionLayerObjectGroupId(reduxLayer.id, uuidv4()),
|
||||
id: getLayerObjectGroupId(reduxLayer.id, uuidv4()),
|
||||
name: REGIONAL_PROMPT_LAYER_OBJECT_GROUP_NAME,
|
||||
listening: false,
|
||||
});
|
||||
@ -187,7 +187,7 @@ export const renderLayers = (
|
||||
// The brush strokes group functions as a mask for this rect, which has the layer's fill and opacity. The brush
|
||||
// strokes' color doesn't matter - the only requirement is that they are not transparent.
|
||||
const transparencyRect = new Konva.Rect({
|
||||
id: getPromptRegionLayerTransparencyRectId(reduxLayer.id),
|
||||
id: getLayerTransparencyRectId(reduxLayer.id),
|
||||
globalCompositeOperation: 'source-in',
|
||||
listening: false,
|
||||
});
|
||||
@ -210,7 +210,7 @@ export const renderLayers = (
|
||||
const konvaObjectGroup = konvaLayer.findOne<Konva.Group>(`.${REGIONAL_PROMPT_LAYER_OBJECT_GROUP_NAME}`);
|
||||
assert(konvaObjectGroup, `Object group not found for layer ${reduxLayer.id}`);
|
||||
const transparencyRect = konvaLayer.findOne<Konva.Rect>(
|
||||
`#${getPromptRegionLayerTransparencyRectId(reduxLayer.id)}`
|
||||
`#${getLayerTransparencyRectId(reduxLayer.id)}`
|
||||
);
|
||||
assert(transparencyRect, `Transparency rect not found for layer ${reduxLayer.id}`);
|
||||
|
||||
@ -307,7 +307,7 @@ export const renderBbox = (
|
||||
let rect = konvaLayer.findOne<Konva.Rect>(`.${REGIONAL_PROMPT_LAYER_BBOX_NAME}`);
|
||||
if (!rect) {
|
||||
rect = new Konva.Rect({
|
||||
id: getPromptRegionLayerBboxId(selectedLayerId),
|
||||
id: getLayerBboxId(selectedLayerId),
|
||||
name: REGIONAL_PROMPT_LAYER_BBOX_NAME,
|
||||
strokeWidth: 1,
|
||||
});
|
||||
|
@ -86,7 +86,7 @@ export const regionalPromptsSlice = createSlice({
|
||||
layerAdded: {
|
||||
reducer: (state, action: PayloadAction<Layer['kind'], string, { uuid: string; color: RgbColor }>) => {
|
||||
const layer: PromptRegionLayer = {
|
||||
id: getPromptRegionLayerId(action.meta.uuid),
|
||||
id: getLayerId(action.meta.uuid),
|
||||
isVisible: true,
|
||||
bbox: null,
|
||||
kind: action.payload,
|
||||
@ -194,7 +194,7 @@ export const regionalPromptsSlice = createSlice({
|
||||
if (!layer || layer.kind !== 'promptRegionLayer') {
|
||||
return;
|
||||
}
|
||||
const lineId = getPromptRegionLayerLineId(layer.id, action.meta.uuid);
|
||||
const lineId = getLayerLineId(layer.id, action.meta.uuid);
|
||||
layer.objects.push({
|
||||
kind: 'line',
|
||||
tool: state.tool,
|
||||
@ -303,17 +303,22 @@ export const getStage = (): Stage => {
|
||||
assert(stage);
|
||||
return stage;
|
||||
};
|
||||
|
||||
// IDs for singleton layers and objects
|
||||
export const BRUSH_PREVIEW_LAYER_ID = 'brushPreviewLayer';
|
||||
export const BRUSH_PREVIEW_FILL_ID = 'brushPreviewFill';
|
||||
export const BRUSH_PREVIEW_BORDER_INNER_ID = 'brushPreviewBorderInner';
|
||||
export const BRUSH_PREVIEW_BORDER_OUTER_ID = 'brushPreviewBorderOuter';
|
||||
|
||||
// Names (aka classes) for Konva layers and objects
|
||||
export const REGIONAL_PROMPT_LAYER_NAME = 'regionalPromptLayer';
|
||||
export const REGIONAL_PROMPT_LAYER_LINE_NAME = 'regionalPromptLayerLine';
|
||||
export const REGIONAL_PROMPT_LAYER_OBJECT_GROUP_NAME = 'regionalPromptLayerObjectGroup';
|
||||
export const REGIONAL_PROMPT_LAYER_BBOX_NAME = 'regionalPromptLayerBbox';
|
||||
export const getPromptRegionLayerId = (layerId: string) => `layer_${layerId}`;
|
||||
export const getPromptRegionLayerLineId = (layerId: string, lineId: string) => `${layerId}.line_${lineId}`;
|
||||
export const getPromptRegionLayerObjectGroupId = (layerId: string, groupId: string) =>
|
||||
`${layerId}.objectGroup_${groupId}`;
|
||||
export const getPromptRegionLayerBboxId = (layerId: string) => `${layerId}.bbox`;
|
||||
export const getPromptRegionLayerTransparencyRectId = (layerId: string) => `${layerId}.transparency_rect`;
|
||||
|
||||
// Getters for non-singleton layer and object IDs
|
||||
export const getLayerId = (layerId: string) => `layer_${layerId}`;
|
||||
export const getLayerLineId = (layerId: string, lineId: string) => `${layerId}.line_${lineId}`;
|
||||
export const getLayerObjectGroupId = (layerId: string, groupId: string) => `${layerId}.objectGroup_${groupId}`;
|
||||
export const getLayerBboxId = (layerId: string) => `${layerId}.bbox`;
|
||||
export const getLayerTransparencyRectId = (layerId: string) => `${layerId}.transparency_rect`;
|
||||
|
Loading…
Reference in New Issue
Block a user