diff --git a/crates/ui-egui/src/present.rs b/crates/ui-egui/src/present.rs index 8b894ab41..05a997a66 100644 --- a/crates/ui-egui/src/present.rs +++ b/crates/ui-egui/src/present.rs @@ -333,6 +333,9 @@ pub struct Presenter { pan: Option<(f64, f64)>, /// How far the view can pan, and the zoom it shows at (from the last layout). pan_range: (f64, f64), + /// Without a device, the part of the presented frame the window shows (page units) when the + /// frame is bigger: the window is then its screen (from the last layout). + window: Option<(f64, f64)>, zoom: f64, /// Scrolling that carries on after the input let go. fling: Option, @@ -398,6 +401,7 @@ impl Presenter { view: PresentView::default(), pan: None, pan_range: (0.0, 0.0), + window: None, zoom: 1.0, fling: None, wheel: None, diff --git a/crates/ui-egui/src/present/layout.rs b/crates/ui-egui/src/present/layout.rs index 1844c4f3b..f21f6684a 100644 --- a/crates/ui-egui/src/present/layout.rs +++ b/crates/ui-egui/src/present/layout.rs @@ -1,6 +1,6 @@ use super::scroll::{clamp_scroll, page_settings}; use super::{ - Device, DeviceColor, Document, NodeId, OverlayState, Point, Pos2, PresentScale, PresentView, Presenter, Rect, Scroller, Vec2, + Device, DeviceColor, Document, NodeId, OverlayState, Point, Pos2, PresentScale, PresentView, Presenter, Rect, ScrollPosition, Scroller, Vec2, anchored_overlay_rect, pos2, vec2, }; @@ -111,16 +111,21 @@ pub(super) fn layout(p: &mut Presenter, area: Rect, chrome: Chrome) -> Option Option 0.5 { f64::from(room) / scale } else { len }; + let window = (device.is_none() && pins).then(|| (fit(sw, avail.width()), fit(sh, avail.height()))).filter(|w| *w != (sw, sh)); + if p.window != window { + p.window = window; + p.rev += 1; + } + let disp = p.display()?; + let fb = disp.world_bounds(p.current)?; + let (size, x, top, whole) = outer(window.unwrap_or((sw, sh)), scale); p.zoom = scale; // What's bigger than the window pans: starting centred across and at the top. let over = |d: f32| if d > 0.5 { d } else { 0.0 }; diff --git a/crates/ui-egui/src/present/navigate.rs b/crates/ui-egui/src/present/navigate.rs index a83e3940f..e748ef2b1 100644 --- a/crates/ui-egui/src/present/navigate.rs +++ b/crates/ui-egui/src/present/navigate.rs @@ -101,7 +101,7 @@ impl Presenter { } let doc = self.doc.as_ref()?; let mut d = apply_scroll(doc, &self.scroll); - if let Some(vp) = viewport(doc, self.current) { + if let Some(vp) = self.screen(doc) { fit_viewport(&mut d, self.current, vp); } self.display = Some((self.rev, d.clone())); diff --git a/crates/ui-egui/src/present/scroll.rs b/crates/ui-egui/src/present/scroll.rs index ea3db1538..ab3cc36ad 100644 --- a/crates/ui-egui/src/present/scroll.rs +++ b/crates/ui-egui/src/present/scroll.rs @@ -73,10 +73,16 @@ impl Presenter { true } - /// How far `frame` scrolls (in `doc`, without scroll offsets): the presented frame within the - /// device's screen, other frames within themselves. + /// What of the presented frame shows (page units): its device's screen, else the window when + /// the frame is bigger than it. None: the frame shows whole. + pub(super) fn screen(&self, doc: &Document) -> Option<(f64, f64)> { + viewport(doc, self.current).or(self.window) + } + + /// How far `frame` scrolls (in `doc`, without scroll offsets): the presented frame within its + /// screen ([`Self::screen`]), other frames within themselves. pub(super) fn range(&self, doc: &Document, frame: NodeId) -> (f64, f64) { - let vp = if frame == self.current { viewport(doc, frame) } else { None }; + let vp = if frame == self.current { self.screen(doc) } else { None }; scroll_range_in(doc, frame, vp) } diff --git a/crates/ui-egui/src/present/tests.rs b/crates/ui-egui/src/present/tests.rs index 9b4504bdb..fb8cdc773 100644 --- a/crates/ui-egui/src/present/tests.rs +++ b/crates/ui-egui/src/present/tests.rs @@ -680,3 +680,47 @@ fn pane_bar_buttons_paint_16pt() { assert!(paints_icon_at_button_size(&painted, icon), "{icon:?} is not 16 pt"); } } + +#[test] +fn without_a_device_fixed_and_sticky_layers_keep_to_the_window_to_the_end_of_the_page() { + // Fixed (#2430): without a device, a frame taller than the window scrolled its content, then + // panned whole through the window, taking a fixed header and a sticky bar off its top. + let mut session = figcraft_engine::Session::new(); + let frame = + id(&session.execute("node.create", &json!({"type": "frame", "width": 1440, "height": 1200, "props": {"overflow": "vertical"}})).unwrap()); + let mut layer = |y: f64, height: f64, position: &str| { + let r = id(&session + .execute("node.create", &json!({"type": "rectangle", "parent": frame, "x": 0, "y": y, "width": 1440, "height": height})) + .unwrap()); + session.execute("node.set", &json!({"id": r, "props": {"scrollPosition": position}})).unwrap(); + r + }; + let page = layer(0.0, 4000.0, "scrolls"); + let header = layer(0.0, 80.0, "fixed"); + let sticky = layer(300.0, 40.0, "sticky"); + let mut ui = Ui::new(session); + ui.run("proto.present", json!({"start": frame})); + ui.app.ui.present.as_mut().unwrap().view.scale = PresentScale::FitWidth; + ui.frames(2, Vec::new); + let wheel = || { + vec![ + egui::Event::PointerMoved(pos2(720.0, 500.0)), + egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Point, + source: egui::MouseWheelSource::Unknown, + delta: vec2(0.0, -1000.0), + phase: egui::TouchPhase::Move, + modifiers: Default::default(), + }, + ] + }; + ui.frames(20, wheel); + ui.frames(60, Vec::new); + // The full-window player's area, under its bar. + let area = Rect::from_min_max(pos2(0.0, 40.0), pos2(1440.0, 900.0)); + let l = layout(ui.app.ui.present.as_mut().unwrap(), area, FULL).unwrap(); + let on_screen = |id| l.place.rect(l.disp.world_bounds(id).unwrap()); + assert!(on_screen(page).min.y < area.min.y - 3000.0, "scrolled to the end of the page: {:?}", on_screen(page)); + assert!((on_screen(header).min.y - area.min.y).abs() < 1.0, "the fixed header stays at the window's top: {:?}", on_screen(header)); + assert!((on_screen(sticky).min.y - area.min.y).abs() < 1.0, "the sticky bar holds at the window's top: {:?}", on_screen(sticky)); +} diff --git a/docs/prototyping-parity.md b/docs/prototyping-parity.md index e56ab3d67..0ea6a5c18 100644 --- a/docs/prototyping-parity.md +++ b/docs/prototyping-parity.md @@ -1,6 +1,6 @@ # Prototyping parity -> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-19 · **Change:** patch (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-11-19 · **Change:** patch (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, @@ -73,7 +73,7 @@ tool; opt-in), **silent** (the documentation doesn't say; the case pins the curr | Easing curves: linear, ease in, ease out, ease in and out, back variants, custom bezier | pass | `easing_curves_and_springs` | | Spring presets are physical springs (mass 1; stiffness / damping: gentle 100/15, quick 300/20, bouncy 600/15, slow 80/20) | **fixed** | they were ad-hoc curves | | A spring plays until it settles: its duration follows from its mass, stiffness and damping, not from the duration field | **fixed** | it was squeezed into the duration field's time; the editor shows the spring's duration in place of the field; `springs_play_until_they_settle` | -| Scrolling: horizontal, vertical or both; momentum; fixed layers stay put; sticky layers stop at the edge | pass | `scroll_offsets_fixed_and_sticky`, `present_view_tests` (sticky on the left edge too: silent) | +| Scrolling: horizontal, vertical or both; momentum; fixed layers stay put; sticky layers stop at the edge | pass | `scroll_offsets_fixed_and_sticky`, `present_view_tests` (sticky on the left edge too: silent); without a device the window is the screen of a frame with fixed or sticky layers (`without_a_device_fixed_and_sticky_layers_keep_to_the_window_to_the_end_of_the_page`, #2430) | | Fixed layers draw and take clicks above the content scrolling under them, wherever they are in the layer list | **fixed** | they drew in layer order, under later layers; the file's order doesn't change; `fixed_layers_stay_above_the_content_that_scrolls` | | Flows and starting points; device frames; presentation options; hotspot hints | pass | `proto_present_tests`, `present_view_tests`, `present_tests` | @@ -111,6 +111,7 @@ tool; opt-in), **silent** (the documentation doesn't say; the case pins the curr | 2026-11-07 | patch | M8, #2015: dragging a prototype connection near the canvas edge pans the view, as measured in Figma: while a drag holds the pointer within about 15 px of the edge (or past it) the view pans toward it at 40 px/s for each px closer, up to 600 px/s at the edge, steadily while the pointer stays still; moving layers, the selection box, drawing a shape and dragging a prototype connection (a link can now reach a frame off screen). Resizing, rotating and other drags don't pan. Tests: `view_autopan_tests`, `canvas_autopan_tests`, `proto_canvas::tests`. | | 2026-11-14 | patch | M5, #2352: a chain of variant changes on After delay plays to the end (A to B to C to D); before, the step a variant had fired stayed marked as fired when the instance changed variant, so the chain stopped after one step, and now each step's delay counts from when its variant appears (`crates/ui-egui/src/present/afterdelay_chain_tests.rs`). Numbers unchanged | | 2026-11-09 | patch | M7, #2158: a connection dragged from a variant (or a layer in it) onto a sibling variant of its set did nothing, because the drop looked only for top-level frames and a variant's top-level frame is its set. It now creates Change to the sibling (On click, Instant, as measured in Figma's web app) and outlines the sibling while dragging; the set's background and the variant itself still add nothing, and a frame outside the set still gets Navigate to | +| 2026-11-19 | patch | M5, #2430: without a device, a frame taller than the window scrolled its own content and then panned whole through the window, so a fixed header and sticky layers left the top once the frame's scroll ran out. A frame with fixed or sticky layers now takes the window as its screen, as a device's screen is: it scrolls through its whole height there, fixed layers keep to the window (bottom constraints to its bottom) and sticky ones hold at its top. Frames without them still pan as one picture, drawn once. | | 2026-11-10 | patch | M7, #2209: the presenter's comment mode showed the frame's pins but nothing started a comment. Measured in Figma's web app: with the mode on (C or the bar's comment button) a click on the presented frame drops a pin at the click and opens an "Add a comment" composer beside it; Enter posts, the pin stays at the same frame-relative spot and the mode stays on; a click on the background does nothing; Escape closes a composer, and with none open turns the mode off; the comment shows on the frame in the editor. Now the same: the click starts the draft at the point mapped back through the presenter's placement, the editor's composer is shared, the post carries the frame's page, the player ignores the pointer while the mode is on (no click interactions or hotspots fire), and Escape closes the draft, then the mode. Tests: `comments_tests::a_click_in_the_presenters_comment_mode_adds_a_comment_on_the_frame` and four more. | | 2026-11-09 | patch | M5, #2127: presenting a frame taller than about 2900 units at 1440 wide on a 2x display (Fit width, or 100%) drew it blurry: the whole frame is rasterised once, capped at 16.8 million pixels (a 1440 by 9701 frame at 1.1 pixels a unit, 1579 by 10632), and stretched up 1.8 times with linear filtering, while the canvas, which renders only what is in view, stayed sharp. Now the part in view plus a quarter of its size each way is drawn again over that texture from one more at the full pixel scale (never past the GPU's side or the same pixel cap), rendered when it stops covering the view and not while a fling, drag or the wheel moves it (while the view moves, a detail is drawn only while it covers the whole view: past it the capped texture shows alone, with no sharp edge across the view, until the view settles); transitions, smart animate, overlays and thumbnails keep the capped texture. Tests: `present::tests::tall_frame_detail_plan_renders_the_view_at_device_scale`, `presenting_a_tall_frame_on_a_hidpi_display_draws_the_view_at_device_scale`. Numbers unchanged | | 2026-11-06 | patch | M5, #2027: `proto.settings` took any string as the device (`"Pixel Nonexistent"`, `"iphone 16"`) and saved it in the file; the presenter then drew no device while its picker showed the name as if it were one, and the settings couldn't be read back over MCP (`proto.settings {}` answered `{ok: true}`). An unknown name (or a non-string) is now refused with every name the picker offers (`None`, `Custom size` and the devices), as an unknown colour is refused with the device's colours, and nothing changes; a known name is taken in any case and stored as the picker spells it. Every call answers the page's settings after it: device, background, rotation, the colour shown, the screen as presented, the custom size and responsive. Test: `proto_present_tests::unknown_devices_are_refused_and_settings_read_back` |