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.

feat(layers): adjustment rows and editors on groups

Josh Corbettb11dadc9fd19
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentComposite.browser.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentComposite.browser.test.ts
index 8fc94bf811..e4d230dd81 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentComposite.browser.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentComposite.browser.test.ts
@@ -79,7 +79,7 @@ describe('group adjustment composite', () => {
const document = docWith([
groupContract('g', [raster('red', { opacity: 0.5 }), raster('white')], {
adjustments: gammaStack('ga'),
- } as never),
+ }),
]);
const scene = sceneFor({ red: '#ff0000', white: '#ffffff' });
const entry = planBaseRasterComposite(document, BBOX);
@@ -100,9 +100,9 @@ describe('group adjustment composite', () => {
// so use a mid value: member is 25% gray (64). invert → 191; gamma-2 on
// 191 → 255·sqrt(191/255) ≈ 221. Reversed: gamma-2(64) ≈ 128, invert → 127.
const document = docWith([
- groupContract('outer', [groupContract('inner', [raster('gray')], { adjustments: invertStack('ia') } as never)], {
+ groupContract('outer', [groupContract('inner', [raster('gray')], { adjustments: invertStack('ia') })], {
adjustments: gammaStack('oa'),
- } as never),
+ }),
]);
const scene = sceneFor({ gray: '#404040' });
const surface = await renderRasterComposite(planBaseRasterComposite(document, BBOX), scene);
@@ -114,7 +114,7 @@ describe('group adjustment composite', () => {
const document = docWith([
groupContract('g', [raster('red', { blendMode: 'multiply', opacity: 0.6 }), raster('white')], {
adjustments: gammaStack('ga'),
- } as never),
+ }),
raster('under'),
]);
const scene = sceneFor({ red: '#ff4040', under: '#2040c0', white: '#c0c0c0' });
@@ -153,11 +153,11 @@ describe('group adjustment composite', () => {
groupContract(
'outer',
[
- groupContract('i1', [raster('a')], { adjustments: invertStack('ia') } as never),
+ groupContract('i1', [raster('a')], { adjustments: invertStack('ia') }),
raster('b', { opacity: 0.0 }),
- groupContract('i2', [raster('d', { opacity: 0.0 })], { adjustments: invertStack('ib') } as never),
+ groupContract('i2', [raster('d', { opacity: 0.0 })], { adjustments: invertStack('ib') }),
],
- { adjustments: gammaStack('oa') } as never
+ { adjustments: gammaStack('oa') }
),
]);
const scene = sceneFor({ a: '#404040', b: '#404040', d: '#404040' });
@@ -179,7 +179,7 @@ describe('group adjustment composite', () => {
});
it('color-samples through a group stack when the providers are wired', () => {
- const document = docWith([groupContract('g', [raster('gray')], { adjustments: invertStack('ia') } as never)]);
+ const document = docWith([groupContract('g', [raster('gray')], { adjustments: invertStack('ia') })]);
const scene = sceneFor({ gray: '#404040' });
const groupSurfaces = createGroupSurfaceCache({
createSurface: (w, h) => scene.backend.createSurface(w, h),
@@ -199,8 +199,8 @@ describe('group adjustment composite', () => {
const flat = docWith([groupContract('g', [raster('white')])]);
expect(planBaseRasterComposite(flat, BBOX).groupScopes).toBeUndefined();
- const adjusted = docWith([groupContract('g', [raster('white')], { adjustments: gammaStack('ga') } as never)]);
- const inverted = docWith([groupContract('g', [raster('white')], { adjustments: invertStack('ia') } as never)]);
+ const adjusted = docWith([groupContract('g', [raster('white')], { adjustments: gammaStack('ga') })]);
+ const inverted = docWith([groupContract('g', [raster('white')], { adjustments: invertStack('ia') })]);
expect(planBaseRasterComposite(adjusted, BBOX).key).not.toBe(planBaseRasterComposite(flat, BBOX).key);
expect(planBaseRasterComposite(adjusted, BBOX).key).not.toBe(planBaseRasterComposite(inverted, BBOX).key);
});
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentScopes.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentScopes.test.ts
index f2ea3224f4..bb3cbe3239 100644
--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentScopes.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/render/groupAdjustmentScopes.test.ts
@@ -19,10 +19,10 @@ const identityStack: CanvasAdjustmentsContract = [
describe('collectAdjustedGroups', () => {
it('collects only raster-stack groups with contributing stacks', () => {
const doc = documentFrom({
- control: [groupContract('og', [layerContract('c1', 'control')], { adjustments: stack('a') } as never)],
+ control: [groupContract('og', [layerContract('c1', 'control')], { adjustments: stack('a') })],
raster: [
- groupContract('g1', [layerContract('r1')], { adjustments: stack('b') } as never),
- groupContract('g2', [layerContract('r2')], { adjustments: identityStack } as never),
+ groupContract('g1', [layerContract('r1')], { adjustments: stack('b') }),
+ groupContract('g2', [layerContract('r2')], { adjustments: identityStack }),
groupContract('g3', [layerContract('r3')]),
],
});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentSettings.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentSettings.browser.test.tsx
index 39eb05547a..be36d53395 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentSettings.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentSettings.browser.test.tsx
@@ -58,8 +58,19 @@ const createLayer = (): CanvasRasterLayerContractV2 =>
const commits: PreparedDocumentEdit[] = [];
let latestAdjustments: unknown = 'untouched';
-const Harness = ({ entryId }: { entryId: string }) => {
- const [layer, setLayer] = useState(createLayer);
+const createGroupOwner = () =>
+ ({
+ adjustments: initialEntries(),
+ children: [],
+ id: 'group-1',
+ isEnabled: true,
+ isLocked: false,
+ name: 'Group 1',
+ type: 'group',
+ }) as unknown as CanvasRasterLayerContractV2;
+
+const Harness = ({ entryId, owner = 'raster' }: { entryId: string; owner?: 'raster' | 'group' }) => {
+ const [layer, setLayer] = useState(owner === 'group' ? createGroupOwner : createLayer);
const engine = useMemo(() => {
const apply = (mutation: CanvasProjectMutation): boolean => {
@@ -103,7 +114,7 @@ const settle = (action: () => void): Promise<void> =>
});
});
-const render = async (entryId = 'cv1') => {
+const render = async (entryId = 'cv1', owner: 'raster' | 'group' = 'raster') => {
applyThemeToRoot('classic');
host = document.createElement('div');
host.style.width = '260px';
@@ -114,7 +125,7 @@ const render = async (entryId = 'cv1') => {
root?.render(
<I18nextProvider i18n={i18n}>
<ChakraProvider value={system}>
- <Harness entryId={entryId} />
+ <Harness entryId={entryId} owner={owner} />
</ChakraProvider>
</I18nextProvider>
);
@@ -159,6 +170,21 @@ const pressTrack = async (track: HTMLElement, fraction: number): Promise<void> =
const forwardEntries = (edit: PreparedDocumentEdit): CanvasAdjustmentEntry[] =>
(edit.forward as unknown as { config: { adjustments: CanvasAdjustmentEntry[] } }).config.adjustments;
+describe('group-owned adjustment editors', () => {
+ it('previews and commits through the group config arm', async () => {
+ await render('hue1', 'group');
+ const [track] = sliderTracks();
+ expect(track).toBeDefined();
+ await pressTrack(track!, 0.75);
+
+ expect(commits).toHaveLength(1);
+ const forward = commits[0]!.forward as unknown as { config: { layerType: string }; id: string };
+ expect(forward.config.layerType).toBe('group');
+ expect(forward.id).toBe('group-1');
+ expect((forwardEntries(commits[0]!)[2] as { rotation: number }).rotation).toBeCloseTo(90, -1);
+ });
+});
+
describe('hue and levels editors', () => {
it('commits a hue rotation as one whole-stack patch', async () => {
await render('hue1');
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentSettings.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentSettings.tsx
index 6fd7e561be..749bf1e1ee 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentSettings.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentSettings.tsx
@@ -68,6 +68,11 @@ const IDENTITY_CURVE: [number, number][] = [
const formatSigned = (value: number): string => `${value > 0 ? '+' : ''}${Math.round(value * 100)}`;
+/** An adjustment stack's owner: a raster layer or a raster-stack group. */
+export type AdjustmentOwner = Pick<CanvasRasterLayerContractV2, 'id' | 'adjustments'> & {
+ type: 'raster' | 'group';
+};
+
export const AdjustmentSettings = ({
engine,
entryId,
@@ -75,7 +80,7 @@ export const AdjustmentSettings = ({
}: {
engine: AdjustmentsEngine | null;
entryId: string;
- layer: CanvasRasterLayerContractV2;
+ layer: AdjustmentOwner;
}) => {
const entry = layer.adjustments?.find((candidate) => candidate.id === entryId);
if (!entry) {
@@ -91,26 +96,30 @@ const AdjustmentEntryEditor = ({
}: {
engine: AdjustmentsEngine | null;
entry: CanvasAdjustmentEntry;
- layer: CanvasRasterLayerContractV2;
+ layer: AdjustmentOwner;
}) => {
const commitPrepared = usePreparedCommit(engine);
const { t } = useTranslation();
const gestureBaselineRef = useRef<readonly CanvasAdjustmentEntry[] | null>(null);
+ const configOf = useCallback(
+ (adjustments: CanvasAdjustmentEntry[]) =>
+ layer.type === 'group'
+ ? { adjustments, layerType: 'group' as const }
+ : { adjustments, layerType: 'raster' as const },
+ [layer.type]
+ );
const patchLive = useCallback(
(next: CanvasAdjustmentEntry) => {
const entries = layer.adjustments ?? [];
gestureBaselineRef.current ??= entries;
applyStructuralPreview(engine, {
- config: {
- adjustments: entries.map((candidate) => (candidate.id === next.id ? next : candidate)),
- layerType: 'raster',
- },
+ config: configOf(entries.map((candidate) => (candidate.id === next.id ? next : candidate))),
id: layer.id,
type: 'updateCanvasLayerConfig',
});
},
- [engine, layer.adjustments, layer.id]
+ [configOf, engine, layer.adjustments, layer.id]
);
const commitEntry = useCallback(
@@ -122,17 +131,14 @@ const AdjustmentEntryEditor = ({
const committed = { ...next, isEnabled: entry.isEnabled };
commitPrepared(label, (model) =>
model.prepare({
- before: { adjustments: [...baseline], layerType: 'raster' },
- config: {
- adjustments: entries.map((candidate) => (candidate.id === committed.id ? committed : candidate)),
- layerType: 'raster',
- },
+ before: configOf([...baseline]),
+ config: configOf(entries.map((candidate) => (candidate.id === committed.id ? committed : candidate))),
id: layer.id,
type: 'patch-config',
})
);
},
- [commitPrepared, entry.isEnabled, layer.adjustments, layer.id]
+ [commitPrepared, configOf, entry.isEnabled, layer.adjustments, layer.id]
);
const cancelGesture = useCallback(() => {
@@ -140,12 +146,12 @@ const AdjustmentEntryEditor = ({
gestureBaselineRef.current = null;
if (baseline) {
applyStructuralPreview(engine, {
- config: { adjustments: [...baseline], layerType: 'raster' },
+ config: configOf([...baseline]),
id: layer.id,
type: 'updateCanvasLayerConfig',
});
}
- }, [engine, layer.id]);
+ }, [configOf, engine, layer.id]);
const handleScalarLive = useCallback(
(field: ScalarField, next: number) => patchLive({ ...entry, [field]: next } as CanvasAdjustmentEntry),
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildRow.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildRow.tsx
index 7a31aa2e80..5ccc15af14 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildRow.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerChildRow.tsx
@@ -58,6 +58,8 @@ export const childRowName = (child: ProjectedChildRow, t: (key: string) => strin
: (child.customName ?? t(childRowNameKey(child.kind)));
interface LayerChildRowProps {
+ /** The owner's combined child count when a group owns both rows and nodes. */
+ ariaSetSize?: number;
child: ProjectedChildRow;
commands: LayerRowCommands;
/** The owning layer travels in the current drag; the row dims with it. */
@@ -76,6 +78,7 @@ interface LayerChildRowProps {
* registers a drop target so a layer drag over it lands below its owner.
*/
const LayerChildRowComponent = ({
+ ariaSetSize,
child,
commands,
dimmed,
@@ -229,7 +232,7 @@ const LayerChildRowComponent = ({
aria-level={child.depth + 2}
aria-posinset={child.posInSet}
aria-selected={selected}
- aria-setsize={child.setSize}
+ aria-setsize={ariaSetSize ?? child.setSize}
data-layer-row-id={child.key}
h="full"
opacity={dimmed ? 0.4 : undefined}
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerGroupContextMenu.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerGroupContextMenu.tsx
index 7f15aeb0ce..2c4c1cf5eb 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerGroupContextMenu.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerGroupContextMenu.tsx
@@ -1,4 +1,9 @@
-import type { CanvasGroupContract, LayerStackKind, LayerStackMoveKind } from '@workbench/canvas-engine/api';
+import type {
+ CanvasAdjustmentEntry,
+ CanvasGroupContract,
+ LayerStackKind,
+ LayerStackMoveKind,
+} from '@workbench/canvas-engine/api';
import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';
import type { LucideIcon } from 'lucide-react';
import type { ComponentProps } from 'react';
@@ -15,6 +20,7 @@ import {
ArrowDownToLineIcon,
ArrowUpIcon,
ArrowUpToLineIcon,
+ ChevronRightIcon,
CircleIcon,
CircleOffIcon,
CopyIcon,
@@ -24,13 +30,18 @@ import {
LockIcon,
LockOpenIcon,
PencilIcon,
+ SlidersHorizontalIcon,
Trash2Icon,
UngroupIcon,
} from 'lucide-react';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { ADJUSTMENT_ADD_ITEMS } from './layerContextActions';
import { canGroupSelection, groupLayers, ungroupLayers } from './layerGroupCommands';
+import { createIdentityAdjustment } from './layerOps';
+
+const SUBMENU_POSITIONING = { placement: 'right-start' } as const;
export type LayerGroupContextMenuEngine = Pick<CanvasEngineHandle, 'document' | 'layers' | 'projectId'>;
@@ -172,6 +183,24 @@ export const LayerGroupContextMenu = ({
const locked = editingLocked;
const hideable = isOverlayStack(stack);
+ // Adjustment stacks apply to a group's composited children, raster stack only.
+ const adjustable = stack === 'raster';
+
+ const handleAddAdjustment = useCallback(
+ (type: CanvasAdjustmentEntry['type']) => () => {
+ const entry = createIdentityAdjustment(type);
+ const before = group.adjustments ?? [];
+ commitPrepared(t('widgets.layers.menu.addAdjustment'), (model) =>
+ model.prepare({
+ before: { adjustments: [...before], layerType: 'group' },
+ config: { adjustments: [...before, entry], layerType: 'group' },
+ id: group.id,
+ type: 'patch-config',
+ })
+ );
+ },
+ [commitPrepared, group.adjustments, group.id, t]
+ );
const items = (
<MenuContent minW="13rem" py="1">
@@ -198,6 +227,37 @@ export const LayerGroupContextMenu = ({
<Menu.Item disabled={locked || frozen || group.isLocked} value="ungroup" onSelect={handleUngroup}>
<MenuRow icon={UngroupIcon} label={t('widgets.layers.actions.ungroup')} />
</Menu.Item>
+ {adjustable ? (
+ locked || frozen || group.isLocked ? (
+ // Same disabled affordance the sibling items use, not a vanished verb.
+ <Menu.Item disabled value="add-adjustment">
+ <MenuRow icon={SlidersHorizontalIcon} label={t('widgets.layers.menu.addAdjustment')} />
+ </Menu.Item>
+ ) : (
+ <Menu.Root positioning={SUBMENU_POSITIONING}>
+ <Menu.TriggerItem aria-label={t('widgets.layers.menu.addAdjustment')}>
+ <HStack gap="2" minW="0" w="full">
+ <Icon as={SlidersHorizontalIcon} boxSize="3.5" color="fg.subtle" flexShrink={0} />
+ <Text flex="1" fontSize="xs">
+ {t('widgets.layers.menu.addAdjustment')}
+ </Text>
+ <Icon as={ChevronRightIcon} boxSize="3" color="fg.subtle" flexShrink={0} />
+ </HStack>
+ </Menu.TriggerItem>
+ <Portal>
+ <Menu.Positioner>
+ <MenuContent minW="13rem" py="1">
+ {ADJUSTMENT_ADD_ITEMS.map((item) => (
+ <Menu.Item key={item.type} value={`add-${item.type}`} onSelect={handleAddAdjustment(item.type)}>
+ <MenuRow icon={item.icon} label={t(item.labelKey)} />
+ </Menu.Item>
+ ))}
+ </MenuContent>
+ </Menu.Positioner>
+ </Portal>
+ </Menu.Root>
+ )
+ ) : null}
<Menu.Separator borderColor="border.subtle" />
<Menu.Item disabled={locked} value="enabled" onSelect={handleToggleEnabled}>
<MenuRow
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRow.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRow.tsx
index 5e590c95b2..629b559070 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRow.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayerRow.tsx
@@ -42,6 +42,9 @@ const GROUP_PILE_CARD_PX = 24;
export type LayerRowDragState = 'source' | 'travelling' | null;
interface LayerRowProps {
+ /** Combined-set ARIA facts when the parent group owns modifier rows. */
+ ariaPosInSet?: number;
+ ariaSetSize?: number;
/** A group on the primary layer's ancestor path; tinted as selection context. */
ancestorOfPrimary: boolean;
/** Projected child rows the layer owns; a chevron appears above zero. */
@@ -73,6 +76,8 @@ const stopPropagation = (event: { stopPropagation: () => void }): void => event.
*/
const LayerRowComponent = ({
ancestorOfPrimary,
+ ariaPosInSet,
+ ariaSetSize,
childCount,
childSelected,
childrenExpanded,
@@ -285,9 +290,9 @@ const LayerRowComponent = ({
aria-expanded={group ? row.expanded : childCount > 0 ? childrenExpanded : undefined}
aria-label={node.name}
aria-level={vm.depth + 2}
- aria-posinset={row.posInSet}
+ aria-posinset={ariaPosInSet ?? row.posInSet}
aria-selected={selected}
- aria-setsize={row.setSize}
+ aria-setsize={ariaSetSize ?? row.setSize}
data-layer-row-id={row.id}
data-primary={primary || undefined}
h="full"
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
index 89b3d749ae..b105d6cbae 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/LayersTree.tsx
@@ -1097,6 +1097,8 @@ export const LayersTree = ({
{panelRow.kind === 'node' ? (
<LayerRow
ancestorOfPrimary={primaryAncestorIds.has(panelRow.row.id)}
+ ariaPosInSet={panelRow.ariaPosInSet}
+ ariaSetSize={panelRow.ariaSetSize}
childCount={panelRow.childCount}
childSelected={panelRow.row.id === selectedChildOwnerId}
childrenExpanded={panelRow.childrenExpanded}
@@ -1114,6 +1116,7 @@ export const LayersTree = ({
/>
) : panelRow.kind === 'child' ? (
<LayerChildRow
+ ariaSetSize={panelRow.ariaSetSize}
child={panelRow.child}
commands={commands}
dimmed={
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
index c99f2671d4..7bfd38502c 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.test.ts
@@ -1,6 +1,10 @@
import type { CanvasAdjustmentEntry, RegionalGuidanceReferenceImage } from '@workbench/canvas-engine/api';
-import { documentFrom, layerContract } from '@workbench/canvas-engine/document-model/documentFixtures.testStub';
+import {
+ documentFrom,
+ groupContract,
+ layerContract,
+} from '@workbench/canvas-engine/document-model/documentFixtures.testStub';
import { describe, expect, it } from 'vitest';
import {
@@ -170,6 +174,72 @@ describe('mask modifier rows', () => {
});
});
+describe('group adjustment child rows', () => {
+ const groupWith = (adjustments: CanvasAdjustmentEntry[]) =>
+ groupContract('g1', [layerContract('r1')], { adjustments });
+ const groupRow = (document: ReturnType<typeof documentFrom>) =>
+ buildLayerStackRows(document.stacks, new Set()).raster.rows.find((row) => row.id === 'g1')!;
+ const stack = (): CanvasAdjustmentEntry[] => [
+ { brightness: 0.2, contrast: 0, id: 'ga1', isEnabled: true, type: 'brightness-contrast' },
+ { id: 'ga2', isEnabled: false, type: 'invert' },
+ ];
+
+ it("projects a group's adjustment entries exactly like a raster layer's", () => {
+ const rows = projectLayerChildRows(groupRow(documentFrom([groupWith(stack())])).vm);
+ expect(rows.map((row) => [row.kind, row.itemId, row.isEnabled, row.layerId])).toEqual([
+ ['adjustment-brightness-contrast', 'ga1', true, 'g1'],
+ ['adjustment-invert', 'ga2', false, 'g1'],
+ ]);
+ });
+
+ it('emits group-arm patches for toggle, move, rename, and drop reorder', () => {
+ const document = documentFrom([groupWith(stack())]);
+ const toggled = layerChildRowCommand(
+ document,
+ { itemId: 'ga2', layerId: 'g1' },
+ { isEnabled: true, type: 'set-enabled' }
+ );
+ expect(toggled).toMatchObject({
+ before: { layerType: 'group' },
+ config: { layerType: 'group' },
+ id: 'g1',
+ type: 'patch-config',
+ });
+ expect((toggled!.config as unknown as { adjustments: CanvasAdjustmentEntry[] }).adjustments[1]!.isEnabled).toBe(
+ true
+ );
+
+ const renamed = layerChildRowCommand(
+ document,
+ { itemId: 'ga1', layerId: 'g1' },
+ { name: 'Warmth', type: 'rename' }
+ );
+ expect((renamed!.config as unknown as { adjustments: CanvasAdjustmentEntry[] }).adjustments[0]!.name).toBe(
+ 'Warmth'
+ );
+
+ const dropped = layerChildDropCommand(
+ document,
+ { itemId: 'ga1', kind: 'adjustment-brightness-contrast', layerId: 'g1' },
+ { beforeItemId: null, layerId: 'g1' }
+ );
+ expect(dropped).toMatchObject({ config: { layerType: 'group' }, id: 'g1' });
+ expect(
+ (dropped as unknown as { config: { adjustments: CanvasAdjustmentEntry[] } }).config.adjustments.map(
+ (entry) => entry.id
+ )
+ ).toEqual(['ga2', 'ga1']);
+ });
+
+ it('resolves group-owned child items', () => {
+ const document = documentFrom([groupWith(stack())]);
+ expect(getLayerChildItem(document, 'g1', 'ga1')).toEqual({
+ isEnabled: true,
+ kind: 'adjustment-brightness-contrast',
+ });
+ });
+});
+
describe('adjustment rows', () => {
const entries = () => [
{ brightness: 0.1, contrast: 0, id: 'a1', isEnabled: true, type: 'brightness-contrast' as const },
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
index aa07175794..bd6b98c606 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerChildRows.ts
@@ -7,7 +7,7 @@ import type {
SemanticNode,
} from '@workbench/canvas-engine/api';
-import { getDocumentLayer } from '@workbench/canvas-engine/api';
+import { getDocumentLayer, getDocumentNode } from '@workbench/canvas-engine/api';
import { layerChildRowKey } from '@workbench/layerPanelState';
export { layerChildRowKey };
@@ -127,6 +127,33 @@ export interface LayerChildItem {
readonly isEnabled: boolean;
}
+/** The node whose adjustment stack a child row edits: a raster layer or a raster-stack group. */
+const adjustmentOwnerNode = (document: CanvasDocumentContractV3, id: string) => {
+ const node = getDocumentNode(document, id);
+ return node && (node.type === 'raster' || node.type === 'group') ? node : null;
+};
+
+/** The whole-stack patch both adjustment owners share; the arm follows the owner's type. */
+const adjustmentsPatch = (
+ ownerType: 'raster' | 'group',
+ id: string,
+ before: readonly CanvasAdjustmentEntry[],
+ next: CanvasAdjustmentEntry[]
+): PatchConfigCommand =>
+ ownerType === 'group'
+ ? {
+ before: { adjustments: [...before], layerType: 'group' },
+ config: { adjustments: next, layerType: 'group' },
+ id,
+ type: 'patch-config',
+ }
+ : {
+ before: { adjustments: [...before], layerType: 'raster' },
+ config: { adjustments: next, layerType: 'raster' },
+ id,
+ type: 'patch-config',
+ };
+
const EMPTY_CHILD_ROWS: readonly ProjectedChildRow[] = [];
const childRowsByNode = new WeakMap<SemanticNode, readonly ProjectedChildRow[]>();
@@ -194,7 +221,7 @@ export const projectLayerChildRows = (vm: SemanticNode): readonly ProjectedChild
}));
} else if (node.type === 'inpaint_mask' && (node.noise || node.denoise)) {
rows = maskModifierRows(vm, node);
- } else if (node.type === 'raster' && node.adjustments && node.adjustments.length > 0) {
+ } else if ((node.type === 'raster' || node.type === 'group') && node.adjustments && node.adjustments.length > 0) {
const setSize = node.adjustments.length;
rows = node.adjustments.map((adjustment, index): ProjectedChildRow => ({
...baseRow(vm),
@@ -234,8 +261,9 @@ export const getLayerChildItem = (
return { isEnabled: layer.denoise.isEnabled, kind: 'mask-denoise' };
}
}
- if (layer?.type === 'raster') {
- const entry = layer.adjustments?.find((candidate) => candidate.id === itemId);
+ const owner = layer ?? adjustmentOwnerNode(document, layerId);
+ if (owner && (owner.type === 'raster' || owner.type === 'group')) {
+ const entry = owner.adjustments?.find((candidate) => candidate.id === itemId);
return entry ? { isEnabled: entry.isEnabled, kind: ADJUSTMENT_KIND_OF[entry.type] } : null;
}
return null;
@@ -290,10 +318,12 @@ export const layerChildDropCommand = (
}
const source = getDocumentLayer(document, child.layerId);
if (isOrderedChildKind(child.kind)) {
- if (target.layerId !== child.layerId || source?.type !== 'raster') {
+ const sourceOwner =
+ source?.type === 'raster' ? source : source ? null : adjustmentOwnerNode(document, child.layerId);
+ if (target.layerId !== child.layerId || !sourceOwner) {
return null;
}
- const before = source.adjustments ?? [];
+ const before = sourceOwner.adjustments ?? [];
const entry = before.find((candidate) => candidate.id === child.itemId);
if (!entry) {
return null;
@@ -306,12 +336,7 @@ export const layerChildDropCommand = (
if (next.every((candidate, index) => candidate === before[index])) {
return null;
}
- return {
- before: { adjustments: [...before], layerType: 'raster' },
- config: { adjustments: next, layerType: 'raster' },
- id: child.layerId,
- type: 'patch-config',
- };
+ return adjustmentsPatch(sourceOwner.type, child.layerId, before, next);
}
if (child.kind !== 'reference-image' || source?.type !== 'regional_guidance') {
return null;
@@ -423,8 +448,9 @@ export const layerChildRowCommand = (
type: 'patch-config',
};
}
- if (layer?.type === 'raster') {
- const before = layer.adjustments ?? [];
+ const owner = layer?.type === 'raster' ? layer : layer ? null : adjustmentOwnerNode(document, target.layerId);
+ if (owner) {
+ const before = owner.adjustments ?? [];
const index = before.findIndex((entry) => entry.id === target.itemId);
if (index < 0) {
return null;
@@ -475,12 +501,7 @@ export const layerChildRowCommand = (
break;
}
}
- return {
- before: { adjustments: [...before], layerType: 'raster' },
- config: { adjustments: next, layerType: 'raster' },
- id: target.layerId,
- type: 'patch-config',
- };
+ return adjustmentsPatch(owner.type, target.layerId, before, next);
}
return null;
};
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
index 1480c7fe40..e7a50d1d14 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerContextActions.ts
@@ -201,6 +201,31 @@ export interface LayerContextAction {
export type LayerConfigPatchKind = 'control-transparency-effect' | 'regional-auto-negative';
const ALL_LAYER_TYPES = ['raster', 'control', 'inpaint_mask', 'regional_guidance'] as const;
+/**
+ * The one add-adjustment catalog: the leaf context menu derives its `add-*`
+ * actions from it and the group context menu renders it directly, so a new
+ * entry type lands in both menus from one edit.
+ */
+export const ADJUSTMENT_ADD_ITEMS: readonly {
+ readonly defaultLabel: string;
+ readonly icon: LucideIcon;
+ readonly labelKey: string;
+ readonly type: CanvasAdjustmentEntry['type'];
+}[] = [
+ {
+ defaultLabel: 'Brightness/Contrast',
+ icon: SunMediumIcon,
+ labelKey: 'widgets.layers.modifiers.brightnessContrast',
+ type: 'brightness-contrast',
+ },
+ { defaultLabel: 'Exposure', icon: ApertureIcon, labelKey: 'widgets.layers.adjustments.exposure', type: 'exposure' },
+ { defaultLabel: 'Levels', icon: SlidersVerticalIcon, labelKey: 'widgets.layers.adjustments.levels', type: 'levels' },
+ { defaultLabel: 'Curves', icon: SplineIcon, labelKey: 'widgets.layers.adjustments.curves', type: 'curves' },
+ { defaultLabel: 'Saturation', icon: DropletIcon, labelKey: 'widgets.layers.adjustments.saturation', type: 'hsl' },
+ { defaultLabel: 'Hue', icon: RainbowIcon, labelKey: 'widgets.layers.adjustments.hue', type: 'hue' },
+ { defaultLabel: 'Invert', icon: ContrastIcon, labelKey: 'widgets.layers.adjustments.invert', type: 'invert' },
+];
+
const RASTER_ONLY = ['raster'] as const;
const CONTROL_ONLY = ['control'] as const;
const RASTER_AND_CONTROL = ['raster', 'control'] as const;
@@ -423,97 +448,19 @@ export const LAYER_CONTEXT_ACTION_DEFINITIONS: readonly LayerContextActionDefini
section: 'primary',
supportedLayerTypes: ALL_LAYER_TYPES,
},
- {
- defaultLabel: 'Brightness/Contrast',
- handler: ({ effects }) => effects.addAdjustment('brightness-contrast'),
- icon: SunMediumIcon,
- id: 'add-brightness-contrast',
- isEnabled: isLayerMutable,
- isVisible: alwaysVisible,
- labelKey: 'widgets.layers.modifiers.brightnessContrast',
- order: 31,
- section: 'primary',
- submenu: 'add-adjustment',
- supportedLayerTypes: RASTER_ONLY,
- },
- {
- defaultLabel: 'Exposure',
- handler: ({ effects }) => effects.addAdjustment('exposure'),
- icon: ApertureIcon,
- id: 'add-exposure',
- isEnabled: isLayerMutable,
- isVisible: alwaysVisible,
- labelKey: 'widgets.layers.adjustments.exposure',
- order: 31.05,
- section: 'primary',
- submenu: 'add-adjustment',
- supportedLayerTypes: RASTER_ONLY,
- },
- {
- defaultLabel: 'Levels',
- handler: ({ effects }) => effects.addAdjustment('levels'),
- icon: SlidersVerticalIcon,
- id: 'add-levels',
- isEnabled: isLayerMutable,
- isVisible: alwaysVisible,
- labelKey: 'widgets.layers.adjustments.levels',
- order: 31.1,
- section: 'primary',
- submenu: 'add-adjustment',
- supportedLayerTypes: RASTER_ONLY,
- },
- {
- defaultLabel: 'Curves',
- handler: ({ effects }) => effects.addAdjustment('curves'),
- icon: SplineIcon,
- id: 'add-curves',
- isEnabled: isLayerMutable,
- isVisible: alwaysVisible,
- labelKey: 'widgets.layers.adjustments.curves',
- order: 31.2,
- section: 'primary',
- submenu: 'add-adjustment',
- supportedLayerTypes: RASTER_ONLY,
- },
- {
- defaultLabel: 'Saturation',
- handler: ({ effects }) => effects.addAdjustment('hsl'),
- icon: DropletIcon,
- id: 'add-hsl',
+ ...ADJUSTMENT_ADD_ITEMS.map((item, index): LayerContextActionDefinition => ({
+ defaultLabel: item.defaultLabel,
+ handler: ({ effects }) => effects.addAdjustment(item.type),
+ icon: item.icon,
+ id: `add-${item.type}` as LayerContextActionId,
isEnabled: isLayerMutable,
isVisible: alwaysVisible,
- labelKey: 'widgets.layers.adjustments.saturation',
- order: 31.3,
+ labelKey: item.labelKey,
+ order: 31 + index * 0.05,
section: 'primary',
submenu: 'add-adjustment',
supportedLayerTypes: RASTER_ONLY,
- },
- {
- defaultLabel: 'Hue',
- handler: ({ effects }) => effects.addAdjustment('hue'),
- icon: RainbowIcon,
- id: 'add-hue',
- isEnabled: isLayerMutable,
- isVisible: alwaysVisible,
- labelKey: 'widgets.layers.adjustments.hue',
- order: 31.4,
- section: 'primary',
- submenu: 'add-adjustment',
- supportedLayerTypes: RASTER_ONLY,
- },
- {
- defaultLabel: 'Invert',
- handler: ({ effects }) => effects.addAdjustment('invert'),
- icon: ContrastIcon,
- id: 'add-invert',
- isEnabled: isLayerMutable,
- isVisible: alwaysVisible,
- labelKey: 'widgets.layers.adjustments.invert',
- order: 31.5,
- section: 'primary',
- submenu: 'add-adjustment',
- supportedLayerTypes: RASTER_ONLY,
- },
+ })),
{
defaultLabel: 'Filter',
handler: ({ effects, layer }) => effects.startFilter(layer.id),
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.test.ts
index bd49e51472..00cae2dfd4 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.test.ts
@@ -1,6 +1,10 @@
-import type { RegionalGuidanceReferenceImage } from '@workbench/canvas-engine/api';
+import type { CanvasAdjustmentEntry, RegionalGuidanceReferenceImage } from '@workbench/canvas-engine/api';
-import { documentFrom, layerContract } from '@workbench/canvas-engine/document-model/documentFixtures.testStub';
+import {
+ documentFrom,
+ groupContract,
+ layerContract,
+} from '@workbench/canvas-engine/document-model/documentFixtures.testStub';
import { describe, expect, it } from 'vitest';
import type { PanelRow } from './layerPanelRows';
@@ -102,3 +106,49 @@ describe('navigateTree over child rows', () => {
expect(navigateTree(flatten(new Set(['rg1'])), 'rg1', 'ArrowLeft')).toEqual({ focus: 'header:regional_guidance' });
});
});
+
+describe('group-owned adjustment rows', () => {
+ const stack = (): CanvasAdjustmentEntry[] => [
+ { brightness: 0.2, contrast: 0, id: 'ga1', isEnabled: true, type: 'brightness-contrast' },
+ { id: 'ga2', isEnabled: true, type: 'invert' },
+ ];
+ const groupStacks = (expandedGroups: ReadonlySet<string>) =>
+ buildLayerStackRows(
+ documentFrom([
+ groupContract('g1', [layerContract('m1'), layerContract('m2'), layerContract('m3')], {
+ adjustments: stack(),
+ }),
+ ]).stacks,
+ expandedGroups
+ );
+ const flattenGroup = (expandedGroups: ReadonlySet<string> = new Set(['g1'])) =>
+ flattenPanelRows(groupStacks(expandedGroups), [], open, {
+ collapsedLayerIds: new Set(),
+ rowsFor: (row) => projectLayerChildRows(row.vm),
+ });
+
+ it("folds a group's rows with its subtree: a collapsed group renders neither", () => {
+ expect(keys(flattenGroup(new Set()))).toEqual(['header:raster', 'g1']);
+ expect(keys(flattenGroup())).toEqual(['header:raster', 'g1', 'child:g1:ga1', 'child:g1:ga2', 'm1', 'm2', 'm3']);
+ });
+
+ it('announces rows and member nodes as ONE combined ARIA set under the group', () => {
+ const rows = flattenGroup();
+ const children = rows.filter((row) => row.kind === 'child');
+ expect(children.map((row) => (row.kind === 'child' ? row.ariaSetSize : 0))).toEqual([5, 5]);
+ const members = rows.filter((row) => row.kind === 'node' && row.key.startsWith('m'));
+ expect(members.map((row) => (row.kind === 'node' ? [row.ariaPosInSet, row.ariaSetSize] : null))).toEqual([
+ [3, 5],
+ [4, 5],
+ [5, 5],
+ ]);
+ });
+
+ it('ArrowRight expands the subtree; ArrowLeft collapses it — never a separate rows fold', () => {
+ const collapsedRows = flattenGroup(new Set());
+ expect(navigateTree(collapsedRows, 'g1', 'ArrowRight')).toEqual({ expand: 'g1', expanded: true });
+ const expandedRows = flattenGroup();
+ expect(navigateTree(expandedRows, 'g1', 'ArrowRight')).toEqual({ focus: 'child:g1:ga1' });
+ expect(navigateTree(expandedRows, 'g1', 'ArrowLeft')).toEqual({ expand: 'g1', expanded: false });
+ });
+});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.ts
index 63bbca9771..d33e2ac0b4 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/layerPanelRows.ts
@@ -29,11 +29,25 @@ export type PanelRow =
readonly key: string;
readonly stack: LayerStackKind;
readonly row: LayerTreeRow;
- /** Projected child rows the node owns; `0` for groups and bare leaves. */
+ /** Projected child rows the node owns; `0` for bare leaves and rowless groups. */
readonly childCount: number;
readonly childrenExpanded: boolean;
+ /**
+ * The node's ARIA position among the parent group's COMBINED children
+ * (modifier rows first, then nodes) when the parent owns modifier rows;
+ * equal to the tree row's own values otherwise.
+ */
+ readonly ariaPosInSet: number;
+ readonly ariaSetSize: number;
}
- | { readonly kind: 'child'; readonly key: string; readonly stack: LayerStackKind; readonly child: ProjectedChildRow };
+ | {
+ readonly kind: 'child';
+ readonly key: string;
+ readonly stack: LayerStackKind;
+ readonly child: ProjectedChildRow;
+ /** The owner's combined child count (rows + node children) for a group owner. */
+ readonly ariaSetSize: number;
+ };
/** How a flattening projects child rows beneath the layers that own them. */
export interface PanelChildRowsSource {
@@ -73,13 +87,35 @@ export const flattenPanelRows = (
stack,
});
if (!collapsed) {
+ // A group whose parent owns modifier rows shifts its node children into
+ // one COMBINED ARIA set (rows first, then nodes) so AT hears a single
+ // coherent set at that level.
+ const rowOffsetByParent = new Map<string, number>();
for (const row of stack.rows) {
- const children = childRows?.rowsFor(row) ?? [];
- const childrenExpanded = children.length > 0 && !childRows!.collapsedLayerIds.has(row.id);
- rows.push({ childCount: children.length, childrenExpanded, key: row.id, kind: 'node', row, stack: kind });
+ const isGroup = row.vm.kind === 'group';
+ // A group's modifier rows fold WITH its subtree: `aria-expanded`
+ // reflects the subtree, so nothing may render beneath a collapsed
+ // group. Leaves keep their separate per-owner fold.
+ const children = isGroup && !row.expanded ? [] : (childRows?.rowsFor(row) ?? []);
+ const childrenExpanded = children.length > 0 && (isGroup || !childRows!.collapsedLayerIds.has(row.id));
+ const offset = rowOffsetByParent.get(row.vm.parentId ?? '') ?? 0;
+ if (isGroup && childrenExpanded) {
+ rowOffsetByParent.set(row.id, children.length);
+ }
+ rows.push({
+ ariaPosInSet: row.posInSet + offset,
+ ariaSetSize: row.setSize + offset,
+ childCount: children.length,
+ childrenExpanded,
+ key: row.id,
+ kind: 'node',
+ row,
+ stack: kind,
+ });
if (childrenExpanded) {
+ const combined = isGroup ? children.length + row.vm.childCount : children.length;
for (const child of children) {
- rows.push({ child, key: child.key, kind: 'child', stack: kind });
+ rows.push({ ariaSetSize: combined, child, key: child.key, kind: 'child', stack: kind });
}
}
}
@@ -150,21 +186,21 @@ export const navigateTree = (
return null;
}
const { row } = current;
- if (current.childCount > 0) {
- if (!current.childrenExpanded) {
- return { expandChildren: row.id, expanded: true };
- }
- const first = rows[position + 1];
- return first && first.kind === 'child' && first.child.layerId === row.id ? { focus: first.key } : null;
+ // A group expands its subtree before its modifier rows; a leaf has only rows.
+ if (row.vm.kind === 'group' && row.vm.childCount > 0 && !row.expanded) {
+ return { expand: row.id, expanded: true };
}
- if (row.vm.kind !== 'group' || row.vm.childCount === 0) {
- return null;
+ if (current.childCount > 0 && !current.childrenExpanded) {
+ return { expandChildren: row.id, expanded: true };
}
- if (!row.expanded) {
- return { expand: row.id, expanded: true };
+ const next = rows[position + 1];
+ if (next && next.kind === 'child' && next.child.layerId === row.id) {
+ return { focus: next.key };
}
- const child = rows[position + 1];
- return child && child.kind === 'node' && child.row.vm.parentId === row.id ? { focus: child.key } : null;
+ if (next && next.kind === 'node' && next.row.vm.parentId === row.id) {
+ return { focus: next.key };
+ }
+ return null;
}
case 'ArrowLeft': {
if (current.kind === 'header') {
@@ -174,12 +210,14 @@ export const navigateTree = (
return { focus: current.child.layerId };
}
const { row } = current;
+ // Mirror of ArrowRight. A group's rows fold with its subtree, so only a
+ // LEAF's rows fold separately here.
+ if (row.vm.kind !== 'group' && current.childrenExpanded) {
+ return { expandChildren: row.id, expanded: false };
+ }
if (row.vm.kind === 'group' && row.expanded) {
return { expand: row.id, expanded: false };
}
- if (current.childrenExpanded) {
- return { expandChildren: row.id, expanded: false };
- }
return { focus: row.vm.parentId ?? headerKey(row.vm.stack) };
}
}
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 9acea00a64..3884f6c133 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerSection.tsx
@@ -1,8 +1,8 @@
-import type { CanvasDocumentContractV3, CanvasLayerContract } from '@workbench/canvas-engine/api';
+import type { CanvasDocumentContractV3, CanvasLayerContract, CanvasNodeContract } from '@workbench/canvas-engine/api';
import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';
import { Stack, Switch, Text } from '@chakra-ui/react';
-import { getDocumentLayer } from '@workbench/canvas-engine/api';
+import { getDocumentNode } from '@workbench/canvas-engine/api';
import { useCanvasEngine } from '@workbench/widgets/canvas/useCanvasEngine';
import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';
import { AdjustmentSettings } from '@workbench/widgets/layers/AdjustmentSettings';
@@ -33,11 +33,11 @@ type LayerSectionEngine = Pick<
>;
// Reference equality is exact: the document index hands back the same node
-// object until the layer itself changes, and the section renders the whole
-// layer, so a narrower comparison would serve stale views of it.
-const selectSelectedLayer = (project: {
+// object until the node itself changes, and the section renders the whole
+// node, so a narrower comparison would serve stale views of it.
+const selectSelectedNode = (project: {
canvas: { document: Pick<CanvasDocumentContractV3, 'stacks' | 'selectedLayerId'> };
-}): CanvasLayerContract | null => getDocumentLayer(project.canvas.document, project.canvas.document.selectedLayerId);
+}): CanvasNodeContract | null => getDocumentNode(project.canvas.document, project.canvas.document.selectedLayerId);
/**
* The Layer section of the Properties pane: the selected layer's type-specific
@@ -48,20 +48,21 @@ const selectSelectedLayer = (project: {
export const LayerSection = ({ disabled }: { disabled: boolean }) => {
const { t } = useTranslation();
const engine = useCanvasEngine();
- const layer = useActiveProjectSelector(selectSelectedLayer);
+ const node = useActiveProjectSelector(selectSelectedNode);
+ const layer = node && node.type !== 'group' ? node : null;
const documentRevision = useActiveProjectSelector((project) => project.canvas.documentRevision);
const projectId = useActiveProjectId();
const childSelection = useLayerChildSelection();
- const child = resolveChildEditor(layer, childSelection?.projectId === projectId ? childSelection : null, t);
+ const child = resolveChildEditor(node, childSelection?.projectId === projectId ? childSelection : null, t);
return (
<PropertiesSection
disabled={disabled}
- subtitle={child ? child.subtitle : (layer?.name ?? t('widgets.transform.noSelection'))}
+ subtitle={child ? child.subtitle : (node?.name ?? t('widgets.transform.noSelection'))}
title={t('widgets.properties.sections.layer')}
>
- {child && layer ? (
- <ChildEditor key={`${layer.id}:${child.itemId}`} child={child} engine={engine} layer={layer} />
+ {child && node ? (
+ <ChildEditor key={`${node.id}:${child.itemId}`} child={child} engine={engine} node={node} />
) : layer ? (
<LayerTypeSettings documentRevision={documentRevision} engine={engine} layer={layer} />
) : (
@@ -79,7 +80,7 @@ interface ChildEditorTarget {
/** What the sub-selection edits, or `null` when it does not belong to `layer`. */
const resolveChildEditor = (
- layer: CanvasLayerContract | null,
+ layer: CanvasNodeContract | null,
selection: { layerId: string; itemId: string } | null,
t: (key: string) => string
): ChildEditorTarget | null => {
@@ -104,7 +105,7 @@ const resolveChildEditor = (
return { itemId: selection.itemId, kind: 'mask-denoise', subtitle: t('widgets.layers.modifiers.denoise') };
}
}
- if (layer.type === 'raster') {
+ if (layer.type === 'raster' || layer.type === 'group') {
const entry = layer.adjustments?.find((candidate) => candidate.id === selection.itemId);
if (entry) {
const kind = adjustmentChildKind(entry.type);
@@ -117,20 +118,20 @@ const resolveChildEditor = (
const ChildEditor = ({
child,
engine,
- layer,
+ node,
}: {
child: ChildEditorTarget;
engine: LayerSectionEngine | null;
- layer: CanvasLayerContract;
+ node: CanvasNodeContract;
}) => {
- if (child.kind === 'reference-image' && layer.type === 'regional_guidance') {
- return <ReferenceImageSettings engine={engine} layer={layer} refId={child.itemId} />;
+ if (child.kind === 'reference-image' && node.type === 'regional_guidance') {
+ return <ReferenceImageSettings engine={engine} layer={node} refId={child.itemId} />;
}
- if ((child.kind === 'mask-noise' || child.kind === 'mask-denoise') && layer.type === 'inpaint_mask') {
- return <MaskModifierSettings engine={engine} kind={child.kind} layer={layer} />;
+ if ((child.kind === 'mask-noise' || child.kind === 'mask-denoise') && node.type === 'inpaint_mask') {
+ return <MaskModifierSettings engine={engine} kind={child.kind} layer={node} />;
}
- if (child.kind.startsWith('adjustment-') && layer.type === 'raster') {
- return <AdjustmentSettings engine={engine} entryId={child.itemId} layer={layer} />;
+ if (child.kind.startsWith('adjustment-') && (node.type === 'raster' || node.type === 'group')) {
+ return <AdjustmentSettings engine={engine} entryId={child.itemId} layer={node} />;
}
return null;
};