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
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ The module list and the engine commands are generated from `frontend/src` by
- `ui/keymap.ts`
- `ui/library-view.ts`
- `ui/media-pane.ts`
- `ui/menu-fit.ts`
- `ui/missing-media.ts`
- `ui/mode-popout.ts`
- `ui/planar-workspace.ts`
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<p align="center">
<img alt="version v2.20.2" src="https://img.shields.io/badge/version-v2.20.2-eef0f4?style=flat-square">
<img alt="version v2.21.0" src="https://img.shields.io/badge/version-v2.21.0-eef0f4?style=flat-square">
<img alt="TypeScript and Vite" src="https://img.shields.io/badge/TypeScript-Vite-3178c6?style=flat-square&logo=typescript&logoColor=white">
<img alt="Python FastAPI" src="https://img.shields.io/badge/Python-FastAPI-3776ab?style=flat-square">
<img alt="macOS, Windows, Linux" src="https://img.shields.io/badge/macOS%20%C2%B7%20Windows%20%C2%B7%20Linux-native-2f7bf5?style=flat-square">
Expand Down
2 changes: 1 addition & 1 deletion backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

prefer_bundled()

APP_VERSION = "2.20.2"
APP_VERSION = "2.21.0"

app = FastAPI(title="formcut engine", version=APP_VERSION)

Expand Down
2 changes: 1 addition & 1 deletion demo/assets/style.css

Large diffs are not rendered by default.

78 changes: 46 additions & 32 deletions demos/deliver/assets/deliver.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demos/deliver/assets/style.css

Large diffs are not rendered by default.

132 changes: 75 additions & 57 deletions demos/grade/assets/grade.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demos/grade/assets/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion form-functions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"format": "form-functions",
"format_version": 1,
"app": "formcut",
"app_version": "2.20.2",
"app_version": "2.21.0",
"functions": [
{
"id": "transcribe",
Expand Down
45 changes: 45 additions & 0 deletions frontend/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,51 @@

Reasoning behind interface changes, newest first.

## 2.21.0 · Blend mode and Timeline height menus take the same cap and hint

- **Why.** The two other menus that open at a point, under a button inside the window (Blend mode in the inspector, the timeline's height chip), had the same uncapped `.dropdown` card; Blend mode, opened low in the inspector of a short window, ran off the bottom. Both now `fitMenu` once and open through `openUnder(menu, box.left, box.bottom + 4)`, so they keep their place under the button, take `menuCap` from that top while hidden, and show the hint. They do not flip above the button. `aria-expanded` follows open and close as before.
- **Removed.**

```ts
const box = blendBtn.getBoundingClientRect(); blendMenu.style.left = `${box.left}px`; blendMenu.style.top = `${box.bottom + 4}px`; blendMenu.style.minWidth = `${box.width}px`;
blendMenu.hidden = !blendMenu.hidden; blendBtn.setAttribute("aria-expanded", String(!blendMenu.hidden));
```

```ts
const box = size.getBoundingClientRect(); heights.style.left = `${box.left}px`; heights.style.top = `${box.bottom + 4}px`;
heights.hidden = !heights.hidden; size.setAttribute("aria-expanded", String(!heights.hidden));
```

## 2.21.0 · the title bar's menus keep under the bar, take a cap and show a more-below hint (FORM-MENU-OVERLAP-FIX 1.2.0)

- **The fault.** File (titlebar.ts), Edit and View (editor-actions.ts), Extensions (extensions.ts), Help (help-menu.ts) and Panels (workspace-layout.ts) each set `top` to their button's bottom and showed the `.dropdown` card, which had no `max-height` and no overflow. The button's bottom is 8 px above the title bar's bottom edge (32 against 40), so every one opened over the bar's lower edge, and a menu taller than the room below ran off the bottom of the window with its last rows out of reach.
- **One helper (ui/menu-fit.ts).** `openUnder(menu, x, y, fromRight)` takes the larger of `y` and the `.titlebar` bottom as the top, sets `max-height: menuCap(top)` (three quarters of the window, never past `innerHeight - top - 4`) while the card is `visibility: hidden`, resets the list's scroll, measures the width, clamps `left` into the window, sets the hint with `showMore(menu, true)`, then shows it. Panels passes `fromRight` with `innerWidth - 12`, the same place its old `right: 12px` gave. On `resize` an open menu's `max-height` is worked out again from the top it opened at; no row is rebuilt.
- **The hint.** `fitMenu(menu)` moves the rows once, where each menu is built, into `.dropdown-list` (the scroller, which carries the mask) and adds `.dropdown-more` (the pill) to the card, so the rows fade into the card's own `--float` and the card's border and shadow stay whole. The list's `scroll` runs `showMore`; the Extensions menu runs it again after `paintMenu` adds command rows. The File menu's recent projects are written into the list (`fileMenu(rows, ...)`). The CSS is FormVis 2.8.4's with this app's names: `.dropdown-list`, `.dropdown-more`, `has-more`, `no-fade`, the registered `--menu-more`, and the card's own `--float`, `--edge-strong` and `--ink-soft` for the pill. The `#000` in the mask is an alpha stop, not a colour on screen.
- **Nothing else reads these cards' children or `scrollTop`**: every lookup is a `closest` or a `querySelector`, which still finds the rows inside the list. formcut has no right-click menu: the one `contextmenu` listener (inspector-pane.ts, the keyframe button) sets an interpolation and opens nothing.
- **Removed.** The placement each menu had:

```ts
menu.style.left = `${rect.left}px`;
menu.style.top = `${rect.bottom + 4}px`;
menu.hidden = false;
```

```ts
button.addEventListener("click", () => { const rect = button.getBoundingClientRect(); menu.style.left = `${rect.left}px`; menu.style.top = `${rect.bottom}px`; if (menu.hidden) for (const probe of probes) probe(); menu.hidden = !menu.hidden; });
```

```ts
menu.style.left = `${rect.left}px`;
menu.style.top = `${rect.bottom}px`;
menu.hidden = !menu.hidden;
```

```ts
panels.title = "Panels"; panels.addEventListener("click", () => { const box = panels.getBoundingClientRect(); menu.style.right = "12px"; menu.style.top = `${box.bottom}px`; menu.hidden = !menu.hidden; });
```

The third block was in both extensions.ts and help-menu.ts; titlebar.ts also passed `menu` to `fileMenu(menu, projects)`.

## Unreleased · Settings, About, Third-party notices

- **The button.** About gains Third-party notices, which reads `GET /api/notices` once and shows it in the scrolling snippet style the OpenH264 licence already uses (`.notices-text`, 240 px high). A build without the file says so in place of the text. The About line now says NOTICE holds the media and model credits and the licences are below, in English, Spanish and German and in the Arabic, Persian, Hebrew and Croatian locale files.
Expand Down
4 changes: 2 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "formcut-frontend",
"version": "2.20.2",
"version": "2.21.0",
"private": true,
"type": "module",
"scripts": {
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,15 @@ input[type="range"], input[type="checkbox"], input[type="radio"], input[type="co
box-shadow: 0 8px 28px var(--veil);
z-index: var(--z-dropdown);
}
@property --menu-more { syntax: '<number>'; inherits: false; initial-value: 0; }
.dropdown:not([hidden]) { display: flex; flex-direction: column; overflow: hidden; }
.dropdown-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; --menu-more: 0; -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - min(88px, 40%)), rgb(0 0 0 / calc(1 - var(--menu-more))) calc(100% - min(22px, 10%))); mask-image: linear-gradient(to bottom, #000 calc(100% - min(88px, 40%)), rgb(0 0 0 / calc(1 - var(--menu-more))) calc(100% - min(22px, 10%))); transition: --menu-more 160ms ease-out; }
.dropdown-more { position: absolute; left: 50%; bottom: 6px; width: 56px; height: 12px; margin-left: -28px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--edge-strong); border-radius: 999px; background: var(--float); color: var(--ink-soft); pointer-events: none; opacity: 0; transition: opacity 160ms ease-out; }
.dropdown-more svg { width: 12px; height: 8px; }
.dropdown.has-more > .dropdown-list { --menu-more: 1; scroll-padding-block-end: min(88px, 40%); transition-duration: 490ms; }
.dropdown.has-more > .dropdown-more { opacity: 1; transition-duration: 490ms; }
.dropdown.no-fade > .dropdown-list, .dropdown.no-fade > .dropdown-more { transition: none; }
@media (prefers-reduced-motion: reduce) { .dropdown-list, .dropdown-more { transition: none; } }
.dropdown-item {
display: block;
width: 100%;
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/ui/editor-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { installFocusMoves } from "./focus-moves";
import { addDeviceClip } from "./device-inspector";
import { installDeviceStage } from "./device-stage";
import { installKeymap } from "./keymap";
import { fitMenu, openUnder } from "./menu-fit";

export const editorVerbs: Record<string, () => void> = {};

Expand Down Expand Up @@ -104,7 +105,8 @@ export function installEditorActions(engine: ProjectEngine, bin: MediaBin): void
menu.append(item);
}
document.body.append(menu);
button.addEventListener("click", () => { const rect = button.getBoundingClientRect(); menu.style.left = `${rect.left}px`; menu.style.top = `${rect.bottom}px`; if (menu.hidden) for (const probe of probes) probe(); menu.hidden = !menu.hidden; });
fitMenu(menu);
button.addEventListener("click", () => { if (!menu.hidden) { menu.hidden = true; return; } for (const probe of probes) probe(); const rect = button.getBoundingClientRect(); openUnder(menu, rect.left, rect.bottom); });
document.addEventListener("pointerdown", event => { if (!menu.contains(event.target as Node) && !button.contains(event.target as Node) && !menu.hidden) menu.hidden = true; });
document.addEventListener("keydown", event => { if (event.key === "Escape") menu.hidden = true; });
};
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/ui/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { MediaBin } from "../engine/media";
import { api } from "../engine/api";
import { t } from "../i18n";
import { icon } from "./icons";
import { fitMenu, openUnder, showMore } from "./menu-fit";
import { agentQuestion } from "../dock-adapter";
import { ERR, ExtensionHost, HostError, PERMISSION_WORDS, type ExtensionRecord, type Frame, type Permission, type Theme } from "../extensions/host-bridge";
import { applyOps, commandList, readDocument, runCommand } from "../extensions/catalogue";
Expand Down Expand Up @@ -341,6 +342,7 @@ function paintMenu() {
for (const node of existing.values()) node.remove();
holder.hidden = !items.length;
menu.querySelector<HTMLElement>('[data-ref="commands-divider"]')!.hidden = !items.length;
showMore(menu);
}

function signature(ext: Row) {
Expand Down Expand Up @@ -636,13 +638,13 @@ export function installExtensionsMenu(): void {
<button class="dropdown-item" data-act="reload">${t("ext.reload")}</button>
<button class="dropdown-item" data-act="manage">${t("ext.manage")}</button>`;
document.body.append(menu);
fitMenu(menu);
const shut = () => { if (menu && !menu.hidden) menu.hidden = true; };
button.addEventListener("click", () => {
if (!menu) return;
if (!menu.hidden) { menu.hidden = true; return; }
const rect = button.getBoundingClientRect();
menu.style.left = `${rect.left}px`;
menu.style.top = `${rect.bottom}px`;
menu.hidden = !menu.hidden;
openUnder(menu, rect.left, rect.bottom);
});
document.addEventListener("pointerdown", (event) => { if (menu && !menu.contains(event.target as Node) && !button.contains(event.target as Node)) shut(); });
document.addEventListener("keydown", (event) => { if (event.key === "Escape") shut(); });
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/ui/help-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// app's native Help menu calls the same window.formcut.actions.openDemo.
import { REPO_DEMOS } from "../demos";
import { t } from "../i18n";
import { fitMenu, openUnder } from "./menu-fit";

export function installHelpMenu(openDemo: (id: string) => Promise<void>): void {
const button = document.querySelector<HTMLButtonElement>('.titlebar-left .menu-item[data-ref="help"]');
Expand All @@ -13,12 +14,12 @@ export function installHelpMenu(openDemo: (id: string) => Promise<void>): void {
menu.innerHTML = `<div class="dropdown-label">${t("demos.title")}</div>` +
REPO_DEMOS.map((demo) => `<button class="dropdown-item" data-demo="${demo.id}">${demo.title}</button>`).join("");
document.body.append(menu);
fitMenu(menu);
const shut = () => { if (!menu.hidden) menu.hidden = true; };
button.addEventListener("click", () => {
if (!menu.hidden) { menu.hidden = true; return; }
const rect = button.getBoundingClientRect();
menu.style.left = `${rect.left}px`;
menu.style.top = `${rect.bottom}px`;
menu.hidden = !menu.hidden;
openUnder(menu, rect.left, rect.bottom);
});
document.addEventListener("pointerdown", (event) => { if (!menu.contains(event.target as Node) && !button.contains(event.target as Node)) shut(); });
document.addEventListener("keydown", (event) => { if (event.key === "Escape") shut(); });
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/ui/inspector-pane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { activeProfile, onInterfaceMode } from "./interface-mode";
import { text } from "../i18n/text";
import { sampledTransform } from "../engine/keyframes";
import { mountDeviceSection } from "./device-inspector";
import { fitMenu, openUnder } from "./menu-fit";

const BLEND_MODES = ["Normal", "Multiply", "Screen", "Overlay", "Darken", "Lighten", "Difference", "Add", "Subtract", "Soft Light"];

Expand Down Expand Up @@ -725,10 +726,12 @@ export function buildInspectorPane(engine: ProjectEngine, bin: MediaBin): HTMLEl
blendMenu.append(item);
}
document.body.append(blendMenu);
fitMenu(blendMenu);
blendBtn.addEventListener("click", () => {
const box = blendBtn.getBoundingClientRect(); blendMenu.style.left = `${box.left}px`; blendMenu.style.top = `${box.bottom + 4}px`; blendMenu.style.minWidth = `${box.width}px`;
if (!blendMenu.hidden) { blendMenu.hidden = true; blendBtn.setAttribute("aria-expanded", "false"); return; }
const box = blendBtn.getBoundingClientRect(); blendMenu.style.minWidth = `${box.width}px`;
for (const item of blendMenu.querySelectorAll<HTMLElement>("[data-mode]")) item.setAttribute("aria-pressed", String(item.dataset.mode === (blendLabel.dataset.mode ?? "Normal")));
blendMenu.hidden = !blendMenu.hidden; blendBtn.setAttribute("aria-expanded", String(!blendMenu.hidden));
openUnder(blendMenu, box.left, box.bottom + 4); blendBtn.setAttribute("aria-expanded", "true");
});
document.addEventListener("pointerdown", (event) => { if (!blendMenu.hidden && !blendMenu.contains(event.target as Node) && !blendBtn.contains(event.target as Node)) { blendMenu.hidden = true; blendBtn.setAttribute("aria-expanded", "false"); } }, true);
document.addEventListener("keydown", (event) => { if (event.key === "Escape" && !blendMenu.hidden) { blendMenu.hidden = true; blendBtn.setAttribute("aria-expanded", "false"); } });
Expand Down
49 changes: 49 additions & 0 deletions frontend/src/ui/menu-fit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const MENU_SHARE = 0.75, MENU_PAD = 4;
const capFrom = new WeakMap<HTMLElement, number>();

export const menuCap = (top: number): number => Math.max(0, Math.min(Math.floor(window.innerHeight * MENU_SHARE), Math.floor(window.innerHeight - top - MENU_PAD)));

const listOf = (menu: HTMLElement): HTMLElement => menu.querySelector<HTMLElement>(":scope > .dropdown-list") ?? menu;

export function showMore(menu: HTMLElement, instant = false): void {
const list = listOf(menu);
const more = !menu.hidden && list.scrollHeight - list.clientHeight - list.scrollTop > 1;
if (instant) menu.classList.add("no-fade");
menu.classList.toggle("has-more", more);
if (instant) { void getComputedStyle(menu.lastElementChild ?? menu).opacity; menu.classList.remove("no-fade"); }
}

export function fitMenu(menu: HTMLElement): HTMLElement {
const list = document.createElement("div");
list.className = "dropdown-list";
list.setAttribute("role", "none");
list.append(...menu.childNodes);
const more = document.createElement("div");
more.className = "dropdown-more";
more.setAttribute("aria-hidden", "true");
more.innerHTML = '<svg viewBox="0 0 12 8"><path d="M1.5 1.5 6 6l4.5-4.5" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
menu.append(list, more);
list.addEventListener("scroll", () => showMore(menu), { passive: true });
window.addEventListener("resize", () => {
if (menu.hidden) return;
menu.style.maxHeight = `${menuCap(capFrom.get(menu) ?? MENU_PAD)}px`;
showMore(menu, true);
});
return list;
}

export function openUnder(menu: HTMLElement, x: number, at: number, fromRight = false): void {
const bar = document.querySelector(".titlebar")?.getBoundingClientRect();
const y = bar && bar.height > 0 ? Math.max(at, bar.bottom) : at;
capFrom.set(menu, y);
menu.style.visibility = "hidden";
menu.hidden = false;
menu.style.maxHeight = `${menuCap(y)}px`;
listOf(menu).scrollTop = 0;
const w = menu.offsetWidth;
const left = Math.max(MENU_PAD, Math.min(fromRight ? x - w : x, window.innerWidth - w - MENU_PAD));
menu.style.left = `${Math.round(left)}px`;
menu.style.top = `${Math.round(y)}px`;
showMore(menu, true);
menu.style.visibility = "";
}
8 changes: 4 additions & 4 deletions frontend/src/ui/titlebar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fileMenu } from "./file-menu";
import { fitMenu, openUnder } from "./menu-fit";
import { text } from "../i18n/text";
import { escapeHtml } from "./safe-text";
import type { ProjectEngine } from "../engine/project";
Expand Down Expand Up @@ -146,6 +147,7 @@ export function buildTitlebar(engine: ProjectEngine, actions?: AppActions): HTML
menu.className = "dropdown";
menu.hidden = true;
document.body.append(menu);
const rows = fitMenu(menu);
// The logo is the way back to the start screen.
el.querySelector('[data-ref="home"]')!.addEventListener("click", () => {
document.dispatchEvent(new CustomEvent("formcut:home"));
Expand Down Expand Up @@ -200,7 +202,7 @@ export function buildTitlebar(engine: ProjectEngine, actions?: AppActions): HTML

const fillMenu = async () => {
const projects = await listProjects();
fileMenu(menu, projects);
fileMenu(rows, projects);
};

fileBtn.addEventListener("click", async (ev) => {
Expand All @@ -211,9 +213,7 @@ export function buildTitlebar(engine: ProjectEngine, actions?: AppActions): HTML
}
await fillMenu();
const rect = fileBtn.getBoundingClientRect();
menu.style.left = `${rect.left}px`;
menu.style.top = `${rect.bottom + 4}px`;
menu.hidden = false;
openUnder(menu, rect.left, rect.bottom + 4);
});
window.addEventListener("pointerdown", (ev) => {
if (!menu.hidden && !menu.contains(ev.target as Node) && ev.target !== fileBtn) {
Expand Down
Loading
Loading