mirror of
https://github.com/storytold/figcraft.git
synced 2026-12-02 15:01:23 -05:00
M5: the presenter's detail margin grows it to at most half the whole-frame texture's pixels (#2879) (#2902)
This commit is contained in:
@@ -357,6 +357,11 @@ impl Presenter {
|
||||
/// window, are drawn from a smaller texture scaled up).
|
||||
const MAX_TEXTURE_PIXELS: f64 = 16_777_216.0;
|
||||
|
||||
/// The most pixels a detail's margin grows it to (see [`detail_plan`]): half the whole-frame cap,
|
||||
/// since the whole texture, the detail texture and the worker's render and its converted image of
|
||||
/// the detail are held at once (#2879).
|
||||
const MAX_DETAIL_PIXELS: f64 = MAX_TEXTURE_PIXELS / 2.0;
|
||||
|
||||
/// The pixel scale, at most `px`, at which `bounds` makes a texture the GPU takes (no side past
|
||||
/// its limit) of at most [`MAX_TEXTURE_PIXELS`].
|
||||
pub(super) fn texture_scale(ctx: &egui::Context, bounds: figcraft_geom::Rect, px: f64) -> f64 {
|
||||
@@ -372,9 +377,10 @@ pub(super) fn texture_scale_for(bounds: figcraft_geom::Rect, px: f64, side: f64)
|
||||
|
||||
/// The page area to draw at the full pixel scale `px` over the whole frame's capped texture, when
|
||||
/// that texture is below `px`: the part in `visible` with a margin (a quarter of its size each
|
||||
/// way, shrunk until the area makes a texture the GPU takes), inside `bounds`. `None` when the
|
||||
/// whole frame is already at `px`, or nothing of it is in view. When the view alone is past the
|
||||
/// caps it is returned all the same, and drawn at the scale [`texture_scale_for`] gives it.
|
||||
/// way, shrunk until the area makes a texture the GPU takes of at most [`MAX_DETAIL_PIXELS`]),
|
||||
/// inside `bounds`. `None` when the whole frame is already at `px`, or nothing of it is in view.
|
||||
/// When the view alone is past the caps it is returned all the same, and drawn at the scale
|
||||
/// [`texture_scale_for`] gives it (so a view up to [`MAX_TEXTURE_PIXELS`] stays at `px`).
|
||||
pub(super) fn detail_plan(bounds: figcraft_geom::Rect, visible: figcraft_geom::Rect, px: f64, side: f64) -> Option<figcraft_geom::Rect> {
|
||||
if texture_scale_for(bounds, px, side) >= px || !(px.is_finite() && px > 0.0) {
|
||||
return None;
|
||||
@@ -383,7 +389,7 @@ pub(super) fn detail_plan(bounds: figcraft_geom::Rect, visible: figcraft_geom::R
|
||||
if !(view.width() > 0.0 && view.height() > 0.0 && view.width().is_finite() && view.height().is_finite()) {
|
||||
return None;
|
||||
}
|
||||
let fits = |r: &figcraft_geom::Rect| r.width() * px <= side && r.height() * px <= side && r.area() * px * px <= MAX_TEXTURE_PIXELS;
|
||||
let fits = |r: &figcraft_geom::Rect| r.width() * px <= side && r.height() * px <= side && r.area() * px * px <= MAX_DETAIL_PIXELS;
|
||||
let mut margin = 0.25;
|
||||
for _ in 0..8 {
|
||||
let r = view.inflate(view.width() * margin, view.height() * margin).intersect(bounds);
|
||||
|
||||
@@ -690,9 +690,15 @@ fn detail_plan_edge_cases() {
|
||||
// Partly outside: the part inside.
|
||||
let r = actions::detail_plan(bounds, R::new(0.0, -500.0, 1440.0, 360.0), 2.0, side).unwrap();
|
||||
assert!(r.y0 == 0.0 && r.y1 >= 360.0, "{r:?}");
|
||||
// A view whose quarter margin passes the pixel cap gets a smaller margin that fits.
|
||||
let r = actions::detail_plan(bounds, R::new(0.0, 3000.0, 1440.0, 5000.0), 2.0, side).unwrap();
|
||||
assert!(r.height() > 2000.0 && r.height() < 3000.0 && r.width() * r.height() * 4.0 <= 16_777_216.0, "{r:?}");
|
||||
// A view whose quarter margin passes the detail's pixel cap gets a smaller margin that fits,
|
||||
// well under the whole frame's cap.
|
||||
let r = actions::detail_plan(bounds, R::new(0.0, 3000.0, 1440.0, 4000.0), 2.0, side).unwrap();
|
||||
assert!(r.height() > 1000.0 && r.height() < 1500.0 && r.width() * r.height() * 4.0 < 16_777_216.0 / 1.5, "{r:?}");
|
||||
// A view past the detail's cap but not the whole frame's gets no margin, and is still drawn at
|
||||
// device scale.
|
||||
let big = R::new(0.0, 1000.0, 1440.0, 3000.0);
|
||||
assert_eq!(actions::detail_plan(bounds, big, 2.0, side), Some(big));
|
||||
assert_eq!(actions::texture_scale_for(big, 2.0, side), 2.0);
|
||||
// A view past the caps by itself is returned as it is.
|
||||
let tall = R::new(0.0, 1000.0, 1440.0, 5000.0);
|
||||
assert_eq!(actions::detail_plan(bounds, tall, 2.0, side), Some(tall));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Prototyping parity
|
||||
|
||||
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-12-02 · **Change:** minor (File ▸ Export prototype as HTML writes a page's prototype as one self-contained HTML file that opens offline in any browser, its click links working (#2886); the sharp detail of a tall frame on a HiDPI display renders off the UI thread, the last detail standing in until it arrives (#2187); a Motion row: the keyframe timeline exists and plays while editing, not in the presenter; a zoom, resize or other change of the presenter's scale or view waits until the view is still before the sharp detail of a tall frame is drawn again (#2187); platform arrow-key aliases and document-scoped player controls, with failed batch UI requests rolled back; at 100% a presented frame reaches the window's edges, the padding kept for Fit; without a device, a frame taller than the window with fixed or sticky layers scrolls in the window as on a device's screen, so a fixed header stays at the window's top to the end of the page instead of panning away with the frame (#2430); dragging a prototype connection near the canvas edge pans the view toward it, so a link can reach a frame off screen (#2015); in the presenter's comment mode (C) a click on the presented frame starts a comment there and the mode stays on for the next one, Escape closes the draft and then the mode, measured in Figma's web app 2026-11-10 (#2209); presenting a tall frame is sharp on a HiDPI display: a frame too big for one texture at device scale (a 1440 by 9701 frame at 2 pixels a unit) is still drawn from the capped whole-frame texture, with the part in view drawn again over it from a texture at device scale (#2127); a connection dragged from a variant, or a layer in it, onto a sibling variant makes Change to, On click, Instant, with the sibling outlined (#2158); `proto.settings` refuses an unknown device with the list of devices instead of saving it, takes a known one in any case, and answers the page's settings, so `proto.settings {}` reads them (#2027); Hide UI in the presenter's Options menu, and Cmd/Ctrl+\ as in the editor: the bar above the prototype and the navigation bar under it go away, a toast names the key that brings them back, `proto.presentOptions {hideUi}` (#1820); the Controller menu names each button as PlayStation and Switch controllers do; "Open in new tab" on Open link: off, the web build's own tab goes to the link; a manual overlay's position can be dragged on the canvas (#405); Open link notices now cover mail links, and skipping them covers only links the viewer fired (#1096); overlay positions relative to the layer that opens them; the Triggers row no longer lists delays on mouse triggers as missing; top-level frames bigger than the device's screen scroll in the player; Change to, set variable and set variable mode lay out what they change in the player, as the canvas does; presentation tabs, one per page of a file; a Present tab with device and scale controls (#537); core editor leftovers: delays on mouse triggers and manual overlay offsets; controller buttons on key/gamepad triggers, widgets that react in prototypes, `proto.evaluate` and the mode lookup rules pinned) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-12-02 · **Change:** minor (the margin around the sharp detail of a tall frame on a HiDPI display grows it to at most 8.4 million pixels, half the whole-frame texture's cap, so the presenter holds less at once; the view itself stays at device scale (#2879); File ▸ Export prototype as HTML writes a page's prototype as one self-contained HTML file that opens offline in any browser, its click links working (#2886); the sharp detail of a tall frame on a HiDPI display renders off the UI thread, the last detail standing in until it arrives (#2187); a Motion row: the keyframe timeline exists and plays while editing, not in the presenter; a zoom, resize or other change of the presenter's scale or view waits until the view is still before the sharp detail of a tall frame is drawn again (#2187); platform arrow-key aliases and document-scoped player controls, with failed batch UI requests rolled back; at 100% a presented frame reaches the window's edges, the padding kept for Fit; without a device, a frame taller than the window with fixed or sticky layers scrolls in the window as on a device's screen, so a fixed header stays at the window's top to the end of the page instead of panning away with the frame (#2430); dragging a prototype connection near the canvas edge pans the view toward it, so a link can reach a frame off screen (#2015); in the presenter's comment mode (C) a click on the presented frame starts a comment there and the mode stays on for the next one, Escape closes the draft and then the mode, measured in Figma's web app 2026-11-10 (#2209); presenting a tall frame is sharp on a HiDPI display: a frame too big for one texture at device scale (a 1440 by 9701 frame at 2 pixels a unit) is still drawn from the capped whole-frame texture, with the part in view drawn again over it from a texture at device scale (#2127); a connection dragged from a variant, or a layer in it, onto a sibling variant makes Change to, On click, Instant, with the sibling outlined (#2158); `proto.settings` refuses an unknown device with the list of devices instead of saving it, takes a known one in any case, and answers the page's settings, so `proto.settings {}` reads them (#2027); Hide UI in the presenter's Options menu, and Cmd/Ctrl+\ as in the editor: the bar above the prototype and the navigation bar under it go away, a toast names the key that brings them back, `proto.presentOptions {hideUi}` (#1820); the Controller menu names each button as PlayStation and Switch controllers do; "Open in new tab" on Open link: off, the web build's own tab goes to the link; a manual overlay's position can be dragged on the canvas (#405); Open link notices now cover mail links, and skipping them covers only links the viewer fired (#1096); overlay positions relative to the layer that opens them; the Triggers row no longer lists delays on mouse triggers as missing; top-level frames bigger than the device's screen scroll in the player; Change to, set variable and set variable mode lay out what they change in the player, as the canvas does; presentation tabs, one per page of a file; a Present tab with device and scale controls (#537); core editor leftovers: delays on mouse triggers and manual overlay offsets; controller buttons on key/gamepad triggers, widgets that react in prototypes, `proto.evaluate` and the mode lookup rules pinned) · **Target:** Figma Design (desktop app 126.10.7)
|
||||
|
||||
**Breadth ~92%, ready ~74% (estimated).** Every Figma trigger except media, every action except
|
||||
media control, every transition and easing exist; key/gamepad triggers take controller buttons,
|
||||
@@ -112,6 +112,7 @@ tool; opt-in), **silent** (the documentation doesn't say; the case pins the curr
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-12-02 | patch | M5, #2879 (from #2187): presenting a tall frame on a HiDPI display holds the capped whole-frame texture, the detail's texture and, while a detail renders, its pixmap and converted image at once. The detail's margin round the view (a quarter of it each way, halved until it fits) now grows it to at most 8.4 million pixels instead of 16.8 million, which on a 4K display (a view of 8.3 million pixels) lowers the peak by about a quarter; a view bigger than that by itself still gets a detail at device scale up to 16.8 million pixels, without a margin. Reusing the render's buffer between details was left out: it keeps the peak the same and holds the buffer between renders. Test: `present::tests::detail_plan_edge_cases`. Numbers unchanged |
|
||||
| 2026-12-02 | minor | M5, #2886: File ▸ Export prototype as HTML… (`file.exportPrototypeHtml`) writes the page's prototype as one self-contained HTML file for viewers without FigCraft, an account or a network: the frames as embedded images, click interactions that navigate, go back or open a web link as links, and what it leaves out listed in `warnings`. Test: `proto_html_tests`. |
|
||||
| 2026-12-02 | patch | M5, #2187: the sharp detail drawn over a tall frame's capped texture on a HiDPI display (up to 16.8 million pixels) was rendered on the UI thread, holding up the frame it was asked in: once the view was still, after an edit, and at each frame of an animated GIF in it. It now renders on a thread of its own (inline in the browser, which has none), the newest request winning; until it arrives the last detail at the same scale stands in while it covers the view (a step behind after an edit or a GIF's next frame), else the capped texture shows alone. A render that fails is not asked again for the same view. Peak memory is unchanged (the pixmap and its converted image now live on that thread). Test: `present::tests::an_animated_gif_in_a_tall_frame_gets_a_new_detail_at_its_next_frame`; the detail tests wait for the worker and check a still view asks for no new render. Numbers unchanged |
|
||||
| 2026-12-01 | patch | M5, #380: Escape with the presenter's Options menu open closed the presentation along with the menu; it now closes only the menu, and a click outside a menu no longer reaches the prototype. Test: `present_options_tests` |
|
||||
|
||||
Reference in New Issue
Block a user