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.

Merge remote-tracking branch 'origin/main' into fix/canvas-v7-feedback

Josh Corbettc89af6aeae0b
diff --cc docs/src/content/docs/Users Guide/07.Canvas/02.canvas-guide.mdx
index 2074e704de,6f2ffb7258..7d1c470f14
--- a/docs/src/content/docs/Users Guide/07.Canvas/02.canvas-guide.mdx
+++ b/docs/src/content/docs/Users Guide/07.Canvas/02.canvas-guide.mdx
@@@ -77,10 -70,10 +77,10 @@@ The buttons along the top of the canvas
* **Zoom level** and **Fit to view**.
* **Fit frame to layers** (**Shift+N**) — resizes the generation frame to enclose all layers.
-* **Fit frame to masks** (**Shift+B**) — resizes the generation frame to enclose the inpaint masks.
+* **Fit frame to masks** (**Shift+B**) — resizes the generation frame to enclose the inpaint masks, with a margin of the **Mask blur** (in the Generate panel's **Compositing** section) plus 8 pixels, so the blurred edge of the mask stays inside the frame. With the default blur of 16, the margin is 24 pixels.
* **Undo canvas edit** (**Ctrl+Z**) and **Redo canvas edit** (**Ctrl+Shift+Z** or **Ctrl+Y**).
- * **Save Canvas to Gallery** — saves the visible canvas as an image on the Gallery's selected board. Its arrow offers **Save Frame to Gallery**, which saves only what is inside the generation frame.
- * **New session → New canvas** — clears all layers and starts a fresh canvas with an empty inpaint mask. This cannot be undone.
-* **Save Canvas to Gallery** — saves the visible canvas as an image on the board new results go to: the auto-add board, or the selected board when none is set (see [Choosing where new media goes](/users-guide/gallery/introduction/#choosing-where-new-media-goes)). Its arrow offers **Save BBox to Gallery**, which saves only what is inside the generation frame. A message names the board the image went to; its **Show in Gallery** button selects the image in the Gallery and keeps the Canvas in the center.
++* **Save Canvas to Gallery** — saves the visible canvas as an image on the board new results go to: the auto-add board, or the selected board when none is set (see [Choosing where new media goes](/users-guide/gallery/introduction/#choosing-where-new-media-goes)). Its arrow offers **Save Frame to Gallery**, which saves only what is inside the generation frame. A message names the board the image went to; its **Show in Gallery** button selects the image in the Gallery and keeps the Canvas in the center.
+ * **Clear canvas** (**Ctrl+Alt+N**, **Cmd+Option+N** on macOS) — after you confirm, clears all layers and starts a fresh canvas with an empty inpaint mask. This cannot be undone.
* **Canvas settings** — see [below](#canvas-settings).
## The generation frame
diff --cc invokeai/frontend/webv2/performance/browser-baseline.json
index 16794ae837,71f8467abc..dd3b077f93
--- a/invokeai/frontend/webv2/performance/browser-baseline.json
+++ b/invokeai/frontend/webv2/performance/browser-baseline.json
@@@ -2938,7 -2929,7 +2930,8 @@@
"source:src/workbench/widgets/canvas/engineStoreHooks.ts",
"source:src/workbench/widgets/canvas/executeCanvasImageDropImport.ts",
"source:src/workbench/widgets/canvas/fitBbox.ts",
+ "source:src/workbench/widgets/canvas/frameIcons.ts",
+ "source:src/workbench/widgets/canvas/gallerySaveToast.ts",
"source:src/workbench/widgets/canvas/implementation.ts",
"source:src/workbench/widgets/canvas/invoke/canvasCompositing.ts",
"source:src/workbench/widgets/canvas/invoke/canvasScaling.ts",
diff --cc invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts
index 2b3d717080,8f02378bcf..319759e7e8
--- a/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts
+++ b/invokeai/frontend/webv2/src/workbench/hotkeys/catalog.ts
@@@ -292,13 -286,13 +292,14 @@@ export const firstPartyHotkeyCatalog: H
hotkey('canvas', 'applySegmentAnything', ['enter']),
hotkey('canvas', 'cancelSegmentAnything', ['esc']),
hotkey('canvas', 'toggleNonRasterLayers', ['shift+h']),
- hotkey('canvas', 'fitBboxToMasks', ['shift+b']),
- hotkey('canvas', 'toggleBbox', ['shift+o']),
+ hotkey('canvas', 'fitBboxToMasks', ['shift+b'], { title: 'Fit Frame To Masks' }),
+ hotkey('canvas', 'toggleBbox', ['shift+o'], { title: 'Toggle Frame' }),
- // New canvas session, the gallery saves and crop all: no default keys — assignable via the hotkeys settings.
- hotkey('canvas', 'newSession', []),
+ // Clear canvas keeps its saved-binding id, `newSession`.
+ hotkey('canvas', 'newSession', ['mod+alt+n'], { title: 'Clear Canvas' }),
- // The gallery saves have no default keys; they are assignable through the hotkeys settings.
++ // The gallery saves and crop all have no default keys; they are assignable through the hotkeys settings.
hotkey('canvas', 'saveToGallery', []),
- hotkey('canvas', 'saveBboxToGallery', []),
+ hotkey('canvas', 'saveBboxToGallery', [], { title: 'Save Frame To Gallery' }),
+ hotkey('canvas', 'cropAllLayersToFrame', []),
hotkey('workflows', 'addNode', ['shift+a', 'space']),
hotkey('workflows', 'copySelection', ['mod+c']),
hotkey('workflows', 'pasteSelection', ['mod+v']),
diff --cc invokeai/frontend/webv2/src/workbench/widgets/canvas/canvasHeaderCommands.ts
index fd4a9fc66b,db82842977..83e2186eb0
--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/canvasHeaderCommands.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/canvasHeaderCommands.ts
@@@ -80,35 -80,9 +80,36 @@@ export const confirmNewCanvas = (ctx: N
ctx.engine.document.replaceDocument(createNewCanvasState(ctx.document.width, ctx.document.height).document);
};
+/** The header's commands as `[id, titleKey, defaultKeys]`; the header registers them while the Canvas is mounted. */
+export const CANVAS_HEADER_HOTKEYS = [
+ ['canvas.fitBboxToLayers', 'widgets.canvas.controls.fitBboxToLayers', ['shift+n']],
+ ['canvas.fitBboxToMasks', 'widgets.canvas.controls.fitBboxToMasks', ['shift+b']],
- // No default keys — assignable through the hotkeys settings.
++ // The gallery saves have no default keys; they are assignable through the hotkeys settings.
+ ['canvas.saveToGallery', 'widgets.canvas.contextMenu.saveCanvasToGallery', []],
+ ['canvas.saveBboxToGallery', 'widgets.canvas.contextMenu.saveBboxToGallery', []],
- ['canvas.newSession', 'widgets.canvas.controls.newSession', []],
++ // Clear canvas keeps its saved-binding id, `newSession`.
++ ['canvas.newSession', 'widgets.canvas.controls.clearCanvas', ['mod+alt+n']],
+ // Browsers reserve Mod+1…8 for tab switching; these act only where the browser delivers the chord.
+ ['canvas.setZoomTo100Percent', 'widgets.canvas.commands.zoomTo100', ['mod+1']],
+ ['canvas.setZoomTo200Percent', 'widgets.canvas.commands.zoomTo200', ['mod+2']],
+ ['canvas.setZoomTo400Percent', 'widgets.canvas.commands.zoomTo400', ['mod+3']],
+ ['canvas.setZoomTo800Percent', 'widgets.canvas.commands.zoomTo800', ['mod+4']],
+] as const satisfies readonly (readonly [id: string, titleKey: string, defaultKeys: readonly string[]])[];
+
+/** The zoom preset commands and the scale each sets about the viewport centre. */
+const ZOOM_PRESET_COMMANDS: Readonly<Record<string, number>> = {
+ 'canvas.setZoomTo100Percent': 1,
+ 'canvas.setZoomTo200Percent': 2,
+ 'canvas.setZoomTo400Percent': 4,
+ 'canvas.setZoomTo800Percent': 8,
+};
+
/** Route new-session commands through the button's confirmation dialog. */
export const executeCanvasHeaderCommand = (commandId: string, ctx: CanvasHeaderCommandContext): void => {
- if (commandId === 'canvas.fitBboxToLayers') {
+ const zoomPreset = ZOOM_PRESET_COMMANDS[commandId];
+ if (zoomPreset !== undefined) {
+ zoomAtViewportCentre(ctx.engine, zoomPreset);
+ } else if (commandId === 'canvas.fitBboxToLayers') {
applyFitBbox(ctx, ctx.fitLayersRect, true);
} else if (commandId === 'canvas.fitBboxToMasks') {
applyFitBbox(ctx, ctx.fitMasksRect, false);