Show edited renders in thumbnails and paste to a filmstrip selection
The grid and filmstrip only ever showed the import thumbnail, so edits and virtual copies looked untouched. Edited tiles now render client-side with the same shader as the canvas, once each, from the small cached thumbnail. The filmstrip also gains Cmd/Shift multi-select so Paste, Copy and Reset can act on several photos from the toolbar or the right-click menu.
This commit is contained in:
+135
-24
@@ -5,7 +5,6 @@ import {
|
||||
defaultLocalLayer,
|
||||
MAX_HEAL_SPOTS,
|
||||
MAX_LOCAL_LAYERS,
|
||||
thumbTransform,
|
||||
} from '../lib/edits';
|
||||
import { subscribeClipPreview } from '../lib/clipPreview';
|
||||
import { getBitmap, getDenoisedBitmap } from '../lib/images';
|
||||
@@ -42,6 +41,7 @@ import type {
|
||||
Snapshot,
|
||||
} from '../types';
|
||||
import ContextMenu, { type MenuEntry } from './ContextMenu';
|
||||
import EditedImage from './EditedImage';
|
||||
import CropOverlay from './CropOverlay';
|
||||
import Histogram from './Histogram';
|
||||
import {
|
||||
@@ -123,7 +123,12 @@ interface Props {
|
||||
onUpdate: (id: string, patch: Partial<PhotoRecord>, historyLabel?: string) => void;
|
||||
clipboard: Edits | null;
|
||||
onCopy: () => void;
|
||||
onPaste: () => void;
|
||||
/** Copy settings from a named filmstrip photo instead of the canvas photo. */
|
||||
onCopyOf?: (id: string) => void;
|
||||
/** Paste the copied settings; no ids means the photo on the canvas. */
|
||||
onPaste: (ids?: string[]) => void;
|
||||
/** Reset several photos at once, without a per-photo confirmation. */
|
||||
onResetSelection?: (ids: string[]) => void;
|
||||
localClipboard: LocalLayer | null;
|
||||
onLocalClipboard: (layer: LocalLayer | null) => void;
|
||||
onExport: () => void;
|
||||
@@ -153,7 +158,9 @@ export default function Develop({
|
||||
onUpdate,
|
||||
clipboard,
|
||||
onCopy,
|
||||
onCopyOf,
|
||||
onPaste,
|
||||
onResetSelection,
|
||||
localClipboard,
|
||||
onLocalClipboard,
|
||||
onExport,
|
||||
@@ -202,6 +209,10 @@ export default function Develop({
|
||||
const toggleStrip = () => (mobile ? setMobileStripOpen((open) => !open) : setStripOpen((open) => !open));
|
||||
const [filmMinRating, setFilmMinRating] = useState(0);
|
||||
const [filmFlag, setFilmFlag] = useState<Flag | 'any'>('any');
|
||||
// Filmstrip multi-select. The canvas keeps its own photo; this is the set a
|
||||
// paste applies to, exactly like Lightroom's filmstrip selection.
|
||||
const [filmSel, setFilmSel] = useState<string[]>([photo.id]);
|
||||
const [filmAnchor, setFilmAnchor] = useState(photo.id);
|
||||
const [showOriginal, setShowOriginal] = useState(false);
|
||||
const [histVersion, setHistVersion] = useState(0);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -214,7 +225,12 @@ export default function Develop({
|
||||
const [panning, setPanning] = useState(false);
|
||||
const [navigatorView, setNavigatorView] = useState<Rect | null>(null);
|
||||
const [readout, setReadout] = useState({ shown: 100, fit: 100 });
|
||||
const [menu, setMenu] = useState<{ x: number; y: number; kind: 'canvas' | 'film' } | null>(null);
|
||||
const [menu, setMenu] = useState<{
|
||||
x: number;
|
||||
y: number;
|
||||
kind: 'canvas' | 'film';
|
||||
ids?: string[];
|
||||
} | null>(null);
|
||||
const [healMode, setHealMode] = useState(false);
|
||||
const [brushPx, setBrushPx] = useState(56);
|
||||
const [healFeather, setHealFeather] = useState(50);
|
||||
@@ -273,6 +289,49 @@ export default function Develop({
|
||||
[filmPhotos, onSelect, photo.id],
|
||||
);
|
||||
|
||||
// The photo on the canvas is always part of the selection, so a fresh filmstrip
|
||||
// starts with just that frame. Cmd/Shift clicks grow the set without moving it.
|
||||
useEffect(() => {
|
||||
setFilmSel([photo.id]);
|
||||
setFilmAnchor(photo.id);
|
||||
}, [photo.id]);
|
||||
|
||||
// A cull filter can hide part of the selection; drop those frames rather than
|
||||
// pasting settings into photos that are no longer on screen.
|
||||
useEffect(() => {
|
||||
setFilmSel((prev) => {
|
||||
const visible = new Set(filmPhotos.map((item) => item.id));
|
||||
const next = prev.filter((id) => visible.has(id));
|
||||
return next.length === prev.length ? prev : next;
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [filmMinRating, filmFlag]);
|
||||
|
||||
const clickFilm = (p: PhotoRecord, e: React.MouseEvent) => {
|
||||
if (e.shiftKey) {
|
||||
const a = filmPhotos.findIndex((item) => item.id === filmAnchor);
|
||||
const b = filmPhotos.findIndex((item) => item.id === p.id);
|
||||
if (a >= 0 && b >= 0) {
|
||||
const [lo, hi] = a < b ? [a, b] : [b, a];
|
||||
setFilmSel(filmPhotos.slice(lo, hi + 1).map((item) => item.id));
|
||||
} else {
|
||||
setFilmSel([p.id]);
|
||||
setFilmAnchor(p.id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (e.metaKey || e.ctrlKey) {
|
||||
setFilmSel((prev) =>
|
||||
prev.includes(p.id) ? prev.filter((id) => id !== p.id) : [...prev, p.id],
|
||||
);
|
||||
setFilmAnchor(p.id);
|
||||
return;
|
||||
}
|
||||
setFilmSel([p.id]);
|
||||
setFilmAnchor(p.id);
|
||||
onSelect(p.id);
|
||||
};
|
||||
|
||||
const moveLensSplit = (e: React.PointerEvent<HTMLButtonElement>) => {
|
||||
const rect = e.currentTarget.parentElement?.getBoundingClientRect();
|
||||
if (!rect || rect.width <= 0) return;
|
||||
@@ -1283,7 +1342,7 @@ export default function Develop({
|
||||
} else if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'c') {
|
||||
onCopy();
|
||||
} else if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'v') {
|
||||
onPaste();
|
||||
onPaste(filmSel);
|
||||
}
|
||||
};
|
||||
const up = (e: KeyboardEvent) => {
|
||||
@@ -1306,6 +1365,7 @@ export default function Develop({
|
||||
navigateFilm,
|
||||
onCopy,
|
||||
onPaste,
|
||||
filmSel,
|
||||
undo,
|
||||
redo,
|
||||
applyZoom,
|
||||
@@ -1456,7 +1516,7 @@ export default function Develop({
|
||||
{ label: 'Before / After', shortcut: '\\', onSelect: () => setShowOriginal((v) => !v) },
|
||||
'separator',
|
||||
{ label: 'Copy settings', shortcut: '⌘C', onSelect: onCopy },
|
||||
{ label: 'Paste settings', shortcut: '⌘V', onSelect: onPaste, disabled: !clipboard },
|
||||
{ label: 'Paste settings', shortcut: '⌘V', onSelect: () => onPaste([photo.id]), disabled: !clipboard },
|
||||
{ label: 'Reset settings', onSelect: resetAll },
|
||||
'separator',
|
||||
...(canPushImmich && onPushImmich
|
||||
@@ -1469,10 +1529,38 @@ export default function Develop({
|
||||
{ label: 'Delete photo…', danger: true, onSelect: onDelete },
|
||||
];
|
||||
|
||||
// Right-clicking one of several selected frames acts on the whole selection;
|
||||
// right-clicking outside it acts on that frame alone.
|
||||
const filmMenuIds = menu?.kind === 'film' && menu.ids?.length ? menu.ids : [photo.id];
|
||||
const filmMenu: MenuEntry[] = [
|
||||
{ label: 'Copy settings', onSelect: onCopy },
|
||||
{ label: 'Paste settings', onSelect: onPaste, disabled: !clipboard },
|
||||
{ label: 'Reset settings', onSelect: resetAll },
|
||||
{
|
||||
label: 'Open in Develop',
|
||||
disabled: filmMenuIds.includes(photo.id),
|
||||
onSelect: () => onSelect(filmMenuIds[0]),
|
||||
},
|
||||
'separator',
|
||||
{
|
||||
label: 'Copy settings',
|
||||
onSelect: () => (onCopyOf ? onCopyOf(filmMenuIds[0]) : onCopy()),
|
||||
},
|
||||
{
|
||||
label:
|
||||
filmMenuIds.length > 1
|
||||
? `Paste settings to ${filmMenuIds.length} photos…`
|
||||
: 'Paste settings',
|
||||
onSelect: () => onPaste(filmMenuIds),
|
||||
disabled: !clipboard,
|
||||
},
|
||||
{
|
||||
label:
|
||||
filmMenuIds.length > 1
|
||||
? `Reset adjustments on ${filmMenuIds.length} photos`
|
||||
: 'Reset settings',
|
||||
onSelect: () =>
|
||||
filmMenuIds.length > 1 && onResetSelection
|
||||
? onResetSelection(filmMenuIds)
|
||||
: resetAll(),
|
||||
},
|
||||
'separator',
|
||||
...(canPushImmich && onPushImmich
|
||||
? ([{ label: 'Send edit to Immich', onSelect: onPushImmich }] as MenuEntry[])
|
||||
@@ -1525,8 +1613,17 @@ export default function Develop({
|
||||
<button className="btn ghost small" onClick={onVirtualCopy} title="Create a virtual copy with its own edits">
|
||||
Virtual copy
|
||||
</button>
|
||||
<button className="btn ghost small" onClick={onPaste} disabled={!clipboard} title="Paste develop settings (⌘V)">
|
||||
Paste
|
||||
<button
|
||||
className="btn ghost small"
|
||||
onClick={() => onPaste(filmSel)}
|
||||
disabled={!clipboard || !filmSel.length}
|
||||
title={
|
||||
filmSel.length > 1
|
||||
? `Paste develop settings to ${filmSel.length} selected photos (⌘V)`
|
||||
: 'Paste develop settings (⌘V)'
|
||||
}
|
||||
>
|
||||
Paste{filmSel.length > 1 ? ` (${filmSel.length})` : ''}
|
||||
</button>
|
||||
<button className="btn ghost small" onClick={undo} disabled={!canUndo} title="Undo (⌘Z)">
|
||||
Undo
|
||||
@@ -2225,8 +2322,13 @@ export default function Develop({
|
||||
<button type="button" className="btn ghost small" onClick={onCopy}>
|
||||
Copy
|
||||
</button>
|
||||
<button type="button" className="btn ghost small" onClick={onPaste} disabled={!clipboard}>
|
||||
Paste
|
||||
<button
|
||||
type="button"
|
||||
className="btn ghost small"
|
||||
onClick={() => onPaste(filmSel)}
|
||||
disabled={!clipboard || !filmSel.length}
|
||||
>
|
||||
Paste{filmSel.length > 1 ? ` (${filmSel.length})` : ''}
|
||||
</button>
|
||||
<button type="button" className="btn ghost small" onClick={resetAll}>
|
||||
Reset
|
||||
@@ -2352,6 +2454,9 @@ export default function Develop({
|
||||
)}
|
||||
|
||||
<div className="spacer" />
|
||||
{filmSel.length > 1 && (
|
||||
<span className="film-count">{filmSel.length} selected</span>
|
||||
)}
|
||||
<span className="film-count">
|
||||
{filmPhotos.length} / {photos.length}
|
||||
</span>
|
||||
@@ -2362,22 +2467,28 @@ export default function Develop({
|
||||
{filmPhotos.map((p) => (
|
||||
<button
|
||||
key={p.id}
|
||||
className={`film ${p.id === photo.id ? 'active' : ''}`}
|
||||
onClick={() => onSelect(p.id)}
|
||||
className={`film ${p.id === photo.id ? 'active' : ''} ${
|
||||
filmSel.includes(p.id) ? 'selected' : ''
|
||||
}`}
|
||||
onClick={(e) => clickFilm(p, e)}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
if (p.id !== photo.id) onSelect(p.id);
|
||||
setMenu({ x: e.clientX, y: e.clientY, kind: 'film' });
|
||||
const inSelection = filmSel.includes(p.id);
|
||||
const ids = inSelection ? filmSel : [p.id];
|
||||
if (!inSelection) {
|
||||
setFilmSel([p.id]);
|
||||
setFilmAnchor(p.id);
|
||||
if (p.id !== photo.id) onSelect(p.id);
|
||||
}
|
||||
setMenu({ x: e.clientX, y: e.clientY, kind: 'film', ids });
|
||||
}}
|
||||
title={p.name}
|
||||
title={
|
||||
filmSel.length > 1 && filmSel.includes(p.id)
|
||||
? `${p.name} · ${filmSel.length} selected`
|
||||
: `${p.name} · Shift-click or Ctrl-click to select more`
|
||||
}
|
||||
>
|
||||
<img
|
||||
src={p.thumbUrl ?? p.thumb}
|
||||
alt={p.name}
|
||||
loading="lazy"
|
||||
draggable={false}
|
||||
style={{ transform: thumbTransform(p, 3 / 2) }}
|
||||
/>
|
||||
<EditedImage photo={p} alt={p.name} boxAspect={3 / 2} />
|
||||
{p.rating > 0 && <span className="film-rating">{'★'.repeat(p.rating)}</span>}
|
||||
</button>
|
||||
))}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { thumbTransform } from '../lib/edits';
|
||||
import { useEditedThumb } from '../lib/editThumbs';
|
||||
import type { PhotoRecord } from '../types';
|
||||
|
||||
interface Props {
|
||||
photo: PhotoRecord;
|
||||
/** Aspect of the tile the picture fills; the rotation transform needs it. */
|
||||
boxAspect?: number;
|
||||
alt?: string;
|
||||
loading?: 'lazy' | 'eager';
|
||||
draggable?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A thumbnail that follows the photo's edits.
|
||||
*
|
||||
* Edited photos get a freshly rendered small JPEG; everything else keeps the
|
||||
* server/import thumbnail and the CSS orientation transform. Rendering starts
|
||||
* only when the tile is close to the viewport.
|
||||
*/
|
||||
export default function EditedImage({
|
||||
photo,
|
||||
boxAspect = 4 / 3,
|
||||
alt,
|
||||
loading = 'lazy',
|
||||
draggable = false,
|
||||
}: Props) {
|
||||
const ref = useRef<HTMLImageElement>(null);
|
||||
const [nearView, setNearView] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const el = ref.current;
|
||||
if (!el) return;
|
||||
if (typeof IntersectionObserver === 'undefined') {
|
||||
setNearView(true);
|
||||
return;
|
||||
}
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
if (!entries.some((entry) => entry.isIntersecting)) return;
|
||||
setNearView(true);
|
||||
observer.disconnect();
|
||||
},
|
||||
{ rootMargin: '400px' },
|
||||
);
|
||||
observer.observe(el);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
const edited = useEditedThumb(photo, nearView);
|
||||
|
||||
return (
|
||||
<img
|
||||
ref={ref}
|
||||
src={edited ?? photo.thumbUrl ?? photo.thumb}
|
||||
alt={alt ?? photo.name}
|
||||
loading={loading}
|
||||
draggable={draggable}
|
||||
// A rendered tile already has the crop, turn and flips baked in.
|
||||
style={{ transform: edited ? 'none' : thumbTransform(photo, boxAspect) }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { COLOR_LABELS, isEdited, thumbTransform } from '../lib/edits';
|
||||
import { COLOR_LABELS, isEdited } from '../lib/edits';
|
||||
import { draggedPhotoIds, endDrag, PHOTO_DRAG, startPhotoDrag } from '../lib/drag';
|
||||
import type { ColorLabel, Flag, PhotoRecord } from '../types';
|
||||
import Stars, { ColorSwatches, FlagButtons } from './Stars';
|
||||
import EditedImage from './EditedImage';
|
||||
|
||||
interface Props {
|
||||
photos: PhotoRecord[];
|
||||
@@ -443,13 +444,7 @@ export default function LibraryGrid({
|
||||
}}
|
||||
>
|
||||
<div className="card-thumb">
|
||||
<img
|
||||
src={p.thumbUrl ?? p.thumb}
|
||||
alt={p.name}
|
||||
loading="lazy"
|
||||
draggable={false}
|
||||
style={{ transform: thumbTransform(p) }}
|
||||
/>
|
||||
<EditedImage photo={p} alt={p.name} />
|
||||
<div className="card-badges">
|
||||
{p.flag === 'pick' && <span className="badge pick">✓</span>}
|
||||
{p.flag === 'reject' && <span className="badge reject">✕</span>}
|
||||
|
||||
Reference in New Issue
Block a user