Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
5f46a98
Photo Studio: styled groups of many large photos redraw when a child'…
jelveh Nov 19, 2026
92161e8
Photo Studio: the Gradient tool on a layer with locked transparency c…
jelveh Nov 19, 2026
aacd08e
Photo Studio: GPU memory of layer effects that are turned off or hidd…
jelveh Nov 19, 2026
f0887be
Photo Studio: Threshold adjustment layers and the Threshold dialog pr…
jelveh Nov 19, 2026
2bd5a15
Photo Studio: filters and Liquify keep the alpha of a layer whose tra…
jelveh Nov 19, 2026
3f8c8c1
Photo Studio: Blur and Sharpen with Sample All Layers keep to their Mode
jelveh Nov 19, 2026
e6d192b
Photo Studio: a quick Mixer Brush click with Sample All Layers is sto…
jelveh Nov 19, 2026
ed6493f
Photo Studio: Escape drops a Spot Healing or Remove stroke being painted
jelveh Nov 19, 2026
78ef37a
Photo Studio: Save asks before writing one frame or page over an anim…
jelveh Nov 19, 2026
c6e2929
Photo Studio: Save asks before writing an image without its EXIF, XMP…
jelveh Nov 19, 2026
05bd300
Photo Studio: files picked in Puter are opened or saved even when ano…
jelveh Nov 19, 2026
cd57aba
Photo Studio: agreeing to flatten a Save a Copy no longer lets Save f…
jelveh Nov 19, 2026
ef299fb
Photo Studio: one document that cannot be kept for recovery no longer…
jelveh Nov 19, 2026
9bce445
Photo Studio: opening a large PNG no longer checksums the whole file …
jelveh Nov 19, 2026
e915656
Photo Studio: the Image Processor no longer fills Open Recent with th…
jelveh Nov 19, 2026
b2aab6d
Photo Studio: a restored document still asks before Save drops what i…
jelveh Nov 19, 2026
cbf9f87
Photo Studio: a 16-bit PNG opens turned upright by its EXIF orientati…
jelveh Nov 19, 2026
e5e5fdb
Photo Studio: recorded actions replay Tween, frame delay, looping, on…
jelveh Nov 19, 2026
0127d4e
Photo Studio: closing a document frees its decoded video frames, vide…
jelveh Nov 19, 2026
a7a1cd8
Photo Studio: actions from imported files or batch links no longer ru…
jelveh Nov 19, 2026
125fa0c
Photo Studio: an Assistant plan keeps editing its own document when a…
jelveh Nov 19, 2026
63b76ea
Photo Studio: Export for Web exports when Export is pressed right aft…
jelveh Nov 19, 2026
fb9cc40
Photo Studio: an action run by a script event plays on the event's do…
jelveh Nov 19, 2026
ce40962
Photo Studio: Lens Correction batch names the images that failed when…
jelveh Nov 19, 2026
827b8bd
Photo Studio: cancelling Export for Web while its preview is prepared…
jelveh Nov 19, 2026
1920f42
Photo Studio: Quick Compare keeps a slightly cropped stored state at …
jelveh Nov 19, 2026
7333ed0
Photo Studio: cancelling Liquify while Find with AI is still waiting …
jelveh Nov 19, 2026
5fb9838
Photo Studio: AI Recompose keeps the arrangement you changed while a …
jelveh Nov 19, 2026
5a1a3e8
Photo Studio: with a relight layer selected, arrow keys in the Path S…
jelveh Nov 19, 2026
34dcd2d
Photo Studio: relight handles follow nudges and undo after a Properti…
jelveh Nov 19, 2026
7ced31b
Photo Studio: Remove Reflections says when the full-size result fails…
jelveh Nov 19, 2026
10a58fb
Photo Studio: the Develop white balance eyedropper and targeted adjus…
jelveh Nov 19, 2026
7a0b9b8
Photo Studio: Generation History places each Rotate Object variation …
jelveh Nov 19, 2026
60c6f0b
Photo Studio: AI Recompose and Rotate Object say that a locked cut-ou…
jelveh Nov 19, 2026
43eaa90
Photo Studio: the empty Generation History panel lists AI Recompose, …
jelveh Nov 19, 2026
f308a7d
Photo Studio: ungrouping a hidden group keeps its layers hidden, and …
jelveh Nov 19, 2026
8447c3e
Photo Studio: Align refuses to move a linked layer whose position is …
jelveh Nov 19, 2026
56ec84f
Photo Studio: Reverse keeps the Background at the bottom and leaves p…
jelveh Nov 19, 2026
a613118
Photo Studio: number keys and blend-mode keys on another layer make a…
jelveh Nov 19, 2026
a16b0be
Photo Studio: Delete All Empty Layers keeps locked layers and the lay…
jelveh Nov 19, 2026
643762a
Photo Studio: the Properties panel's background fill leaves a locked …
jelveh Nov 19, 2026
2eec875
Photo Studio: undoing a script run also undoes its first edit when it…
jelveh Nov 19, 2026
7b3962d
Photo Studio: a new layer made while a layer of a locked group is sel…
jelveh Nov 19, 2026
3a8adad
Photo Studio: a brush stroke keeps its pixels when another edit clean…
jelveh Nov 19, 2026
9bca8a8
Photo Studio: cancelling a stroke or making healing clicks on a slowl…
jelveh Nov 19, 2026
230bb94
Photo Studio: Apply Image keeps the transparency of a layer whose tra…
jelveh Nov 19, 2026
aa28da8
Photo Studio: links and accent-colored text keep 4.5:1 contrast on ev…
jelveh Nov 19, 2026
015b092
Photo Studio: the Properties panel shows an empty state on the start …
jelveh Nov 19, 2026
7ee5f45
Photo Studio: with no document open, zoom, Close and Toggle Last Stat…
jelveh Nov 19, 2026
dc0488e
Photo Studio: a document tab or its close button keeps the keyboard f…
jelveh Nov 19, 2026
65e0c5f
Photo Studio: the search button's tooltip names Ctrl+F on Windows and…
jelveh Nov 19, 2026
36dec1d
Photo Studio: after clicking a checkbox in the options bar or a panel…
jelveh Nov 19, 2026
77da1fb
Photo Studio: in a narrow window the quick actions bar shows its butt…
jelveh Nov 19, 2026
216dcab
Photo Studio: Tab on the start screen goes to its own controls instea…
jelveh Nov 19, 2026
37c3653
Photo Studio: in a horizontally flipped view the ruler counts from th…
jelveh Nov 19, 2026
5697770
Photo Studio: closing the last document clears the Navigator instead …
jelveh Nov 19, 2026
a81fcf6
Photo Studio: History on the start screen lists no steps of a placeho…
jelveh Nov 19, 2026
d615b60
Photo Studio: the color chip, Quick Mask, screen mode and panels butt…
jelveh Nov 19, 2026
518c545
Photo Studio: a primary button focused from the keyboard shows its fo…
jelveh Nov 19, 2026
60cdfba
Photo Studio: close-with-Save specs save their documents as projects,…
jelveh Nov 19, 2026
ae25970
Photo Studio: Pattern Stamp with Aligned off starts the pattern where…
jelveh Nov 19, 2026
7966031
Photo Studio: Shift-click after a smoothed Brush or Pencil stroke dra…
jelveh Nov 19, 2026
bc98173
Photo Studio: recorded actions replay Transitions, Interpret Footage …
jelveh Nov 19, 2026
dfc4f5d
Photo Studio: Run in a batch link window waits for a running task and…
jelveh Nov 19, 2026
319972a
Photo Studio: Flatten Frames Into Layers turns each frame into tiles …
jelveh Nov 19, 2026
5fc5a85
Photo Studio: Image Processor, Lens Correction batch and batch links …
jelveh Nov 19, 2026
61d741b
Photo Studio: tooltips in Liquify, Perspective Planes, Develop and Se…
jelveh Nov 19, 2026
a5641fb
Photo Studio: a hovered Assistant step name, a running step's status …
jelveh Nov 19, 2026
1cb015c
Photo Studio: arrow keys used to move through the tools panel or open…
jelveh Nov 19, 2026
2c5f507
Photo Studio: the screen mode button opens its list of modes with the…
jelveh Nov 19, 2026
59be76f
Photo Studio: a hidden relight layer, or one in a hidden group, shows…
jelveh Nov 19, 2026
0d47655
Photo Studio: a Develop preset named "__defaults" or "__last" applies…
jelveh Nov 19, 2026
b5218c1
Photo Studio: holding \ to peek at Quick Compare for the first time t…
jelveh Nov 19, 2026
219e1c4
Photo Studio: in AI Recompose, Remove Reflections and Rotate Object, …
jelveh Nov 19, 2026
df372cd
Photo Studio: resizing the window with AI Recompose, Remove Reflectio…
jelveh Nov 19, 2026
32c7578
Photo Studio: the close-with-Save transform spec saves its document a…
jelveh Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/photo-studio/src/app/shell.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { svg } from './icons';
import { formatShortcut } from './shortcuts';
import { labelDialogsOnOpen } from '../ui/dialog';
import { installLongPress } from './long-press';

Expand All @@ -12,7 +13,7 @@ export function appShell(root: HTMLElement) {
<div class="brand" title="Photo Studio" aria-label="Photo Studio">${appIcon(22)}</div>
<nav class="menubar" aria-label="Application menu"></nav>
<div class="top-actions">
<button class="top-search" data-command="edit.search" title="Search commands (⌘F)" aria-label="Search commands">${svg('search', 16)}</button>
<button class="top-search" data-command="edit.search" title="Search commands (${formatShortcut('Mod+F')})" aria-label="Search commands">${svg('search', 16)}</button>
<button data-command="file.save" class="save-button" title="Save to Puter">${svg('cloud-upload', 16)}<span>Save</span></button>
<button data-command="file.export-as" class="export-button" title="Export">Export ${svg('arrow-up-right', 16)}</button>
<button data-command="app.account" id="account" class="account" title="Puter account" aria-label="Puter account">${svg('user-round', 16)}</button>
Expand All @@ -23,7 +24,7 @@ export function appShell(root: HTMLElement) {
<div id="tool-options"></div>
<div class="options-end">
<label class="theme-label"><span class="sr-only">Color theme</span><select id="theme" aria-label="Color theme"><option value="dark">Dark</option><option value="medium">Medium</option><option value="light">Light</option><option value="system">System</option></select></label>
<button data-command="window.toggle-panels" class="icon-button" title="Show or hide panels (Tab)" aria-label="Toggle panels">${svg('panel-right', 17)}</button>
<button data-command="window.toggle-panels" class="icon-button" title="Show or hide panels (Tab)" data-key-title="Show or hide panels{key}" aria-label="Toggle panels">${svg('panel-right', 17)}</button>
</div>
</div>
<div class="editor-layout">
Expand All @@ -32,16 +33,18 @@ export function appShell(root: HTMLElement) {
<div class="tool-slots" role="toolbar" aria-label="Editing tools" aria-orientation="vertical"></div>
<div class="tool-separator" role="separator"></div>
<div class="color-chips">
<button class="chip-default" data-command="color.default" title="Default foreground and background colors (D)" aria-label="Default colors">${svg('default-colors', 12)}</button>
<button class="chip-swap" data-command="color.swap" title="Switch foreground and background colors (X)" aria-label="Switch colors">${svg('swap-colors', 12)}</button>
<button class="chip-default" data-command="color.default" title="Default foreground and background colors (D)" data-key-title="Default foreground and background colors{key}" aria-label="Default colors">${svg('default-colors', 12)}</button>
<button class="chip-swap" data-command="color.swap" title="Switch foreground and background colors (X)" data-key-title="Switch foreground and background colors{key}" aria-label="Switch colors">${svg('swap-colors', 12)}</button>
<button class="chip bg-chip" data-command="color.pick-background" aria-label="Background color" title="Set background color"></button>
<button class="chip fg-chip" data-command="color.pick-foreground" aria-label="Foreground color" title="Set foreground color"></button>
<input type="color" id="foreground" value="#000000" aria-label="Foreground color value" tabindex="-1" class="sr-only">
</div>
<button class="tool-slot quick-mask-button" data-command="select.quick-mask" data-alt-command="select.quick-mask-options" title="Edit in Quick Mask mode (Q)
Double-click or Alt-click for options" data-key-title="Edit in Quick Mask mode{key}
Double-click or Alt-click for options" aria-label="Quick Mask mode">${svg('quick-mask')}</button>
<button class="tool-slot" data-command="view.cycle-screen-mode" title="Change screen mode (F)
Right-click or hold for the list" aria-label="Change screen mode" aria-haspopup="menu">${svg('screen-mode')}</button>
Right-click, hold or press → for the list" data-key-title="Change screen mode{key}
Right-click, hold or press → for the list" aria-label="Change screen mode">${svg('screen-mode')}</button>
</aside>
<main class="workspace">
<div class="document-tabs" role="tablist" aria-label="Open documents"></div>
Expand Down
17 changes: 16 additions & 1 deletion src/photo-studio/src/app/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,28 @@ export class Toolbar {
const cancel = () => clearTimeout(timer);
el.addEventListener('pointerup', cancel);
el.addEventListener('pointerleave', cancel);
// The keys a toolbar button handles stay out of the workspace, where the
// arrows would nudge the layer with the Move tool.
el.addEventListener('keydown', (ev) => {
const open = ev.key === 'ArrowRight' || (ev.key === 'Enter' && ev.altKey);
// Like a slot's flyout, a button's list (screen modes, Quick Mask) opens
// from the keyboard too; Enter alone runs the button.
const menu = open ? buttonMenu(ev.target as HTMLElement) : undefined;
if (menu) {
ev.preventDefault();
ev.stopPropagation();
const r = (ev.target as HTMLElement).closest('button')!.getBoundingClientRect();
showContextMenu(e, r.right + 4, r.top, menu);
return;
}
const slot = (ev.target as HTMLElement).closest<HTMLElement>('[data-slot]');
if (slot && (ev.key === 'ArrowRight' || (ev.key === 'Enter' && ev.altKey))) {
if (slot && open) {
ev.preventDefault();
ev.stopPropagation();
this.openFlyout(slot.dataset.slot!, slot);
} else if (slot && (ev.key === 'ArrowDown' || ev.key === 'ArrowUp')) {
ev.preventDefault();
ev.stopPropagation();
const slots = [...el.querySelectorAll<HTMLElement>('[data-slot]')];
const at = slots.indexOf(slot);
slots[(at + (ev.key === 'ArrowDown' ? 1 : -1) + slots.length) % slots.length].focus();
Expand Down
22 changes: 18 additions & 4 deletions src/photo-studio/src/app/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class WindowManager {
const e = this.e;
if (!this.multi) {
const strip = e.el('.document-tabs');
strip.innerHTML = e.views.map((v) => this.tabHTML(v)).join('');
setTabs(strip, e.views.map((v) => this.tabHTML(v)).join(''));
// A document shown from elsewhere (opened, chosen in Window › Documents)
// brings its tab into the strip's view; otherwise the strip stays where
// it was scrolled.
Expand All @@ -239,14 +239,14 @@ export class WindowManager {
}
return;
}
e.el('.document-tabs').innerHTML = '';
setTabs(e.el('.document-tabs'), '');
this.frames.forEach((frame, i) => {
const bar = this.host.querySelector<HTMLElement>(`[data-frame="${i}"] .frame-tabs`);
if (bar) bar.innerHTML = frame.map((v) => this.tabHTML(v)).join('');
if (bar) setTabs(bar, frame.map((v) => this.tabHTML(v)).join(''));
});
for (const v of e.views) {
const bar = v.floating && this.host.querySelector<HTMLElement>(`[data-float="${v.id}"] .frame-tabs`);
if (bar) bar.innerHTML = this.tabHTML(v);
if (bar) setTabs(bar, this.tabHTML(v));
}
}
// ----- Previews of inactive views -----
Expand Down Expand Up @@ -457,3 +457,17 @@ function checker(c: CanvasRenderingContext2D) {
checkerPattern = { ctx: c, key: a + b, pattern };
return pattern;
}

/** Redraw a tab bar (after every edit, zoom and title change) only when its
* markup changed, keeping the keyboard focus on the tab or close button it
* was on: rebuilding the bar would drop it to the page. (The focus on a
* closed window's tab is moved by the close button's handler.) */
const tabMarkup = new WeakMap<HTMLElement, string>();
function setTabs(bar: HTMLElement, html: string) {
if (tabMarkup.get(bar) === html) return;
tabMarkup.set(bar, html);
const f = document.activeElement instanceof HTMLElement && bar.contains(document.activeElement) ? document.activeElement : null;
const same = f?.dataset.closeView ? `[data-close-view="${CSS.escape(f.dataset.closeView)}"]` : f?.dataset.view ? `[data-view="${CSS.escape(f.dataset.view)}"]` : '';
bar.innerHTML = html;
if (same && !f!.isConnected) bar.querySelector<HTMLElement>(same)?.focus({ preventScroll: true });
}
12 changes: 10 additions & 2 deletions src/photo-studio/src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ export class Editor {
this.el('.canvas-color-mode').textContent = `${this.colorModeLabel} / ${depth}`;
this.el('#empty').hidden = this.hasDocument;
this.root.classList.toggle('no-document', !this.hasDocument);
// The start screen covers the document area, and the options it dims
// ignore the pointer: the keyboard and screen readers skip them too.
for (const sel of ['.document-tabs', '.canvas-area', '#tool-options']) this.el(sel).inert = !this.hasDocument;
this.windows.renderTabs();
this.options();
this.toolbar?.render();
Expand Down Expand Up @@ -817,7 +820,9 @@ export class Editor {
this.root.classList.toggle('rulers-hidden', !this.preferences.showRulers);
if (this.preferences.showRulers) {
const unit = rulerUnitScale(this.doc, this.preferences.rulerUnits);
setMarkup(this.el('#ruler-x'), rulerTicks(viewport.clientWidth, viewport.clientWidth / 2 + this.pan.x - (this.doc.width * this.zoom * aspect) / 2, this.zoom * aspect, false, unit.x));
// A flipped view has the image's left edge, the ruler's zero, on the right.
const sx = this.zoom * aspect * (this.activeView.flip ? -1 : 1);
setMarkup(this.el('#ruler-x'), rulerTicks(viewport.clientWidth, viewport.clientWidth / 2 + this.pan.x - (this.doc.width * sx) / 2, sx, false, unit.x));
setMarkup(this.el('#ruler-y'), rulerTicks(viewport.clientHeight, viewport.clientHeight / 2 + this.pan.y - (this.doc.height * this.zoom) / 2, this.zoom, true, unit.y));
}
this.screenOverlay();
Expand Down Expand Up @@ -1037,7 +1042,10 @@ export class Editor {
this.el('#viewport').focus({ preventScroll: true });
return;
}
const typing = !!target.closest('input,textarea,select,[contenteditable="true"],[role="slider"]');
// A checkbox or radio button (focused by the click that set it) keeps only
// the keys it uses itself; tool keys and shortcuts such as Select All work.
const toggle = target instanceof HTMLInputElement && (target.type === 'checkbox' || target.type === 'radio');
const typing = toggle ? [' ', 'Enter', 'Tab'].includes(e.key) || e.key.startsWith('Arrow') : !!target.closest('input,textarea,select,[contenteditable="true"],[role="slider"]');
if (target.closest('dialog')) return;
// A modal dialog makes the workspace behind it inert: keys that reach the
// page (the focus fell off a control the dialog rebuilt, or Tab left its
Expand Down
26 changes: 23 additions & 3 deletions src/photo-studio/src/engine/paint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export type StrokeOptions = {
// first is normally the identity); see imaging/symmetry.
symmetry?: Affine[];
seed?: number;
// Frees working tiles the stroke no longer needs (cancelled, or unchanged
// at commit). The preview may still be drawing them, so callers with a
// renderer free them once it is done; by default they are deleted at once.
release?: (ids: string[]) => void;
};
type Working = {
id: string;
Expand All @@ -128,6 +132,7 @@ export class StrokeSession {
private seed: number;
// Pressure or jitter gives dabs of one stroke different opacities.
private varyingOpacity: boolean;
private unhold: () => void;
dabs = 0;
constructor(
private store: TileStore,
Expand All @@ -138,6 +143,11 @@ export class StrokeSession {
if ((options.target.kind === 'mask') !== (this.channels === 1))
throw new Error('The paint target does not match the tile format.');
this.preview = { ...original, tiles: { ...original.tiles } };
// The working tiles belong to no document until the stroke is committed:
// tile cleanup run by another edit meanwhile must keep them. A stroke
// abandoned without commit or cancel is not kept alive by the hold.
const self = new WeakRef(this.working);
this.unhold = store.hold(() => Array.from(self.deref()?.values() ?? [], (w) => w.id));
this.seed = options.seed ?? 1;
this.varyingOpacity = !!(options.dynamics?.pressureOpacity || options.dynamics?.opacityJitter);
let state = (options.seed ?? 1) >>> 0 || 1;
Expand Down Expand Up @@ -536,9 +546,10 @@ export class StrokeSession {
commit(): TileGrid {
const grid: TileGrid = { ...this.original, tiles: { ...this.original.tiles } };
const fill = this.channels === 1 ? (this.original.fill ?? 0) : 0;
const dropped: string[] = [];
for (const [key, w] of this.working) {
if (!this.touched.has(key)) {
this.store.delete(w.id);
dropped.push(w.id);
continue;
}
let empty = true;
Expand All @@ -548,17 +559,26 @@ export class StrokeSession {
break;
}
if (empty) {
this.store.delete(w.id);
dropped.push(w.id);
delete grid.tiles[key];
} else grid.tiles[key] = w.id;
}
grid.bounds = computeBounds(this.store, grid);
this.working.clear();
this.unhold();
this.free(dropped);
return grid;
}
cancel() {
for (const w of this.working.values()) this.store.delete(w.id);
const ids = Array.from(this.working.values(), (w) => w.id);
this.working.clear();
this.unhold();
this.free(ids);
}
private free(ids: string[]) {
if (!ids.length) return;
if (this.options.release) this.options.release(ids);
else for (const id of ids) this.store.delete(id);
}
}

Expand Down
85 changes: 85 additions & 0 deletions src/photo-studio/src/features/action-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// playback, stops the action.
import type { Editor } from '../editor';
import { formDialog, type Field } from '../ui/dialog';
import { modal } from './files/ui';
import { deferRecording, recordStep } from './filters/record';

export { deferRecording as recordsSettings, recordStep };
Expand Down Expand Up @@ -55,3 +56,87 @@ export async function settingsDialog(e: Editor, id: string, arg: unknown, title:
else noteDialogCancelled();
return v;
}

type FormControl = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
const controls = (form: HTMLFormElement) =>
(Array.from(form.elements) as FormControl[]).filter(
(el) => el.name && !['submit', 'button', 'reset'].includes(el.type),
);

/** The settings of a form's named controls; checkboxes as 'yes' or 'no'. */
function formSettings(form: HTMLFormElement): Record<string, string> {
return Object.fromEntries(
controls(form).map((el) => [
el.name,
el.type === 'checkbox' ? ((el as HTMLInputElement).checked ? 'yes' : 'no') : el.value,
]),
);
}

/** Set a form's named controls to given settings; a value a control does not
* allow (an option it lacks, a number out of range) leaves it as it was. */
function applySettings(form: HTMLFormElement, given: Record<string, unknown>) {
for (const el of controls(form)) {
const v = given[el.name];
if (v === undefined || v === null) continue;
if (el.type === 'checkbox') {
if (v === true || v === 'yes') (el as HTMLInputElement).checked = true;
else if (v === false || v === 'no') (el as HTMLInputElement).checked = false;
continue;
}
if (typeof v !== 'string' && typeof v !== 'number') continue;
const s = String(v);
if (el.tagName === 'SELECT') {
if (Array.from((el as HTMLSelectElement).options).some((o) => o.value === s)) el.value = s;
} else if (el.type === 'number') {
const n = s.trim() ? Number(s) : NaN;
const input = el as HTMLInputElement;
const min = input.min === '' ? -Infinity : Number(input.min);
const max = input.max === '' ? Infinity : Number(input.max);
if (Number.isFinite(n)) el.value = String(Math.min(max, Math.max(min, n)));
} else if (el.type === 'color') {
if (/^#[0-9a-f]{6}$/i.test(s)) el.value = s.toLowerCase();
} else {
const max = (el as HTMLInputElement | HTMLTextAreaElement).maxLength;
el.value = s.slice(0, max >= 0 ? max : 1000);
}
}
}

/** A free-form modal (files/ui) of the recordable command `id`, read as the
* settings of its named controls: with { params } in `arg` it answers with
* those settings, checked against the form's controls, without asking; with
* { initial } it opens showing them. Confirmed settings are recorded; Cancel
* resolves null. */
export async function settingsModal(
e: Editor,
id: string,
arg: unknown,
opts: Parameters<typeof modal>[0],
): Promise<Record<string, string> | null> {
const given = paramsOf(arg);
if (given) {
// An inert copy of the form fills in what the settings leave out.
const t = document.createElement('template');
t.innerHTML = `<form>${opts.body}</form>`;
const form = t.content.firstElementChild as HTMLFormElement;
applySettings(form, given);
return formSettings(form);
}
const initial = paramsOf(arg, 'initial');
const result = await modal({
...opts,
bind: (dialog) => {
if (initial) applySettings(dialog.querySelector('form')!, initial);
opts.bind?.(dialog);
},
});
if (!result) {
noteDialogCancelled();
return null;
}
const v = formSettings(result.form);
result.close();
recordStep(e, id, { params: { ...v } });
return v;
}
8 changes: 5 additions & 3 deletions src/photo-studio/src/features/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,11 @@ export async function playAction(e: Editor, action: Action, from = 0) {
// Steps recorded before a command was renamed run the current one.
const c = findCommand(s.command);
if (!c) throw new Error(`The command “${s.command}” is not available.`);
// Imported action files can name any command; an Actions panel
// command would play an action from inside one (itself, forever).
if (interactiveOnly(c.id) || c.id.startsWith('actions.')) throw new Error(`Actions cannot run “${c.label.replace(/…$/, '')}”.`);
// Imported action files and batch links can name any command; an
// Actions panel command would play an action from inside one (itself,
// forever), and commands that are never recorded (deleting custom
// brushes, resetting presets) reach beyond the documents played on.
if (interactiveOnly(c.id) || c.id.startsWith('actions.') || c.recordable === false) throw new Error(`Actions cannot run “${c.label.replace(/…$/, '')}”.`);
if (c.enabled && !c.enabled(e)) throw new Error(`“${c.label}” is not available in the current state.`);
// Steps call commands directly so the busy guard does not skip them.
// A step with its dialog on opens the dialog, showing the recorded
Expand Down
4 changes: 3 additions & 1 deletion src/photo-studio/src/features/adjust/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export function compileSpec(spec: AdjustmentSpec): CompiledLut | null {
out.curves = { r: comp(r), g: comp(g), b: comp(b) };
}
if (c.lut3d) out.lut3d = c.lut3d;
if (c.postCurves) out.postCurves = c.postCurves;
// A hard step is compared exactly in the shader (a table would blur it).
if (c.postStep !== undefined) out.postStep = c.postStep;
else if (c.postCurves) out.postCurves = c.postCurves;
return out.curves || out.lut3d ? out : null;
}

Expand Down
4 changes: 3 additions & 1 deletion src/photo-studio/src/features/adjust/relight-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ function lightControls(light: RelightLight, host: AdjustHost<'relight'>) {
box.append(h('div', { class: 'adj-field-label relight-section' }, escapeXML(light.name)));
// Live previews draw the handles from the working copy.
const change = (c: boolean, label: string) => {
relightUi.draft = c ? undefined : { layerId: host.layerId ?? '', params: host.params };
relightUi.draft = c
? undefined
: { layerId: host.layerId ?? '', params: host.params, doc: host.e.doc };
host.change(c, label);
host.e.overlay();
};
Expand Down
Loading
Loading