mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): clean up action names
This commit is contained in:
parent
58d3a9e7d4
commit
cfddbda578
@ -5,8 +5,8 @@ import {
|
|||||||
$isMouseDown,
|
$isMouseDown,
|
||||||
$isMouseOver,
|
$isMouseOver,
|
||||||
$tool,
|
$tool,
|
||||||
lineAdded,
|
maskLayerLineAdded,
|
||||||
pointsAddedToLastLine,
|
maskLayerPointsAdded,
|
||||||
} from 'features/regionalPrompts/store/regionalPromptsSlice';
|
} from 'features/regionalPrompts/store/regionalPromptsSlice';
|
||||||
import type Konva from 'konva';
|
import type Konva from 'konva';
|
||||||
import type { KonvaEventObject } from 'konva/lib/Node';
|
import type { KonvaEventObject } from 'konva/lib/Node';
|
||||||
@ -64,7 +64,7 @@ export const useMouseEvents = () => {
|
|||||||
// const tool = getTool();
|
// const tool = getTool();
|
||||||
if (tool === 'brush' || tool === 'eraser') {
|
if (tool === 'brush' || tool === 'eraser') {
|
||||||
dispatch(
|
dispatch(
|
||||||
lineAdded({
|
maskLayerLineAdded({
|
||||||
layerId: selectedLayerId,
|
layerId: selectedLayerId,
|
||||||
points: [Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.x), Math.floor(pos.y)],
|
points: [Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.x), Math.floor(pos.y)],
|
||||||
tool,
|
tool,
|
||||||
@ -101,7 +101,7 @@ export const useMouseEvents = () => {
|
|||||||
}
|
}
|
||||||
// const tool = getTool();
|
// const tool = getTool();
|
||||||
if (getIsFocused(stage) && $isMouseOver.get() && $isMouseDown.get() && (tool === 'brush' || tool === 'eraser')) {
|
if (getIsFocused(stage) && $isMouseOver.get() && $isMouseDown.get() && (tool === 'brush' || tool === 'eraser')) {
|
||||||
dispatch(pointsAddedToLastLine({ layerId: selectedLayerId, point: [Math.floor(pos.x), Math.floor(pos.y)] }));
|
dispatch(maskLayerPointsAdded({ layerId: selectedLayerId, point: [Math.floor(pos.x), Math.floor(pos.y)] }));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[dispatch, selectedLayerId, tool]
|
[dispatch, selectedLayerId, tool]
|
||||||
@ -140,7 +140,7 @@ export const useMouseEvents = () => {
|
|||||||
}
|
}
|
||||||
if (tool === 'brush' || tool === 'eraser') {
|
if (tool === 'brush' || tool === 'eraser') {
|
||||||
dispatch(
|
dispatch(
|
||||||
lineAdded({
|
maskLayerLineAdded({
|
||||||
layerId: selectedLayerId,
|
layerId: selectedLayerId,
|
||||||
points: [Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.x), Math.floor(pos.y)],
|
points: [Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.x), Math.floor(pos.y)],
|
||||||
tool,
|
tool,
|
||||||
|
@ -92,7 +92,7 @@ export const regionalPromptsSlice = createSlice({
|
|||||||
name: 'regionalPrompts',
|
name: 'regionalPrompts',
|
||||||
initialState: initialRegionalPromptsState,
|
initialState: initialRegionalPromptsState,
|
||||||
reducers: {
|
reducers: {
|
||||||
//#region Meta Layer
|
//#region Any Layers
|
||||||
layerAdded: {
|
layerAdded: {
|
||||||
reducer: (state, action: PayloadAction<Layer['kind'], string, { uuid: string }>) => {
|
reducer: (state, action: PayloadAction<Layer['kind'], string, { uuid: string }>) => {
|
||||||
const kind = action.payload;
|
const kind = action.payload;
|
||||||
@ -166,10 +166,6 @@ export const regionalPromptsSlice = createSlice({
|
|||||||
state.layers = state.layers.filter((l) => l.id !== action.payload);
|
state.layers = state.layers.filter((l) => l.id !== action.payload);
|
||||||
state.selectedLayerId = state.layers[0]?.id ?? null;
|
state.selectedLayerId = state.layers[0]?.id ?? null;
|
||||||
},
|
},
|
||||||
allLayersDeleted: (state) => {
|
|
||||||
state.layers = [];
|
|
||||||
state.selectedLayerId = null;
|
|
||||||
},
|
|
||||||
layerMovedForward: (state, action: PayloadAction<string>) => {
|
layerMovedForward: (state, action: PayloadAction<string>) => {
|
||||||
const cb = (l: Layer) => l.id === action.payload;
|
const cb = (l: Layer) => l.id === action.payload;
|
||||||
moveForward(state.layers, cb);
|
moveForward(state.layers, cb);
|
||||||
@ -188,8 +184,12 @@ export const regionalPromptsSlice = createSlice({
|
|||||||
// Because the layers are in reverse order, moving to the back is equivalent to moving to the front
|
// Because the layers are in reverse order, moving to the back is equivalent to moving to the front
|
||||||
moveToFront(state.layers, cb);
|
moveToFront(state.layers, cb);
|
||||||
},
|
},
|
||||||
|
allLayersDeleted: (state) => {
|
||||||
|
state.layers = [];
|
||||||
|
state.selectedLayerId = null;
|
||||||
|
},
|
||||||
//#endregion
|
//#endregion
|
||||||
//#region RP Layers
|
//#region Mask Layers
|
||||||
maskLayerPositivePromptChanged: (state, action: PayloadAction<{ layerId: string; prompt: string }>) => {
|
maskLayerPositivePromptChanged: (state, action: PayloadAction<{ layerId: string; prompt: string }>) => {
|
||||||
const { layerId, prompt } = action.payload;
|
const { layerId, prompt } = action.payload;
|
||||||
const layer = state.layers.find((l) => l.id === layerId);
|
const layer = state.layers.find((l) => l.id === layerId);
|
||||||
@ -211,7 +211,7 @@ export const regionalPromptsSlice = createSlice({
|
|||||||
layer.previewColor = color;
|
layer.previewColor = color;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lineAdded: {
|
maskLayerLineAdded: {
|
||||||
reducer: (
|
reducer: (
|
||||||
state,
|
state,
|
||||||
action: PayloadAction<
|
action: PayloadAction<
|
||||||
@ -244,7 +244,7 @@ export const regionalPromptsSlice = createSlice({
|
|||||||
meta: { uuid: uuidv4() },
|
meta: { uuid: uuidv4() },
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
pointsAddedToLastLine: (state, action: PayloadAction<{ layerId: string; point: [number, number] }>) => {
|
maskLayerPointsAdded: (state, action: PayloadAction<{ layerId: string; point: [number, number] }>) => {
|
||||||
const { layerId, point } = action.payload;
|
const { layerId, point } = action.payload;
|
||||||
const layer = state.layers.find((l) => l.id === layerId);
|
const layer = state.layers.find((l) => l.id === layerId);
|
||||||
if (layer) {
|
if (layer) {
|
||||||
@ -318,26 +318,26 @@ class LayerColors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
// Meta layer actions
|
// Any layer actions
|
||||||
layerAdded,
|
layerAdded,
|
||||||
layerDeleted,
|
layerDeleted,
|
||||||
layerMovedBackward,
|
layerMovedBackward,
|
||||||
layerMovedForward,
|
layerMovedForward,
|
||||||
layerMovedToBack,
|
layerMovedToBack,
|
||||||
layerMovedToFront,
|
layerMovedToFront,
|
||||||
allLayersDeleted,
|
|
||||||
// Regional Prompt layer actions
|
|
||||||
maskLayerAutoNegativeChanged,
|
|
||||||
layerBboxChanged,
|
|
||||||
maskLayerPreviewColorChanged,
|
|
||||||
layerVisibilityToggled,
|
|
||||||
lineAdded,
|
|
||||||
maskLayerNegativePromptChanged,
|
|
||||||
pointsAddedToLastLine,
|
|
||||||
maskLayerPositivePromptChanged,
|
|
||||||
layerReset,
|
layerReset,
|
||||||
layerSelected,
|
layerSelected,
|
||||||
layerTranslated,
|
layerTranslated,
|
||||||
|
layerBboxChanged,
|
||||||
|
layerVisibilityToggled,
|
||||||
|
allLayersDeleted,
|
||||||
|
// Vector mask layer actions
|
||||||
|
maskLayerAutoNegativeChanged,
|
||||||
|
maskLayerPreviewColorChanged,
|
||||||
|
maskLayerLineAdded,
|
||||||
|
maskLayerNegativePromptChanged,
|
||||||
|
maskLayerPointsAdded,
|
||||||
|
maskLayerPositivePromptChanged,
|
||||||
// General actions
|
// General actions
|
||||||
isEnabledChanged,
|
isEnabledChanged,
|
||||||
brushSizeChanged,
|
brushSizeChanged,
|
||||||
@ -405,13 +405,13 @@ export const regionalPromptsUndoableConfig: UndoableOptions<RegionalPromptsState
|
|||||||
undoType: undoRegionalPrompts.type,
|
undoType: undoRegionalPrompts.type,
|
||||||
redoType: redoRegionalPrompts.type,
|
redoType: redoRegionalPrompts.type,
|
||||||
groupBy: (action, state, history) => {
|
groupBy: (action, state, history) => {
|
||||||
// Lines are started with `lineAdded` and may have any number of subsequent `pointsAddedToLastLine` events.
|
// Lines are started with `maskLayerLineAdded` and may have any number of subsequent `maskLayerPointsAdded` events.
|
||||||
// We can use a double-buffer-esque trick to group each "logical" line as a single undoable action, without grouping
|
// We can use a double-buffer-esque trick to group each "logical" line as a single undoable action, without grouping
|
||||||
// separate logical lines as a single undo action.
|
// separate logical lines as a single undo action.
|
||||||
if (lineAdded.match(action)) {
|
if (maskLayerLineAdded.match(action)) {
|
||||||
return history.group === LINE_1 ? LINE_2 : LINE_1;
|
return history.group === LINE_1 ? LINE_2 : LINE_1;
|
||||||
}
|
}
|
||||||
if (pointsAddedToLastLine.match(action)) {
|
if (maskLayerPointsAdded.match(action)) {
|
||||||
if (history.group === LINE_1 || history.group === LINE_2) {
|
if (history.group === LINE_1 || history.group === LINE_2) {
|
||||||
return history.group;
|
return history.group;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user