Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 16 additions & 8 deletions apps/studio/src/apps/PhotoApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { AppProps } from "./registry";
/**
* The Photo app (docs/rewrite/09-shells.md): one photo, large, with its facts. ← and → step through
* the list it was opened from (or its collection, else its folder). The preview shows at once; the
* original is loaded on request.
* original replaces it as soon as it has loaded.
*/
/** One photo; opened without one, the start screen of the project's photos (#426). */
export function PhotoApp(p: AppProps) {
Expand All @@ -28,11 +28,10 @@ function PhotoView({ win, resource, projectId, setTitle, setRoute }: AppProps) {
const [id, setId] = useState(resource?.id ?? "");
useEffect(() => { if (resource?.id) setId(resource.id); }, [resource?.id, win.stateSeq]);
const f = map.get(id);
const [full, setFull] = useState(false);
// The preview shows at once; the original replaces it as soon as it has loaded (#426: no Preview / Full size switch).
const [loaded, setLoaded] = useState<string | null>(null);
const [name, setName] = useState(f?.name ?? "");
useEffect(() => { setName(f?.name ?? ""); }, [f?.id, f?.name]);
useEffect(() => { setFull(false); }, [id]);
const [panels, setPanels] = useDockLayout("photo", { right: { tabs: ["facts"] } });

// The list to step through: the one it was opened from, else its collection, else its folder.
Expand All @@ -45,12 +44,22 @@ function PhotoView({ win, resource, projectId, setTitle, setRoute }: AppProps) {
// The window stands for the photo it shows (one window per file): stepping onto one open elsewhere brings that window up.
const step = (d: number) => { const next = list[at + d]; if (next && wm.setResource(win.id, { type: "photo", id: next })) setId(next); };
useEffect(() => { if (f) { setTitle(f.name); setRoute(f.id); } }, [f?.id, f?.name]);
useKeys(bind("photo", { prev: () => step(-1), next: () => step(1), full: () => setFull((v) => !v) }));
useKeys(bind("photo", { prev: () => step(-1), next: () => step(1) }));
const originalUrl = f && f.photo?.stored.original && f.photo.media_type !== "image/heic" ? imageUrl(f.id, "original") : null;
useEffect(() => {
if (!originalUrl || loaded === originalUrl) return;
const img = new Image();
img.onload = () => setLoaded(originalUrl);
img.src = originalUrl;
return () => { img.onload = null; };
}, [originalUrl]);

if (!files) return <div className="oc-app st-center"><Spinner /></div>;
if (!f || f.type !== "photo" || !f.photo) return <div className="oc-app"><EmptyState icon="image" title="This photo is gone">It was deleted, or it is in the recycle bin.</EmptyState></div>;
const p = f.photo;
const src = full && p.stored.original && p.media_type !== "image/heic" ? imageUrl(f.id, "original") : p.stored.preview ? imageUrl(f.id, "preview") : p.stored.thumbnail ? imageUrl(f.id, "thumbnail") : null;
const original = p.stored.original && p.media_type !== "image/heic" ? imageUrl(f.id, "original") : null;
const first = p.stored.preview ? imageUrl(f.id, "preview") : p.stored.thumbnail ? imageUrl(f.id, "thumbnail") : null;
const src = original && loaded === original ? original : first ?? original;
const commit = () => { const to = name.trim(); if (!to || to === f.name) { setName(f.name); return; } void store.rename(f, to).catch((e) => { toastError(e); setName(f.name); }); };
return (
<ViewerLayout
Expand All @@ -60,14 +69,13 @@ function PhotoView({ win, resource, projectId, setTitle, setRoute }: AppProps) {
<Button size="sm" variant="quiet" icon="chevron-right" label="Next photo (→)" disabled={at < 0 || at >= list.length - 1} onClick={() => step(1)} />
<TextInput size="sm" value={name} aria-label="Name" maxLength={120} style={{ width: 240 }} onInput={(e) => setName(e.currentTarget.value)} onBlur={commit} onKeyDown={(e) => { if (e.key === "Enter") e.currentTarget.blur(); if (e.key === "Escape") { setName(f.name); e.currentTarget.blur(); } }} />
<ToolbarSpacer />
<Button size="sm" variant="quiet" selected={full} disabled={!p.stored.original || p.media_type === "image/heic"} onClick={() => setFull(!full)}>{full ? "Full size" : "Preview"}</Button>
<Button size="sm" variant="quiet" icon="brush" onClick={() => void canvasFromPhoto(f, map)}>Make a canvas</Button>
<Button size="sm" variant="quiet" icon="download" label="Download the original" disabled={!p.stored.original} onClick={() => { const a = document.createElement("a"); a.href = imageUrl(f.id, "original"); a.download = f.name; a.click(); }} />
</Toolbar>
)}
dock={{ layout: panels, onLayoutChange: setPanels, zoneSizes: { right: 300 }, panels: [{ id: "facts", title: "Properties", icon: "info", body: <div className="st-info"><PropertyList><PhotoFactsSections f={f} map={map} /></PropertyList></div> }] }}
stage={<div className="st-stage">{src ? <img key={src} src={src} alt={f.name} onLoad={() => setLoaded(src)} /> : <EmptyState icon="cloud-upload" title="Not uploaded yet">The preview shows here once it arrived.</EmptyState>}</div>}
statusBar={<StatusBar>{at >= 0 ? `${at + 1} of ${list.length}` : ""}{coll ? ` · in “${coll.name}”` : ""} · {p.width} × {p.height}{full && loaded !== src ? " · loading the original…" : ""}</StatusBar>}
stage={<div className="st-stage">{src ? <img key={src} src={src} alt={f.name} /> : <EmptyState icon="cloud-upload" title="Not uploaded yet">The preview shows here once it arrived.</EmptyState>}</div>}
statusBar={<StatusBar>{at >= 0 ? `${at + 1} of ${list.length}` : ""}{coll ? ` · in “${coll.name}”` : ""} · {p.width} × {p.height}{original && loaded !== original ? " · loading the original…" : ""}</StatusBar>}
/>
);
}
8 changes: 6 additions & 2 deletions apps/studio/src/apps/SettingsApp.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from "preact/hooks";
import { FormField, Kbd, Segmented, SettingsGroup, SettingsLayout, Switch } from "@openclapper/design";
import { Checkbox, FormField, Kbd, Segmented, SettingsGroup, SettingsLayout, Switch } from "@openclapper/design";
import { useInstance } from "../instance";
import { setPrefs, usePrefs, usePrefsState, type Edge } from "../prefs";
import { setPrefs, usePrefs, usePrefsState, type Edge, type TaskbarItem } from "../prefs";
import { SCOPES, keysLabel, shortcutsOf, type ScopeId } from "../shortcuts";
import { THEMES, useTheme, type Theme } from "../theme";
import * as store from "../files";
Expand All @@ -19,6 +19,9 @@ const TITLE: Record<(typeof TABS)[number], string> = { workspaces: "Workspaces",
/** A settings page file's page, as a tab (#426: one file per page; "project" is the General page). */
const PAGE_TAB: Record<string, Tab> = { general: "general", properties: "properties", naming: "naming", customizations: "customizations", extensions: "extensions", appearance: "appearance", account: "account", shortcuts: "shortcuts" };

/** Taskbar items one can hide (#426), in the order they sit. */
const TASKBAR_ITEMS: [TaskbarItem, string][] = [["project", "Switch project"], ["search", "Search"], ["theme", "Theme"], ["account", "Account"], ["clock", "Clock"]];

/** Every shortcut of the registry, scope by scope: the same list as the `?` sheet and docs/shortcuts.md. */
export function ShortcutList() {
return (
Expand Down Expand Up @@ -82,6 +85,7 @@ export function SettingsApp({ win, projectId, setTitle, setRoute }: AppProps) {
<SettingsGroup title="Taskbar">
<FormField label="Position"><span><Segmented label="Taskbar position" value={prefs.taskbarEdge} onChange={(v) => setPrefs({ taskbarEdge: v as Edge })} options={[{ value: "bottom", label: "Bottom" }, { value: "top", label: "Top" }, { value: "left", label: "Left" }, { value: "right", label: "Right" }]} /></span></FormField>
<FormField label="Apps and windows" hint="Along a side bar, the start is its top."><span><Segmented label="Taskbar alignment" value={prefs.taskbarAlign} onChange={(v) => setPrefs({ taskbarAlign: v as "start" | "center" })} options={[{ value: "start", label: "At the start" }, { value: "center", label: "Centred" }]} /></span></FormField>
<FormField label="Shown" hint="The launcher and the task view always stay."><span className="st-checks">{TASKBAR_ITEMS.map(([id, label]) => <Checkbox key={id} checked={!(prefs.taskbarHide ?? []).includes(id)} onChange={() => setPrefs({ taskbarHide: (prefs.taskbarHide ?? []).includes(id) ? prefs.taskbarHide.filter((x) => x !== id) : [...(prefs.taskbarHide ?? []), id] })}>{label}</Checkbox>)}</span></FormField>
</SettingsGroup>
<p className="st-note">{saved === "unsaved" ? "Not saved to your account yet: the server could not be reached. It is kept in this browser and saved when it answers again." : "These follow your account to every browser. Window layouts stay with the browser, because they depend on the screen."}</p>
<SettingsGroup title="Media">
Expand Down
10 changes: 5 additions & 5 deletions apps/studio/src/apps/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface AppDef {
id: string;
name: string;
glyph: IconName;
/** 0 neutral, 1 to 8 categorical (the design system's app icon). */
/** 0 neutral, 1 to 8 categorical, 10 to 18 the outlined tile in a colour (the design system's app icon); every app its own (#426). */
color: number;
tier: "core" | "standard" | "extension";
/** The extension that brings it: listed only while the project has it on; a window of it says it needs it. */
Expand Down Expand Up @@ -67,14 +67,14 @@ const APPS: AppDef[] = [
fromRoute: (rest) => ({ resource: rest ? { type: "location", id: rest } : null }), about: "A location: the real place, with what was gathered there" },
{ id: "timeline", name: "Timeline", glyph: "timeline", color: 6, tier: "standard", singleton: false, opens: ["timeline"], defaultSize: { w: 1320, h: 840 }, minSize: { w: 760, h: 500 }, component: TimelineApp,
fromRoute: timelineFromRoute, about: "A rough cut: clips with hold times, played back" },
{ id: "layouts", name: "Camera layouts", glyph: "camera-layout", color: 3, tier: "core", singleton: true, opens: ["layout"], defaultSize: { w: 1280, h: 820 }, minSize: { w: 760, h: 520 }, component: LayoutsApp,
{ id: "layouts", name: "Camera layouts", glyph: "camera-layout", color: 13, tier: "core", singleton: true, opens: ["layout"], defaultSize: { w: 1280, h: 820 }, minSize: { w: 760, h: 520 }, component: LayoutsApp,
fromRoute: layoutsFromRoute, about: "Which controls the phone's camera shows, and where" },
{ id: "devices", name: "Devices", glyph: "mobile", color: 6, tier: "core", singleton: true, opens: ["device"], defaultSize: { w: 1040, h: 720 }, minSize: { w: 600, h: 400 }, component: DevicesApp, about: "Your phones and tablets: their tabs and camera layout" },
{ id: "devices", name: "Devices", glyph: "mobile", color: 16, tier: "core", singleton: true, opens: ["device"], defaultSize: { w: 1040, h: 720 }, minSize: { w: 600, h: 400 }, component: DevicesApp, about: "Your phones and tablets: their tabs and camera layout" },
{ id: "canvas", name: "Canvas", glyph: "brush", color: 7, tier: "core", singleton: false, opens: ["canvas"], defaultSize: { w: 1280, h: 820 }, minSize: { w: 720, h: 480 }, component: CanvasApp,
fromRoute: (rest) => ({ resource: rest ? { type: "canvas", id: rest } : null }), about: "Draw, place photos and frame them" },
{ id: "presets", name: "Optics presets", glyph: "lens", color: 6, tier: "standard", singleton: true, opens: ["preset"], defaultSize: { w: 1000, h: 640 }, minSize: { w: 560, h: 380 }, component: PresetsApp,
{ id: "presets", name: "Optics presets", glyph: "lens", color: 8, tier: "standard", singleton: true, opens: ["preset"], defaultSize: { w: 1000, h: 640 }, minSize: { w: 560, h: 380 }, component: PresetsApp,
fromRoute: (rest) => ({ resource: rest ? { type: "preset", id: rest } : null }), about: "Cameras with their lenses, for frames on a canvas" },
{ id: "bin", name: "Recycle bin", glyph: "trash", color: 0, tier: "core", singleton: true, defaultSize: { w: 900, h: 560 }, minSize: { w: 520, h: 320 }, component: BinApp, about: "What was deleted, for 30 days" },
{ id: "bin", name: "Recycle bin", glyph: "trash", color: 10, tier: "core", singleton: true, defaultSize: { w: 900, h: 560 }, minSize: { w: 520, h: 320 }, component: BinApp, about: "What was deleted, for 30 days" },
{ id: "settings", name: "Settings", glyph: "settings", color: 0, tier: "core", singleton: true, opens: ["settings", "preferences", "property", "naming"], defaultSize: { w: 900, h: 640 }, minSize: { w: 480, h: 360 }, component: SettingsApp,
fromRoute: (rest) => ({ state: { tab: rest } }), about: "Yours, the project's and all projects: appearance, account, shortcuts, properties, naming, extensions" },
];
Expand Down
4 changes: 2 additions & 2 deletions apps/studio/src/ext/flows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { registerFileLook } from "../../fileKinds";
import { FlowsApp } from "./FlowsApp";

registerApp({
id: "flows", name: "Flows", glyph: "timeline", color: 3, tier: "extension", extension: "flows", singleton: true, opens: ["flow"],
id: "flows", name: "Flows", glyph: "bulb", color: 14, tier: "extension", extension: "flows", singleton: true, opens: ["flow"],
defaultSize: { w: 1320, h: 820 }, minSize: { w: 760, h: 480 }, component: FlowsApp,
fromRoute: (rest) => ({ resource: rest ? { type: "flow", id: rest } : null }), about: "Timed programmes for lights and cameras",
});
registerFileLook("flow", { glyph: "timeline", color: 3 });
registerFileLook("flow", { glyph: "bulb", color: 14 });
registerPhoneTab({ id: "flows", label: "Flows", icon: "timeline", extension: "flows" });
10 changes: 5 additions & 5 deletions apps/studio/src/fileKinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const LOOK: Record<string, { glyph: IconName; color: number }> = {
shortcut: { glyph: "shortcut", color: 0 },
preferences: { glyph: "settings", color: 0 },
settings: { glyph: "settings", color: 2 },
device: { glyph: "mobile", color: 6 },
layout: { glyph: "camera-layout", color: 3 },
device: { glyph: "mobile", color: 16 },
layout: { glyph: "camera-layout", color: 13 },
photo: { glyph: "image", color: 4 },
collection: { glyph: "layers", color: 4 },
shot: { glyph: "slate", color: 1 },
Expand All @@ -22,7 +22,7 @@ const LOOK: Record<string, { glyph: IconName; color: number }> = {
naming: { glyph: "edit", color: 0 },
// Types of later steps, named already by properties and naming patterns.
canvas: { glyph: "brush", color: 7 },
preset: { glyph: "lens", color: 6 },
preset: { glyph: "lens", color: 8 },
set: { glyph: "home", color: 2 },
location: { glyph: "location", color: 3 },
timeline: { glyph: "timeline", color: 6 },
Expand Down Expand Up @@ -52,12 +52,12 @@ export function targetOf(f: FileRec, files: ReadonlyMap<string, FileRec>): Targe

/** How a file shows as an icon or a row: a shortcut takes the look of what it opens. */
const PAGE_GLYPH: Record<string, IconName> = { general: "slate", properties: "tag", naming: "edit", customizations: "sliders", extensions: "extension", appearance: "palette", account: "user", shortcuts: "keyboard" };
/** The fixed folders' own glyphs: a first-class folder like an OS's Desktop, not a padlock. */
/** The fixed folders' own glyphs: a first-class folder like an OS's Desktop, not a padlock; in the system's grey, not a folder's blue (#426). */
const FIXED_GLYPH: Record<string, IconName> = { desktop: "desktop", settings: "settings" };
export const fixedGlyph = (fixed: string): IconName => FIXED_GLYPH[fixed] ?? "folder";

export function lookOf(f: FileRec, files: ReadonlyMap<string, FileRec>): { glyph: IconName; color: number; shortcut: boolean; broken: boolean } {
if (f.fixed && f.type === "folder") return { glyph: fixedGlyph(f.fixed), color: 5, shortcut: false, broken: false };
if (f.fixed && f.type === "folder") return { glyph: fixedGlyph(f.fixed), color: 0, shortcut: false, broken: false };
// A settings page (#426): its page's glyph; the person's in one colour, the project's in another.
if (f.type === "settings") return { glyph: PAGE_GLYPH[(f.body as { page?: string } | undefined)?.page ?? ""] ?? "settings", color: f.home ? 8 : 2, shortcut: false, broken: false };
if (f.type !== "shortcut") return { ...kindOf(f.type), shortcut: false, broken: false };
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/src/layouts/layouts.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
.lay-item > .oc-icon:first-child { color: var(--text-disabled); }
.lay-item__name { flex: 1; min-width: 80px; }
.lay-item--empty { justify-content: center; color: var(--text-secondary); font-size: var(--font-size-2xs); border: var(--border-w) dashed var(--border-control); cursor: default; }
.lay-swatches { display: inline-flex; gap: 6px; }
.lay-swatches { display: inline-flex; flex-wrap: wrap; gap: 8px; padding: 4px; }
.lay-swatches button { width: 22px; height: 22px; border: var(--border-w) solid var(--border-control); border-radius: 50%; cursor: pointer; }
.lay-swatches button.is-on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

Expand Down
5 changes: 4 additions & 1 deletion apps/studio/src/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export interface Prefs {
icons: Record<string, Record<string, { c: number; r: number }>>;
/** The recycle bin has an icon on the desktop. */
binOnDesktop: boolean;
/** Taskbar items hidden (#426); the launcher and the task view always stay. */
taskbarHide: TaskbarItem[];
/** How a collection's colour is drawn on its photos and its tile: a bar below or to the left, a dot, or a frame. */
collectionMark: "bar" | "barleft" | "dot" | "frame";
/** How long a clip added to a timeline holds, unless the timeline has a value of its own. */
Expand All @@ -33,9 +35,10 @@ export interface Prefs {
/** The file browser's table per kind of list (folders, Photos, Shots, …): which columns show and how wide (#426). */
columns: Record<string, ColumnSetup>;
}
export type TaskbarItem = "clock" | "account" | "theme" | "search" | "project";
export interface ColumnSetup { visible?: string[]; widths?: Record<string, number> }

export const DEFAULT_PREFS: Prefs = { columns: {}, theme: "auto", taskbarEdge: "bottom", taskbarAlign: "start", pins: {}, icons: {}, binOnDesktop: true, collectionMark: "bar", clipHoldMs: 2000, canvasTakesFrame: true };
export const DEFAULT_PREFS: Prefs = { columns: {}, taskbarHide: [], theme: "auto", taskbarEdge: "bottom", taskbarAlign: "start", pins: {}, icons: {}, binOnDesktop: true, collectionMark: "bar", clipHoldMs: 2000, canvasTakesFrame: true };
export type PrefsState = "local" | "loading" | "saved" | "saving" | "unsaved";

let prefs: Prefs = { ...DEFAULT_PREFS, theme: getTheme() };
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/shell.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,4 @@ body.wm-gesture { user-select: none; }
.st-wsrow { width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius-control); }
.st-wsrow:hover { background: var(--surface-hover); }
.st-hit { margin-left: var(--space-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-checks { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); }
1 change: 0 additions & 1 deletion apps/studio/src/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export const SHORTCUTS = [
// ---- Photo
{ scope: "photo", action: "prev", keys: ["ArrowLeft"], label: "Previous photo" },
{ scope: "photo", action: "next", keys: ["ArrowRight"], label: "Next photo" },
{ scope: "photo", action: "full", keys: ["f"], label: "Preview or full size" },

// ---- Timeline (docs/features/timeline.md)
{ scope: "timeline", action: "play", keys: [" "], display: "Space", label: "Play or pause" },
Expand Down
Loading
Loading