From 799861166356e2039952daee09b4c6245d9e1ced Mon Sep 17 00:00:00 2001 From: mocenigo Date: Mon, 23 Nov 2026 19:44:49 +0100 Subject: [PATCH 01/56] pages: no horizontal scroll bar while the pages fit the view's width The view can't scroll sideways then (the offset is clamped to one value), so the bar only showed a thumb filling its track. It comes back when a zoom makes the pages wider. --- crates/pages/src/ui/view.rs | 2 ++ crates/pages/tests/it/views.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/pages/src/ui/view.rs b/crates/pages/src/ui/view.rs index 59bb088272..e8aee62986 100644 --- a/crates/pages/src/ui/view.rs +++ b/crates/pages/src/ui/view.rs @@ -912,6 +912,8 @@ fn run_pass(ui: &mut Ui, cx: &mut BodyCx<'_>, held: &mut Held<'_, PageViewState> let document = drawn_frame.document(&drawn); let (xs, ys) = (offset_range(geo.doc.x0, geo.doc.x1, vw), offset_range(geo.doc.y0, geo.doc.y1, vh)); let bars = CanvasScrollbars::new(words.scroll_bars.clone(), Bind::given(shown), DocRect::from_origin_size(Point::ZERO, document)); + // Pages that fit the view's width can't scroll sideways, so there is no horizontal bar. + let bars = if xs.0 >= xs.1 { bars.vertical_only() } else { bars }; // The tip names the page at the top of the view the thumb moved to: the bars ask for it once they know the move. let format = env.format(); let tip = |moved: &CanvasView| { diff --git a/crates/pages/tests/it/views.rs b/crates/pages/tests/it/views.rs index 8a8f04cd68..ccc69519ef 100644 --- a/crates/pages/tests/it/views.rs +++ b/crates/pages/tests/it/views.rs @@ -49,6 +49,24 @@ fn layout_rig(count: usize, start: PageViewState) -> LayoutRig { (fixture, state, rects) } +/// Whether the view shows a horizontal scroll bar at `zoom` in a window 900 wide. +fn has_horizontal_bar(zoom: f64) -> bool { + let (fixture, _, _) = layout_rig( + 3, + state_with(|s| { + s.fit = Fit::None; + s.zoom = zoom; + }), + ); + fixture.by_role(Role::SCROLL_BAR).iter().any(|bar| bar.rect.width() > bar.rect.height()) +} + +#[trial] +fn the_horizontal_bar_shows_only_when_the_pages_are_wider_than_the_view() { + assert!(!has_horizontal_bar(0.5), "pages that fit the width need no horizontal bar"); + assert!(has_horizontal_bar(3.0), "pages wider than the view scroll sideways"); +} + #[trial] fn a_changed_zoom_keeps_the_page_at_the_top_in_place() { let (mut fixture, state, rects) = layout_rig( From e3385de040ea7cc7418d9eb9e47bee13c13c21a4 Mon Sep 17 00:00:00 2001 From: batistalucasv Date: Mon, 23 Nov 2026 23:37:10 -0300 Subject: [PATCH 02/56] font-manager: use filled warning triangle icon in FontPicker (storytold/wordcraft#7684) --- crates/font-manager/src/picker.rs | 2 +- crates/font-manager/tests/it/picker.rs | 58 +++++++++++++++++++ crates/ui-contract/icons/ATTRIBUTION.md | 2 +- crates/ui-contract/icons/icons.toml | 5 ++ .../icons/phosphor/warning-filled.svg | 1 + 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 crates/ui-contract/icons/phosphor/warning-filled.svg diff --git a/crates/font-manager/src/picker.rs b/crates/font-manager/src/picker.rs index 887faf69c5..ee4dc64442 100644 --- a/crates/font-manager/src/picker.rs +++ b/crates/font-manager/src/picker.rs @@ -531,7 +531,7 @@ const TEXT: PartKey = PartKey::new("text"); const CHEVRON: PartKey = PartKey::new("chevron"); /// The mark before the chevron of a shown font that is not installed; its tooltip is the note. const WARNING: PartKey = PartKey::new("missing"); -const WARNING_ICON: &str = "warning"; +const WARNING_ICON: &str = "warning_filled"; /// The popup the chevron and Alt+Down toggle. const POPUP: &str = "list"; /// The Show Similar part at the end of a family row, in the `Chips` layout. diff --git a/crates/font-manager/tests/it/picker.rs b/crates/font-manager/tests/it/picker.rs index 5b1f60c26b..583d16830c 100644 --- a/crates/font-manager/tests/it/picker.rs +++ b/crates/font-manager/tests/it/picker.rs @@ -798,6 +798,64 @@ fn the_missing_font_warning_icon_paints_in_status_warn_fg_and_dims_when_disabled ); } +/// Texture ids of textured meshes whose centre falls inside `rect`. +fn mesh_textures(shapes: &[egui::Shape], rect: egui::Rect, out: &mut Vec) { + for shape in shapes { + match shape { + egui::Shape::Vec(inner) => mesh_textures(inner, rect, out), + egui::Shape::Mesh(mesh) if rect.contains(mesh.calc_bounds().center()) => { + out.push(mesh.texture_id); + } + _ => {} + } + } +} + +#[trial] +fn the_missing_font_warning_icon_is_a_filled_triangle() { + use std::cell::Cell; + + let catalog = catalog_of(&[INTER_REGULAR]); + let seen = Rc::new(Cell::new(None)); + let held = Rc::clone(&seen); + let mut family = "Gotham".to_owned(); + let mut fx = Fixture::new(move |ui| { + let out = FontPicker::new("Font family", Bind::bound(&mut family), &catalog).kind(FontPickerKind::Plain).shown_as("Inter").show(ui); + held.set(Some(out.edit.response.id)); + }); + fx.pixels_per_point(2.0); + fx.record_paint(); + fx.in_room(Room::Window); + fx.settle(); + let picker = seen.get().expect("the picker"); + let mark = fx.part_rect(picker, PartKey::new("missing")).expect("the field carries a mark while the family is not installed"); + let mut paint = fx.take_paint().expect("recorded paint output"); + let mut textures = Vec::new(); + for clipped in &paint.shapes { + mesh_textures(std::slice::from_ref(&clipped.shape), mark, &mut textures); + } + let texture = *textures.first().expect("the missing-font warning icon paints a texture"); + let image = paint + .textures_delta + .set + .get(&texture) + .and_then(|deltas| deltas.last()) + .map(|delta| match &delta.image { + egui::ImageData::Color(color) => color, + }) + .expect("the warning icon texture was uploaded"); + let [w, h] = image.size; + let alpha = |fx: f32, fy: f32| { + let x = ((w as f32 * fx) as usize).min(w - 1); + let y = ((h as f32 * fy) as usize).min(h - 1); + image.pixels[y * w + x].a() + }; + let (left, right, center) = (alpha(0.34, 0.69), alpha(0.66, 0.69), alpha(0.50, 0.48)); + paint.textures_delta.clear(); + assert!(left > 128 && right > 128, "the triangle interior is filled, not an outline (left={left}, right={right}, size={w}x{h})"); + assert!(center < 128, "the exclamation stem stays knocked out inside the filled triangle (center={center})"); +} + /// The library picker's family and settings, as the last pass left them. struct Library { family: String, diff --git a/crates/ui-contract/icons/ATTRIBUTION.md b/crates/ui-contract/icons/ATTRIBUTION.md index 4579d05c91..7baac2bd35 100644 --- a/crates/ui-contract/icons/ATTRIBUTION.md +++ b/crates/ui-contract/icons/ATTRIBUTION.md @@ -11,7 +11,7 @@ Each folder holds only the files `icons.toml` lists, unchanged from the pinned s Carbon's licence file is the repository's root `LICENSE` (the icons package has none of its own). -Every set folder's files come from the npm package of the version in the table (`@phosphor-icons/core` 2.0.8, `lucide-static` 1.63.0, `@carbon/icons` 11.91.0, `@tabler/icons` 3.50.0), the same releases as the tags above. Phosphor files are `regular` weight, except `star-filled.svg` and `circle-filled.svg`, which are Phosphor's `fill` weight (`star-fill.svg`, `circle-fill.svg`). `panel-left.svg` is Phosphor's `sidebar-simple` unchanged, and `panel-right.svg` is the same glyph mirrored. +Every set folder's files come from the npm package of the version in the table (`@phosphor-icons/core` 2.0.8, `lucide-static` 1.63.0, `@carbon/icons` 11.91.0, `@tabler/icons` 3.50.0), the same releases as the tags above. Phosphor files are `regular` weight, except `star-filled.svg`, `circle-filled.svg` and `warning-filled.svg`, which are Phosphor's `fill` weight (`star-fill.svg`, `circle-fill.svg`, `warning-fill.svg`). `panel-left.svg` is Phosphor's `sidebar-simple` unchanged, and `panel-right.svg` is the same glyph mirrored. `phosphor/` also holds drawings made for the suite, for glyphs the pinned Phosphor release lacks. They follow Phosphor's regular style (256 view box, 16-unit round-capped strokes, some converted to filled outlines), take their shapes from PhotoCraft's glyphs, and carry the suite's own licence: diff --git a/crates/ui-contract/icons/icons.toml b/crates/ui-contract/icons/icons.toml index 2a324cd10a..7fdd9233c7 100644 --- a/crates/ui-contract/icons/icons.toml +++ b/crates/ui-contract/icons/icons.toml @@ -454,6 +454,11 @@ phosphor = "warning" carbon = "warning--alt" tabler = "alert-triangle" +[[icon]] +name = "warning_filled" +directional = false +phosphor = "warning-filled" + [[icon]] name = "web_colors" directional = false diff --git a/crates/ui-contract/icons/phosphor/warning-filled.svg b/crates/ui-contract/icons/phosphor/warning-filled.svg new file mode 100644 index 0000000000..f8ada0ad27 --- /dev/null +++ b/crates/ui-contract/icons/phosphor/warning-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file From e7e8785fff8ba5aebd8e349bff6806639fde64a2 Mon Sep 17 00:00:00 2001 From: mocenigo Date: Tue, 24 Nov 2026 12:33:11 +0100 Subject: [PATCH 03/56] ui-canvas: a held horizontal thumb keeps its bar until the press ends With vertical_only set while the thumb drags (the page view's pages came to fit the width mid-drag), the bar went and its release never reached it: the drag's edit stayed open and the held extent stayed in the press slot. --- crates/pages/tests/it/views.rs | 25 +++++++++++++++++++ crates/ui-canvas/src/canvas/scrollbars/mod.rs | 4 ++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/crates/pages/tests/it/views.rs b/crates/pages/tests/it/views.rs index 3028d4fd7c..0042c27937 100644 --- a/crates/pages/tests/it/views.rs +++ b/crates/pages/tests/it/views.rs @@ -433,6 +433,31 @@ fn assert_centre_kept(out: &Out, before: (usize, kurbo::Point), what: &str) { /// A written zoom keeps the point at the centre; a new room (a panel opened beside the view) refits and keeps the /// current page's top where it was, as production did. +/// The horizontal scroll bar the fixture shows, if any. +fn horizontal_bar(fixture: &Fixture) -> Option { + fixture.by_role(Role::SCROLL_BAR).iter().map(|bar| bar.rect).find(|rect| rect.width() > rect.height()) +} + +#[trial] +fn a_horizontal_thumb_held_while_the_pages_come_to_fit_keeps_its_bar_until_the_release() { + let (mut fixture, state, _) = layout_rig( + 3, + state_with(|s| { + s.fit = Fit::None; + s.zoom = 3.0; + }), + ); + let bar = horizontal_bar(&fixture).expect("pages wider than the view have a horizontal bar"); + // The view starts at the left edge, so the thumb is at the start of the track. + let from = pos2(bar.left() + 4.0, bar.center().y); + fixture.drag_hold_at(from, vec2(20.0, 0.0)); + state.borrow_mut().zoom = 0.5; + fixture.idle(3); + assert!(horizontal_bar(&fixture).is_some(), "the held thumb keeps its bar, so its release reaches it"); + fixture.release_at(from + vec2(20.0, 0.0)).idle(2); + assert!(horizontal_bar(&fixture).is_none(), "after the release, pages that fit have no horizontal bar"); +} + #[trial] fn a_changed_zoom_keeps_the_point_at_the_centre_and_a_new_room_the_current_pages_top() { // The app's zoom. diff --git a/crates/ui-canvas/src/canvas/scrollbars/mod.rs b/crates/ui-canvas/src/canvas/scrollbars/mod.rs index f0d190d33b..d8a0f97d21 100644 --- a/crates/ui-canvas/src/canvas/scrollbars/mod.rs +++ b/crates/ui-canvas/src/canvas/scrollbars/mod.rs @@ -477,7 +477,9 @@ impl<'a> CanvasScrollbars<'a> { } fn bars(&self, view: &CanvasView, rect: Rect, style: &ScrollbarsStyle, held: Option<&HeldThumb>) -> Bars { - Bars::of(view, self.document, self.overscroll, !self.vertical_only, rect, style, held) + // A horizontal thumb held keeps its bar until the press ends, so its release closes the drag. + let horizontal = !self.vertical_only || held.is_some_and(|held| held.on(Axis::X)); + Bars::of(view, self.document, self.overscroll, horizontal, rect, style, held) } } From 1d8dc6c2b3f0689b168a294b70a413e52601f2cf Mon Sep 17 00:00:00 2001 From: batistalucasv Date: Tue, 24 Nov 2026 11:42:10 -0300 Subject: [PATCH 04/56] ci: retest flaky automation test From 3709418d5f1a50a79f7c0f42fa34f56397eb5d8a Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 21:35:30 +0000 Subject: [PATCH 05/56] Keys: an app's own focused widget keeps the plain Enter While an app's own egui widget or popup has the focus, a plain Enter stays in egui's input for it and no window Submit comes of it, as with Tab and Escape. The window's Submit was offered beside the press, so an app editor read one Enter and an app that returns the window's Submit to egui read two; an app TextEdit in a framework dialog also fired the dialog's default button. With nothing focused the plain Enter stays the window's Submit and in egui's input. --- crates/ui-contract/src/runtime/focus.rs | 3 +- crates/ui-contract/src/runtime/keys/input.rs | 7 ++-- .../src/testing/host_key_trials.rs | 35 +++++++++++++++++++ docs/craft-framework.md | 2 +- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index a75ce8ea63..696f74b9e1 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -97,7 +97,8 @@ pub(crate) struct FocusedRecord { pub(crate) canvas: Option, /// egui focus is on a widget no framework component made, or an egui popup is open, and no framework press or /// drag is captured: an app's own focused widget or popup keeps the keys a focused component keeps (Tab, Escape, - /// the clipboard events). Written by the end hook after its focus moves. + /// the plain Enter, the clipboard events), and no window intent comes of them. Written by the end hook after its + /// focus moves. pub(crate) foreign: bool, /// egui focus is on a widget no framework component made, and no framework press or drag is captured: egui /// moves focus among the app's own widgets with the arrows and the Tab it keeps. Written by the end hook. diff --git a/crates/ui-contract/src/runtime/keys/input.rs b/crates/ui-contract/src/runtime/keys/input.rs index db3f8a9496..26cc8794f3 100644 --- a/crates/ui-contract/src/runtime/keys/input.rs +++ b/crates/ui-contract/src/runtime/keys/input.rs @@ -42,8 +42,8 @@ struct Strip<'a> { holds_drafts: bool, /// A dialog keeps a canvas open and Space belongs to it: the press is the canvas's momentary command chord. canvas_space: bool, - /// An app's own egui widget or popup has the focus (`FocusedRecord::foreign`): Tab, Escape and the clipboard - /// events are its own. + /// An app's own egui widget or popup has the focus (`FocusedRecord::foreign`): Tab, Escape, the plain Enter and the + /// clipboard events are its own, and no window intent comes of them. foreign: bool, /// The focused stop is the app's own egui widget (`Stop::host`, `FocusedRecord::host`), which reads its keys from /// egui: its Escape stays there, as an app's own focused widget's does. Tab and the arrows follow its `KeyUse`, as @@ -348,6 +348,7 @@ impl Strip<'_> { let ctrl_tab = key == Key::Tab && (if self.os == Os::Mac { mods.ctrl && !mods.cmd } else { mods.cmd }); let ctrl_tab = ctrl_tab && self.pages && !self.keeps_tab; let bare_tab = key == Key::Tab && !mods.cmd && !mods.ctrl && !mods.alt; + let plain_enter = key == Key::Enter && mods.is_none(); // Alt and Shift ride along, as with Enter: a canvas tool reads them; Cmd and Ctrl chords are the app's. While // the focused stop records, Escape with any modifier held is a chord for the recorder; only plain Escape is a // scope escape. Over an open press any Escape is the press's cancel: a borrowed tool's drag holds Cmd. Shift or @@ -379,7 +380,7 @@ impl Strip<'_> { PressUse::Edit(*command) } else if key == Key::Space && self.canvas_space { PressUse::CanvasSpace - } else if (self.foreign && (bare_tab || escape)) || (self.host && escape && !self.press_captured) || canvas_tab || egui_edit { + } else if (self.foreign && (bare_tab || escape || plain_enter)) || (self.host && escape && !self.press_captured) || canvas_tab || egui_edit { PressUse::Egui } else if bare_tab && self.egui_tab && !self.keeps_tab { PressUse::TabToEgui diff --git a/crates/ui-contract/src/testing/host_key_trials.rs b/crates/ui-contract/src/testing/host_key_trials.rs index 71f62c579b..a6bb427c03 100644 --- a/crates/ui-contract/src/testing/host_key_trials.rs +++ b/crates/ui-contract/src/testing/host_key_trials.rs @@ -236,6 +236,41 @@ fn a_focused_egui_field_keeps_tab_escape_and_the_clipboard() { assert_eq!(seen(&host), (vec![Key::Escape], 0), "the field's Escape is egui's, and no window Cancel"); } +/// The Enter presses in egui's input and the window Submits taken after one Enter, with the host's field focused or +/// nothing focused. +fn enter_with(field_focused: bool) -> (usize, usize) { + let counts = Rc::new(Cell::new((0usize, 0usize))); + let counted = Rc::clone(&counts); + let (_host, mut base) = host_window(); + let mut show = move |ui: &mut Ui| { + let enters = ui.input(|input| input.events.iter().filter(|event| matches!(event, Event::Key { key: Key::Enter, pressed: true, .. })).count()); + let submit = with_window_intents(ui.ctx(), false, |intents| intents.take(Intent::Submit)); + let (seen, taken) = counted.get(); + counted.set((seen + enters, taken + usize::from(submit))); + base(ui); + }; + let mut frames = Frames::new(); + frames.frame(Vec::new(), &mut show); + if field_focused { + fixture::host_focus(&frames.ctx, field()); + frames.frame(Vec::new(), &mut show); + assert_eq!(egui_focused(&frames.ctx), Some(field()), "the host's field holds egui focus"); + } + counts.set((0, 0)); + press_key(&mut frames, &mut show, Key::Enter); + frames.idle(2, &mut show); + counts.get() +} + +/// An app's own focused widget keeps the plain Enter as it keeps Escape: it reads it from egui once, and no window +/// Submit comes of it, so an app that turns the window's Submit back into an Enter does not get two. With nothing +/// focused the plain Enter is the window's Submit and stays in egui's input too. +#[trial] +fn a_focused_egui_field_keeps_enter_and_the_window_gets_no_submit() { + assert_eq!(enter_with(true), (1, 0), "the field reads one Enter and the window takes no Submit"); + assert_eq!(enter_with(false), (1, 1), "with nothing focused, Enter is the window's Submit and stays in egui"); +} + #[trial] fn an_open_egui_popup_keeps_escape() { let popup = named_id("host popup"); diff --git a/docs/craft-framework.md b/docs/craft-framework.md index a717ace9ad..0b7dd03f76 100644 --- a/docs/craft-framework.md +++ b/docs/craft-framework.md @@ -169,7 +169,7 @@ An app with its own eframe `App` calls the hooks in `craft::ui::shell::embed`. ` | App modals | A modal the app draws with its own egui code blocks nothing outside egui by itself. While one shows, the app names its window each frame with `FrameInput::app_modal(Some(viewport))`: the app's other windows, panels floated into windows of their own among them, are then blocked as under a framework app-modal layer (their presses, keys, wheel and text are dropped, a press there brings the modal's window forward, and they refuse to close). | | Input pacing | One press per pass: extra presses in one frame wait for the next passes. A press outside an open framework menu closes the menu and goes no further. After an OS resize of the window, the held pointer is released. | -The window's keys are the ones the runtime routes to no component: an Escape or a plain Enter while no framework stop is focused, and the arrows' nudge. `with_window_intents` offers them to its closure while nothing has framework focus. The closure takes what it handles (`Intents::take(Intent::Cancel)`; `Intent` and the other types `Intents` reads are in `ui::runtime::keys`) and returns whether it took anything; the rest stays for later readers. A framework scope that ran earlier in the pass takes them first (an open dialog takes the Escape that closes it), so the app reads them last in its UI to see what no component took. App code that read `Key::Escape`, `Key::Tab`, F6 or F10 from egui while none of its own widgets had focus reads these intents and `FrameOutput::chrome_toggles` instead; its own focused widgets and popups keep reading Tab and Escape from egui. +The window's keys are the ones the runtime routes to no component: an Escape or a plain Enter while nothing has the focus, neither a framework stop nor one of the app's own widgets or popups, and the arrows' nudge. The window's plain Enter also stays in egui's input. `with_window_intents` offers them to its closure while nothing has framework focus. The closure takes what it handles (`Intents::take(Intent::Cancel)`; `Intent` and the other types `Intents` reads are in `ui::runtime::keys`) and returns whether it took anything; the rest stays for later readers. A framework scope that ran earlier in the pass takes them first (an open dialog takes the Escape that closes it), so the app reads them last in its UI to see what no component took. App code that read `Key::Escape`, `Key::Tab`, F6 or F10 from egui while none of its own widgets had focus reads these intents and `FrameOutput::chrome_toggles` instead; its own focused widgets and popups keep reading Tab, Escape and the plain Enter from egui, and no window intent comes of them. Framework dialogs the app keeps as values run on a `DialogHost`: the app calls `run(ui)` once per pass after its own UI and reads results with `take`. From b2cd66151015d68d34b8cf5c5db7813dd344eb7f Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 21:39:59 +0000 Subject: [PATCH 06/56] Focus: host_stop puts an app's own widgets into the one Tab order focus::host_stop registers an app's own egui widget as a focus stop (Stop::host, as host_canvas does, without marking a document canvas), so a window that has framework stops and the app's own widgets keeps one framework Tab order holding both, in registration order. A canvas keeps Tab only while it has the focus. With nothing focused a bare Tab moves focus into the window or toggles the panels, even for a canvas that keeps Tab, as the unfocused canvas's claims already never take Tab: the canvas cannot trap keyboard navigation. The last assertion of a_host_canvas_marks_the_window_and_tab_toggles_its_panels changes to this rule: with nothing focused, the Tab toggles the panels instead of reaching the canvas in egui. The unused Strip::canvas field goes with the old rule. --- crates/ui-contract/src/runtime/focus.rs | 29 +++++++++---- crates/ui-contract/src/runtime/keys/input.rs | 10 +---- .../src/testing/host_key_trials.rs | 41 +++++++++++++++++-- docs/contract-api.md | 1 + docs/craft-framework.md | 3 +- 5 files changed, 64 insertions(+), 20 deletions(-) diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 696f74b9e1..7b61bf93b5 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -244,15 +244,27 @@ pub(crate) fn register_stop(ctx: &Context, stop: Stop) { /// route as `keys` says (the arrows as nudges, Tab moving focus on or toggling the panels unless it keeps Tab). `keys` /// is `KeyUse::CANVAS`, or a variant such as `KeyUse::CANVAS.with_keep(KeepKeys::Tab).with_edits(..)` while Tab and the /// clipboard are the canvas's own. The canvas reads its keys from egui: with nothing focused it is the key target, and -/// a bare Tab it keeps, the chords it claims (`KeyUse::with_claims`; Alt+numpad code entry leaves a claimed Alt+digit -/// alone), and the clipboard events and edit chords of its edit set stay in egui's input for the app, and nothing -/// toggles or fires with them; Page Up and Down, Home and End arrive as its `Intent::Move`, as while it has the focus. -/// With the canvas focused, the same keys stay in egui, and Escape too, as for any focused widget of the app's own; -/// Escape with nothing focused is the window's cancel. Call it each pass the canvas shows. +/// the chords it claims (`KeyUse::with_claims`; Alt+numpad code entry leaves a claimed Alt+digit alone) and the +/// clipboard events and edit chords of its edit set stay in egui's input for the app, and nothing toggles or fires with +/// them; Page Up and Down, Home and End arrive as its `Intent::Move`, as while it has the focus. A bare Tab with nothing +/// focused is never the canvas's, even when it keeps Tab: it moves focus into the window or toggles the panels, so the +/// canvas cannot trap keyboard navigation. With the canvas focused, the same keys stay in egui, a Tab it keeps and +/// Escape too, as for any focused widget of the app's own; Escape with nothing focused is the window's cancel. Call it +/// each pass the canvas shows. pub fn host_canvas(ctx: &Context, id: Id, keys: KeyUse) { register_stop(ctx, Stop::new(id, keys.with_chrome_key(true)).host()); } +/// Registers the app's own egui widget `id`, drawn in the running pass, as a focus stop with `keys`, in the window's one +/// Tab order: Tab and F6 reach it among the framework's stops in the order the pass registers them, so call it where +/// the widget is drawn, each pass it shows. The widget must take egui focus under `id`. While it has the focus it reads +/// its keys from egui as any focused widget of the app's own does (Escape, Enter, the keys `keys` keeps, and its +/// claims), and Tab moves on from it as `keys` says. It never marks the window as showing a document: the document +/// canvas registers with [`host_canvas`]. +pub fn host_stop(ctx: &Context, id: Id, keys: KeyUse) { + register_stop(ctx, Stop::new(id, keys.with_chrome_key(false)).host()); +} + /// The stop of the document canvas `viewport` registered in its last pass (`KeyUse::chrome_key`), framework or the /// app's own (`Stop::host`). Read before the begin hook rotates the registrations, by the input hook and the begin /// hook's Tab moves. @@ -279,9 +291,10 @@ pub(crate) fn is_canvas_member(ctx: &Context, rec: &StopRec) -> bool { } /// Whether a bare Tab in `viewport` is egui's own focus move: the window registered no framework stop in its last pass, -/// only stops of the app's own egui widgets (`Stop::host`) if any, which egui's Tab order holds with the app's other -/// widgets; and egui held no focus at the end of that pass, or held it on one of those stops. A framework move would -/// reach the host stops alone. Read by the input hook, before the begin hook rotates the registrations. +/// only stops of the app's own egui widgets (`Stop::host`: `host_canvas`, `host_stop`) if any, which egui's Tab order +/// holds with the app's other widgets; and egui held no focus at the end of that pass, or held it on one of those +/// stops. A framework move would reach the host stops alone. With a framework stop in the window, Tab is the +/// framework's move over its one order, which holds the host stops beside the framework's. Read by the input hook, before the begin hook rotates the registrations. pub(crate) fn tab_is_egui_s(ctx: &Context, viewport: ViewportId) -> bool { with_viewport(ctx, viewport, |state| { state.stops.iter().all(|rec| rec.stop.host) && state.focus_now.is_none_or(|id| state.stops.iter().any(|rec| rec.stop.root == id)) diff --git a/crates/ui-contract/src/runtime/keys/input.rs b/crates/ui-contract/src/runtime/keys/input.rs index 26cc8794f3..ce2d66f9b3 100644 --- a/crates/ui-contract/src/runtime/keys/input.rs +++ b/crates/ui-contract/src/runtime/keys/input.rs @@ -49,12 +49,8 @@ struct Strip<'a> { /// egui: its Escape stays there, as an app's own focused widget's does. Tab and the arrows follow its `KeyUse`, as /// the framework's navigation reads it. host: bool, - /// The keys of the window's canvas while nothing has the focus, neither a framework stop nor an app's own widget - /// or popup: the canvas is then the key target, as the chrome gate takes it, and reads from egui the keys its - /// `KeyUse` keeps (Tab with `KeepKeys::Tab`). - canvas: Option, /// The edit set whose clipboard events and edit chords stay in egui's input: the focused stop's when it is the - /// app's own widget (`host`), else the canvas's with nothing focused (`canvas`). + /// app's own widget (`host`), else the window canvas's with nothing focused (`target_canvas`). egui_edits: EditSet, /// A bare Tab that the focus does not keep is egui's own move (`focus::tab_is_egui_s`): the window registered no /// framework stop in its last pass, only the app's own widgets' (`Stop::host`) if any, and nothing has the focus or @@ -367,7 +363,6 @@ impl Strip<'_> { let edit = self.edit_chords.iter().find(|(command, chord)| (self.edits)(*command) && self.layout.matches(chord, input, self.os)); let egui_edit = self.edit_chords.iter().any(|(command, chord)| self.egui_edits.contains(*command) && self.layout.matches(chord, input, self.os)); - let canvas_tab = bare_tab && self.canvas.is_some_and(|canvas| canvas.keep == focus::KeepKeys::Tab); // The chrome keys are Tab's, which the bare-Tab arm and `take_nav` read. let window_shortcut = self .window_shortcuts @@ -380,7 +375,7 @@ impl Strip<'_> { PressUse::Edit(*command) } else if key == Key::Space && self.canvas_space { PressUse::CanvasSpace - } else if (self.foreign && (bare_tab || escape || plain_enter)) || (self.host && escape && !self.press_captured) || canvas_tab || egui_edit { + } else if (self.foreign && (bare_tab || escape || plain_enter)) || (self.host && escape && !self.press_captured) || egui_edit { PressUse::Egui } else if bare_tab && self.egui_tab && !self.keeps_tab { PressUse::TabToEgui @@ -705,7 +700,6 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec) }`. The shape the focus ring takes around a part. - `craft_ui::runtime::focus::has`: `pub fn has(ctx: &Context, id: Id) -> bool`. Whether focus is on the component `id` or on one of its parts (a canvas's editor part), from the focus record of - `craft_ui::runtime::focus::host_canvas`: `pub fn host_canvas(ctx: &Context, id: Id, keys: KeyUse)`. Registers the app's own egui widget `id`, drawn in the running pass, as its window's document canvas: a focus stop +- `craft_ui::runtime::focus::host_stop`: `pub fn host_stop(ctx: &Context, id: Id, keys: KeyUse)`. Registers the app's own egui widget `id`, drawn in the running pass, as a focus stop with `keys`, in the window's one - `craft_ui::runtime::focus::request`: `pub fn request(ctx: &Context, target: FocusTarget) -> bool`. Moves focus to `target`, leaves modality unchanged and asks the enclosing scroll owner to reveal it. Called - `craft_ui::runtime::focus::takes_letters`: `pub fn takes_letters(keys: &KeyUse) -> bool`. Whether a stop with these keys takes typed letters: a text field or a shortcut recorder. The letters a keytip or a - `craft_ui::runtime::focus::ActivateKeys`: `pub enum ActivateKeys { Neither, Enter, Space, Both }`. The keys that activate a component. diff --git a/docs/craft-framework.md b/docs/craft-framework.md index 0b7dd03f76..082fa1a60e 100644 --- a/docs/craft-framework.md +++ b/docs/craft-framework.md @@ -145,13 +145,14 @@ An app with its own eframe `App` calls the hooks in `craft::ui::shell::embed`. ` | Each frame | `logic`, after the app's own logic | `embed::logic(ctx, \|\| decision)`: the root window's close path. The closure runs only when the root window was asked to close, and returns `CloseDecision::Close` or `Hold`. | | Each pass | `ui`, before the app's UI | `embed::before_ui(ctx, frame)`: hands the runtime the root's native window (eframe's `Frame`, or any `raw_window_handle::HasWindowHandle`) on Windows, where the runtime answers the window's hit test (resize edges, the title bar's move area, snap layouts on the maximize button), and fits the root window to its monitor once. Native only; it needs no eframe feature of the facade. | | Each pass | `ui`, where the app draws its own document canvas | Optional: `ui::runtime::focus::host_canvas(ctx, id, KeyUse::CANVAS)` declares it as the window's canvas (Tab row below). | +| Each pass | `ui`, where the app draws a widget of its own that Tab should reach | Optional: `ui::runtime::focus::host_stop(ctx, id, keys)` puts it into the window's one Tab order among the framework's stops (Tab row below). | | Each pass | `ui`, last | Optional: `ui::runtime::keys::with_window_intents(ctx, rtl, \|intents\| ...)` reads the keys no component took (below). | `install` takes over these parts of the context for the whole window, not only for framework components: | What | Effect on the app's own egui code | | --- | --- | -| Tab | Bare Tab moves framework focus and never reaches egui, unless the focused framework stop keeps Tab or an app's own widget has the focus (below), or nothing has the focus in a window that registered no focus stop: egui then moves its own focus into the app's widgets. A window with stops but no Tab entry (on the Mac, where Tab reaches only text fields by default) keeps the Tab from egui, which would otherwise focus framework controls the platform's rule skips. With `RootEnv::tab_toggles_chrome`, Tab toggles the chrome in a window that shows a document canvas, with nothing focused or the canvas focused, and arrives in `FrameOutput::chrome_toggles`. The canvas is a framework canvas, or the app's own egui canvas declared each pass with `ui::runtime::focus::host_canvas`. With nothing focused, the canvas is the key target: a canvas that keeps Tab (`KeyUse::CANVAS.with_keep(KeepKeys::Tab)`) gets the press in egui's input, as when it is focused, and nothing toggles. A focused canvas whose editor part keeps Tab reads Shift+Tab as `Intent::BackTab` (`EditorInput::BackTab`); no other stop gets it as an intent, and a text field keeps Shift+Tab as a focus move. | +| Tab | Bare Tab moves framework focus and never reaches egui, unless the focused framework stop keeps Tab or an app's own widget has the focus (below), or nothing has the focus in a window that registered no focus stop: egui then moves its own focus into the app's widgets. A window with stops but no Tab entry (on the Mac, where Tab reaches only text fields by default) keeps the Tab from egui, which would otherwise focus framework controls the platform's rule skips. With `RootEnv::tab_toggles_chrome`, Tab toggles the chrome in a window that shows a document canvas, with nothing focused or the canvas focused, and arrives in `FrameOutput::chrome_toggles`. The canvas is a framework canvas, or the app's own egui canvas declared each pass with `ui::runtime::focus::host_canvas`. A canvas that keeps Tab (`KeyUse::CANVAS.with_keep(KeepKeys::Tab)`) gets the press in egui's input only while it has the focus; with nothing focused, Tab moves focus into the window or toggles the chrome, so the canvas cannot trap keyboard navigation. In a window with framework stops, the app's own widgets take part in Tab order as stops registered each pass with `host_stop`, in the order the pass registers them; a window whose stops are all the app's (`host_canvas`, `host_stop`) leaves Tab from nothing or from those stops to egui, whose order holds them with the app's other widgets. A focused canvas whose editor part keeps Tab reads Shift+Tab as `Intent::BackTab` (`EditorInput::BackTab`); no other stop gets it as an intent, and a text field keeps Shift+Tab as a focus move. | | F6 | F6 and Shift+F6 move between panes and never reach egui. They are the defaults of the commands `NavCommand::NextPane` and `NavCommand::PreviousPane` (ids `window.next_pane` and `window.previous_pane`; name them by `NavCommand::NextPane.id()` in code): a default chord that another command binds is that command's, and the overrides move or unbind them (`CommandInput::overrides`). An app whose own shortcut table keeps F6 unbinds them there. | | Escape | Plain Escape (Alt and Shift may be held) goes to the focused framework stop and its scopes; with no framework stop focused, it goes to the window as `Intent::Cancel`. A held Escape cancels once: its repeats raise no `Cancel`. It reaches egui only while an app's own widget has the focus (below). An Escape the runtime takes outside a captured framework press also ends egui's own drag in that pass, as egui's Escape does. | | F10, Alt+letter | Taken while a framework menu bar is registered: F10 (`NavCommand::FocusMenuBar`, id `window.focus_menu_bar`, bound and yielded as F6 is) focuses the bar, Alt+letter opens a menu (not on macOS) unless the keymap binds it to an enabled command, which runs instead. | From 8c2cd95de3a5c3cf5a0541300153a566c192133a Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 21:46:04 +0000 Subject: [PATCH 07/56] IME: an app editor's own reset survives the host fence A press during the app's own editor's composition interrupts it, and the engine wrote its own reset request over the one the editor wrote in the same output: the platform answered only the engine's id, so the app never got the completion its own fence waits for, and the fence (which took every IME event) dropped it anyway. The interrupt keeps a reset request the app's output already carries, and the engine waits for that one. The app's reset requests are recorded from its IME output; their completions and retirements stay in egui's input for the app, and a completion of the request the fence waits for ends the fence. Late events of the interrupted composition stay fenced, and an editor that asks for no reset is fenced by the engine's own request as before. --- .../ui-contract/src/runtime/egui/fixture.rs | 44 ++++++++++++++++++ crates/ui-contract/src/runtime/egui/ime.rs | 16 ++++--- crates/ui-contract/src/runtime/ime.rs | 46 +++++++++++++++++-- .../src/testing/host_key_trials.rs | 36 +++++++++++++++ 4 files changed, 131 insertions(+), 11 deletions(-) diff --git a/crates/ui-contract/src/runtime/egui/fixture.rs b/crates/ui-contract/src/runtime/egui/fixture.rs index 0a6f26448f..e1064759df 100644 --- a/crates/ui-contract/src/runtime/egui/fixture.rs +++ b/crates/ui-contract/src/runtime/egui/fixture.rs @@ -520,6 +520,50 @@ pub(crate) fn host_ime_editor(ui: &Ui, id: egui::Id, rect: Rect, text: &mut Stri ui.ctx().output_mut(|output| output.ime = Some(egui::output::IMEOutput::new(id, 1, egui::IMEPurpose::Normal, rect, rect))); } +/// What [`host_resetting_ime_editor`] holds between passes. +#[cfg(feature = "suite")] +#[derive(Default)] +pub(crate) struct ResettingEditor { + pub(crate) text: String, + pub(crate) composing: bool, + /// The reset the editor asked for at a press during its composition, until its completion arrives; the editor + /// takes no IME event meanwhile. + pub(crate) reset: Option, +} + +/// A host's own text editor of `id` at `rect` that fences its own interrupted composition, as EffectCraft's viewer text +/// editor does: a primary press while it composes ends the composition and asks the platform for a reset in its own IME +/// output, and the editor ignores IME events until that reset's completion. Otherwise as [`host_ime_editor`]. +#[cfg(feature = "suite")] +pub(crate) fn host_resetting_ime_editor(ui: &Ui, id: egui::Id, rect: Rect, editor: &mut ResettingEditor) { + let _ = ui.interact(rect, id, egui::Sense::click()); + for event in ui.input(|input| input.events.clone()) { + match event { + Event::ImeResetCompleted { request_id } if editor.reset == Some(request_id) => editor.reset = None, + _ if editor.reset.is_some() => {} + Event::Ime(egui::ImeEvent::Preedit { text, .. }) => editor.composing = !text.is_empty(), + Event::Ime(egui::ImeEvent::Commit(committed)) => { + editor.text.push_str(&committed); + editor.composing = false; + } + Event::Ime(egui::ImeEvent::DeleteSurrounding { before_chars, .. }) => { + for _ in 0..before_chars { + editor.text.pop(); + } + } + _ => {} + } + } + let mut ime = egui::output::IMEOutput::new(id, 1, egui::IMEPurpose::Normal, rect, rect); + if editor.composing && ui.input(|input| input.pointer.primary_pressed()) { + editor.composing = false; + editor.reset = ui.ctx().request_ime_reset(ui.ctx().viewport_id()); + ime.should_interrupt_composition = true; + ime.reset_request = editor.reset; + } + ui.ctx().output_mut(|output| output.ime = Some(ime)); +} + /// Gives the host's own egui widget `id` key focus, as the host's code does. #[cfg(feature = "suite")] pub(crate) fn host_focus(ctx: &Context, id: egui::Id) { diff --git a/crates/ui-contract/src/runtime/egui/ime.rs b/crates/ui-contract/src/runtime/egui/ime.rs index 32ee328e8c..71fd378600 100644 --- a/crates/ui-contract/src/runtime/egui/ime.rs +++ b/crates/ui-contract/src/runtime/egui/ime.rs @@ -27,14 +27,14 @@ pub(crate) enum Raw { ResetRetired(egui::ImeResetId), } -/// Removes the IME events from `events`, and the other events `drop` names, and returns the IME events in order, each -/// with its place: how many of the events left in `events` arrived before it. The key stage numbers the events it -/// reads by the same places (`keys::input_hook`), so an editor gets the two in the order they arrived. -pub(crate) fn take_events(events: &mut Vec, take: bool, drop: impl Fn(&Event) -> bool) -> Vec<(Raw, usize)> { +/// Removes the IME events `take` names from `events`, and the other events `drop` names, and returns the IME events +/// in order, each with its place: how many of the events left in `events` arrived before it. The key stage numbers the +/// events it reads by the same places (`keys::input_hook`), so an editor gets the two in the order they arrived. +pub(crate) fn take_events(events: &mut Vec, take: impl Fn(&Event) -> bool, drop: impl Fn(&Event) -> bool) -> Vec<(Raw, usize)> { let mut taken = Vec::new(); let mut kept = 0; events.retain(|Arrived { event, .. }| { - if let Some(raw) = take.then(|| raw_of(event)).flatten() { + if let Some(raw) = take(event).then(|| raw_of(event)).flatten() { taken.extend(raw.map(|raw| (raw, kept))); return false; } @@ -110,9 +110,11 @@ pub(crate) fn write(ctx: &Context, viewport: ViewportId, out: Output) -> Option< } /// Interrupts the composition of the IME output the app's own editor wrote this pass, in its context, and asks for a -/// reset. Returns the reset request it published, as `write` does. +/// reset. An editor that asked for its own reset in that output keeps its request, so the platform answers the app's +/// id and the app gets its completion. Returns the reset request the output carries, as `write` does. pub(crate) fn interrupt_written(ctx: &Context, viewport: ViewportId) -> Option { - let reset = ctx.request_ime_reset(viewport); + let written = ctx.output(|output| output.ime.as_ref().and_then(|ime| ime.reset_request)); + let reset = written.or_else(|| ctx.request_ime_reset(viewport)); ctx.output_mut(|output| { if let Some(ime) = &mut output.ime { ime.should_interrupt_composition = true; diff --git a/crates/ui-contract/src/runtime/ime.rs b/crates/ui-contract/src/runtime/ime.rs index dbb537f3eb..20c6509eed 100644 --- a/crates/ui-contract/src/runtime/ime.rs +++ b/crates/ui-contract/src/runtime/ime.rs @@ -53,6 +53,10 @@ struct Engine { editor: Option, /// The app's own editor that wrote the IME output of the last pass while no framework editor owned the IME. host: Option, + /// The reset requests the app's own editor wrote in its IME output, unanswered yet: their completions and + /// retirements are the app's and stay in egui's input for it, fence or not. One of them is the fence's `reset` + /// when the app asked for its reset in the pass the engine interrupted its composition. + host_resets: Vec, } /// An app's own editor holding the IME: the owner and context generation of the IME output it wrote, and whether it @@ -197,6 +201,20 @@ impl Engine { self.discard = true; } + /// Notes an answer to one of the app's own reset requests: the request is answered, and a completion of the one the + /// fence waits for ends the fence; a retirement leaves the end hook to ask again. + fn host_answered(&mut self, event: &Event) { + let (Event::ImeResetCompleted { request_id: id } | Event::ImeResetRetired { request_id: id }) = event else { return }; + let Some(at) = self.host_resets.iter().position(|own| own == id) else { return }; + self.host_resets.remove(at); + if self.reset == Some(*id) { + self.reset = None; + if matches!(event, Event::ImeResetCompleted { .. }) { + self.stale = false; + } + } + } + /// Follows the composition of the app's own editor through the IME events left to it in egui's input, and /// interrupts it at a pointer press, as a press ends a framework editor's composition. The one-press rule (H0) /// holds the events after the press for the next frame, where the fence drops the composition's late deletions and @@ -230,23 +248,37 @@ fn current(ctx: &Context, f: impl FnOnce(&mut Engine) -> R) -> R { /// The input hook: takes the IME events out of raw input while a framework editor owns the IME, or while the reset /// the engine asked for is pending (the late events of the interrupted composition, and the OS's answer), and removes /// the keys that would end the composition. With no framework editor, the events after the reset's completion are -/// the app's own editor's again, and the hook follows that editor's composition (`Engine::watch_host`). +/// the app's own editor's again, and the hook follows that editor's composition (`Engine::watch_host`). The answers to +/// the app's own reset requests always stay in egui's input for it; when the fence waits for one of them, its +/// completion ends the fence too. pub(crate) fn input_hook(ctx: &Context, events: &mut Vec, viewport: ViewportId) { with(ctx, viewport, |engine| { let take = engine.owner.is_some() || engine.reset.is_some(); + let host_resets = engine.host_resets.clone(); + let host_answer = |event: &Event| match event { + Event::ImeResetCompleted { request_id } | Event::ImeResetRetired { request_id } => host_resets.contains(request_id), + _ => false, + }; let completed = |id: egui::ImeResetId| move |arrived: &Arrived| matches!(arrived.event, Event::ImeResetCompleted { request_id } if request_id == id); + // The events after the completion are the app's; the completion too when it answers the app's own request. let mut after = match engine.reset { - Some(id) if engine.owner.is_none() => events.iter().position(completed(id)).map(|at| events.split_off(at + 1)), + Some(id) if engine.owner.is_none() => { + let own = host_resets.contains(&id); + events.iter().position(completed(id)).map(|at| events.split_off(if own { at } else { at + 1 })) + } _ => None, }; let guarded = engine.composing || engine.guard > 0; let ends_composition = |event: &Event| { matches!(event, Event::Key { key: Key::Enter | Key::Escape | Key::Backspace | Key::Delete | Key::Space, pressed: true, .. }) }; - let taken = os::take_events(events, take, |event| guarded && ends_composition(event)); + let taken = os::take_events(events, |event| take && !host_answer(event), |event| guarded && ends_composition(event)); engine.queue.extend(taken); engine.guard = engine.guard.saturating_sub(1); + for arrived in events.iter().chain(after.iter().flatten()) { + engine.host_answered(&arrived.event); + } if engine.owner.is_none() { match &mut after { Some(after) => engine.watch_host(after), @@ -458,7 +490,8 @@ pub(crate) fn note_caret(ctx: &Context, owner: Id, field: Rect, caret: Rect, pas pub(crate) fn end_pass(ctx: &Context) { let viewport = pass::current_viewport(ctx); let (frame_nr, pass_nr) = (ctx.cumulative_frame_nr_for(viewport), ctx.cumulative_pass_nr_for(viewport)); - let app_wrote = ctx.output(|output| output.ime.as_ref().map(|ime| (ime.owner, ime.context_generation))); + let app_ime = ctx.output(|output| output.ime.as_ref().map(|ime| (ime.owner, ime.context_generation, ime.reset_request))); + let app_wrote = app_ime.map(|(owner, generation, _)| (owner, generation)); let (owner, interrupt, caret, update, published, host) = with(ctx, viewport, |engine| { let ran = std::mem::take(&mut engine.ran); if !ran { @@ -477,6 +510,11 @@ pub(crate) fn end_pass(ctx: &Context) { let last_host = engine.host; let kept = engine.host.filter(|host| app_wrote.is_some_and(|(owner, _)| owner == host.owner)).is_some_and(|host| host.composing); engine.host = app_wrote.filter(|_| engine.owner.is_none()).map(|(owner, generation)| HostIme { owner, generation, composing: kept }); + if let Some(id) = app_ime.filter(|_| engine.owner.is_none()).and_then(|(.., reset)| reset) + && !engine.host_resets.contains(&id) + { + engine.host_resets.push(id); + } // The fence has no request the integration can answer: the owner's output asks again, a framework editor's // or the app's own. if engine.stale diff --git a/crates/ui-contract/src/testing/host_key_trials.rs b/crates/ui-contract/src/testing/host_key_trials.rs index 42e09891be..c09af46180 100644 --- a/crates/ui-contract/src/testing/host_key_trials.rs +++ b/crates/ui-contract/src/testing/host_key_trials.rs @@ -215,6 +215,42 @@ fn a_press_during_an_app_editor_s_composition_fences_its_late_ime_events() { assert_eq!(*editor.borrow(), "abX", "the commit after the completion reaches the editor"); } +/// An app editor that asks for its own reset at the press that interrupts its composition keeps that request: the +/// platform is asked to answer the app's id, the late events stay fenced, and the completion reaches the editor, which +/// takes the events after it and composes again. +#[trial] +fn an_app_editor_s_own_reset_at_the_press_reaches_it_and_it_composes_again() { + let editor = Rc::new(RefCell::new(fixture::ResettingEditor::default())); + let held = Rc::clone(&editor); + let rect = Rect::from_min_size(Pos2::new(100.0, 100.0), egui::vec2(200.0, 30.0)); + let mut show = move |ui: &mut Ui| fixture::host_resetting_ime_editor(ui, host_editor_id(), rect, &mut held.borrow_mut()); + let mut frames = Frames::new(); + frames.idle(2, &mut show); + frames.frame(vec![Event::Ime(ImeEvent::Commit("ab".to_owned()))], &mut show); + frames.frame(vec![Event::Ime(ImeEvent::Preedit { text: "z".to_owned(), active_range_chars: None })], &mut show); + let at = Pos2::new(150.0, 115.0); + let late = vec![ + moved(at), + press(at), + Event::Ime(ImeEvent::DeleteSurrounding { before_chars: 1, after_chars: 0 }), + Event::Ime(ImeEvent::Commit("Q".to_owned())), + ]; + frames.frame(late, &mut show); + let own = editor.borrow().reset; + assert!(own.is_some(), "the editor asked for its own reset at the press"); + let reset = frames.ime().and_then(|ime| ime.interrupt.then_some(ime.reset).flatten()); + assert_eq!(reset, own, "the interrupt asks the platform to answer the editor's own request"); + let Some(reset) = reset else { return }; + frames.frame(vec![release(at)], &mut show); + frames.frame(Vec::new(), &mut show); + assert_eq!(editor.borrow().text, "ab", "the composition's late deletion and commit never reach the editor"); + frames.frame(vec![Event::ImeResetCompleted { request_id: reset }, Event::Ime(ImeEvent::Commit("X".to_owned()))], &mut show); + assert_eq!(editor.borrow().reset, None, "the completion of its own request reaches the editor"); + assert_eq!(editor.borrow().text, "abX", "the commit after it reaches the editor"); + frames.frame(vec![Event::Ime(ImeEvent::Preedit { text: "y".to_owned(), active_range_chars: None })], &mut show); + assert!(editor.borrow().composing, "the editor composes again"); +} + #[trial] fn a_focused_egui_field_keeps_tab_escape_and_the_clipboard() { let (host, mut show) = host_window(); From 3408eb09a57969987db986514978bb24cc6859c4 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 21:47:55 +0000 Subject: [PATCH 08/56] Dock: a group's tab overflow button is a gesture source (SourceKind::Overflow) TabStripOutput reports the overflow button's rect and access node id while some tabs do not fit. The dock group passes it on (DockGroupOutput::overflow, through the memoized tab row so a replay moves it with the row), and the dock area reports it beside the group's tabs as SourceKind::Overflow, named by the group's first panel, so a host can give the button an automation id. --- crates/ui-panels/src/docking/group.rs | 34 +++++++++++++++---- crates/ui-panels/src/docking/sources.rs | 9 +++-- crates/ui-patterns/src/patterns/dock/area.rs | 3 ++ .../ui-patterns/tests/it/docking/sources.rs | 31 ++++++++++++++++- crates/ui-widgets/src/tabs/strip.rs | 5 ++- docs/ui-docking.md | 2 +- 6 files changed, 71 insertions(+), 13 deletions(-) diff --git a/crates/ui-panels/src/docking/group.rs b/crates/ui-panels/src/docking/group.rs index 82d7a75e25..ad0dd7e631 100644 --- a/crates/ui-panels/src/docking/group.rs +++ b/crates/ui-panels/src/docking/group.rs @@ -301,6 +301,8 @@ pub struct DockGroupOutput { pub tabs: Vec<(PanelKey, Rect, Id)>, /// The band the group is dragged by this pass, with the id of its accessibility node. pub grip: Option<(Rect, Id)>, + /// The strip's overflow button, when some tabs do not fit, with the id of its accessibility node. + pub overflow: Option<(Rect, Id)>, } impl Outcome for DockGroupOutput { @@ -336,6 +338,7 @@ struct Reported { /// A drag started on the strip's empty room, which `finish` starts as a drag of the group. empty_drag: bool, tabs: Vec<(PanelKey, Rect, Id)>, + overflow: Option<(Rect, Id)>, } /// A group of panels: a header of tab strip and panel menu button, dragged by its empty part, over the active panel's @@ -626,7 +629,19 @@ impl Component for } let grip = cx.part_if_declared(GRIP).map(|grip| (grip.rect, crate::runtime::access::sub_node_id(cx.core.id, GRIP.into()))); let Reported { - picked, closed, picked_document, closed_documents, menu, item, commands, toggle_minimized, torn_off, drag_started, tabs, .. + picked, + closed, + picked_document, + closed_documents, + menu, + item, + commands, + toggle_minimized, + torn_off, + drag_started, + tabs, + overflow, + .. } = self.reported; DockGroupOutput { response: cx.response.clone(), @@ -642,6 +657,7 @@ impl Component for drag_started, tabs, grip, + overflow, } } } @@ -748,12 +764,13 @@ impl Container for // A press on the group's empty body focuses its panel, as in Photoshop; an app's own egui body keeps its presses. if surface_pressed && !self.host_body - && let Some((strip, _)) = &strip + && let Some((strip, _, _)) = &strip { focus::request(ui.ctx(), FocusTarget::Id(*strip)); } - if let Some((strip, tabs)) = &strip { + if let Some((strip, tabs, overflow)) = &strip { self.reported.tabs = tabs.iter().map(|(key, rect)| (*key, *rect, crate::contract::item_node(*strip, key))).collect(); + self.reported.overflow = *overflow; } let size = self.size; let (titles, reported) = (&self.panels, &mut self.reported); @@ -887,10 +904,13 @@ fn shown_tab(panels: &[PanelTitle], active: PanelKey) -> PanelKey { .unwrap_or(active) } -/// A group's tab strip with its tab insertion spots. Returns the strip's id and the rect of each tab it shows, which a -/// replay returns again, moved with the row. The panels' documents are tabs of the same strip after the panel tabs: one +/// What a group's tab row shows: the strip's id, each shown tab's rect and the overflow button with its node id. +type TabRowShown = (Id, Vec<(PanelKey, Rect)>, Option<(Rect, Id)>); + +/// A group's tab strip with its tab insertion spots. Returns the strip's id, the rect of each tab it shows and the +/// overflow button with its node id, which a replay returns again, moved with the row. The panels' documents are tabs of the same strip after the panel tabs: one /// fit, one overflow menu and one keyboard order for both. Only panel tabs drag and take tab insertions. -fn tab_row(row: &mut TabRow<'_, P>, ui: &mut Ui) -> (Id, Vec<(PanelKey, Rect)>) { +fn tab_row(row: &mut TabRow<'_, P>, ui: &mut Ui) -> TabRowShown { let env = crate::runtime::env::Env::of(ui); let name = Label::from(env.words::().panels.as_str().to_owned()); let rtl = env.direction.is_rtl(); @@ -977,7 +997,7 @@ fn tab_row(row: &mu if strip.empty_double { row.sent.send(TabEvent::EmptyDouble); } - (strip.response.response.id, strip.tab_rects) + (strip.response.response.id, strip.tab_rects, strip.overflow) } /// Registers the tab insertion spots of a group: the half of each shown tab nearer the start edge inserts before diff --git a/crates/ui-panels/src/docking/sources.rs b/crates/ui-panels/src/docking/sources.rs index 5b07725d92..1399c147bf 100644 --- a/crates/ui-panels/src/docking/sources.rs +++ b/crates/ui-panels/src/docking/sources.rs @@ -1,6 +1,6 @@ -//! The places a dock area drew in a pass where a press starts a dock gesture: tabs, group bars, a floating window's -//! grip and resize grips, and the dividers. A host names them for its own automation (an element id per source) and -//! reads which one holds key focus by the source's node id. +//! The places a dock area drew in a pass where a press starts a dock gesture: tabs, group bars, a tab strip's overflow +//! button, a floating window's grip and resize grips, and the dividers. A host names them for its own automation (an +//! element id per source) and reads which one holds key focus by the source's node id. use crate::runtime::windows::ResizeEdge; use egui::{Id, Rect, ViewportId}; @@ -38,6 +38,9 @@ pub enum SourceKind

{ Document(P, u64), /// The bar a group is dragged by, named by the group's first panel. GroupBar(P), + /// The overflow button of a group's tab strip, named by the group's first panel: a click opens the menu of the tabs + /// that do not fit. Only while some tabs do not fit. + Overflow(P), /// The band a floating window is moved by, named by the window's first panel. WindowGrip(P), /// A grip a floating window is resized by, named by the window's first panel, with the edge or corner it moves. diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index 1f19d184f5..ad4a690104 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -1332,6 +1332,9 @@ impl Pass<'_, P> { }; let tabs = output.tabs.iter().filter_map(|(key, rect, node)| Some(DockSource::new(kind_of(*key)?, *rect, *node))); self.report.sources.extend(tabs); + if let Some((rect, node)) = output.overflow { + self.report.sources.push(DockSource::new(SourceKind::Overflow(anchor.clone()), rect, node)); + } if let Some((rect, node)) = output.grip { self.report.sources.push(DockSource::new(SourceKind::GroupBar(anchor.clone()), rect, node)); } diff --git a/crates/ui-patterns/tests/it/docking/sources.rs b/crates/ui-patterns/tests/it/docking/sources.rs index 623e906f19..d68e5cd2bd 100644 --- a/crates/ui-patterns/tests/it/docking/sources.rs +++ b/crates/ui-patterns/tests/it/docking/sources.rs @@ -4,10 +4,11 @@ use super::Numbered; use craft_behavior::Axis; use craft_behavior::dock::{Column, DockEdge, Floating, Group, Layout, Node, SplitSize, StackEntry, Workspace}; -use craft_ui::contract::{Bind, BodyCx, Tracked}; +use craft_ui::contract::{Bind, BodyCx, Role, Tracked}; use craft_ui::docking::{DividerKind, DockConfig, DockPanels, DockSource, HidePanels, PanelKey, SourceKind}; use craft_ui::patterns::dock::DockArea; use craft_ui::runtime::env::{BodyMode, ShellCx, ShellEntry, WindowKey}; +use craft_ui::testing::access::NodeKey; use craft_ui::testing::{Fixture, trial}; use egui::{Pos2, Rect, Ui, Vec2}; use std::cell::RefCell; @@ -166,3 +167,31 @@ fn each_stack_section_reports_its_panels_tab() { let tabs = panels(&reported.borrow(), |kind| if let SourceKind::Tab(panel) = kind { Some(*panel) } else { None }); assert_eq!(tabs, [UPPER, LOWER], "{:?}", reported.borrow()); } + +/// A group whose tabs do not fit reports its strip's overflow button, named by the group's first panel, under the id of +/// the button's node and where a click opens the menu of the hidden tabs; groups whose tabs fit report none. +#[trial] +fn a_group_whose_tabs_do_not_fit_reports_its_overflow_button() { + const PANELS: [usize; 6] = [11, 12, 13, 14, 15, 16]; + let reported: Rc>>> = Rc::default(); + let seen = Rc::clone(&reported); + let mut narrow = Fixture::new(move |ui| { + let mut workspace = Arc::new(Workspace::new(Layout::new(Some(Node::tabs(PANELS.to_vec(), 0)), Vec::new()))); + let specs = Tracked::new(Numbered); + let mut bodies = Bodies; + *seen.borrow_mut() = DockArea::new("Overflow", Bind::bound(&mut workspace), &specs, &mut bodies, DockConfig::default()).show(ui).sources; + }); + narrow.room(Vec2::new(160.0, 300.0)).settle(); + let overflow: Vec> = + reported.borrow().iter().filter(|source| matches!(source.kind, SourceKind::Overflow(_))).cloned().collect(); + let kinds: Vec> = overflow.iter().map(|source| source.kind.clone()).collect(); + assert_eq!(kinds, vec![SourceKind::Overflow(PANELS[0])], "one overflow button, named by the group's first panel"); + let more = narrow.by_label("More tabs").expect("the strip's overflow button shows"); + assert_eq!(more.node, NodeKey::of(overflow[0].id), "the source's id is the button's node"); + assert!(narrow.by_role(Role::MENU_ITEM).is_empty(), "no menu is open yet"); + narrow.click_at(overflow[0].rect.center()).settle(); + assert!(!narrow.by_role(Role::MENU_ITEM).is_empty(), "a click on the source's rect opens the menu of the hidden tabs"); + + let (_wide, wide) = fixture(None, None); + assert!(wide.borrow().iter().all(|source| !matches!(source.kind, SourceKind::Overflow(_))), "groups whose tabs fit report no overflow button"); +} diff --git a/crates/ui-widgets/src/tabs/strip.rs b/crates/ui-widgets/src/tabs/strip.rs index ce8278c479..e8379d2818 100644 --- a/crates/ui-widgets/src/tabs/strip.rs +++ b/crates/ui-widgets/src/tabs/strip.rs @@ -99,6 +99,8 @@ pub struct TabStripOutput { pub empty_drag: bool, /// The second press of a double click went down on the strip's empty room this pass. pub empty_double: bool, + /// The overflow button, when some tabs do not fit: its rect in screen space and the id of its accessibility node. + pub overflow: Option<(Rect, Id)>, } impl Outcome for TabStripOutput { @@ -988,6 +990,7 @@ impl Component f fn finish(self, mut cx: Cx<'_, Self>) -> TabStripOutput { let tab_rects = self.tab_rects(&cx); + let overflow = self.more.map(|rect| (rect, crate::runtime::access::sub_node_id(cx.core.id, OVERFLOW.into()))); let TabStrip { picked, torn, wheeled, empty_drag, empty_double, can_close, kind, .. } = self; let mut response = cx.collection_response(); let (mut closed, mut menu) = (Vec::new(), None); @@ -1010,7 +1013,7 @@ impl Component f mods: craft_keymap::Mods::NONE, })); response.events = kept; - TabStripOutput { response, closed, menu, picked, torn_off: torn, tab_rects, empty_drag, empty_double } + TabStripOutput { response, closed, menu, picked, torn_off: torn, tab_rects, empty_drag, empty_double, overflow } } } diff --git a/docs/ui-docking.md b/docs/ui-docking.md index c9dd4314d8..b9e587024b 100644 --- a/docs/ui-docking.md +++ b/docs/ui-docking.md @@ -82,7 +82,7 @@ Props: `hide` (`HidePanels::None`, `All` or `Except`), `maximized`, `auto_collap A panel in a column collapsed to icons shows in its flyout (`Layout::opens_in_flyout`). The host opens and closes it by writing the `flyout` binding, not the layout: `WindowMenuRows` checks such a panel's row while its flyout is open (`WindowMenuRows::flyout`) and reports a pick in `WindowMenuRowsOutput::flyout`. -`DockAreaOutput` holds the `actions` taken, the bodies' `requested` actions, the `events` for the host, the `focused` and `picked` panels, the `pressed` panel (the shown panel of the group whose body the primary press went down in, whatever took it, so a host whose bodies are its own egui code knows the panel clicked into), the gesture `sources` (a panel tab, a document tab, a group bar, window grips, dividers), `edit`, `float_space`, `columns`, the OS `windows` the floating windows showed in (by a panel of each), `window_files` (one `WindowFiles` per drop on a floating OS window: the shown panel of the group under the drop, the first group's for a drop on the title row, and the files), and `error`: an `InvalidGeometry` when the workspace fails `validate`, in which case the area draws nothing. +`DockAreaOutput` holds the `actions` taken, the bodies' `requested` actions, the `events` for the host, the `focused` and `picked` panels, the `pressed` panel (the shown panel of the group whose body the primary press went down in, whatever took it, so a host whose bodies are its own egui code knows the panel clicked into), the gesture `sources` (a panel tab, a document tab, a group bar, a tab strip's overflow button, window grips, dividers), `edit`, `float_space`, `columns`, the OS `windows` the floating windows showed in (by a panel of each), `window_files` (one `WindowFiles` per drop on a floating OS window: the shown panel of the group under the drop, the first group's for a drop on the title row, and the files), and `error`: an `InvalidGeometry` when the workspace fails `validate`, in which case the area draws nothing. The host handles these `DockEvent`s: From ddbb7e6a4da34c360b53444878d34595b3666ca9 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:51 +0000 Subject: [PATCH 09/56] Pin egui to aiongg/egui ime-pending-reset (bbfd6471e): pending_ime_reset and covered-widget arrow focus --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 28 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96a6d625ab..4fe6f14aad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5535,7 +5535,7 @@ dependencies = [ [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "bytemuck", "emath", @@ -5591,7 +5591,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "ahash", "bytemuck", @@ -5626,7 +5626,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "accesskit", "ahash", @@ -5645,7 +5645,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "ahash", "bytemuck", @@ -5664,7 +5664,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "block2 0.6.2", "bytemuck", @@ -5684,7 +5684,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "bytemuck", "egui", @@ -5697,7 +5697,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "eframe", "egui", @@ -5774,7 +5774,7 @@ dependencies = [ [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "bytemuck", ] @@ -5847,7 +5847,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" dependencies = [ "ahash", "bytemuck", @@ -5873,7 +5873,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" [[package]] name = "equator" @@ -15205,19 +15205,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" [[patch.unused]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=a87d00caaec947ea781657c6ff410c9838016d18#a87d00caaec947ea781657c6ff410c9838016d18" +source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" diff --git a/Cargo.toml b/Cargo.toml index 3ab56cbec0..a71f6358de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -316,20 +316,20 @@ hayro-postscript = { path = "vendor/hayro-postscript" } linesweeper = { path = "vendor/linesweeper" } vello_common = { path = "vendor/vello_common" } vello_cpu = { path = "vendor/vello_cpu" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -emath = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "a87d00caaec947ea781657c6ff410c9838016d18" } +ecolor = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +emath = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +epaint = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +eframe = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # symphonia's FLAC decoder restores LPC samples as `residual + (prediction as i32)`. In a valid From a3a58be575021d853c9f74c6366e6fab8c36d11a Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:51 +0000 Subject: [PATCH 10/56] IME: the fence follows the app's reset requests asked through egui The app's reset of a pass is the one egui publishes: Context::pending_ime_reset, else the IME output's own field. The interrupt of an app editor reuses it, the engine records it, and a request the app publishes while the fence is up becomes the one the fence waits for. A completion answers its request and every older one. --- .../ui-contract/src/runtime/egui/fixture.rs | 23 +++-- crates/ui-contract/src/runtime/egui/ime.rs | 14 ++- crates/ui-contract/src/runtime/ime.rs | 30 ++++--- .../src/testing/host_key_trials.rs | 86 ++++++++++++++----- 4 files changed, 112 insertions(+), 41 deletions(-) diff --git a/crates/ui-contract/src/runtime/egui/fixture.rs b/crates/ui-contract/src/runtime/egui/fixture.rs index e1064759df..63be1d9b0d 100644 --- a/crates/ui-contract/src/runtime/egui/fixture.rs +++ b/crates/ui-contract/src/runtime/egui/fixture.rs @@ -526,17 +526,23 @@ pub(crate) fn host_ime_editor(ui: &Ui, id: egui::Id, rect: Rect, text: &mut Stri pub(crate) struct ResettingEditor { pub(crate) text: String, pub(crate) composing: bool, - /// The reset the editor asked for at a press during its composition, until its completion arrives; the editor - /// takes no IME event meanwhile. + /// The reset the editor asked for last, until its completion arrives; the editor takes no IME event meanwhile. pub(crate) reset: Option, + /// The editor also writes its request into its IME output's `reset_request`. Otherwise it leaves that field to egui, + /// which publishes the request asked through `Context::request_ime_reset`, as EffectCraft's editor does. + pub(crate) in_output: bool, + /// Ask for a reset at the next pass, as EffectCraft's editor does when its caret moves after an outside press. + pub(crate) ask: bool, } /// A host's own text editor of `id` at `rect` that fences its own interrupted composition, as EffectCraft's viewer text -/// editor does: a primary press while it composes ends the composition and asks the platform for a reset in its own IME -/// output, and the editor ignores IME events until that reset's completion. Otherwise as [`host_ime_editor`]. +/// editor does: a primary press on it while it composes ends the composition and asks the platform for a reset, and the +/// editor ignores IME events until that reset's completion. A press elsewhere asks for nothing. Otherwise as +/// [`host_ime_editor`]. #[cfg(feature = "suite")] pub(crate) fn host_resetting_ime_editor(ui: &Ui, id: egui::Id, rect: Rect, editor: &mut ResettingEditor) { let _ = ui.interact(rect, id, egui::Sense::click()); + let pressed = ui.input(|input| input.pointer.primary_pressed() && input.pointer.press_origin().is_some_and(|at| rect.contains(at))); for event in ui.input(|input| input.events.clone()) { match event { Event::ImeResetCompleted { request_id } if editor.reset == Some(request_id) => editor.reset = None, @@ -555,11 +561,14 @@ pub(crate) fn host_resetting_ime_editor(ui: &Ui, id: egui::Id, rect: Rect, edito } } let mut ime = egui::output::IMEOutput::new(id, 1, egui::IMEPurpose::Normal, rect, rect); - if editor.composing && ui.input(|input| input.pointer.primary_pressed()) { + let interrupted = editor.composing && pressed; + if interrupted || std::mem::take(&mut editor.ask) { editor.composing = false; editor.reset = ui.ctx().request_ime_reset(ui.ctx().viewport_id()); - ime.should_interrupt_composition = true; - ime.reset_request = editor.reset; + ime.should_interrupt_composition = interrupted; + if editor.in_output { + ime.reset_request = editor.reset; + } } ui.ctx().output_mut(|output| output.ime = Some(ime)); } diff --git a/crates/ui-contract/src/runtime/egui/ime.rs b/crates/ui-contract/src/runtime/egui/ime.rs index 71fd378600..9c9542d310 100644 --- a/crates/ui-contract/src/runtime/egui/ime.rs +++ b/crates/ui-contract/src/runtime/egui/ime.rs @@ -109,12 +109,18 @@ pub(crate) fn write(ctx: &Context, viewport: ViewportId, out: Output) -> Option< reset } +/// The reset request the app asked for this pass, as egui publishes it at the end of the pass: one asked through +/// `Context::request_ime_reset`, which replaces the IME output's own `reset_request`, or else the one the app wrote +/// there. +pub(crate) fn app_reset(ctx: &Context, viewport: ViewportId) -> Option { + ctx.pending_ime_reset(viewport).or_else(|| ctx.output(|output| output.ime.as_ref().and_then(|ime| ime.reset_request))) +} + /// Interrupts the composition of the IME output the app's own editor wrote this pass, in its context, and asks for a -/// reset. An editor that asked for its own reset in that output keeps its request, so the platform answers the app's -/// id and the app gets its completion. Returns the reset request the output carries, as `write` does. +/// reset. An editor that asked for its own reset this pass (`app_reset`) keeps its request, so the platform answers the +/// app's id and the app gets its completion. Returns the reset request the output carries, as `write` does. pub(crate) fn interrupt_written(ctx: &Context, viewport: ViewportId) -> Option { - let written = ctx.output(|output| output.ime.as_ref().and_then(|ime| ime.reset_request)); - let reset = written.or_else(|| ctx.request_ime_reset(viewport)); + let reset = app_reset(ctx, viewport).or_else(|| ctx.request_ime_reset(viewport)); ctx.output_mut(|output| { if let Some(ime) = &mut output.ime { ime.should_interrupt_composition = true; diff --git a/crates/ui-contract/src/runtime/ime.rs b/crates/ui-contract/src/runtime/ime.rs index 20c6509eed..4870f17ebd 100644 --- a/crates/ui-contract/src/runtime/ime.rs +++ b/crates/ui-contract/src/runtime/ime.rs @@ -53,9 +53,9 @@ struct Engine { editor: Option, /// The app's own editor that wrote the IME output of the last pass while no framework editor owned the IME. host: Option, - /// The reset requests the app's own editor wrote in its IME output, unanswered yet: their completions and - /// retirements are the app's and stay in egui's input for it, fence or not. One of them is the fence's `reset` - /// when the app asked for its reset in the pass the engine interrupted its composition. + /// The reset requests the app's own editor published with its IME output, oldest first, unanswered yet: their + /// completions and retirements are the app's and stay in egui's input for it, fence or not. The latest one the app + /// published while the fence is up is the fence's `reset`, from the pass the engine interrupted its composition on. host_resets: Vec, } @@ -201,13 +201,17 @@ impl Engine { self.discard = true; } - /// Notes an answer to one of the app's own reset requests: the request is answered, and a completion of the one the - /// fence waits for ends the fence; a retirement leaves the end hook to ask again. + /// Notes an answer to one of the app's own reset requests. A completion answers that request and every older one, + /// as completions arrive in request order, and ends the fence when it waits for one of them; a retirement answers + /// only its own request and, when the fence waits for it, leaves the end hook to ask again. fn host_answered(&mut self, event: &Event) { let (Event::ImeResetCompleted { request_id: id } | Event::ImeResetRetired { request_id: id }) = event else { return }; let Some(at) = self.host_resets.iter().position(|own| own == id) else { return }; - self.host_resets.remove(at); - if self.reset == Some(*id) { + let answered: Vec<_> = match event { + Event::ImeResetCompleted { .. } => self.host_resets.drain(..=at).collect(), + _ => vec![self.host_resets.remove(at)], + }; + if self.reset.is_some_and(|reset| answered.contains(&reset)) { self.reset = None; if matches!(event, Event::ImeResetCompleted { .. }) { self.stale = false; @@ -490,8 +494,9 @@ pub(crate) fn note_caret(ctx: &Context, owner: Id, field: Rect, caret: Rect, pas pub(crate) fn end_pass(ctx: &Context) { let viewport = pass::current_viewport(ctx); let (frame_nr, pass_nr) = (ctx.cumulative_frame_nr_for(viewport), ctx.cumulative_pass_nr_for(viewport)); - let app_ime = ctx.output(|output| output.ime.as_ref().map(|ime| (ime.owner, ime.context_generation, ime.reset_request))); - let app_wrote = app_ime.map(|(owner, generation, _)| (owner, generation)); + let app_wrote = ctx.output(|output| output.ime.as_ref().map(|ime| (ime.owner, ime.context_generation))); + // egui publishes the app's request only in a pass that has an IME output. + let app_reset = app_wrote.and(os::app_reset(ctx, viewport)); let (owner, interrupt, caret, update, published, host) = with(ctx, viewport, |engine| { let ran = std::mem::take(&mut engine.ran); if !ran { @@ -510,10 +515,15 @@ pub(crate) fn end_pass(ctx: &Context) { let last_host = engine.host; let kept = engine.host.filter(|host| app_wrote.is_some_and(|(owner, _)| owner == host.owner)).is_some_and(|host| host.composing); engine.host = app_wrote.filter(|_| engine.owner.is_none()).map(|(owner, generation)| HostIme { owner, generation, composing: kept }); - if let Some(id) = app_ime.filter(|_| engine.owner.is_none()).and_then(|(.., reset)| reset) + if let Some(id) = app_reset.filter(|_| engine.owner.is_none()) && !engine.host_resets.contains(&id) { engine.host_resets.push(id); + // Completions arrive in request order: the latest request's completion ends the interrupted composition, + // whichever request the fence waited for. + if engine.stale { + engine.reset = Some(id); + } } // The fence has no request the integration can answer: the owner's output asks again, a framework editor's // or the app's own. diff --git a/crates/ui-contract/src/testing/host_key_trials.rs b/crates/ui-contract/src/testing/host_key_trials.rs index c09af46180..e65e8c1cd3 100644 --- a/crates/ui-contract/src/testing/host_key_trials.rs +++ b/crates/ui-contract/src/testing/host_key_trials.rs @@ -215,12 +215,11 @@ fn a_press_during_an_app_editor_s_composition_fences_its_late_ime_events() { assert_eq!(*editor.borrow(), "abX", "the commit after the completion reaches the editor"); } -/// An app editor that asks for its own reset at the press that interrupts its composition keeps that request: the -/// platform is asked to answer the app's id, the late events stay fenced, and the completion reaches the editor, which -/// takes the events after it and composes again. -#[trial] -fn an_app_editor_s_own_reset_at_the_press_reaches_it_and_it_composes_again() { - let editor = Rc::new(RefCell::new(fixture::ResettingEditor::default())); +/// The app's own resetting editor at its rect, the show closure that draws it, and the frames after two idle ones, +/// a commit of "ab" and a preedit of "z": the editor composes. `in_output`: the editor writes its reset request into +/// its IME output too, instead of leaving it to egui as EffectCraft's editor does. +fn composing_resetting_editor(in_output: bool) -> (Rc>, impl FnMut(&mut Ui), Frames) { + let editor = Rc::new(RefCell::new(fixture::ResettingEditor { in_output, ..Default::default() })); let held = Rc::clone(&editor); let rect = Rect::from_min_size(Pos2::new(100.0, 100.0), egui::vec2(200.0, 30.0)); let mut show = move |ui: &mut Ui| fixture::host_resetting_ime_editor(ui, host_editor_id(), rect, &mut held.borrow_mut()); @@ -228,25 +227,72 @@ fn an_app_editor_s_own_reset_at_the_press_reaches_it_and_it_composes_again() { frames.idle(2, &mut show); frames.frame(vec![Event::Ime(ImeEvent::Commit("ab".to_owned()))], &mut show); frames.frame(vec![Event::Ime(ImeEvent::Preedit { text: "z".to_owned(), active_range_chars: None })], &mut show); - let at = Pos2::new(150.0, 115.0); - let late = vec![ + (editor, show, frames) +} + +/// The press at `at` with the composition's late deletion and commit after it, in one frame. +fn press_with_late_ime(at: Pos2) -> Vec { + vec![ moved(at), press(at), Event::Ime(ImeEvent::DeleteSurrounding { before_chars: 1, after_chars: 0 }), Event::Ime(ImeEvent::Commit("Q".to_owned())), - ]; - frames.frame(late, &mut show); - let own = editor.borrow().reset; - assert!(own.is_some(), "the editor asked for its own reset at the press"); - let reset = frames.ime().and_then(|ime| ime.interrupt.then_some(ime.reset).flatten()); - assert_eq!(reset, own, "the interrupt asks the platform to answer the editor's own request"); - let Some(reset) = reset else { return }; - frames.frame(vec![release(at)], &mut show); + ] +} + +/// An app editor that asks for its own reset at the press that interrupts its composition keeps that request: the +/// platform is asked to answer the app's id, the late events stay fenced, and the completion reaches the editor, which +/// takes the events after it and composes again. The editor asks through egui alone, or writes the request into its +/// output too. +#[trial] +fn an_app_editor_s_own_reset_at_the_press_reaches_it_and_it_composes_again() { + for in_output in [false, true] { + let (editor, mut show, mut frames) = composing_resetting_editor(in_output); + let at = Pos2::new(150.0, 115.0); + frames.frame(press_with_late_ime(at), &mut show); + let own = editor.borrow().reset; + assert!(own.is_some(), "the editor asked for its own reset at the press"); + let reset = frames.ime().and_then(|ime| ime.interrupt.then_some(ime.reset).flatten()); + assert_eq!(reset, own, "the interrupt asks the platform to answer the editor's own request (in_output {in_output})"); + let Some(reset) = reset else { return }; + frames.frame(vec![release(at)], &mut show); + frames.frame(Vec::new(), &mut show); + assert_eq!(editor.borrow().text, "ab", "the composition's late deletion and commit never reach the editor"); + frames.frame(vec![Event::ImeResetCompleted { request_id: reset }, Event::Ime(ImeEvent::Commit("X".to_owned()))], &mut show); + assert_eq!(editor.borrow().reset, None, "the completion of its own request reaches the editor"); + assert_eq!(editor.borrow().text, "abX", "the commit after it reaches the editor"); + frames.frame(vec![Event::Ime(ImeEvent::Preedit { text: "y".to_owned(), active_range_chars: None })], &mut show); + assert!(editor.borrow().composing, "the editor composes again"); + } +} + +/// A press outside the app's editor fences its composition with the framework's own reset request; a reset the app +/// asks for in a later pass becomes the one the fence waits for. Its completion ends the fence, the commit after it +/// reaches the editor, and the framework's request is never answered. +#[trial] +fn an_app_editor_s_later_reset_ends_the_fence() { + let (editor, mut show, mut frames) = composing_resetting_editor(false); + let outside = Pos2::new(500.0, 400.0); + frames.frame(press_with_late_ime(outside), &mut show); + let fence = frames.ime().and_then(|ime| ime.interrupt.then_some(ime.reset).flatten()); + assert!(fence.is_some() && editor.borrow().reset.is_none(), "the framework fences with its own request; the editor asks nothing"); + frames.frame(vec![release(outside)], &mut show); + editor.borrow_mut().ask = true; frames.frame(Vec::new(), &mut show); - assert_eq!(editor.borrow().text, "ab", "the composition's late deletion and commit never reach the editor"); - frames.frame(vec![Event::ImeResetCompleted { request_id: reset }, Event::Ime(ImeEvent::Commit("X".to_owned()))], &mut show); - assert_eq!(editor.borrow().reset, None, "the completion of its own request reaches the editor"); - assert_eq!(editor.borrow().text, "abX", "the commit after it reaches the editor"); + let later = editor.borrow().reset; + assert!(later.is_some() && later != fence, "the editor asks for its own reset later"); + assert_eq!(frames.ime().and_then(|ime| ime.reset), later, "the pass publishes the editor's request"); + let Some(later) = later else { return }; + frames.frame( + vec![ + Event::Ime(ImeEvent::Commit("Q".to_owned())), + Event::ImeResetCompleted { request_id: later }, + Event::Ime(ImeEvent::Commit("X".to_owned())), + ], + &mut show, + ); + assert_eq!(editor.borrow().reset, None, "the completion of its later request reaches the editor"); + assert_eq!(editor.borrow().text, "abX", "the late commit is fenced and the commit after the completion reaches the editor"); frames.frame(vec![Event::Ime(ImeEvent::Preedit { text: "y".to_owned(), active_range_chars: None })], &mut show); assert!(editor.borrow().composing, "the editor composes again"); } From 951ca3f3d19b617765996b2523af894679c077a0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:51 +0000 Subject: [PATCH 11/56] Trial: arrows in an app's popup list skip the widget it covers --- crates/ui-contract/src/runtime/egui/areas.rs | 24 +++++++++++++++++++ .../src/testing/host_key_trials.rs | 22 +++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/crates/ui-contract/src/runtime/egui/areas.rs b/crates/ui-contract/src/runtime/egui/areas.rs index 090a019ecd..b307ea3d7b 100644 --- a/crates/ui-contract/src/runtime/egui/areas.rs +++ b/crates/ui-contract/src/runtime/egui/areas.rs @@ -544,6 +544,30 @@ pub(crate) fn host_popup(ui: &Ui, id: egui::Id, at: Pos2) { egui::Popup::new(id, ui.ctx().clone(), at, ui.layer_id()).open_memory(None).show(|ui| ui.allocate_space(ui.spacing().interact_size)); } +/// The size of one entry of [`host_popup_list`], as an app's popup list entry. +#[cfg(feature = "suite")] +const HOST_LIST_ENTRY: Vec2 = Vec2::new(104.0, 22.0); + +/// A host's own popup list `id` at `at`, as an app draws one: an egui foreground area with one clickable entry per id +/// in `entries`, stacked from the top. It leaves arrow keys to egui's directional focus. Returns the entries' rects. +#[cfg(feature = "suite")] +pub(crate) fn host_popup_list(ctx: &Context, id: Id, at: Pos2, entries: &[Id]) -> Vec { + egui::Area::new(id) + .order(Order::Foreground) + .fixed_pos(at) + .show(ctx, |ui| { + let mut rects = Vec::new(); + for (row, &entry) in entries.iter().enumerate() { + let rect = Rect::from_min_size(at + Vec2::Y * (HOST_LIST_ENTRY.y * row as f32), HOST_LIST_ENTRY); + ui.allocate_rect(rect, Sense::hover()); + let _ = ui.interact(rect, entry, Sense::click()); + rects.push(rect); + } + rects + }) + .inner +} + /// Opens the host's egui popup `id`. #[cfg(feature = "suite")] pub(crate) fn open_host_popup(ctx: &Context, id: egui::Id) { diff --git a/crates/ui-contract/src/testing/host_key_trials.rs b/crates/ui-contract/src/testing/host_key_trials.rs index e65e8c1cd3..44ec6efc44 100644 --- a/crates/ui-contract/src/testing/host_key_trials.rs +++ b/crates/ui-contract/src/testing/host_key_trials.rs @@ -424,6 +424,28 @@ fn arrows_and_tab_move_egui_focus_among_host_buttons() { assert_eq!(egui_focused(&frames.ctx), Some(named_id("button")), "egui's arrows leave a framework stop's focus alone"); } +/// Arrows from an entry of the app's own popup list stay in the list: the app's button under the list, a host stop as +/// an app's tool slot is, is no arrow target while the list covers it, though it lies nearer below the first entry +/// than the second entry does. +#[trial] +fn arrows_in_an_app_popup_list_skip_the_widget_it_covers() { + let (button, popup, first, second) = (named_id("host tool"), named_id("host popup"), named_id("host entry 1"), named_id("host entry 2")); + let mut show = move |ui: &mut Ui| { + fixture::host_button(ui, button, Rect::from_min_max(Pos2::new(228.0, 31.0), Pos2::new(254.0, 57.0))); + host_stop(ui.ctx(), button, KeyUse::of(Input::Pointer)); + areas::host_popup_list(ui.ctx(), popup, Pos2::new(201.0, 18.0), &[first, second]); + }; + let mut frames = Frames::new(); + frames.idle(2, &mut show); + fixture::host_focus(&frames.ctx, first); + frames.idle(2, &mut show); + assert_eq!(egui_focused(&frames.ctx), Some(first)); + press_key(&mut frames, &mut show, Key::ArrowDown); + assert_eq!(egui_focused(&frames.ctx), Some(second), "ArrowDown goes to the list's next entry, not to the button under it"); + press_key(&mut frames, &mut show, Key::ArrowUp); + assert_eq!(egui_focused(&frames.ctx), Some(first), "ArrowUp comes back to the first entry"); +} + /// What the window shows before the app's own egui buttons. #[derive(Clone, Copy)] enum Before { From ed1da0da5e7aa77ef299c98ef4d5a97c6bec17ef Mon Sep 17 00:00:00 2001 From: mocenigo Date: Tue, 24 Nov 2026 23:44:09 +0100 Subject: [PATCH 12/56] pages, ui-canvas: drop a held thumb's extent once its press ended unseen A full-screen view drops the bars, so a thumb released there never reached them and the extent stayed in the press slot; with the held-thumb guard, it would keep the horizontal bar up over pages that fit. The bars drop it as soon as they see the thumb idle again. Also moves the new test helper off the doc comment of the zoom test it had split, and has_horizontal_bar uses it. --- crates/pages/tests/it/views.rs | 85 +++++++++++++------ crates/ui-canvas/src/canvas/scrollbars/mod.rs | 10 +++ 2 files changed, 69 insertions(+), 26 deletions(-) diff --git a/crates/pages/tests/it/views.rs b/crates/pages/tests/it/views.rs index 0042c27937..f0ec0c2e8e 100644 --- a/crates/pages/tests/it/views.rs +++ b/crates/pages/tests/it/views.rs @@ -116,7 +116,7 @@ fn has_horizontal_bar(zoom: f64) -> bool { s.zoom = zoom; }), ); - fixture.by_role(Role::SCROLL_BAR).iter().any(|bar| bar.rect.width() > bar.rect.height()) + horizontal_bar(&fixture).is_some() } #[trial] @@ -125,6 +125,64 @@ fn the_horizontal_bar_shows_only_when_the_pages_are_wider_than_the_view() { assert!(has_horizontal_bar(3.0), "pages wider than the view scroll sideways"); } +/// The horizontal scroll bar the fixture shows, if any. +fn horizontal_bar(fixture: &Fixture) -> Option { + fixture.by_role(Role::SCROLL_BAR).iter().map(|bar| bar.rect).find(|rect| rect.width() > rect.height()) +} + +#[trial] +fn a_horizontal_thumb_held_while_the_pages_come_to_fit_keeps_its_bar_until_the_release() { + let (mut fixture, state, _) = layout_rig( + 3, + state_with(|s| { + s.fit = Fit::None; + s.zoom = 3.0; + }), + ); + let bar = horizontal_bar(&fixture).expect("pages wider than the view have a horizontal bar"); + // The view starts at the left edge, so the thumb is at the start of the track. + let from = pos2(bar.left() + 4.0, bar.center().y); + fixture.drag_hold_at(from, vec2(20.0, 0.0)); + state.borrow_mut().zoom = 0.5; + fixture.idle(3); + assert!(horizontal_bar(&fixture).is_some(), "the held thumb keeps its bar, so its release reaches it"); + fixture.release_at(from + vec2(20.0, 0.0)).idle(2); + assert!(horizontal_bar(&fixture).is_none(), "after the release, pages that fit have no horizontal bar"); +} + +#[trial] +fn a_horizontal_thumb_released_while_the_bars_are_not_shown_leaves_no_bar_behind() { + let state = Rc::new(RefCell::new(state_with(|s| { + s.fit = Fit::None; + s.zoom = 3.0; + }))); + let full_screen = Rc::new(Cell::new(false)); + let (kept, edge_to_edge) = (Rc::clone(&state), Rc::clone(&full_screen)); + let pages = DemoPages::new(3); + let mut fixture = Fixture::new(move |ui| { + let mut now = kept.borrow().clone(); + PageView::new("Pages", &pages, &mut now, PAPER).options(LayoutOptions::ACROBAT).fill_screen(edge_to_edge.get()).show(ui, |_, _| ()); + *kept.borrow_mut() = now; + }); + fixture.room(vec2(900.0, 600.0)); + fixture.settle(); + let bar = horizontal_bar(&fixture).expect("pages wider than the view have a horizontal bar"); + let from = pos2(bar.left() + 4.0, bar.center().y); + fixture.drag_hold_at(from, vec2(20.0, 0.0)); + // Full screen mid-drag: the bars go, and the release can't reach them. + full_screen.set(true); + fixture.idle(2); + fixture.release_at(from + vec2(20.0, 0.0)).idle(2); + full_screen.set(false); + { + let mut state = state.borrow_mut(); + state.fit = Fit::None; + state.zoom = 0.5; + } + fixture.idle(3); + assert!(horizontal_bar(&fixture).is_none(), "a press that ended unseen leaves no horizontal bar over pages that fit"); +} + #[trial] fn go_to_a_narrow_page_brings_it_back_into_horizontal_view() { let Rig { mut fixture, state, out, .. } = rig_over( @@ -433,31 +491,6 @@ fn assert_centre_kept(out: &Out, before: (usize, kurbo::Point), what: &str) { /// A written zoom keeps the point at the centre; a new room (a panel opened beside the view) refits and keeps the /// current page's top where it was, as production did. -/// The horizontal scroll bar the fixture shows, if any. -fn horizontal_bar(fixture: &Fixture) -> Option { - fixture.by_role(Role::SCROLL_BAR).iter().map(|bar| bar.rect).find(|rect| rect.width() > rect.height()) -} - -#[trial] -fn a_horizontal_thumb_held_while_the_pages_come_to_fit_keeps_its_bar_until_the_release() { - let (mut fixture, state, _) = layout_rig( - 3, - state_with(|s| { - s.fit = Fit::None; - s.zoom = 3.0; - }), - ); - let bar = horizontal_bar(&fixture).expect("pages wider than the view have a horizontal bar"); - // The view starts at the left edge, so the thumb is at the start of the track. - let from = pos2(bar.left() + 4.0, bar.center().y); - fixture.drag_hold_at(from, vec2(20.0, 0.0)); - state.borrow_mut().zoom = 0.5; - fixture.idle(3); - assert!(horizontal_bar(&fixture).is_some(), "the held thumb keeps its bar, so its release reaches it"); - fixture.release_at(from + vec2(20.0, 0.0)).idle(2); - assert!(horizontal_bar(&fixture).is_none(), "after the release, pages that fit have no horizontal bar"); -} - #[trial] fn a_changed_zoom_keeps_the_point_at_the_centre_and_a_new_room_the_current_pages_top() { // The app's zoom. diff --git a/crates/ui-canvas/src/canvas/scrollbars/mod.rs b/crates/ui-canvas/src/canvas/scrollbars/mod.rs index d8a0f97d21..f4e30e5e3f 100644 --- a/crates/ui-canvas/src/canvas/scrollbars/mod.rs +++ b/crates/ui-canvas/src/canvas/scrollbars/mod.rs @@ -549,6 +549,16 @@ impl Component for CanvasScrollbars<'_> { } let Some(view) = cx.value().copied() else { return }; let mut held = cx.press_slot::().clone(); + // A press that ended while the bars weren't shown (a full-screen view drops them) never reached them: its thumb + // is idle again, and the extent kept for it is stale. + let stale = held.as_ref().is_some_and(|held| { + let thumb = thumb_of(if held.horizontal { HORIZONTAL } else { VERTICAL }); + matches!(cx.part(thumb).press.phase, PressPhase::Idle | PressPhase::Hover) + }); + if stale { + *cx.press_slot::() = None; + held = None; + } let bars = self.bars(&view, cx.rect, cx.style, held.as_ref()); let mut ended = false; let rtl = cx.flow.is_rtl(); From 9ea549874c57d88d193b074ac77d909539bf1eeb Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 00:12:07 +0000 Subject: [PATCH 13/56] Pin egui to aiongg/egui ime-pending-reset (c7a2f6af5): texture deltas of a multi-pass run and of every viewport reach the shared renderer in order --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 28 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fe6f14aad..9cf603b2e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5535,7 +5535,7 @@ dependencies = [ [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "bytemuck", "emath", @@ -5591,7 +5591,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "ahash", "bytemuck", @@ -5626,7 +5626,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "accesskit", "ahash", @@ -5645,7 +5645,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "ahash", "bytemuck", @@ -5664,7 +5664,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "block2 0.6.2", "bytemuck", @@ -5684,7 +5684,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "bytemuck", "egui", @@ -5697,7 +5697,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "eframe", "egui", @@ -5774,7 +5774,7 @@ dependencies = [ [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "bytemuck", ] @@ -5847,7 +5847,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" dependencies = [ "ahash", "bytemuck", @@ -5873,7 +5873,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" [[package]] name = "equator" @@ -15205,19 +15205,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" [[patch.unused]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e#bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" +source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" diff --git a/Cargo.toml b/Cargo.toml index a71f6358de..c781e85120 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -316,20 +316,20 @@ hayro-postscript = { path = "vendor/hayro-postscript" } linesweeper = { path = "vendor/linesweeper" } vello_common = { path = "vendor/vello_common" } vello_cpu = { path = "vendor/vello_cpu" } -ecolor = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -emath = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -epaint = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -eframe = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } -egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "bbfd6471ed43bc3d46bffbb6e1ef7f39d0528e6e" } +ecolor = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +emath = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +epaint = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +eframe = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # symphonia's FLAC decoder restores LPC samples as `residual + (prediction as i32)`. In a valid From 0bac50867b2c4977e492f436029ff0075a14dab5 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 00:12:07 +0000 Subject: [PATCH 14/56] Trial: a dock restored with a native float in a later pass of the first frame paints The windows kit's renderer shares one texture store between the windows, as eframe's does, applies each window's texture changes when it paints and panics on a change to a texture it has not allocated. A frame whose first pass asks for another and whose second shows a dock with a native float, as an app's start-up, paints its float's window without that panic. --- crates/ui-patterns/tests/it/docking/native.rs | 28 ++++++++++++++ crates/ui-test-kit/src/windows.rs | 37 +++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/crates/ui-patterns/tests/it/docking/native.rs b/crates/ui-patterns/tests/it/docking/native.rs index 740f54eced..206c0b1e0d 100644 --- a/crates/ui-patterns/tests/it/docking/native.rs +++ b/crates/ui-patterns/tests/it/docking/native.rs @@ -105,6 +105,34 @@ fn a_native_dock_window_is_moved_by_the_app_from_its_first_pass() { assert!(probe.0.iter().all(|known| *known), "every pass of the window knows the app moves it: {:?}", probe.0); } +/// A dock restored with a native float in the second pass of the first frame, as an app that lays out its window in +/// the first pass and shows its dock in the next: the float's window paints during the frame's run, before the run's +/// output reaches the renderer the windows share, so its texture changes must come after the first pass's +/// allocations (the font atlas). The kit's renderer panics on a change to a texture it has not allocated. +#[trial] +fn a_dock_restored_with_a_native_float_in_a_later_pass_of_the_first_frame_paints() { + let windows = Windows::new(); + windows.root_info(info(true, ROOT_AT)); + windows.child_info(info(true, PALETTE_AT)); + let mut window = float(); + window.native = Some(Placement::new(PALETTE_AT.size().into(), 1.0)); + let mut workspace = Arc::new(Workspace::new(Layout::new(None, vec![window]))); + let mut probe = MoveProbe(Vec::new()); + let mut passes = 0; + windows.frame(vec![], vec![], |ui| { + passes += 1; + if passes == 1 { + ui.label("Starting"); + ui.ctx().request_discard("the dock shows in the next pass"); + return; + } + let config = DockConfig::default().native_windows(true); + let _ = DockArea::new("Native dock", Bind::bound(&mut workspace), &Specs::with(Permissions::ALL), &mut probe, config).show(ui); + }); + assert_eq!(passes, 2, "the first frame runs two passes"); + assert!(!probe.0.is_empty(), "the float's window runs its pass in the second one"); +} + /// The dock records a move the OS made to its native window, and nothing while the OS reports what the model holds. #[trial] fn the_dock_records_where_the_os_put_its_native_window() { diff --git a/crates/ui-test-kit/src/windows.rs b/crates/ui-test-kit/src/windows.rs index cbe93a3eae..e6514eb36d 100644 --- a/crates/ui-test-kit/src/windows.rs +++ b/crates/ui-test-kit/src/windows.rs @@ -1,6 +1,9 @@ //! A frame driver for trials with child viewports: the context opens OS viewports (not embedded), and a renderer //! like eframe's runs each child's pass nested inside its parent's UI closure, with events and window facts the trial -//! gives it. As an integration does, the window gets what changed in its builder as commands before the pass. +//! gives it. As an integration does, the window gets what changed in its builder as commands before the pass. The +//! windows share one texture store, as eframe's renderer: each pass's texture changes reach it when the window paints +//! (a child as soon as its pass ends, the root after its run), and a change to a texture the store has not allocated +//! panics, as egui-wgpu's renderer does. use craft_host::target::ShellInfo; use craft_ui::runtime::InstallSpec; @@ -10,8 +13,9 @@ use craft_ui::testing::Frames; use craft_ui::testing::access::{AccessTree, tree_of}; use craft_ui::testing::windows::FakeSystem; use craft_ui::testing::windows::{FullOutput, RawInput}; -use egui::{Context, Event, HoveredFile, Pos2, Rect, Ui, Vec2, ViewportBuilder, ViewportCommand, ViewportId, ViewportInfo}; +use egui::{Context, Event, HoveredFile, Pos2, Rect, TextureId, TexturesDelta, Ui, Vec2, ViewportBuilder, ViewportCommand, ViewportId, ViewportInfo}; use std::cell::{Cell, RefCell}; +use std::collections::HashSet; use std::sync::Arc; const ROOT_SIZE: Vec2 = Vec2::new(800.0, 600.0); @@ -43,6 +47,30 @@ thread_local! { /// Each child's builder as its window has it: a later builder patches it, and what changed goes to the window as /// commands, as an integration sends them. static BUILDERS: RefCell> = const { RefCell::new(Vec::new()) }; + /// The textures the shared renderer has allocated. + static TEXTURES: RefCell> = RefCell::new(HashSet::new()); +} + +/// Paints `viewport`'s texture changes into the shared store, in order. +fn paint_textures(viewport: ViewportId, delta: &mut TexturesDelta) { + TEXTURES.with(|textures| { + let mut textures = textures.borrow_mut(); + for (id, images) in delta.set.drain() { + for image in images { + if image.is_whole() { + textures.insert(id); + } else { + assert!( + textures.contains(&id), + "{viewport:?} updates {id:?}, which the renderer has not allocated yet: an earlier change to it has not reached the renderer" + ); + } + } + } + for id in delta.free.drain() { + textures.remove(&id); + } + }); } /// Seconds between two frames. @@ -199,7 +227,7 @@ fn render_child(ctx: &Context, viewport: egui::ImmediateViewport<'_>) { input.viewports = all_viewports(); input.viewports.insert(viewport.ids.this, info); let mut output = ctx.run_ui(input, |ui| callback(ui)); - output.textures_delta.clear(); + paint_textures(viewport.ids.this, &mut output.textures_delta); keep_commands(&output); keep_tree(&mut output, viewport.ids.this); } @@ -310,6 +338,7 @@ impl Windows { CHILDREN.with(|children| children.borrow_mut().clear()); COMMANDS.with(|kept| kept.borrow_mut().clear()); BUILDERS.with(|kept| kept.borrow_mut().clear()); + TEXTURES.with(|textures| textures.borrow_mut().clear()); NOW.with(|now| now.set(0.0)); Windows { ctx, @@ -400,7 +429,7 @@ impl Windows { CHILDREN.with(|children| children.borrow_mut().retain(shown)); OWN_INFO.with(|own| own.borrow_mut().retain(|(id, _)| shown(id))); BUILDERS.with(|kept| kept.borrow_mut().retain(|(id, _)| shown(id))); - output.textures_delta.clear(); + paint_textures(ViewportId::ROOT, &mut output.textures_delta); keep_commands(&output); keep_tree(&mut output, ViewportId::ROOT); let builders = output.viewport_output.iter().map(|(id, viewport)| (*id, viewport.builder.clone())).collect(); From 1f14633b7443bd3be317592c1e618fb9754c8daf Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 00:36:38 +0000 Subject: [PATCH 15/56] Pin egui to aiongg/egui ime-pending-reset (f678ecb71): Memory lists the pass's focus candidates and reports the focused widget's event filter --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 28 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9cf603b2e9..90632bb705 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5535,7 +5535,7 @@ dependencies = [ [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "bytemuck", "emath", @@ -5591,7 +5591,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "ahash", "bytemuck", @@ -5626,7 +5626,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "accesskit", "ahash", @@ -5645,7 +5645,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "ahash", "bytemuck", @@ -5664,7 +5664,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "block2 0.6.2", "bytemuck", @@ -5684,7 +5684,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "bytemuck", "egui", @@ -5697,7 +5697,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "eframe", "egui", @@ -5774,7 +5774,7 @@ dependencies = [ [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "bytemuck", ] @@ -5847,7 +5847,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" dependencies = [ "ahash", "bytemuck", @@ -5873,7 +5873,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" [[package]] name = "equator" @@ -15205,19 +15205,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" [[patch.unused]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944#c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" +source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" diff --git a/Cargo.toml b/Cargo.toml index c781e85120..0e01b72d1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -316,20 +316,20 @@ hayro-postscript = { path = "vendor/hayro-postscript" } linesweeper = { path = "vendor/linesweeper" } vello_common = { path = "vendor/vello_common" } vello_cpu = { path = "vendor/vello_cpu" } -ecolor = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -emath = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -epaint = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -eframe = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } -egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "c7a2f6af5dc9d4c3c5c2a40b077ab30a66c90944" } +ecolor = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +emath = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +epaint = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +eframe = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # symphonia's FLAC decoder restores LPC samples as `residual + (prediction as i32)`. In a valid From c933a90624b7a5669df284cfdf53726694636bba Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 00:36:38 +0000 Subject: [PATCH 16/56] Every focusable egui widget the app draws is a stop of the window's one Tab order The focus service takes egui's focus candidates of the pass (Memory::focus_candidates) at every order-dependent registration and at the end hook: each widget no component made becomes a stop of the app's own, where it was drawn among the framework's stops, a text stop for a TextEdit. Recorded views and lazy children replay them with their transcripts. A bare Tab is the framework's move unless an egui popup is open or the app's focused widget keeps Tab by its egui key filter. Removed: focus::host_stop and the separate egui-Tab path for windows without framework stops. The scrim absorber no longer takes key focus. --- crates/ui-contract/src/runtime/egui/areas.rs | 4 +- .../ui-contract/src/runtime/egui/fixture.rs | 7 + crates/ui-contract/src/runtime/egui/focus.rs | 17 +- crates/ui-contract/src/runtime/focus.rs | 144 +++++++++----- crates/ui-contract/src/runtime/focus/nav.rs | 11 +- crates/ui-contract/src/runtime/keys.rs | 3 - crates/ui-contract/src/runtime/keys/input.rs | 33 +-- .../src/testing/host_key_trials.rs | 188 +++++++++++++++--- .../ui-contract/src/testing/replay_trials.rs | 28 +++ docs/contract-api.md | 3 +- docs/craft-framework.md | 9 +- 11 files changed, 327 insertions(+), 120 deletions(-) diff --git a/crates/ui-contract/src/runtime/egui/areas.rs b/crates/ui-contract/src/runtime/egui/areas.rs index b307ea3d7b..107d48ea80 100644 --- a/crates/ui-contract/src/runtime/egui/areas.rs +++ b/crates/ui-contract/src/runtime/egui/areas.rs @@ -380,7 +380,9 @@ pub(crate) fn show_cover_layer(ctx: &Context, cover: CoverLayer) { sizing = ui.is_sizing_pass(); for rect in covered { ui.painter().rect_filled(rect, 0.0, scrim); - let absorber = ui.allocate_rect(rect, Sense::click_and_drag()); + // It absorbs presses and never takes key focus: a focusable egui widget no component made is a Tab stop + // of the app's own (`focus::take_app_widgets`). + let absorber = ui.allocate_rect(rect, Sense::CLICK | Sense::DRAG); crate::runtime::egui::widgets::note_widget(ui.ctx(), absorber.id); crate::runtime::egui::access::hide(ui.ctx(), absorber.id); } diff --git a/crates/ui-contract/src/runtime/egui/fixture.rs b/crates/ui-contract/src/runtime/egui/fixture.rs index 63be1d9b0d..138ff49b58 100644 --- a/crates/ui-contract/src/runtime/egui/fixture.rs +++ b/crates/ui-contract/src/runtime/egui/fixture.rs @@ -500,6 +500,13 @@ pub(crate) fn host_field(ui: &mut Ui, id: egui::Id, text: &mut String) -> Rect { ui.add(egui::TextEdit::singleline(text).id(id)).rect } +/// A host's own multi-line egui text field of `id` over `text` that locks focus, as a code editor of the app's own: +/// its egui key filter keeps Tab, which it types. +#[cfg(feature = "suite")] +pub(crate) fn host_code_field(ui: &mut Ui, id: egui::Id, text: &mut String) -> Rect { + ui.add(egui::TextEdit::multiline(text).id(id).lock_focus(true)).rect +} + /// A host's own text editor of `id` at `rect`, as a canvas text tool draws it: it reads the IME events from egui's /// input into `text` (a commit appends, a deletion before the caret removes characters from its end) and writes the /// pass's IME output, context generation 1. diff --git a/crates/ui-contract/src/runtime/egui/focus.rs b/crates/ui-contract/src/runtime/egui/focus.rs index f0f6b7fe54..0941e5d433 100644 --- a/crates/ui-contract/src/runtime/egui/focus.rs +++ b/crates/ui-contract/src/runtime/egui/focus.rs @@ -27,6 +27,17 @@ pub(crate) fn focused(ctx: &Context) -> Option { ctx.memory(|memory| memory.focused()) } +/// egui's focus candidates of the running pass from the `seen`th on (`Memory::focus_candidates`): the widgets +/// interested in key focus, in the order they registered. +pub(crate) fn candidates_since(ctx: &Context, seen: usize) -> Vec { + ctx.memory(|memory| memory.focus_candidates().get(seen..).map(<[_]>::to_vec).unwrap_or_default()) +} + +/// Whether the widget egui holds key focus on keeps Tab by its event filter (`Memory::focus_lock_filter`). +pub(crate) fn focused_keeps_tab(ctx: &Context) -> bool { + ctx.memory(|memory| memory.focus_lock_filter()).is_some_and(|filter| filter.tab) +} + /// Whether egui holds a label text selection, which egui copies on a copy or cut event. pub(crate) fn label_selection(ctx: &Context) -> bool { ctx.with_plugin::(|state| state.has_selection()).unwrap_or(false) @@ -57,9 +68,9 @@ pub(crate) fn surrender(ctx: &Context, id: Id) { } /// H7: egui's begin pass set a focus direction from an unmodified arrow or the Tab it kept. The focus service clears -/// it before any component runs unless egui focus is on an app's own widget (`FocusedRecord::host_focus`), or the -/// key stage left a Tab to egui in a window with no focus stop, and the service moves no focus in the pass: egui would -/// otherwise move focus off a framework stop that the same arrow reaches as an intent. +/// it before any component runs unless egui focus is on an app's own widget (`FocusedRecord::host_focus`) and the +/// service moves no focus in the pass: egui would otherwise move focus off a framework stop that the same arrow +/// reaches as an intent. pub(crate) fn clear_directional_focus(ctx: &Context) { ctx.memory_mut(|memory| memory.move_focus(FocusDirection::None)); } diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 7b61bf93b5..f17212669f 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -76,7 +76,8 @@ pub(crate) struct FocusedRecord { pub(crate) claims: Vec, /// The component of the focused stop: only its state-dependent claims hold. pub(crate) focused: Option, - /// The focused stop is the app's own egui widget (`Stop::host`): it reads the presses it claims from egui. + /// The focused stop is the app's own egui widget (`Stop::host`: one of the app's focusable egui widgets, or its + /// canvas): it reads the presses it claims from egui. pub(crate) host: bool, /// The arena root of the focused stop when the stop is a non-text member of an arena (a part of a canvas's frame /// overlay): the root's state-dependent claims hold too, so a canvas tool's keys work with a part focused. @@ -96,12 +97,18 @@ pub(crate) struct FocusedRecord { /// focused. pub(crate) canvas: Option, /// egui focus is on a widget no framework component made, or an egui popup is open, and no framework press or - /// drag is captured: an app's own focused widget or popup keeps the keys a focused component keeps (Tab, Escape, - /// the plain Enter, the clipboard events), and no window intent comes of them. Written by the end hook after its - /// focus moves. + /// drag is captured: an app's own focused widget or popup keeps the keys a focused component keeps (Escape, the + /// plain Enter, the clipboard events), and no window intent comes of them. Written by the end hook after its focus + /// moves. pub(crate) foreign: bool, - /// egui focus is on a widget no framework component made, and no framework press or drag is captured: egui - /// moves focus among the app's own widgets with the arrows and the Tab it keeps. Written by the end hook. + /// A bare Tab is egui's: an egui popup is open (`foreign`), or egui focus is on the app's own widget and its egui + /// key filter keeps Tab (a multi-line text edit that locks focus, a code editor). Any other bare Tab is the + /// framework's move over its one order, which holds the app's widgets (`take_app_widgets`). Written by the end + /// hook. + pub(crate) tab_in_egui: bool, + /// egui focus is on a widget no framework component made (`State::app_widget`: its stop of the app's own does not + /// count, the app's canvas does), and no framework press or drag is captured: egui moves focus among the app's own + /// widgets with the arrows. Written by the end hook. pub(crate) host_focus: bool, /// `host_focus`, on a text edit the app drew itself. Written by the end hook. pub(crate) host_text: bool, @@ -182,8 +189,9 @@ pub(crate) struct State { /// The stop focus last moved onto, the frame whose passes see the move, and what moved it there. It stays until focus /// moves again: while the stop keeps the focus, it is how the stop got it (`origin`). pub(super) arrived: Option<(u64, StopKey, FocusOrigin)>, - /// The running pass's begin hook left a Tab to egui (`NavKeys::tab_to_egui`); its end hook takes it. - pub(super) tab_to_egui: bool, + /// How many of egui's focus candidates of the running pass (`Memory::focus_candidates`) `take_app_widgets` has + /// read. + pub(super) candidates_seen: usize, } fn viewport(ctx: &Context) -> ViewportId { @@ -219,26 +227,78 @@ pub(crate) fn apply(ctx: &Context, acts: Vec) { } } -/// Registers a stop of the running pass in the innermost open scope, in registration order. +/// Registers a stop of the running pass in the innermost open scope, in registration order: after the app's own +/// widgets drawn before it (`take_app_widgets`). The app's own widget `stop` names (`host_canvas`) takes the place of +/// its stop as one of those widgets, if the pass took it already. pub(crate) fn register_stop(ctx: &Context, stop: Stop) { + take_app_widgets(ctx, Some(stop.root)); let acts = with(ctx, |state| { - let scope = state.open.last().map(|(id, _)| *id); - state.stop_ids.insert(stop.id); + if stop.host + && let Some(rec) = state.stops.iter_mut().find(|rec| rec.stop.host && rec.stop.id == stop.id) + { + rec.stop = stop; + return Vec::new(); + } + state.push_stop(stop) + }); + apply(ctx, acts); +} + +impl State { + /// Appends `stop` to the running pass's stops in the innermost open scope; it takes the focus a request of the pass + /// awaits for it. + fn push_stop(&mut self, stop: Stop) -> Vec { + let scope = self.open.last().map(|(id, _)| *id); + self.stop_ids.insert(stop.id); let rec = StopRec { stop, scope, group_position: false }; - let acts = if state.awaited == Some(rec.stop.key()) { - state.awaited = None; - state.focus_stop(rec.clone()) + let acts = if self.awaited == Some(rec.stop.key()) { + self.awaited = None; + self.focus_stop(rec.clone()) } else { Vec::new() }; - state.stops.push(rec); + self.stops.push(rec); + acts + } +} + +/// Registers the app's own egui widgets that egui listed as focus candidates since the last take of the running pass +/// (`Memory::focus_candidates`, in the order they registered with egui), each as a stop of the app's own +/// (`Stop::host`) with the keys of a pointer control, a text stop for a text edit: every focusable egui widget the app +/// draws is a Tab and F6 stop among the framework's, where it was drawn. A widget a component made is none: its +/// component registers its stops (`pointer::made_by_component`, or the root of a stop of the pass), and so is +/// `except`, the root of the stop being registered. Every registration that depends on order takes them first, and +/// the end hook takes the last ones, so a stop range (`mark`, `stop_count`) holds the app's widgets drawn in it. +fn take_app_widgets(ctx: &Context, except: Option) { + let seen = with(ctx, |state| state.candidates_seen); + let fresh = egui_focus::candidates_since(ctx, seen); + if fresh.is_empty() { + return; + } + let viewport = viewport(ctx); + let app: Vec = fresh + .iter() + .filter(|candidate| Some(candidate.id) != except && !crate::runtime::pointer::made_by_component(ctx, viewport, candidate.id)) + .copied() + .collect(); + let acts = with(ctx, |state| { + state.candidates_seen = seen + fresh.len(); + let mut acts = Vec::new(); + for candidate in app { + if state.stops.iter().any(|rec| rec.stop.root == candidate.id) { + continue; + } + let stop = Stop::new(candidate.id, KeyUse::of(craft_behavior::Input::Pointer)).host(); + acts.extend(state.push_stop(if candidate.text { stop.text() } else { stop })); + } acts }); apply(ctx, acts); } -/// Registers the app's own egui widget `id`, drawn in the running pass, as its window's document canvas: a focus stop -/// with `keys`, marked as the canvas (`KeyUse::chrome_key`). The window then shows a document, so with +/// Registers the app's own egui widget `id`, drawn in the running pass, as its window's document canvas: its focus stop +/// takes `keys` and is marked as the canvas (`KeyUse::chrome_key`), in place of the stop it has as one of the app's +/// focusable egui widgets, at the same place in Tab order. The window then shows a document, so with /// `RootEnv::tab_toggles_chrome` a bare Tab with nothing focused toggles its panels, as with a framework canvas. Focus /// reaches the canvas by Tab, F6, `request` or the app's own egui focus request; while it has focus, Tab and the arrows /// route as `keys` says (the arrows as nudges, Tab moving focus on or toggling the panels unless it keeps Tab). `keys` @@ -255,16 +315,6 @@ pub fn host_canvas(ctx: &Context, id: Id, keys: KeyUse) { register_stop(ctx, Stop::new(id, keys.with_chrome_key(true)).host()); } -/// Registers the app's own egui widget `id`, drawn in the running pass, as a focus stop with `keys`, in the window's one -/// Tab order: Tab and F6 reach it among the framework's stops in the order the pass registers them, so call it where -/// the widget is drawn, each pass it shows. The widget must take egui focus under `id`. While it has the focus it reads -/// its keys from egui as any focused widget of the app's own does (Escape, Enter, the keys `keys` keeps, and its -/// claims), and Tab moves on from it as `keys` says. It never marks the window as showing a document: the document -/// canvas registers with [`host_canvas`]. -pub fn host_stop(ctx: &Context, id: Id, keys: KeyUse) { - register_stop(ctx, Stop::new(id, keys.with_chrome_key(false)).host()); -} - /// The stop of the document canvas `viewport` registered in its last pass (`KeyUse::chrome_key`), framework or the /// app's own (`Stop::host`). Read before the begin hook rotates the registrations, by the input hook and the begin /// hook's Tab moves. @@ -290,19 +340,9 @@ pub(crate) fn is_canvas_member(ctx: &Context, rec: &StopRec) -> bool { }) } -/// Whether a bare Tab in `viewport` is egui's own focus move: the window registered no framework stop in its last pass, -/// only stops of the app's own egui widgets (`Stop::host`: `host_canvas`, `host_stop`) if any, which egui's Tab order -/// holds with the app's other widgets; and egui held no focus at the end of that pass, or held it on one of those -/// stops. A framework move would reach the host stops alone. With a framework stop in the window, Tab is the -/// framework's move over its one order, which holds the host stops beside the framework's. Read by the input hook, before the begin hook rotates the registrations. -pub(crate) fn tab_is_egui_s(ctx: &Context, viewport: ViewportId) -> bool { - with_viewport(ctx, viewport, |state| { - state.stops.iter().all(|rec| rec.stop.host) && state.focus_now.is_none_or(|id| state.stops.iter().any(|rec| rec.stop.root == id)) - }) -} - /// How many stops the running pass has registered so far. pub(crate) fn stop_count(ctx: &Context) -> usize { + take_app_widgets(ctx, None); with(ctx, |state| state.stops.len()) } @@ -388,6 +428,7 @@ impl Eq for Transcript {} /// Where the running pass's registrations stand. pub(crate) fn mark(ctx: &Context) -> Mark { + take_app_widgets(ctx, None); with(ctx, |state| Mark { stops: state.stops.len(), scopes: state.scope_order.len(), @@ -398,6 +439,7 @@ pub(crate) fn mark(ctx: &Context) -> Mark { /// What the running pass registered since `mark`, which a run that closed every scope it opened left. pub(crate) fn transcript(ctx: &Context, mark: Mark) -> Transcript { + take_app_widgets(ctx, None); with(ctx, |state| { let stops = state.stops.get(mark.stops..).unwrap_or_default().to_vec(); let scopes = state.scope_order.get(mark.scopes..).unwrap_or_default(); @@ -416,6 +458,7 @@ pub(crate) fn transcript(ctx: &Context, mark: Mark) -> Transcript { /// Registers `transcript` again in the running pass, in place of the run that left it: in the innermost open scope, /// as the run would have. A replayed scope is no new scope: it moves no focus when it shows again. pub(crate) fn replay(ctx: &Context, transcript: &Transcript) { + take_app_widgets(ctx, None); let frame = crate::runtime::egui::pass::frame_nr(ctx, viewport(ctx)); let focused = egui_focus::focused(ctx); with(ctx, |state| { @@ -456,6 +499,7 @@ pub(crate) fn has_reachable_stop(ctx: &Context, id: Id) -> bool { /// Where a request for the component `id` goes when it has no stop of its own: the first stop registered since /// `from` (a `stop_count`), which a component inside it holds. pub(crate) fn first_stop_inside(ctx: &Context, id: Id, from: usize) -> Option { + take_app_widgets(ctx, None); with(ctx, |state| { if state.stop_ids.contains(&id) { return None; @@ -489,6 +533,7 @@ pub(crate) fn focus_in(ctx: &Context, range: std::ops::Range) -> bool { /// order, then the footer's, then the header's, and initial focus goes to the first of them, not to the title /// row's close action. The first mark of a pass stands. pub(crate) fn begin_body(ctx: &Context) { + take_app_widgets(ctx, None); with(ctx, |state| { if let Some((scope, _)) = state.open.last().copied() { let at = state.stops.len(); @@ -552,6 +597,7 @@ pub(crate) fn push_scope_from( closing: bool, entering: Option, ) { + take_app_widgets(ctx, None); let focused = egui_focus::focused(ctx); with(ctx, |state| { let parent = state.open.last().map(|(parent, _)| *parent); @@ -583,6 +629,7 @@ pub fn open_scope(ctx: &Context) -> Option { /// Closes the innermost open scope. A scope pushed for the first time (or again after a gap of a frame) /// moves focus to its initial stop, in this pass. pub(crate) fn pop_scope(ctx: &Context) { + take_app_widgets(ctx, None); let frame = crate::runtime::egui::pass::frame_nr(ctx, viewport(ctx)); let acts = with(ctx, |state| { nav::order_regions(state); @@ -1014,17 +1061,15 @@ pub(crate) fn begin(ctx: &Context, tab_all_controls: bool, dialog_tab: TabReach) dialog_tab, frame: crate::runtime::egui::pass::frame_nr(ctx, viewport(ctx)), }; - let tab_to_egui = input.nav.tab_to_egui; let (acts, announcements, host_focus) = with(ctx, |state| { state.awaited = None; let host_focus = state.record.host_focus; - state.tab_to_egui = tab_to_egui; let (acts, announcements) = nav::begin(state, input); (acts, announcements, host_focus) }); - // egui's direction moves focus from the widget it holds, an app's own, or with a Tab the key stage left to egui - // (from nothing or a host stop); never in a pass whose focus the framework moves. - if !(host_focus || tab_to_egui) || !acts.is_empty() { + // egui's direction (its arrows, a Tab the key stage left to egui) moves focus from the widget it holds when that is + // an app's own; never in a pass whose focus the framework moves. + if !host_focus || !acts.is_empty() { egui_focus::clear_directional_focus(ctx); } apply(ctx, acts); @@ -1037,13 +1082,7 @@ pub(crate) fn begin(ctx: &Context, tab_all_controls: bool, dialog_tab: TabReach) /// moves it off a stop that was not registered, and records what the next input hook reads. pub(crate) fn end(ctx: &Context) { let viewport = viewport(ctx); - // A Tab left to egui moves egui focus into the app's own widgets only: a component's egui widget takes focus - // through its stop, and a component that registered none (a disabled one) takes none. - if with(ctx, |state| std::mem::take(&mut state.tab_to_egui)) - && let Some(id) = egui_focus::focused(ctx).filter(|id| crate::runtime::pointer::made_by_component(ctx, viewport, *id)) - { - egui_focus::surrender(ctx, id); - } + take_app_widgets(ctx, None); let app_widget = |id: Id| { let made = crate::runtime::pointer::made_by_component(ctx, viewport, id); with(ctx, |state| state.app_widget(id, made)) @@ -1056,7 +1095,9 @@ pub(crate) fn end(ctx: &Context) { // Escape over a captured framework press or drag cancels it (`frame::begin_pass`), whatever egui has focused. let captured = crate::runtime::pointer::press_captured(ctx) || crate::runtime::drag::running(ctx); let host_focus = !captured && with(ctx, |state| state.focus_now).is_some_and(app_widget); - let foreign = host_focus || (!captured && crate::runtime::egui::areas::popup_open(ctx)); + let popup = !captured && crate::runtime::egui::areas::popup_open(ctx); + let foreign = host_focus || popup; + let tab_in_egui = popup || (host_focus && egui_focus::focused_keeps_tab(ctx)); let label_selection = egui_focus::label_selection(ctx); let host_text = host_focus && ctx.text_edit_focused(); // A modal layer keeps the canvas's claims from it, as it keeps the arrows (`overlay::end_pass` ran before). @@ -1064,6 +1105,7 @@ pub(crate) fn end(ctx: &Context) { with(ctx, |state| { state.record.canvas = state.record.canvas.filter(|_| !modal); state.record.foreign = foreign; + state.record.tab_in_egui = tab_in_egui; state.record.host_focus = host_focus; state.record.host_text = host_text; state.record.label_selection = label_selection; diff --git a/crates/ui-contract/src/runtime/focus/nav.rs b/crates/ui-contract/src/runtime/focus/nav.rs index 58924165b3..1591f6b7fd 100644 --- a/crates/ui-contract/src/runtime/focus/nav.rs +++ b/crates/ui-contract/src/runtime/focus/nav.rs @@ -193,6 +193,7 @@ impl State { self.body_from.clear(); self.entered = false; self.asked = false; + self.candidates_seen = 0; } /// The registrations of last pass, which Tab and the arrows move over. @@ -228,10 +229,13 @@ impl State { .or_else(|| self.stops.iter().chain(&self.last_stops).find(|rec| rec.stop.root == root).cloned()) } - /// Whether `id`, holding egui focus, is an app's own widget: no stop's root and, as `made` says, no widget a - /// component made (`pointer::made_by_component`). + /// Whether `id`, holding egui focus, is an app's own widget: as `made` says, no widget a component made + /// (`pointer::made_by_component`), and the root of no stop but the one every focusable egui widget of the app has + /// (`Stop::host` with default keys). The app's canvas (`host_canvas`, `KeyUse::chrome_key`) is none: its declared + /// keys route as a framework stop's do, so egui's arrows and Tab never move focus off it. pub(super) fn app_widget(&self, id: Id, made: bool) -> bool { - !made && self.find_stop((id, None)).is_none() && !self.stops.iter().chain(&self.last_stops).any(|rec| rec.stop.root == id) + let automatic = |rec: &StopRec| rec.stop.host && !rec.stop.keys.chrome_key; + !made && !self.stops.iter().chain(&self.last_stops).any(|rec| !automatic(rec) && (rec.stop.root == id || rec.stop.key() == (id, None))) } /// Moves focus to `rec` and asks the enclosing scroll owner to reveal it: the egui widget is its root, and the stop @@ -873,6 +877,7 @@ pub(super) fn end(state: &mut State, focused: Option, on_app_widget: bool, f menu_bar_by_claim: std::mem::take(&mut state.menu_bar_by_claim), canvas: if stop.is_none() { state.stops.iter().find(|rec| rec.stop.keys.chrome_key).map(|rec| rec.stop.id) } else { None }, foreign: false, + tab_in_egui: false, host_focus: false, host_text: false, label_selection: false, diff --git a/crates/ui-contract/src/runtime/keys.rs b/crates/ui-contract/src/runtime/keys.rs index a09f13fb0a..ba7b0644fc 100644 --- a/crates/ui-contract/src/runtime/keys.rs +++ b/crates/ui-contract/src/runtime/keys.rs @@ -66,9 +66,6 @@ pub enum MenuKey { pub(crate) struct NavKeys { pub(crate) tabs: Vec, pub(crate) panes: Vec, - /// The input hook left a bare Tab in egui's input: nothing has the focus and the window registered no focus stop, - /// so the framework has nothing to move to and egui moves its own focus. - pub(crate) tab_to_egui: bool, } struct Press { diff --git a/crates/ui-contract/src/runtime/keys/input.rs b/crates/ui-contract/src/runtime/keys/input.rs index ce2d66f9b3..4a1177e2a1 100644 --- a/crates/ui-contract/src/runtime/keys/input.rs +++ b/crates/ui-contract/src/runtime/keys/input.rs @@ -42,9 +42,12 @@ struct Strip<'a> { holds_drafts: bool, /// A dialog keeps a canvas open and Space belongs to it: the press is the canvas's momentary command chord. canvas_space: bool, - /// An app's own egui widget or popup has the focus (`FocusedRecord::foreign`): Tab, Escape, the plain Enter and the + /// An app's own egui widget or popup has the focus (`FocusedRecord::foreign`): Escape, the plain Enter and the /// clipboard events are its own, and no window intent comes of them. foreign: bool, + /// A bare Tab is egui's (`FocusedRecord::tab_in_egui`): an app's own popup is open, or the app's own focused widget + /// keeps Tab by its egui key filter. + tab_in_egui: bool, /// The focused stop is the app's own egui widget (`Stop::host`, `FocusedRecord::host`), which reads its keys from /// egui: its Escape stays there, as an app's own focused widget's does. Tab and the arrows follow its `KeyUse`, as /// the framework's navigation reads it. @@ -52,12 +55,6 @@ struct Strip<'a> { /// The edit set whose clipboard events and edit chords stay in egui's input: the focused stop's when it is the /// app's own widget (`host`), else the window canvas's with nothing focused (`target_canvas`). egui_edits: EditSet, - /// A bare Tab that the focus does not keep is egui's own move (`focus::tab_is_egui_s`): the window registered no - /// framework stop in its last pass, only the app's own widgets' (`Stop::host`) if any, and nothing has the focus or - /// one of those stops has it. egui's Tab order holds those stops and the app's other widgets; a framework move - /// would reach the stops alone. Focus on a component's widget without a stop is focus: egui would take a Tab from - /// it as a move to the next widget it shows, in a later pass. A Tab that toggles the chrome stays the framework's. - egui_tab: bool, /// egui holds a label text selection, which a copy or cut event copies. label_selection: bool, /// A tool host claimed the lone Alt tap: it goes to the claimer on every OS, not to the menu bar. @@ -375,10 +372,12 @@ impl Strip<'_> { PressUse::Edit(*command) } else if key == Key::Space && self.canvas_space { PressUse::CanvasSpace - } else if (self.foreign && (bare_tab || escape || plain_enter)) || (self.host && escape && !self.press_captured) || egui_edit { + } else if (self.foreign && (escape || plain_enter)) + || (bare_tab && self.tab_in_egui) + || (self.host && escape && !self.press_captured) + || egui_edit + { PressUse::Egui - } else if bare_tab && self.egui_tab && !self.keeps_tab { - PressUse::TabToEgui } else if bare_tab && !self.keeps_tab { PressUse::Tab } else if ctrl_tab { @@ -439,12 +438,6 @@ impl Strip<'_> { // the key from egui; the runtime routes nothing for it, so no shortcut toggles the chrome or fires an edit // command with it either. PressUse::Egui => true, - PressUse::TabToEgui => { - // egui moves its own focus with it, from nothing focused or a host stop through the app's own widgets - // (`focus::begin`). - batch.nav.tab_to_egui = true; - true - } PressUse::Tab => { batch.tabs.push(TabPress { input: *input, repeat, at, place: batch.place }); false @@ -534,8 +527,6 @@ enum PressUse { CanvasSpace, /// The app's own widget or popup, or the canvas with nothing focused, reads the key from egui. Egui, - /// A bare Tab egui moves its own focus with, through the app's own widgets. - TabToEgui, /// A bare Tab: a focus move or a chrome toggle, which `take_nav` decides. Tab, /// The page switch of the focused stop. @@ -666,10 +657,6 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec; @@ -699,9 +686,9 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec (Option, bool) { (egui_focused(&frames.ctx), reached) } +/// Tab is the framework's move whatever the window holds: from nothing focused it reaches the app's own widgets as its +/// stops, and never egui's input. A component's widget that registered no stop is no stop of the app's own. #[trial] -fn tab_from_nothing_focused_in_a_window_without_stops_moves_egui_focus() { +fn tab_from_nothing_reaches_the_app_s_widgets_as_the_framework_s_move() { let (first, last) = (Some(named_id("host first")), Some(named_id("host last"))); - assert_eq!(tab_from_nothing(Before::Nothing, false), (first, true), "Tab gives egui focus to the first host button"); - assert_eq!(tab_from_nothing(Before::Nothing, true), (last, true), "Shift+Tab to the last"); - assert_eq!(tab_from_nothing(Before::Stop, false), (Some(named_id("button")), false), "with a framework stop, Tab is the framework's move"); - assert_eq!(tab_from_nothing(Before::Unstopped, false), (None, true), "egui's Tab gives no focus to a component's widget without a stop"); - let (focused, reached) = tab_from_nothing(Before::FocusedUnstopped, false); - assert!(focused.is_some() && focused != first && !reached, "egui focus on that widget is focus: the Tab is not egui's and moves nothing"); + assert_eq!(tab_from_nothing(Before::Nothing, false), (first, false), "Tab focuses the first host button"); + assert_eq!(tab_from_nothing(Before::Nothing, true), (last, false), "Shift+Tab the last"); + assert_eq!(tab_from_nothing(Before::Stop, false), (Some(named_id("button")), false), "the framework stop drawn first comes first"); + assert_eq!(tab_from_nothing(Before::Unstopped, false), (first, false), "a component's widget without a stop gets no focus"); + assert_eq!(tab_from_nothing(Before::FocusedUnstopped, false), (first, false), "from that widget holding focus, Tab goes to the first stop"); } -/// A window with a framework stop, two of the app's own buttons registered as host stops and the app's canvas, which -/// keeps Tab, unfocused: Tab from nothing is the framework's move over its one order, which holds the app's buttons -/// beside the framework's stop. The unfocused canvas does not keep the Tab; it is the last entry, and once Tab focuses -/// it, it keeps Tab. +/// A window with a framework stop, two of the app's own buttons and the app's canvas, which keeps Tab, unfocused: Tab +/// from nothing is the framework's move over its one order, which holds the app's buttons beside the framework's +/// stop. The unfocused canvas does not keep the Tab; it is the last entry, and once Tab focuses it, it keeps Tab. #[trial] -fn tab_from_nothing_goes_through_the_framework_order_with_the_app_s_host_stops() { +fn tab_from_nothing_goes_through_the_framework_order_with_the_app_s_widgets() { let (stop, first, second, canvas) = (named_id("button"), named_id("host first"), named_id("host second"), named_id("host canvas")); let reached = Rc::new(Cell::new(false)); let seen_tab = Rc::clone(&reached); @@ -524,7 +525,6 @@ fn tab_from_nothing_goes_through_the_framework_order_with_the_app_s_host_stops() register_stop(ui.ctx(), Stop::new(stop, KeyUse::of(Input::Pointer))); for (id, x) in [(first, 300.0), (second, 420.0)] { fixture::host_button(ui, id, Rect::from_min_size(Pos2::new(x, 300.0), egui::vec2(80.0, 30.0))); - host_stop(ui.ctx(), id, KeyUse::of(Input::Pointer)); } widget(ui, canvas); host_canvas(ui.ctx(), canvas, KeyUse::CANVAS.with_keep(KeepKeys::Tab)); @@ -544,10 +544,11 @@ fn tab_from_nothing_goes_through_the_framework_order_with_the_app_s_host_stops() assert_eq!(tab(&mut frames), (Some(canvas), true), "the focused canvas keeps Tab and reads it from egui"); } -/// A window whose only stop is the app's own canvas, between two of the app's own buttons: a bare Tab moves egui -/// focus through egui's order, from nothing focused and from the canvas alike, and a canvas that keeps Tab keeps it. +/// A window of the app's own canvas between two of the app's own buttons, with no framework stop: a bare Tab moves +/// focus through them in the order the pass drew them, from nothing focused and from the canvas alike, and never +/// reaches egui; a canvas that keeps Tab keeps it. #[trial] -fn tab_moves_egui_focus_through_the_app_s_widgets_while_every_stop_is_a_host_stop() { +fn tab_moves_through_the_app_s_widgets_and_canvas_in_a_window_without_framework_stops() { let (first, canvas, last) = (named_id("host first"), named_id("host canvas"), named_id("host last")); let keeps = Rc::new(Cell::new(false)); let reached = Rc::new(Cell::new(false)); @@ -567,9 +568,9 @@ fn tab_moves_egui_focus_through_the_app_s_widgets_while_every_stop_is_a_host_sto frames.frame(Vec::new(), &mut *show); (egui_focused(&frames.ctx), reached.get()) }; - assert_eq!(tab(&mut frames, &mut show), (Some(first), true), "Tab from nothing gives egui focus to the first widget in egui's order"); - assert_eq!(tab(&mut frames, &mut show), (Some(canvas), true), "the next Tab reaches the canvas"); - assert_eq!(tab(&mut frames, &mut show), (Some(last), true), "Tab from the canvas moves on through egui's order"); + assert_eq!(tab(&mut frames, &mut show), (Some(first), false), "Tab from nothing focuses the first widget drawn"); + assert_eq!(tab(&mut frames, &mut show), (Some(canvas), false), "the next Tab reaches the canvas"); + assert_eq!(tab(&mut frames, &mut show), (Some(last), false), "Tab from the canvas moves on"); keeps.set(true); request(&frames.ctx, FocusTarget::Id(canvas)); frames.idle(2, &mut show); @@ -577,6 +578,135 @@ fn tab_moves_egui_focus_through_the_app_s_widgets_while_every_stop_is_a_host_sto assert_eq!(tab(&mut frames, &mut show), (Some(canvas), true), "a canvas that keeps Tab gets it from egui and keeps the focus"); } +/// The window the one-order trials show: the app's own button, a framework stop, the app's own single-line text field +/// inside a framework scope, a framework stop and the app's own button, in that order. +const MIXED: [&str; 5] = ["app first", "framework one", "app field", "framework two", "app last"]; + +fn mixed_window() -> impl FnMut(&mut Ui) { + let mut text = String::new(); + move |ui: &mut Ui| { + let [first, one, field, two, last] = MIXED.map(named_id); + fixture::host_button(ui, first, Rect::from_min_size(Pos2::new(20.0, 300.0), egui::vec2(80.0, 30.0))); + widget(ui, one); + register_stop(ui.ctx(), Stop::new(one, KeyUse::of(Input::Pointer))); + push_scope(ui.ctx(), named_id("group"), FocusPolicy::NONE, None); + fixture::host_field(ui, field, &mut text); + pop_scope(ui.ctx()); + widget(ui, two); + register_stop(ui.ctx(), Stop::new(two, KeyUse::of(Input::Pointer))); + fixture::host_button(ui, last, Rect::from_min_size(Pos2::new(420.0, 300.0), egui::vec2(80.0, 30.0))); + } +} + +/// A Tab press with `mods`, released in the same frame, and the frame after it: where egui focus is then. +fn tab_with(frames: &mut Frames, show: &mut impl FnMut(&mut Ui), mods: Modifiers) -> Option { + frames.frame(vec![key_press(Key::Tab, mods), key_release(Key::Tab, mods)], &mut *show); + frames.frame(Vec::new(), &mut *show); + egui_focused(&frames.ctx) +} + +/// Every focusable egui widget the app draws is a Tab stop of the window's one order, where the pass drew it among the +/// framework's stops, with no registration of its own: Tab from nothing visits the five in order and wraps, and +/// Shift+Tab walks back. +#[trial] +fn tab_reaches_the_app_s_egui_widgets_beside_the_framework_stops_in_registration_order() { + let mut show = mixed_window(); + let mut frames = Frames::new(); + frames.idle(2, &mut show); + let order = MIXED.map(|name| Some(named_id(name))); + let forward: Vec> = (0..6).map(|_| tab_with(&mut frames, &mut show, Modifiers::NONE)).collect(); + assert_eq!(forward, [&order[..], &order[..1]].concat(), "Tab visits the five in the order the pass drew them, then wraps"); + let back: Vec> = (0..5).map(|_| tab_with(&mut frames, &mut show, Modifiers::SHIFT)).collect(); + let reversed: Vec> = order.iter().rev().copied().collect(); + assert_eq!(back, reversed, "Shift+Tab walks back from the first, wrapping to the last"); +} + +/// F6 lands on the app's own widget in a pane whose only content it is. +#[trial] +fn f6_lands_on_an_app_widget_in_a_pane() { + let button = named_id("app pane button"); + let mut show = move |ui: &mut Ui| { + show_panes(ui); + push_scope(ui.ctx(), named_id("app pane"), FocusPolicy::PANE, Some(Arc::from("App"))); + fixture::host_button(ui, button, Rect::from_min_size(Pos2::new(420.0, 300.0), egui::vec2(80.0, 30.0))); + pop_scope(ui.ctx()); + }; + let mut frames = Frames::new(); + frames.idle(2, &mut show); + focus_stop(&mut frames, &mut show, named_id("right")); + let (focused, said) = pane_key(&mut frames, &mut show, Modifiers::NONE); + assert_eq!(focused, Some(button), "F6 from the right pane goes to the app's pane and its button"); + assert!(said.contains(&"App".to_owned()), "and announces the pane: {said:?}"); +} + +/// A focused multi-line text field of the app's own whose egui key filter keeps Tab (it locks focus) gets the Tab in +/// egui and types it; a single-line field of the app's own moves on to the next stop. +#[trial] +fn an_app_field_that_keeps_tab_types_it_and_a_single_line_field_tabs_on() { + let (code, line, after) = (named_id("app code"), named_id("app line"), named_id("framework after")); + let texts = Rc::new(RefCell::new((String::new(), String::new()))); + let shared = Rc::clone(&texts); + let mut show = move |ui: &mut Ui| { + let mut texts = shared.borrow_mut(); + let (code_text, line_text) = &mut *texts; + fixture::host_code_field(ui, code, code_text); + fixture::host_field(ui, line, line_text); + widget(ui, after); + register_stop(ui.ctx(), Stop::new(after, KeyUse::of(Input::Pointer))); + }; + let mut frames = Frames::new(); + frames.idle(2, &mut show); + fixture::host_focus(&frames.ctx, code); + frames.idle(2, &mut show); + assert_eq!(tab_with(&mut frames, &mut show, Modifiers::NONE), Some(code), "the field that keeps Tab keeps the focus"); + assert!(texts.borrow().0.contains('\t'), "and types the Tab: {:?}", texts.borrow().0); + fixture::host_focus(&frames.ctx, line); + frames.idle(2, &mut show); + assert_eq!(tab_with(&mut frames, &mut show, Modifiers::NONE), Some(after), "the single-line field's Tab moves on"); + assert_eq!(texts.borrow().1, "", "and types nothing"); +} + +/// Where Tab reaches only text fields (the Mac's default), it reaches the app's own text field and skips the app's +/// own buttons, as it skips the framework's. +#[trial] +fn tab_that_reaches_only_text_fields_reaches_the_app_s_field_and_skips_its_buttons() { + let mut show = mixed_window(); + let mut frames = Frames::new(); + crate::runtime::windows::set_os(&frames.ctx, craft_host::target::Os::Mac); + frames.root({ + let mut root = RootEnv::default(); + root.tab_all_controls = false; + root + }); + frames.idle(2, &mut show); + let field = Some(named_id("app field")); + assert_eq!(tab_with(&mut frames, &mut show, Modifiers::NONE), field, "Tab from nothing goes to the app's field"); + assert_eq!(tab_with(&mut frames, &mut show, Modifiers::NONE), field, "the field is the one entry: the next Tab stays on it"); +} + +/// While an app's own egui popup is open, Tab is egui's, as Escape is: the framework moves no focus with it. +#[trial] +fn an_open_app_popup_keeps_tab() { + let popup = named_id("host popup"); + let (host, mut base) = host_window(); + let mut show = move |ui: &mut Ui| { + base(ui); + areas::host_popup(ui, popup, Pos2::ZERO); + }; + let mut frames = Frames::new(); + frames.frame(Vec::new(), &mut show); + request(&frames.ctx, FocusTarget::Id(named_id("button"))); + frames.idle(2, &mut show); + areas::open_host_popup(&frames.ctx, popup); + frames.frame(Vec::new(), &mut show); + assert!(areas::host_popup_open(&frames.ctx, popup)); + seen(&host); + press_key(&mut frames, &mut show, Key::Tab); + assert_eq!(seen(&host).0, vec![Key::Tab], "the popup's Tab is egui's"); + frames.frame(Vec::new(), &mut show); + assert_eq!(egui_focused(&frames.ctx), Some(named_id("button")), "the framework moved no focus"); +} + #[trial] fn escape_ends_an_egui_drag_on_a_host_widget() { let area = named_id("host drag area"); diff --git a/crates/ui-contract/src/testing/replay_trials.rs b/crates/ui-contract/src/testing/replay_trials.rs index 30981b5812..2f3e2741c9 100644 --- a/crates/ui-contract/src/testing/replay_trials.rs +++ b/crates/ui-contract/src/testing/replay_trials.rs @@ -125,6 +125,34 @@ fn replayed_focus_stops_keep_their_own_target() { }); } +// The app's own egui widgets drawn inside a recorded view are stops of its transcript, and none drawn before it; the +// replay registers each once, where the view shows, after the widgets drawn before it. +#[trial] +fn a_recorded_view_holds_the_app_s_widgets_drawn_in_it_and_its_replay_registers_them_once() { + let mut frames = Frames::new(); + let [before, inside] = [fixture::named_id("app before"), fixture::named_id("app inside")]; + let rect = |x: f32| Rect::from_min_size(Pos2::new(x, 100.0), Vec2::new(80.0, 30.0)); + let mut recorded = None; + frames.frame(Vec::new(), |ui| { + let ctx = ui.ctx().clone(); + fixture::host_button(ui, before, rect(20.0)); + replay::open(&ctx); + fixture::host_button(ui, inside, rect(120.0)); + recorded = Some(replay::close(&ctx, fixture::layer_of(ui))); + }); + let recorded = recorded.expect("the frame ran"); + assert_eq!(recorded.focus.stop_ids().collect::>(), [inside], "the transcript holds the widget drawn in the view alone"); + let mut order = Vec::new(); + frames.frame(Vec::new(), |ui| { + let ctx = ui.ctx(); + fixture::host_button(ui, before, rect(20.0)); + focus::replay(ctx, &recorded.focus); + focus::stop_count(ctx); + order = focus::tab_order(ctx, |_| true).into_iter().map(|(id, _)| id).collect(); + }); + assert_eq!(order, [before, inside], "the replay registers the view's widget once, after the one drawn before it"); +} + /// Records `stops` run inside a record, with `entering` the first-pass flag of the layer scope it pushes, inside the /// scope `outer` when one is given. fn layer_scope_record(frames: &mut Frames, outer: Option, entering: bool) -> replay::Record { diff --git a/docs/contract-api.md b/docs/contract-api.md index 825a83db82..b186ce4737 100644 --- a/docs/contract-api.md +++ b/docs/contract-api.md @@ -3974,8 +3974,7 @@ The focus service: stops, scopes and roving groups registered per pass, the focu - `craft_ui::runtime::focus::FocusMove`: `pub enum FocusMove { Keys, Other }`. What moved the key focus. - `craft_ui::runtime::focus::FocusShape`: `pub enum FocusShape { Rect, Circle, Polygon(Vec) }`. The shape the focus ring takes around a part. - `craft_ui::runtime::focus::has`: `pub fn has(ctx: &Context, id: Id) -> bool`. Whether focus is on the component `id` or on one of its parts (a canvas's editor part), from the focus record of -- `craft_ui::runtime::focus::host_canvas`: `pub fn host_canvas(ctx: &Context, id: Id, keys: KeyUse)`. Registers the app's own egui widget `id`, drawn in the running pass, as its window's document canvas: a focus stop -- `craft_ui::runtime::focus::host_stop`: `pub fn host_stop(ctx: &Context, id: Id, keys: KeyUse)`. Registers the app's own egui widget `id`, drawn in the running pass, as a focus stop with `keys`, in the window's one +- `craft_ui::runtime::focus::host_canvas`: `pub fn host_canvas(ctx: &Context, id: Id, keys: KeyUse)`. Registers the app's own egui widget `id`, drawn in the running pass, as its window's document canvas: its focus stop - `craft_ui::runtime::focus::request`: `pub fn request(ctx: &Context, target: FocusTarget) -> bool`. Moves focus to `target`, leaves modality unchanged and asks the enclosing scroll owner to reveal it. Called - `craft_ui::runtime::focus::takes_letters`: `pub fn takes_letters(keys: &KeyUse) -> bool`. Whether a stop with these keys takes typed letters: a text field or a shortcut recorder. The letters a keytip or a - `craft_ui::runtime::focus::ActivateKeys`: `pub enum ActivateKeys { Neither, Enter, Space, Both }`. The keys that activate a component. diff --git a/docs/craft-framework.md b/docs/craft-framework.md index 082fa1a60e..3e67966078 100644 --- a/docs/craft-framework.md +++ b/docs/craft-framework.md @@ -144,22 +144,21 @@ An app with its own eframe `App` calls the hooks in `craft::ui::shell::embed`. ` | Each frame | `raw_input_hook` | `embed::before_input(ctx, \|output\| { ...; input })`: the closure receives the `FrameOutput` of the frame before (fired commands, announcements, chrome toggles) and returns the `FrameInput` for this frame (`RootEnv`, command states, the `Host`). eframe runs the hook for the main window only: an app that drops the window system's input there (an agent-driven session) sets `FrameInput::window_input(WindowInput::Dropped)` too, and the runtime drops it in every other OS window it hosts, before injected input joins. macOS Control+Click is the runtime's in every window; the app does not map it. | | Each frame | `logic`, after the app's own logic | `embed::logic(ctx, \|\| decision)`: the root window's close path. The closure runs only when the root window was asked to close, and returns `CloseDecision::Close` or `Hold`. | | Each pass | `ui`, before the app's UI | `embed::before_ui(ctx, frame)`: hands the runtime the root's native window (eframe's `Frame`, or any `raw_window_handle::HasWindowHandle`) on Windows, where the runtime answers the window's hit test (resize edges, the title bar's move area, snap layouts on the maximize button), and fits the root window to its monitor once. Native only; it needs no eframe feature of the facade. | -| Each pass | `ui`, where the app draws its own document canvas | Optional: `ui::runtime::focus::host_canvas(ctx, id, KeyUse::CANVAS)` declares it as the window's canvas (Tab row below). | -| Each pass | `ui`, where the app draws a widget of its own that Tab should reach | Optional: `ui::runtime::focus::host_stop(ctx, id, keys)` puts it into the window's one Tab order among the framework's stops (Tab row below). | +| Each pass | `ui`, where the app draws its own document canvas | Optional: `ui::runtime::focus::host_canvas(ctx, id, KeyUse::CANVAS)` declares it as the window's canvas (Tab row below). Every other focusable egui widget the app draws is a Tab stop with no call: the window's one Tab order holds it among the framework's stops, in the order the pass draws them. | | Each pass | `ui`, last | Optional: `ui::runtime::keys::with_window_intents(ctx, rtl, \|intents\| ...)` reads the keys no component took (below). | `install` takes over these parts of the context for the whole window, not only for framework components: | What | Effect on the app's own egui code | | --- | --- | -| Tab | Bare Tab moves framework focus and never reaches egui, unless the focused framework stop keeps Tab or an app's own widget has the focus (below), or nothing has the focus in a window that registered no focus stop: egui then moves its own focus into the app's widgets. A window with stops but no Tab entry (on the Mac, where Tab reaches only text fields by default) keeps the Tab from egui, which would otherwise focus framework controls the platform's rule skips. With `RootEnv::tab_toggles_chrome`, Tab toggles the chrome in a window that shows a document canvas, with nothing focused or the canvas focused, and arrives in `FrameOutput::chrome_toggles`. The canvas is a framework canvas, or the app's own egui canvas declared each pass with `ui::runtime::focus::host_canvas`. A canvas that keeps Tab (`KeyUse::CANVAS.with_keep(KeepKeys::Tab)`) gets the press in egui's input only while it has the focus; with nothing focused, Tab moves focus into the window or toggles the chrome, so the canvas cannot trap keyboard navigation. In a window with framework stops, the app's own widgets take part in Tab order as stops registered each pass with `host_stop`, in the order the pass registers them; a window whose stops are all the app's (`host_canvas`, `host_stop`) leaves Tab from nothing or from those stops to egui, whose order holds them with the app's other widgets. A focused canvas whose editor part keeps Tab reads Shift+Tab as `Intent::BackTab` (`EditorInput::BackTab`); no other stop gets it as an intent, and a text field keeps Shift+Tab as a focus move. | +| Tab | Bare Tab moves focus over the window's one Tab order and never reaches egui, unless the focused framework stop keeps Tab, the app's own focused widget keeps it by its egui key filter (a multi-line `TextEdit` with `lock_focus`, a code editor), or an egui popup is open (below). The order holds the framework's stops and every focusable egui widget the app draws (egui's focus candidates of the pass), in the order the pass registers and draws them, each inside the framework scope it was drawn in; a `TextEdit` is a text stop. So the app's own menu bar, buttons and fields are reached where it draws them, with no registration. A window with stops but no Tab entry (on the Mac, where Tab reaches only text fields by default) keeps the Tab from egui, which would otherwise focus controls the platform's rule skips. With `RootEnv::tab_toggles_chrome`, Tab toggles the chrome in a window that shows a document canvas, with nothing focused or the canvas focused, and arrives in `FrameOutput::chrome_toggles`. The canvas is a framework canvas, or the app's own egui canvas declared each pass with `ui::runtime::focus::host_canvas`, which takes the canvas's keys at the canvas's place in the order. A canvas that keeps Tab (`KeyUse::CANVAS.with_keep(KeepKeys::Tab)`) gets the press in egui's input only while it has the focus; with nothing focused, Tab moves focus into the window or toggles the chrome, so the canvas cannot trap keyboard navigation. A focused canvas whose editor part keeps Tab reads Shift+Tab as `Intent::BackTab` (`EditorInput::BackTab`); no other stop gets it as an intent, and a text field keeps Shift+Tab as a focus move. | | F6 | F6 and Shift+F6 move between panes and never reach egui. They are the defaults of the commands `NavCommand::NextPane` and `NavCommand::PreviousPane` (ids `window.next_pane` and `window.previous_pane`; name them by `NavCommand::NextPane.id()` in code): a default chord that another command binds is that command's, and the overrides move or unbind them (`CommandInput::overrides`). An app whose own shortcut table keeps F6 unbinds them there. | | Escape | Plain Escape (Alt and Shift may be held) goes to the focused framework stop and its scopes; with no framework stop focused, it goes to the window as `Intent::Cancel`. A held Escape cancels once: its repeats raise no `Cancel`. It reaches egui only while an app's own widget has the focus (below). An Escape the runtime takes outside a captured framework press also ends egui's own drag in that pass, as egui's Escape does. | | F10, Alt+letter | Taken while a framework menu bar is registered: F10 (`NavCommand::FocusMenuBar`, id `window.focus_menu_bar`, bound and yielded as F6 is) focuses the bar, Alt+letter opens a menu (not on macOS) unless the keymap binds it to an enabled command, which runs instead. | | Claimed chords | The chords the app's canvas claims (`KeyUse::CANVAS.with_claims(..)` in `host_canvas`) stay in egui's input for it while it has the focus and, with nothing focused, while it is the window's key target; no command fires with them. On Windows and Linux, Alt+numpad code entry takes every other Alt+digit (egui reports keypad and top-row digits alike), so an app's Alt+digit shortcut works only when its canvas claims the chord. | | Edit chords | Taken while a framework editor is focused. With nothing focused, the edit chords and egui's copy, cut and paste events of the commands in the window canvas's edit set (`KeyUse::edits`, `host_canvas`) stay in egui's input for it, and no command fires with them. Otherwise egui's copy, cut and paste events become the ⌘C/X/V chord for the app's commands, unless an app's own widget has the focus (below). While egui holds a label text selection, copy and cut stay egui's, and egui copies the selection. | | IME | Taken while a framework editor owns the IME: its events and `PlatformOutput.ime` are the runtime's. Otherwise they stay egui's, for the app's own `TextEdit` or IME code. | -| An app's own focused widget | While egui focus is on a widget no framework component made, or an egui popup is open, and no framework press or drag is captured, Tab, Shift+Tab, Escape and egui's clipboard events stay in egui's input for it, and the runtime routes nothing for them. While egui focus is on such a widget, the arrows and Tab move egui focus among the app's widgets as egui does; while a framework stop has the focus, egui's arrow moves are off. | +| An app's own focused widget | While egui focus is on a widget no framework component made, or an egui popup is open, and no framework press or drag is captured, Escape, the plain Enter and egui's clipboard events stay in egui's input for it, and the runtime routes nothing for them; Tab and Shift+Tab are the window's focus moves (Tab row) unless the widget keeps Tab or the popup is open. While egui focus is on such a widget, the arrows move egui focus among the app's widgets as egui does; while a framework stop has the focus, egui's arrow moves are off. | | Releases | The release of every key the runtime took is taken too. | | Focus surrender | The runtime moves its own focus on press (8.3): a press a framework component takes moves focus to it; a press no component takes drops the framework's focus. egui's click-away never takes the framework's focus. egui's surrender option (`InputOptions::surrender_focus_on`) stays the app's and governs the focus of the app's own widgets, as in egui alone: a press no component takes leaves that focus to egui's rule. | | Clicks | egui's click options (`InputOptions::max_click_dist`, `max_click_duration`) stay the app's, for its own widgets. A framework component clicks and drags by the framework's press lifecycle: a release within the slop (`HitSizes::slop`), whatever its duration. Read a component's click with `contract::clicked(&response)` or its output's `clicked()`; egui's `Response::clicked()` on a component's response also needs a click by egui's options. | @@ -170,7 +169,7 @@ An app with its own eframe `App` calls the hooks in `craft::ui::shell::embed`. ` | App modals | A modal the app draws with its own egui code blocks nothing outside egui by itself. While one shows, the app names its window each frame with `FrameInput::app_modal(Some(viewport))`: the app's other windows, panels floated into windows of their own among them, are then blocked as under a framework app-modal layer (their presses, keys, wheel and text are dropped, a press there brings the modal's window forward, and they refuse to close). | | Input pacing | One press per pass: extra presses in one frame wait for the next passes. A press outside an open framework menu closes the menu and goes no further. After an OS resize of the window, the held pointer is released. | -The window's keys are the ones the runtime routes to no component: an Escape or a plain Enter while nothing has the focus, neither a framework stop nor one of the app's own widgets or popups, and the arrows' nudge. The window's plain Enter also stays in egui's input. `with_window_intents` offers them to its closure while nothing has framework focus. The closure takes what it handles (`Intents::take(Intent::Cancel)`; `Intent` and the other types `Intents` reads are in `ui::runtime::keys`) and returns whether it took anything; the rest stays for later readers. A framework scope that ran earlier in the pass takes them first (an open dialog takes the Escape that closes it), so the app reads them last in its UI to see what no component took. App code that read `Key::Escape`, `Key::Tab`, F6 or F10 from egui while none of its own widgets had focus reads these intents and `FrameOutput::chrome_toggles` instead; its own focused widgets and popups keep reading Tab, Escape and the plain Enter from egui, and no window intent comes of them. +The window's keys are the ones the runtime routes to no component: an Escape or a plain Enter while nothing has the focus, neither a framework stop nor one of the app's own widgets or popups, and the arrows' nudge. The window's plain Enter also stays in egui's input. `with_window_intents` offers them to its closure while nothing has framework focus. The closure takes what it handles (`Intents::take(Intent::Cancel)`; `Intent` and the other types `Intents` reads are in `ui::runtime::keys`) and returns whether it took anything; the rest stays for later readers. A framework scope that ran earlier in the pass takes them first (an open dialog takes the Escape that closes it), so the app reads them last in its UI to see what no component took. App code that read `Key::Escape`, `Key::Tab`, F6 or F10 from egui while none of its own widgets had focus reads these intents and `FrameOutput::chrome_toggles` instead; its own focused widgets and popups keep reading Escape and the plain Enter from egui (Tab only where the widget keeps it or a popup is open), and no window intent comes of them. Framework dialogs the app keeps as values run on a `DialogHost`: the app calls `run(ui)` once per pass after its own UI and reads results with `take`. From 6a02da62d4f5c1362ef010e8320a5c343aaa3db7 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 01:09:59 +0000 Subject: [PATCH 17/56] Iconic column trial: the rule between icon groups spans more than half the rail, asserted as a relation --- crates/ui-panels/src/docking/iconic/trials.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-panels/src/docking/iconic/trials.rs b/crates/ui-panels/src/docking/iconic/trials.rs index 3b04852221..b3d65d6652 100644 --- a/crates/ui-panels/src/docking/iconic/trials.rs +++ b/crates/ui-panels/src/docking/iconic/trials.rs @@ -708,7 +708,8 @@ fn icon_groups_apart_by_a_rule_show_one_level_rule_between_them() { let between: Vec<_> = level.iter().filter(|(a, _, _)| a.y > last.bottom() && a.y < next.top()).collect(); let [(a, b, ink)] = between.as_slice() else { panic!("one rule between the groups: {level:?}") }; let (left, right) = (a.x.min(b.x), a.x.max(b.x)); - assert!(left > 0.0 && right < RAIL && right - left > RAIL / 2.0, "the rule reaches across the column, short of its sides: {a:?} to {b:?}"); + let span = right - left; + assert!(left > 0.0 && right < RAIL && span > RAIL - span, "the rule reaches across the column, short of its sides: {a:?} to {b:?}"); let [r, g, bl, al] = border.0; assert_eq!(*ink, egui::Color32::from_rgba_unmultiplied(r, g, bl, al), "the rule is in line.border"); } From e46f5180a062ee519346f2626830f47c32d64d9d Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 01:15:31 +0000 Subject: [PATCH 18/56] Focus: a Tab with no stop to move to and nothing focused stays in egui's input for the app's own binding --- crates/ui-contract/src/runtime/focus.rs | 8 +++++ crates/ui-contract/src/runtime/keys/input.rs | 8 +++-- .../src/testing/host_key_trials.rs | 33 +++++++++++++++++++ docs/craft-framework.md | 2 +- 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 31745019c1..d4bb8d0626 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -345,6 +345,14 @@ pub(crate) fn is_canvas_member(ctx: &Context, rec: &StopRec) -> bool { }) } +/// Whether a bare Tab in `viewport` has no stop to move the focus to: the window's last pass registered no stop (the +/// app's focusable egui widgets are stops too, `take_app_widgets`) and nothing held the focus at its end. Such a Tab +/// stays in egui's input for the app's own binding. Read by the input hook, before the begin hook rotates the +/// registrations. +pub(crate) fn tab_has_no_stop(ctx: &Context, viewport: ViewportId) -> bool { + with_viewport(ctx, viewport, |state| state.stops.is_empty() && state.focus_now.is_none()) +} + /// How many stops the running pass has registered so far. pub(crate) fn stop_count(ctx: &Context) -> usize { take_app_widgets(ctx, None); diff --git a/crates/ui-contract/src/runtime/keys/input.rs b/crates/ui-contract/src/runtime/keys/input.rs index 4a1177e2a1..10fc04150f 100644 --- a/crates/ui-contract/src/runtime/keys/input.rs +++ b/crates/ui-contract/src/runtime/keys/input.rs @@ -45,8 +45,9 @@ struct Strip<'a> { /// An app's own egui widget or popup has the focus (`FocusedRecord::foreign`): Escape, the plain Enter and the /// clipboard events are its own, and no window intent comes of them. foreign: bool, - /// A bare Tab is egui's (`FocusedRecord::tab_in_egui`): an app's own popup is open, or the app's own focused widget - /// keeps Tab by its egui key filter. + /// A bare Tab is egui's: an app's own popup is open, or the app's own focused widget keeps Tab by its egui key + /// filter (`FocusedRecord::tab_in_egui`), or the window has no stop to move the focus to and nothing focused + /// (`focus::tab_has_no_stop`), so the Tab is the app's own binding's. tab_in_egui: bool, /// The focused stop is the app's own egui widget (`Stop::host`, `FocusedRecord::host`), which reads its keys from /// egui: its Escape stays there, as an app's own focused widget's does. Tab and the arrows follow its `KeyUse`, as @@ -665,6 +666,7 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec Date: Wed, 25 Nov 2026 02:00:59 +0000 Subject: [PATCH 19/56] Bypass walk: the stop every focusable egui widget gets by itself (Stop::automatic) is no registration, so a raw egui widget beside a component is a finding again --- crates/ui-contract/src/runtime/focus/nav.rs | 5 ++--- crates/ui-contract/src/runtime/focus/registration.rs | 10 ++++++++-- crates/ui-contract/src/testing/bypass.rs | 5 +++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/crates/ui-contract/src/runtime/focus/nav.rs b/crates/ui-contract/src/runtime/focus/nav.rs index 3284bb4f14..f40500b341 100644 --- a/crates/ui-contract/src/runtime/focus/nav.rs +++ b/crates/ui-contract/src/runtime/focus/nav.rs @@ -231,11 +231,10 @@ impl State { /// Whether `id`, holding egui focus, is an app's own widget: as `made` says, no widget a component made /// (`pointer::made_by_component`), and the root of no stop but the one every focusable egui widget of the app has - /// (`Stop::host` with default keys). The app's canvas (`host_canvas`, `KeyUse::chrome_key`) is none: its declared + /// (`Stop::automatic`). The app's canvas (`host_canvas`, `KeyUse::chrome_key`) is none: its declared /// keys route as a framework stop's do, so egui's arrows and Tab never move focus off it. pub(super) fn app_widget(&self, id: Id, made: bool) -> bool { - let automatic = |rec: &StopRec| rec.stop.host && !rec.stop.keys.chrome_key; - !made && !self.stops.iter().chain(&self.last_stops).any(|rec| !automatic(rec) && (rec.stop.root == id || rec.stop.key() == (id, None))) + !made && !self.stops.iter().chain(&self.last_stops).any(|rec| !rec.stop.automatic() && (rec.stop.root == id || rec.stop.key() == (id, None))) } /// Moves focus to `rec` and asks the enclosing scroll owner to reveal it: the egui widget is its root, and the stop diff --git a/crates/ui-contract/src/runtime/focus/registration.rs b/crates/ui-contract/src/runtime/focus/registration.rs index 56eaddb64f..a83dc80a26 100644 --- a/crates/ui-contract/src/runtime/focus/registration.rs +++ b/crates/ui-contract/src/runtime/focus/registration.rs @@ -37,8 +37,8 @@ pub struct Stop { /// The arena root the stop is shown in (a canvas whose body holds it), whether or not it joined the arena: a text /// stop keeps its own egui widget. A removed stop hands focus back to it. pub arena: Option, - /// The app's own egui widget (`focus::host_canvas`), which reads its keys from egui's input: the key stage leaves - /// the presses it routes to the stop there. + /// The app's own egui widget (`focus::host_canvas`, or any focusable egui widget the app draws), which reads its + /// keys from egui's input: the key stage leaves the presses it routes to the stop there. pub host: bool, } @@ -128,6 +128,12 @@ impl Stop { self } + /// Whether this is the stop every focusable egui widget the app draws gets by itself (`focus::take_app_widgets`): + /// the app's own widget, not declared as its canvas (`KeyUse::chrome_key`). No component or app call registered it. + pub fn automatic(&self) -> bool { + self.host && !self.keys.chrome_key + } + pub(crate) fn key(&self) -> StopKey { (self.id, self.part) } diff --git a/crates/ui-contract/src/testing/bypass.rs b/crates/ui-contract/src/testing/bypass.rs index ec44a2076b..815bf36289 100644 --- a/crates/ui-contract/src/testing/bypass.rs +++ b/crates/ui-contract/src/testing/bypass.rs @@ -1,7 +1,8 @@ //! Bypass detection (24.2): the pass-end walk that finds what a component made without the runtime. //! //! Every interactive egui widget of the latest pass must be one a component registered (a root or one of its -//! widgets, a focus stop's root) or one the runtime noted. Every AccessKit node that declares an action must +//! widgets, the root of a focus stop that something registered: not the stop every focusable egui widget gets by +//! itself, `Stop::automatic`) or one the runtime noted. Every AccessKit node that declares an action must //! come from the runtime's node writer. A raw `ui.interact`, `ui.button` or `ui.add(Slider)` in a component //! fails here, with the id of the offender. @@ -24,7 +25,7 @@ pub fn findings(fixture: &Fixture) -> Vec { let mut registered: HashSet = pointer::registered_widgets(ctx); registered.extend(noted_widgets); focus::with_viewport(ctx, egui::ViewportId::ROOT, |state| { - registered.extend(state.stops.iter().chain(&state.last_stops).map(|rec| rec.stop.root)); + registered.extend(state.stops.iter().chain(&state.last_stops).filter(|rec| !rec.stop.automatic()).map(|rec| rec.stop.root)); }); let mut found: Vec = widgets::interactive(ctx) .into_iter() From a3715cee5b59e262fc88145d161ca612b36d1442 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:12:25 +0000 Subject: [PATCH 20/56] IME: an interrupt of a framework editor publishes the app's own reset request of that pass, and the request counts as the app's only when the published output carries it --- crates/ui-contract/src/runtime/egui/ime.rs | 16 +++--- crates/ui-contract/src/runtime/ime.rs | 44 +++++++++------ .../src/testing/host_key_trials.rs | 54 +++++++++++++++++++ 3 files changed, 91 insertions(+), 23 deletions(-) diff --git a/crates/ui-contract/src/runtime/egui/ime.rs b/crates/ui-contract/src/runtime/egui/ime.rs index 9c9542d310..b06c469fae 100644 --- a/crates/ui-contract/src/runtime/egui/ime.rs +++ b/crates/ui-contract/src/runtime/egui/ime.rs @@ -78,6 +78,9 @@ pub(crate) struct Output { pub caret: Rect, /// Interrupt the OS composition and ask for a reset. pub interrupt: bool, + /// The reset request the app's own editor asked for this pass (`app_reset`), which an interrupt publishes instead + /// of asking a new one: egui keeps one unpublished request per viewport, so a new one would replace the app's. + pub app_reset: Option, /// The context generation the tracker gave the owner: it changes when the owner, its epoch, its focus or its /// purpose changes, and stays for ordinary edits. pub generation: u64, @@ -89,9 +92,10 @@ pub(crate) struct Output { } /// Writes the pass's IME output; egui reads it only when it is `Some` at the end of the pass. Returns the reset -/// request an interrupt published: its completion is the one that matches (`None` when the ids ran out). +/// request an interrupt published, the app's own when it asked for one: its completion is the one that matches +/// (`None` when the ids ran out). pub(crate) fn write(ctx: &Context, viewport: ViewportId, out: Output) -> Option { - let reset = out.interrupt.then(|| ctx.request_ime_reset(viewport)).flatten(); + let reset = out.interrupt.then(|| out.app_reset.or_else(|| ctx.request_ime_reset(viewport))).flatten(); ctx.output_mut(|output| { let mut ime = egui::output::IMEOutput::new( out.owner, @@ -117,10 +121,10 @@ pub(crate) fn app_reset(ctx: &Context, viewport: ViewportId) -> Option Option { - let reset = app_reset(ctx, viewport).or_else(|| ctx.request_ime_reset(viewport)); +/// reset. An editor that asked for its own reset this pass (`app`, from `app_reset`) keeps its request, so the platform +/// answers the app's id and the app gets its completion. Returns the reset request the output carries, as `write` does. +pub(crate) fn interrupt_written(ctx: &Context, viewport: ViewportId, app: Option) -> Option { + let reset = app.or_else(|| ctx.request_ime_reset(viewport)); ctx.output_mut(|output| { if let Some(ime) = &mut output.ime { ime.should_interrupt_composition = true; diff --git a/crates/ui-contract/src/runtime/ime.rs b/crates/ui-contract/src/runtime/ime.rs index 4870f17ebd..c931780bbb 100644 --- a/crates/ui-contract/src/runtime/ime.rs +++ b/crates/ui-contract/src/runtime/ime.rs @@ -497,7 +497,7 @@ pub(crate) fn end_pass(ctx: &Context) { let app_wrote = ctx.output(|output| output.ime.as_ref().map(|ime| (ime.owner, ime.context_generation))); // egui publishes the app's request only in a pass that has an IME output. let app_reset = app_wrote.and(os::app_reset(ctx, viewport)); - let (owner, interrupt, caret, update, published, host) = with(ctx, viewport, |engine| { + let (owner, interrupt, caret, update, published, host, app_request) = with(ctx, viewport, |engine| { let ran = std::mem::take(&mut engine.ran); if !ran { engine.edits.clear(); @@ -515,20 +515,15 @@ pub(crate) fn end_pass(ctx: &Context) { let last_host = engine.host; let kept = engine.host.filter(|host| app_wrote.is_some_and(|(owner, _)| owner == host.owner)).is_some_and(|host| host.composing); engine.host = app_wrote.filter(|_| engine.owner.is_none()).map(|(owner, generation)| HostIme { owner, generation, composing: kept }); - if let Some(id) = app_reset.filter(|_| engine.owner.is_none()) - && !engine.host_resets.contains(&id) - { - engine.host_resets.push(id); - // Completions arrive in request order: the latest request's completion ends the interrupted composition, - // whichever request the fence waited for. - if engine.stale { - engine.reset = Some(id); - } - } + // The app's request while no framework editor owns the IME: every output this pass publishes carries it, the + // app's own or the engine's interrupt, and a new one becomes the fence's request below. + let app_request = app_reset.filter(|_| engine.owner.is_none()); + let fresh = app_request.filter(|id| !engine.host_resets.contains(id)); // The fence has no request the integration can answer: the owner's output asks again, a framework editor's // or the app's own. if engine.stale && engine.reset.is_none() + && fresh.is_none() && let Some(owner) = engine.owner.or(engine.host.map(|host| host.owner)) { engine.interrupt.get_or_insert(owner); @@ -536,13 +531,13 @@ pub(crate) fn end_pass(ctx: &Context) { let caret = engine.caret.take(); let password = caret.filter(|(id, ..)| Some(*id) == engine.owner).map(|(.., password)| password); let update = engine.observe(viewport, frame_nr, pass_nr, password); - (engine.owner, engine.interrupt.take(), caret, update, engine.published, last_host) + (engine.owner, engine.interrupt.take(), caret, update, engine.published, last_host, app_request) }); let host_interrupt = interrupt.filter(|old| owner.is_none() && app_wrote.is_some_and(|(id, _)| id == *old)); let written = if owner.is_none() && interrupt.is_none() { None } else if host_interrupt.is_some() { - Some((os::interrupt_written(ctx, viewport), None)) + Some((os::interrupt_written(ctx, viewport, app_request), None)) } else { os::clear(ctx); match (caret, interrupt, update) { @@ -553,6 +548,7 @@ pub(crate) fn end_pass(ctx: &Context) { field, caret, interrupt: interrupt.is_some(), + app_reset: app_request, generation, password, surrounding: update.surrounding_text, @@ -569,6 +565,7 @@ pub(crate) fn end_pass(ctx: &Context) { field: Rect::NOTHING, caret: Rect::NOTHING, interrupt: true, + app_reset: app_request, generation, password: false, surrounding: IMESurroundingText::Unavailable, @@ -579,14 +576,27 @@ pub(crate) fn end_pass(ctx: &Context) { _ => None, } }; - if let Some((reset, generation)) = written { - with(ctx, viewport, |engine| { + // The app's request counts as its own only when the published output carries it: egui's own output when the + // engine wrote none, else the engine's. + let carried = app_request.filter(|id| written.as_ref().is_none_or(|(reset, _)| *reset == Some(*id))); + with(ctx, viewport, |engine| { + if let Some((reset, generation)) = written { if generation.is_some() { engine.published = generation; } if interrupt.is_some() { engine.reset = reset; } - }); - } + } + if let Some(id) = carried + && !engine.host_resets.contains(&id) + { + engine.host_resets.push(id); + // Completions arrive in request order: the latest request's completion ends the interrupted composition, + // whichever request the fence waited for. + if engine.stale { + engine.reset = Some(id); + } + } + }); } diff --git a/crates/ui-contract/src/testing/host_key_trials.rs b/crates/ui-contract/src/testing/host_key_trials.rs index 84635d3ea2..83e2690fd0 100644 --- a/crates/ui-contract/src/testing/host_key_trials.rs +++ b/crates/ui-contract/src/testing/host_key_trials.rs @@ -9,6 +9,7 @@ use crate::runtime::egui::{areas, fixture}; use crate::runtime::env::{Env, RootEnv}; use crate::runtime::focus::{EditSet, FocusPolicy, FocusTarget, KeepKeys, KeyUse, host_canvas, request}; use crate::runtime::frame::{ChromeToggle, take_output}; +use crate::runtime::ime; use crate::runtime::keys::with_window_intents; use crate::style::{ComponentStyle, StyleCx}; use crate::testing::focus::{Stop, egui_focused, key_release, named_id, pop_scope, push_scope, register_stop, widget}; @@ -297,6 +298,59 @@ fn an_app_editor_s_later_reset_ends_the_fence() { assert!(editor.borrow().composing, "the editor composes again"); } +/// A framework text field of `id`, as a text component's part draws it: a text stop that takes the IME edits meant for +/// it and notes its caret. +fn framework_field(ui: &mut Ui, id: Id) { + let rect = widget(ui, id); + register_stop(ui.ctx(), Stop::new(id, KeyUse::of(Input::Text)).text()); + let _ = ime::take(ui.ctx(), id, false); + ime::note_caret(ui.ctx(), id, rect, rect, false); +} + +/// A press on the app's editor takes the focus from a composing framework field, and the editor asks for its own reset +/// in the pass the field loses the IME, as EffectCraft's editor does when its caret moves after the press. The interrupt +/// of the field's composition publishes the editor's request, so the platform's answer reaches the editor, the field's +/// late commit stays fenced until then, and the commit after it reaches the editor. +#[trial] +fn an_app_editor_s_reset_asked_as_it_takes_the_focus_from_a_composing_framework_field_completes() { + let editor = Rc::new(RefCell::new(fixture::ResettingEditor::default())); + let held = Rc::clone(&editor); + let rect = Rect::from_min_size(Pos2::new(100.0, 100.0), egui::vec2(200.0, 30.0)); + let framework = named_id("framework field"); + let mut show = move |ui: &mut Ui| { + framework_field(ui, framework); + fixture::host_resetting_ime_editor(ui, host_editor_id(), rect, &mut held.borrow_mut()); + }; + let mut frames = Frames::new(); + frames.idle(2, &mut show); + request(&frames.ctx, FocusTarget::Id(framework)); + frames.frame(Vec::new(), &mut show); + frames.frame(vec![Event::Ime(ImeEvent::Preedit { text: "k".to_owned(), active_range_chars: None })], &mut show); + assert_eq!(frames.ime().map(|ime| ime.owner), Some(framework), "the framework field composes"); + let at = rect.center(); + frames.frame(vec![moved(at), press(at)], &mut show); + assert!(!frames.ime().is_some_and(|ime| ime.interrupt), "the field keeps the IME through the press pass"); + editor.borrow_mut().ask = true; + frames.frame(vec![release(at)], &mut show); + let own = editor.borrow().reset; + assert!(own.is_some(), "the editor asked for its own reset"); + let ime = frames.ime().cloned(); + assert!(ime.as_ref().is_some_and(|ime| ime.owner == framework && ime.interrupt), "the pass interrupts the field's composition"); + assert_eq!(ime.and_then(|ime| ime.reset), own, "the interrupt publishes the editor's request, not a new one"); + let Some(own) = own else { return }; + frames.frame(Vec::new(), &mut show); + frames.frame( + vec![ + Event::Ime(ImeEvent::Commit("Q".to_owned())), + Event::ImeResetCompleted { request_id: own }, + Event::Ime(ImeEvent::Commit("X".to_owned())), + ], + &mut show, + ); + assert_eq!(editor.borrow().reset, None, "the completion of its request reaches the editor"); + assert_eq!(editor.borrow().text, "X", "the field's late commit is fenced and the commit after the completion reaches the editor"); +} + #[trial] fn a_focused_egui_field_keeps_escape_and_the_clipboard_and_tabs_on_through_the_one_order() { let (host, mut show) = host_window(); From d103fc5ea510774994297e01956aeeb728332758 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:15:03 +0000 Subject: [PATCH 21/56] Pin egui to aiongg/egui ime-pending-reset (b15ffe9bf) --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 28 ++++++++++++++-------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34224f4e3d..fe943467c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5562,7 +5562,7 @@ dependencies = [ [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", "emath", @@ -5618,7 +5618,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -5653,7 +5653,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "accesskit", "ahash", @@ -5672,7 +5672,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -5691,7 +5691,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "block2 0.6.2", "bytemuck", @@ -5711,7 +5711,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", "egui", @@ -5724,7 +5724,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "eframe", "egui", @@ -5801,7 +5801,7 @@ dependencies = [ [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", ] @@ -5874,7 +5874,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -5900,7 +5900,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[package]] name = "equator" @@ -15232,19 +15232,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[patch.unused]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=f678ecb710dfb98e4b934f6a8d4176c858606a95#f678ecb710dfb98e4b934f6a8d4176c858606a95" +source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" diff --git a/Cargo.toml b/Cargo.toml index 0e01b72d1e..d39b1bf024 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -316,20 +316,20 @@ hayro-postscript = { path = "vendor/hayro-postscript" } linesweeper = { path = "vendor/linesweeper" } vello_common = { path = "vendor/vello_common" } vello_cpu = { path = "vendor/vello_cpu" } -ecolor = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -emath = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -epaint = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -eframe = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } -egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "f678ecb710dfb98e4b934f6a8d4176c858606a95" } +ecolor = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +emath = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +epaint = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +eframe = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # symphonia's FLAC decoder restores LPC samples as `residual + (prediction as i32)`. In a valid From 7f085531fbaf9a13ee7a89665840fe7c495756d2 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:19:56 +0000 Subject: [PATCH 22/56] Focus candidates: one per-pass set of what components made, and the stop roots as a set, replace the walks; an editor part's focus widget is its component's, so a disabled editor never becomes an app Tab stop --- crates/ui-contract/src/contract/editor.rs | 2 ++ crates/ui-contract/src/runtime/focus.rs | 7 ++++- crates/ui-contract/src/runtime/focus/nav.rs | 1 + crates/ui-contract/src/runtime/pointer.rs | 30 +++++++++++++++++-- .../src/testing/host_key_trials.rs | 22 ++++++++++++++ crates/ui-contract/tests/it/text/editor.rs | 27 +++++++++++++++++ 6 files changed, 85 insertions(+), 4 deletions(-) diff --git a/crates/ui-contract/src/contract/editor.rs b/crates/ui-contract/src/contract/editor.rs index 78e8e9e13a..922f2ced2c 100644 --- a/crates/ui-contract/src/contract/editor.rs +++ b/crates/ui-contract/src/contract/editor.rs @@ -73,6 +73,8 @@ pub(crate) fn run(cx: &mut Cx<'_, C>, ui: &mut Ui, step: &mut supe let (ctx, id) = (cx.core.ctx.clone(), cx.core.id); let widget = ImeSurface::of(id, decl.key).widget(); let focused = egui_editor::show(ui, widget, decl.rect, egui_focus::event_filter(keys.keep, false)); + // The focus widget is the component's, enabled or not: it is never one of the app's own widgets (`take_app_widgets`). + crate::runtime::pointer::record_text_widget(&ctx, widget, id); let read_only = cx.core.resolved.read_only || !cx.core.resolved.enabled; let mut inputs: Vec<(Order, EditorInput)> = Vec::new(); if focused { diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index d4bb8d0626..7cdd0fe54d 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -149,6 +149,8 @@ pub(crate) struct RowGroups { pub(crate) struct State { pub(crate) stops: Vec, stop_ids: IdSet, + /// The egui roots of `stops`. + stop_roots: IdSet, pub(crate) last_stops: Vec, pub(crate) scopes: FastMap, pub(crate) last_scopes: FastMap, @@ -241,6 +243,7 @@ pub(crate) fn register_stop(ctx: &Context, stop: Stop) { if stop.host && let Some(rec) = state.stops.iter_mut().find(|rec| rec.stop.host && rec.stop.id == stop.id) { + state.stop_roots.insert(stop.root); rec.stop = stop; return Vec::new(); } @@ -255,6 +258,7 @@ impl State { fn push_stop(&mut self, stop: Stop) -> Vec { let scope = self.open.last().map(|(id, _)| *id); self.stop_ids.insert(stop.id); + self.stop_roots.insert(stop.root); let rec = StopRec { stop, scope, group_position: false }; let acts = if self.awaited == Some(rec.stop.key()) { self.awaited = None; @@ -290,7 +294,7 @@ fn take_app_widgets(ctx: &Context, except: Option) { state.candidates_seen = seen + fresh.len(); let mut acts = Vec::new(); for candidate in app { - if state.stops.iter().any(|rec| rec.stop.root == candidate.id) { + if state.stop_roots.contains(&candidate.id) { continue; } let stop = Stop::new(candidate.id, KeyUse::of(craft_behavior::Input::Pointer)).host(); @@ -488,6 +492,7 @@ pub(crate) fn replay(ctx: &Context, transcript: &Transcript) { } for rec in placed.stops { state.stop_ids.insert(rec.stop.id); + state.stop_roots.insert(rec.stop.root); state.stops.push(rec); } for group in placed.groups { diff --git a/crates/ui-contract/src/runtime/focus/nav.rs b/crates/ui-contract/src/runtime/focus/nav.rs index f40500b341..0fa84e5e23 100644 --- a/crates/ui-contract/src/runtime/focus/nav.rs +++ b/crates/ui-contract/src/runtime/focus/nav.rs @@ -184,6 +184,7 @@ impl State { pub(super) fn rotate(&mut self) { self.last_stops = std::mem::take(&mut self.stops); self.stop_ids.clear(); + self.stop_roots.clear(); self.last_scopes = std::mem::take(&mut self.scopes); self.last_scope_order = std::mem::take(&mut self.scope_order); self.last_groups = std::mem::take(&mut self.groups); diff --git a/crates/ui-contract/src/runtime/pointer.rs b/crates/ui-contract/src/runtime/pointer.rs index 36e734e570..58539fbe32 100644 --- a/crates/ui-contract/src/runtime/pointer.rs +++ b/crates/ui-contract/src/runtime/pointer.rs @@ -229,6 +229,9 @@ pub(crate) struct Shapes { /// the last, each with its component: such a widget takes its press itself. this_texts: IdMap, last_texts: IdMap, + /// Every id components registered or made in the running pass: the roots, their egui widgets and the widgets made + /// for their text and editor parts (`made_by_component`). + this_made: IdSet, /// The layers' own egui widgets (an overlay `Area`'s, which senses a click where nothing on the layer does) in the /// running pass and the last: such a widget lies under every widget and shape on its layer and stands for none. this_grounds: IdSet, @@ -250,6 +253,9 @@ pub(crate) struct Shapes { /// The resolutions the running pass made (`find_under`), for the count trials. #[cfg(feature = "testing")] resolutions: u32, + /// The `made_by_component` lookups the running pass made, for the count trials. + #[cfg(feature = "testing")] + made_lookups: u32, } /// The begin hook (H5): converts the pass's pointer input. @@ -373,6 +379,7 @@ pub(crate) fn begin(ctx: &Context, hit: HitSizes, latched: craft_keymap::Mods) { shapes.last = std::mem::take(&mut shapes.this); shapes.last_bodies = std::mem::take(&mut shapes.this_bodies); shapes.last_texts = std::mem::take(&mut shapes.this_texts); + shapes.this_made.clear(); shapes.last_grounds = std::mem::take(&mut shapes.this_grounds); shapes.next = 0; shapes.hover = None; @@ -381,6 +388,7 @@ pub(crate) fn begin(ctx: &Context, hit: HitSizes, latched: craft_keymap::Mods) { #[cfg(feature = "testing")] { shapes.resolutions = 0; + shapes.made_lookups = 0; } }); // The pointer's hover is resolved once for the pass, over last pass's complete record, with the targets egui's hit @@ -621,6 +629,7 @@ pub(crate) fn add_shapes_in(ctx: &Context, viewport: ViewportId, layer: Layer, r PerViewport::::with(ctx, viewport, |record| { let order = record.next; record.next += 1; + record.this_made.insert(root); let entry = record.this.entry(layer).or_default().entry(root).or_default(); entry.shapes.extend(shapes); entry.placed.resize(entry.shapes.len(), Placed { order, clip }); @@ -628,11 +637,13 @@ pub(crate) fn add_shapes_in(ctx: &Context, viewport: ViewportId, layer: Layer, r } /// Records the egui widget `widget` that the component `owner` made for its own text (a field's text, a selection -/// part): a press egui gives it is the widget's own and goes to no root, and the hover goes to `owner`. +/// part, an editor part's focus widget): a press egui gives it is the widget's own and goes to no root, and the hover +/// goes to `owner`. pub(crate) fn record_text_widget(ctx: &Context, widget: Id, owner: Id) { crate::runtime::replay::journal(ctx, || (widget, owner), |ctx, &(widget, owner)| record_text_widget(ctx, widget, owner)); PerViewport::::with(ctx, pass::current_viewport(ctx), |record| { record.this_texts.insert(widget, owner); + record.this_made.insert(widget); }); } @@ -669,6 +680,8 @@ pub(crate) fn record_widgets_in(ctx: &Context, viewport: ViewportId, layer: Laye |ctx, (layer, root, widgets, click)| record_widgets(ctx, *layer, *root, widgets, *click), ); PerViewport::::with(ctx, viewport, |record| { + record.this_made.insert(root); + record.this_made.extend(widgets.iter().copied()); let entry = record.this.entry(layer).or_default().entry(root).or_default(); entry.widgets.extend_from_slice(widgets); entry.click |= click; @@ -841,13 +854,24 @@ pub(crate) fn registered_widgets(ctx: &Context) -> std::collections::HashSet }) } -/// Whether `id` is a root or an egui widget that a component registered in the running pass of `viewport`. +/// Whether `id` is a root, an egui widget that a component registered, or a widget a component made for its text or +/// editor part, in the running pass of `viewport`. pub(crate) fn made_by_component(ctx: &Context, viewport: ViewportId, id: Id) -> bool { PerViewport::::with(ctx, viewport, |record| { - record.this.values().any(|roots| roots.contains_key(&id) || roots.values().any(|root| root.widgets.contains(&id))) + #[cfg(feature = "testing")] + { + record.made_lookups += 1; + } + record.this_made.contains(&id) }) } +/// How many `made_by_component` lookups the running pass of `viewport` made so far, for the count trials. +#[cfg(feature = "testing")] +pub(crate) fn made_lookups(ctx: &Context, viewport: ViewportId) -> u32 { + PerViewport::::with(ctx, viewport, |record| record.made_lookups) +} + /// The roots a press at a point goes to, each with the shape of it that wins it: its click's and its drag's (8.3, H7). /// Among the roots under the point ([`Under`]), each resolves its own shapes by the arena rule, and the roots rank by /// their winning shapes' place in the pass's paint order, top first. The top one takes every kind of press its shape diff --git a/crates/ui-contract/src/testing/host_key_trials.rs b/crates/ui-contract/src/testing/host_key_trials.rs index 84635d3ea2..30f7d0b42d 100644 --- a/crates/ui-contract/src/testing/host_key_trials.rs +++ b/crates/ui-contract/src/testing/host_key_trials.rs @@ -707,6 +707,28 @@ fn an_open_app_popup_keeps_tab() { assert_eq!(egui_focused(&frames.ctx), Some(named_id("button")), "the framework moved no focus"); } +/// The scan that makes the app's egui widgets Tab stops classifies each focus candidate of a pass once, however many +/// registrations take candidates in between: the pass's lookups grow with its widgets, one per app widget. +#[trial] +fn each_focus_candidate_of_a_pass_is_classified_once() { + let lookups = |n: usize| { + let mut show = move |ui: &mut Ui| { + for at in 0..n { + fixture::host_button(ui, Id::new(("app", at)), Rect::from_min_size(Pos2::new(10.0, 30.0 * at as f32), egui::vec2(60.0, 20.0))); + widget(ui, Id::new(("framework", at))); + register_stop(ui.ctx(), Stop::new(Id::new(("framework", at)), KeyUse::of(Input::Pointer))); + } + }; + let mut frames = Frames::new(); + frames.idle(2, &mut show); + crate::runtime::pointer::made_lookups(&frames.ctx, ViewportId::ROOT) as usize + }; + // The framework widget is the root of the stop registered after it, so only the app's widgets need a lookup. + let (small, large) = (lookups(8), lookups(16)); + assert!(small >= 8, "every app widget is looked up: {small}"); + assert_eq!(large - small, 8, "eight more app widgets cost one lookup each: {small} then {large}"); +} + /// A Tab in a window with no stop and nothing focused moves no focus, so it stays in egui's input for the app's own /// binding (EffectCraft's Tab for the timeline's mini flowchart), from the window's first pass on. Once the app draws a /// focusable widget, that widget is a stop and the Tab is the framework's move to it. diff --git a/crates/ui-contract/tests/it/text/editor.rs b/crates/ui-contract/tests/it/text/editor.rs index c3246338f9..ecc63f134c 100644 --- a/crates/ui-contract/tests/it/text/editor.rs +++ b/crates/ui-contract/tests/it/text/editor.rs @@ -1029,3 +1029,30 @@ fn an_alt_chord_bound_only_out_of_scope_leaves_its_text_typed() { let fired: Vec = take_output(&frames.ctx).fired.into_iter().map(|fired| fired.command.id).collect(); assert!(fired.is_empty(), "nothing ran: {fired:?}"); } + +/// A disabled editor registers no stop, and its focus widget is still the component's own: it never becomes a Tab stop +/// of the app's own widgets. With every control in Tab order, Tab and Shift+Tab land on the button beside it each time. +#[trial] +fn tab_never_focuses_a_disabled_editor_s_widget() { + let log = RefCell::new(Vec::new()); + let seen = RefCell::new(Seen::default()); + let (editor, button) = (Cell::new(Id::NULL), Cell::new(Id::NULL)); + let mut show = |ui: &mut egui::Ui| { + editor.set(Probe::new(&log, true).label("Source").enabled(false).id_salt("code").show_at(ui, AT).id); + button.set(Button::new(&seen).id_salt("next").show_at(ui, NEXT).id); + }; + let mut frames = Frames::new(); + frames.root({ + let mut root = craft_ui::runtime::env::RootEnv::default(); + root.tab_all_controls = true; + root + }); + frames.idle(3, &mut show); + for shift in [false, false, true, true] { + let mods = if shift { Modifiers::SHIFT } else { Modifiers::NONE }; + frames.frame(vec![key_press(Key::Tab, mods), key_release(Key::Tab, mods)], &mut show); + frames.frame(Vec::new(), &mut show); + let focused = craft_ui::testing::focus::egui_focused(&frames.ctx); + assert_eq!(focused, Some(button.get()), "Tab (shift {shift}) lands on the button, never on the disabled editor {:?}", editor.get()); + } +} From 86c5f7a8d3875e846056cfddd85b07665b341387 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:31:27 +0000 Subject: [PATCH 23/56] Editor part: its focus widget is an egui focus candidate only while its component takes focus, so egui's arrows never reach a disabled editor; trial ids through the crate's id helpers --- crates/ui-contract/src/contract/editor.rs | 3 ++- crates/ui-contract/src/runtime/egui/editor.rs | 8 ++++--- .../src/testing/host_key_trials.rs | 10 ++++++--- crates/ui-contract/tests/it/text/editor.rs | 22 ++++++++++++++++--- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/crates/ui-contract/src/contract/editor.rs b/crates/ui-contract/src/contract/editor.rs index 922f2ced2c..d20a202b6e 100644 --- a/crates/ui-contract/src/contract/editor.rs +++ b/crates/ui-contract/src/contract/editor.rs @@ -72,7 +72,8 @@ pub(crate) fn run(cx: &mut Cx<'_, C>, ui: &mut Ui, step: &mut supe } let (ctx, id) = (cx.core.ctx.clone(), cx.core.id); let widget = ImeSurface::of(id, decl.key).widget(); - let focused = egui_editor::show(ui, widget, decl.rect, egui_focus::event_filter(keys.keep, false)); + let focusable = super::steps::takes_focus(cx.core.resolved); + let focused = egui_editor::show(ui, widget, decl.rect, egui_focus::event_filter(keys.keep, false), focusable); // The focus widget is the component's, enabled or not: it is never one of the app's own widgets (`take_app_widgets`). crate::runtime::pointer::record_text_widget(&ctx, widget, id); let read_only = cx.core.resolved.read_only || !cx.core.resolved.enabled; diff --git a/crates/ui-contract/src/runtime/egui/editor.rs b/crates/ui-contract/src/runtime/egui/editor.rs index e1824adda2..63e618eede 100644 --- a/crates/ui-contract/src/runtime/egui/editor.rs +++ b/crates/ui-contract/src/runtime/egui/editor.rs @@ -4,9 +4,11 @@ use egui::{EventFilter, Id, Rect, Ui}; /// Registers the editor's focus widget over `rect` and applies `filter` while it holds focus; returns whether it holds -/// focus. -pub(crate) fn show(ui: &mut Ui, id: Id, rect: Rect, filter: EventFilter) -> bool { - let response = ui.interact(rect, id, egui::Sense::focusable_noninteractive()); +/// focus. The widget is one of egui's focus candidates only while `focusable` (its component takes focus), so neither +/// Tab nor egui's arrows reach the editor of a disabled component. +pub(crate) fn show(ui: &mut Ui, id: Id, rect: Rect, filter: EventFilter, focusable: bool) -> bool { + let sense = if focusable { egui::Sense::focusable_noninteractive() } else { egui::Sense::hover() }; + let response = ui.interact(rect, id, sense); let focused = response.has_focus(); if focused { ui.memory_mut(|memory| memory.set_focus_lock_filter(id, filter)); diff --git a/crates/ui-contract/src/testing/host_key_trials.rs b/crates/ui-contract/src/testing/host_key_trials.rs index 30f7d0b42d..2ef494050a 100644 --- a/crates/ui-contract/src/testing/host_key_trials.rs +++ b/crates/ui-contract/src/testing/host_key_trials.rs @@ -714,9 +714,13 @@ fn each_focus_candidate_of_a_pass_is_classified_once() { let lookups = |n: usize| { let mut show = move |ui: &mut Ui| { for at in 0..n { - fixture::host_button(ui, Id::new(("app", at)), Rect::from_min_size(Pos2::new(10.0, 30.0 * at as f32), egui::vec2(60.0, 20.0))); - widget(ui, Id::new(("framework", at))); - register_stop(ui.ctx(), Stop::new(Id::new(("framework", at)), KeyUse::of(Input::Pointer))); + fixture::host_button( + ui, + crate::runtime::egui::memory::unique(("app", at)), + Rect::from_min_size(Pos2::new(10.0, 30.0 * at as f32), egui::vec2(60.0, 20.0)), + ); + widget(ui, crate::runtime::egui::memory::unique(("framework", at))); + register_stop(ui.ctx(), Stop::new(crate::runtime::egui::memory::unique(("framework", at)), KeyUse::of(Input::Pointer))); } }; let mut frames = Frames::new(); diff --git a/crates/ui-contract/tests/it/text/editor.rs b/crates/ui-contract/tests/it/text/editor.rs index ecc63f134c..fed1efee1c 100644 --- a/crates/ui-contract/tests/it/text/editor.rs +++ b/crates/ui-contract/tests/it/text/editor.rs @@ -1030,16 +1030,21 @@ fn an_alt_chord_bound_only_out_of_scope_leaves_its_text_typed() { assert!(fired.is_empty(), "nothing ran: {fired:?}"); } -/// A disabled editor registers no stop, and its focus widget is still the component's own: it never becomes a Tab stop -/// of the app's own widgets. With every control in Tab order, Tab and Shift+Tab land on the button beside it each time. +/// A disabled editor registers no stop, and its focus widget is still the component's own and no egui focus candidate: +/// it never becomes a Tab stop of the app's own widgets, and egui's arrows from the app's own focused widget never +/// reach it. With every control in Tab order, Tab and Shift+Tab land on the button beside it each time. #[trial] fn tab_never_focuses_a_disabled_editor_s_widget() { let log = RefCell::new(Vec::new()); let seen = RefCell::new(Seen::default()); let (editor, button) = (Cell::new(Id::NULL), Cell::new(Id::NULL)); + // The app's own egui button, level with the editor on its right: the editor lies straight to its left. + let app = craft_ui::testing::focus::named_id("app button"); + let app_at = Rect::from_min_size(Pos2::new(AT.right() + 40.0, AT.center().y - 10.0), egui::vec2(60.0, 20.0)); let mut show = |ui: &mut egui::Ui| { editor.set(Probe::new(&log, true).label("Source").enabled(false).id_salt("code").show_at(ui, AT).id); button.set(Button::new(&seen).id_salt("next").show_at(ui, NEXT).id); + ui.interact(app_at, app, egui::Sense::click()); }; let mut frames = Frames::new(); frames.root({ @@ -1053,6 +1058,17 @@ fn tab_never_focuses_a_disabled_editor_s_widget() { frames.frame(vec![key_press(Key::Tab, mods), key_release(Key::Tab, mods)], &mut show); frames.frame(Vec::new(), &mut show); let focused = craft_ui::testing::focus::egui_focused(&frames.ctx); - assert_eq!(focused, Some(button.get()), "Tab (shift {shift}) lands on the button, never on the disabled editor {:?}", editor.get()); + assert!( + focused == Some(button.get()) || focused == Some(app), + "Tab (shift {shift}) lands on a control, never on the disabled editor {:?}: {focused:?}", + editor.get() + ); } + craft_ui::runtime::focus::request(&frames.ctx, craft_ui::runtime::focus::FocusTarget::Id(app)); + frames.idle(2, &mut show); + assert_eq!(craft_ui::testing::focus::egui_focused(&frames.ctx), Some(app), "the app's button has the focus"); + frames.frame(vec![key_press(Key::ArrowLeft, Modifiers::NONE), key_release(Key::ArrowLeft, Modifiers::NONE)], &mut show); + frames.frame(Vec::new(), &mut show); + let focused = craft_ui::testing::focus::egui_focused(&frames.ctx); + assert!(focused == Some(app) || focused == Some(button.get()), "the arrow never reaches the disabled editor {:?}: {focused:?}", editor.get()); } From 34e2534d92337a0eb8f10b6be158951e740b5ee5 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 02:21:49 +0000 Subject: [PATCH 24/56] IME: the app's reset request made while a framework editor owns the IME is the engine's interrupt of that editor, recorded and fenced on --- crates/ui-contract/src/runtime/ime.rs | 47 ++++++++++++------- .../src/testing/host_key_trials.rs | 44 ++++++++++++++--- 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/crates/ui-contract/src/runtime/ime.rs b/crates/ui-contract/src/runtime/ime.rs index c931780bbb..6c97d87ac6 100644 --- a/crates/ui-contract/src/runtime/ime.rs +++ b/crates/ui-contract/src/runtime/ime.rs @@ -53,9 +53,9 @@ struct Engine { editor: Option, /// The app's own editor that wrote the IME output of the last pass while no framework editor owned the IME. host: Option, - /// The reset requests the app's own editor published with its IME output, oldest first, unanswered yet: their - /// completions and retirements are the app's and stay in egui's input for it, fence or not. The latest one the app - /// published while the fence is up is the fence's `reset`, from the pass the engine interrupted its composition on. + /// The reset requests of the app's own editor that a published IME output carried, its own or a framework editor's + /// it interrupted, oldest first, unanswered yet: their completions and retirements are the app's and stay in + /// egui's input for it, fence or not. The latest one published while the fence is up is the fence's `reset`. host_resets: Vec, } @@ -201,6 +201,16 @@ impl Engine { self.discard = true; } + /// Interrupts the owner's input method context: a running composition is ended and fenced (`interrupt`); with none + /// running there are no late events to drop, and only the interrupt goes out. + fn interrupt_owner(&mut self, owner: Id) { + if self.composing { + self.interrupt(owner); + } else { + self.interrupt = Some(owner); + } + } + /// Notes an answer to one of the app's own reset requests. A completion answers that request and every older one, /// as completions arrive in request order, and ends the fence when it waits for one of them; a retirement answers /// only its own request and, when the fence waits for it, leaves the end hook to ask again. @@ -423,11 +433,7 @@ pub(crate) fn request_interrupt(ctx: &Context, owner: Id) { if engine.owner != Some(owner) { return; } - if engine.composing { - engine.interrupt(owner); - } else { - engine.interrupt = Some(owner); - } + engine.interrupt_owner(owner); }); } @@ -497,7 +503,7 @@ pub(crate) fn end_pass(ctx: &Context) { let app_wrote = ctx.output(|output| output.ime.as_ref().map(|ime| (ime.owner, ime.context_generation))); // egui publishes the app's request only in a pass that has an IME output. let app_reset = app_wrote.and(os::app_reset(ctx, viewport)); - let (owner, interrupt, caret, update, published, host, app_request) = with(ctx, viewport, |engine| { + let (owner, interrupt, caret, update, published, host) = with(ctx, viewport, |engine| { let ran = std::mem::take(&mut engine.ran); if !ran { engine.edits.clear(); @@ -515,10 +521,15 @@ pub(crate) fn end_pass(ctx: &Context) { let last_host = engine.host; let kept = engine.host.filter(|host| app_wrote.is_some_and(|(owner, _)| owner == host.owner)).is_some_and(|host| host.composing); engine.host = app_wrote.filter(|_| engine.owner.is_none()).map(|(owner, generation)| HostIme { owner, generation, composing: kept }); - // The app's request while no framework editor owns the IME: every output this pass publishes carries it, the - // app's own or the engine's interrupt, and a new one becomes the fence's request below. - let app_request = app_reset.filter(|_| engine.owner.is_none()); - let fresh = app_request.filter(|id| !engine.host_resets.contains(id)); + // The app's request: every output this pass publishes carries it, the app's own or the engine's, and a new one + // becomes the fence's request after the write. While a framework editor owns the IME, egui publishes it on that + // editor's output as an interrupt, so the engine takes it as its own interrupt of the owner. + let fresh = app_reset.filter(|id| !engine.host_resets.contains(id)); + if fresh.is_some() + && let Some(owner) = engine.owner + { + engine.interrupt_owner(owner); + } // The fence has no request the integration can answer: the owner's output asks again, a framework editor's // or the app's own. if engine.stale @@ -531,13 +542,13 @@ pub(crate) fn end_pass(ctx: &Context) { let caret = engine.caret.take(); let password = caret.filter(|(id, ..)| Some(*id) == engine.owner).map(|(.., password)| password); let update = engine.observe(viewport, frame_nr, pass_nr, password); - (engine.owner, engine.interrupt.take(), caret, update, engine.published, last_host, app_request) + (engine.owner, engine.interrupt.take(), caret, update, engine.published, last_host) }); let host_interrupt = interrupt.filter(|old| owner.is_none() && app_wrote.is_some_and(|(id, _)| id == *old)); let written = if owner.is_none() && interrupt.is_none() { None } else if host_interrupt.is_some() { - Some((os::interrupt_written(ctx, viewport, app_request), None)) + Some((os::interrupt_written(ctx, viewport, app_reset), None)) } else { os::clear(ctx); match (caret, interrupt, update) { @@ -548,7 +559,7 @@ pub(crate) fn end_pass(ctx: &Context) { field, caret, interrupt: interrupt.is_some(), - app_reset: app_request, + app_reset, generation, password, surrounding: update.surrounding_text, @@ -565,7 +576,7 @@ pub(crate) fn end_pass(ctx: &Context) { field: Rect::NOTHING, caret: Rect::NOTHING, interrupt: true, - app_reset: app_request, + app_reset, generation, password: false, surrounding: IMESurroundingText::Unavailable, @@ -578,7 +589,7 @@ pub(crate) fn end_pass(ctx: &Context) { }; // The app's request counts as its own only when the published output carries it: egui's own output when the // engine wrote none, else the engine's. - let carried = app_request.filter(|id| written.as_ref().is_none_or(|(reset, _)| *reset == Some(*id))); + let carried = app_reset.filter(|id| written.as_ref().is_none_or(|(reset, _)| *reset == Some(*id))); with(ctx, viewport, |engine| { if let Some((reset, generation)) = written { if generation.is_some() { diff --git a/crates/ui-contract/src/testing/host_key_trials.rs b/crates/ui-contract/src/testing/host_key_trials.rs index 83e2690fd0..eb9d60448f 100644 --- a/crates/ui-contract/src/testing/host_key_trials.rs +++ b/crates/ui-contract/src/testing/host_key_trials.rs @@ -307,12 +307,9 @@ fn framework_field(ui: &mut Ui, id: Id) { ime::note_caret(ui.ctx(), id, rect, rect, false); } -/// A press on the app's editor takes the focus from a composing framework field, and the editor asks for its own reset -/// in the pass the field loses the IME, as EffectCraft's editor does when its caret moves after the press. The interrupt -/// of the field's composition publishes the editor's request, so the platform's answer reaches the editor, the field's -/// late commit stays fenced until then, and the commit after it reaches the editor. -#[trial] -fn an_app_editor_s_reset_asked_as_it_takes_the_focus_from_a_composing_framework_field_completes() { +/// The framework field of `framework_field` and the app's resetting editor beside it at its rect, the show closure that +/// draws both, and the frames after the field took the focus and composed "k". +fn framework_field_composing_beside_an_app_editor() -> (Id, Rect, Rc>, impl FnMut(&mut Ui), Frames) { let editor = Rc::new(RefCell::new(fixture::ResettingEditor::default())); let held = Rc::clone(&editor); let rect = Rect::from_min_size(Pos2::new(100.0, 100.0), egui::vec2(200.0, 30.0)); @@ -327,6 +324,16 @@ fn an_app_editor_s_reset_asked_as_it_takes_the_focus_from_a_composing_framework_ frames.frame(Vec::new(), &mut show); frames.frame(vec![Event::Ime(ImeEvent::Preedit { text: "k".to_owned(), active_range_chars: None })], &mut show); assert_eq!(frames.ime().map(|ime| ime.owner), Some(framework), "the framework field composes"); + (framework, rect, editor, show, frames) +} + +/// A press on the app's editor takes the focus from a composing framework field, and the editor asks for its own reset +/// in the pass the field loses the IME, as EffectCraft's editor does when its caret moves after the press. The interrupt +/// of the field's composition publishes the editor's request, so the platform's answer in the next frame reaches the +/// editor, the field's late commit stays fenced until then, and the commit after it reaches the editor. +#[trial] +fn an_app_editor_s_reset_asked_as_it_takes_the_focus_from_a_composing_framework_field_completes() { + let (framework, rect, editor, mut show, mut frames) = framework_field_composing_beside_an_app_editor(); let at = rect.center(); frames.frame(vec![moved(at), press(at)], &mut show); assert!(!frames.ime().is_some_and(|ime| ime.interrupt), "the field keeps the IME through the press pass"); @@ -338,7 +345,6 @@ fn an_app_editor_s_reset_asked_as_it_takes_the_focus_from_a_composing_framework_ assert!(ime.as_ref().is_some_and(|ime| ime.owner == framework && ime.interrupt), "the pass interrupts the field's composition"); assert_eq!(ime.and_then(|ime| ime.reset), own, "the interrupt publishes the editor's request, not a new one"); let Some(own) = own else { return }; - frames.frame(Vec::new(), &mut show); frames.frame( vec![ Event::Ime(ImeEvent::Commit("Q".to_owned())), @@ -351,6 +357,30 @@ fn an_app_editor_s_reset_asked_as_it_takes_the_focus_from_a_composing_framework_ assert_eq!(editor.borrow().text, "X", "the field's late commit is fenced and the commit after the completion reaches the editor"); } +/// The app's editor asks for its own reset at the press that takes the focus from a composing framework field, while +/// the field still owns the IME. egui publishes that request on the field's output as an interrupt; the engine takes it +/// as its interrupt of the field and fences on it. The field loses the IME in the next pass with no second interrupt, +/// the platform's answer in that frame reaches the editor, the field's late commit stays fenced, and the editor takes +/// the commits after it. +#[trial] +fn an_app_editor_s_reset_asked_at_the_press_on_it_while_a_framework_field_composes_completes() { + let (framework, rect, editor, mut show, mut frames) = framework_field_composing_beside_an_app_editor(); + let at = rect.center(); + editor.borrow_mut().ask = true; + frames.frame(vec![moved(at), press(at)], &mut show); + let own = editor.borrow().reset; + assert!(own.is_some(), "the editor asked for its own reset at the press"); + let ime = frames.ime().cloned(); + assert!(ime.as_ref().is_some_and(|ime| ime.owner == framework && ime.interrupt), "the request interrupts the field's composition"); + assert_eq!(ime.and_then(|ime| ime.reset), own, "the field's output carries the editor's request"); + let Some(own) = own else { return }; + frames.frame(vec![release(at), Event::Ime(ImeEvent::Commit("Q".to_owned())), Event::ImeResetCompleted { request_id: own }], &mut show); + assert!(!frames.ime().is_some_and(|ime| ime.interrupt), "the field loses the IME without a second interrupt"); + assert_eq!(editor.borrow().reset, None, "the completion of its request reaches the editor"); + frames.frame(vec![Event::Ime(ImeEvent::Commit("X".to_owned()))], &mut show); + assert_eq!(editor.borrow().text, "X", "the field's late commit is fenced and the editor takes the commit after the completion"); +} + #[trial] fn a_focused_egui_field_keeps_escape_and_the_clipboard_and_tabs_on_through_the_one_order() { let (host, mut show) = host_window(); From b2910054ca47c6f2ba928cd745a9011865dbf8d5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 19:11:34 -0800 Subject: [PATCH 25/56] menu: Keyboard Shortcuts can list only the app's own Show entries Show always listed All Commands, each menu, Tools, each panel and Other before the app's own `Options::areas`. An app that gives Tools and Menu Commands as its only entries got them at the end of a long strip, with a second Tools entry, and the dialog opened on All Commands. - `Options::own_areas`: Show lists only the app's own entries (and Fixed Keys), and the dialog opens on the first of them, or on the one that lists the command selected before it opened. - Go to Conflict and Accept and Go to Conflict show the holder under the first entry that lists it when Show has no All Commands. - The option is off by default, and a dialog without it is unchanged. --- crates/menu/src/shortcuts/keyboard.rs | 2 +- crates/menu/src/shortcuts/mod.rs | 5 ++ crates/menu/src/shortcuts/rows.rs | 30 ++++++++--- crates/menu/src/shortcuts/state.rs | 18 +++++-- crates/menu/src/shortcuts/view/bars.rs | 2 +- crates/menu/src/shortcuts/view/detail.rs | 2 +- crates/menu/tests/it/shortcuts/rows.rs | 69 +++++++++++++++++++++++- 7 files changed, 113 insertions(+), 15 deletions(-) diff --git a/crates/menu/src/shortcuts/keyboard.rs b/crates/menu/src/shortcuts/keyboard.rs index 9c2f74804d..9166e2533d 100644 --- a/crates/menu/src/shortcuts/keyboard.rs +++ b/crates/menu/src/shortcuts/keyboard.rs @@ -661,7 +661,7 @@ pub(crate) fn show(ui: &mut Ui, _cx: &mut BodyCx<'_>, env: &mut Env<'_>, state: state.keyboard.key = Some(key); } if let Some(c) = go { - state.go_to(&c); + state.go_to(env, &c); } if assign && let (Some(command), Some(key)) = (state.selected.clone(), state.keyboard.key) { let trigger = Trigger::single(Chord { mods, key }); diff --git a/crates/menu/src/shortcuts/mod.rs b/crates/menu/src/shortcuts/mod.rs index eed667ba9a..ec38488298 100644 --- a/crates/menu/src/shortcuts/mod.rs +++ b/crates/menu/src/shortcuts/mod.rs @@ -308,6 +308,10 @@ pub struct Options { pub area_tabs: bool, /// The app's own Show entries. pub areas: Vec, + /// false: Show lists All Commands, each menu, Tools, each panel and Other before the app's own + /// [`areas`](Self::areas); true: it lists only the app's own entries (and Fixed Keys), and the + /// dialog opens on the first of them. + pub own_areas: bool, /// `None`: every catalog entry is listed. Otherwise the table, its Show entries and search /// list only the entries it returns true for; the others keep their bindings and still count /// in conflicts. @@ -343,6 +347,7 @@ impl Default for Options { sort_by_label: false, area_tabs: false, areas: Vec::new(), + own_areas: false, visible: None, keyboard: false, fixed: Vec::new(), diff --git a/crates/menu/src/shortcuts/rows.rs b/crates/menu/src/shortcuts/rows.rs index 309ccf16a5..485d8fc7fc 100644 --- a/crates/menu/src/shortcuts/rows.rs +++ b/crates/menu/src/shortcuts/rows.rs @@ -210,8 +210,30 @@ fn listed<'k>(keymap: &'k Keymap, options: &Options) -> impl Iterator Vec { + let mut out = if options.own_areas { Vec::new() } else { built_in_areas(keymap, options, text) }; + let catalog = listed(keymap, options); + for a in options.areas.iter().filter(|a| catalog.clone().any(a.rows)) { + out.push(AreaEntry { id: AreaId::App(a.id), label: text.segment(a.label).into_owned() }); + } + if !options.fixed.is_empty() { + out.push(AreaEntry { id: AreaId::Fixed, label: text.words().fixed_keys.as_str().to_owned() }); + } + out +} + +/// The area that shows `b`'s row: All Commands when Show lists it, else the first listed area that holds the row. +pub(crate) fn area_of(areas: &[AreaEntry], b: &CommandDef, options: &Options) -> AreaId { + if areas.iter().any(|area| area.id == AreaId::All) { + return AreaId::All; + } + areas.iter().find(|area| in_area(&area.id, b, options)).map_or(AreaId::All, |area| area.id.clone()) +} + +/// All Commands, each menu, Tools, each panel and Other, leaving out areas with no rows. +fn built_in_areas(keymap: &Keymap, options: &Options, text: &Say) -> Vec { let catalog = listed(keymap, options); let mut out = vec![AreaEntry { id: AreaId::All, label: text.words().all_commands.as_str().to_owned() }]; let mut menus: Vec<&str> = Vec::new(); @@ -239,12 +261,6 @@ pub(crate) fn areas(keymap: &Keymap, options: &Options, text: &Say) -> Vec, state: &mut DialogState) { } let out = notice.show(ui); match (out.action, &goto) { - (Some(0), Some(command)) => state.go_to(command), + (Some(0), Some(command)) => state.go_to(env, command), (Some(at), Some(_)) if undo && at == 1 => state.undo(env), (Some(0), None) if undo => state.undo(env), _ => {} diff --git a/crates/menu/src/shortcuts/view/detail.rs b/crates/menu/src/shortcuts/view/detail.rs index d38514868d..d1394ee815 100644 --- a/crates/menu/src/shortcuts/view/detail.rs +++ b/crates/menu/src/shortcuts/view/detail.rs @@ -257,6 +257,6 @@ fn holders(ui: &mut Ui, env: &Env<'_>, state: &mut DialogState) { } } if let Some(command) = go { - state.go_to(&command); + state.go_to(env, &command); } } diff --git a/crates/menu/tests/it/shortcuts/rows.rs b/crates/menu/tests/it/shortcuts/rows.rs index df232b1c33..5ff4299e35 100644 --- a/crates/menu/tests/it/shortcuts/rows.rs +++ b/crates/menu/tests/it/shortcuts/rows.rs @@ -4,9 +4,10 @@ use std::sync::Arc; use craft_host::{AppInfo, Host}; use craft_keymap::{Binding, CommandDef, CommandRef, Keymap, Platform, Policy, Scope, Scopes}; -use craft_menu::shortcuts::{HoldSetting, Outcome}; +use craft_menu::shortcuts::{Area, HoldSetting, Outcome}; use craft_ui::contract::Role; use craft_ui::testing::trial; +use egui::{Key, Modifiers}; use super::fixture::{self, Rig}; @@ -110,3 +111,69 @@ fn the_summary_without_a_ui_is_the_one_summarize_writes() { let (title, _) = text.split_once('\n').expect("a title line"); assert_eq!(craft_menu::shortcuts::summary::text_for(&km, &host, title), text); } + +fn is_tool(def: &CommandDef) -> bool { + matches!(def.kind, craft_keymap::CommandKind::Tool { .. }) +} + +fn area(rig: &Rig) -> String { + let shared = rig.shared.borrow(); + shared.state.snapshot(&shared.km).expect("the dialog has shown").area +} + +/// With `own_areas`, Show lists only the app's own entries, the dialog opens on the first of them, and its table +/// lists that entry's rows. Without it, the built-in entries come first and the dialog opens on All Commands. +#[trial] +fn own_areas_show_only_the_apps_entries_and_open_on_the_first() { + let tune = |own: bool| { + move |options: &mut craft_menu::shortcuts::Options| { + options.area_tabs = true; + options.areas = vec![Area::new("tools", "Tools", is_tool), Area::new("menu", "Menu Commands", |def| !is_tool(def))]; + options.own_areas = own; + } + }; + let rig = Rig::tuned(Platform::Mac, tune(true)); + assert_eq!(rig.names_with(Role::TAB, ""), ["Tools", "Menu Commands"], "only the app's entries are tabs"); + assert_eq!(area(&rig), "tools", "the dialog opens on the first of them"); + let rows = rig.names_with(Role::ROW, ""); + assert!(rows.iter().all(|row| row.contains("Marquee")) && !rows.is_empty(), "the table lists the Tools rows only: {rows:?}"); + + let rig = Rig::tuned(Platform::Mac, tune(false)); + let tabs = rig.names_with(Role::TAB, ""); + assert_eq!(tabs.first().map(String::as_str), Some("All Commands"), "the built-in entries come first: {tabs:?}"); + assert!(tabs.iter().any(|t| t == "Menu Commands"), "the app's entries follow them: {tabs:?}"); + assert_eq!(area(&rig), "all"); +} + +/// A dialog opened with a command selected, with Show listing only the app's entries, opens on the entry that lists it. +#[trial] +fn own_areas_open_on_the_selected_commands_entry() { + let mut rig = Rig::tuned(Platform::Mac, |options| { + options.areas = vec![Area::new("tools", "Tools", is_tool), Area::new("menu", "Menu Commands", |def| !is_tool(def))]; + options.own_areas = true; + }); + { + let mut shared = rig.shared.borrow_mut(); + let mut state = craft_menu::shortcuts::DialogState::new(); + state.select(&CommandRef::from("file.export")); + shared.state = state; + } + rig.pass(); + assert_eq!(area(&rig), "menu", "Export… is listed under Menu Commands"); + assert!(rig.names_with(Role::ROW, "").iter().any(|row| row.starts_with("Export…")), "its row shows"); +} + +/// Accept and Go to Conflict, with Show listing only the app's entries, shows the holder under the entry that lists +/// it. +#[trial] +fn going_to_a_conflict_picks_an_area_that_lists_the_holder() { + let mut rig = Rig::tuned(Platform::Mac, |options| { + options.areas = vec![Area::new("tools", "Tools", is_tool), Area::new("menu", "Menu Commands", |def| !is_tool(def))]; + options.own_areas = true; + }); + rig.click("Marquee Tool: M"); + rig.press(Modifiers::COMMAND, Key::E); + rig.click("Accept and Go to Conflict"); + assert_eq!(area(&rig), "menu", "Export… is listed under Menu Commands"); + assert!(rig.has("Export…"), "the holder's row shows"); +} From dee3e7af57806d147d68844c65213a7837effc54 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 19:20:04 -0800 Subject: [PATCH 26/56] menu: Keyboard Shortcuts can open at a size the app gives An editable Keyboard Shortcuts dialog sizes from its content, so with a large catalog the table takes the whole window and the dialog covers it. The app had no way to choose another size. - `Options::size`: the dialog opens at this size, in points, until the user resizes it. A size that is not finite is ignored. - Without it, an editable dialog opens as before and a read-only one keeps its moderate fixed size. --- crates/menu/src/shortcuts/mod.rs | 12 +++++++++++- crates/menu/tests/it/shortcuts/mod.rs | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/crates/menu/src/shortcuts/mod.rs b/crates/menu/src/shortcuts/mod.rs index eed667ba9a..b7fc0b93e2 100644 --- a/crates/menu/src/shortcuts/mod.rs +++ b/crates/menu/src/shortcuts/mod.rs @@ -287,6 +287,10 @@ pub struct Options { /// The window title [`ShortcutsDialog::show`] draws and the summary's heading, already translated. /// `None`: the dialog's own "Keyboard Shortcuts". pub title: Option, + /// `None`: an editable dialog opens at the room the window gives it, and a read-only one at a moderate fixed size. + /// Otherwise the dialog opens at this size, in points, until the user resizes it; a size that is not finite is + /// ignored. + pub size: Option, /// true; false shows the table read-only with Close and Summarize. pub editable: bool, /// The name, already translated, that edits of a built-in set are saved under. `None`: the dialog's own @@ -333,6 +337,7 @@ impl Default for Options { fn default() -> Options { Options { title: None, + size: None, editable: true, custom_set_name: None, conflicts: ConflictMode::Ask, @@ -618,10 +623,15 @@ fn frame(ui: &mut Ui, env: &mut Env<'_>, state: &mut DialogState) -> ShortcutsOu // A read-only reference opens at a fixed, moderate height (production's key list scrolls inside it), not at the // window's; the user's own resize is still remembered. let reference = !env.options.editable; + let asked = env.options.size.filter(|size| size.is_finite()); + let size = asked.or(reference.then_some(egui::vec2(READ_ONLY_WIDTH, READ_ONLY_HEIGHT))); let session = RefCell::new(Session { env, state }); let shown = Dialog::new(title) .resizable(true) - .overlay(|overlay| if reference { overlay.size(egui::vec2(READ_ONLY_WIDTH, READ_ONLY_HEIGHT)) } else { overlay }) + .overlay(|overlay| match size { + Some(size) => overlay.size(size), + None => overlay, + }) .remember(SaveKey::new("craft_menu.shortcuts")) .outer_gesture(true) .collection_body() diff --git a/crates/menu/tests/it/shortcuts/mod.rs b/crates/menu/tests/it/shortcuts/mod.rs index 2fc7cba0e3..fc1ff547c8 100644 --- a/crates/menu/tests/it/shortcuts/mod.rs +++ b/crates/menu/tests/it/shortcuts/mod.rs @@ -22,3 +22,22 @@ fn a_read_only_dialog_opens_at_a_moderate_height() { let close = rig.fixture.by_label("Close").expect("the close button"); assert!(close.rect.bottom() < 560.0, "the dialog's footer sits within a moderate height, not the 700-point window: {:?}", close.rect); } + +/// The editable dialog's bounds, opened with `size` in the rig's 1000 by 700 point window. +fn dialog_bounds(size: Option) -> egui::Rect { + let rig = Rig::tuned(Platform::Windows, |options| options.size = size); + rig.fixture.by_role(craft_ui::contract::Role::DIALOG).first().expect("the dialog").rect +} + +/// An editable dialog opens at the size the app gives, larger or smaller than its own, and ignores a size that is not +/// finite. +#[trial] +fn an_editable_dialog_opens_at_the_size_the_app_gives() { + let own = dialog_bounds(None).size(); + for asked in [own + egui::vec2(200.0, 120.0), egui::vec2(own.x + 80.0, own.y - 60.0)] { + let opened = dialog_bounds(Some(asked)).size(); + assert!((opened - asked).abs().max_elem() < 1.0, "asked {asked:?}, opened {opened:?}, own {own:?}"); + } + let endless = dialog_bounds(Some(egui::vec2(f32::INFINITY, f32::NAN))).size(); + assert_eq!(endless, own, "a size that is not finite opens the dialog as without one"); +} From f244e6212b6e751efbaa301be0a95bef2c10e3f1 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 03:39:37 +0000 Subject: [PATCH 27/56] Pin egui to storytold/egui next (b15ffe9bf), which now carries the IME reset, arrow cover, multi-pass texture and focus candidate commits --- Cargo.lock | 28 ++++++++++++++-------------- Cargo.toml | 28 ++++++++++++++-------------- crates/craft/src/egui_fork.rs | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe943467c2..ed3cb7769d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5562,7 +5562,7 @@ dependencies = [ [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", "emath", @@ -5618,7 +5618,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -5653,7 +5653,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "accesskit", "ahash", @@ -5672,7 +5672,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -5691,7 +5691,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "block2 0.6.2", "bytemuck", @@ -5711,7 +5711,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", "egui", @@ -5724,7 +5724,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "eframe", "egui", @@ -5801,7 +5801,7 @@ dependencies = [ [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", ] @@ -5874,7 +5874,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -5900,7 +5900,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[package]] name = "equator" @@ -15232,19 +15232,19 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[patch.unused]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/aiongg/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" diff --git a/Cargo.toml b/Cargo.toml index d39b1bf024..cc40daf56d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -316,20 +316,20 @@ hayro-postscript = { path = "vendor/hayro-postscript" } linesweeper = { path = "vendor/linesweeper" } vello_common = { path = "vendor/vello_common" } vello_cpu = { path = "vendor/vello_cpu" } -ecolor = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -emath = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -epaint = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -epaint_default_fonts = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui-winit = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui-wgpu = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui_glow = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui_extras = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui_kittest = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui_system_font_provider = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -eframe = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui_demo_lib = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui_inspection = { git = "https://github.com/aiongg/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +emath = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # symphonia's FLAC decoder restores LPC samples as `residual + (prediction as i32)`. In a valid diff --git a/crates/craft/src/egui_fork.rs b/crates/craft/src/egui_fork.rs index 182581c420..b8535c5c1e 100644 --- a/crates/craft/src/egui_fork.rs +++ b/crates/craft/src/egui_fork.rs @@ -3,7 +3,7 @@ /// The egui fork the library is built and tested with. Apps patch egui to exactly this. pub const GIT: &str = "https://github.com/storytold/egui.git"; /// The commit of [`GIT`]. -pub const REV: &str = "a87d00caaec947ea781657c6ff410c9838016d18"; +pub const REV: &str = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec"; /// The packages the workspace patches to the fork (the `[patch.crates-io]` entries that name [`GIT`]). pub const PACKAGES: &[&str] = &[ From 8a133a094b3c50a0b8a5c65c80b2d1d533e01185 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Wed, 25 Nov 2026 07:50:26 +0700 Subject: [PATCH 28/56] theme, ui-widgets, ui-patterns, ui-shell: StartLayout::Column, one centred column at most size.page.column (820) wide a page margin from every edge: title (Display) and subtitle, New and Open centred, the recent files as rows only when there are any, the app's section, the templates as cards that keep their size and wrap, the links under links_title centred without icons and StartLink::primary as a primary pill with its icon; templates_title prop. Tile::page, blank paper on the popup surface's shadow fitted to the picture, now New Document's preset card and a Template's with Template::page. Stories start_screen_column, start_screen_column_without_files, tile_page; trials; New Document's page trial checks the filled page; dumps updated --- crates/theme/sizes/comfortable.json | 3 + crates/theme/sizes/compact.json | 3 + crates/theme/src/dump.rs | 7 +- crates/theme/src/lib.rs | 2 +- crates/theme/src/sizes.rs | 1 + crates/theme/src/tokens/size.rs | 9 + .../tokens/adwaita-dark-high-comfortable.txt | 1 + .../tokens/adwaita-dark-high-compact.txt | 1 + .../adwaita-dark-standard-comfortable.txt | 1 + .../tokens/adwaita-dark-standard-compact.txt | 1 + .../tokens/adwaita-light-high-comfortable.txt | 1 + .../tokens/adwaita-light-high-compact.txt | 1 + .../adwaita-light-standard-comfortable.txt | 1 + .../tokens/adwaita-light-standard-compact.txt | 1 + .../tokens/artcraft-dark-high-comfortable.txt | 1 + .../tokens/artcraft-dark-high-compact.txt | 1 + .../artcraft-dark-standard-comfortable.txt | 1 + .../tokens/artcraft-dark-standard-compact.txt | 1 + .../artcraft-light-high-comfortable.txt | 1 + .../tokens/artcraft-light-high-compact.txt | 1 + .../artcraft-light-standard-comfortable.txt | 1 + .../artcraft-light-standard-compact.txt | 1 + .../tokens/breeze-dark-high-comfortable.txt | 1 + .../dumps/tokens/breeze-dark-high-compact.txt | 1 + .../breeze-dark-standard-comfortable.txt | 1 + .../tokens/breeze-dark-standard-compact.txt | 1 + .../tokens/breeze-light-high-comfortable.txt | 1 + .../tokens/breeze-light-high-compact.txt | 1 + .../breeze-light-standard-comfortable.txt | 1 + .../tokens/breeze-light-standard-compact.txt | 1 + .../tokens/classic-light-high-comfortable.txt | 1 + .../tokens/classic-light-high-compact.txt | 1 + .../classic-light-standard-comfortable.txt | 1 + .../tokens/classic-light-standard-compact.txt | 1 + .../tokens/graphite-dark-high-comfortable.txt | 1 + .../tokens/graphite-dark-high-compact.txt | 1 + .../graphite-dark-standard-comfortable.txt | 1 + .../tokens/graphite-dark-standard-compact.txt | 1 + .../graphite-light-high-comfortable.txt | 1 + .../tokens/graphite-light-high-compact.txt | 1 + .../graphite-light-standard-comfortable.txt | 1 + .../graphite-light-standard-compact.txt | 1 + .../tokens/pro-dark-high-comfortable.txt | 1 + .../dumps/tokens/pro-dark-high-compact.txt | 1 + ...ro-dark-standard-comfortable-app-sizes.txt | 1 + .../tokens/pro-dark-standard-comfortable.txt | 1 + .../tokens/pro-dark-standard-compact.txt | 1 + .../pro-light-gray-light-high-comfortable.txt | 1 + .../pro-light-gray-light-high-compact.txt | 1 + ...-light-gray-light-standard-comfortable.txt | 1 + .../pro-light-gray-light-standard-compact.txt | 1 + .../tokens/pro-light-high-comfortable.txt | 1 + .../dumps/tokens/pro-light-high-compact.txt | 1 + .../tokens/pro-light-standard-comfortable.txt | 1 + .../tokens/pro-light-standard-compact.txt | 1 + .../tokens/soft-dark-high-comfortable.txt | 1 + .../dumps/tokens/soft-dark-high-compact.txt | 1 + .../tokens/soft-dark-standard-comfortable.txt | 1 + .../tokens/soft-dark-standard-compact.txt | 1 + .../tokens/soft-light-high-comfortable.txt | 1 + .../dumps/tokens/soft-light-high-compact.txt | 1 + .../soft-light-standard-comfortable.txt | 1 + .../tokens/soft-light-standard-compact.txt | 1 + .../solarized-dark-dark-high-comfortable.txt | 1 + .../solarized-dark-dark-high-compact.txt | 1 + ...larized-dark-dark-standard-comfortable.txt | 1 + .../solarized-dark-dark-standard-compact.txt | 1 + .../tokens/studio-dark-high-comfortable.txt | 1 + .../dumps/tokens/studio-dark-high-compact.txt | 1 + .../studio-dark-standard-comfortable.txt | 1 + .../tokens/studio-dark-standard-compact.txt | 1 + .../tokens/studio-light-high-comfortable.txt | 1 + .../tokens/studio-light-high-compact.txt | 1 + .../studio-light-standard-comfortable.txt | 1 + .../tokens/studio-light-standard-compact.txt | 1 + ...ctorcraft-modern-dark-high-comfortable.txt | 1 + .../vectorcraft-modern-dark-high-compact.txt | 1 + ...craft-modern-dark-standard-comfortable.txt | 1 + ...ctorcraft-modern-dark-standard-compact.txt | 1 + ...torcraft-modern-light-high-comfortable.txt | 1 + .../vectorcraft-modern-light-high-compact.txt | 1 + ...raft-modern-light-standard-comfortable.txt | 1 + ...torcraft-modern-light-standard-compact.txt | 1 + ...ft-modern-medium-dark-high-comfortable.txt | 1 + ...rcraft-modern-medium-dark-high-compact.txt | 1 + ...odern-medium-dark-standard-comfortable.txt | 1 + ...ft-modern-medium-dark-standard-compact.txt | 1 + ...t-modern-medium-light-high-comfortable.txt | 1 + ...craft-modern-medium-light-high-compact.txt | 1 + ...dern-medium-light-standard-comfortable.txt | 1 + ...t-modern-medium-light-standard-compact.txt | 1 + .../form_dialogs/new_document/cards.rs | 29 +-- .../tests/it/form_dialogs/new_document.rs | 11 +- crates/ui-shell/src/shell/recent.rs | 12 +- crates/ui-shell/src/shell/recent_list.rs | 1 + crates/ui-shell/src/shell/start.rs | 214 ++++++++++++++++-- crates/ui-shell/src/shell/start/stories.rs | 48 ++++ crates/ui-shell/tests/it/shell/start.rs | 77 +++++++ crates/ui-widgets/src/tile_grid/stories.rs | 6 + crates/ui-widgets/src/tile_grid/tile.rs | 30 ++- 100 files changed, 483 insertions(+), 55 deletions(-) diff --git a/crates/theme/sizes/comfortable.json b/crates/theme/sizes/comfortable.json index 36545501dc..27811ad1a6 100644 --- a/crates/theme/sizes/comfortable.json +++ b/crates/theme/sizes/comfortable.json @@ -71,6 +71,9 @@ "short": 120.0, "track": 144.0 }, + "page": { + "column": 820.0 + }, "pane": { "least": 50.0 }, diff --git a/crates/theme/sizes/compact.json b/crates/theme/sizes/compact.json index a57c5b4435..2d4b98d254 100644 --- a/crates/theme/sizes/compact.json +++ b/crates/theme/sizes/compact.json @@ -71,6 +71,9 @@ "short": 96.0, "track": 128.0 }, + "page": { + "column": 820.0 + }, "pane": { "least": 40.0 }, diff --git a/crates/theme/src/dump.rs b/crates/theme/src/dump.rs index eee2c42eee..6c8758568e 100644 --- a/crates/theme/src/dump.rs +++ b/crates/theme/src/dump.rs @@ -7,8 +7,8 @@ use std::fmt::Write as _; use crate::{ BarSizes, ColorToken, ControlSizes, DialogSizes, DockColumnSizes, Easing, Edge, Elevation, ElevationTokens, FloatSizes, FontSlot, Gaps, - GripShape, HandleSizes, HitSizes, IconSizes, Insets, KnobShape, LengthSizes, Motion, MotionTokens, Pads, PaneSizes, PlotSizes, RadiusSet, - RailSizes, RampSizes, Rgba, RowSizes, ShapeTokens, SizeTokens, SpaceTokens, StrokeTokens, ThumbSamples, ThumbSizes, Tokens, TypeStyle, + GripShape, HandleSizes, HitSizes, IconSizes, Insets, KnobShape, LengthSizes, Motion, MotionTokens, Pads, PageSizes, PaneSizes, PlotSizes, + RadiusSet, RailSizes, RampSizes, Rgba, RowSizes, ShapeTokens, SizeTokens, SpaceTokens, StrokeTokens, ThumbSamples, ThumbSizes, Tokens, TypeStyle, TypeTokens, WellShape, WindowSizes, }; @@ -143,6 +143,7 @@ fn size_lines(out: &mut Lines, size: &SizeTokens) { pane, dock, dialog, + page, } = size; let ControlSizes { sm, md } = control; out.line("size.control.sm", len(*sm)); @@ -215,6 +216,8 @@ fn size_lines(out: &mut Lines, size: &SizeTokens) { out.line("size.dialog.wrap", len(*wrap)); out.line("size.dialog.button", len(*button)); out.line("size.dialog.side_button", len(*side_button)); + let PageSizes { column } = page; + out.line("size.page.column", len(*column)); } fn slot(s: FontSlot) -> &'static str { diff --git a/crates/theme/src/lib.rs b/crates/theme/src/lib.rs index ad90903550..28e950415e 100644 --- a/crates/theme/src/lib.rs +++ b/crates/theme/src/lib.rs @@ -98,7 +98,7 @@ pub use token_group::{GroupValues, TokenGroup}; pub use tokens::{ AccentColors, BarSizes, CaptionColors, ColorToken, ColorTokens, ControlSizes, DataColors, DialogSizes, DockColumnSizes, Edge, EdgeColors, ElevationTokens, FloatSizes, FontSlot, Gaps, GripMark, GripShape, HandleSizes, HitSizes, IconSizes, Insets, KnobShape, LengthSizes, LetterCase, - LineColors, LocatorShape, Motion, MotionTokens, OverlayColors, Pads, PaneSizes, PlotSizes, RadiusSet, RailSizes, RampSizes, RowSizes, + LineColors, LocatorShape, Motion, MotionTokens, OverlayColors, Pads, PageSizes, PaneSizes, PlotSizes, RadiusSet, RailSizes, RampSizes, RowSizes, ShapeTokens, SizeTokens, SpaceTokens, StateColors, Status, StatusColors, StatusKind, StrokeTokens, SurfaceColors, TextColors, ThumbSamples, ThumbSizes, Tokens, TypeRole, TypeStyle, TypeTokens, WellShape, WindowSizes, }; diff --git a/crates/theme/src/sizes.rs b/crates/theme/src/sizes.rs index c3f8025ad2..d0ebfed203 100644 --- a/crates/theme/src/sizes.rs +++ b/crates/theme/src/sizes.rs @@ -146,6 +146,7 @@ pub(crate) fn leaves(b: &mut Preset) -> Vec> { "base.size.dialog.wrap" Num 120.0..=1024.0 => s.dialog.wrap; "base.size.dialog.button" Num 24.0..=240.0 => s.dialog.button; "base.size.dialog.side_button" Num 24.0..=240.0 => s.dialog.side_button; + "base.size.page.column" Num 240.0..=2048.0 => s.page.column; } let sp = &mut b.space; leaves! { out; diff --git a/crates/theme/src/tokens/size.rs b/crates/theme/src/tokens/size.rs index bd4f69b9c6..9285c4e5db 100644 --- a/crates/theme/src/tokens/size.rs +++ b/crates/theme/src/tokens/size.rs @@ -310,6 +310,15 @@ pub struct SizeTokens { pub dock: DockColumnSizes, /// Dialogs: their content width and their buttons. pub dialog: DialogSizes, + /// Full-window pages. + pub page: PageSizes, +} + +/// The sizes of a full-window page (a start page), in logical pixels. +#[derive(Clone, Copy, Debug, Default, PartialEq)] +pub struct PageSizes { + /// The widest a page's centred column of content grows; a narrower room keeps the page's margin at each side. + pub column: f32, } /// The sizes of the panes of a dock's split, in logical pixels. diff --git a/crates/theme/tests/dumps/tokens/adwaita-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/adwaita-dark-high-comfortable.txt index b5eaff10fa..a3b210c342 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/adwaita-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/adwaita-dark-high-compact.txt index 8a000a8b1d..6f8f139fd4 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/adwaita-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/adwaita-dark-standard-comfortable.txt index b60c4660eb..22aa65aa0f 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/adwaita-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/adwaita-dark-standard-compact.txt index d9ba4d191c..999e0cc005 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/adwaita-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/adwaita-light-high-comfortable.txt index 67ca889771..35219bedd0 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/adwaita-light-high-compact.txt b/crates/theme/tests/dumps/tokens/adwaita-light-high-compact.txt index b257a262ae..f765308c4d 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/adwaita-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/adwaita-light-standard-comfortable.txt index e719821b56..ce332514f4 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/adwaita-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/adwaita-light-standard-compact.txt index e5b785c851..e3aca1bd4a 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/artcraft-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/artcraft-dark-high-comfortable.txt index b163cd46e5..0d495a3043 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/artcraft-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/artcraft-dark-high-compact.txt index 78438edcea..10f513dc43 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/artcraft-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/artcraft-dark-standard-comfortable.txt index 5c79aa8c02..d55e4899e5 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/artcraft-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/artcraft-dark-standard-compact.txt index 0eeec55f30..39ae17705a 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/artcraft-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/artcraft-light-high-comfortable.txt index 1f42323960..624a23f1de 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/artcraft-light-high-compact.txt b/crates/theme/tests/dumps/tokens/artcraft-light-high-compact.txt index 08b18dcb03..3eb51e943c 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/artcraft-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/artcraft-light-standard-comfortable.txt index 3314537cb2..0ed32cad89 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/artcraft-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/artcraft-light-standard-compact.txt index eb4d771525..ed72061a85 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/breeze-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/breeze-dark-high-comfortable.txt index 019465e5b7..549a134c58 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/breeze-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/breeze-dark-high-compact.txt index e3c630e045..e107d59e09 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/breeze-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/breeze-dark-standard-comfortable.txt index 187f4c5ce0..768d0f10be 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/breeze-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/breeze-dark-standard-compact.txt index f8fd665768..f3a5739801 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/breeze-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/breeze-light-high-comfortable.txt index affaf06b7d..a07c709ac7 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/breeze-light-high-compact.txt b/crates/theme/tests/dumps/tokens/breeze-light-high-compact.txt index f97279220e..e8da62e1e1 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/breeze-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/breeze-light-standard-comfortable.txt index 8f8452ffd6..de4f9b0bcd 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/breeze-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/breeze-light-standard-compact.txt index 9aab1e6438..62b425fbb5 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/classic-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/classic-light-high-comfortable.txt index 0313c28fa2..e3448a88ed 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/classic-light-high-compact.txt b/crates/theme/tests/dumps/tokens/classic-light-high-compact.txt index 6ed815f020..7b7718c215 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/classic-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/classic-light-standard-comfortable.txt index 2db3097b89..57046d8dcb 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/classic-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/classic-light-standard-compact.txt index c92767dd02..6046f088fe 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/graphite-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/graphite-dark-high-comfortable.txt index 28d5675410..8eb7764e91 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/graphite-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/graphite-dark-high-compact.txt index 2d37c60ae4..b17339240d 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/graphite-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/graphite-dark-standard-comfortable.txt index fdf074abbf..800e8e321e 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/graphite-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/graphite-dark-standard-compact.txt index 468c79fe5a..e52e2c75a8 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/graphite-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/graphite-light-high-comfortable.txt index 99e16fa51f..f51c5eebc7 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/graphite-light-high-compact.txt b/crates/theme/tests/dumps/tokens/graphite-light-high-compact.txt index 33ef213208..be91ae5500 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/graphite-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/graphite-light-standard-comfortable.txt index 95f7b8108a..17df054390 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/graphite-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/graphite-light-standard-compact.txt index 801ed81a71..cbc377b81f 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/pro-dark-high-comfortable.txt index 3b2c32d0be..b4948153f5 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/pro-dark-high-compact.txt index 34b9d99bc0..39d68864b1 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable-app-sizes.txt b/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable-app-sizes.txt index 2964d6953d..ac8127cfba 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable-app-sizes.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable-app-sizes.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable.txt index 721a51aee8..0096ac9e68 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/pro-dark-standard-compact.txt index a87e51dfc5..827ea48719 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-light-gray-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/pro-light-gray-light-high-comfortable.txt index 8e58298270..993b1c2c83 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-gray-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-gray-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-light-gray-light-high-compact.txt b/crates/theme/tests/dumps/tokens/pro-light-gray-light-high-compact.txt index 9b37c7232e..27c5ce4dda 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-gray-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-gray-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-light-gray-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/pro-light-gray-light-standard-comfortable.txt index 42a059da1b..b8486f1261 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-gray-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-gray-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-light-gray-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/pro-light-gray-light-standard-compact.txt index 9b0726cbb1..bff0f83b94 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-gray-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-gray-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/pro-light-high-comfortable.txt index c0f710bf68..800dd40bf7 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-light-high-compact.txt b/crates/theme/tests/dumps/tokens/pro-light-high-compact.txt index 522f29b1a2..a7b21afd46 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/pro-light-standard-comfortable.txt index 4fe12a7b49..f12fa15981 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/pro-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/pro-light-standard-compact.txt index 8e31eb40bf..94cfdf85e1 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/soft-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/soft-dark-high-comfortable.txt index 8efbfd674d..1142e6b81b 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/soft-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/soft-dark-high-compact.txt index c8af3713c6..bc310dfdee 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/soft-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/soft-dark-standard-comfortable.txt index 6097578157..f54c4f048c 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/soft-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/soft-dark-standard-compact.txt index 1061081192..84a5ee707a 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/soft-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/soft-light-high-comfortable.txt index 6b0daad252..648cb23f72 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/soft-light-high-compact.txt b/crates/theme/tests/dumps/tokens/soft-light-high-compact.txt index 537bc28778..800968d9c2 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/soft-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/soft-light-standard-comfortable.txt index 8444a1ac84..8459523915 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/soft-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/soft-light-standard-compact.txt index a04cf2103c..2503879274 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/solarized-dark-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/solarized-dark-dark-high-comfortable.txt index bdf0aa48b0..2ab8fca561 100644 --- a/crates/theme/tests/dumps/tokens/solarized-dark-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/solarized-dark-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/solarized-dark-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/solarized-dark-dark-high-compact.txt index 2503ac48d3..88dd688f2b 100644 --- a/crates/theme/tests/dumps/tokens/solarized-dark-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/solarized-dark-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/solarized-dark-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/solarized-dark-dark-standard-comfortable.txt index 3bb3d5d0ae..86e757ef37 100644 --- a/crates/theme/tests/dumps/tokens/solarized-dark-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/solarized-dark-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/solarized-dark-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/solarized-dark-dark-standard-compact.txt index 15bd64f3a3..4a7e377fe8 100644 --- a/crates/theme/tests/dumps/tokens/solarized-dark-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/solarized-dark-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/studio-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/studio-dark-high-comfortable.txt index 86fa0e5143..c73196392a 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/studio-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/studio-dark-high-compact.txt index cc37776b2c..09c2d1a2c9 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/studio-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/studio-dark-standard-comfortable.txt index 9e4fd3748a..9f9c23a0b2 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/studio-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/studio-dark-standard-compact.txt index cf28125ba8..e5e96e2a69 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/studio-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/studio-light-high-comfortable.txt index bee113924d..686a152060 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/studio-light-high-compact.txt b/crates/theme/tests/dumps/tokens/studio-light-high-compact.txt index b30c62c8b1..c8f8eabdf4 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/studio-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/studio-light-standard-comfortable.txt index 93b0f384bb..dff8e709ea 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/studio-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/studio-light-standard-compact.txt index bad4578f5b..70bad1890e 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt index ee47af893f..618ec893fa 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt index bcfcb2970c..81ba013d6a 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-comfortable.txt index 0b1c8870ce..d818b2c176 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-compact.txt index d13e94d03f..d854a76d2a 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-comfortable.txt index f3a2666a29..5c3fd955e3 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-compact.txt index 9233c07eca..819575105a 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-comfortable.txt index f4bc397bb1..fd1cb95685 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-compact.txt index 281b3a0aa7..e26127715c 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt index 59a517959d..b7308bb811 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt index 2d2d840faf..645e743212 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-comfortable.txt index d6c8136658..d445915f76 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-compact.txt index aeda88b611..933a277b1f 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-comfortable.txt index bd8464d80c..15fb2dd7e4 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-compact.txt index 8eb261539b..d0b273e8c4 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-high-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-comfortable.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-comfortable.txt index bc821f3e69..63e7f742de 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-comfortable.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-compact.txt b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-compact.txt index 6f1c1139ac..bc1adb7ea9 100644 --- a/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-light-standard-compact.txt @@ -198,6 +198,7 @@ size.dialog.least = 380 size.dialog.wrap = 440 size.dialog.button = 84 size.dialog.side_button = 96 +size.page.column = 820 stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 diff --git a/crates/ui-patterns/src/patterns/form_dialogs/new_document/cards.rs b/crates/ui-patterns/src/patterns/form_dialogs/new_document/cards.rs index 85d75fd697..80d950ef08 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/new_document/cards.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/new_document/cards.rs @@ -6,15 +6,14 @@ use super::{NewDocumentWords, Read, Session, background_label, depth_label, mode use crate::buttons::{Button, ButtonOutput}; use crate::contract::{Bind, CollectionEvent, Props as _, SelectMode, Show as _, ShowCollection as _, clicked}; use crate::display::{Shade, Text}; -use crate::list::{List, ListRow, ThumbAspect}; +use crate::list::{List, ListRow}; use crate::patterns::presets::{PresetId, PresetLibrary}; -use crate::primitives::{ContentPainterCx, StrokeWidth}; use crate::runtime::env::{Label, UnitKind}; use crate::style::TypeRole; use crate::tabs::{Tab, TabKind, TabStrip}; use crate::tile_grid::{CardText, Tile, TileGrid}; use craft_behavior::{DisplayOrder, ItemSource, Selection, SelectionChange, keyed}; -use egui::{CornerRadius, Rect, Stroke, StrokeKind, Ui, vec2}; +use egui::Ui; use std::borrow::Cow; use std::cell::Cell; @@ -350,30 +349,12 @@ fn recent_title(recent: &DocumentOptions, cx: &CardCx<'_, DocumentOptions>) -> L found.map_or_else(|| cx.words.custom.clone(), |preset| preset_title(preset, cx.setup, cx.words, cx.preset_words)) } -/// The tile of a card: the page outline at the card's aspect, the title and the size line. +/// The tile of a card: the page at the card's shape, the title and the size line. fn tile_of(card: &DocumentCard) -> Tile<'static> { - let page = card.settings.page(); - let tile = Tile::new(card.title.clone()) - .detail(card.line.clone()) - .flat_thumbnail() - .thumb(ThumbAspect::new(2, 1), move |painter: &ContentPainterCx<'_>, rect: Rect| paint_page(painter, rect, page)); + let (width, height) = card.settings.page(); + let tile = Tile::new(card.title.clone()).detail(card.line.clone()).page(width, height); match &card.tooltip { Some(tooltip) => tile.tooltip(tooltip.clone()), None => tile, } } - -/// A page icon inside the tile's picture, in content ink so the tile alone draws the selection ring. -fn paint_page(painter: &ContentPainterCx<'_>, picture: Rect, (width, height): (f64, f64)) { - let page = page_rect(picture, width, height); - let stroke = Stroke::new(painter.stroke_width(StrokeWidth::Thin), painter.ink()); - painter.painter.rect_stroke(page, CornerRadius::ZERO, stroke, StrokeKind::Inside); -} - -/// The page's aspect inside `room`, capped at the 30-point size of the original outline. -fn page_rect(room: Rect, width: f64, height: f64) -> Rect { - const PAGE_SIDE: f32 = 30.0; - let (width, height) = (width.max(1.0) as f32, height.max(1.0) as f32); - let scale = (room.width().min(PAGE_SIDE) / width).min(room.height().min(PAGE_SIDE) / height); - Rect::from_center_size(room.center(), vec2(width * scale, height * scale)) -} diff --git a/crates/ui-patterns/tests/it/form_dialogs/new_document.rs b/crates/ui-patterns/tests/it/form_dialogs/new_document.rs index f56c6eddc2..91b09b9a18 100644 --- a/crates/ui-patterns/tests/it/form_dialogs/new_document.rs +++ b/crates/ui-patterns/tests/it/form_dialogs/new_document.rs @@ -357,11 +357,12 @@ fn recent_preset_cards_paint_one_small_page_at_its_aspect() { for (name, key, size) in [("Clipboard", clipboard, wide), ("Custom", custom, tall)] { let card = tree.bounds_of(key).expect("visible tile bounds"); let caption = frames.texts().iter().find(|line| line.text == name).expect("the preset title is painted"); - let outlines: Vec<_> = shapes + // The page is blank paper: the one white fill centred in the card above its title. + let pages: Vec<_> = shapes .iter() .filter_map(|shape| match shape { egui::Shape::Rect(rect) - if rect.stroke.width > 0.0 + if rect.fill == egui::Color32::WHITE && (rect.rect.center().x - card.center().x).abs() <= 1.0 && card.contains_rect(rect.rect) && rect.rect.bottom() <= caption.rect.top() => @@ -371,9 +372,9 @@ fn recent_preset_cards_paint_one_small_page_at_its_aspect() { _ => None, }) .collect(); - assert_eq!(outlines.len(), 1, "one page outline and no extra frame in {name} at {scale}: {outlines:?}"); - let page = outlines[0]; - assert!((page.width().max(page.height()) - 30.0).abs() <= 1.0, "the compact page outline in {name}: {page:?}"); + assert_eq!(pages.len(), 1, "one page and no extra frame in {name} at {scale}: {pages:?}"); + let page = pages[0]; + assert!(page.width() < card.width() && page.height() < card.height() / 2.0, "a small page inside the card in {name}: {page:?}"); assert!((page.width() / page.height() - size.width as f32 / size.height as f32).abs() < 0.05, "the page has the preset's aspect"); } diff --git a/crates/ui-shell/src/shell/recent.rs b/crates/ui-shell/src/shell/recent.rs index 556f61dbe6..f5be8d1519 100644 --- a/crates/ui-shell/src/shell/recent.rs +++ b/crates/ui-shell/src/shell/recent.rs @@ -69,12 +69,22 @@ pub struct Template { pub name: String, /// The line under the name: "1920 × 1080 px". pub detail: String, + /// The width and height of the page the template makes, in any one unit: its card shows the page + /// (`Tile::page`), as New Document's presets do, in place of the template's thumbnail. + pub page: Option<(f64, f64)>, } impl Template { /// A template `id` named `name`, with `detail` under the name. pub fn new(id: impl Into, name: impl Into, detail: impl Into) -> Self { - Template { id: id.into(), name: name.into(), detail: detail.into() } + Template { id: id.into(), name: name.into(), detail: detail.into(), page: None } + } + + /// This template makes a `width` by `height` page, which its card shows. + #[must_use] + pub fn page(mut self, width: f64, height: f64) -> Self { + self.page = Some((width, height)); + self } } diff --git a/crates/ui-shell/src/shell/recent_list.rs b/crates/ui-shell/src/shell/recent_list.rs index 56d5dac416..05801c693c 100644 --- a/crates/ui-shell/src/shell/recent_list.rs +++ b/crates/ui-shell/src/shell/recent_list.rs @@ -98,6 +98,7 @@ impl<'a> RecentList<'a> { offers_new: true, offers_open: true, pinned_title: None, + templates_title: None, heading_sections: false, }; let files: Vec = recent.iter().take(max_recent).cloned().collect(); diff --git a/crates/ui-shell/src/shell/start.rs b/crates/ui-shell/src/shell/start.rs index 59d7a31a76..0454b86f8d 100644 --- a/crates/ui-shell/src/shell/start.rs +++ b/crates/ui-shell/src/shell/start.rs @@ -11,10 +11,10 @@ use crate::buttons::button::ButtonStyleKey; use crate::buttons::{Button, Link}; use crate::choice::Segmented; use crate::contract::{ - ActivateOn, Bind, BodyCx, CollectionEvent, Entry, Gap, NoValue, Outcome, Pad, Pattern, Props, Remember as _, Scroll, SelectMode, Show as _, - ShowCollection as _, ShowContainer as _, Sizing, clicked, + ActivateOn, Bind, BodyCx, CollectionEvent, Entry, Gap, NoValue, Outcome, Pad, Pattern, Props, Remember as _, RowAlign, Scroll, SelectMode, + Show as _, ShowCollection as _, ShowContainer as _, Sizing, clicked, }; -use crate::display::{Divider, Icon, Text}; +use crate::display::{Divider, Icon, Shade, Text}; use crate::layout_components::{Row, Stack}; use crate::list::{List, ListRow, RowEvent, ThumbAspect, TrailingFace, TrailingPart}; use crate::menu::{Menu, MenuItem}; @@ -29,11 +29,11 @@ use crate::runtime::commands::{CommandSet as _, Commands as _}; use crate::runtime::env::{AgeStyle, Env, Label}; use crate::sections::{HeaderStrength, Section}; use crate::style::{Corners, DataColor, StyleCx, SurfaceKind, SurroundLook, TypeRole}; -use crate::tile_grid::{CaptionPlace, GridZoom, Tile, TileGrid}; +use crate::tile_grid::{CaptionPlace, CardText, GridZoom, Tile, TileGrid}; use craft_behavior::{DisplayOrder, IconId, ItemSource, Proposal, SelectionChange, keyed}; use craft_theme::variant::{CustomVariant, Emphasis, RadiusStep, Tone, VariantLook}; use craft_theme::{Rgba, Tokens, Variant}; -use egui::{CornerRadius, Rect, Response, Ui, Vec2, pos2, vec2}; +use egui::{CornerRadius, Rect, Response, Ui, UiBuilder, Vec2, pos2, vec2}; use std::borrow::Cow; use std::cell::RefCell; use std::path::{Path, PathBuf}; @@ -150,6 +150,21 @@ pub enum StartLayout { Gallery, /// A greeting page: a title, the templates, then the recent files as rows. It shows neither Pinned nor the drop card. Greeting, + /// One centred column, at most `size.page.column` wide and a page margin from every edge: the title and subtitle, + /// New and Open, the recent files as rows when there are any, the app's section, the templates as cards that keep + /// their size and wrap, then the links, the call to action as a pill. It shows neither Pinned, the drop card nor + /// the recent files' view switch and sort. + Column, +} + +/// The column's template cards keep the card thumbnail's size, so as many as fit stand in a row and the rest wrap. +const COLUMN_CARD_ZOOM: f32 = 1.0; + +/// The call to action among a Column page's links: the primary variant at pill corners, with its icon. +const CALL_TO_ACTION_LOOK: CustomVariant = CustomVariant::new::("craft_ui.start-call-to-action", call_to_action_look); + +fn call_to_action_look(tokens: &Tokens) -> VariantLook { + Variant::PRIMARY.resolve(tokens).radius(RadiusStep::Pill) } /// Where a host section sits on the start screen. @@ -345,6 +360,15 @@ pub struct StartScreen<'a> { /// The page's heading. #[prop(into)] title: Option