Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(canvas): add Layer properties to the layer menu (#10133)

shkomg9d94088d4461
diff --git a/docs/src/content/docs/Users Guide/07.Canvas/01.introduction.mdx b/docs/src/content/docs/Users Guide/07.Canvas/01.introduction.mdx
index 3ec2f83377..fb25ca2570 100644
--- a/docs/src/content/docs/Users Guide/07.Canvas/01.introduction.mdx
+++ b/docs/src/content/docs/Users Guide/07.Canvas/01.introduction.mdx
@@ -43,7 +43,7 @@ Each raster layer row has an eye button on the right: a hidden raster layer is o
### Settings live in the Properties pane
-Each layer's settings, such as a regional prompt or a control layer's model, are in the **Properties** tab at the bottom of the Layers panel. Select the layer and click **Properties**: the heading at the top of the tab confirms which layer you are editing, for example *Layer: Regional Guidance 1*. The settings are in its **Layer** section. The Layer section comes after the settings of the active tool, so **you may need to scroll the Properties pane down to see it**. Dragging the divider above the Properties pane upward, or collapsing the color picker, gives it more room.
+Each layer's settings, such as a regional prompt or a control layer's model, are in the **Properties** tab at the bottom of the Layers panel. Select the layer and click **Properties**: the heading at the top of the tab confirms which layer you are editing, for example *Layer: Regional Guidance 1*. The settings are in its **Layer** section. The Layer section comes after the settings of the active tool, so **you may need to scroll the Properties pane down to see it**. Right-clicking the layer and choosing **Layer properties** opens the tab and scrolls to that section for you. Dragging the divider above the Properties pane upward, or collapsing the color picker, gives it more room.
### The generation frame
@@ -120,7 +120,7 @@ Regional guidance gives one area of the image its own prompt. For example, keep
2. **Paint the region** with the **Brush**, or draw it with the **Shape** tool. It shows as a tinted overlay.
-3. **Enter the region's prompt.** With the layer selected, open **Properties** and scroll down to its **Layer** section. Type in **Positive prompt**. To keep something out of the region as well, click **+ Negative prompt…** and type in **Negative prompt**. Each prompt is saved when you click away from its field.
+3. **Enter the region's prompt.** Right-click the layer and choose **Layer properties**: the **Properties** tab opens at its **Layer** section. Type in **Positive prompt**. To keep something out of the region as well, click **+ Negative prompt…** and type in **Negative prompt**. Each prompt is saved when you click away from its field.
4. **Press Invoke.** The main prompt still describes the whole image; the regional prompt applies inside the region.
diff --git a/docs/src/content/docs/Users Guide/07.Canvas/03.layers-panel.mdx b/docs/src/content/docs/Users Guide/07.Canvas/03.layers-panel.mdx
index fb3ca536ab..0272b5e777 100644
--- a/docs/src/content/docs/Users Guide/07.Canvas/03.layers-panel.mdx
+++ b/docs/src/content/docs/Users Guide/07.Canvas/03.layers-panel.mdx
@@ -88,6 +88,7 @@ Right-click a layer, or select it and press **Shift+F10**, for its menu. Right-c
The icons at the top **Arrange** the layer (move it to the front, forward, backward or to the back), **Duplicate layer** and **Group layers**. Below them:
* **For every layer:**
+ * **Layer properties** opens the **Properties** tab and scrolls it to the layer's **Layer** section.
* **Rename layer** and **Fit to frame** (scale the layer to fit inside the generation frame).
* **Merge down** — combines the layer with the one below. Each layer's adjustments are baked into the merged pixels; undo restores both layers with their adjustments.
* **Copy to** — including **Copy layer to clipboard**, and copies to other layer types.
@@ -122,7 +123,7 @@ Below the heading, the tab shows up to three sections, in this order:
3. **Layer** — the settings of the selected layer.
:::tip[Scroll down for the layer's settings]
-The **Layer** section comes after the tool options, so on most screens it starts below the visible part of the pane. Scroll the Properties pane down to reach it, or drag the divider above the pane upward to make it taller.
+The **Layer** section comes after the tool options, so on most screens it starts below the visible part of the pane. Right-click the layer and choose **Layer properties** to jump to it, scroll the Properties pane down, or drag the divider above the pane upward to make it taller.
:::
The Layer section is dimmed while Filter or Select Object is running.
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index db4cf0eb75..9167b18e25 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -5192,6 +5192,7 @@
"operationFailed": "The canvas could not apply this change, so nothing was changed.",
"overBudget": "There is not enough canvas memory to make this change undoable, so nothing was changed.",
"stale": "The layer changed before this action finished, so nothing was changed. Try again.",
+ "properties": "Layer properties",
"rasterize": "Rasterize layer",
"removeQuickSwitchBookmark": "Remove quick switch bookmark",
"rename": "Rename layer",
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.browser.test.tsx
index cc74f07e4f..b4893557bd 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.browser.test.tsx
@@ -44,6 +44,7 @@ vi.mock('@workbench/WorkbenchContext', async (importOriginal) => ({
useWorkbenchCommands: () => harness.store!.commands,
}));
+import { getLayerChildSelection, selectLayerChild } from './layerChildSelection';
import { CanvasLayerContextMenu } from './LayerContextMenu';
import { LayerGroupContextMenu } from './LayerGroupContextMenu';
@@ -144,7 +145,7 @@ const renderMenu = async (
};
const document_ = () => store.getState().projects[0]!.canvas.document;
const notices = () => store.getState().notifications.map(({ message, title }) => [title, message]);
- return { document: document_, engine, notices, openMenu };
+ return { document: document_, engine, notices, openMenu, projectId };
};
const item = (name: string) => page.getByRole('menuitem', { exact: true, name });
@@ -220,6 +221,16 @@ describe('Layers context menu over a real engine', () => {
}
);
+ it('opens Layer properties on the layer itself, clearing a selected child row of that layer', async () => {
+ const { openMenu, projectId } = await renderMenu([imageLayer('art')], ['art']);
+ selectLayerChild(projectId, 'art', 'adjustment-1');
+
+ await openMenu('art');
+ await act(() => item('Layer properties').click());
+
+ expect(getLayerChildSelection()).toBeNull();
+ });
+
it('describes Add regenerate region under its label without widening the menu', async () => {
const { openMenu } = await renderMenu([imageLayer('art')]);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
index c143af82e6..0a19883a08 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerContextMenu.tsx
@@ -81,6 +81,7 @@ import type {
} from './layerContextMenuLayout';
import type { LayerMenuDialogKind, LayerMenuDialogState } from './layerMenuState';
+import { clearLayerChildSelection } from './layerChildSelection';
import {
deleteLayers,
duplicateLayers,
@@ -133,7 +134,7 @@ import {
needsBakedControlPixels,
} from './layerOps';
import { LayerSaveToBoardSubmenu } from './LayerSaveToBoardSubmenu';
-import { useRevealLayerProperties } from './revealLayerProperties';
+import { revealLayerSection, useRevealLayerProperties } from './revealLayerProperties';
import { RunLayerWorkflowDialog, useLayerWorkflowAvailability } from './RunLayerWorkflowDialog';
import { useSelectedModelBase } from './useSelectedModelBase';
@@ -705,8 +706,11 @@ const LayerMenu = ({
const { focusRegion } = useWorkbenchFocus();
const handleOpenProperties = useCallback(() => {
+ // A selected child row (reference image, mask modifier, adjustment) would keep its own editor in the pane.
+ clearLayerChildSelection();
revealProperties(layer.id);
focusRegion('right', 'layers');
+ revealLayerSection();
}, [focusRegion, layer.id, revealProperties]);
const handleBooleanRaster = useCallback(
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts
index 5ebc79025a..f76dc66067 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.test.ts
@@ -272,6 +272,7 @@ describe('getLayerContextActions', () => {
'duplicate',
'group',
'remove-from-group',
+ 'open-properties',
'rename',
'transform',
'fit-to-bbox',
@@ -528,6 +529,21 @@ describe('getLayerContextActions', () => {
});
});
+describe('open-properties', () => {
+ it('offers Layer properties on every layer type and opens the Properties pane through its effect', () => {
+ for (const type of ['raster', 'control', 'inpaint_mask', 'regional_guidance'] as const) {
+ const action = byId(getLayerContextActions(makeState(makeLayer(type))), 'open-properties');
+ expect(action.isDisabled, type).toBe(false);
+ }
+ expect(getEnglishTranslation('widgets.layers.actions.properties')).toBe('Layer properties');
+
+ const effects = makeEffects();
+ getLayerContextActionDefinition('open-properties').handler(makeRuntimeContext(rasterLayer, { effects }));
+
+ expect(Object.values(effects).filter((effect) => effect.mock.calls.length > 0)).toEqual([effects.openProperties]);
+ });
+});
+
describe('toggle-visibility', () => {
const labelOf = (layer: CanvasLayerContract, overrides: Partial<LayerContextActionState> = {}) =>
getEnglishTranslation(byId(getLayerContextActions(makeState(layer, overrides)), 'toggle-visibility').labelKey);
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
index c7a9653ba4..ae2e11b81d 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
@@ -53,6 +53,7 @@ import {
MergeIcon,
PencilIcon,
SaveIcon,
+ Settings2Icon,
ContrastIcon,
RainbowIcon,
ScanSearchIcon,
@@ -95,6 +96,7 @@ export type LayerContextActionId =
| 'duplicate'
| 'group'
| 'remove-from-group'
+ | 'open-properties'
| 'rename'
| 'transform'
| 'fit-to-bbox'
@@ -623,6 +625,18 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini
section: 'quick',
supportedLayerTypes: ALL_LAYER_TYPES,
},
+ {
+ defaultLabel: 'Layer properties',
+ handler: ({ effects }) => effects.openProperties(),
+ icon: Settings2Icon,
+ id: 'open-properties',
+ isEnabled: isOperationFree,
+ isVisible: alwaysVisible,
+ labelKey: 'widgets.layers.actions.properties',
+ order: 5,
+ section: 'primary',
+ supportedLayerTypes: ALL_LAYER_TYPES,
+ },
{
defaultLabel: 'Transform',
handler: ({ effects }) => effects.transform(),
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts
index 69111e6166..1d13ecbe27 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextMenuLayout.test.ts
@@ -84,6 +84,7 @@ describe('getLayerContextMenuLayout', () => {
{
id: 'primary',
items: [
+ 'open-properties',
'transform',
'rename',
'fit-to-bbox',
@@ -129,6 +130,7 @@ describe('getLayerContextMenuLayout', () => {
expect(summarize(inpaint)[1]).toEqual({
id: 'primary',
items: [
+ 'open-properties',
'transform',
'rename',
'fit-to-bbox',
@@ -142,6 +144,7 @@ describe('getLayerContextMenuLayout', () => {
expect(summarize(regional)[1]).toEqual({
id: 'primary',
items: [
+ 'open-properties',
'transform',
'rename',
'fit-to-bbox',
@@ -162,6 +165,7 @@ describe('getLayerContextMenuLayout', () => {
expect(summarize(control)[1]).toEqual({
id: 'primary',
items: [
+ 'open-properties',
'transform',
'rename',
'fit-to-bbox',
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
index 2e833c9f0a..f3eea5aa06 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx
@@ -112,6 +112,8 @@ vi.mock('@workbench/canvas-operations/api', async (importOriginal) => ({
getCanvasEngine: () => harness.engine,
}));
+import { revealLayerSection } from '@workbench/widgets/layers/revealLayerProperties';
+
import type { LayerEditorPaneLayout } from './editorPaneLayout';
import { ColorPane } from './ColorPane';
@@ -300,7 +302,11 @@ const GRADIENT_SOURCE = {
const mount = async (
View: typeof PropertiesPane,
selection: Selection = 'none',
- { extraNodes = [], width = 450 }: { extraNodes?: Parameters<typeof stacksFrom>[0]; width?: number } = {}
+ {
+ extraNodes = [],
+ height = 600,
+ width = 450,
+ }: { extraNodes?: Parameters<typeof stacksFrom>[0]; height?: number; width?: number } = {}
) => {
const base = { ...createInitialWorkbenchState().projects[0]!, id: 'p' };
const nodes =
@@ -333,7 +339,7 @@ const mount = async (
type: 'replaceCanvasDocument',
});
host = document.createElement('div');
- host.style.cssText = `width:${width}px;height:600px;`;
+ host.style.cssText = `width:${width}px;height:${height}px;`;
document.body.append(host);
root = createRoot(host);
registry = createEngineRegistry({ gracePeriodMs: 0 });
@@ -551,6 +557,46 @@ describe('Select Object properties', () => {
});
});
+describe('Layer section reveal', () => {
+ it('scrolls the Layer section below the tool settings into view', async () => {
+ await mount(PropertiesPane, 'control', { height: 240 });
+ await act(() => engine!.tools.setTool('brush'));
+ await settle();
+ const section = host!.querySelector<HTMLElement>('[data-properties-section="layer"]')!;
+ const inView = () => section.getBoundingClientRect().top < host!.getBoundingClientRect().bottom;
+ expect(inView()).toBe(false);
+
+ revealLayerSection();
+
+ await expect.poll(inView).toBe(true);
+ await expect.element(page.getByRole('combobox', { exact: true, name: 'Type' })).toBeInViewport();
+ });
+
+ it('brings the start of a tall Layer section back into view after the user scrolled down within it', async () => {
+ await mount(PropertiesPane, 'control', { height: 160 });
+ await act(() => engine!.tools.setTool('brush'));
+ await settle();
+ const section = host!.querySelector<HTMLElement>('[data-properties-section="layer"]')!;
+ let scroller = section.parentElement;
+ while (scroller && scroller.scrollHeight <= scroller.clientHeight) {
+ scroller = scroller.parentElement;
+ }
+ const viewTop = () => scroller!.getBoundingClientRect().top;
+ const startInView = () => Math.abs(section.getBoundingClientRect().top - viewTop()) < 2;
+ expect(section.getBoundingClientRect().height).toBeGreaterThan(scroller!.clientHeight);
+
+ revealLayerSection();
+ await expect.poll(startInView).toBe(true);
+
+ scroller!.scrollTop += 80;
+ expect(section.getBoundingClientRect().top).toBeLessThan(viewTop());
+
+ revealLayerSection();
+ await expect.poll(startInView).toBe(true);
+ await expect.element(page.getByRole('combobox', { exact: true, name: 'Type' })).toBeInViewport();
+ });
+});
+
describe('Tool property scrubbers', () => {
beforeEach(() => resetPropertyGroupCollapse());
afterEach(() => resetPropertyGroupCollapse());
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
index aec5d7d3bf..4a846f87b0 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
@@ -59,6 +59,7 @@ export const LayerSection = ({ disabled }: { disabled: boolean }) => {
return (
<PropertiesSection
disabled={disabled}
+ sectionId="layer"
subtitle={child ? child.subtitle : (node?.name ?? t('widgets.transform.noSelection'))}
title={t('widgets.properties.sections.layer')}
>
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx
index b7984869fe..fdb874f13c 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesSection.tsx
@@ -9,6 +9,7 @@ export const PropertiesSection = ({
children,
disabled = false,
ref,
+ sectionId,
subtitle,
subtitleDetail,
title,
@@ -18,6 +19,8 @@ export const PropertiesSection = ({
/** The surface is busy elsewhere (staging, generation, an operation): the rows stay in place but cannot act. */
disabled?: boolean;
ref?: Ref<HTMLDivElement>;
+ /** Marks the section for reveals that scroll it into view. */
+ sectionId?: 'layer';
subtitle?: string;
/** More about the subtitle: its tooltip, and read with it by assistive tech. */
subtitleDetail?: string;
@@ -37,6 +40,7 @@ export const PropertiesSection = ({
aria-label={title}
borderBottomWidth="1px"
borderColor="border.subtle"
+ data-properties-section={sectionId}
gap="2"
inert={disabled || undefined}
opacity={disabled ? 0.5 : 1}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/revealLayerProperties.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/revealLayerProperties.ts
index 50b933f6cc..b847fcafdd 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/revealLayerProperties.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/revealLayerProperties.ts
@@ -24,3 +24,28 @@ export const useRevealLayerProperties = (): ((layerId: string) => void) => {
[registry, widgets]
);
};
+
+/** How long a reveal waits for the Properties pane, just opened, to render the Layer section. */
+const REVEAL_WAIT_MS = 1500;
+
+/**
+ * Scrolls the Properties pane to the start of its Layer section, which sits below the active tool's settings and often
+ * starts out of view. The caller opens the pane first; a reveal whose pane never renders gives up quietly.
+ */
+export const revealLayerSection = (): void => {
+ const deadline = performance.now() + REVEAL_WAIT_MS;
+
+ const attempt = () => {
+ const section = [...document.querySelectorAll<HTMLElement>('[data-properties-section="layer"]')].find(
+ (element) => element.getClientRects().length > 0
+ );
+ if (section) {
+ // `start`, not `nearest`: a section taller than the pane, already scrolled into, would otherwise not move.
+ section.scrollIntoView({ block: 'start' });
+ } else if (performance.now() < deadline) {
+ requestAnimationFrame(attempt);
+ }
+ };
+
+ requestAnimationFrame(attempt);
+};
diff --git a/invokeai/frontend/webv2/vite.config.mts b/invokeai/frontend/webv2/vite.config.mts
index 6f61b6a1be..9101e368d9 100644
--- a/invokeai/frontend/webv2/vite.config.mts
+++ b/invokeai/frontend/webv2/vite.config.mts
@@ -430,6 +430,8 @@ const CANVAS_LAYER_SHARED_MODULES = [
'/workbench/widgets/layers/colorLabels.ts',
'/workbench/widgets/layers/layerCommands.ts',
'/workbench/widgets/layers/layerActionSession.ts',
+ '/workbench/widgets/layers/layerChildRows.ts',
+ '/workbench/widgets/layers/layerChildSelection.ts',
'/workbench/widgets/layers/layerContextActions.ts',
'/workbench/widgets/layers/layerContextMenuLayout.ts',
'/workbench/widgets/layers/layerExportActions.ts',