From ae722739ab984d9daa1f0f4c6cea1a6ea82f5cc2 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 03:28:05 +0000 Subject: [PATCH 01/22] ui-contract: presses the focused component holds leave egui's input again, and Tab stays navigation with nothing focused The merge of next (b138b533fe) passed whether a stop was focused where withdraw_taken takes whether the app's own widget reads its keys from egui, so no held press left egui's input while anything had focus. With nothing focused the document canvas's held claims leave out Tab and Shift+Tab: a tool that claims the plain keys no longer keeps keyboard navigation from moving into the window. The unfocused-canvas trial releases its keys, since a press of a key already down is a repeat. --- crates/ui-contract/src/runtime/keys/input.rs | 11 ++++++++--- crates/ui-contract/src/runtime/keys/route.rs | 4 +++- crates/ui-contract/src/testing/key_trials.rs | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/ui-contract/src/runtime/keys/input.rs b/crates/ui-contract/src/runtime/keys/input.rs index de0b670c2..b0ca7a5fc 100644 --- a/crates/ui-contract/src/runtime/keys/input.rs +++ b/crates/ui-contract/src/runtime/keys/input.rs @@ -541,12 +541,17 @@ enum PressUse { /// The chords the focused component of `record` claims: its stop's, the state-dependent ones (`keys::claim`) of the /// component, its arena root and its menu level, and a bare End where it declares `EndKey::EndMode`. With nothing -/// focused and no modal layer open, the window's document canvas's state-dependent claims hold instead. +/// focused and no modal layer open, the window's document canvas's state-dependent claims hold instead, except Tab and +/// Shift+Tab. pub(super) fn focused_claims(record: &focus::FocusedRecord, stage: &Stage) -> Vec { let mut claims = record.claims.clone(); let canvas = record.canvas.filter(|_| !record.foreign); - let holds = |owner: Id| [record.focused, record.root, record.menu, record.menu_bar, canvas].contains(&Some(owner)); - claims.extend(stage.claims.iter().filter(|(owner, _)| holds(*owner)).map(|(_, chord)| *chord)); + let holds = |owner: Id| [record.focused, record.root, record.menu, record.menu_bar].contains(&Some(owner)); + // The unfocused canvas's tool never takes Tab or Shift+Tab: with nothing focused they move focus into the window, + // so a tool that claims the plain keys cannot trap keyboard navigation. + let canvas_holds = + |owner: Id, chord: &Chord| Some(owner) == canvas && !(chord.key == Key::Tab && (chord.mods == Mods::NONE || chord.mods == Mods::SHIFT)); + claims.extend(stage.claims.iter().filter(|(owner, chord)| holds(*owner) || canvas_holds(*owner, chord)).map(|(_, chord)| *chord)); // A bare End belongs to a stop that declares `EndKey::EndMode`: it reads the key as a claimed chord and toggles its // mode, so no collection navigation or scroll owner takes it as a move to the end. if record.keys.is_some_and(|keys| keys.end == EndKey::EndMode) { diff --git a/crates/ui-contract/src/runtime/keys/route.rs b/crates/ui-contract/src/runtime/keys/route.rs index f88b186d9..a889e9d4d 100644 --- a/crates/ui-contract/src/runtime/keys/route.rs +++ b/crates/ui-contract/src/runtime/keys/route.rs @@ -185,7 +185,9 @@ pub(crate) fn begin(ctx: &Context, press_captured: bool) -> EscapeRouting { } let over: Vec = batch.presses.iter().map(held_press).collect(); let (shortcuts, held) = owned_shortcuts(ctx, target.as_ref(), &batch, &consumed, &taken_texts, &over); - withdraw_taken(ctx, target.is_some(), &batch, &held, &withdrawn_texts); + // The app's own widget, focused or the window's canvas, reads its keys from egui. + let host = target.as_ref().or(canvas.as_ref()).is_some_and(|rec| rec.stop.host); + withdraw_taken(ctx, host, &batch, &held, &withdrawn_texts); let pasted = batch.paste.clone().zip(focused).map(|(content, id)| (id, content)); // PLAN: a repeat Tab of a held-over key is not gated; `take_nav` reads `batch.tabs` before this hook runs (owner: focus). // One Escape press cancels once: its repeats cancel nothing more, in the layer it closed or in what that uncovered. diff --git a/crates/ui-contract/src/testing/key_trials.rs b/crates/ui-contract/src/testing/key_trials.rs index acc91136a..1efd74fce 100644 --- a/crates/ui-contract/src/testing/key_trials.rs +++ b/crates/ui-contract/src/testing/key_trials.rs @@ -258,7 +258,8 @@ fn an_unfocused_press_the_window_canvas_takes_reaches_no_app_shortcut() { take_output(&frames.ctx); let fired = |frames: &mut Frames, show: &mut dyn FnMut(&mut Ui)| { frames.frame(vec![key_press(Key::PageDown, Modifiers::NONE), key_press(Key::ArrowRight, Modifiers::NONE)], &mut *show); - frames.frame(Vec::new(), &mut *show); + // Released, so the next round's presses are fresh presses, not repeats of held keys. + frames.frame(vec![key_release(Key::PageDown, Modifiers::NONE), key_release(Key::ArrowRight, Modifiers::NONE)], &mut *show); take_output(&frames.ctx).fired.len() }; assert_eq!(fired(&mut frames, &mut show), 0, "neither press reaches the app's commands"); From 22205fffd1db1ba95a65564a2607593f77a45b5c Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 03:28:05 +0000 Subject: [PATCH 02/22] ui-contract: an OS file drop lands where it was dropped, and files hovering in the pass that takes it start their own drag A drop the next frame takes reads the drop's own position, not a pointer the next files have moved, and the files the OS holds over the window in that pass start a session once the drop ends the old one. The files' pointer is the system pointer where the platform tells one, else the pass's own: the drag's noted source pointer is from the pass before. --- crates/ui-contract/src/runtime/drag.rs | 88 ++++++++++++++++++-------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/crates/ui-contract/src/runtime/drag.rs b/crates/ui-contract/src/runtime/drag.rs index bfe015694..30dfc6f6a 100644 --- a/crates/ui-contract/src/runtime/drag.rs +++ b/crates/ui-contract/src/runtime/drag.rs @@ -260,6 +260,12 @@ struct Session { dropped: Option, /// A file drop has arrived but no pointer position is available yet. waiting_for_pointer: bool, + /// Where the OS dropped the files: the pass that takes a drop after the frame of its arrival places it there, not + /// at a pointer that has moved on (files hovering again for a drag of their own). + dropped_at: Option, + /// Files the OS holds over the window in the pass that takes this session's drop: a drag of their own, which + /// starts when the drop ends this session (`end_pass`). + hovering_next: Vec, /// The root frame the session started in, the only one in which [`amend`] changes its payload. began: u64, } @@ -364,6 +370,8 @@ pub fn start( os: false, dropped: None, waiting_for_pointer: false, + dropped_at: None, + hovering_next: Vec::new(), began, }); board.ended = None; @@ -489,8 +497,7 @@ fn os_files(ctx: &Context) { let hovering = !seen.hovered.is_empty(); // A session whose window closed has no pass left to end it. let closed = source_viewport(ctx).is_some_and(|window| !pass::live_viewports(ctx).contains(&window)); - let host = WindowHost::of(ctx); - let position = if host.desktop_pointer().is_some() { host.pointer_in(viewport) } else { pointer::frame_raw(ctx).pos }; + let position = os_files_pointer(ctx, viewport, pointer::frame_raw(ctx).pos); let positioned = position.is_some(); // A window target can take the drop immediately only if the pointer has not moved since resolution. let window_winner = PerViewport::::with(ctx, viewport, |targets| targets.winner_window && targets.pointer == position); @@ -501,23 +508,11 @@ fn os_files(ctx: &Context) { if has_drop { repaint = true; } - board.session = Some(Session { - source: Id::NULL.with("craft_ui::os_files"), - moving: Moving::default(), - viewport, - button: PointerButton::Primary, - payload: Arc::new(OsFiles { files: if has_drop { seen.dropped } else { seen.hovered } }), - also: Vec::new(), - preview: DragPreview::None, - env: None, - mark: None, - released: None, - taken: false, - os: true, - dropped: (has_drop && positioned).then_some(frame.saturating_add(1)), - waiting_for_pointer: has_drop && !positioned, - began: frame, - }); + let mut session = os_session(if has_drop { seen.dropped } else { seen.hovered }, viewport, frame); + session.dropped = (has_drop && positioned).then_some(frame.saturating_add(1)); + session.dropped_at = position.filter(|_| has_drop); + session.waiting_for_pointer = has_drop && !positioned; + board.session = Some(session); board.ended = None; board.started += 1; } @@ -527,6 +522,7 @@ fn os_files(ctx: &Context) { let files = seen.dropped.into_iter().map(|file| with_hovered_type(file, hovered)).collect(); session.payload = Arc::new(OsFiles { files }); session.viewport = viewport; + session.dropped_at = position; if window_winner { session.dropped = Some(frame); } else if positioned { @@ -540,9 +536,13 @@ fn os_files(ctx: &Context) { // Targets register this pass and take the drop in the next, after their winner is resolved. session.waiting_for_pointer = false; session.dropped = Some(frame.saturating_add(1)); + session.dropped_at = position; repaint = true; } else if hovering { session.viewport = viewport; + if session.dropped == Some(frame) { + session.hovering_next = seen.hovered; + } } else if (session.viewport == viewport || closed) && !seen.reading && !session.waiting_for_pointer @@ -560,6 +560,29 @@ fn os_files(ctx: &Context) { } } +/// A session of `files` the OS holds over `viewport`, started in root frame `frame`. +fn os_session(files: Vec, viewport: ViewportId, frame: u64) -> Session { + Session { + source: Id::NULL.with("craft_ui::os_files"), + moving: Moving::default(), + viewport, + button: PointerButton::Primary, + payload: Arc::new(OsFiles { files }), + also: Vec::new(), + preview: DragPreview::None, + env: None, + mark: None, + released: None, + taken: false, + os: true, + dropped: None, + waiting_for_pointer: false, + dropped_at: None, + hovering_next: Vec::new(), + began: frame, + } +} + /// `file` with the media type the OS gave the hovered file at the same path, which egui does not repeat on a drop. fn with_hovered_type(mut file: OsFile, hovered: Option<&OsFiles>) -> OsFile { let held = hovered.and_then(|hovered| hovered.files.iter().find(|held| held.path.is_some() && held.path == file.path)); @@ -588,12 +611,22 @@ pub fn cross_window_pointer(ctx: &Context, viewport: ViewportId) -> Option } /// The pointer of the running session in screen space, whatever its payload: the pointer `dragging_of` pairs with a -/// payload, where the button went up in the pass of its release (`PointerFrame::pick_pos`). `None` without a session or -/// a pointer. +/// payload, where the button went up in the pass of its release (`PointerFrame::pick_pos`); for an OS drop, where the +/// files were dropped in the pass that takes it. `None` without a session or a pointer. pub(crate) fn session_pointer(ctx: &Context) -> Option { - let os = board(ctx, |board| board.session.as_ref().map(|session| session.os))?; - let host = WindowHost::of(ctx); - if os && host.desktop_pointer().is_some() { host.pointer_in(pass::current_viewport(ctx)) } else { pointer::frame_raw(ctx).pick_pos } + let frame = pass::root_frame_nr(ctx); + let (os, dropped_at) = + board(ctx, |board| board.session.as_ref().map(|session| (session.os, session.dropped_at.filter(|_| session.dropped == Some(frame)))))?; + let own = pointer::frame_raw(ctx).pick_pos; + if os { dropped_at.or_else(|| os_files_pointer(ctx, pass::current_viewport(ctx), own)) } else { own } +} + +/// The pointer of OS files over `viewport`: the system pointer where the platform tells one, since the OS sends the +/// window no pointer events while it drags files over it; else `own`, the pass's own pointer. A drag's noted source +/// pointer (`windows::note_source_pointer`) is from the pass before, for the other windows, so it never stands in for +/// the pass's own. +fn os_files_pointer(ctx: &Context, viewport: ViewportId, own: Option) -> Option { + if windows::system_pointer(ctx).is_some() { WindowHost::of(ctx).pointer_in(viewport) } else { own } } /// The running session's payload whose type is `payload` and the pointer in screen space. For files the OS drags, the @@ -799,8 +832,7 @@ pub(crate) fn ended(ctx: &Context, source: Id) -> Option released + 1); let ended_here = is_source && !held && session.released.is_none(); if expired || (ended_here && !foreign_target) { - board.session = None; + let next = std::mem::take(&mut session.hovering_next); + board.session = (!next.is_empty()).then(|| os_session(next, viewport, frame)); + board.started += u64::from(board.session.is_some()); } else if ended_here { session.released = Some(frame); } From 3b200f43d66b3273f5d42ef55235747ac5e1f789 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 03:28:05 +0000 Subject: [PATCH 03/22] text: a one-line field pastes each line ending as a space again; the editor's step loop is its own function The merge of next (b138b533fe) dropped one_line from the paste when it took the step loop. Moving the loop out of TextEditor::update keeps the update under clippy's cognitive complexity limit. --- crates/text/src/ui/editor.rs | 139 ++++++++++++++++++++--------------- 1 file changed, 80 insertions(+), 59 deletions(-) diff --git a/crates/text/src/ui/editor.rs b/crates/text/src/ui/editor.rs index 29a7d6b94..93a9a5ee6 100644 --- a/crates/text/src/ui/editor.rs +++ b/crates/text/src/ui/editor.rs @@ -376,6 +376,11 @@ impl EditorMode { } } +/// `text` on one line: each line ending (`\r\n`, `\r` or `\n`) becomes one space. +fn one_line(text: &str) -> String { + text.replace("\r\n", " ").replace(['\r', '\n'], " ") +} + /// What the editor did this pass. #[derive(Debug)] #[non_exhaustive] @@ -572,6 +577,80 @@ fn show_i_beam(cx: &mut Cx<'_, TextEditor<'_>>, phase: &PressPhase, vertical: bo } } +/// Applies one pass's editor steps to `edits` in order: typing, the marked text, moves, deletes, selections, the edit +/// commands and the commands keys fired. Returns the text a Copy or Cut put on the clipboard, and whether a command +/// asked for the character panel. +fn apply_steps( + edits: &mut Edits<'_>, + steps: Vec>, + mode: EditorMode, + masked: bool, + pasted: Option<&str>, + fallback: Rect, +) -> (Option, bool) { + let mut copied: Option = None; + let mut ending: Option> = None; + let mut character_panel = false; + for step in steps { + // A commit or cancel ends the session; an input method's committed text still lands. + if (edits.done.commit || edits.done.cancel) && ending.is_none() { + break; + } + let input = match step { + EditorStep::Input(input) => input, + EditorStep::Command(command, _) => { + edits.command(command, &mut character_panel); + continue; + } + _ => continue, + }; + if let Some(range) = ending.take() { + if let EditorInput::Text(text) = &input { + edits.commit_marked(range, text); + continue; + } + edits.drop_marked(range); + } + match input { + EditorInput::Preedit { text, cursor, .. } => { + let active = cursor.map(|bytes| byte_range_to_chars(&text, bytes)); + ending = edits.preedit(&text, active); + } + EditorInput::ImeCommit => ending = edits.session.preedit.take(), + EditorInput::Text(text) => edits.done.changed |= edits.insert_typed(&text), + EditorInput::Newline { .. } if edits.session.preedit.is_none() && mode.multiline() => { + edits.done.changed |= edits.insert_text("\n", EditKind::Typed); + } + EditorInput::Tab if mode.takes_tab() => edits.done.changed |= edits.insert_text("\t", EditKind::Typed), + EditorInput::Move(step, mods) => edits.motion(step, mods), + EditorInput::Delete { forward, by, .. } => edits.done.changed |= edits.delete(forward, by), + EditorInput::DeleteSurrounding { before, after, unit, .. } => edits.done.changed |= edits.delete_around(before, after, unit), + EditorInput::Select { anchor, focus, .. } => { + let lines = lines_of(&mut *edits.host, fallback); + edits.end_composition(); + edits.selection = TextSelection { anchor: char_at(&lines, anchor), caret: char_at(&lines, focus) }; + } + EditorInput::Edit(EditCommand::SelectAll) => edits.select_all(), + EditorInput::Edit(EditCommand::Copy) if !masked => copied = edits.selected_text(), + EditorInput::Edit(EditCommand::Cut) if !masked => { + copied = edits.selected_text(); + edits.done.changed |= edits.delete_selection(); + } + EditorInput::Edit(EditCommand::Paste) => { + if let Some(text) = pasted { + let text = if mode.multiline() { text.to_string() } else { one_line(text) }; + edits.done.changed |= edits.insert_text(&text, EditKind::Pasted); + } + } + _ => {} + } + } + if let Some(range) = ending { + edits.drop_marked(range); + } + (copied, character_panel) +} + /// The clipboard's text when the pass's input asks to paste and the clipboard has it ready. fn pasted_text(cx: &mut Cx<'_, TextEditor<'_>>, steps: &[EditorStep]) -> Option> { if !steps.iter().any(|step| matches!(step, EditorStep::Input(EditorInput::Edit(EditCommand::Paste)))) { @@ -636,7 +715,6 @@ impl Component for TextEditor<'_> { let now = cx.now(); let pasted = pasted_text(cx, &steps); let (mode, masked) = (self.mode, self.masked); - let mut copied: Option = None; let mut session = std::mem::take(cx.memory::()); let mut edits = Edits { host: &mut *self.host, @@ -652,64 +730,7 @@ impl Component for TextEditor<'_> { edits.reconcile(); let fallback = space.doc_rect(cx.rect); - let mut ending: Option> = None; - let mut character_panel = false; - for step in steps { - // A commit or cancel ends the session; an input method's committed text still lands. - if (edits.done.commit || edits.done.cancel) && ending.is_none() { - break; - } - let input = match step { - EditorStep::Input(input) => input, - EditorStep::Command(command, _) => { - edits.command(command, &mut character_panel); - continue; - } - _ => continue, - }; - if let Some(range) = ending.take() { - if let EditorInput::Text(text) = &input { - edits.commit_marked(range, text); - continue; - } - edits.drop_marked(range); - } - match input { - EditorInput::Preedit { text, cursor, .. } => { - let active = cursor.map(|bytes| byte_range_to_chars(&text, bytes)); - ending = edits.preedit(&text, active); - } - EditorInput::ImeCommit => ending = edits.session.preedit.take(), - EditorInput::Text(text) => edits.done.changed |= edits.insert_typed(&text), - EditorInput::Newline { .. } if edits.session.preedit.is_none() && mode.multiline() => { - edits.done.changed |= edits.insert_text("\n", EditKind::Typed); - } - EditorInput::Tab if mode.takes_tab() => edits.done.changed |= edits.insert_text("\t", EditKind::Typed), - EditorInput::Move(step, mods) => edits.motion(step, mods), - EditorInput::Delete { forward, by, .. } => edits.done.changed |= edits.delete(forward, by), - EditorInput::DeleteSurrounding { before, after, unit, .. } => edits.done.changed |= edits.delete_around(before, after, unit), - EditorInput::Select { anchor, focus, .. } => { - let lines = lines_of(&mut *edits.host, fallback); - edits.end_composition(); - edits.selection = TextSelection { anchor: char_at(&lines, anchor), caret: char_at(&lines, focus) }; - } - EditorInput::Edit(EditCommand::SelectAll) => edits.select_all(), - EditorInput::Edit(EditCommand::Copy) if !masked => copied = edits.selected_text(), - EditorInput::Edit(EditCommand::Cut) if !masked => { - copied = edits.selected_text(); - edits.done.changed |= edits.delete_selection(); - } - EditorInput::Edit(EditCommand::Paste) => { - if let Some(text) = &pasted { - edits.done.changed |= edits.insert_text(text, EditKind::Pasted); - } - } - _ => {} - } - } - if let Some(range) = ending { - edits.drop_marked(range); - } + let (copied, character_panel) = apply_steps(&mut edits, steps, mode, masked, pasted.as_deref(), fallback); // A press is the pass's last pointer event (H0), so the pass's editor input came before it. match press.phase { PressPhase::Down { start, .. } if start.button == craft_behavior::PointerButton::Primary => { From 8ef406cd5d04a983e6c47a805101ef25e991bfe4 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 03:28:05 +0000 Subject: [PATCH 04/22] ui-widgets: a tile grid that takes its width from its content asks for at least one card again The merge of next (b138b533fe) brought back the early zero width that ebf9254522 removed, so a measured stack lost the grid's rows and what follows them. The selectable-text trial names its canvas with Id::unique. --- crates/ui-widgets/src/tile_grid/grid.rs | 3 --- crates/ui-widgets/tests/it/text/selectable.rs | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/ui-widgets/src/tile_grid/grid.rs b/crates/ui-widgets/src/tile_grid/grid.rs index 36961bf62..07d0c57aa 100644 --- a/crates/ui-widgets/src/tile_grid/grid.rs +++ b/crates/ui-widgets/src/tile_grid/grid.rs @@ -1042,9 +1042,6 @@ impl Collection for TileGrid<'_, K /// The last layout again while the width, the rows stamp and everything the arrangement reads are the same. fn ideal_width(&self, item: Option, _rows: usize, cx: &StyleCx<'_>) -> f32 { - if self.card_columns == 0 { - return 0.0; - } let style = GridSizes::of(cx, self.card, self.card_text, self.items.row_height, self.regular_card_padding, self.action_place); let aspect = if self.aspect.is_finite() && self.aspect > 0.0 { self.aspect } else { 1.0 }; let around = style.around.get(self.caption, self.detail_line); diff --git a/crates/ui-widgets/tests/it/text/selectable.rs b/crates/ui-widgets/tests/it/text/selectable.rs index c471d839b..ecc76542b 100644 --- a/crates/ui-widgets/tests/it/text/selectable.rs +++ b/crates/ui-widgets/tests/it/text/selectable.rs @@ -153,7 +153,7 @@ fn metadata_value_copies_without_selecting_the_row() { fn tab_toggles_the_panels_from_read_only_text_a_press_or_drag_focused() { let text = Rc::new(Cell::new(Id::NULL)); let seen = text.clone(); - let canvas = Id::new("document canvas"); + let canvas = Id::unique("document canvas"); let mut fixture = Fixture::new(move |ui| { Button::new("Save").show(ui); seen.set(SelectableText::new("Path", "/projects/poster.indd").show(ui).id); From c13c6eeed5d059b870a1498e325be7409bfabe02 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 03:28:05 +0000 Subject: [PATCH 05/22] docs: regenerate the components index --- docs/components-index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/components-index.md b/docs/components-index.md index 2a3c0638f..a0bbf32a2 100644 --- a/docs/components-index.md +++ b/docs/components-index.md @@ -236,7 +236,7 @@ Grouped by gallery level, then shape, then name. | `Watermark` | Pattern | `craft_ui_patterns::patterns::form_dialogs::watermark` | The watermark rows of an export dialog: Style (Text, Graphic), the text field or the image path with Choose…, Orientation, Position as the 3 by 3 reference point, Rotation, Size, Opacity, Inset X and Y, and Shadow | | `WindowMenuRows` | Pattern | `craft_ui_panels::docking::window_menu` | One check row per panel in the order the app gives, for a Window menu | | `WorkspaceSwitcher` | Pattern | `craft_ui_patterns::patterns::dock::switcher` | The switcher at the end of an options bar: a small select showing the current workspace's name | -| `ZoomField` | Pattern | `craft_ui_widgets::text::zoom_field` | A zoom field: a `NumberField` over the view's zoom in percent on its [`ZoomScale`] (device pixels unless set), with the zoom codec and the zoom ladder's range | +| `ZoomField` | Pattern | `craft_ui_widgets::text::zoom_field` | A zoom field: a `NumberField` over the view's zoom in percent on its [`ZoomScale`] (device pixels unless set), with the zoom codec and the zoom scheme's range | | `RecoveryDialog` | Dialog | `craft_ui_panels::dialog::recovery` | Recover Unsaved Work, one document at a time: a prompt saying when the document was autosaved, with Discard and Recover (the accepting answer) | ### Shells @@ -273,7 +273,7 @@ Grouped by gallery level, then shape, then name. | `craft_behavior::eviction` | When a component's remembered state is due for eviction | | `craft_behavior::fit` | The fit rules: which tabs, bar items or titles stay in a strip and which go to an overflow menu | | `craft_behavior::flow` | `Insets`, `Flow` and `Axis`: start and end geometry resolved once for the layout direction | -| `craft_behavior::focus` | Pure focus rules (spec 9.3, 9.4, 8.3): key ownership, focus after removal, the Escape order and the focus-on-press kinds | +| `craft_behavior::focus` | Pure focus rules (spec 9.3, 9.4, 8.3): key ownership, the Escape order and the focus-on-press kinds | | `craft_behavior::frame_step` | The step of one pass of motion: a Hand glide, a held Zoom press and an autoscroll integrate over it | | `craft_behavior::grid` | The `Grid` cursor: columns resolved from last pass's measurements, and the cell each child takes | | `craft_behavior::hit` | Hit shapes, their priority and the arena's resolve rule (8.3) | From 9750fe6d77d16a8b014a37a4755767cdfddc50e2 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 03:41:37 +0000 Subject: [PATCH 06/22] i18n: the region test module builds only where its one test runs --- crates/i18n/src/region.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/i18n/src/region.rs b/crates/i18n/src/region.rs index f34cac506..9f1559913 100644 --- a/crates/i18n/src/region.rs +++ b/crates/i18n/src/region.rs @@ -389,11 +389,10 @@ fn read_system() -> Region { Region::from_tag(&sys_locale::get_locale().unwrap_or_default()) } -#[cfg(test)] +#[cfg(all(test, unix, not(any(target_vendor = "apple", target_os = "android"))))] mod tests { use super::*; - #[cfg(all(unix, not(any(target_vendor = "apple", target_os = "android"))))] #[test] fn each_locale_category_decides_its_own_part_and_lc_all_all_of_them() { let env = From eaeb0fa0283a24b0fcdad77ea3705b150db37b8e Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 04:02:17 +0000 Subject: [PATCH 07/22] platform: owner_only's docs name its Windows-only functions as code, not links From storytold/craft-libs#3236, so this PR's Workspace docs check can pass. Co-authored-by: skylartaylor --- crates/platform/src/owner_only.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/platform/src/owner_only.rs b/crates/platform/src/owner_only.rs index 506907e03..e664dcffe 100644 --- a/crates/platform/src/owner_only.rs +++ b/crates/platform/src/owner_only.rs @@ -2,23 +2,23 @@ //! //! On Windows a file created in a folder inherits the folder's access list, and folders such as //! a new folder at a drive root, `C:\Users\Public` or `C:\ProgramData` let every signed-in user -//! read what is created in them. [`restrict_to_owner`] replaces the whole list with the current -//! user and SYSTEM only, makes that user the owner, and checks the result. [`create_private_dir`] +//! read what is created in them. `restrict_to_owner` replaces the whole list with the current +//! user and SYSTEM only, makes that user the owner, and checks the result. `create_private_dir` //! does the same for a new folder whose list the files created in it inherit, so a file can be -//! private from the moment it exists. [`read_with_sddl`] reads a file and its security descriptor +//! private from the moment it exists. `read_with_sddl` reads a file and its security descriptor //! through one handle. [`foreign_access`] reads the descriptor in SDDL form, which names accounts //! by SID and so reads the same in every Windows language, and says why another user could have //! written or could read the file. They run the tools Windows ships rather than calling the //! security API directly, which would need `unsafe`. /// Why the file whose security descriptor is `sddl` (`O:` owner and `D:` access list, in SDDL or -/// as [`read_with_sddl`] writes it) can't be trusted as user `me`'s own: it is owned by someone else, it has no +/// as `read_with_sddl` writes it) can't be trusted as user `me`'s own: it is owned by someone else, it has no /// access list (everyone may use it), or it lets an account other than `me` or SYSTEM use it. /// Accounts are compared by SID; `None` means it is `me`'s alone. /// /// Stricter than OpenSSH's rule for private keys, which also lets Administrators in: an entry for /// the Administrators group would let another administrator read the token without taking the -/// file over. [`restrict_to_owner`] never grants it, so the app's own file always passes; a file +/// file over. `restrict_to_owner` never grants it, so the app's own file always passes; a file /// that inherited it from a user's folder is refused. pub fn foreign_access(sddl: &str, me: &str) -> Option { let me = me.trim(); From 52503acd71e159867795275d7214df6b64e24239 Mon Sep 17 00:00:00 2001 From: skylartaylor Date: Tue, 24 Nov 2026 00:23:15 +0100 Subject: [PATCH 08/22] Fix the macOS test failures next picked up from the PdfCraft framework sync (#3232) - atomic: a file the user may write but not read (mode 0200) saves again on macOS; its extended attributes can't be read, so there are none to keep. - menu, ui-shell, pages, ui-contract, ui-canvas tests: follow the macOS conventions the code already has. The in-window bar test pins its target as the other bar tests do; macOS has no Menu key and no Cmd+Home/End move; its platform copy key is Option; a press with Control there is a secondary click, so Control comes after the press. --- crates/atomic/src/lib.rs | 7 ++++--- crates/menu/tests/it/bar.rs | 3 +++ crates/pages/tests/it/views.rs | 11 +++++------ crates/ui-canvas/tests/it/canvas/crop.rs | 9 ++++++++- crates/ui-contract/tests/it/collection/drops.rs | 6 ++++-- crates/ui-shell/tests/it/shell/start.rs | 8 +++++--- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/crates/atomic/src/lib.rs b/crates/atomic/src/lib.rs index 2fa589d09..c417eec67 100644 --- a/crates/atomic/src/lib.rs +++ b/crates/atomic/src/lib.rs @@ -548,8 +548,9 @@ const MAX_XATTR_TOTAL_BYTES: usize = 64 * 1024 * 1024; /// binding, quarantine, resource forks) to the stage. The attributes are as untrusted as the /// bytes, so the reads are bounded; one that cannot be read or written whole, or passes a bound, /// refuses the save rather than dropping the user's metadata unnoticed. Only a volume without -/// extended attributes (`ENOTSUP`) is skipped. `com.apple.provenance` belongs to macOS, which -/// gives the new file its own. Compression bookkeeping stays hidden (no `XATTR_SHOWCOMPRESSION`). +/// extended attributes (`ENOTSUP`) and a file the user may write but not read (mode 0200, whose +/// attributes the user can't read either) are skipped; those save as they did before attributes +/// were kept. `com.apple.provenance` belongs to macOS, which gives the new file its own. Compression bookkeeping stays hidden (no `XATTR_SHOWCOMPRESSION`). #[cfg(target_os = "macos")] fn copy_xattrs(target: &Path, stage: &File) -> io::Result<()> { use rustix::fs::{Mode, OFlags, XattrFlags, fgetxattr, fgetxattr_query, flistxattr, fsetxattr, open}; @@ -559,7 +560,7 @@ fn copy_xattrs(target: &Path, stage: &File) -> io::Result<()> { // names another file. NONBLOCK keeps a FIFO put at the name from hanging the open. let source = match open(target, OFlags::RDONLY | OFlags::CLOEXEC | OFlags::NOFOLLOW | OFlags::NONBLOCK, Mode::empty()) { Ok(fd) => File::from(fd), - Err(Errno::NOENT | Errno::LOOP) => return Ok(()), + Err(Errno::NOENT | Errno::LOOP | Errno::ACCESS) => return Ok(()), Err(e) => return Err(e.into()), }; if !source.metadata()?.is_file() { diff --git a/crates/menu/tests/it/bar.rs b/crates/menu/tests/it/bar.rs index 071ae4684..efe960a13 100644 --- a/crates/menu/tests/it/bar.rs +++ b/crates/menu/tests/it/bar.rs @@ -1,5 +1,6 @@ //! The in-window bar's own rules over the model. +use craft_host::target::Os; use craft_menu::{Item, Menu, MenuBar, MenuBarUi, Node}; use craft_ui::contract::Tracked; use craft_ui::testing::{Fixture, trial}; @@ -18,6 +19,8 @@ fn a_disabled_submenu_is_greyed_and_does_not_open() { let mut fixture = Fixture::new(move |ui| { MenuBarUi::new(&bar).show(ui); }); + // The in-window bar's rules; a Mac's menus are in the system bar. + fixture.os(Os::Linux); fixture.settle(); let Some(file) = fixture.by_label("File") else { panic!("the bar shows File") }; fixture.click(&file).settle(); diff --git a/crates/pages/tests/it/views.rs b/crates/pages/tests/it/views.rs index e4e60c79a..e0aa1babf 100644 --- a/crates/pages/tests/it/views.rs +++ b/crates/pages/tests/it/views.rs @@ -1007,12 +1007,11 @@ fn shift_and_command_with_the_page_keys_and_arrows_go_to_the_ends() { ); focus_canvas(&mut fixture); let keys = [(Key::PageDown, both, 4), (Key::PageUp, both, 0), (Key::ArrowDown, both, 4), (Key::ArrowUp, both, 0)]; - let ends = [ - (Key::End, Modifiers::SHIFT, 4), - (Key::Home, Modifiers::SHIFT, 0), - (Key::End, Modifiers::COMMAND, 4), - (Key::Home, Modifiers::COMMAND, 0), - ]; + // Off macOS Ctrl+End and Ctrl+Home go to the ends too; macOS gives Cmd with Home and End no move. + let mut ends = vec![(Key::End, Modifiers::SHIFT, 4), (Key::Home, Modifiers::SHIFT, 0)]; + if !cfg!(target_os = "macos") { + ends.extend([(Key::End, Modifiers::COMMAND, 4), (Key::Home, Modifiers::COMMAND, 0)]); + } for (key, mods, want) in keys.into_iter().chain(ends) { fixture.key(key, mods); fixture.idle(2); diff --git a/crates/ui-canvas/tests/it/canvas/crop.rs b/crates/ui-canvas/tests/it/canvas/crop.rs index d2b6a8b73..69b91085d 100644 --- a/crates/ui-canvas/tests/it/canvas/crop.rs +++ b/crates/ui-canvas/tests/it/canvas/crop.rs @@ -451,6 +451,7 @@ fn a_quick_drag_in_one_frame_starts_at_the_press() { assert_eq!((events.first(), events.last()), (Some(&"begin"), Some(&"commit")), "{events:?}"); } +/// Control is pressed once the resize has started: on macOS a press with Control held is a secondary click. #[trial] fn the_control_key_held_during_a_resize_turns_snapping_off() { for (held, right) in [(Modifiers::NONE, 310.0), (Modifiers::CTRL, 307.0)] { @@ -459,7 +460,13 @@ fn the_control_key_held_during_a_resize_turns_snapping_off() { s.snap_x = Some(310.0); s }); - rig.drag(rig.at(300.0, 220.0), rig.at(307.0, 220.0), held); + let (from, to) = (rig.at(300.0, 220.0), rig.at(307.0, 220.0)); + rig.press(from); + rig.frames.hold(held); + rig.move_to(from.lerp(to, 0.5)); + rig.move_to(to); + rig.release(to); + rig.frames.hold(Modifiers::NONE); assert!((rig.rect().x1 - right).abs() < 1e-6, "{held:?}: {:?}", rig.rect()); } } diff --git a/crates/ui-contract/tests/it/collection/drops.rs b/crates/ui-contract/tests/it/collection/drops.rs index 331ba96bf..ec8c2179b 100644 --- a/crates/ui-contract/tests/it/collection/drops.rs +++ b/crates/ui-contract/tests/it/collection/drops.rs @@ -137,13 +137,15 @@ fn rows_from_another_list_drop_into_a_gap_only_where_a_kind_takes_them() { } /// A list's copy keys decide which held key makes its own row drag a copy, and the pointer over it shows the copy -/// while they are held: off macOS Ctrl for the platform's keys, Alt for Alt; the other key moves. +/// while they are held: the platform's keys copy with Ctrl off macOS and Option on it, Alt copies with Alt; the other +/// key moves. #[trial] fn a_lists_copy_keys_pick_the_key_that_copies_its_rows() { use craft_behavior::{CopyKeys, Cursor, CursorIcon}; use egui::Modifiers; let ctrl = Modifiers::CTRL | Modifiers::COMMAND; - for (keys, copies, moves) in [(CopyKeys::Platform, ctrl, Modifiers::ALT), (CopyKeys::Alt, Modifiers::ALT, ctrl)] { + let platform = if cfg!(target_os = "macos") { (Modifiers::ALT, ctrl) } else { (ctrl, Modifiers::ALT) }; + for (keys, copies, moves) in [(CopyKeys::Platform, platform.0, platform.1), (CopyKeys::Alt, Modifiers::ALT, ctrl)] { for (held, copy) in [(copies, true), (moves, false)] { let words = Words::flat(&["a", "b", "c", "d"]); let run = Run::default(); diff --git a/crates/ui-shell/tests/it/shell/start.rs b/crates/ui-shell/tests/it/shell/start.rs index c53a8cb9a..32b596852 100644 --- a/crates/ui-shell/tests/it/shell/start.rs +++ b/crates/ui-shell/tests/it/shell/start.rs @@ -196,8 +196,8 @@ fn a_recent_row_names_its_full_path_and_reveals_remove_on_hover_or_focus() { assert!(log.borrow().contains(&StartAction::ClearRecent), "Clear reports ClearRecent: {:?}", log.borrow()); } -/// A recent file's menu offers Show in Folder exactly where the platform can reveal a file, and the menu key and -/// Shift+F10 open it from the focused card. The menu is told by "Clear Recent Files", which only the menu has: the +/// A recent file's menu offers Show in Folder exactly where the platform can reveal a file, and the menu key (off +/// macOS, which has none) and Shift+F10 open it from the focused card. The menu is told by "Clear Recent Files", which only the menu has: the /// card's hover action carries "Remove from Recent" too. #[trial] fn the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal() { @@ -213,7 +213,9 @@ fn the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal() { assert!(fixture.by_label(MENU_ONLY).is_some(), "a right click on a recent file opens its menu"); assert_eq!(fixture.by_label("Show in Folder").is_some(), craft_platform::open::CAN_REVEAL); - for (key, modifiers) in [(Key::Menu, Modifiers::NONE), (Key::F10, Modifiers::SHIFT)] { + let keys: &[(Key, Modifiers)] = + if cfg!(target_os = "macos") { &[(Key::F10, Modifiers::SHIFT)] } else { &[(Key::Menu, Modifiers::NONE), (Key::F10, Modifiers::SHIFT)] }; + for &(key, modifiers) in keys { fixture.key(Key::Escape, Modifiers::NONE).idle(3); assert!(fixture.by_label(MENU_ONLY).is_none(), "Escape closes the menu before {key:?}"); let card = fixture.by_label("Poster.psd").expect("the card shows"); From f29372d28066eb09c0184616a8e39941d6780b69 Mon Sep 17 00:00:00 2001 From: skylartaylor Date: Tue, 24 Nov 2026 00:58:10 +0100 Subject: [PATCH 09/22] atomic: an unreadable file saves only when it has no attributes to lose (review) When the old file can't be opened for reading, its attribute names are listed by path: none (or only com.apple.provenance) lets the save go on; any other refuses it, since they can't be copied without the file. --- crates/atomic/src/lib.rs | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/crates/atomic/src/lib.rs b/crates/atomic/src/lib.rs index c417eec67..da11bf153 100644 --- a/crates/atomic/src/lib.rs +++ b/crates/atomic/src/lib.rs @@ -548,9 +548,11 @@ const MAX_XATTR_TOTAL_BYTES: usize = 64 * 1024 * 1024; /// binding, quarantine, resource forks) to the stage. The attributes are as untrusted as the /// bytes, so the reads are bounded; one that cannot be read or written whole, or passes a bound, /// refuses the save rather than dropping the user's metadata unnoticed. Only a volume without -/// extended attributes (`ENOTSUP`) and a file the user may write but not read (mode 0200, whose -/// attributes the user can't read either) are skipped; those save as they did before attributes -/// were kept. `com.apple.provenance` belongs to macOS, which gives the new file its own. Compression bookkeeping stays hidden (no `XATTR_SHOWCOMPRESSION`). +/// extended attributes (`ENOTSUP`) is skipped, and so is a file whose data the user may not read +/// (mode 0200) when it has no attribute names the user can list either; one whose names can be +/// listed refuses the save, as its attributes can't be copied without its data. +/// `com.apple.provenance` belongs to macOS, which gives the new file its own. Compression +/// bookkeeping stays hidden (no `XATTR_SHOWCOMPRESSION`). #[cfg(target_os = "macos")] fn copy_xattrs(target: &Path, stage: &File) -> io::Result<()> { use rustix::fs::{Mode, OFlags, XattrFlags, fgetxattr, fgetxattr_query, flistxattr, fsetxattr, open}; @@ -560,7 +562,8 @@ fn copy_xattrs(target: &Path, stage: &File) -> io::Result<()> { // names another file. NONBLOCK keeps a FIFO put at the name from hanging the open. let source = match open(target, OFlags::RDONLY | OFlags::CLOEXEC | OFlags::NOFOLLOW | OFlags::NONBLOCK, Mode::empty()) { Ok(fd) => File::from(fd), - Err(Errno::NOENT | Errno::LOOP | Errno::ACCESS) => return Ok(()), + Err(Errno::NOENT | Errno::LOOP) => return Ok(()), + Err(Errno::ACCESS) => return unreadable_has_no_attributes(target), Err(e) => return Err(e.into()), }; if !source.metadata()?.is_file() { @@ -596,6 +599,27 @@ fn copy_xattrs(target: &Path, stage: &File) -> io::Result<()> { Ok(()) } +/// For a target whose data can't be opened for reading: `Ok` when it has no extended attribute the +/// user can list (or the volume has none), so the save loses nothing; otherwise refuse the save, as +/// the attributes can't be copied without opening the file. The names are read without following a +/// link, by path. +#[cfg(target_os = "macos")] +fn unreadable_has_no_attributes(target: &Path) -> io::Result<()> { + use rustix::fs::llistxattr; + use rustix::io::Errno; + let mut names = vec![0u8; MAX_XATTR_NAMES_BYTES]; + match llistxattr(target, names.as_mut_slice()) { + Ok(0) | Err(Errno::NOTSUP | Errno::ACCESS | Errno::NOENT) => Ok(()), + Ok(len) if names.get(..len).is_some_and(|names| names.split(|b| *b == 0).all(|name| name.is_empty() || name == b"com.apple.provenance")) => { + Ok(()) + } + Ok(_) | Err(Errno::RANGE) => { + Err(io::Error::new(io::ErrorKind::PermissionDenied, "the file can't be read, so its extended attributes can't be copied")) + } + Err(e) => Err(e.into()), + } +} + /// Read one attribute value of `size` bytes (already within the bounds) with `read`, then ask /// its size again with `query_size`. A read that does not fill `size`, or a size that changed, /// is refused: a growing resource fork returns the prefix that fits instead of an error. From 1d281f38c1e1e9c6b58cd6e401689db0760ef6a2 Mon Sep 17 00:00:00 2001 From: skylartaylor Date: Tue, 24 Nov 2026 01:48:07 +0100 Subject: [PATCH 10/22] atomic: a write-only file's unreadable attributes are dropped, as documented and tested (review) On macOS a mode-0200 file's owner can list none of its attribute names either, so they are dropped, as before attributes were kept. An ACL that denies the data but lets the names be listed still refuses the save. Both are now tested on macOS. Also: the pages key doc gives the macOS exception for Cmd+Home/End. --- crates/atomic/src/lib.rs | 15 +++++----- crates/atomic/tests/atomic_tests.rs | 46 +++++++++++++++++++++++++++++ crates/pages/src/ui/view.rs | 3 +- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/crates/atomic/src/lib.rs b/crates/atomic/src/lib.rs index da11bf153..5aa3c75cd 100644 --- a/crates/atomic/src/lib.rs +++ b/crates/atomic/src/lib.rs @@ -548,9 +548,10 @@ const MAX_XATTR_TOTAL_BYTES: usize = 64 * 1024 * 1024; /// binding, quarantine, resource forks) to the stage. The attributes are as untrusted as the /// bytes, so the reads are bounded; one that cannot be read or written whole, or passes a bound, /// refuses the save rather than dropping the user's metadata unnoticed. Only a volume without -/// extended attributes (`ENOTSUP`) is skipped, and so is a file whose data the user may not read -/// (mode 0200) when it has no attribute names the user can list either; one whose names can be -/// listed refuses the save, as its attributes can't be copied without its data. +/// extended attributes (`ENOTSUP`) is skipped. So is a file whose data the user may not read when +/// its attribute names can't be listed either, as with mode 0200: its attributes are dropped, as +/// before attributes were kept, since the user can't read them (or its bytes) at all. One whose +/// data is denied but whose names can be listed (an ACL that denies reading) refuses the save. /// `com.apple.provenance` belongs to macOS, which gives the new file its own. Compression /// bookkeeping stays hidden (no `XATTR_SHOWCOMPRESSION`). #[cfg(target_os = "macos")] @@ -599,10 +600,10 @@ fn copy_xattrs(target: &Path, stage: &File) -> io::Result<()> { Ok(()) } -/// For a target whose data can't be opened for reading: `Ok` when it has no extended attribute the -/// user can list (or the volume has none), so the save loses nothing; otherwise refuse the save, as -/// the attributes can't be copied without opening the file. The names are read without following a -/// link, by path. +/// For a target whose data can't be opened for reading: `Ok` when the user can list no extended +/// attribute names on it (none, only `com.apple.provenance`, none supported, or listing is denied too, +/// as for mode 0200, whose attributes are then dropped); otherwise refuse the save, as the attributes +/// can't be copied without opening the file. The names are read without following a link, by path. #[cfg(target_os = "macos")] fn unreadable_has_no_attributes(target: &Path) -> io::Result<()> { use rustix::fs::llistxattr; diff --git a/crates/atomic/tests/atomic_tests.rs b/crates/atomic/tests/atomic_tests.rs index b1da9be0a..fcafd2ca7 100644 --- a/crates/atomic/tests/atomic_tests.rs +++ b/crates/atomic/tests/atomic_tests.rs @@ -99,3 +99,49 @@ fn private_staging_preserves_existing_modes_after_callback() -> io::Result<()> { assert_no_temp(&d.0); Ok(()) } + +/// Extended attribute names on `path`, read by path. +#[cfg(target_os = "macos")] +fn xattr_names(path: &Path) -> Vec> { + let mut names = vec![0u8; 64 * 1024]; + let len = rustix::fs::listxattr(path, names.as_mut_slice()).unwrap_or(0); + names.truncate(len); + names.split(|b| *b == 0).filter(|n| !n.is_empty()).map(<[u8]>::to_vec).collect() +} + +/// A write-only file (mode 0200) saves: macOS lets its owner neither read its data nor list its +/// attributes, so its attributes are dropped, as before attributes were kept. +#[cfg(target_os = "macos")] +#[test] +fn a_write_only_file_saves_and_drops_the_attributes_it_cannot_read() -> io::Result<()> { + use std::os::unix::fs::PermissionsExt; + let d = TempDir::new("write_only_xattrs"); + let p = d.0.join("doc.craft"); + std::fs::write(&p, ORIGINAL)?; + rustix::fs::setxattr(&p, "com.craft.t", b"tag", rustix::fs::XattrFlags::empty())?; + std::fs::set_permissions(&p, std::fs::Permissions::from_mode(0o200))?; + atomic_write(&p, b"new")?; + std::fs::set_permissions(&p, std::fs::Permissions::from_mode(0o600))?; + assert_eq!(std::fs::read(&p)?, b"new"); + assert!(!xattr_names(&p).iter().any(|n| n == b"com.craft.t"), "the unreadable attribute is dropped"); + Ok(()) +} + +/// A file whose data an ACL denies but whose attribute names can be listed is not replaced: its +/// attributes can't be copied without its data, and the save refuses rather than drop them. +#[cfg(target_os = "macos")] +#[test] +fn an_unreadable_file_with_listable_attributes_is_not_replaced() -> io::Result<()> { + let d = TempDir::new("acl_denied_xattrs"); + let p = d.0.join("doc.craft"); + std::fs::write(&p, ORIGINAL)?; + rustix::fs::setxattr(&p, "com.craft.t", b"tag", rustix::fs::XattrFlags::empty())?; + let denied = std::process::Command::new("/bin/chmod").arg("+a").arg("everyone deny read").arg(&p).status()?; + assert!(denied.success(), "the ACL is set"); + let result = atomic_write(&p, b"new"); + let _ = std::process::Command::new("/bin/chmod").arg("-N").arg(&p).status(); + assert!(result.is_err(), "the save is refused"); + assert_eq!(std::fs::read(&p)?, ORIGINAL, "the original is unchanged"); + assert!(xattr_names(&p).iter().any(|n| n == b"com.craft.t"), "and keeps its attribute"); + Ok(()) +} diff --git a/crates/pages/src/ui/view.rs b/crates/pages/src/ui/view.rs index 2fc10109b..0b08850bb 100644 --- a/crates/pages/src/ui/view.rs +++ b/crates/pages/src/ui/view.rs @@ -1544,7 +1544,8 @@ impl KeyMoves { /// Page Up and Down a screen less a key line (a row when not continuous, and with Cmd), Home and End the first /// and last page, Up and Down a key line (not continuous, a turn once the row is at its edge that way), Left and /// Right a key line sideways while the current page or spread has more to show that way, else a turn of a page or - /// spread; Cmd with Left or Right turns at once. Home and End with Shift or Cmd, and Page Up, Page Down, Up and + /// spread; Cmd with Left or Right turns at once. Home and End with Shift, or with Cmd off macOS (which gives Cmd + /// with them no move), and Page Up, Page Down, Up and /// Down with Shift and Cmd together, go to the first or last page; Alt, and Shift alone with the other keys, /// leave them to nothing. fn of( From 6af5a5eaf20abb210b46c710841a718a5de46816 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 18:10:05 +0700 Subject: [PATCH 11/22] theme: VectorCraft Modern and Modern Medium pin state.text_selection to the accent at 55% alpha (dark #f06a528c, light #d9472f8c), as production's field selection --- .../dumps/tokens/vectorcraft-modern-dark-high-comfortable.txt | 2 +- .../tests/dumps/tokens/vectorcraft-modern-dark-high-compact.txt | 2 +- .../tokens/vectorcraft-modern-dark-standard-comfortable.txt | 2 +- .../dumps/tokens/vectorcraft-modern-dark-standard-compact.txt | 2 +- .../dumps/tokens/vectorcraft-modern-light-high-comfortable.txt | 2 +- .../dumps/tokens/vectorcraft-modern-light-high-compact.txt | 2 +- .../tokens/vectorcraft-modern-light-standard-comfortable.txt | 2 +- .../dumps/tokens/vectorcraft-modern-light-standard-compact.txt | 2 +- .../tokens/vectorcraft-modern-medium-dark-high-comfortable.txt | 2 +- .../tokens/vectorcraft-modern-medium-dark-high-compact.txt | 2 +- .../vectorcraft-modern-medium-dark-standard-comfortable.txt | 2 +- .../tokens/vectorcraft-modern-medium-dark-standard-compact.txt | 2 +- .../tokens/vectorcraft-modern-medium-light-high-comfortable.txt | 2 +- .../tokens/vectorcraft-modern-medium-light-high-compact.txt | 2 +- .../vectorcraft-modern-medium-light-standard-comfortable.txt | 2 +- .../tokens/vectorcraft-modern-medium-light-standard-compact.txt | 2 +- crates/theme/themes/vectorcraft-modern-medium.json | 2 ++ crates/theme/themes/vectorcraft-modern.json | 2 ++ 18 files changed, 20 insertions(+), 16 deletions(-) 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 05862e073..c2bec4dc9 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 @@ -68,7 +68,7 @@ state.pressed = #593330ff state.selected = #4c2e2eff state.selected_hover = #604040ff state.disabled_fill = #181b22ff -state.text_selection = #f26b5346 +state.text_selection = #f06a528c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #262b3540 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 4c5d9b971..cd25bc683 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 @@ -68,7 +68,7 @@ state.pressed = #593330ff state.selected = #4c2e2eff state.selected_hover = #604040ff state.disabled_fill = #181b22ff -state.text_selection = #f26b5346 +state.text_selection = #f06a528c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #262b3540 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 14a525235..074927837 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 @@ -68,7 +68,7 @@ state.pressed = #593330ff state.selected = #4c2e2eff state.selected_hover = #604040ff state.disabled_fill = #181b22ff -state.text_selection = #f06a5246 +state.text_selection = #f06a528c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #262b3540 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 e4068c5d4..afad9f76c 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 @@ -68,7 +68,7 @@ state.pressed = #593330ff state.selected = #4c2e2eff state.selected_hover = #604040ff state.disabled_fill = #181b22ff -state.text_selection = #f06a5246 +state.text_selection = #f06a528c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #262b3540 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 d7384b50f..769cf8d26 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 @@ -68,7 +68,7 @@ state.pressed = #edcbc8ff state.selected = #eed2d0ff state.selected_hover = #e2c7c5ff state.disabled_fill = #f3f5f8ff -state.text_selection = #af1c0046 +state.text_selection = #d9472f8c state.match = #8378005a state.match_current = #f0a3306e state.stripe = #e3e7ed40 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 ae25fc624..16a456516 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 @@ -68,7 +68,7 @@ state.pressed = #edcbc8ff state.selected = #eed2d0ff state.selected_hover = #e2c7c5ff state.disabled_fill = #f3f5f8ff -state.text_selection = #af1c0046 +state.text_selection = #d9472f8c state.match = #8378005a state.match_current = #f0a3306e state.stripe = #e3e7ed40 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 f610585cb..cfd9a503e 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 @@ -68,7 +68,7 @@ state.pressed = #edcbc8ff state.selected = #eed2d0ff state.selected_hover = #e2c7c5ff state.disabled_fill = #f3f5f8ff -state.text_selection = #d9472f46 +state.text_selection = #d9472f8c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #e3e7ed40 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 aeeae13fd..2686cdcb2 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 @@ -68,7 +68,7 @@ state.pressed = #edcbc8ff state.selected = #eed2d0ff state.selected_hover = #e2c7c5ff state.disabled_fill = #f3f5f8ff -state.text_selection = #d9472f46 +state.text_selection = #d9472f8c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #e3e7ed40 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 97a482400..3d4eed2df 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 @@ -68,7 +68,7 @@ state.pressed = #633f3eff state.selected = #573b3dff state.selected_hover = #6b4e50ff state.disabled_fill = #272c36ff -state.text_selection = #fc755c46 +state.text_selection = #f06a528c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #353c4940 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 c8561174b..5b4fda53a 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 @@ -68,7 +68,7 @@ state.pressed = #633f3eff state.selected = #573b3dff state.selected_hover = #6b4e50ff state.disabled_fill = #272c36ff -state.text_selection = #fc755c46 +state.text_selection = #f06a528c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #353c4940 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 e84b9e3e7..06a5152da 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 @@ -68,7 +68,7 @@ state.pressed = #633f3eff state.selected = #573b3dff state.selected_hover = #6b4e50ff state.disabled_fill = #272c36ff -state.text_selection = #f06a5246 +state.text_selection = #f06a528c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #353c4940 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 841009d9c..0d034691f 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 @@ -68,7 +68,7 @@ state.pressed = #633f3eff state.selected = #573b3dff state.selected_hover = #6b4e50ff state.disabled_fill = #272c36ff -state.text_selection = #f06a5246 +state.text_selection = #f06a528c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #353c4940 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 c520b18b0..ea0ac0604 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 @@ -68,7 +68,7 @@ state.pressed = #d4b5b6ff state.selected = #d4bbbdff state.selected_hover = #c9b0b2ff state.disabled_fill = #d3d8e0ff -state.text_selection = #af1b0046 +state.text_selection = #d9472f8c state.match = #776c005a state.match_current = #f0a3306e state.stripe = #c5ccd640 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 38de13e38..165064bb7 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 @@ -68,7 +68,7 @@ state.pressed = #d4b5b6ff state.selected = #d4bbbdff state.selected_hover = #c9b0b2ff state.disabled_fill = #d3d8e0ff -state.text_selection = #af1b0046 +state.text_selection = #d9472f8c state.match = #776c005a state.match_current = #f0a3306e state.stripe = #c5ccd640 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 bfeee3a20..71742fe3b 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 @@ -68,7 +68,7 @@ state.pressed = #d4b5b6ff state.selected = #d4bbbdff state.selected_hover = #c9b0b2ff state.disabled_fill = #d3d8e0ff -state.text_selection = #d9472f46 +state.text_selection = #d9472f8c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #c5ccd640 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 3cdc85665..41575fb0b 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 @@ -68,7 +68,7 @@ state.pressed = #d4b5b6ff state.selected = #d4bbbdff state.selected_hover = #c9b0b2ff state.disabled_fill = #d3d8e0ff -state.text_selection = #d9472f46 +state.text_selection = #d9472f8c state.match = #f0dc005a state.match_current = #f0a3306e state.stripe = #c5ccd640 diff --git a/crates/theme/themes/vectorcraft-modern-medium.json b/crates/theme/themes/vectorcraft-modern-medium.json index bc43e6148..ce7aa4700 100644 --- a/crates/theme/themes/vectorcraft-modern-medium.json +++ b/crates/theme/themes/vectorcraft-modern-medium.json @@ -32,6 +32,7 @@ "state.hover": "#c5ccd6", "state.pressed": "#d4b5b6", "state.selected": "#d4bbbd", + "state.text_selection": "#d9472f8c", "surface.background": "#c4cad4", "surface.canvas": "#b9c0cb", "surface.control": "#c9d0da", @@ -53,6 +54,7 @@ "state.hover": "#353c49", "state.pressed": "#633f3e", "state.selected": "#573b3d", + "state.text_selection": "#f06a528c", "surface.background": "#1b1f27", "surface.canvas": "#1e222a", "surface.control": "#39404d", diff --git a/crates/theme/themes/vectorcraft-modern.json b/crates/theme/themes/vectorcraft-modern.json index 27424c473..49853128a 100644 --- a/crates/theme/themes/vectorcraft-modern.json +++ b/crates/theme/themes/vectorcraft-modern.json @@ -32,6 +32,7 @@ "state.hover": "#e3e7ed", "state.pressed": "#edcbc8", "state.selected": "#eed2d0", + "state.text_selection": "#d9472f8c", "surface.background": "#e6e9ee", "surface.canvas": "#dfe3e9", "surface.control": "#e3e7ed", @@ -53,6 +54,7 @@ "state.hover": "#262b35", "state.pressed": "#593330", "state.selected": "#4c2e2e", + "state.text_selection": "#f06a528c", "surface.background": "#0b0d12", "surface.canvas": "#101217", "surface.control": "#282d37", From 9a41bd4b8429cd42bb437a899d7b81d8406dcf32 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 18:14:41 +0700 Subject: [PATCH 12/22] ui-contract, field labels: LinkLabelInk, an env value an app sets once at its root, draws a field's label shown as a link in text.normal (Neutral) instead of the link look's accent (Accent, the default); the underline stays. A free Link keeps the accent and takes Tone::Neutral for the same ink. Story field_link_label_ink shows both. --- crates/ui-contract/src/contract/label.rs | 4 +- crates/ui-contract/src/contract/label/leaf.rs | 7 +++- .../ui-contract/src/contract/label/props.rs | 15 +++++++ crates/ui-contract/src/contract/mod.rs | 3 +- crates/ui-widgets/src/form/stories.rs | 41 ++++++++++++++++++- 5 files changed, 64 insertions(+), 6 deletions(-) diff --git a/crates/ui-contract/src/contract/label.rs b/crates/ui-contract/src/contract/label.rs index 49da6126c..236d7bf1a 100644 --- a/crates/ui-contract/src/contract/label.rs +++ b/crates/ui-contract/src/contract/label.rs @@ -13,5 +13,7 @@ mod step; pub use leaf::colon_of; pub(crate) use place::{control_after, label_gap}; pub(crate) use props::inside; -pub use props::{CaptionColumn, CellWidth, FieldLayout, GlyphColon, GlyphLabel, InsideLabel, LabelKind, LabelPress, LabelScheme, Scrub, SideLabel}; +pub use props::{ + CaptionColumn, CellWidth, FieldLayout, GlyphColon, GlyphLabel, InsideLabel, LabelKind, LabelPress, LabelScheme, LinkLabelInk, Scrub, SideLabel, +}; pub(crate) use step::{LabelIn, LeafLabel, Trailing, flow_leaf, in_column, leaf, leaf_under, report_after_reach, run, show_leaf_in_flow}; diff --git a/crates/ui-contract/src/contract/label/leaf.rs b/crates/ui-contract/src/contract/label/leaf.rs index 3268419fb..62274da56 100644 --- a/crates/ui-contract/src/contract/label/leaf.rs +++ b/crates/ui-contract/src/contract/label/leaf.rs @@ -1,6 +1,6 @@ //! The side label as a leaf component: its node, press state, reset dot and colon. -use super::props::{FieldLayout, Glyph, GlyphColon, LabelKind, LabelScheme}; +use super::props::{FieldLayout, Glyph, GlyphColon, LabelKind, LabelScheme, LinkLabelInk}; use super::step::LabelIn; use crate::contract::InBar; use crate::contract::{Component, Props}; @@ -174,10 +174,13 @@ impl Component for LabelLeaf { name: { let text = &cx.tokens.color.text; let (role, ink) = if key.after { (TypeRole::Body, text.normal) } else { (TypeRole::Label, text.muted) }; - if key.link { + let neutral = cx.env::() == LinkLabelInk::Neutral; + if key.link && !neutral { // A link label keeps its role, so it takes the room of the caption it is, in the link's ink. TextLook { role, ..cx.link_look(true) } } else { + // A neutral link label reads in the body ink; its underline still marks it. + let ink = if key.link { text.normal } else { ink }; let (ink, off) = (cx.color(ink), cx.color(text.disabled)); TextLook::new(role, Stateful::new(ink).off(States::new(ink, ink, ink, off))) } diff --git a/crates/ui-contract/src/contract/label/props.rs b/crates/ui-contract/src/contract/label/props.rs index 01fd5e9c4..8e5785bc8 100644 --- a/crates/ui-contract/src/contract/label/props.rs +++ b/crates/ui-contract/src/contract/label/props.rs @@ -121,6 +121,21 @@ impl crate::runtime::env::EnvValue for GlyphColon { } } +/// The ink of a field's label shown as a link ([`SideLabel::link`]), which opens its control's options. An app sets it +/// once at its root (`RootEnv::values`); the default is the link look's accent. Either way it stays underlined, so +/// colour is not its only cue. A free `Link` keeps the accent: one that opens options asks for `Tone::Neutral`. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum LinkLabelInk { + /// The link look (`StyleCx::link_look`): `accent.solid`, `accent.text` at high contrast. + #[default] + Accent, + /// `text.normal`, the ink of a `Link` in `Tone::Neutral`: VectorCraft's "Opacity:" and "Stroke" labels, as + /// production drew them. + Neutral, +} + /// Whether the beside captions of a [`LabelScheme::Inline`] form share one column. Off (the default), each caption is /// as wide as its own text and its control follows it at once. On, the captions keep to the row start in one column as /// wide as the widest, so the controls after them line up (production's Rotate Pages dialog: Direction:, Pages: and diff --git a/crates/ui-contract/src/contract/mod.rs b/crates/ui-contract/src/contract/mod.rs index eb92e07be..cb309b921 100644 --- a/crates/ui-contract/src/contract/mod.rs +++ b/crates/ui-contract/src/contract/mod.rs @@ -93,7 +93,8 @@ pub use items::{measure_item, show_item, show_item_in_flow}; #[doc(hidden)] pub use label::colon_of; pub use label::{ - CaptionColumn, CellWidth, FieldLabelRole, FieldLayout, GlyphColon, GlyphLabel, InsideLabel, LabelKind, LabelPress, LabelScheme, Scrub, SideLabel, + CaptionColumn, CellWidth, FieldLabelRole, FieldLayout, GlyphColon, GlyphLabel, InsideLabel, LabelKind, LabelPress, LabelScheme, LinkLabelInk, + Scrub, SideLabel, }; pub use lazy::Lazy; #[doc(hidden)] diff --git a/crates/ui-widgets/src/form/stories.rs b/crates/ui-widgets/src/form/stories.rs index 7a8c6259c..6531e98b4 100644 --- a/crates/ui-widgets/src/form/stories.rs +++ b/crates/ui-widgets/src/form/stories.rs @@ -2,9 +2,12 @@ use super::Help; use super::{Field, FieldGroup}; +use crate::buttons::Link; use crate::choice::Swatch; -use crate::contract::{FieldLayout, GlyphColon, GlyphLabel, LabelKind, LabelScheme, Show as _, ShowContainer as _, SideLabel, Validity}; -use crate::layout_components::Row; +use crate::contract::{ + FieldLayout, GlyphColon, GlyphLabel, LabelKind, LabelScheme, LinkLabelInk, Props as _, Show as _, ShowContainer as _, SideLabel, Validity, +}; +use crate::layout_components::{Row, Stack}; use crate::runtime::env::{Message, with_env}; use crate::testing::{Drive, StoryData, StoryOutput, story}; use crate::text::{HexField, NumberField}; @@ -49,6 +52,40 @@ fn field_link_label(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { StoryOutput { clicked: facts.clicked || link, ..facts } } +/// A field's link label under each `LinkLabelInk`, each with a free link to options under it: the accent (the default) +/// with a plain `Link`, then the body ink VectorCraft sets at its root with a `Link` in `Tone::Neutral`, the same ink. +/// Both stay underlined. +#[story(Field, covers = [], drive = Drive::Never)] +fn field_link_label_ink(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let mut rows = |ui: &mut Ui, key: &'static str, tone: Option| { + Stack::new() + .id_salt(key) + .show(ui, |ui, _| { + let side = SideLabel::new().link(); + let field = Field::new("Opacity").side(side).show(ui, |ui, _| NumberField::new("Opacity", data.bind(key, Some(100.0))).show(ui)); + let link = Link::new("Stroke"); + let link = match tone { + Some(tone) => link.tone(tone), + None => link, + } + .show(ui); + // The field the label names reports the link click; the story is its host. + field.inner.as_ref().is_some_and(|field| field.link) || link.clicked() + }) + .inner + == Some(true) + }; + let accent = rows(ui, "accent", None); + let neutral = with_env( + ui, + |overrides| { + overrides.values.set(LinkLabelInk::Neutral); + }, + |ui| rows(ui, "neutral", Some(Tone::Neutral)), + ); + StoryOutput { clicked: accent || neutral, ..StoryOutput::default() } +} + /// A glyph label: the icon shows, the text only names the control. #[story(Field, covers = [], drive = Drive::Never)] fn field_icon_label(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { From b4d4b64ddbff8f26044da961bdcba54265811cab Mon Sep 17 00:00:00 2001 From: David Mann Date: Tue, 24 Nov 2026 12:24:51 +0100 Subject: [PATCH 13/22] color-ui: pass PaintChip's style to layout without a needless borrow, so next's Workspace lint passes on clippy 1.100 Co-Authored-By: Claude Opus 5.5 --- crates/color-ui/src/ui/paint_chip.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/color-ui/src/ui/paint_chip.rs b/crates/color-ui/src/ui/paint_chip.rs index 8026cac9d..28de7cc7b 100644 --- a/crates/color-ui/src/ui/paint_chip.rs +++ b/crates/color-ui/src/ui/paint_chip.rs @@ -783,7 +783,7 @@ impl Component for PaintChip<'_> { } fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { - let (well, mark) = self.layout(cx.rect, &cx.style, cx.flow.is_rtl()); + let (well, mark) = self.layout(cx.rect, cx.style, cx.flow.is_rtl()); if self.popup_mark == PopupMark::Menu { let mut arrow = DisclosureGlyph::dropdown_of(cx.env.get()); arrow.color = Some(cx.style.arrow_color); From dc8b91f5f1656189012c6e40e80883397b16c7b7 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 18:29:26 +0700 Subject: [PATCH 14/22] list, menu: CommandHighlight (an env style value, Accent by default) chooses how a menu's active row, a popup list's command row, the palette's active row and an open menu bar title show it; under Hover they paint state.hover with their own ink, as a row with an open submenu --- .../src/patterns/panels/palette/stories.rs | 17 +++++++- crates/ui-widgets/src/list/mod.rs | 4 +- crates/ui-widgets/src/list/row.rs | 2 +- crates/ui-widgets/src/list/row/style.rs | 36 ++++++++++++----- crates/ui-widgets/src/menu/bar.rs | 4 +- crates/ui-widgets/src/menu/bar/stories.rs | 15 +++++++ crates/ui-widgets/tests/it/menu/rows.rs | 40 ++++++++++++++++++- 7 files changed, 101 insertions(+), 17 deletions(-) diff --git a/crates/ui-patterns/src/patterns/panels/palette/stories.rs b/crates/ui-patterns/src/patterns/panels/palette/stories.rs index 5b4e1c5fc..0a2508ae0 100644 --- a/crates/ui-patterns/src/patterns/panels/palette/stories.rs +++ b/crates/ui-patterns/src/patterns/panels/palette/stories.rs @@ -3,9 +3,10 @@ use super::{CommandPalette, PaletteFace}; use crate::buttons::Button; use crate::contract::{Bind, Show as _}; +use crate::list::CommandHighlight; use crate::menu::search::{HelpEntry, SearchIndex, SearchWords, Synonyms}; use crate::runtime::commands::{CommandRef, CommandState, CommandStates, EditCommands}; -use crate::runtime::env::{Label, WordTemplate}; +use crate::runtime::env::{Label, WordTemplate, with_env}; use crate::testing::{Drive, StoryData, StoryOutput, story}; use egui::Ui; use std::sync::LazyLock; @@ -163,3 +164,17 @@ fn command_palette_many_results(ui: &mut Ui, data: &mut StoryData) -> StoryOutpu // PLAN: the sheet has the story data type "a"; the query is the palette's own session memory, which story data cannot set. palette(ui, data, MANY.as_slice(), Vec::new()) } + +/// The active row under `CommandHighlight::Hover`: the hover tint with the row's own ink, as an app sets it at its root +/// for a quiet command highlight. +#[story(CommandPalette<'static>, covers = [], drive = Drive::Never, title = "Hover highlight", commands = commands)] +fn command_palette_hover_highlight(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let recents = [PhotoCraftCommand::Levels, PhotoCraftCommand::Brush].map(CommandRef::from).to_vec(); + with_env( + ui, + |overrides| { + overrides.values.set(CommandHighlight::Hover); + }, + |ui| palette(ui, data, ENTRIES.as_slice(), recents), + ) +} diff --git a/crates/ui-widgets/src/list/mod.rs b/crates/ui-widgets/src/list/mod.rs index ea02f9f6a..6fc405b8d 100644 --- a/crates/ui-widgets/src/list/mod.rs +++ b/crates/ui-widgets/src/list/mod.rs @@ -21,8 +21,8 @@ pub use findings::{Finding, Findings, FindingsList, FindingsListStyle, FindingsS pub use predicate::{DropTest, RowTest, RowText}; pub(crate) use row::RowThumb; pub use row::{ - CellStatus, HueTarget, LabelUnderline, ListRow, ListRowStyle, RowDragSpot, RowEvent, RowInk, RowLines, RowOutput, RowRun, RowStyleCx, - ThumbAspect, ThumbPaint, ThumbSize, ThumbTarget, ThumbTargets, TrailingFace, TrailingPart, TreeLeaves, label_color_label, tree_steps, + CellStatus, CommandHighlight, HueTarget, LabelUnderline, ListRow, ListRowStyle, RowDragSpot, RowEvent, RowInk, RowLines, RowOutput, RowRun, + RowStyleCx, ThumbAspect, ThumbPaint, ThumbSize, ThumbTarget, ThumbTargets, TrailingFace, TrailingPart, TreeLeaves, label_color_label, tree_steps, }; pub use toggle::{ToggleCell, ToggleFace, ToggleState}; pub use tree::OpenSet; diff --git a/crates/ui-widgets/src/list/row.rs b/crates/ui-widgets/src/list/row.rs index 196931448..c885026b0 100644 --- a/crates/ui-widgets/src/list/row.rs +++ b/crates/ui-widgets/src/list/row.rs @@ -41,7 +41,7 @@ pub use placement::indent_steps; #[doc(hidden)] pub use placement::placement_under_fixed_sizes; pub use placement::{TreeLeaves, tree_steps}; -pub use style::{ListRowStyle, RowStyleCx}; +pub use style::{CommandHighlight, ListRowStyle, RowStyleCx}; pub(crate) use thumb::RowThumb; pub(super) use thumb::Thumb; use thumb::ThumbPayload; diff --git a/crates/ui-widgets/src/list/row/style.rs b/crates/ui-widgets/src/list/row/style.rs index 956fcf8cb..4321c0b44 100644 --- a/crates/ui-widgets/src/list/row/style.rs +++ b/crates/ui-widgets/src/list/row/style.rs @@ -74,6 +74,19 @@ impl RowForm { } } +/// How the active row of a menu, a popup list's command rows and the palette, and an open menu bar title, show it. An +/// app sets it once at its root (`RootEnv::values`); the default is the accent. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum CommandHighlight { + /// `accent.solid` with `text.on_accent`. + #[default] + Accent, + /// The hover tint (`state.hover`) with the row's own ink, as a row with an open submenu shows it. + Hover, +} + /// What the row fill depends on. #[derive(Clone, Copy)] pub(super) struct FillKey { @@ -109,7 +122,7 @@ pub(super) fn fill_of(cx: &StyleCx<'_>, key: FillKey) -> Stateful { if key.form == RowForm::Option { fill = fill.on(States::new(c(state.selected), c(state.selected), c(state.selected), c(state.selected))); } - for rule in flag_rules(key.form) { + for rule in flag_rules(key.form, cx.env::()) { let rgba = match rule.fill { RuleFill::Tinted => tinted, RuleFill::Selected => state.selected, @@ -165,14 +178,19 @@ struct FlagRule { /// the fill under it: the lead row on a selected row paints the selected hover fill with `text.on_selected`, a /// selected row shows its selection whether or not it is emphasized, an emphasized row that is not selected keeps its /// hover-like fill and base ink, and the lead row alone keeps the hover tint. The command -/// form of a menu paints the lead row with `accent.solid` and `text.on_accent`. The option form paints the chosen row +/// form of a menu paints the lead row as `highlight` says: `accent.solid` with `text.on_accent`, or the hover tint with +/// the base ink. The option form paints the chosen row /// with `state.selected` and `text.on_selected`, lead or not, and the lead row alone with `state.hover`. -fn flag_rules(form: RowForm) -> Vec { +fn flag_rules(form: RowForm, highlight: CommandHighlight) -> Vec { let emphasized = FlagRule { flags: Flags::EMPHASIZED, fill: RuleFill::Tinted, ink: RuleInk::Base }; match form { RowForm::Command => { let emphasized = FlagRule { fill: RuleFill::Hover, ..emphasized }; - return vec![emphasized, FlagRule { flags: Flags::LEAD, fill: RuleFill::Accent, ink: RuleInk::OnAccent }]; + let lead = match highlight { + CommandHighlight::Accent => FlagRule { flags: Flags::LEAD, fill: RuleFill::Accent, ink: RuleInk::OnAccent }, + CommandHighlight::Hover => FlagRule { flags: Flags::LEAD, ..emphasized }, + }; + return vec![emphasized, lead]; } RowForm::Option => { return vec![ @@ -192,8 +210,8 @@ fn flag_rules(form: RowForm) -> Vec { /// The row looks of the collection items, on a `StyleCx`: lists, menus and popup lists share them. pub trait RowStyleCx { - /// The fill of a row of a menu or popup list: the active (lead) row is a command highlight in `accent.solid`, and a - /// row with an open submenu (emphasized) keeps the hover tint. + /// The fill of a row of a menu or popup list: the active (lead) row is the command highlight ([`CommandHighlight`]), + /// and a row with an open submenu (emphasized) keeps the hover tint. fn command_row_surface(&self) -> Stateful; /// The surface of a face of a menu: the command highlight on square corners, as the old menu rows and bar titles @@ -204,8 +222,8 @@ pub trait RowStyleCx { /// fills, and `text.disabled` on a disabled item. fn row_ink(&self, base: Rgba) -> Stateful; - /// The ink of a menu or popup list row: `base`, `text.on_accent` on the active row, and `text.disabled` on a - /// disabled row. + /// The ink of a menu or popup list row: `base`, the command highlight's ink on the active row, and `text.disabled` on + /// a disabled row. fn command_row_ink(&self, base: Rgba) -> Stateful; } @@ -250,7 +268,7 @@ pub(super) fn row_ink_of(cx: &StyleCx<'_>, base: StyleColor, form: RowForm) -> S let on_accent = cx.color(cx.tokens.color.text.on_accent); let disabled = cx.color(cx.tokens.color.text.disabled); let mut ink = Stateful::new(base).off(States::new(base, base, base, disabled)).on(States::new(on_selected, on_selected, on_selected, disabled)); - for rule in flag_rules(form) { + for rule in flag_rules(form, cx.env::()) { ink = ink.when( rule.flags, match rule.ink { diff --git a/crates/ui-widgets/src/menu/bar.rs b/crates/ui-widgets/src/menu/bar.rs index 30a9ae802..7ab92d88e 100644 --- a/crates/ui-widgets/src/menu/bar.rs +++ b/crates/ui-widgets/src/menu/bar.rs @@ -63,8 +63,8 @@ pub enum MenuTitlePad { Control, } -/// The style of a title's face: a menu row's surface and ink (flat, square corners, no border), with the accent fill -/// and `text.on_accent` under the pointer and while its menu is open or the keyboard is on it. +/// The style of a title's face: a menu row's surface and ink (flat, square corners, no border), with the command +/// highlight (`CommandHighlight`) under the pointer and while its menu is open or the keyboard is on it. #[derive(Clone, Debug, PartialEq, ComponentStyle)] #[non_exhaustive] struct TitleFaceStyle { diff --git a/crates/ui-widgets/src/menu/bar/stories.rs b/crates/ui-widgets/src/menu/bar/stories.rs index e76defb43..f617bd4b8 100644 --- a/crates/ui-widgets/src/menu/bar/stories.rs +++ b/crates/ui-widgets/src/menu/bar/stories.rs @@ -4,6 +4,7 @@ use super::{MenuBar, MenuHelp, MenuTitle, MenuTitlePad}; use crate::buttons::{IconButton, PopupMark}; use crate::contract::{Entry, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger}; use crate::display::Divider; +use crate::list::CommandHighlight; use crate::menu::{EditMenu, GroupItem, HelpEntry, Menu, MenuItem, PanelMenu, PanelRow}; use crate::runtime::commands::EditCommands; use crate::runtime::env::with_env; @@ -102,6 +103,20 @@ fn menu_bar_close_titles(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { .into() } +/// The open File menu under `CommandHighlight::Hover`: the open title and the active row show the hover tint with +/// their own ink, as an app sets it at its root for a quiet command highlight. +#[story(MenuBar<'static>, covers = [], drive = Drive::Custom(open_file))] +fn menu_bar_hover_highlight(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + with_env( + ui, + |overrides| { + overrides.values.set(CommandHighlight::Hover); + }, + |ui| MenuBar::new("Main menu", titles()).show(ui), + ) + .into() +} + #[story(MenuBar<'static>, covers = [], drive = Drive::Never)] fn menu_bar_with_help_search(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { let entries = || HELP.clone(); diff --git a/crates/ui-widgets/tests/it/menu/rows.rs b/crates/ui-widgets/tests/it/menu/rows.rs index dfe540f80..b411d063f 100644 --- a/crates/ui-widgets/tests/it/menu/rows.rs +++ b/crates/ui-widgets/tests/it/menu/rows.rs @@ -6,11 +6,11 @@ use craft_i18n::Direction; use craft_ui::buttons::Button; use craft_ui::contract::tooltip::DELAY; use craft_ui::contract::{CommandSet, Props as _, Show as _, ShowContainer as _, Trigger}; -use craft_ui::list::ThumbAspect; +use craft_ui::list::{CommandHighlight, ThumbAspect}; use craft_ui::menu::{Menu, MenuItem}; use craft_ui::primitives::FacePaint; use craft_ui::runtime::commands::CommandState; -use craft_ui::runtime::env::Scale; +use craft_ui::runtime::env::{Scale, with_env}; use craft_ui::testing::{Fixture, Room, pointer, trial}; use egui::Rect; use std::cell::Cell; @@ -259,6 +259,42 @@ fn the_menu_highlight_moves_to_the_next_row_in_the_frame_the_pointer_reaches_it( assert!(fills_in(&shapes, undo).is_empty(), "the row the pointer left paints no highlight at once: {:?}", fills_in(&shapes, undo)); } +/// The fill of an open menu's row under the pointer, with `highlight` set at the root or the default. +fn lit_fill(highlight: Option) -> egui::Color32 { + let mut fixture = Fixture::new(move |ui| { + with_env( + ui, + |overrides| { + if let Some(highlight) = highlight { + overrides.values.set(highlight); + } + }, + |ui| { + let opener = Button::new("Open").show(ui); + Menu::new("Edit").opened_by(&opener, Trigger::Click).show(ui, |ui, _| { + MenuItem::new("Undo").show(ui); + MenuItem::new("Redo").show(ui); + }); + }, + ); + }); + fixture.settle(); + let opener = fixture.by_label("Open").expect("the opener"); + fixture.click(&opener).settle(); + let undo = fixture.by_label("Undo").expect("the menu is open").rect; + let shapes = fixture.frame_shapes_with(vec![pointer::moved(undo.center())]); + let [lit] = fills_in(&shapes, undo)[..] else { panic!("the row under the pointer paints one highlight: {:?}", fills_in(&shapes, undo)) }; + lit +} + +/// An app that sets `CommandHighlight::Hover` at its root gets a highlight other than the default accent on the row +/// under the pointer, and the menu still shows which row is active. +#[trial] +fn a_root_command_highlight_changes_the_active_rows_fill() { + assert_eq!(lit_fill(Some(CommandHighlight::Accent)), lit_fill(None), "the accent is the default"); + assert_ne!(lit_fill(Some(CommandHighlight::Hover)), lit_fill(None), "the hover highlight is not the accent"); +} + /// A label long enough that a menu of it is wider than a popup's least width, so a sample column shows in the width. const LONG: &str = "Neue Grotesk Display Condensed Extra Light Italic"; From 327fcaa90637ab44600ba291d2d15edc3402d9c8 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 18:31:59 +0700 Subject: [PATCH 15/22] canvas, pasteboard: Pasteboard::artboard_edge chooses ArtboardEdge::Plain, which edges the active artboard in black at stroke.thin and the others in grey 120 at a hairline, data colours that read against the paper; Accent stays the default --- crates/ui-canvas/src/canvas/mod.rs | 2 +- crates/ui-canvas/src/canvas/pasteboard/mod.rs | 49 +++++++++++++++---- .../src/canvas/pasteboard/stories.rs | 13 ++++- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/crates/ui-canvas/src/canvas/mod.rs b/crates/ui-canvas/src/canvas/mod.rs index 162b9fa29..88a0dd64d 100644 --- a/crates/ui-canvas/src/canvas/mod.rs +++ b/crates/ui-canvas/src/canvas/mod.rs @@ -44,7 +44,7 @@ pub use raster_source::{PixelRect, RasterSource}; pub(crate) mod pasteboard; pub(crate) mod split; -pub use pasteboard::{PageBorder, PageFill, PageFrame, Pasteboard, PasteboardColor, PasteboardOutput, PasteboardStyle}; +pub use pasteboard::{ArtboardEdge, PageBorder, PageFill, PageFrame, Pasteboard, PasteboardColor, PasteboardOutput, PasteboardStyle}; pub use split::{PanePress, SplitAt, SplitLayout, SplitPane, SplitPaneAt, SplitStyle, SplitViews, SplitViewsOutput, TabDrop, TabDropTarget}; pub use words::SplitWords; diff --git a/crates/ui-canvas/src/canvas/pasteboard/mod.rs b/crates/ui-canvas/src/canvas/pasteboard/mod.rs index 0625da39d..a175bb976 100644 --- a/crates/ui-canvas/src/canvas/pasteboard/mod.rs +++ b/crates/ui-canvas/src/canvas/pasteboard/mod.rs @@ -12,7 +12,7 @@ use crate::contract::{ Access, Bind, Common, Component, Cx, MeasureCx, Name, NoValue, Outcome, Overlay, OverlayUi, Overlays as _, PaintUi, PartsCx, Pointer as _, Props as _, Rename, Role, Show as _, }; -use crate::primitives::{Checker, CheckerArea, PaintShape, PaintSlot, Rule, StrokeWidth, TextRun, paint_surround}; +use crate::primitives::{Checker, CheckerArea, PaintShape, PaintSlot, Rule, StrokeColor, StrokeWidth, TextRun, paint_surround}; use crate::runtime::env::Label; use crate::runtime::focus::{FocusPolicy, Initial}; use crate::runtime::memory::Remember as _; @@ -77,6 +77,23 @@ pub enum PageBorder { None, } +/// How the edges of artboards (pages marked with [`PageFrame::active()`]) show which one is active. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] +#[non_exhaustive] +pub enum ArtboardEdge { + /// The active artboard's edge in `accent.solid`, the others in `line.border`, all at `stroke.thin`. + #[default] + Accent, + /// Colours that read against the paper rather than the chrome: the active artboard's edge black at `stroke.thin`, + /// the others mid grey at a hairline. + Plain, +} + +/// The edge of the active artboard under [`ArtboardEdge::Plain`]: black. +const PLAIN_ACTIVE: DataColor = DataColor::new(Color32::BLACK); +/// The edge of another artboard under [`ArtboardEdge::Plain`]: grey 120. +const PLAIN_OTHER: DataColor = DataColor::new(Color32::from_gray(120)); + /// What fills a page under the document. #[derive(Clone, Copy, Debug, PartialEq)] #[non_exhaustive] @@ -97,9 +114,9 @@ pub struct PageFrame { pub name: Option, /// The page's own fill under the document (an artboard's background), or `None` for none. pub fill: Option, - /// An artboard's edge: `Some(true)` for the active board (an accent edge, its name in the normal text colour), - /// `Some(false)` for another board (a faint dark edge, its name muted); `None` for a plain page, which only the - /// border shows. + /// An artboard's edge: `Some(true)` for the active board (its name in the normal text colour), `Some(false)` for + /// another board (its name muted), each edged as the pasteboard's [`ArtboardEdge`] says; `None` for a plain page, + /// which only the border shows. pub active: Option, /// Whether a double press on the page's name renames the page. pub renames: bool, @@ -216,6 +233,9 @@ pub struct Pasteboard<'a> { /// The border round each page; a drop shadow by default. #[prop] border: PageBorder, + /// How the artboards' edges show the active one; the accent by default. + #[prop] + artboard_edge: ArtboardEdge, /// Document rects the pasteboard does not cover, subtracted like the pages. #[prop] uncovered: &'a [DocRect], @@ -239,6 +259,7 @@ impl<'a> Pasteboard<'a> { common: Common::new(), pages, border: PageBorder::DropShadow, + artboard_edge: ArtboardEdge::Accent, uncovered: &[], shows_outside: false, name_sizes: Vec::new(), @@ -477,16 +498,17 @@ impl Component for Pasteboard<'_> { surround(); } let aligned = view.axis_aligned(); - let edge = |quad: &[Pos2; 4], color: StyleColor| { + // An edge in `color`, at `stroke.thin` or a hairline: `rule` is the same colour as the snapped rule paints it. + let edge = |quad: &[Pos2; 4], rule: Color32, color: StrokeColor, hairline: bool| { if aligned { let rect = bounds(quad); - let look = RuleLook { color: color.egui(), width: RuleWidth::Points(style.edge) }; + let look = RuleLook { color: rule, width: if hairline { RuleWidth::Hairline } else { RuleWidth::Points(style.edge) } }; let corners = [rect.left_top(), rect.right_top(), rect.right_bottom(), rect.left_bottom()]; for (from, to) in corners.into_iter().zip(corners.into_iter().cycle().skip(1)) { edges.painter.extend(Rule::shapes(&look, from, to, edges.pixels_per_point())); } } else { - draw.stroke(&polygon(quad), StrokeWidth::Thin, color); + draw.stroke(&polygon(quad), if hairline { StrokeWidth::Hairline } else { StrokeWidth::Thin }, color); } }; let shown = |page: &PageFrame| page.name.is_some() || bounds(&view.quad(page.rect)).intersects(view.rect); @@ -519,10 +541,19 @@ impl Component for Pasteboard<'_> { for (at, page) in self.pages.iter().enumerate().filter(|(_, page)| shown(page)) { let quad = view.quad(page.rect); if self.border == PageBorder::Line { - edge(&quad, style.outline); + edge(&quad, style.outline.egui(), style.outline.into(), false); } if let Some(active) = page.active { - edge(&quad, if active { style.active_edge } else { style.outline }); + match self.artboard_edge { + ArtboardEdge::Accent => { + let color = if active { style.active_edge } else { style.outline }; + edge(&quad, color.egui(), color.into(), false); + } + ArtboardEdge::Plain => { + let color = if active { PLAIN_ACTIVE } else { PLAIN_OTHER }; + edge(&quad, color.0, color.into(), !active); + } + } } if let (Some(name), Some(size)) = (&page.name, self.name_sizes.get(at).copied().flatten()) { let rect = name_rect(&view, page, style.name_gap, size); diff --git a/crates/ui-canvas/src/canvas/pasteboard/stories.rs b/crates/ui-canvas/src/canvas/pasteboard/stories.rs index 8a1e4ed55..8542c6d68 100644 --- a/crates/ui-canvas/src/canvas/pasteboard/stories.rs +++ b/crates/ui-canvas/src/canvas/pasteboard/stories.rs @@ -1,6 +1,6 @@ //! Stories of the pasteboard. -use super::{NAME, PageBorder, PageFrame, Pasteboard, PasteboardColor}; +use super::{ArtboardEdge, NAME, PageBorder, PageFrame, Pasteboard, PasteboardColor}; use crate::canvas::Canvas; use crate::canvas::testing::canvas_story::{StoryDocument, on_canvas_view, on_canvas_with, story_view}; use crate::contract::Show as _; @@ -53,6 +53,17 @@ fn artboards(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { on_canvas_view(ui, view, Some(&StoryDocument::STANDARD), |ui, at, _| Pasteboard::new("Pasteboard", pages).border(border).show_at(ui, at)) } +/// The two artboards under `ArtboardEdge::Plain`: the active one edged in black, the other in mid grey at a hairline, +/// as a drawing app's artboards read against the paper. +#[story(Pasteboard<'static>, covers = [], drive = Drive::Never)] +fn artboards_with_plain_edges(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let view = view_values(data, 0.0); + let pages: &[PageFrame] = data.value("pages", boards()); + on_canvas_view(ui, view, Some(&StoryDocument::STANDARD), |ui, at, _| { + Pasteboard::new("Pasteboard", pages).artboard_edge(ArtboardEdge::Plain).show_at(ui, at) + }) +} + #[story(Pasteboard<'static>, covers = [Default], drive = Drive::Never)] fn page_with_a_line(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let view = view_values(data, 0.0); From 66ab239f539354c493a8e7c88e0bed41fb068d50 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 18:33:33 +0700 Subject: [PATCH 16/22] ui-contract, text: TextRun::data_color fills the run's colour from data, painted as given, as IconSpec::data_color does for an icon: text over document content in the content's own colour --- crates/ui-contract/src/primitives/text.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/ui-contract/src/primitives/text.rs b/crates/ui-contract/src/primitives/text.rs index 5aafba08d..ab31ba77a 100644 --- a/crates/ui-contract/src/primitives/text.rs +++ b/crates/ui-contract/src/primitives/text.rs @@ -5,7 +5,7 @@ use crate::runtime::egui::memory; use crate::runtime::egui::text_layout; pub use crate::style::Span; use crate::style::text_measure::{paragraph_job, span_format}; -use crate::style::{LetterCase, StyleColor, TypeRole, UiTokens}; +use crate::style::{DataColor, LetterCase, StyleColor, TypeRole, UiTokens}; use craft_i18n::Direction; use egui::epaint::text::FontCacheRevision; use egui::text::{LayoutJob, TextWrapping}; @@ -141,6 +141,14 @@ impl<'a> TextRun<'a> { self } + /// Sets the colour from data, painted as given: text drawn over document content (a smart guide's label in the + /// guide's colour), whose colour belongs to the document and not to a state. It fills the colour slot of + /// [`color`](Self::color), as [`IconSpec::data_color`](super::IconSpec::data_color) does for an icon. + pub fn data_color(mut self, color: DataColor) -> Self { + self.color = Some(StyleColor(color.0)); + self + } + /// Sets how the run fits its room. pub fn wrap(mut self, wrap: Wrap) -> Self { self.wrap = wrap; From 6798a83eb94077241c143c780187d349724f3e3f Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 18:52:09 +0700 Subject: [PATCH 17/22] theme, tabs, canvas panel: size.bar.tab_large, the height of large document tabs (today's size.bar.title in every size set), so large tabs no longer take the title bar's height; CanvasPanel gives its tab pane an extent, size.bar.tab or size.bar.tab_large with the new large_tabs prop, so a strip taller than its first measured height shows its tabs whole. Story canvas_panel_with_large_tabs. --- crates/theme/sizes/comfortable.json | 1 + crates/theme/sizes/compact.json | 1 + crates/theme/src/dump.rs | 6 ++- crates/theme/src/sizes.rs | 1 + crates/theme/src/tokens/size.rs | 2 + .../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 + crates/ui-shell/src/shell/canvas_shell.rs | 14 +++++-- .../src/shell/canvas_shell/stories.rs | 21 ++++++++++ .../ui-shell/tests/it/shell/canvas_panel.rs | 40 ++++++++++++++++++- crates/ui-widgets/src/tabs/tab.rs | 2 +- docs/craft-framework.md | 2 +- 95 files changed, 166 insertions(+), 9 deletions(-) diff --git a/crates/theme/sizes/comfortable.json b/crates/theme/sizes/comfortable.json index b8a9da4ec..c9a0e265f 100644 --- a/crates/theme/sizes/comfortable.json +++ b/crates/theme/sizes/comfortable.json @@ -19,6 +19,7 @@ "options_narrow": 36.0, "status": 30.0, "tab": 30.0, + "tab_large": 38.0, "title": 38.0 }, "checker": 4.0, diff --git a/crates/theme/sizes/compact.json b/crates/theme/sizes/compact.json index 327efd8fb..1911106a6 100644 --- a/crates/theme/sizes/compact.json +++ b/crates/theme/sizes/compact.json @@ -19,6 +19,7 @@ "options_narrow": 28.0, "status": 24.0, "tab": 26.0, + "tab_large": 32.0, "title": 32.0 }, "checker": 4.0, diff --git a/crates/theme/src/dump.rs b/crates/theme/src/dump.rs index c57e37138..6f2dd8116 100644 --- a/crates/theme/src/dump.rs +++ b/crates/theme/src/dump.rs @@ -153,8 +153,10 @@ fn size_lines(out: &mut Lines, size: &SizeTokens) { let RailSizes { width, button } = rail; out.line("size.rail.width", len(*width)); out.line("size.rail.button", len(*button)); - let BarSizes { title, tab, status, options, options_narrow } = bar; - for (k, v) in [("title", title), ("tab", tab), ("status", status), ("options", options), ("options_narrow", options_narrow)] { + let BarSizes { title, tab, tab_large, status, options, options_narrow } = bar; + for (k, v) in + [("title", title), ("tab", tab), ("tab_large", tab_large), ("status", status), ("options", options), ("options_narrow", options_narrow)] + { out.line(&format!("size.bar.{k}"), len(*v)); } out.line("size.panel_header", len(*panel_header)); diff --git a/crates/theme/src/sizes.rs b/crates/theme/src/sizes.rs index 3b688f220..6101f7a76 100644 --- a/crates/theme/src/sizes.rs +++ b/crates/theme/src/sizes.rs @@ -102,6 +102,7 @@ pub(crate) fn leaves(b: &mut Preset) -> Vec> { "base.size.rail.button" Num 16.0..=64.0 => s.rail.button; "base.size.bar.title" Num 16.0..=80.0 => s.bar.title; "base.size.bar.tab" Num 16.0..=64.0 => s.bar.tab; + "base.size.bar.tab_large" Num 16.0..=80.0 => s.bar.tab_large; "base.size.bar.status" Num 16.0..=64.0 => s.bar.status; "base.size.bar.options" Num 16.0..=80.0 => s.bar.options; "base.size.bar.options_narrow" Num 16.0..=80.0 => s.bar.options_narrow; diff --git a/crates/theme/src/tokens/size.rs b/crates/theme/src/tokens/size.rs index 070402c7f..ce32a174a 100644 --- a/crates/theme/src/tokens/size.rs +++ b/crates/theme/src/tokens/size.rs @@ -225,6 +225,8 @@ pub struct BarSizes { pub title: f32, /// Tab strip. pub tab: f32, + /// Tab strip in its large form: large document tabs. + pub tab_large: f32, /// Status bar. pub status: f32, /// Tool options bar. 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 b9775df30..28bb4e540 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 3473dc114..049f56f19 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 7c79ce22f..46ae206f3 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 35e209a7c..cf3838c0d 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 2cccdc47d..1bfc92439 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 6bfe73ca8..829789b5b 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 407efd953..8becd841b 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 259fec424..3be11340e 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 72f92b55c..032d4a323 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 8f7404506..d13f08ba9 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 2f6d4bf66..a9ad075e4 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 0b9ef0d53..c3197b3d9 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 17c3f20e5..b18e615c9 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 f57a97bb2..7c1bdafc6 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 b903fb3d8..c04d76f9d 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 3af9fd463..f7448bea3 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 b3763445e..6f2fb5849 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 c8dbe7254..f7033fe8f 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 ae5183f13..8dfdb6673 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 2a8d84d2a..4959b6cc6 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 f3bb51673..a7a3b4adf 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 0f4b69e82..ca17d13ec 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 18bb48150..cddf7cf0d 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 b0303accf..134343b10 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 13727cb0f..4989b3eaf 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 066d41b5f..68563809d 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 2b68b4b3b..b52c28cad 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 36bb43ae8..e9b370a38 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 e0e59ac2f..b94b40adb 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 d0d601bed..16a7e2e94 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 4b8f20dd7..5223539c4 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 1072f5fb8..bf757ef21 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 95496cba8..feea7e8c0 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 7f321c715..ac715e105 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 d4a16141c..109721a5c 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 7010fd507..546ddb2ce 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 68e27a0bf..e6d3fca3b 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 5378f8d1a..20995a4ed 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 eb4dc5245..41ef2b8fb 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 2006a7000..1cfb24ce1 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 a72a2ce93..0613337f3 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 aa80bb3ec..d4bc3c92c 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 6c2d5ac98..c08ddb36e 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 a056292cd..4e755587f 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 0432039e9..d101cd1e8 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 3fb00c5b0..946945fae 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 9cb3857e5..102ba36e0 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 aee798775..5f921a8cd 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 97f114805..6b320a480 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 2105907f3..809ad2657 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 77f6ccdf6..17b68a56a 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 69a634cf7..c8213d01c 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 d535ed6ba..e7bd9f094 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 d3052e3dc..1da506ba3 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 ba3c5a1ba..0765c69df 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 2ca46e362..aa6f1f5af 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 3e5f7d544..608d7b62f 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 81709fae1..3ec91240c 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 52074cba6..5074be5a1 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 cbd58a3e9..9c81b7d0c 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 2aa846b60..2b5e409fd 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 7c96649c4..da22e8f42 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 aa84dca3f..4c0a039d7 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 cba6ebd6b..72edc0bc3 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 3f1d0c6f8..0b3cebd63 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 238bc1c66..696d0c65d 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-high-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 23d08b145..d02a991db 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-high-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 0a5a53a70..0eed9e1dc 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-standard-comfortable.txt @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 343cf762a..4795b318f 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-standard-compact.txt @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 05862e073..4567717fc 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 4c5d9b971..639bd853b 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 14a525235..c5e6193de 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 e4068c5d4..20d896f05 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 d7384b50f..684f2dbec 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 ae25fc624..a4dfa9b4d 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 f610585cb..514f8436f 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 aeeae13fd..a235839f1 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 97a482400..35569a21c 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 c8561174b..d970a4ac2 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 e84b9e3e7..4d63bbbe0 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 841009d9c..4ea363907 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 c520b18b0..c8ec46757 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 38de13e38..c1df70b96 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 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 bfeee3a20..669049b28 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 @@ -152,6 +152,7 @@ size.rail.width = 50 size.rail.button = 36 size.bar.title = 38 size.bar.tab = 30 +size.bar.tab_large = 38 size.bar.status = 30 size.bar.options = 42 size.bar.options_narrow = 36 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 3cdc85665..09f1e0bbe 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 @@ -152,6 +152,7 @@ size.rail.width = 40 size.rail.button = 30 size.bar.title = 32 size.bar.tab = 26 +size.bar.tab_large = 32 size.bar.status = 24 size.bar.options = 36 size.bar.options_narrow = 28 diff --git a/crates/ui-shell/src/shell/canvas_shell.rs b/crates/ui-shell/src/shell/canvas_shell.rs index b8427a4f9..260ed70f5 100644 --- a/crates/ui-shell/src/shell/canvas_shell.rs +++ b/crates/ui-shell/src/shell/canvas_shell.rs @@ -82,17 +82,21 @@ pub struct CanvasPanel<'a> { /// Documents are opening: the tab strip shows even when the host hides the tabs, in normal mode. #[prop] opening: bool, + /// The tab strip shows large tabs (`size.bar.tab_large` high, not `size.bar.tab`): give the strip's + /// `DocumentTabs::large` the same value. + #[prop] + large_tabs: bool, } impl<'a> CanvasPanel<'a> { /// A panel with no tab strip. pub fn new() -> Self { - CanvasPanel { tabs: None, opening: false } + CanvasPanel { tabs: None, opening: false, large_tabs: false } } /// Lays the panel out in `ui`, the body of the dock's canvas panel, with `document` in the area left. pub fn show(self, ui: &mut Ui, mut document: impl FnMut(&mut Ui, &mut BodyCx<'_>)) -> CanvasPanelOutput { - let CanvasPanel { tabs, opening } = self; + let CanvasPanel { tabs, opening, large_tabs } = self; let env = Env::of(ui); let words = env.words::(); let shell = env.get::().0; @@ -101,8 +105,10 @@ impl<'a> CanvasPanel<'a> { let mut tabs_rect = None; if let (Some(mut add), true) = (tabs.map(|RegionBody(add)| add), tabs_shown) { - // The document tabs sit on the window's background, as tab strips do. - let out = ShellRegion::pane(ShellPane::new("document_tabs").edge(PaneEdge::Top)) + // The document tabs sit on the window's background, as tab strips do, as high as their tabs. + let bar = &env.tokens.size.bar; + let height = if large_tabs { bar.tab_large } else { bar.tab }; + let out = ShellRegion::pane(ShellPane::new("document_tabs").edge(PaneEdge::Top).extent(height)) .surface(SurfaceKind::Background) .id_salt("document_tabs") .label(words.document_tabs.clone()) diff --git a/crates/ui-shell/src/shell/canvas_shell/stories.rs b/crates/ui-shell/src/shell/canvas_shell/stories.rs index 0c9beb101..63a17fc4c 100644 --- a/crates/ui-shell/src/shell/canvas_shell/stories.rs +++ b/crates/ui-shell/src/shell/canvas_shell/stories.rs @@ -3,6 +3,7 @@ use super::CanvasPanel; use crate::contract::Show as _; use crate::display::Text; +use crate::tabs::{DocumentTab, DocumentTabs, DocumentTabsEvent}; use crate::testing::{Drive, StoryData, StoryOutput, story}; use egui::Ui; @@ -28,3 +29,23 @@ fn empty_canvas_panel(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { .show(ui, |_, _| {}) .into() } + +/// Large tabs: the strip is `size.bar.tab_large` high, the height the panel gives its tab pane. +#[story(CanvasPanel<'static>, covers = [], drive = Drive::Never)] +fn canvas_panel_with_large_tabs(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let tabs = [DocumentTab::new(0_usize, "Poster"), DocumentTab::new(1, "Logo")]; + let shown = data.value("shown", 0_usize); + let out = CanvasPanel::new() + .large_tabs(true) + .tabs(|ui, _| { + for event in DocumentTabs::new("Documents", &tabs).selected(*shown).large(true).show(ui).events { + if let DocumentTabsEvent::Selected(tab) = event { + *shown = tab; + } + } + }) + .show(ui, |ui, _| { + Text::new("Document").show(ui); + }); + out.into() +} diff --git a/crates/ui-shell/tests/it/shell/canvas_panel.rs b/crates/ui-shell/tests/it/shell/canvas_panel.rs index cae0cf894..dc7c29043 100644 --- a/crates/ui-shell/tests/it/shell/canvas_panel.rs +++ b/crates/ui-shell/tests/it/shell/canvas_panel.rs @@ -1,14 +1,18 @@ //! `CanvasPanel`: a double click on the empty document area is the panel's `empty_double` (the host opens a file); -//! over a document whose canvas takes the press, it is never reported. +//! over a document whose canvas takes the press, it is never reported. The tab strip is as high as its tabs. use craft_behavior::{HitLevel, HitPriority, PartKey, Sense}; +use craft_theme::{AppSizes, SizeValue}; use craft_ui::contract::{Common, Component, Cx, MeasureCx, PartsCx, Role, Show as _}; +use craft_ui::runtime::env::{Env, RootEnv}; use craft_ui::shell::CanvasPanel; +use craft_ui::tabs::{DocumentTab, DocumentTabs}; use craft_ui::testing::pointer::{moved, press, release}; use craft_ui::testing::trial; use craft_ui_test_kit::contract::PlainStyle; use craft_ui_test_kit::windows::Windows; use egui::{Event, Rect, Response, Vec2}; +use std::sync::Arc; const BACKGROUND: PartKey = PartKey::new("background"); @@ -90,3 +94,37 @@ fn an_empty_canvas_panel_reports_a_double_click_on_its_room() { assert_eq!(empty_doubles(false, 2), vec![3], "the second press on the empty room reports once"); assert_eq!(empty_doubles(true, 2), Vec::::new(), "a document that takes the press leaves the room's double click unreported"); } + +/// Regression: the tab pane had no extent, so it kept the height it first took (the strip before its tabs measured) and +/// cut the tabs of a taller `size.bar.tab`; large tabs took the title bar's height. Each form of the strip shows its +/// tabs whole in a pane at least as high as its own token, the large form above the regular. +#[trial] +fn the_tab_strip_is_as_high_as_its_tabs() { + let tabs = [DocumentTab::new(0_usize, "One"), DocumentTab::new(1, "Two")]; + let shown = |large: bool| { + let windows = Windows::new(); + let mut root = RootEnv::default(); + let mut sizes = AppSizes::default(); + sizes.all.insert("size.bar.tab".to_owned(), SizeValue::Number(44.0)); + sizes.all.insert("size.bar.tab_large".to_owned(), SizeValue::Number(60.0)); + root.sizes = Arc::new(sizes); + windows.root_env(root); + let (mut pane, mut strip, mut token) = (None, Rect::NOTHING, 0.0); + for _ in 0..3 { + windows.frame(vec![], vec![], |ui| { + let bar = Env::of(ui).tokens.size.bar; + token = if large { bar.tab_large } else { bar.tab }; + pane = CanvasPanel::new() + .large_tabs(large) + .tabs(|ui, _| strip = DocumentTabs::new("Documents", &tabs).large(large).show(ui).response.rect) + .show(ui, |_, _| {}) + .tabs; + }); + } + let (pane, form) = (pane.expect("the panel shows its tab strip"), if large { "large" } else { "regular" }); + assert!(pane.height() >= token, "the {form} strip's pane {pane:?} is as high as its token {token}"); + assert!(strip.is_positive() && pane.contains_rect(strip), "the {form} strip's tabs {strip:?} lie whole in its pane {pane:?}"); + pane.height() + }; + assert!(shown(true) > shown(false), "large tabs take the taller strip"); +} diff --git a/crates/ui-widgets/src/tabs/tab.rs b/crates/ui-widgets/src/tabs/tab.rs index 729f598f3..7a035282f 100644 --- a/crates/ui-widgets/src/tabs/tab.rs +++ b/crates/ui-widgets/src/tabs/tab.rs @@ -393,7 +393,7 @@ impl Component for Tab<'_> { } else if text_only { line(role) + space.gap.tight + stroke.thick } else if key.large { - size.bar.title + size.bar.tab_large } else if key.kind == TabKind::Panel { size.panel_header } else { diff --git a/docs/craft-framework.md b/docs/craft-framework.md index 19276c95c..6ba8c0c0e 100644 --- a/docs/craft-framework.md +++ b/docs/craft-framework.md @@ -989,7 +989,7 @@ A theme with its own shape replaces the radii or adds an offset to control, surf | `size.control.sm`, `size.control.md` | Controls, fields, buttons | | `size.icon.sm`, `size.icon.md`, `size.icon.lg` | Icons; `md` is the glyph of a tool strip and of a panel footer's actions (`GlyphRole::Tool`), `lg` of a tool rail (`GlyphRole::ToolRail`). A stroke-set icon draws its line `stroke.icon` of its side | | `size.icon.glyph_sm`, `size.icon.glyph_md` | The glyph in an icon-only button (`GlyphRole::Control`, the default; a container sets another with `ContainerProps::child_glyphs`) | -| `size.bar.title`, `size.bar.tab`, `size.bar.status`, `size.bar.options`, `size.bar.options_narrow` | Title bar, document tab bar, status bar, options bar | +| `size.bar.title`, `size.bar.tab`, `size.bar.tab_large`, `size.bar.status`, `size.bar.options`, `size.bar.options_narrow` | Title bar, document tab bar, document tab bar with large tabs, status bar, options bar | | `size.panel_header` | Panel headers | | `size.popup_min` | Least width of a popup surface (menus only; popup lists such as Select and ComboBox take their anchor's width) | | `size.groove` | Groove of a value track | From 6ea1ea73b1620557c9d4d78686dcfd15d162ad2d Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 18:52:16 +0700 Subject: [PATCH 18/22] ui-contract, sections: SectionRhythm, an env value an app sets once at its root. Under Spaced a header ruled above (a Section) stands its rule space.gap.section off what precedes it in its Stack, in place of the stack's gap (no room at its flow's start), and its header space.gap.row below the rule; Tight, the default, keeps the stack's gap and the header right under the rule. The Stack's gap reaches its direct children through the env. Story section_rhythm shows both. --- crates/ui-contract/src/contract/body/hooks.rs | 10 ++-- .../ui-contract/src/contract/body/regions.rs | 36 ++++++++++---- crates/ui-contract/src/contract/body/size.rs | 2 +- crates/ui-contract/src/contract/container.rs | 14 ++++++ crates/ui-contract/src/contract/mod.rs | 4 +- crates/ui-contract/src/layout/body.rs | 1 + crates/ui-contract/src/runtime/env.rs | 4 ++ .../ui-panels/src/sections/section/stories.rs | 27 ++++++++++- crates/ui-panels/tests/it/sections/mod.rs | 1 + crates/ui-panels/tests/it/sections/rhythm.rs | 48 +++++++++++++++++++ 10 files changed, 130 insertions(+), 17 deletions(-) create mode 100644 crates/ui-panels/tests/it/sections/rhythm.rs diff --git a/crates/ui-contract/src/contract/body/hooks.rs b/crates/ui-contract/src/contract/body/hooks.rs index fbb2783e3..a92e7820e 100644 --- a/crates/ui-contract/src/contract/body/hooks.rs +++ b/crates/ui-contract/src/contract/body/hooks.rs @@ -165,8 +165,9 @@ impl ShapeHooks for BodyHooks<'_> { self.region_gap = gap_of(&env.tokens, Gap::Tight); self.end_gap = gap_of(&env.tokens, props.end.map_or(Gap::Tight, |end| end.gap)); self.header_gap = header_gap_of(props, &env.tokens); - self.after_rule = layout::flow_start(&ctx, env) == Some(true); - self.rules = RuleBands::of(props, &env.tokens, crate::runtime::egui::scale::pixels_per_point(&ctx), self.after_rule); + let start = layout::flow_start(&ctx, env); + self.after_rule = start == Some(true); + self.rules = RuleBands::of(props, env, crate::runtime::egui::scale::pixels_per_point(&ctx), start); self.least_width = least_of(&env.tokens, props.least_width); let quiet = stage.is_peek() || crate::runtime::measure::active(&ctx); if !matches!(props.mount, Mount::Inline | Mount::Pane(_)) @@ -1900,8 +1901,9 @@ impl BodyHooks<'_> { self.region_gap = gap_of(&at.env.tokens, Gap::Tight); self.end_gap = gap_of(&at.env.tokens, props.end.map_or(Gap::Tight, |end| end.gap)); self.header_gap = header_gap_of(&props, &at.env.tokens); - self.after_rule = layout::flow_start(at.ui.ctx(), at.env) == Some(true); - self.rules = RuleBands::of(&props, &at.env.tokens, crate::runtime::egui::scale::pixels_per_point(at.ui.ctx()), self.after_rule); + let start = layout::flow_start(at.ui.ctx(), at.env); + self.after_rule = start == Some(true); + self.rules = RuleBands::of(&props, at.env, crate::runtime::egui::scale::pixels_per_point(at.ui.ctx()), start); self.least_width = least_of(&at.env.tokens, props.least_width); self.room = match at.width { Some(width) => Vec2::new(width, props.room_height.unwrap_or(f32::INFINITY)), diff --git a/crates/ui-contract/src/contract/body/regions.rs b/crates/ui-contract/src/contract/body/regions.rs index 1d74217e4..a02bea21b 100644 --- a/crates/ui-contract/src/contract/body/regions.rs +++ b/crates/ui-contract/src/contract/body/regions.rs @@ -3,7 +3,7 @@ use super::BodyHooks; use super::scroll::scroll_of; use crate::contract::cx::BodyCx; -use crate::contract::{Container, ContainerProps, FooterPlace, Gap, HeaderParts, LeastWidth, Mount, Pad, PadEdges, Sizing}; +use crate::contract::{Container, ContainerProps, FooterPlace, Gap, HeaderParts, LeastWidth, Mount, Pad, PadEdges, SectionRhythm, Sizing}; use crate::layout::{ColumnGroup, Columns, Reached}; use crate::primitives::{RectSide, Rule}; use crate::runtime::access::{self}; @@ -70,11 +70,16 @@ pub(super) fn pad_vec(tokens: &UiTokens, pad: Pad, edges: PadEdges) -> Vec2 { /// The room the rules between a container's regions take, in points: the divider rule's width on the display for each /// rule the container draws, none for one it doesn't. Each rule lies in a band of its own, so it shares no pixel with -/// a region's content at any scale. +/// a region's content at any scale. Under `SectionRhythm::Spaced` the rule above a header has room around it. #[derive(Clone, Copy, Debug, Default)] pub(super) struct RuleBands { + /// Before the rule above the header: what makes the gap the container's `Stack` leaves before it up to + /// `space.gap.section`. + pub(super) lead: f32, /// Above a header with `HeaderRegion::rule_above`. pub(super) above: f32, + /// Between the rule above and the header: `space.gap.row`. + pub(super) trail: f32, /// Under a stacked header with `HeaderRegion::rule`, before its gap. pub(super) under: f32, /// Between a footer with `FooterRegion::rule` and the content beside it: over the footer, or under it in the end @@ -85,18 +90,31 @@ pub(super) struct RuleBands { } impl RuleBands { - /// The bands of `props`' rules in `tokens` on a display of `pixels_per_point`. A rule above separates the - /// container from what precedes it in flow: right after a rule (`after_rule`) there is none. - pub(super) fn of(props: &ContainerProps, tokens: &UiTokens, pixels_per_point: f32, after_rule: bool) -> Self { + /// The bands of `props`' rules under `env` on a display of `pixels_per_point`, for a container whose flow start is + /// `start` (`layout::flow_start`). A rule above separates the container from what precedes it in flow: right after + /// a rule there is none, and at its flow's start nothing precedes it to stand off from. + pub(super) fn of(props: &ContainerProps, env: &Env, pixels_per_point: f32, start: Option) -> Self { + let tokens = &env.tokens; let width = rule_look(tokens, RuleKind::Divider).width.points(pixels_per_point); let on = |rule: bool| if rule { width } else { 0.0 }; + let above = on(start != Some(true) && props.header.is_some_and(|header| header.rule_above)); + let spaced = above > 0.0 && env.get::() == SectionRhythm::Spaced; + let gaps = &tokens.tokens().space.gap; + let stack_gap = env.stack_gap.filter(|(body, _)| env.flow_body == Some(*body)).map_or(0.0, |(_, gap)| gap); RuleBands { - above: on(!after_rule && props.header.is_some_and(|header| header.rule_above)), + lead: if spaced && start.is_none() { (gaps.section - stack_gap).max(0.0) } else { 0.0 }, + above, + trail: if spaced { gaps.row } else { 0.0 }, under: on(props.header.is_some_and(|header| header.rule && !header.inline)), footer: on(props.footer.is_some_and(|footer| footer.rule)), end: on(props.end.is_some_and(|end| end.rule)), } } + + /// The band of the rule above the header with the room around it. + pub(super) fn above_band(&self) -> f32 { + self.lead + self.above + self.trail + } } /// Whether a ruled footer's rule lies under it: a footer at the top of the end region separates itself from the end @@ -405,7 +423,7 @@ impl<'b> BodyHooks<'b> { let end_h = sizes.end.map_or(0.0, |end| end.y) + if in_end { footer_h } else { 0.0 }; // An inline header takes no height of its own: the line is as high as the taller of header and body. A rule // above the header takes its band either way. - let stacked_h = self.rules.above + if inline { 0.0 } else { header_h + self.header_space(header_h) }; + let stacked_h = self.rules.above_band() + if inline { 0.0 } else { header_h + self.header_space(header_h) }; let top = inner.min.y + stacked_h; // Along an axis the container is not given, its body is offered the room the container was offered and the // container takes what the body took. @@ -457,7 +475,7 @@ impl<'b> BodyHooks<'b> { let width = if rtl && !width.is_finite() { crate::contract::MAX_EXTENT } else { width }; let (left, right) = if rtl { (inner.max.x - width, inner.max.x) } else { (inner.min.x, inner.min.x + width) }; let band = |top: f32, bottom: f32| Rect::from_min_max(Pos2::new(left, top), Pos2::new(right, bottom.max(top))); - let header_top = inner.min.y + self.rules.above; + let header_top = inner.min.y + self.rules.above_band(); let header = band(header_top, if props.header.is_some() { header_top + header_h.max(0.0) } else { header_top }); let mut body = band(top, bottom); let header = if inline { @@ -476,7 +494,7 @@ impl<'b> BodyHooks<'b> { header }; let across = |top: f32, width: f32| (width > 0.0).then(|| (Rect::from_x_y_ranges(inner.x_range(), top..=top + width), RectSide::Top)); - let above = across(inner.min.y, self.rules.above); + let above = across(inner.min.y + self.rules.lead, self.rules.above); let under = if inline { None } else { across(header.max.y, self.rules.under) }; // The end region keeps the width it measured (with a footer in it, the wider of the two) and takes the end // edge; the body takes the rest. Before its first measure it spans the line and the body keeps its width. diff --git a/crates/ui-contract/src/contract/body/size.rs b/crates/ui-contract/src/contract/body/size.rs index fe3c8103f..fb634c843 100644 --- a/crates/ui-contract/src/contract/body/size.rs +++ b/crates/ui-contract/src/contract/body/size.rs @@ -271,7 +271,7 @@ impl<'b> BodyHooks<'b> { } else { ((line.x + gap(end.x, end_gap)).max(across.x), line.y.max(end.y) + across.y) }; - let above = self.rules.above; + let above = self.rules.above_band(); if inline { Vec2::new(width, height + above) } else { diff --git a/crates/ui-contract/src/contract/container.rs b/crates/ui-contract/src/contract/container.rs index 819ff2606..502851b41 100644 --- a/crates/ui-contract/src/contract/container.rs +++ b/crates/ui-contract/src/contract/container.rs @@ -307,6 +307,20 @@ pub enum HeaderEdge { End, } +/// The room around the rule above a header ([`HeaderRegion::rule_above`]), as a `Section` has. An app sets it once at its +/// root (`RootEnv::values`); the default is `Tight`. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum SectionRhythm { + /// The rule takes the gap its flow leaves before the container, and the header follows it at once. + #[default] + Tight, + /// The rule stands `space.gap.section` below what precedes it in its `Stack`, in place of the stack's gap (no room + /// at its flow's start), and the header `space.gap.row` below it: production VectorCraft's panel sections. + Spaced, +} + /// A header region, filled by `Container::header`. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[non_exhaustive] diff --git a/crates/ui-contract/src/contract/mod.rs b/crates/ui-contract/src/contract/mod.rs index cb309b921..03dd21d44 100644 --- a/crates/ui-contract/src/contract/mod.rs +++ b/crates/ui-contract/src/contract/mod.rs @@ -69,8 +69,8 @@ pub use container::InBar; pub use container::InMenu; pub use container::{ BandFill, Bracket, Collapse, ContainerProps, DragBand, EndRegion, FooterPlace, FooterRegion, Gap, HeaderEdge, HeaderParts, HeaderRegion, - LeastWidth, Mount, Notch, POPUP_PAD, Pad, PadEdges, PaneEdge, Scroll, ScrollAnchor, ScrollAxes, ScrollIndicator, ShellPane, Sizing, ThemeScope, - WrapWidth, + LeastWidth, Mount, Notch, POPUP_PAD, Pad, PadEdges, PaneEdge, Scroll, ScrollAnchor, ScrollAxes, ScrollIndicator, SectionRhythm, ShellPane, + Sizing, ThemeScope, WrapWidth, }; pub use craft_tracked::{PlainData, Revision, Tracked}; pub use craft_ui_macros::{CommandSet, Component, Pattern, PlainData, Props, register_contract}; diff --git a/crates/ui-contract/src/layout/body.rs b/crates/ui-contract/src/layout/body.rs index ab377e08d..5ca08306c 100644 --- a/crates/ui-contract/src/layout/body.rs +++ b/crates/ui-contract/src/layout/body.rs @@ -1965,6 +1965,7 @@ fn run_stack(ui: &mut Ui, env: &Env, at: &RowIn, body: impl FnMut(&mut Ui) -> let env = env.derive_local(|scoped| { scoped.shrink = Some(Shrink::Fit); scoped.flow_body = Some(at.id); + scoped.stack_gap = Some((at.id, at.gap.y)); }); let installed = Env::install_for(ui, env.clone()); // A held child of a column whose own room is unbounded keeps the width it measured at. diff --git a/crates/ui-contract/src/runtime/env.rs b/crates/ui-contract/src/runtime/env.rs index c655fb603..294f035af 100644 --- a/crates/ui-contract/src/runtime/env.rs +++ b/crates/ui-contract/src/runtime/env.rs @@ -165,6 +165,9 @@ pub struct Scoped { /// The body whose flow places the scope's direct children: the flow start a child reads (`layout::flow_start`) /// and the one a child placed in flow closes. pub(crate) flow_body: Option, + /// The `Stack` body that places the scope's direct children in flow and the gap it leaves between them; it holds + /// only while that body is `flow_body`. + pub(crate) stack_gap: Option<(Id, f32)>, /// A rule precedes the start of the body this scope opens: its container draws one under its header, or draws /// nothing of its own and itself follows one. The body's layout opens its flow start with it. pub(crate) after_rule: bool, @@ -700,6 +703,7 @@ impl Env { row_line: None, first_line: None, flow_body: None, + stack_gap: None, after_rule: false, column_row: false, bracket: None, diff --git a/crates/ui-panels/src/sections/section/stories.rs b/crates/ui-panels/src/sections/section/stories.rs index 1425532bc..fd33261ef 100644 --- a/crates/ui-panels/src/sections/section/stories.rs +++ b/crates/ui-panels/src/sections/section/stories.rs @@ -1,8 +1,10 @@ //! Stories of `Section`. use super::Section; -use crate::contract::{Role, Show as _, ShowContainer as _}; +use crate::contract::{Props as _, Role, SectionRhythm, Show as _, ShowContainer as _}; use crate::display::Text; +use crate::layout_components::Stack; +use crate::runtime::env::with_env; use crate::sections::sample::body; use crate::sections::{HeaderAction, HeaderStrength}; use crate::testing::{Drive, Fixture, StoryData, StoryOutput, story}; @@ -61,3 +63,26 @@ fn section_with_controls(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { .show(ui, |ui, _| body(ui)); shown.output.into() } + +/// A row and two sections under each `SectionRhythm`: `Tight` (the default) gives each rule the stack's gap and its +/// header follows at once; `Spaced` stands each rule `space.gap.section` off what precedes it and its header +/// `space.gap.row` below it. +#[story(Section<'static>, covers = [], drive = Drive::Never)] +fn section_rhythm(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let mut column = |ui: &mut Ui, key: &'static str| { + Stack::new().id_salt(key).show(ui, |ui, _| { + Text::new("Fill").show(ui); + Section::new("Stroke").open(data.bind(key, true)).show(ui, |ui, _| body(ui)); + Section::fixed("Effects").show(ui, |ui, _| body(ui)); + }); + }; + column(ui, "tight"); + with_env( + ui, + |overrides| { + overrides.values.set(SectionRhythm::Spaced); + }, + |ui| column(ui, "spaced"), + ); + StoryOutput::default() +} diff --git a/crates/ui-panels/tests/it/sections/mod.rs b/crates/ui-panels/tests/it/sections/mod.rs index c5c8b214d..9a71809d9 100644 --- a/crates/ui-panels/tests/it/sections/mod.rs +++ b/crates/ui-panels/tests/it/sections/mod.rs @@ -7,4 +7,5 @@ pub(crate) mod footer_row; pub(crate) mod layout; pub(crate) mod panel_header; pub(crate) mod reorderable; +pub(crate) mod rhythm; pub(crate) mod stack; diff --git a/crates/ui-panels/tests/it/sections/rhythm.rs b/crates/ui-panels/tests/it/sections/rhythm.rs new file mode 100644 index 000000000..4fe61c1b7 --- /dev/null +++ b/crates/ui-panels/tests/it/sections/rhythm.rs @@ -0,0 +1,48 @@ +//! `SectionRhythm`: the room around the rule above a section's header. + +use craft_ui::contract::{SectionRhythm, Show as _, ShowContainer as _}; +use craft_ui::display::Text; +use craft_ui::layout_components::Stack; +use craft_ui::runtime::env::{Env, RootEnv}; +use craft_ui::sections::Section; +use craft_ui::testing::{Frames, trial}; +use egui::{Rect, Ui}; + +/// What a stack of a row and a fixed section shows under `rhythm`: the room from the row to the section's rule, the room +/// from the rule to the section's body, and `space.gap.section`. +fn rule_room(rhythm: SectionRhythm) -> (f32, f32, f32) { + let mut frames = Frames::new(); + let mut root = RootEnv::default(); + root.values.set(rhythm); + frames.root(root); + let (mut row, mut body, mut section_gap) = (Rect::NOTHING, Rect::NOTHING, 0.0); + let mut show = |ui: &mut Ui| { + section_gap = Env::of(ui).tokens.space.gap.section; + Stack::new().show(ui, |ui, _| { + row = Text::new("Fill").show(ui).rect; + Section::fixed("Stroke").show(ui, |ui, _| body = Text::new("Width").show(ui).rect); + }); + }; + frames.idle(2, &mut show); + let rule = frames + .frame_shapes(&mut show) + .iter() + .map(egui::Shape::visual_bounding_rect) + .find(|line| { + line.is_finite() && line.height() <= 2.0 && line.width() > body.width() && line.top() >= row.bottom() && line.bottom() <= body.top() + }) + .expect("the section draws its rule between the row and its body"); + (rule.top() - row.bottom(), body.top() - rule.bottom(), section_gap) +} + +/// Regression: a ruled section in a stack took only the stack's gap above its rule and its header right under it, so an +/// app could not keep production's room around its panel dividers. `Spaced` stands the rule `space.gap.section` off the +/// row above and the header further from the rule; `Tight` keeps the stack's rhythm. +#[trial] +fn a_spaced_section_stands_its_rule_off_the_row_above_and_its_header() { + let (tight_above, tight_below, _) = rule_room(SectionRhythm::Tight); + let (spaced_above, spaced_below, section_gap) = rule_room(SectionRhythm::Spaced); + assert!(spaced_above > tight_above, "the spaced rule stands further off the row ({spaced_above}) than the tight one ({tight_above})"); + assert!(spaced_above >= section_gap - 0.5, "the spaced rule stands a section gap ({section_gap}) off the row, not {spaced_above}"); + assert!(spaced_below > tight_below, "the spaced header stands further below its rule ({spaced_below}) than the tight one ({tight_below})"); +} From 09650e1d3d773e0389d2bcbeff3153962b0a466d Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 19:38:11 +0700 Subject: [PATCH 19/22] ui-contract style: TrackFill, a root style value; under TrackFill::Accent a slider's and a range slider's track fill the value's part in accent.solid (disabled text.disabled) on a line.outline groove; TrackFill::Muted, the default, keeps text.muted on line.control_edge. Slider story under Accent --- crates/ui-contract/src/style/cx.rs | 14 +++++++++----- crates/ui-contract/src/style/look.rs | 13 +++++++++++++ crates/ui-contract/src/style/mod.rs | 2 +- .../ui-widgets/src/value_drag/slider/stories.rs | 15 ++++++++++++++- 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/crates/ui-contract/src/style/cx.rs b/crates/ui-contract/src/style/cx.rs index 5dbb72465..ccc0377e8 100644 --- a/crates/ui-contract/src/style/cx.rs +++ b/crates/ui-contract/src/style/cx.rs @@ -1,7 +1,7 @@ //! `StyleCx`: what `style` and the app colour hooks get. Tokens are readable only through it. use super::key::{EnvKey, Ink}; -use super::look::{DataColor, FocusLook, StyleColor, SurfaceKind, SurfaceLook, TrackLook}; +use super::look::{DataColor, FocusLook, StyleColor, SurfaceKind, SurfaceLook, TrackFill, TrackLook}; use super::paint::{ AutoScrollMarkLook, HandleLook, MarkerLook, ResetMarkLook, RuleKind, RuleLook, ScrollBarKind, ScrollBarLook, auto_scroll_mark_look, handle_look, marker_look, reset_mark_look, rule_look, scroll_bar_look_of, @@ -350,14 +350,18 @@ impl<'a> StyleCx<'a> { )) } - /// The look of a value track: a groove of `size.groove` with the part a value fills over it, and its marks. + /// The look of a value track: a groove of `size.groove` with the part a value fills over it, in the scope's + /// [`TrackFill`], and its marks. pub fn track(&self) -> TrackLook { let colors = &self.tokens.color; - let groove = self.color(colors.line.control_edge); - let muted = self.color(colors.text.muted); + let (groove, fill) = match self.env::() { + TrackFill::Muted => (colors.line.control_edge, colors.text.muted), + TrackFill::Accent => (colors.line.outline, colors.accent.solid), + }; + let (groove, fill) = (self.color(groove), self.color(fill)); TrackLook { unfilled: Stateful::new(groove), - filled: Stateful::new(muted).off(States::new(muted, muted, muted, self.color(colors.text.disabled))), + filled: Stateful::new(fill).off(States::new(fill, fill, fill, self.color(colors.text.disabled))), edge: Stateful::new(self.color(colors.line.control_edge)), edge_width: self.tokens.stroke.thin, thickness: self.tokens.size.groove, diff --git a/crates/ui-contract/src/style/look.rs b/crates/ui-contract/src/style/look.rs index 27b48a990..07fd98849 100644 --- a/crates/ui-contract/src/style/look.rs +++ b/crates/ui-contract/src/style/look.rs @@ -290,6 +290,19 @@ impl IconLook { } } +/// How a value track (`StyleCx::track`) colours its groove and the part a value fills: a slider's and a range +/// slider's. An app sets it once at its root (`RootEnv::values`); the default is the muted fill. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum TrackFill { + /// `text.muted` on a `line.control_edge` groove. + #[default] + Muted, + /// `accent.solid` on a `line.outline` groove: VectorCraft's. + Accent, +} + /// A value track: a groove with the part a value fills over it, and the marks and ticks along it. A slider, a /// range slider, a thumb row and a progress bar paint the same track. #[derive(Clone, Debug, PartialEq)] diff --git a/crates/ui-contract/src/style/mod.rs b/crates/ui-contract/src/style/mod.rs index 5fff01886..aea145c95 100644 --- a/crates/ui-contract/src/style/mod.rs +++ b/crates/ui-contract/src/style/mod.rs @@ -25,7 +25,7 @@ pub(crate) use cx::control_metrics; pub use cx::{GlyphRole, StyleCx, VariantParts}; pub use key::{EnvKey, Ink, StyleKey}; pub(crate) use look::StyleView; -pub use look::{ComponentStyle, Corners, DataColor, FocusLook, IconLook, StyleColor, SurfaceKind, SurfaceLook, TextLook, TrackLook}; +pub use look::{ComponentStyle, Corners, DataColor, FocusLook, IconLook, StyleColor, SurfaceKind, SurfaceLook, TextLook, TrackFill, TrackLook}; pub use paint::{ AutoScrollMarkLook, HandleLook, MarkerLook, ResetMarkLook, ResizeLineLook, RuleKind, RuleLook, RuleWidth, ScrollBarKind, ScrollBarLook, resize_line_look, diff --git a/crates/ui-widgets/src/value_drag/slider/stories.rs b/crates/ui-widgets/src/value_drag/slider/stories.rs index 26859e8c9..45fa02d1b 100644 --- a/crates/ui-widgets/src/value_drag/slider/stories.rs +++ b/crates/ui-widgets/src/value_drag/slider/stories.rs @@ -5,7 +5,8 @@ use super::{Slider, SliderScale, SliderThumb}; use crate::contract::{Props as _, Show as _, ShowContainer as _, Validity}; use crate::display::Progress; use crate::form::Field; -use crate::runtime::env::Message; +use crate::runtime::env::{Message, with_env}; +use crate::style::TrackFill; use crate::testing::{Drive, Grip, StoryData, StoryOutput, story}; use crate::value_drag::TrackFace; use craft_behavior::Mixed; @@ -91,6 +92,18 @@ fn slider_disabled_3(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { disabled_row(ui, data, "Disabled 3", 100.0) } +/// A slider of an app that sets `TrackFill::Accent` at its root: the filled part in the accent on an outline groove. +#[story(Slider<'static>, covers = [], drive = Drive::Drag(Grip::new(Slider::THUMB)), group = "Values", title = "Accent fill")] +fn slider_accent_fill(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + with_env( + ui, + |overrides| { + overrides.values.set(TrackFill::Accent); + }, + |ui| value_row(ui, data, "Opacity", 60.0), + ) +} + /// With the direction set to right to left the label moves to the right; the slider keeps its geometry. #[story(Slider<'static>, covers = [], drive = Drive::Step, group = "Right to left", title = "Opacity")] fn slider_right_to_left(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { From 68cde01dc51f7f470d2c6b5fc2c3daccc8a31d79 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 19:38:11 +0700 Subject: [PATCH 20/22] ui-widgets choice: ChoiceLook, a root style value; under ChoiceLook::Strong a check box, radio button or switch track that is on fills with accent.strong (pressed accent.strong_pressed, disabled unchanged) under a text.on_strong mark; ChoiceLook::Accent, the default, keeps accent.solid with text.on_accent. Check box and radio stories under Strong --- crates/ui-widgets/src/choice/check/stories.rs | 28 ++++++++++++++-- crates/ui-widgets/src/choice/mod.rs | 33 +++++++++++++++---- crates/ui-widgets/src/choice/radio/stories.rs | 24 +++++++++++++- 3 files changed, 76 insertions(+), 9 deletions(-) diff --git a/crates/ui-widgets/src/choice/check/stories.rs b/crates/ui-widgets/src/choice/check/stories.rs index a9e007ee6..f8a9f0ad7 100644 --- a/crates/ui-widgets/src/choice/check/stories.rs +++ b/crates/ui-widgets/src/choice/check/stories.rs @@ -1,8 +1,10 @@ //! Stories of `Checkbox`. use super::Checkbox; -use crate::contract::{Props as _, Show as _, Validity}; -use crate::runtime::env::Message; +use crate::choice::ChoiceLook; +use crate::contract::{Props as _, Show as _, ShowContainer as _, Validity}; +use crate::layout_components::Stack; +use crate::runtime::env::{Message, with_env}; use crate::testing::{Drive, StoryData, StoryOutput, story}; use craft_behavior::Mixed; use craft_theme::ControlSize; @@ -59,3 +61,25 @@ fn checkbox_disabled_mixed(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { fn checkbox_long_label(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { Checkbox::new(data.bind("checked", true)).label(LONG_LABEL).show(ui).into() } + +/// The check boxes of an app that sets `ChoiceLook::Strong` at its root: a checked or mixed box fills with the strong +/// accent under a white mark; an unchecked box and a disabled one look as they do by default. +#[story(Checkbox<'static>, covers = [], drive = Drive::Never, group = "Looks", title = "Strong")] +fn checkbox_strong(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let mut output = StoryOutput::default(); + with_env( + ui, + |overrides| { + overrides.values.set(ChoiceLook::Strong); + }, + |ui| { + Stack::new().show(ui, |ui, _| { + output = Checkbox::new(data.bind("checked", true)).label("Checked").show(ui).into(); + Checkbox::new(data.bind("unchecked", false)).label("Unchecked").show(ui); + Checkbox::new(data.bind_mixed("mixed", Mixed::Mixed)).label("Mixed").show(ui); + Checkbox::new(data.bind("disabled", true)).label("Disabled (checked)").enabled(false).show(ui); + }) + }, + ); + output +} diff --git a/crates/ui-widgets/src/choice/mod.rs b/crates/ui-widgets/src/choice/mod.rs index 0fd728a56..ab2265181 100644 --- a/crates/ui-widgets/src/choice/mod.rs +++ b/crates/ui-widgets/src/choice/mod.rs @@ -22,6 +22,19 @@ pub use swatch::{ }; pub use swatch_table::{RowMarks, SwatchArrangement, SwatchRows, SwatchSpacing, SwatchTable, SwatchTableOutput, SwatchTableStyle}; +/// How a check box, radio button or switch track that is on fills. An app sets it once at its root +/// (`RootEnv::values`); the default is the accent. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum ChoiceLook { + /// `accent.solid` with a `text.on_accent` mark. + #[default] + Accent, + /// `accent.strong` with a white `text.on_strong` mark: VectorCraft's. + Strong, +} + /// The well of a check box, radio button or switch track with `radius` corners: the sunken surface, so a bevelled theme /// draws its bevel, filled with the off fill or the on accent. A flat theme draws the outline as its edge, in the failure /// colour while the value is invalid. @@ -61,21 +74,29 @@ fn well(cx: &crate::style::StyleCx<'_>) -> craft_theme::Stateful) -> craft_theme::Stateful { use craft_theme::{Stateful, States}; let accent = &cx.tokens.color.accent; - let (solid, pressed, disabled) = (cx.color(accent.solid), cx.color(accent.pressed), cx.color(cx.tokens.color.text.disabled)); + let (solid, pressed) = match cx.env::() { + ChoiceLook::Accent => (accent.solid, accent.pressed), + ChoiceLook::Strong => (accent.strong, accent.strong_pressed), + }; + let (solid, pressed, disabled) = (cx.color(solid), cx.color(pressed), cx.color(cx.tokens.color.text.disabled)); Stateful::new(solid).off(States::new(solid, solid, pressed, disabled)) } -/// The mark on an on-accent fill (check, dash, dot): `text.on_accent`, and the panel while disabled, cut into the -/// disabled box. +/// The mark on the on fill (check, dash, dot): the text colour paired with the [`ChoiceLook`]'s accent, and the panel +/// while disabled, cut into the disabled box. fn mark(cx: &crate::style::StyleCx<'_>) -> craft_theme::Stateful { use craft_theme::{Stateful, States}; let colors = &cx.tokens.color; - let (mark, disabled) = (cx.color(colors.text.on_accent), cx.color(colors.state.disabled_fill)); + let mark = match cx.env::() { + ChoiceLook::Accent => colors.text.on_accent, + ChoiceLook::Strong => colors.text.on_strong, + }; + let (mark, disabled) = (cx.color(mark), cx.color(colors.state.disabled_fill)); Stateful::new(mark).off(States::new(mark, mark, mark, disabled)) } diff --git a/crates/ui-widgets/src/choice/radio/stories.rs b/crates/ui-widgets/src/choice/radio/stories.rs index 1285c7298..b26c5b27a 100644 --- a/crates/ui-widgets/src/choice/radio/stories.rs +++ b/crates/ui-widgets/src/choice/radio/stories.rs @@ -1,10 +1,11 @@ //! Stories of `RadioGroup` and `Radio`. use super::{Radio, RadioGroup}; +use crate::choice::ChoiceLook; use crate::contract::{FieldLayout, Props as _, Show as _, ShowContainer as _, SideLabel, Validity}; use crate::display::{Shade, Text}; use crate::layout_components::{Row, Stack}; -use crate::runtime::env::Message; +use crate::runtime::env::{Message, with_env}; use crate::testing::{Drive, Fixture, StoryData, StoryOutput, story}; use craft_behavior::{IconId, Mixed}; use egui::{Response, Ui}; @@ -153,3 +154,24 @@ fn radio(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { }); selected.map(StoryOutput::from).unwrap_or_default() } + +/// The radio buttons of an app that sets `ChoiceLook::Strong` at its root: the selected one fills with the strong +/// accent under a white dot. Beside it a mixed group, which selects none, and a disabled group. +#[story(RadioGroup<'static, u8>, covers = [], drive = Drive::Never, group = "Looks", title = "Strong")] +fn radio_group_strong(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let mut output = StoryOutput::default(); + with_env( + ui, + |overrides| { + overrides.values.set(ChoiceLook::Strong); + }, + |ui| { + Row::new().show(ui, |ui, _| { + output = column(ui, RadioGroup::new("Size", data.bind("size", 2u8))); + column(ui, RadioGroup::new("Mixed", data.bind_mixed("mixed", Mixed::Mixed))); + column(ui, RadioGroup::new("Disabled", data.bind("disabled", 2u8)).enabled(false)); + }) + }, + ); + output +} From 7cb5edfda4a240fc691109ededc7bceb63320cc3 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 19:38:21 +0700 Subject: [PATCH 21/22] ui-widgets segmented: a picked segment follows ActiveLook; under ActiveLook::Pressed it takes state.pressed with text.normal at rest, under the pointer and pressed, as an icon button that is on does; ActiveLook::Accent, the default, keeps state.selected with text.on_selected. Segmented story under Pressed --- crates/ui-widgets/src/buttons/mod.rs | 5 +++-- crates/ui-widgets/src/choice/segmented.rs | 13 +++++++++---- .../ui-widgets/src/choice/segmented/stories.rs | 16 +++++++++++++++- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/crates/ui-widgets/src/buttons/mod.rs b/crates/ui-widgets/src/buttons/mod.rs index d4c20f66a..7e4234f16 100644 --- a/crates/ui-widgets/src/buttons/mod.rs +++ b/crates/ui-widgets/src/buttons/mod.rs @@ -63,8 +63,9 @@ pub enum ControlPlace { SideMenu, } -/// How an icon button that is on shows it. A tool rail sets it for its buttons (`ToolRail::active_look`), so the -/// current tool can show the look an app's tools had. +/// How an icon button or a segment that is on shows it. A tool rail sets it for its buttons (`ToolRail::active_look`), +/// so the current tool can show the look an app's tools had; an app sets it at its root (`RootEnv::values`) for its +/// segmented pickers as well. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, EnvValue, MemoProps)] #[env(style)] #[non_exhaustive] diff --git a/crates/ui-widgets/src/choice/segmented.rs b/crates/ui-widgets/src/choice/segmented.rs index e9fbd06ec..108db79d1 100644 --- a/crates/ui-widgets/src/choice/segmented.rs +++ b/crates/ui-widgets/src/choice/segmented.rs @@ -2,6 +2,7 @@ //! face that is flat and muted, with a hover fill, and takes the selection fill and edge while it is picked. The row is one Tab stop over its segments: arrows, Home and End move focus between them, Space, //! Enter or a click picks the focused one. +use crate::buttons::ActiveLook; use crate::buttons::face::{self, FaceLook, FaceSpec}; use crate::contract::{ Access, Bind, BindMut, Common, Component, Cx, Edit as _, EditResponse, Entry, MeasureCx, Name, PaintUi, PartsCx, Props as _, Role, SetPosition, @@ -214,8 +215,12 @@ impl Component for Segment { fn style(cx: &StyleCx<'_>, _: SegmentStyleKey) -> SegmentStyle { let colors = &cx.tokens.color; let c = |rgba| cx.color(rgba); - let (clear, selected, selected_hover) = (c(Rgba::TRANSPARENT), c(colors.state.selected), c(colors.state.selected_hover)); - let disabled = c(colors.state.disabled_fill); + // The picked segment wears the look of an icon button that is on (`face::pressed_parts` under `Pressed`). + let (selected, selected_hover, on_ink) = match cx.env::() { + ActiveLook::Accent => (c(colors.state.selected), c(colors.state.selected_hover), c(colors.text.on_selected)), + ActiveLook::Pressed => (c(colors.state.pressed), c(colors.state.pressed), c(colors.text.normal)), + }; + let (clear, disabled) = (c(Rgba::TRANSPARENT), c(colors.state.disabled_fill)); let fill = cx.state_layer().on(States::new(selected, selected_hover, selected_hover, disabled)); let edge = Stateful::new(c(colors.line.control_edge)).off(States::new(clear, clear, clear, clear)).on(States::new( c(colors.line.control_edge), @@ -223,8 +228,8 @@ impl Component for Segment { c(colors.line.control_edge), c(colors.line.divider), )); - let (muted, on_selected, off) = (c(colors.text.muted), c(colors.text.on_selected), c(colors.text.disabled)); - let ink = Stateful::new(muted).off(States::new(muted, muted, muted, off)).on(States::new(on_selected, on_selected, on_selected, off)); + let (muted, off) = (c(colors.text.muted), c(colors.text.disabled)); + let ink = Stateful::new(muted).off(States::new(muted, muted, muted, off)).on(States::new(on_ink, on_ink, on_ink, off)); let control = cx.segment_control(); SegmentStyle { // The selected segment rises: a bevelled theme draws the raised bevel, a flat one the edge alone. diff --git a/crates/ui-widgets/src/choice/segmented/stories.rs b/crates/ui-widgets/src/choice/segmented/stories.rs index 02a3e3d30..52754e83c 100644 --- a/crates/ui-widgets/src/choice/segmented/stories.rs +++ b/crates/ui-widgets/src/choice/segmented/stories.rs @@ -1,8 +1,9 @@ //! Stories of `Segmented`. use super::Segmented; +use crate::buttons::ActiveLook; use crate::contract::{Entry, Props as _, Show as _, Validity}; -use crate::runtime::env::Message; +use crate::runtime::env::{Message, with_env}; use crate::testing::{Drive, Fixture, StoryData, StoryOutput, story}; use craft_behavior::{IconId, Mixed}; use craft_theme::ControlSize; @@ -89,3 +90,16 @@ fn segmented_icons(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { fn segmented_icons_five(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { icon_row(ui, data, 5, 2) } + +/// The row of an app that sets `ActiveLook::Pressed` at its root: the picked segment takes the pressed +/// fill with the normal text colour, as an icon button that is on does, at rest, under the pointer and pressed. +#[story(Segmented<'static, u8>, covers = [], drive = Drive::Custom(pick_add), group = "Text", title = "Pressed look")] +fn segmented_pressed_look(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + with_env( + ui, + |overrides| { + overrides.values.set(ActiveLook::Pressed); + }, + |ui| text_row(ui, data, 3, 0, ControlSize::Md), + ) +} From 34e96f9325bafa4e7c7d0fe3774c177e1d90712d Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 19:38:28 +0700 Subject: [PATCH 22/22] ui-panels footer: DialogButtonLook::Filled shows Cancel, Other, Alternate and Alternative as the filled neutral button (buttons::FILLED, now public: surface.control with no edge, state.hover under the pointer) beside the accented answer. Footer story and trial under Filled --- crates/ui-panels/src/sections/footer.rs | 12 +++++++--- .../ui-panels/src/sections/footer/stories.rs | 22 ++++++++++++++++++- crates/ui-panels/tests/it/dialogs.rs | 11 ++++++++++ crates/ui-widgets/src/buttons/mod.rs | 5 +++-- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/crates/ui-panels/src/sections/footer.rs b/crates/ui-panels/src/sections/footer.rs index 581ee146e..40427888a 100644 --- a/crates/ui-panels/src/sections/footer.rs +++ b/crates/ui-panels/src/sections/footer.rs @@ -392,6 +392,9 @@ pub enum DialogButtonLook { /// PdfCraft's: Cancel and an Alternate answer (Don't Save, No) are plain text (the ghost look) beside the accented /// accepting button, as production's prompts show them. Quiet, + /// VectorCraft's: every button but the accepting and the destructive one is a filled neutral tile with no edge + /// (`buttons::FILLED`). + Filled, } /// What a dialog button means; it decides the button's look and its place in the row. @@ -719,7 +722,7 @@ impl FooterBar { let armed_for = Env::of(&*ui).get::().0; let default_at = buttons.iter().position(|button| button.role == DialogRole::Accept && button.live(armed_for)); let least = if column { LeastWidth::DialogSideButton } else { LeastWidth::DialogButton }; - let quiet = Env::of(ui).get::() == DialogButtonLook::Quiet; + let look = Env::of(ui).get::(); let place = |ui: &mut Ui, shown: &mut Shown| { for at in display_order(&roles, os == Os::Windows, column) { let button = &buttons[at]; @@ -727,8 +730,11 @@ impl FooterBar { DialogRole::Accept => Variant::PRIMARY, DialogRole::Destructive => Variant::DANGER, // Production shows Cancel and Don't Save as plain text beside the accented answer. - DialogRole::Cancel | DialogRole::Alternate if quiet => Variant::GHOST, - DialogRole::Cancel | DialogRole::Other | DialogRole::Alternate | DialogRole::Alternative => Variant::SECONDARY, + DialogRole::Cancel | DialogRole::Alternate if look == DialogButtonLook::Quiet => Variant::GHOST, + DialogRole::Cancel | DialogRole::Other | DialogRole::Alternate | DialogRole::Alternative => match look { + DialogButtonLook::Filled => crate::buttons::FILLED, + DialogButtonLook::Standard | DialogButtonLook::Quiet => Variant::SECONDARY, + }, }; let live = button.live(armed_for); let mut widget = Button::new(button.label.clone()).variant(variant).enabled(live).least_width(least); diff --git a/crates/ui-panels/src/sections/footer/stories.rs b/crates/ui-panels/src/sections/footer/stories.rs index 5801a5ec4..8f82fd707 100644 --- a/crates/ui-panels/src/sections/footer/stories.rs +++ b/crates/ui-panels/src/sections/footer/stories.rs @@ -1,8 +1,9 @@ //! Stories of the footer actions. -use super::{DropAction, FooterAction, FooterBar}; +use super::{DialogButtonLook, DialogRole, DropAction, FooterAction, FooterBar, FooterButton}; use crate::buttons::IconButton; use crate::contract::{PopupKind, Props as _, Show as _, ShowContainer as _}; +use crate::runtime::env::with_env; use crate::story_kit::sample::words; use crate::testing::{Drive, StoryData, StoryOutput, story}; use craft_behavior::IconId; @@ -24,6 +25,25 @@ fn footer_actions(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { FooterBar::actions(actions).show_footer(ui).into() } +/// The dialog buttons of an app that sets `DialogButtonLook::Filled` at its root: Cancel, the Alternate answer and +/// another outcome are filled neutral tiles with no edge beside the accented OK, at rest, under the pointer and pressed. +#[story(FooterBar, covers = [], drive = Drive::Never, title = "Filled dialog buttons")] +fn footer_filled_buttons(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + let buttons = [ + FooterButton::new("Reset", DialogRole::Other), + FooterButton::new("Don't Save", DialogRole::Alternate), + FooterButton::new("Cancel", DialogRole::Cancel), + FooterButton::new("OK", DialogRole::Accept), + ]; + with_env( + ui, + |overrides| { + overrides.values.set(DialogButtonLook::Filled); + }, + |ui| FooterBar::buttons(buttons).show_footer(ui).into(), + ) +} + #[story(DropAction, covers = [Default], drive = Drive::Never)] fn drop_action(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { DropAction::new(|_: &u8| true) diff --git a/crates/ui-panels/tests/it/dialogs.rs b/crates/ui-panels/tests/it/dialogs.rs index 5f5d416f8..2d4b3c919 100644 --- a/crates/ui-panels/tests/it/dialogs.rs +++ b/crates/ui-panels/tests/it/dialogs.rs @@ -738,6 +738,17 @@ fn a_footer_cancel_is_a_ghost_button_beside_the_accent_answer() { assert!(!seen.contains(&Variant::SECONDARY), "no outlined button in the footer: {seen:?}"); } +/// VectorCraft's dialogs (`DialogButtonLook::Filled`) show Cancel and Don't Save as filled neutral tiles beside the +/// accented answer, not as outlines. +#[trial] +fn a_footer_cancel_is_a_filled_button_beside_the_accent_answer() { + use craft_theme::Variant; + let seen = footer_variants(Some(craft_ui::sections::DialogButtonLook::Filled)); + assert!(seen.contains(&craft_ui::buttons::FILLED), "Cancel is a filled button: {seen:?}"); + assert!(seen.contains(&Variant::PRIMARY), "Save is the accented button: {seen:?}"); + assert!(!seen.contains(&Variant::SECONDARY), "no outlined button in the footer: {seen:?}"); +} + /// The left edges of a Save anyway / Save as… / Cancel prompt's buttons on Linux, with the Alternate's role set to /// `role` when it names one. fn alternate_edges(role: Option) -> (f32, f32, f32) { diff --git a/crates/ui-widgets/src/buttons/mod.rs b/crates/ui-widgets/src/buttons/mod.rs index 7e4234f16..946b5939d 100644 --- a/crates/ui-widgets/src/buttons/mod.rs +++ b/crates/ui-widgets/src/buttons/mod.rs @@ -91,8 +91,9 @@ pub enum PushButtonLook { Filled, } -/// The filled neutral variant a push button takes under [`PushButtonLook::Filled`]. -pub(crate) const FILLED: craft_theme::Variant = craft_theme::Variant::look(craft_theme::Emphasis::Filled, craft_theme::variant::Tone::Neutral); +/// The filled neutral variant a push button takes under [`PushButtonLook::Filled`]: `surface.control` with no edge at +/// rest. +pub const FILLED: craft_theme::Variant = craft_theme::Variant::look(craft_theme::Emphasis::Filled, craft_theme::variant::Tone::Neutral); /// The variant a push or split button that asks for none takes in `env` (`Component::default_variant`): the filled one /// under [`PushButtonLook::Filled`], outside a ribbon.