From 5d094e34adf3b6c2f7a0322d9ba5094d1e51ccca Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:02:08 +0700 Subject: [PATCH 01/76] ui-widgets: declare the Arabic test font read from ui-contract --- crates/ui-widgets/Cargo.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ui-widgets/Cargo.toml b/crates/ui-widgets/Cargo.toml index 63d0e4bdf..3b84b7f38 100644 --- a/crates/ui-widgets/Cargo.toml +++ b/crates/ui-widgets/Cargo.toml @@ -14,6 +14,13 @@ test = false [lints] workspace = true +# Files of other crates that this crate's build or tests read. CI selects this crate's tests +# when one of them changes (craft-common-actions' select-platforms). +[package.metadata.craft] +reads = [ + "crates/ui-contract/tests/fonts/NotoSansArabic-test.ttf", +] + [features] suite = ["testing", "craft-ui-contract/suite"] default = [] From 1b7222027268956fc09f045b245399a343f7f450 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:07:49 +0700 Subject: [PATCH 02/76] behavior: a grid's least probe keeps its Fill columns Fill, unbounded, so a field that fills its width there measures its own width instead of none; the fill column's least is then the field's, so a grid beside a menu no longer squeezes the field under it, stacks its label in rows measured unstacked, and overlaps the next row --- crates/behavior/src/grid.rs | 9 ++- .../ui-widgets/tests/it/layout/grid_labels.rs | 74 ++++++++++++++----- 2 files changed, 60 insertions(+), 23 deletions(-) diff --git a/crates/behavior/src/grid.rs b/crates/behavior/src/grid.rs index b9c1e5bfd..bd782a0e9 100644 --- a/crates/behavior/src/grid.rs +++ b/crates/behavior/src/grid.rs @@ -119,10 +119,11 @@ impl GridCursor { cursor } - /// A cursor for the sweep that asks each column for its least: every column but a `Fixed` one is placed as a - /// `Content` column whose cells measure in no bound along x, so each column measures its widest cell. + /// A cursor for the sweep that asks each column for its least: the cells of every `Content` and `Fill` column + /// measure in no bound along x, so each column measures its widest cell. A `Fill` column stays one, so a child + /// that fills its width measures its own width there, where a `Content` column would hold it and take none. pub fn unbounded(flow: Flow, columns: &[ColumnWidth], gap: Vec2) -> Self { - let mut cursor = Self::new(flow, &as_content(columns), gap, &GridMeasure::default()); + let mut cursor = Self::new(flow, columns, gap, &GridMeasure::default()); cursor.unbounded = true; cursor } @@ -185,7 +186,7 @@ impl GridCursor { let count = self.columns.len().max(1); let (column, _, _, top) = self.next_place(); let width = match self.columns.get(column) { - Some(ColumnWidth::Content) if self.unbounded => f32::INFINITY, + Some(ColumnWidth::Content | ColumnWidth::Fill { .. }) if self.unbounded => f32::INFINITY, Some(ColumnWidth::Content) => { // Every other column keeps at least its least: a column that fills keeps only that, and so does a // content column when each column measures alone. diff --git a/crates/ui-widgets/tests/it/layout/grid_labels.rs b/crates/ui-widgets/tests/it/layout/grid_labels.rs index 1e1c1712d..a854e1a87 100644 --- a/crates/ui-widgets/tests/it/layout/grid_labels.rs +++ b/crates/ui-widgets/tests/it/layout/grid_labels.rs @@ -1,12 +1,14 @@ //! The glyph labels beside the fields of one grid column share a width. use craft_behavior::ColumnWidth; -use craft_ui::contract::{Bind, GlyphLabel, LabelKind, Show as _, ShowContainer as _, SideLabel}; +use craft_ui::contract::{Bind, Entry, GlyphLabel, LabelKind, Show as _, ShowContainer as _, SideLabel}; +use craft_ui::display::Text; use craft_ui::form::Field; -use craft_ui::layout_components::Grid; +use craft_ui::layout_components::{Grid, Stack}; +use craft_ui::pickers::Select; use craft_ui::testing::{Fixture, trial}; use craft_ui::text::NumberField; -use egui::Rect; +use egui::{Rect, Ui}; use std::cell::RefCell; use std::rc::Rc; @@ -44,30 +46,64 @@ fn the_fields_of_a_grid_column_share_a_left_edge() { /// A filling column, then one sized by its cells. static FILL_FIRST: [ColumnWidth; 2] = [ColumnWidth::fill(1.0), ColumnWidth::Content]; -/// A grid row is as tall as a field in it whose label stacks above its control for want of room: the next row's label -/// starts below the control. Guards against a grid that spaced its rows as if the label sat beside the control, so the -/// next row's label overlapped it. -#[trial] -fn a_grid_row_holds_a_field_whose_label_stacks() { +/// The rects of the two fields of a grid whose rows each hold a labelled field and, in the column sized by its cells, +/// text or a menu, in a room `width` wide; and the second field's label. `in_container`: the grid shows under a header +/// in a container that fills its width, beside menus, as a fixed section shows it. +fn grid_rows(in_container: bool, width: f32) -> ([Rect; 2], Rect) { let rects: Rc>> = Rc::default(); let seen = rects.clone(); let mut fixture = Fixture::new(move |ui| { let mut seen = seen.borrow_mut(); seen.clear(); - Grid::new(&FILL_FIRST).show(ui, |ui, _| { - for i in 0..2 { - Field::new(format!("Top Left Corner {i}")).show(ui, |ui, _| { - seen.push(NumberField::new(format!("Radius {i}"), Bind::given(Some(10.0))).show(ui).response.rect); - }); - craft_ui::display::Text::new("Round").show(ui); - } - }); + let entries = [Entry::new(0u8, "Round"), Entry::new(1, "Inverted Round"), Entry::new(2, "Chamfer")]; + let mut grid = |ui: &mut Ui| { + Grid::new(&FILL_FIRST).show(ui, |ui, _| { + for i in 0..2 { + Field::new(format!("Top Left Corner {i}")).show(ui, |ui, _| { + seen.push(NumberField::new(format!("Radius {i}"), Bind::given(Some(10.0))).show(ui).response.rect); + }); + if in_container { + Select::new(format!("Corner {i}"), Bind::given(0u8), &entries).show(ui); + } else { + Text::new("Round").show(ui); + } + } + }); + }; + if in_container { + Stack::new() + .fill_width() + .header(|ui, _| { + Text::new("Rectangle").show(ui); + }) + .show(ui, |ui, _| grid(ui)); + } else { + grid(ui); + } }); - fixture.room(egui::vec2(150.0, 400.0)).record_paint(); + fixture.room(egui::vec2(width, 400.0)).record_paint(); fixture.settle(); let rects = rects.borrow(); - let [first, _] = rects[..] else { panic!("two fields show: {rects:?}") }; + let [first, second] = rects[..] else { panic!("two fields show: {rects:?}") }; let label = fixture.texts().iter().find(|text| text.text == "Top Left Corner 1").map(|text| text.rect).expect("the second label shows"); - assert!(label.bottom() <= rects[1].top() + 0.5, "the label stacks above its control: {label:?}, {:?}", rects[1]); + ([first, second], label) +} + +/// A grid row is as tall as a field in it whose label sits beside its control or stacks above it for want of room: +/// the next row's label starts below the control, and the label shows whole. The grid stands alone beside text, and +/// fills a container's width beside menus at several widths. Guards against a grid that spaced its rows as if the +/// label sat beside the control and then placed it stacked, so the next row's label overlapped it; and against one +/// that took the least of a column of filling fields as none, so the field was left a sliver beside the menu. +#[trial] +fn a_grid_row_holds_a_field_whose_label_stacks() { + let (_, whole) = grid_rows(false, 600.0); + let ([first, second], label) = grid_rows(false, 150.0); + assert!(label.bottom() <= second.top() + 0.5, "the label stacks above its control: {label:?}, {second:?}"); assert!(label.top() >= first.bottom() - 0.5, "the second row starts below the first row's control: {label:?}, {first:?}"); + for width in [200.0, 240.0, 320.0] { + let ([first, second], label) = grid_rows(true, width); + assert!(label.top() >= first.bottom() - 0.5, "at {width}, the second row starts below the first row's control: {label:?}, {first:?}"); + assert!(second.top() >= first.bottom() - 0.5, "at {width}, the second field starts below the first: {second:?}, {first:?}"); + assert!(label.width() >= whole.width() - 0.5, "at {width}, the label shows whole: {label:?}, {whole:?}"); + } } From c41413e8b5f17ca186a87b1047b4ec488006e769 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:08:04 +0700 Subject: [PATCH 03/76] platform: name the page save callback type; web-host: implement Files::pending_pick --- crates/platform/src/browser_files.rs | 7 +++++-- crates/web-host/src/files.rs | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/platform/src/browser_files.rs b/crates/platform/src/browser_files.rs index a00309b25..3d18b37ca 100644 --- a/crates/platform/src/browser_files.rs +++ b/crates/platform/src/browser_files.rs @@ -38,7 +38,10 @@ pub struct BrowserFiles { /// An embedding page's save ([`BrowserFiles::page_saves`]): given the file name, the bytes and whether the user asked /// for Save As, `None` when no page hosts the app, else the page's answer. -pub type PageSave = Arc Option> + Send + Sync>; +pub type PageSave = Arc; + +/// The callback behind a [`PageSave`]. +pub type PageSaveFn = dyn Fn(&str, &[u8], bool) -> Option> + Send + Sync; /// Tickets of one service, shared with the tasks that answer them. #[derive(Default)] @@ -178,7 +181,7 @@ fn write_name(path: &Path) -> String { /// A write's route: the embedding page when `page` answers (`Ok(true)`), else `download` (`Ok(false)`). pub(crate) fn page_or_download( - page: Option<&(dyn Fn(&str, &[u8], bool) -> Option> + Send + Sync)>, + page: Option<&PageSaveFn>, name: &str, bytes: &[u8], save_as: bool, diff --git a/crates/web-host/src/files.rs b/crates/web-host/src/files.rs index bc9bcf5cc..dcd15a883 100644 --- a/crates/web-host/src/files.rs +++ b/crates/web-host/src/files.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; -use craft_host::{FileError, Files, PickId, PickRequest, Picked, Wake, WriteIntent}; +use craft_host::{FileError, Files, PendingPick, PickId, PickRequest, Picked, Wake, WriteIntent}; use craft_platform::browser_files::{BrowserFiles as PlatformFiles, PickLimits}; /// The hosting page's save, for [`PlatformFiles::page_saves`]: posts `bytes` to the page `Host::connect` connected @@ -46,8 +46,8 @@ impl Files for BrowserFiles { self.inner.forget(id); } - fn pick_pending(&self) -> bool { - self.inner.pick_pending() + fn pending_pick(&self) -> Option { + self.inner.pending_pick() } fn read(&self, path: &Path) -> Result, FileError> { From 969bfa99fabed92148b55ad58981717df5cbf8cc Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:11:54 +0700 Subject: [PATCH 04/76] ui-patterns: a document dialog's fixed section puts its rows on a card again and heads them with its name, which the merge of next dropped from the section rewrite --- crates/ui-patterns/src/patterns/form_dialogs/rows.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs index 9ff040e87..4b4b03b86 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs @@ -13,7 +13,7 @@ use super::words::ParamWords; use crate::buttons::{Button, IconButton, ToggleButton}; use crate::choice::{Checkbox, Radio, RadioGroup, Swatch}; use crate::contract::{ - Bind, BodyCx, CanvasGesture, CaptionColumn, Entry, FieldLayout, LabelScheme, NoValue, Outcome, Props as _, Remember as _, Sampler as _, + Bind, BodyCx, CanvasGesture, CaptionColumn, Entry, FieldLayout, LabelScheme, NoValue, Outcome, Pad, Props as _, Remember as _, Sampler as _, Show as _, ShowContainer as _, SideLabel, Sizing, TooltipSpec, clicked, }; use crate::display::Text; @@ -26,6 +26,7 @@ use crate::pickers::{Select, UnitSelect}; use crate::runtime::env::{Env, Label, UnitKind, Units, with_env}; use crate::sections::{HeaderStrength, Section}; +use crate::style::SurfaceKind; use crate::text::{NumberField, RangeAlert, SelectableText, TextField, UnitPlacement}; use crate::value_drag::{AngleDial, PointPicker, SliderScale}; @@ -706,7 +707,14 @@ impl<'p> Pass<'p> { /// One section: its head, then its rows. fn section(&mut self, ui: &mut Ui, head: &Param, body: &[Param]) { let title = plain(&head.label); + let outer = self.heading.replace(title.as_str().to_owned()); match head.option().head() { + // A document dialog's option group: a caption over its rows on a card. + Head::Fixed if self.shaded => { + Section::fixed(title).id_salt(head.key.as_str()).strength(HeaderStrength::Caption).show(ui, |ui, _| { + Stack::new().fill_width().surface(SurfaceKind::Raised).pad(Pad::Control).show(ui, |ui, _| self.body(ui, body)); + }); + } Head::Fixed => { Section::fixed(title).id_salt(head.key.as_str()).show(ui, |ui, _| self.body(ui, body)); } @@ -724,6 +732,7 @@ impl<'p> Pass<'p> { }); } } + self.heading = outer; } /// `param` as the pass shows it, `compact` in a pair. From daed17160c85a78c958177e3293a01590054d175 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:11:59 +0700 Subject: [PATCH 05/76] ui-patterns: a hosted dialog's automation set takes the host's row labels and shown states, every tab's rows and the read-only refusal again, and reports the rows it changed, which the merge of next dropped from the batched set --- .../src/patterns/form_dialogs/dialog.rs | 19 ++++++++++++------- .../patterns/form_dialogs/host_requests.rs | 11 ++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs index cbc7b8c4f..b95aee9bb 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs @@ -2000,12 +2000,21 @@ impl StackDialog for HostedParamDialog { self.requests.answer_color(key, color); } - /// Sets the fields on a clone of the values and commits the clone only when every field is accepted. + /// Sets the fields on a clone of the values and commits the clone only when every field is accepted. The rows are + /// those the user sees: the host's labels and shown states over every tab's rows; a read-only dialog refuses all. fn set_json_fields(&mut self, _: &Context, fields: &[(String, Value)]) -> Result<(), String> { - let params = (self.build)(&mut self.fields).params.into_owned(); + let (params, read_only) = { + let mut dialog = (self.build)(&mut self.fields); + self.rows.apply(&mut dialog); + let ParamDialog { params, tabs, read_only, .. } = dialog; + (every_param(params, &tabs).into_owned(), read_only) + }; let mut staged = self.fields.clone(); let mut preview = self.preview_on; for (field, value) in fields { + if read_only { + return Err(FieldRefusal::Inactive.message(field)); + } match (field.as_str(), &self.presets) { ("preview", _) if self.previews => { preview = value.as_bool().ok_or_else(|| FieldRefusal::Rejects(value).message(field))?; @@ -2018,11 +2027,7 @@ impl StackDialog for HostedParamDialog { _ => set_param_field(¶ms, &mut staged, field, value.clone())?, } } - for param in params.iter().filter(|param| matches!(param.kind, ParamKind::Files { .. })) { - if let Some(request) = param.listing_after(&self.fields, &staged) { - self.requests.request_listing(request); - } - } + self.requests.request_set(¶ms, &self.fields, &staged); self.fields = staged; self.preview_on = preview; Ok(()) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/host_requests.rs b/crates/ui-patterns/src/patterns/form_dialogs/host_requests.rs index ce5933cfe..af852f73f 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/host_requests.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/host_requests.rs @@ -223,13 +223,18 @@ impl HostRequests { pub fn set_field(&mut self, params: &[Param], fields: &mut DialogFields, field: &str, value: Value) -> Result<(), String> { let before = fields.clone(); super::set_param_field(params, fields, field, value)?; + self.request_set(params, &before, fields); + Ok(()) + } + + /// Files what a set through automation of the rows `params` from `before` to `after` files ([`set_field`](Self::set_field)). + pub fn request_set(&mut self, params: &[Param], before: &DialogFields, after: &DialogFields) { for param in params.iter().filter(|param| matches!(param.kind, ParamKind::Files { .. })) { - if let Some(request) = param.listing_after(&before, fields) { + if let Some(request) = param.listing_after(before, after) { self.request_listing(request); } } - self.request_edited(edited_rows(params, &before, fields)); - Ok(()) + self.request_edited(edited_rows(params, before, after)); } /// The row keys an edit changed since the last take. From 7002b2ec8f48048ae0a3e55fe6eaeb60a4e3398c Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:23:57 +0700 Subject: [PATCH 06/76] ui-contract: drag::register takes a target's reach as one TargetReach; collections report an item's output through one helper --- crates/ui-contract/src/contract/cx/pointer.rs | 3 +- .../ui-contract/src/contract/items/hooks.rs | 14 +----- .../ui-contract/src/contract/items/members.rs | 13 +----- .../ui-contract/src/contract/items/press.rs | 18 +++++++- crates/ui-contract/src/runtime/drag.rs | 46 ++++++++----------- 5 files changed, 42 insertions(+), 52 deletions(-) diff --git a/crates/ui-contract/src/contract/cx/pointer.rs b/crates/ui-contract/src/contract/cx/pointer.rs index f7dc0b3cc..9f31c1299 100644 --- a/crates/ui-contract/src/contract/cx/pointer.rs +++ b/crates/ui-contract/src/contract/cx/pointer.rs @@ -197,7 +197,8 @@ impl Pointer for CxCore<'_> { let op = drag::current_operation(&self.ctx, craft_behavior::CopyKeys::Alt); let drop = target.accept(&payload, op)?; let ordinal = drag::next_ordinal(&self.ctx, self.id); - drag::register(&self.ctx, self.id, self.response.layer_id, target.mark(&drop), op, self.env.shared_tokens(), true, target.under_modal()); + let reach = drag::TargetReach { window: true, under_modal: target.under_modal() }; + drag::register(&self.ctx, self.id, self.response.layer_id, target.mark(&drop), op, self.env.shared_tokens(), reach); drag::take_drop(&self.ctx, self.id, ordinal, op, TypeId::of::

()).then_some(drop) } diff --git a/crates/ui-contract/src/contract/items/hooks.rs b/crates/ui-contract/src/contract/items/hooks.rs index 7039260b8..f25092d50 100644 --- a/crates/ui-contract/src/contract/items/hooks.rs +++ b/crates/ui-contract/src/contract/items/hooks.rs @@ -8,8 +8,7 @@ use super::{Held, ITEM_NODE, ItemsHooks, LastLayout, Lead, Placement, Renaming, use super::{request, rows}; use crate::contract::ValueOf; use crate::contract::collection::{ - CollectionEvent, CollectionProps, ColumnLayout, ContextMenuRequest, DropAt, Gestures, HoverLead, ItemsOut, OpenChange, PendingDrop, Rename, - RowState, ShownRow, + CollectionEvent, CollectionProps, ColumnLayout, DropAt, Gestures, HoverLead, ItemsOut, PendingDrop, Rename, RowState, ShownRow, }; use crate::contract::cx::{BodyCx, CxCore, Pointer as _}; use crate::contract::run::{Measuring, ShapeHooks, ShowAt}; @@ -644,16 +643,7 @@ impl ShapeHooks for ItemsHooks<'_, '_, C> { if let Some(row) = shown_rows.last_mut() { row.openers = self.item_openers(&row_ui, &ctx, id, cx.core.resolved.enabled, openers); } - if let Some(ask) = out.open_request() { - self.events.push(CollectionEvent::Open(OpenChange { key: key.clone(), open: ask.open, all: ask.all })); - } - if let Some(rect) = out.menu_request() { - crate::runtime::keys::request_context(&ctx, id, rect, None); - self.ask_menu(ContextMenuRequest { key: key.clone(), at: self.on_screen(rect.left_bottom()), column: None, part: None }); - } - if let Some(event) = out.into_event() { - self.events.push(CollectionEvent::Item(key.clone(), event)); - } + self.report_item_output(&ctx, id, &key, out); if state.renaming { self.rename_row(comp, &mut row_ui, (&ctx, id, rtl), (at, &key), label); } diff --git a/crates/ui-contract/src/contract/items/members.rs b/crates/ui-contract/src/contract/items/members.rs index 72b61d910..405d60dcc 100644 --- a/crates/ui-contract/src/contract/items/members.rs +++ b/crates/ui-contract/src/contract/items/members.rs @@ -2,7 +2,7 @@ //! arena, updated, painted and finished at their rows, reported as sub-nodes of the collection. use super::{ITEM_NODE, ItemsHooks, key_hash}; -use crate::contract::collection::{CollectionEvent, ContextMenuRequest, OpenChange, ShownRow}; +use crate::contract::collection::ShownRow; use crate::contract::run; use crate::contract::{Collection, Component as _, Cx, Internal, ItemOpener, ItemOutput as _, Meta as _}; use crate::primitives::sensing::{self, MemberSpec}; @@ -87,16 +87,7 @@ impl<'r, C: Collection> ItemsHooks<'_, 'r, C> { shown.openers = self.item_openers(ui, ctx, id, enabled, openers); } let label = output.label_rect().unwrap_or(row); - if let Some(ask) = output.open_request() { - self.events.push(CollectionEvent::Open(OpenChange { key: key.clone(), open: ask.open, all: ask.all })); - } - if let Some(rect) = output.menu_request() { - crate::runtime::keys::request_context(ctx, id, rect, None); - self.ask_menu(ContextMenuRequest { key: key.clone(), at: self.on_screen(rect.left_bottom()), column: None, part: None }); - } - if let Some(event) = output.into_event() { - self.events.push(CollectionEvent::Item(key.clone(), event)); - } + self.report_item_output(ctx, id, &key, output); if renaming { self.rename_row(comp, ui, (ctx, id, rtl), (at, &key), label); } diff --git a/crates/ui-contract/src/contract/items/press.rs b/crates/ui-contract/src/contract/items/press.rs index df7c59977..cf6819543 100644 --- a/crates/ui-contract/src/contract/items/press.rs +++ b/crates/ui-contract/src/contract/items/press.rs @@ -3,8 +3,8 @@ use super::drag::SlowClick; use super::lead::PickBy; use super::{ItemsHooks, Placement, RowPress, SECTION}; -use crate::contract::collection::{ActivateOn, CollectionEvent, CollectionProps, ContextMenuRequest, LeadSource, RowPressed, SelectMode}; -use crate::contract::{Collection, Cx, ItemOpener}; +use crate::contract::collection::{ActivateOn, CollectionEvent, CollectionProps, ContextMenuRequest, LeadSource, OpenChange, RowPressed, SelectMode}; +use crate::contract::{Collection, Cx, ItemOpener, ItemOutput}; use crate::runtime::egui::response; use crate::runtime::env::ArenaId; use crate::runtime::focus; @@ -380,6 +380,20 @@ impl ItemsHooks<'_, '_, C> { self.events.push(CollectionEvent::ContextMenu(request)); } + /// Reports what the shown item `key` asked for: opening or closing its children, its menu, and its event. + pub(super) fn report_item_output(&mut self, ctx: &Context, id: Id, key: &C::Key, output: impl ItemOutput) { + if let Some(ask) = output.open_request() { + self.events.push(CollectionEvent::Open(OpenChange { key: key.clone(), open: ask.open, all: ask.all })); + } + if let Some(rect) = output.menu_request() { + crate::runtime::keys::request_context(ctx, id, rect, None); + self.ask_menu(ContextMenuRequest { key: key.clone(), at: self.on_screen(rect.left_bottom()), column: None, part: None }); + } + if let Some(event) = output.into_event() { + self.events.push(CollectionEvent::Item(key.clone(), event)); + } + } + /// The response of each part an item asked to open a menu from (`ItemCx::part_opener`). pub(super) fn item_openers(&self, ui: &Ui, ctx: &Context, id: Id, enabled: bool, openers: Vec) -> Vec<(ItemOpener, egui::Response)> { item_openers(ui, ctx, id, enabled, openers) diff --git a/crates/ui-contract/src/runtime/drag.rs b/crates/ui-contract/src/runtime/drag.rs index 423bc707e..bfe015694 100644 --- a/crates/ui-contract/src/runtime/drag.rs +++ b/crates/ui-contract/src/runtime/drag.rs @@ -74,7 +74,7 @@ pub enum DropMark { }, } -crate::stays!(Arc, DropOperation); +crate::stays!(Arc, DropOperation, TargetReach); impl crate::runtime::Shift for DropMark { fn shifted(&self, by: &egui::RecordShift) -> Self { @@ -301,10 +301,16 @@ struct Registration { op: DropOperation, /// The tokens of the target's region. tokens: Arc, + reach: TargetReach, +} + +/// Where a drop target takes drops beyond its own mark. +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct TargetReach { /// The target covers the whole window: any target over a component beats it. - window: bool, + pub(crate) window: bool, /// The target takes OS files under a modal layer (`DropTarget::under_modal`). - under_modal: bool, + pub(crate) under_modal: bool, } /// A viewport's registrations: this pass's, and the target that won last pass. @@ -635,24 +641,12 @@ pub(crate) fn show_mark(ctx: &Context, mark: Option) { } /// Records that `owner`'s `ordinal`th target on `layer` accepts at the pointer a drop doing `op`, with its mark in -/// layer space and the tokens of the target's region. A `window` target covers the whole window; an `under_modal` one -/// takes OS files under a modal layer. -pub(crate) fn register( - ctx: &Context, - owner: Id, - layer: Layer, - mark: DropMark, - op: DropOperation, - tokens: Arc, - window: bool, - under_modal: bool, -) { +/// layer space, the tokens of the target's region and its `reach`. +pub(crate) fn register(ctx: &Context, owner: Id, layer: Layer, mark: DropMark, op: DropOperation, tokens: Arc, reach: TargetReach) { crate::runtime::replay::journal( ctx, - || (owner, layer, mark, op, tokens.clone(), (window, under_modal)), - |ctx, (owner, layer, mark, op, tokens, (window, under_modal))| { - register(ctx, *owner, *layer, *mark, *op, tokens.clone(), *window, *under_modal) - }, + || (owner, layer, mark, op, tokens.clone(), reach), + |ctx, (owner, layer, mark, op, tokens, reach)| register(ctx, *owner, *layer, *mark, *op, tokens.clone(), *reach), ); let mark = match areas::layer_map(ctx, layer) { Some(map) => mark.mapped(|point| map.to_screen(point)), @@ -661,7 +655,7 @@ pub(crate) fn register( let scope = overlay::drawing_parent(ctx); PerViewport::::with(ctx, pass::current_viewport(ctx), |targets| { let ordinal = targets.this.iter().filter(|registration| registration.owner == owner).count() as u32; - targets.this.push(Registration { owner, ordinal, layer, scope, mark, op, tokens, window, under_modal }); + targets.this.push(Registration { owner, ordinal, layer, scope, mark, op, tokens, reach }); }); } @@ -747,7 +741,7 @@ pub(crate) fn target_of>( let op = current_operation(ctx, target.copy_keys()); let drop = target.accept(&*payload, at, op)?; let ordinal = next_ordinal(ctx, owner); - register(ctx, owner, zone.layer, target.mark(&drop), op, tokens, false, target.under_modal()); + register(ctx, owner, zone.layer, target.mark(&drop), op, tokens, TargetReach { window: false, under_modal: target.under_modal() }); take_drop(ctx, owner, ordinal, op, payload_type).then_some(drop) } @@ -811,7 +805,7 @@ pub(crate) fn end_pass(ctx: &Context) { // that takes them there. let os = carries_os_files(ctx); let scopes: Vec<(Option, bool)> = PerViewport::::with(ctx, viewport, |targets| { - targets.this.iter().map(|registration| (registration.scope, os && registration.under_modal)).collect() + targets.this.iter().map(|registration| (registration.scope, os && registration.reach.under_modal)).collect() }); let open: Vec = scopes.iter().map(|(scope, through)| *through || overlay::key_layer(ctx, scope.as_slice(), None) != LayerKeys::Blocked).collect(); @@ -823,10 +817,10 @@ pub(crate) fn end_pass(ctx: &Context) { .iter() .enumerate() .filter(|(at, _)| open[*at]) - .max_by_key(|(at, registration)| (!registration.window, areas::layer_position(ctx, registration.layer), *at)) + .max_by_key(|(at, registration)| (!registration.reach.window, areas::layer_position(ctx, registration.layer), *at)) .map(|(_, registration)| registration); - targets.component = best.is_some_and(|registration| !registration.window); - targets.winner_window = best.is_some_and(|registration| registration.window); + targets.component = best.is_some_and(|registration| !registration.reach.window); + targets.winner_window = best.is_some_and(|registration| registration.reach.window); targets.pointer = position; let best = best.map(|registration| ((registration.owner, registration.ordinal), (registration.mark, registration.op, registration.tokens.clone()))); @@ -909,7 +903,7 @@ pub(crate) fn held_elsewhere(ctx: &Context) -> bool { let viewport = pass::current_viewport(ctx); pass::live_viewports(ctx).into_iter().filter(|other| *other != viewport).any(|other| { PerViewport::::with(ctx, other, |targets| { - (targets.winner.is_some() && targets.component) || targets.this.iter().any(|registration| !registration.window) + (targets.winner.is_some() && targets.component) || targets.this.iter().any(|registration| !registration.reach.window) }) }) } From f92a0be4ec12ac64b371a2910b52a412d961c08c Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:37:06 +0700 Subject: [PATCH 07/76] atomic: drop the empty line between KEPT_ATTRIBUTES and its doc comment --- crates/atomic/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/atomic/src/lib.rs b/crates/atomic/src/lib.rs index c0bbcf555..2fa589d09 100644 --- a/crates/atomic/src/lib.rs +++ b/crates/atomic/src/lib.rs @@ -491,7 +491,6 @@ fn name_taken(e: &io::Error, tmp: &Path) -> bool { /// The Windows attributes a replaced file passes on to its stage: hidden and system, the two that /// say who should see the file. A read-only file is never replaced, the archive bit is the /// system's to set on a changed file, and the others describe how the volume stores it. - #[cfg(windows)] const KEPT_ATTRIBUTES: u32 = 0x2 | 0x4; From afbe61c547b767aa90947b23d0be080b7f4bd9f5 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 08:48:26 +0700 Subject: [PATCH 08/76] automation: the control server ends a connection after its last reply by closing its write side and reading off what the client still sends, so the close no longer resets the connection and loses the reply or the end of the stream --- crates/automation/src/server.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rs index b2f9fdd1d..c6808156d 100644 --- a/crates/automation/src/server.rs +++ b/crates/automation/src/server.rs @@ -1,7 +1,7 @@ //! The loopback JSON-lines TCP transport: one request per line, one reply per line. -use std::io::{BufReader, Write}; -use std::net::{SocketAddr, TcpListener, TcpStream}; +use std::io::{BufReader, Read, Write}; +use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{Receiver, Sender, channel}; @@ -89,6 +89,7 @@ pub fn serve_with_deadline( let Some(permit) = limiter.try_acquire() else { let _ = configure_stream(&stream); let _ = writeln!(stream, "{}", json!({"id": null, "ok": false, "error": "connection limit reached"})); + close_after_reply(&stream); continue; }; let tx = tx.clone(); @@ -179,4 +180,27 @@ fn serve_connection(stream: TcpStream, token: &str, tx: &Sender, break; } } + close_after_reply(&out); +} + +/// How long a closing connection's leftover input is read and dropped ([`close_after_reply`]). +const CLOSE_LINGER: Duration = Duration::from_millis(250); + +/// Closes `stream` after its last reply without resetting it: the write side ends first, so the client reads the +/// reply and then the end of the stream, and what the client still sends is read and dropped until it closes too, for +/// at most [`CLOSE_LINGER`]. A socket closed with input unread is reset instead, and the client loses the reply +/// (Linux) or reads the reset where the end of the stream should be (Windows). +fn close_after_reply(mut stream: &TcpStream) { + let _ = stream.shutdown(Shutdown::Write); + let deadline = motion::now() + CLOSE_LINGER; + let mut sink = [0; 1024]; + loop { + let left = deadline.saturating_duration_since(motion::now()); + if left.is_zero() || stream.set_read_timeout(Some(left)).is_err() { + return; + } + if matches!(stream.read(&mut sink), Ok(0) | Err(_)) { + return; + } + } } From 9aa180d0314c2ce18690af8c0f50dd132abf3fab Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 09:13:59 +0700 Subject: [PATCH 09/76] ui-contract: a press egui gives to a selection part's text takes focus through the press plan A press on SelectableText has no winning framework shape, so the press plan was Unclaimed and egui's read-only text widget took focus by itself: the focus record never saw a press, and Tab with tab_toggles_chrome on moved focus instead of toggling the panels. A press no shape wins that egui gives to the widget of a press-only stop now takes focus for that stop, so it records FocusOrigin::Press. --- crates/ui-contract/src/runtime/focus/press.rs | 22 ++++++++- crates/ui-widgets/tests/it/text/selectable.rs | 47 ++++++++++++++++++- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/crates/ui-contract/src/runtime/focus/press.rs b/crates/ui-contract/src/runtime/focus/press.rs index c03e0604d..eb8fbbdf2 100644 --- a/crates/ui-contract/src/runtime/focus/press.rs +++ b/crates/ui-contract/src/runtime/focus/press.rs @@ -107,8 +107,21 @@ impl State { let text_stop = text_rec.as_ref().map(|stop| stop.stop.id); let held = !on_focused && text_rec.as_ref().is_some_and(|stop| stop.stop.keys.holds_drafts) && (at.over_focus || self.press.holds(&at.under)); self.press.held_draft = text_stop.filter(|_| held); - let kind = if on_focused || held { PressFocus::Keep } else { classify_press(winner.map(|winner| winner.sense)) }; - let (owner, part) = winner.map_or((None, None), |winner| (Some(winner.owner), winner.part)); + // A press no shape wins that egui gives to the widget of a press-only stop (a selection part's text, which egui + // selects in) takes focus for that stop, as a press on any stop's shape does. + let widget_stop = at.target.filter(|_| winner.is_none()).and_then(|target| self.press_only_stop(target)); + let kind = if on_focused || held { + PressFocus::Keep + } else if widget_stop.is_some() { + PressFocus::Take + } else { + classify_press(winner.map(|winner| winner.sense)) + }; + let (owner, part) = match (winner, widget_stop) { + (Some(winner), _) => (Some(winner.owner), winner.part), + (None, Some(rec)) => (Some(rec.stop.id), rec.stop.part), + (None, None) => (None, None), + }; let was_text = text_stop.is_some() && kind.commits_draft(); // A press that takes focus for another component commits too: the page that component switches may remove the // field in the same pass, so a later focus loss would never reach it. @@ -130,6 +143,11 @@ impl State { self.find_stop((owner, part)).or_else(|| self.find_stop((owner, None))) } + /// The press-only stop whose egui widget is `widget`. + fn press_only_stop(&self, widget: Id) -> Option { + self.stops.iter().chain(&self.last_stops).find(|rec| rec.stop.press_only && rec.stop.root == widget).cloned() + } + /// The press's focus move at the end hook; `focused` is egui's focus now. The press moves the framework's focus /// only: when `focused` is an app's own widget (`on_app_widget`), egui's own surrender rule, by the app's /// `surrender_focus_on`, decides whether a press elsewhere takes it; a press a component takes still moves focus diff --git a/crates/ui-widgets/tests/it/text/selectable.rs b/crates/ui-widgets/tests/it/text/selectable.rs index 854390ab0..c471d839b 100644 --- a/crates/ui-widgets/tests/it/text/selectable.rs +++ b/crates/ui-widgets/tests/it/text/selectable.rs @@ -2,14 +2,17 @@ //! (`SelectableText`, a notice's title and message, a toast's text, a metadata table's values). use craft_theme::variant::Tone; +use craft_ui::buttons::Button; use craft_ui::contract::{Bind, CollectionEvent, Props as _, Show as _}; use craft_ui::notices::{Notice, NoticeAction, ToastStack}; -use craft_ui::runtime::env::WindowKey; +use craft_ui::runtime::env::{RootEnv, WindowKey}; +use craft_ui::runtime::focus::{KeyUse, host_canvas}; +use craft_ui::runtime::frame::{ChromeToggle, take_output}; use craft_ui::runtime::toast; use craft_ui::table::{MetadataGroup, MetadataRow, MetadataTable}; use craft_ui::testing::{Fixture, trial}; use craft_ui::text::{SelectableText, TextField}; -use egui::{Event, Id, Key, Modifiers, Rect, Vec2}; +use egui::{Event, Id, Key, Modifiers, Rect, Sense, Vec2, ViewportId}; use std::cell::Cell; use std::rc::Rc; @@ -141,3 +144,43 @@ fn metadata_value_copies_without_selecting_the_row() { assert_eq!(copy_all(&mut fixture), ["X100V"]); assert!(!selected.get(), "the press on the value selected no row"); } + +/// In a window with a document canvas whose Tab toggles the panels, read-only text a press or a drag focused to select +/// from is no text field: Tab toggles the panels from it, as from the button a press focused, and leaves the focus on +/// it. Guards the press that focuses a selection part, which no framework shape wins (egui's text widget takes it), being +/// recorded as a press. +#[trial] +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 mut fixture = Fixture::new(move |ui| { + Button::new("Save").show(ui); + seen.set(SelectableText::new("Path", "/projects/poster.indd").show(ui).id); + ui.interact(ui.available_rect_before_wrap(), canvas, Sense::click()); + host_canvas(ui.ctx(), canvas, KeyUse::CANVAS); + }); + let mut root = RootEnv::default(); + root.tab_toggles_chrome = true; + fixture.root(root); + fixture.settle(); + let tab = |fixture: &mut Fixture| { + take_output(fixture.ctx()); + fixture.key(Key::Tab, Modifiers::NONE); + take_output(fixture.ctx()).chrome_toggles + }; + let path = painted(&fixture, "/projects/poster.indd"); + for dragged in [false, true] { + let button = fixture.by_label("Save").expect("the button has a node"); + fixture.click(&button); + assert_eq!(tab(&mut fixture), [(ViewportId::ROOT, ChromeToggle::Panels)], "the pressed button (dragged {dragged})"); + if dragged { + fixture.drag_at(path.left_center() + Vec2::new(1.0, 0.0), Vec2::new(path.width() / 2.0, 0.0)); + } else { + fixture.click_at(path.center()); + } + assert_eq!(stop(&fixture), Some(text.get()), "the gesture focused the text (dragged {dragged})"); + assert_eq!(tab(&mut fixture), [(ViewportId::ROOT, ChromeToggle::Panels)], "the pressed text (dragged {dragged})"); + assert_eq!(stop(&fixture), Some(text.get()), "the toggle moved no focus (dragged {dragged})"); + } +} From 68a41a9e813915c83a0f7679914dbcbff7023c23 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 09:17:56 +0700 Subject: [PATCH 10/76] text: Format Text's font row names the font_picker prop without a link the font-picker feature gates --- crates/text/src/ui/character/format_text.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/text/src/ui/character/format_text.rs b/crates/text/src/ui/character/format_text.rs index 5f697ac1a..5a5de1ef6 100644 --- a/crates/text/src/ui/character/format_text.rs +++ b/crates/text/src/ui/character/format_text.rs @@ -138,8 +138,8 @@ const LINE_PRESETS: [LineSpacing; 5] = /// superscript, subscript; line and paragraph spacing; scale and character spacing). A control in `unsupported` is /// disabled with its reason. It keeps no state between passes: each pass reports only the edits of its own input. /// -/// - Font: the family field the Character controls show: craft-font-manager's `FontPicker` over -/// [`font_picker`](Self::font_picker) (with the host's rows), else a `Select` of `families`. A family pick is +/// - Font: the family field the Character controls show: craft-font-manager's `FontPicker` with +/// `font-picker` and `font_picker` (with the host's rows), else a `Select` of `families`. A family pick is /// `Character(Family(..))`, a style row pick `Character(Family(..))` then `Character(Style(..))`, and a host row /// pick `HostFont(key)`. /// - Size, paragraph spacing and character spacing are lengths in points; horizontal scale is a percentage. A scrub From b6b2908123777e725684a4fb9be2ee848be37529 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 09:27:06 +0700 Subject: [PATCH 11/76] theme: regenerate the VectorCraft token dumps with the six tokens next added --- .../tokens/vectorcraft-modern-dark-high-comfortable.txt | 6 ++++++ .../dumps/tokens/vectorcraft-modern-dark-high-compact.txt | 6 ++++++ .../tokens/vectorcraft-modern-dark-standard-comfortable.txt | 6 ++++++ .../tokens/vectorcraft-modern-dark-standard-compact.txt | 6 ++++++ .../tokens/vectorcraft-modern-light-high-comfortable.txt | 6 ++++++ .../dumps/tokens/vectorcraft-modern-light-high-compact.txt | 6 ++++++ .../vectorcraft-modern-light-standard-comfortable.txt | 6 ++++++ .../tokens/vectorcraft-modern-light-standard-compact.txt | 6 ++++++ .../vectorcraft-modern-medium-dark-high-comfortable.txt | 6 ++++++ .../tokens/vectorcraft-modern-medium-dark-high-compact.txt | 6 ++++++ .../vectorcraft-modern-medium-dark-standard-comfortable.txt | 6 ++++++ .../vectorcraft-modern-medium-dark-standard-compact.txt | 6 ++++++ .../vectorcraft-modern-medium-light-high-comfortable.txt | 6 ++++++ .../tokens/vectorcraft-modern-medium-light-high-compact.txt | 6 ++++++ ...vectorcraft-modern-medium-light-standard-comfortable.txt | 6 ++++++ .../vectorcraft-modern-medium-light-standard-compact.txt | 6 ++++++ 16 files changed, 96 insertions(+) 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 4efc3b228..812c906cf 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 @@ -8,6 +8,7 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #bbc4d5ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 783dfa13a..f790188e0 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 @@ -8,6 +8,7 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #bbc4d5ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 d89eec9a4..ea748d6c0 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 @@ -8,6 +8,7 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #969fafff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 bd51c9429..d66b2ac69 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 @@ -8,6 +8,7 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #969fafff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 40242a0b5..4b820d4ad 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 @@ -8,6 +8,7 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #3d4452ff @@ -17,6 +18,7 @@ text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 5542f8faa..38b4a70b0 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 @@ -8,6 +8,7 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #3d4452ff @@ -17,6 +18,7 @@ text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 69eedb01e..5fac7f945 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 @@ -8,6 +8,7 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #58606eff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 aff055622..2958fed49 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 @@ -8,6 +8,7 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #58606eff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 8e0d025e3..f38597b67 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 @@ -8,6 +8,7 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #d3dcedff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 6f0078e78..272a5add3 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 @@ -8,6 +8,7 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #d3dcedff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 f2ce55a49..1280892e8 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 @@ -8,6 +8,7 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #99a2b2ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 d7e3d29eb..da092c68e 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 @@ -8,6 +8,7 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #99a2b2ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 ca6e14c28..647ee2163 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 @@ -8,6 +8,7 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #2a303eff @@ -17,6 +18,7 @@ text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 315233d45..df1623ec6 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 @@ -8,6 +8,7 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #2a303eff @@ -17,6 +18,7 @@ text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 e15440c53..5ad36953a 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 @@ -8,6 +8,7 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #4a5160ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 7051e2d8e..5107c75c7 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 @@ -8,6 +8,7 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #4a5160ff @@ -17,6 +18,7 @@ text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 From 12c5d012ed495f344a219e892515c383527d8bb9 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 09:57:15 +0700 Subject: [PATCH 12/76] ui-contract: a focused text field keeps the Escape it does not use, and every other focused control lends it to the window --- crates/ui-contract/src/runtime/keys/intents.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/ui-contract/src/runtime/keys/intents.rs b/crates/ui-contract/src/runtime/keys/intents.rs index b3ca4df20..a60d21cc5 100644 --- a/crates/ui-contract/src/runtime/keys/intents.rs +++ b/crates/ui-contract/src/runtime/keys/intents.rs @@ -4,7 +4,7 @@ use super::route::push; use super::{Nudge, Source, Stage, current}; use crate::runtime::focus::{self}; use craft_behavior::focus::{EscapeFacts, EscapeStep, escape_step}; -use craft_behavior::{AccessRequest, CancelRule, EditCommand, EditorInput, Intent, MoveMods, NavMove, PartRef}; +use craft_behavior::{AccessRequest, CancelRule, EditCommand, EditorInput, Intent, MoveMods, NavMove, OwnerClass, PartRef}; use craft_keymap::{Chord, Key, Mods}; use egui::{Context, Id, Vec2}; use std::sync::Arc; @@ -287,7 +287,7 @@ pub fn intents_of(ctx: &Context, id: Option, rtl: bool) -> Intents { /// /// The window's intents are the keys the runtime routes to no component this pass: an Escape (`Intent::Cancel`) /// or a plain Enter (`Intent::Submit`) while no framework stop is focused, and the arrows' nudge; with a framework -/// stop focused, its unused Escape. A component or a +/// stop focused, its unused Escape, unless it is a text field. A component or a /// scope that runs earlier in the pass takes them first (an open dialog takes the Escape that closes it, a canvas /// session the one that ends it), so an app that hosts the runtime reads them last in its UI to see what no /// component took. `rtl` reads horizontal moves in the window's direction. @@ -305,7 +305,11 @@ pub fn with_canvas_window_intents(ctx: &Context, rtl: bool, take: impl FnOnce(&m } fn offer_window_intents(ctx: &Context, rtl: bool, take: impl FnOnce(&mut Intents) -> bool) -> bool { - let focused = focus::focused_rec(ctx).map(|rec| rec.stop.id); + // A focused text field keeps the Escape it does not use, so typing in a palette's field never closes the + // palette; the document's editor and a canvas control lend it as any other control does. + let focused = focus::focused_rec(ctx) + .filter(|rec| rec.stop.keys.owner != OwnerClass::Text || rec.stop.keys.is_document_editor() || focus::is_canvas_member(ctx, rec)) + .map(|rec| rec.stop.id); let mut window = intents_of(ctx, None, rtl); // The focused stop's leftover Escape stays in its slot until taken. let lent_cancel = From a6c6eda35a502076923b7800095bbbadac4071bf Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 09:58:45 +0700 Subject: [PATCH 13/76] theme: VectorCraft Modern's selected, pressed and disabled colours take production's values Production tints selected rows and pressed fills toward the accent in every Modern palette, the default Coral included, and draws disabled text in its disabled grey. The VectorCraft themes pinned the untinted values and left text.disabled derived. Their dumps also lacked tokens added since they were last written. --- ...ctorcraft-modern-dark-high-comfortable.txt | 26 ++++++++++------- .../vectorcraft-modern-dark-high-compact.txt | 26 ++++++++++------- ...craft-modern-dark-standard-comfortable.txt | 19 +++++++++---- ...ctorcraft-modern-dark-standard-compact.txt | 19 +++++++++---- ...torcraft-modern-light-high-comfortable.txt | 28 +++++++++++-------- .../vectorcraft-modern-light-high-compact.txt | 28 +++++++++++-------- ...raft-modern-light-standard-comfortable.txt | 19 +++++++++---- ...torcraft-modern-light-standard-compact.txt | 19 +++++++++---- ...ft-modern-medium-dark-high-comfortable.txt | 28 +++++++++++-------- ...rcraft-modern-medium-dark-high-compact.txt | 28 +++++++++++-------- ...odern-medium-dark-standard-comfortable.txt | 20 ++++++++----- ...ft-modern-medium-dark-standard-compact.txt | 20 ++++++++----- ...t-modern-medium-light-high-comfortable.txt | 28 +++++++++++-------- ...craft-modern-medium-light-high-compact.txt | 28 +++++++++++-------- ...dern-medium-light-standard-comfortable.txt | 20 ++++++++----- ...t-modern-medium-light-standard-compact.txt | 20 ++++++++----- .../themes/vectorcraft-modern-medium.json | 10 ++++--- crates/theme/themes/vectorcraft-modern.json | 10 ++++--- 18 files changed, 250 insertions(+), 146 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 4efc3b228..9fb87ac4a 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 @@ -8,21 +8,23 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff -text.muted = #bbc4d5ff -text.faint = #bbc4d5ff -text.disabled = #82868fff +text.muted = #c7d1e1ff +text.faint = #c7d1e2ff +text.disabled = #5a6271ff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff line.knob_edge = #00000000 line.frame = #0d0d0eff -line.mark = #989da5ff +line.mark = #a3a8b0ff line.grip = #2b2e36ff line.focus = #f06a52ff accent.solid = #f26b53ff @@ -60,9 +62,9 @@ status.info.solid = #8c96a8ff status.info.solid_hover = #8f99abff status.info.solid_pressed = #a2abbdff state.hover = #262b35ff -state.pressed = #2f3541ff -state.selected = #3a2a2cff -state.selected_hover = #4d3c3eff +state.pressed = #593330ff +state.selected = #4c2e2eff +state.selected_hover = #604040ff state.disabled_fill = #181b22ff state.text_selection = #f26b5346 state.match = #f0dc005a @@ -95,14 +97,14 @@ data.cyan = #00c8ebff data.magenta = #e909a2ff data.yellow = #f0dc00ff data.scope = #282828ff -data.backdrop = #bbc4d580 +data.backdrop = #c7d1e180 data.selection = #f26b5359 caption.close_hover = #c42b1cff caption.close_pressed = #c42b1ce6 caption.close_text = #ffffffff caption.disc = #dfe4ec1a -caption.inactive = #bbc4d5ff -caption.pressed = #bbc4d5ff +caption.inactive = #c7d1e2ff +caption.pressed = #c7d1e1ff edge.light = #3d4048ff edge.dark = #000000ff shape.radius.sm = 3 @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 783dfa13a..347403929 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 @@ -8,21 +8,23 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff -text.muted = #bbc4d5ff -text.faint = #bbc4d5ff -text.disabled = #82868fff +text.muted = #c7d1e1ff +text.faint = #c7d1e2ff +text.disabled = #5a6271ff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff line.knob_edge = #00000000 line.frame = #0d0d0eff -line.mark = #989da5ff +line.mark = #a3a8b0ff line.grip = #2b2e36ff line.focus = #f06a52ff accent.solid = #f26b53ff @@ -60,9 +62,9 @@ status.info.solid = #8c96a8ff status.info.solid_hover = #8f99abff status.info.solid_pressed = #a2abbdff state.hover = #262b35ff -state.pressed = #2f3541ff -state.selected = #3a2a2cff -state.selected_hover = #4d3c3eff +state.pressed = #593330ff +state.selected = #4c2e2eff +state.selected_hover = #604040ff state.disabled_fill = #181b22ff state.text_selection = #f26b5346 state.match = #f0dc005a @@ -95,14 +97,14 @@ data.cyan = #00c8ebff data.magenta = #e909a2ff data.yellow = #f0dc00ff data.scope = #282828ff -data.backdrop = #bbc4d580 +data.backdrop = #c7d1e180 data.selection = #f26b5359 caption.close_hover = #c42b1cff caption.close_pressed = #c42b1ce6 caption.close_text = #ffffffff caption.disc = #dfe4ec1a -caption.inactive = #bbc4d5ff -caption.pressed = #bbc4d5ff +caption.inactive = #c7d1e2ff +caption.pressed = #c7d1e1ff edge.light = #3d4048ff edge.dark = #000000ff shape.radius.sm = 2 @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 d89eec9a4..86e14c857 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 @@ -8,21 +8,23 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #969fafff text.faint = #5a6271ff -text.disabled = #82868fff +text.disabled = #5a6271ff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff line.knob_edge = #00000000 line.frame = #0d0d0eff -line.mark = #797e86ff +line.mark = #83878fff line.grip = #2b2e36ff line.focus = #f06a52ff accent.solid = #f06a52ff @@ -60,9 +62,9 @@ status.info.solid = #6f788aff status.info.solid_hover = #8f99abff status.info.solid_pressed = #a2abbdff state.hover = #262b35ff -state.pressed = #2f3541ff -state.selected = #3a2a2cff -state.selected_hover = #4d3c3eff +state.pressed = #593330ff +state.selected = #4c2e2eff +state.selected_hover = #604040ff state.disabled_fill = #181b22ff state.text_selection = #f06a5246 state.match = #f0dc005a @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 @@ -244,10 +250,11 @@ motion.caret.easing = enter motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false +warning = text.muted on state.pressed: 4.06 < 4.50 warning = text.faint on surface.background: 3.17 < 4.50 warning = text.faint on surface.panel: 2.81 < 4.50 warning = text.faint on surface.chrome: 2.81 < 4.50 warning = text.faint on surface.raised: 2.53 < 4.50 warning = text.faint on surface.sunken: 3.08 < 4.50 warning = text.faint on state.hover: 2.31 < 4.50 -warning = text.faint on state.pressed: 2.00 < 4.50 +warning = text.faint on state.pressed: 1.76 < 4.50 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 bd51c9429..1f8f65595 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 @@ -8,21 +8,23 @@ surface.raised = #21242cff surface.sunken = #0f1116ff surface.knob = #e9ebf0ff surface.scrim = #00000080 +surface.inverse = #e9ebf0ff surface.shadow = #00000096 text.normal = #dfe4ecff text.muted = #969fafff text.faint = #5a6271ff -text.disabled = #82868fff +text.disabled = #5a6271ff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e9ebf0ff +text.on_inverse = #0d0d0eff line.divider = #232832ff line.border = #06070aff line.control_edge = #2c323eff line.knob_edge = #00000000 line.frame = #0d0d0eff -line.mark = #797e86ff +line.mark = #83878fff line.grip = #2b2e36ff line.focus = #f06a52ff accent.solid = #f06a52ff @@ -60,9 +62,9 @@ status.info.solid = #6f788aff status.info.solid_hover = #8f99abff status.info.solid_pressed = #a2abbdff state.hover = #262b35ff -state.pressed = #2f3541ff -state.selected = #3a2a2cff -state.selected_hover = #4d3c3eff +state.pressed = #593330ff +state.selected = #4c2e2eff +state.selected_hover = #604040ff state.disabled_fill = #181b22ff state.text_selection = #f06a5246 state.match = #f0dc005a @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 @@ -244,10 +250,11 @@ motion.caret.easing = enter motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false +warning = text.muted on state.pressed: 4.06 < 4.50 warning = text.faint on surface.background: 3.17 < 4.50 warning = text.faint on surface.panel: 2.81 < 4.50 warning = text.faint on surface.chrome: 2.81 < 4.50 warning = text.faint on surface.raised: 2.53 < 4.50 warning = text.faint on surface.sunken: 3.08 < 4.50 warning = text.faint on state.hover: 2.31 < 4.50 -warning = text.faint on state.pressed: 2.00 < 4.50 +warning = text.faint on state.pressed: 1.76 < 4.50 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 40242a0b5..0737f2949 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 @@ -8,21 +8,23 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff -text.muted = #3d4452ff -text.faint = #3f444fff -text.disabled = #848689ff +text.muted = #383f4dff +text.faint = #3a3f4aff +text.disabled = #9aa1adff text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff -line.knob_edge = #3d4452ff +line.knob_edge = #383f4dff line.frame = #c3c9d3ff -line.mark = #5f6062ff +line.mark = #5a5b5dff line.grip = #e2e4e7ff line.focus = #c4321aff accent.solid = #af1c00ff @@ -60,9 +62,9 @@ status.info.solid = #8c96a8ff status.info.solid_hover = #8c96a8ff status.info.solid_pressed = #8d96a7ff state.hover = #e3e7edff -state.pressed = #d5dbe3ff -state.selected = #f8d9d2ff -state.selected_hover = #eccec7ff +state.pressed = #edcbc8ff +state.selected = #eed2d0ff +state.selected_hover = #e2c7c5ff state.disabled_fill = #f3f5f8ff state.text_selection = #af1c0046 state.match = #8378005a @@ -95,14 +97,14 @@ data.cyan = #00829aff data.magenta = #e0009cff data.yellow = #837800ff data.scope = #282828ff -data.backdrop = #3d445280 +data.backdrop = #383f4d80 data.selection = #af1c0059 caption.close_hover = #c42b1cff caption.close_pressed = #c42b1ce6 caption.close_text = #ffffffff caption.disc = #1b1f271a -caption.inactive = #3f444fff -caption.pressed = #3d4452ff +caption.inactive = #3a3f4aff +caption.pressed = #383f4dff edge.light = #ffffffff edge.dark = #a0a1a4ff shape.radius.sm = 3 @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 5542f8faa..2ab2ec91b 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 @@ -8,21 +8,23 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff -text.muted = #3d4452ff -text.faint = #3f444fff -text.disabled = #848689ff +text.muted = #383f4dff +text.faint = #3a3f4aff +text.disabled = #9aa1adff text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff -line.knob_edge = #3d4452ff +line.knob_edge = #383f4dff line.frame = #c3c9d3ff -line.mark = #5f6062ff +line.mark = #5a5b5dff line.grip = #e2e4e7ff line.focus = #c4321aff accent.solid = #af1c00ff @@ -60,9 +62,9 @@ status.info.solid = #8c96a8ff status.info.solid_hover = #8c96a8ff status.info.solid_pressed = #8d96a7ff state.hover = #e3e7edff -state.pressed = #d5dbe3ff -state.selected = #f8d9d2ff -state.selected_hover = #eccec7ff +state.pressed = #edcbc8ff +state.selected = #eed2d0ff +state.selected_hover = #e2c7c5ff state.disabled_fill = #f3f5f8ff state.text_selection = #af1c0046 state.match = #8378005a @@ -95,14 +97,14 @@ data.cyan = #00829aff data.magenta = #e0009cff data.yellow = #837800ff data.scope = #282828ff -data.backdrop = #3d445280 +data.backdrop = #383f4d80 data.selection = #af1c0059 caption.close_hover = #c42b1cff caption.close_pressed = #c42b1ce6 caption.close_text = #ffffffff caption.disc = #1b1f271a -caption.inactive = #3f444fff -caption.pressed = #3d4452ff +caption.inactive = #3a3f4aff +caption.pressed = #383f4dff edge.light = #ffffffff edge.dark = #a0a1a4ff shape.radius.sm = 2 @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 69eedb01e..d3fa34530 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 @@ -8,21 +8,23 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #58606eff text.faint = #9aa1adff -text.disabled = #848689ff +text.disabled = #9aa1adff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff line.knob_edge = #58606eff line.frame = #c3c9d3ff -line.mark = #7a7c7eff +line.mark = #757678ff line.grip = #e2e4e7ff line.focus = #d9472fff accent.solid = #d9472fff @@ -60,9 +62,9 @@ status.info.solid = #6f788aff status.info.solid_hover = #6c7587ff status.info.solid_pressed = #6c7585ff state.hover = #e3e7edff -state.pressed = #d5dbe3ff -state.selected = #f8d9d2ff -state.selected_hover = #eccec7ff +state.pressed = #edcbc8ff +state.selected = #eed2d0ff +state.selected_hover = #e2c7c5ff state.disabled_fill = #f3f5f8ff state.text_selection = #d9472f46 state.match = #f0dc005a @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 @@ -244,10 +250,11 @@ motion.caret.easing = enter motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false +warning = text.muted on state.pressed: 4.22 < 4.50 warning = text.faint on surface.background: 2.14 < 4.50 warning = text.faint on surface.panel: 2.38 < 4.50 warning = text.faint on surface.chrome: 2.38 < 4.50 warning = text.faint on surface.raised: 2.51 < 4.50 warning = text.faint on surface.sunken: 2.60 < 4.50 warning = text.faint on state.hover: 2.10 < 4.50 -warning = text.faint on state.pressed: 1.87 < 4.50 +warning = text.faint on state.pressed: 1.73 < 4.50 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 aff055622..0802ea550 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 @@ -8,21 +8,23 @@ surface.raised = #f9fbfeff surface.sunken = #ffffffff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #262627ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #58606eff text.faint = #9aa1adff -text.disabled = #848689ff +text.disabled = #9aa1adff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #262627ff +text.on_inverse = #fcfcfdff line.divider = #dde1e8ff line.border = #d0d5ddff line.control_edge = #c3c9d3ff line.knob_edge = #58606eff line.frame = #c3c9d3ff -line.mark = #7a7c7eff +line.mark = #757678ff line.grip = #e2e4e7ff line.focus = #d9472fff accent.solid = #d9472fff @@ -60,9 +62,9 @@ status.info.solid = #6f788aff status.info.solid_hover = #6c7587ff status.info.solid_pressed = #6c7585ff state.hover = #e3e7edff -state.pressed = #d5dbe3ff -state.selected = #f8d9d2ff -state.selected_hover = #eccec7ff +state.pressed = #edcbc8ff +state.selected = #eed2d0ff +state.selected_hover = #e2c7c5ff state.disabled_fill = #f3f5f8ff state.text_selection = #d9472f46 state.match = #f0dc005a @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 @@ -244,10 +250,11 @@ motion.caret.easing = enter motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false +warning = text.muted on state.pressed: 4.22 < 4.50 warning = text.faint on surface.background: 2.14 < 4.50 warning = text.faint on surface.panel: 2.38 < 4.50 warning = text.faint on surface.chrome: 2.38 < 4.50 warning = text.faint on surface.raised: 2.51 < 4.50 warning = text.faint on surface.sunken: 2.60 < 4.50 warning = text.faint on state.hover: 2.10 < 4.50 -warning = text.faint on state.pressed: 1.87 < 4.50 +warning = text.faint on state.pressed: 1.73 < 4.50 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 8e0d025e3..3338fe6e6 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 @@ -8,21 +8,23 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff -text.muted = #d3dcedff -text.faint = #d2ddeeff -text.disabled = #808692ff +text.muted = #d9e3f4ff +text.faint = #d8e3f4ff +text.disabled = #626b7aff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff -text.on_selected = #e8ebf1ff +text.on_selected = #f5f9ffff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff line.knob_edge = #00000000 line.frame = #0d0d0eff -line.mark = #abb2beff +line.mark = #b0b7c3ff line.grip = #3b404bff line.focus = #fc755cff accent.solid = #fc755cff @@ -60,9 +62,9 @@ status.info.solid = #8c96a8ff status.info.solid_hover = #8f99abff status.info.solid_pressed = #a2abbdff state.hover = #353c49ff -state.pressed = #3d4553ff -state.selected = #4a3236ff -state.selected_hover = #5e4448ff +state.pressed = #633f3eff +state.selected = #573b3dff +state.selected_hover = #6b4e50ff state.disabled_fill = #272c36ff state.text_selection = #fc755c46 state.match = #f0dc005a @@ -95,14 +97,14 @@ data.cyan = #00c8ebff data.magenta = #f423abff data.yellow = #f0dc00ff data.scope = #282828ff -data.backdrop = #d3dced80 +data.backdrop = #d9e3f480 data.selection = #fc755c59 caption.close_hover = #c42b1cff caption.close_pressed = #c42b1ce6 caption.close_text = #ffffffff caption.disc = #e4e9f11a -caption.inactive = #d2ddeeff -caption.pressed = #d3dcedff +caption.inactive = #d8e3f4ff +caption.pressed = #d9e3f4ff edge.light = #4e535eff edge.dark = #000001ff shape.radius.sm = 3 @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 6f0078e78..c02aa3eda 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 @@ -8,21 +8,23 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff -text.muted = #d3dcedff -text.faint = #d2ddeeff -text.disabled = #808692ff +text.muted = #d9e3f4ff +text.faint = #d8e3f4ff +text.disabled = #626b7aff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff -text.on_selected = #e8ebf1ff +text.on_selected = #f5f9ffff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff line.knob_edge = #00000000 line.frame = #0d0d0eff -line.mark = #abb2beff +line.mark = #b0b7c3ff line.grip = #3b404bff line.focus = #fc755cff accent.solid = #fc755cff @@ -60,9 +62,9 @@ status.info.solid = #8c96a8ff status.info.solid_hover = #8f99abff status.info.solid_pressed = #a2abbdff state.hover = #353c49ff -state.pressed = #3d4553ff -state.selected = #4a3236ff -state.selected_hover = #5e4448ff +state.pressed = #633f3eff +state.selected = #573b3dff +state.selected_hover = #6b4e50ff state.disabled_fill = #272c36ff state.text_selection = #fc755c46 state.match = #f0dc005a @@ -95,14 +97,14 @@ data.cyan = #00c8ebff data.magenta = #f423abff data.yellow = #f0dc00ff data.scope = #282828ff -data.backdrop = #d3dced80 +data.backdrop = #d9e3f480 data.selection = #fc755c59 caption.close_hover = #c42b1cff caption.close_pressed = #c42b1ce6 caption.close_text = #ffffffff caption.disc = #e4e9f11a -caption.inactive = #d2ddeeff -caption.pressed = #d3dcedff +caption.inactive = #d8e3f4ff +caption.pressed = #d9e3f4ff edge.light = #4e535eff edge.dark = #000001ff shape.radius.sm = 2 @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 f2ce55a49..6fd9898dd 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 @@ -8,21 +8,23 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #99a2b2ff text.faint = #626b7aff -text.disabled = #808692ff +text.disabled = #626b7aff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff line.knob_edge = #00000000 line.frame = #0d0d0eff -line.mark = #89909bff +line.mark = #8e95a0ff line.grip = #3b404bff line.focus = #f06a52ff accent.solid = #f06a52ff @@ -60,9 +62,9 @@ status.info.solid = #6f788aff status.info.solid_hover = #8f99abff status.info.solid_pressed = #a2abbdff state.hover = #353c49ff -state.pressed = #3d4553ff -state.selected = #4a3236ff -state.selected_hover = #5e4448ff +state.pressed = #633f3eff +state.selected = #573b3dff +state.selected_hover = #6b4e50ff state.disabled_fill = #272c36ff state.text_selection = #f06a5246 state.match = #f0dc005a @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 @@ -245,11 +251,11 @@ motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false warning = text.muted on state.hover: 4.31 < 4.50 -warning = text.muted on state.pressed: 3.75 < 4.50 +warning = text.muted on state.pressed: 3.53 < 4.50 warning = text.faint on surface.background: 3.07 < 4.50 warning = text.faint on surface.panel: 2.60 < 4.50 warning = text.faint on surface.chrome: 2.60 < 4.50 warning = text.faint on surface.raised: 2.25 < 4.50 warning = text.faint on surface.sunken: 3.10 < 4.50 warning = text.faint on state.hover: 2.06 < 4.50 -warning = text.faint on state.pressed: 1.80 < 4.50 +warning = text.faint on state.pressed: 1.69 < 4.50 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 d7e3d29eb..7343d1164 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 @@ -8,21 +8,23 @@ surface.raised = #313640ff surface.sunken = #1a1e26ff surface.knob = #e8ebf1ff surface.scrim = #00000080 +surface.inverse = #e8ebf1ff surface.shadow = #00000096 text.normal = #e4e9f1ff text.muted = #99a2b2ff text.faint = #626b7aff -text.disabled = #808692ff +text.disabled = #626b7aff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #e8ebf1ff +text.on_inverse = #0d0d0eff line.divider = #323946ff line.border = #11141aff line.control_edge = #3a414eff line.knob_edge = #00000000 line.frame = #0d0d0eff -line.mark = #89909bff +line.mark = #8e95a0ff line.grip = #3b404bff line.focus = #f06a52ff accent.solid = #f06a52ff @@ -60,9 +62,9 @@ status.info.solid = #6f788aff status.info.solid_hover = #8f99abff status.info.solid_pressed = #a2abbdff state.hover = #353c49ff -state.pressed = #3d4553ff -state.selected = #4a3236ff -state.selected_hover = #5e4448ff +state.pressed = #633f3eff +state.selected = #573b3dff +state.selected_hover = #6b4e50ff state.disabled_fill = #272c36ff state.text_selection = #f06a5246 state.match = #f0dc005a @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 @@ -245,11 +251,11 @@ motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false warning = text.muted on state.hover: 4.31 < 4.50 -warning = text.muted on state.pressed: 3.75 < 4.50 +warning = text.muted on state.pressed: 3.53 < 4.50 warning = text.faint on surface.background: 3.07 < 4.50 warning = text.faint on surface.panel: 2.60 < 4.50 warning = text.faint on surface.chrome: 2.60 < 4.50 warning = text.faint on surface.raised: 2.25 < 4.50 warning = text.faint on surface.sunken: 3.10 < 4.50 warning = text.faint on state.hover: 2.06 < 4.50 -warning = text.faint on state.pressed: 1.80 < 4.50 +warning = text.faint on state.pressed: 1.69 < 4.50 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 ca6e14c28..99b494063 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 @@ -8,21 +8,23 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff -text.muted = #2a303eff -text.faint = #2a303dff -text.disabled = #82868eff +text.muted = #292f3dff +text.faint = #29303cff +text.disabled = #7d8594ff text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff -line.knob_edge = #2a303eff +line.knob_edge = #292f3dff line.frame = #9aa2b0ff -line.mark = #4a4d54ff +line.mark = #494c53ff line.grip = #c3c8d0ff line.focus = #a81a00ff accent.solid = #af1b00ff @@ -60,9 +62,9 @@ status.info.solid = #8c96a8ff status.info.solid_hover = #8c96a8ff status.info.solid_pressed = #8d96a7ff state.hover = #c5ccd6ff -state.pressed = #b6bec9ff -state.selected = #e7c4bdff -state.selected_hover = #dbb9b2ff +state.pressed = #d4b5b6ff +state.selected = #d4bbbdff +state.selected_hover = #c9b0b2ff state.disabled_fill = #d3d8e0ff state.text_selection = #af1b0046 state.match = #776c005a @@ -95,14 +97,14 @@ data.cyan = #00758bff data.magenta = #cb008dff data.yellow = #776c00ff data.scope = #282828ff -data.backdrop = #2a303e80 +data.backdrop = #292f3d80 data.selection = #af1b0059 caption.close_hover = #c42b1cff caption.close_pressed = #c42b1ce6 caption.close_text = #ffffffff caption.disc = #1b1f271a -caption.inactive = #2a303dff -caption.pressed = #2a303eff +caption.inactive = #29303cff +caption.pressed = #292f3dff edge.light = #ffffffff edge.dark = #82878eff shape.radius.sm = 3 @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 315233d45..76037d632 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 @@ -8,21 +8,23 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff -text.muted = #2a303eff -text.faint = #2a303dff -text.disabled = #82868eff +text.muted = #292f3dff +text.faint = #29303cff +text.disabled = #7d8594ff text.on_accent = #ffffffff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff -line.knob_edge = #2a303eff +line.knob_edge = #292f3dff line.frame = #9aa2b0ff -line.mark = #4a4d54ff +line.mark = #494c53ff line.grip = #c3c8d0ff line.focus = #a81a00ff accent.solid = #af1b00ff @@ -60,9 +62,9 @@ status.info.solid = #8c96a8ff status.info.solid_hover = #8c96a8ff status.info.solid_pressed = #8d96a7ff state.hover = #c5ccd6ff -state.pressed = #b6bec9ff -state.selected = #e7c4bdff -state.selected_hover = #dbb9b2ff +state.pressed = #d4b5b6ff +state.selected = #d4bbbdff +state.selected_hover = #c9b0b2ff state.disabled_fill = #d3d8e0ff state.text_selection = #af1b0046 state.match = #776c005a @@ -95,14 +97,14 @@ data.cyan = #00758bff data.magenta = #cb008dff data.yellow = #776c00ff data.scope = #282828ff -data.backdrop = #2a303e80 +data.backdrop = #292f3d80 data.selection = #af1b0059 caption.close_hover = #c42b1cff caption.close_pressed = #c42b1ce6 caption.close_text = #ffffffff caption.disc = #1b1f271a -caption.inactive = #2a303dff -caption.pressed = #2a303eff +caption.inactive = #29303cff +caption.pressed = #292f3dff edge.light = #ffffffff edge.dark = #82878eff shape.radius.sm = 2 @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 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 e15440c53..99d34c458 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 @@ -8,21 +8,23 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #4a5160ff text.faint = #7d8594ff -text.disabled = #82868eff +text.disabled = #7d8594ff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff line.knob_edge = #4a5160ff line.frame = #9aa2b0ff -line.mark = #64676eff +line.mark = #63676dff line.grip = #c3c8d0ff line.focus = #cd3b24ff accent.solid = #d9472fff @@ -60,9 +62,9 @@ status.info.solid = #6f788aff status.info.solid_hover = #6c7587ff status.info.solid_pressed = #6c7585ff state.hover = #c5ccd6ff -state.pressed = #b6bec9ff -state.selected = #e7c4bdff -state.selected_hover = #dbb9b2ff +state.pressed = #d4b5b6ff +state.selected = #d4bbbdff +state.selected_hover = #c9b0b2ff state.disabled_fill = #d3d8e0ff state.text_selection = #d9472f46 state.match = #f0dc005a @@ -134,6 +136,9 @@ space.pad.roomy = 20 space.pad.chip = 6 space.pad.segment = 14 space.inset.screen = 20 +space.inset.page_side = 70 +space.inset.page_margin = 28 +space.inset.page_gap = 14 size.control.sm = 24 size.control.md = 30 size.icon.sm = 14 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 @@ -245,11 +251,11 @@ motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false warning = accent.solid on surface.panel: 3.00 < 3.00 -warning = text.muted on state.pressed: 4.25 < 4.50 +warning = text.muted on state.pressed: 4.20 < 4.50 warning = text.faint on surface.background: 2.25 < 4.50 warning = text.faint on surface.panel: 2.59 < 4.50 warning = text.faint on surface.chrome: 2.59 < 4.50 warning = text.faint on surface.raised: 2.75 < 4.50 warning = text.faint on surface.sunken: 3.14 < 4.50 warning = text.faint on state.hover: 2.30 < 4.50 -warning = text.faint on state.pressed: 1.98 < 4.50 +warning = text.faint on state.pressed: 1.96 < 4.50 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 7051e2d8e..df681c998 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 @@ -8,21 +8,23 @@ surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff surface.knob = #fcfcfdff surface.scrim = #00000059 +surface.inverse = #252629ff surface.shadow = #00000032 text.normal = #1b1f27ff text.muted = #4a5160ff text.faint = #7d8594ff -text.disabled = #82868eff +text.disabled = #7d8594ff text.on_accent = #000000ff text.on_strong = #ffffffff text.on_status = #000000ff text.on_selected = #252629ff +text.on_inverse = #fcfcfdff line.divider = #bcc3ceff line.border = #a9b0bcff line.control_edge = #9aa2b0ff line.knob_edge = #4a5160ff line.frame = #9aa2b0ff -line.mark = #64676eff +line.mark = #63676dff line.grip = #c3c8d0ff line.focus = #cd3b24ff accent.solid = #d9472fff @@ -60,9 +62,9 @@ status.info.solid = #6f788aff status.info.solid_hover = #6c7587ff status.info.solid_pressed = #6c7585ff state.hover = #c5ccd6ff -state.pressed = #b6bec9ff -state.selected = #e7c4bdff -state.selected_hover = #dbb9b2ff +state.pressed = #d4b5b6ff +state.selected = #d4bbbdff +state.selected_hover = #c9b0b2ff state.disabled_fill = #d3d8e0ff state.text_selection = #d9472f46 state.match = #f0dc005a @@ -134,6 +136,9 @@ space.pad.roomy = 16 space.pad.chip = 4 space.pad.segment = 10 space.inset.screen = 16 +space.inset.page_side = 56 +space.inset.page_margin = 24 +space.inset.page_gap = 12 size.control.sm = 20 size.control.md = 24 size.icon.sm = 12 @@ -191,6 +196,7 @@ stroke.thin = 1 stroke.medium = 1.5 stroke.thick = 2 stroke.heavy = 3 +stroke.focus = 2 stroke.dash = 4 stroke.dash_gap = 3 stroke.icon = 0.0729 @@ -245,11 +251,11 @@ motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false warning = accent.solid on surface.panel: 3.00 < 3.00 -warning = text.muted on state.pressed: 4.25 < 4.50 +warning = text.muted on state.pressed: 4.20 < 4.50 warning = text.faint on surface.background: 2.25 < 4.50 warning = text.faint on surface.panel: 2.59 < 4.50 warning = text.faint on surface.chrome: 2.59 < 4.50 warning = text.faint on surface.raised: 2.75 < 4.50 warning = text.faint on surface.sunken: 3.14 < 4.50 warning = text.faint on state.hover: 2.30 < 4.50 -warning = text.faint on state.pressed: 1.98 < 4.50 +warning = text.faint on state.pressed: 1.96 < 4.50 diff --git a/crates/theme/themes/vectorcraft-modern-medium.json b/crates/theme/themes/vectorcraft-modern-medium.json index 7c416f16e..77f15a2f5 100644 --- a/crates/theme/themes/vectorcraft-modern-medium.json +++ b/crates/theme/themes/vectorcraft-modern-medium.json @@ -29,12 +29,13 @@ "neutral": "#d3d8e0" }, "state.hover": "#c5ccd6", - "state.pressed": "#b6bec9", - "state.selected": "#e7c4bd", + "state.pressed": "#d4b5b6", + "state.selected": "#d4bbbd", "surface.background": "#c4cad4", "surface.canvas": "#b9c0cb", "surface.panel": "#d3d8e0", "surface.sunken": "#e9ecf1", + "text.disabled": "#7d8594", "text.faint": "#7d8594", "text.muted": "#4a5160", "text.normal": "#1b1f27" @@ -47,12 +48,13 @@ "line.control_edge": "#3a414e", "line.divider": "#323946", "state.hover": "#353c49", - "state.pressed": "#3d4553", - "state.selected": "#4a3236", + "state.pressed": "#633f3e", + "state.selected": "#573b3d", "surface.background": "#1b1f27", "surface.canvas": "#1e222a", "surface.panel": "#272c36", "surface.sunken": "#1a1e26", + "text.disabled": "#626b7a", "text.faint": "#626b7a", "text.muted": "#99a2b2", "text.normal": "#e4e9f1" diff --git a/crates/theme/themes/vectorcraft-modern.json b/crates/theme/themes/vectorcraft-modern.json index be251b3e4..98e9193bc 100644 --- a/crates/theme/themes/vectorcraft-modern.json +++ b/crates/theme/themes/vectorcraft-modern.json @@ -29,12 +29,13 @@ "neutral": "#f3f5f8" }, "state.hover": "#e3e7ed", - "state.pressed": "#d5dbe3", - "state.selected": "#f8d9d2", + "state.pressed": "#edcbc8", + "state.selected": "#eed2d0", "surface.background": "#e6e9ee", "surface.canvas": "#dfe3e9", "surface.panel": "#f3f5f8", "surface.sunken": "#ffffff", + "text.disabled": "#9aa1ad", "text.faint": "#9aa1ad", "text.muted": "#58606e", "text.normal": "#1b1f27" @@ -47,12 +48,13 @@ "line.control_edge": "#2c323e", "line.divider": "#232832", "state.hover": "#262b35", - "state.pressed": "#2f3541", - "state.selected": "#3a2a2c", + "state.pressed": "#593330", + "state.selected": "#4c2e2e", "surface.background": "#0b0d12", "surface.canvas": "#101217", "surface.panel": "#181b22", "surface.sunken": "#0f1116", + "text.disabled": "#5a6271", "text.faint": "#5a6271", "text.muted": "#969faf", "text.normal": "#dfe4ec" From 9c9e7ae80681509dad7d16eb83974d9899ef14cd Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 10:12:15 +0700 Subject: [PATCH 14/76] ui-contract: a focused stop in a layer that plays its exit loses the focus in the first pass of the exit --- crates/ui-contract/src/runtime/focus.rs | 2 +- crates/ui-contract/src/runtime/focus/nav.rs | 33 +++++++++++++----- crates/ui-contract/tests/it/runtime/focus.rs | 35 ++++++++++++++++++++ 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/crates/ui-contract/src/runtime/focus.rs b/crates/ui-contract/src/runtime/focus.rs index 46d12f0f5..7a46482fb 100644 --- a/crates/ui-contract/src/runtime/focus.rs +++ b/crates/ui-contract/src/runtime/focus.rs @@ -62,7 +62,7 @@ pub(crate) struct ScopeRec { /// The stop that held focus when the scope was first pushed, or for a scope that does not trap the stop focus last /// entered it from, which `restore` returns to. pub(crate) opener: Option, - /// The scope's layer is playing its exit: focus inside it already returns to the opener. + /// The scope's layer is playing its exit: focus inside it leaves at once, to the opener or nowhere. pub(crate) closing: bool, /// For a layer's scope: whether this is its first pass since the layer appeared, as the layer's memory says; /// none for other scopes, which are new after a gap of a frame. diff --git a/crates/ui-contract/src/runtime/focus/nav.rs b/crates/ui-contract/src/runtime/focus/nav.rs index 208816b99..8dce33400 100644 --- a/crates/ui-contract/src/runtime/focus/nav.rs +++ b/crates/ui-contract/src/runtime/focus/nav.rs @@ -571,29 +571,44 @@ impl State { Some(self.focus_stop(member)) } - /// The focus move when the focused stop was not registered this pass: a removed child of a collection row hands - /// focus back to the row, as Escape does; any other removed stop leaves focus nowhere, whatever stops are left - /// around it. + /// The focus move when the focused stop was not registered this pass, or only inside a layer that plays its exit + /// (`fading`): a removed child of a collection row hands focus back to the row, as Escape does; any other removed + /// stop leaves focus nowhere, whatever stops are left around it. fn removed_focus(&mut self, focused: Option) -> Option> { let root = focused?; let key = *self.focused.get(&root)?; - if self.stops.iter().any(|rec| rec.stop.key() == key) { + let live = |rec: &&StopRec| !self.fading(rec.scope); + if self.stops.iter().filter(live).any(|rec| rec.stop.key() == key) { return None; } - let gone = self.last_stops.iter().find(|rec| rec.stop.key() == key)?; + let gone = self.find_stop(key)?; let row = gone.stop.group.and_then(|group| self.group(group)).filter(|group| group.row); - let owner = row.and_then(|group| self.row_owner(&group)).filter(|owner| self.stops.iter().any(|rec| rec.stop.key() == owner.stop.key())); + let owner = + row.and_then(|group| self.row_owner(&group)).filter(|owner| self.stops.iter().filter(live).any(|rec| rec.stop.key() == owner.stop.key())); // A removed stop in an arena (an editor or control in a canvas body) hands focus back to the arena root's own // stop (the canvas). - let target = owner - .or_else(|| gone.stop.arena.and_then(|arena| self.stops.iter().find(|rec| rec.stop.id == arena && rec.stop.part.is_none()).cloned())); + let target = owner.or_else(|| { + gone.stop.arena.and_then(|arena| self.stops.iter().filter(live).find(|rec| rec.stop.id == arena && rec.stop.part.is_none()).cloned()) + }); Some(match target { Some(target) => self.focus_stop_from(target, FocusOrigin::Removal), None => vec![Act::Surrender(root)], }) } - /// The opener of a scope that went away while focus was inside it. + /// Whether the scope `scope` of this pass, or one around it, is a layer playing its exit: its stops take no focus. + fn fading(&self, scope: Option) -> bool { + let mut at = scope; + while let Some(rec) = at.and_then(|id| self.scopes.get(&id)) { + if rec.closing { + return true; + } + at = rec.parent; + } + false + } + + /// The opener of a scope that went away, or plays its exit, while focus was inside it. fn restored_focus(&self, focused: Option) -> Option { let root = focused?; let key = *self.focused.get(&root).unwrap_or(&(root, None)); diff --git a/crates/ui-contract/tests/it/runtime/focus.rs b/crates/ui-contract/tests/it/runtime/focus.rs index f6e80e4d0..f515edf15 100644 --- a/crates/ui-contract/tests/it/runtime/focus.rs +++ b/crates/ui-contract/tests/it/runtime/focus.rs @@ -74,3 +74,38 @@ fn a_request_in_a_press_pass_keeps_the_focus_from_the_press() { craft_ui::testing::pointer::click(&mut frames, at.get().center(), &mut show); assert_eq!(egui_focused(&frames.ctx), Some(editor), "the request of the press's pass holds"); } + +/// A popover opened with nothing focused closes while a stop in it holds the focus: from the first pass of its exit +/// fade, while its body still draws, the focus is nowhere, so a key pressed during the fade is not the stop's +/// (VectorCraft: Cmd+A after the Artboards flyout closed still selected the list's rows). +#[trial] +fn a_stop_in_a_layer_that_fades_out_loses_the_focus_at_once() { + use craft_behavior::overlay::{Align, Side}; + use craft_ui::contract::overlay::{Anchor, Place}; + use craft_ui::contract::{Mount, Overlay, Sizing}; + let seen = RefCell::new(Seen::default()); + let (close, drawn) = (Cell::new(false), Cell::new(0u32)); + let mut show = |ui: &mut Ui| { + let overlay = Overlay::popover().place(Place::anchored(Anchor::Rect(Rect::from_min_size(ORIGIN, VIEW)), Side::Below, Align::Start)); + Slab::new(ContainerProps::new().mount(Mount::Layer(overlay)).sizing(Sizing::Content)).id_salt("flyout").show(ui, |ui, cx| { + drawn.set(drawn.get() + 1); + if close.get() { + cx.request_close(); + } + Probe::new(&seen).label("List").id_salt("list").show(ui); + }); + }; + let mut frames = Frames::new(); + frames.idle(3, &mut show); + let list = seen.borrow().id.expect("the list ran"); + request(&frames.ctx, FocusTarget::Id(list)); + frames.idle(2, &mut show); + assert_eq!(craft_ui::testing::focus::egui_focused(&frames.ctx), Some(list), "the list took the focus"); + close.set(true); + frames.idle(1, &mut show); + close.set(false); + drawn.set(0); + frames.idle(1, &mut show); + assert!(drawn.get() > 0, "the layer still draws its fade"); + assert_eq!(craft_ui::testing::focus::egui_focused(&frames.ctx), None, "the fading layer's stop has no focus"); +} From ae722739ab984d9daa1f0f4c6cea1a6ea82f5cc2 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 03:28:05 +0000 Subject: [PATCH 15/76] 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 16/76] 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 17/76] 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 18/76] 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 19/76] 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 20/76] 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 21/76] 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 22/76] 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 23/76] 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 24/76] 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 48d19d281053524a4c794f69db88688d770ddbf4 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:08:24 +0700 Subject: [PATCH 25/76] ui-contract: a command fired from a button runs as a command; only a menu's or the palette's fire stands for the key a component claims --- crates/ui-canvas/tests/it/canvas/tool_keys.rs | 17 ++++++++++++++++- .../ui-contract/src/runtime/commands/board.rs | 9 +++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/crates/ui-canvas/tests/it/canvas/tool_keys.rs b/crates/ui-canvas/tests/it/canvas/tool_keys.rs index aab42724d..41eedb0ef 100644 --- a/crates/ui-canvas/tests/it/canvas/tool_keys.rs +++ b/crates/ui-canvas/tests/it/canvas/tool_keys.rs @@ -20,7 +20,7 @@ use craft_ui::dialog::Dialog; use craft_ui::display::Text; use craft_ui::popover::Popover; use craft_ui::primitives::Draw; -use craft_ui::runtime::commands::{self, EditCommands, FireSource}; +use craft_ui::runtime::commands::{self, CommandSet as _, EditCommands, FireSource}; use craft_ui::runtime::frame::take_output; use craft_ui::testing::access::Declared; use craft_ui::testing::focus::{AccessActionKind, key_release}; @@ -169,6 +169,21 @@ fn a_fired_command_whose_key_the_tool_claims_reaches_it_with_nothing_focused() { assert!(take_output(canvas.fixture().ctx()).fired.is_empty(), "no app command ran"); } +/// A command a button fires runs as the button's command, though the tool claims its key: only a menu's or the +/// palette's stands for the key (a toolbar's tool button finishes a gesture the tool holds the keyboard for). +#[trial] +fn a_pointer_fired_command_whose_key_the_tool_claims_runs_as_a_command() { + let mut canvas = ToolFixture::new("Document", Outline::new(true)); + canvas.fixture().settle(); + assert_eq!(canvas.fixture().focused(), None, "nothing is focused"); + take_output(canvas.fixture().ctx()); + assert!(commands::fire(canvas.fixture().ctx(), EditCommands::Delete, FireSource::Pointer), "Delete runs"); + canvas.fixture().settle(); + assert_eq!(canvas.tool().seen, [], "the tool got no Delete"); + let fired = take_output(canvas.fixture().ctx()).fired; + assert!(fired.iter().any(|fired| fired.command.id == EditCommands::Delete.id()), "the app's Delete ran: {fired:?}"); +} + /// A tool that takes every key the host offers it, and the lone Alt tap while `taps`. #[derive(Default)] struct Taker { diff --git a/crates/ui-contract/src/runtime/commands/board.rs b/crates/ui-contract/src/runtime/commands/board.rs index 7af58b6f8..c06b9a868 100644 --- a/crates/ui-contract/src/runtime/commands/board.rs +++ b/crates/ui-contract/src/runtime/commands/board.rs @@ -1731,10 +1731,11 @@ fn queue(ctx: &Context, fired: Fired) { observed.push(fired.command.clone()); } }); - // A command whose key the focused component claims reaches it as that key, as the key's press does; an edit command - // goes to the focused component that lists it; otherwise it goes to the instance that declared it or, with none, - // stays an app command. - if fired.phase != FirePhase::Release { + // A command run from a menu or the palette whose key the focused component claims reaches it as that key, as the + // key's press does (a button's is the button's command, even while a canvas gesture claims every key); an edit + // command goes to the focused component that lists it; otherwise it goes to the instance that declared it or, with + // none, stays an app command. + if fired.phase != FirePhase::Release && matches!(fired.source, FireSource::Menu | FireSource::Palette) { let chords: Vec = bindings(ctx, &fired.command).into_iter().filter(|binding| !binding.trigger.is_double()).map(|binding| binding.trigger.chord).collect(); if keys::fire_claimed(ctx, &chords) { From c71c3025ce1147ef6446204a73368be756011bf4 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:18:40 +0700 Subject: [PATCH 26/76] sections: HeaderStrength::Subheading, label text in the normal ink with no rule --- crates/ui-panels/src/sections/section.rs | 7 ++++--- crates/ui-panels/src/sections/section/stories.rs | 6 ++++++ crates/ui-panels/src/sections/title_row.rs | 4 ++++ crates/ui-panels/src/sections/title_row/stories.rs | 5 +++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/crates/ui-panels/src/sections/section.rs b/crates/ui-panels/src/sections/section.rs index c7b089b29..0ac544895 100644 --- a/crates/ui-panels/src/sections/section.rs +++ b/crates/ui-panels/src/sections/section.rs @@ -158,12 +158,13 @@ impl<'a> Section<'a> { self.props.header = Some(header); } - /// The header's weight: `Section` by default, under a rule; `Caption` for a quiet heading over a group of - /// controls, with no rule. + /// The header's weight: `Section` by default, under a rule; `Caption`, `Subheading` or `Overline` for a heading over + /// a group of controls, with no rule. #[must_use] pub fn strength(mut self, strength: HeaderStrength) -> Self { self.strength = strength; - self.update_header(|header| header.rule_above(!matches!(strength, HeaderStrength::Caption | HeaderStrength::Overline))); + let quiet = matches!(strength, HeaderStrength::Caption | HeaderStrength::Subheading | HeaderStrength::Overline); + self.update_header(|header| header.rule_above(!quiet)); self } diff --git a/crates/ui-panels/src/sections/section/stories.rs b/crates/ui-panels/src/sections/section/stories.rs index 4af0a2091..1425532bc 100644 --- a/crates/ui-panels/src/sections/section/stories.rs +++ b/crates/ui-panels/src/sections/section/stories.rs @@ -39,6 +39,12 @@ fn section_caption(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { shown.output.into() } +#[story(Section<'static>, covers = [], drive = Drive::Never)] +fn section_subheading(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + let shown = Section::fixed("Shape modes").strength(HeaderStrength::Subheading).show(ui, |ui, _| body(ui)); + shown.output.into() +} + #[story(Section<'static>, covers = [], drive = Drive::Never)] fn section_with_menu_and_reorder(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let shown = Section::new("Layers").open(data.bind("open", true)).actions([HeaderAction::Menu]).reorder(true).show(ui, |ui, _| body(ui)); diff --git a/crates/ui-panels/src/sections/title_row.rs b/crates/ui-panels/src/sections/title_row.rs index 953b466ab..a562ae85d 100644 --- a/crates/ui-panels/src/sections/title_row.rs +++ b/crates/ui-panels/src/sections/title_row.rs @@ -37,6 +37,9 @@ pub enum HeaderStrength { Heading, /// A quiet heading over a group of controls: label text, faint, as written, with no rule. Caption, + /// A sub-heading inside a section, over a group of its controls: label text in the normal ink, as written, with no + /// rule. + Subheading, /// A window's drag bar: one text row high (`size.row.text`), with label text; its action parts shrink to the row. Bar, /// A small overline over a group of controls: the caption role, faint, in capitals, with no rule. A document @@ -349,6 +352,7 @@ impl Component for TitleRow<'_> { HeaderStrength::Section => (cx.tokens.size.panel_header, TypeRole::BodyStrong, text.normal), HeaderStrength::Heading => (cx.tokens.size.panel_header, TypeRole::Heading, text.normal), HeaderStrength::Caption => (cx.control().height, TypeRole::Label, text.faint), + HeaderStrength::Subheading => (cx.control().height, TypeRole::Label, text.normal), HeaderStrength::Bar => (cx.tokens.size.row.text, TypeRole::Label, text.normal), HeaderStrength::Overline => (cx.control().height, TypeRole::Caption, text.faint), }; diff --git a/crates/ui-panels/src/sections/title_row/stories.rs b/crates/ui-panels/src/sections/title_row/stories.rs index 75ec6c848..43763072f 100644 --- a/crates/ui-panels/src/sections/title_row/stories.rs +++ b/crates/ui-panels/src/sections/title_row/stories.rs @@ -62,6 +62,11 @@ fn title_row_caption(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { TitleRow::new("Preset details").strength(HeaderStrength::Caption).show(ui).edit.into() } +#[story(TitleRow<'static>, covers = [], drive = Drive::Never)] +fn title_row_subheading(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + TitleRow::new("Ellipse Properties:").strength(HeaderStrength::Subheading).show(ui).edit.into() +} + #[story(TitleRow<'static>, covers = [], drive = Drive::Never)] fn title_row_bar(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { // A floating window's drag bar: no title, the Close action at the end. From 47691f10c2e4343dac13bf65e66192018d8d0581 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:18:43 +0700 Subject: [PATCH 27/76] Inspector: title_strength gives the title another weight than a section heading's --- .../src/patterns/panels/inspector.rs | 28 ++++++++++++++++--- .../src/patterns/panels/inspector/stories.rs | 15 +++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/crates/ui-patterns/src/patterns/panels/inspector.rs b/crates/ui-patterns/src/patterns/panels/inspector.rs index d4ede9326..3e80f5951 100644 --- a/crates/ui-patterns/src/patterns/panels/inspector.rs +++ b/crates/ui-patterns/src/patterns/panels/inspector.rs @@ -22,6 +22,9 @@ pub(crate) mod stories; /// - No target: the body is replaced by a centred notice, `empty` or "No properties", and the header shows the label. /// - The body can hold a `SectionStack` for sections the user reorders. /// - Padding: none of its own. An inspector is a dock body, docked or floating, and the dock group insets it. +/// - Title weight: a section heading's by default, as the headings of the sections under it; +/// [`title_strength`](Inspector::title_strength) gives another, such as `Caption` for a quiet kind line over the +/// sections. #[derive(crate::contract::Pattern)] pub struct Inspector<'a> { label: Label, @@ -30,6 +33,7 @@ pub struct Inspector<'a> { name: Option

, /// The header menu's command rows in place of the default ones ([`WorkspaceSwitcher::commands`]). commands: Option>, + look: SelectLook, } impl<'a, P> WorkspaceSwitcher<'a, P> { /// A switcher over `set`. pub fn new(set: &'a WorkspaceSet

) -> Self { - WorkspaceSwitcher { set, commands: None } + WorkspaceSwitcher { set, commands: None, look: SelectLook::Field } } /// The header menu's command rows, in place of the default `WorkspaceCommands` rows. @@ -58,14 +59,22 @@ impl<'a, P> WorkspaceSwitcher<'a, P> { self } + /// How the select looks and how wide it is: a field as wide as the widest workspace name by default, or a quiet box + /// as wide as the current one (`SelectLook::Quiet`). + pub fn look(mut self, look: SelectLook) -> Self { + self.look = look; + self + } + /// Shows the switcher and reports the workspace picked. pub fn show(self, ui: &mut Ui) -> WorkspaceSwitcherOutput { - let WorkspaceSwitcher { set, commands } = self; + let WorkspaceSwitcher { set, commands, look } = self; let words = Env::of(ui).words::(); let entries: Vec> = set.builtin.iter().chain(&set.saved).map(|w| Entry::new(w.id.clone(), w.name.clone())).collect(); let shown = Select::new(words.choose_workspace.clone(), Bind::given(set.current.clone()), &entries) .size(ControlSize::Sm) .sizing(Sizing::Content) + .look(look) .header_menu(|ui, _| match &commands { Some(rows) => { for row in rows { diff --git a/crates/ui-patterns/src/patterns/dock/switcher/stories.rs b/crates/ui-patterns/src/patterns/dock/switcher/stories.rs index 03e917f8b..4f894bb35 100644 --- a/crates/ui-patterns/src/patterns/dock/switcher/stories.rs +++ b/crates/ui-patterns/src/patterns/dock/switcher/stories.rs @@ -2,6 +2,7 @@ use super::WorkspaceSwitcher; use crate::docking::WorkspaceCommands; +use crate::pickers::SelectLook; use crate::testing::{Drive, StoryData, StoryOutput, story}; use craft_behavior::dock::{NamedWorkspace, Workspace, WorkspaceSet}; use egui::Ui; @@ -21,3 +22,13 @@ fn workspace_switcher_commands(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { let set = WorkspaceSet::new(vec![essentials]); WorkspaceSwitcher::new(&set).commands(vec![WorkspaceCommands::New.into(), WorkspaceCommands::Reset.into()]).show(ui).into() } + +/// A quiet switcher, as wide as the current workspace's name, beside a longer one: it sits on the panel surface with +/// no edge until it has focus. +#[story(WorkspaceSwitcher<'static, u32>, covers = [], drive = Drive::Never)] +fn workspace_switcher_quiet(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + let essentials = NamedWorkspace::new("essentials", "Essentials", Workspace::::default()); + let long = NamedWorkspace::new("print", "Print production and prepress", Workspace::::default()); + let set = WorkspaceSet::new(vec![essentials, long]); + WorkspaceSwitcher::new(&set).look(SelectLook::Quiet).show(ui).into() +} diff --git a/crates/ui-widgets/src/pickers/mod.rs b/crates/ui-widgets/src/pickers/mod.rs index 53b36a885..10533d9a5 100644 --- a/crates/ui-widgets/src/pickers/mod.rs +++ b/crates/ui-widgets/src/pickers/mod.rs @@ -22,7 +22,7 @@ pub use date::{ pub use dress::RowDress; pub use face::{FaceKind, SelectFace, SelectFaceStyle, toggle_on_key}; pub use icon_picker::{IconPicker, IconPickerGroup, IconPickerGroups, IconPickerItem, IconPickerOutput}; -pub use select::{Select, SelectStyle}; +pub use select::{Select, SelectLook, SelectStyle}; pub use tree_picker::{TreeEntry, TreePicker, TreePickerStyle}; pub use unit_select::{UnitSelect, UnitSelectOutput, UnitSelectStyle}; diff --git a/crates/ui-widgets/src/pickers/select.rs b/crates/ui-widgets/src/pickers/select.rs index 573c19c30..934fee1c8 100644 --- a/crates/ui-widgets/src/pickers/select.rs +++ b/crates/ui-widgets/src/pickers/select.rs @@ -24,13 +24,13 @@ use crate::primitives::ContentPainterCx; use crate::runtime::env::Label; use crate::runtime::focus::FocusMove; use crate::runtime::overlay::CloseReason; -use crate::style::{ComponentStyle, Ink, StyleCx, SurfaceLook, TextLook, TypeRole}; +use crate::style::{ComponentStyle, Ink, StyleCx, SurfaceKind, SurfaceLook, TextLook, TypeRole}; use craft_behavior::nav::{StepResult, ValueAxes, ValueSteps}; use craft_behavior::overlay::MinWidth; use craft_behavior::{ CancelReason, GesturePhase, HitLevel, HitPriority, IconId, Metrics, NavMove, PartKey, Selection, Sense, TypeAhead, Value, WheelPhase, wheel_step, }; -use craft_theme::{Stateful, States}; +use craft_theme::{Flags, Stateful, States}; use egui::{Rect, Ui, Vec2}; use std::borrow::Cow; @@ -56,6 +56,21 @@ pub struct SelectStyle { /// The face's placeholder text. #[style(text)] muted: TextLook, + /// The least width of the box: `size.length.short` for a quiet select, none for a field. + least_width: f32, +} + +/// How a select's closed box looks and how wide it is. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] +#[non_exhaustive] +pub enum SelectLook { + /// A field as wide as its widest entry, so its width stays whichever entry is picked. + #[default] + Field, + /// A quiet box on the panel surface with no edge until it has focus, as wide as the entry it shows (text, chevron + /// and padding): at least `size.length.short`, at most a field length, where a longer text elides. It changes + /// width with the pick (a workspace switcher at the end of an app bar). + Quiet, } /// The icon of the button in the popup header that opens the header menu. @@ -138,6 +153,10 @@ pub struct Select<'a, T: Value + 'static> { /// A button in the popup header opens a menu of these rows (a list's own options: sort, view). #[prop(func = "FnMut(&mut Ui, &mut BodyCx<'_>)")] header_menu: Option>, + /// How the closed box looks and how wide it is. + #[style_key] + #[prop] + look: SelectLook, } impl<'a, T: Value + 'static> Select<'a, T> { @@ -158,6 +177,7 @@ impl<'a, T: Value + 'static> Select<'a, T> { picture_only: false, preview: false, header_menu: None, + look: SelectLook::Field, } .label(label) } @@ -166,6 +186,21 @@ impl<'a, T: Value + 'static> Select<'a, T> { value.and_then(|value| self.entries.iter().position(|entry| entry.value() == Some(value))) } + /// The text the face shows for `value`, unresolved (none for a value that names no entry and no placeholder), and + /// whether it stands in for a pick: the `mixed` word for no value, or the placeholder. + fn shown<'s>(&'s self, value: Option<&T>, mixed: &'s Label) -> (Option<&'s Label>, bool) { + match self.position(value) { + Some(at) => (Some(self.entries[at].face_label()), false), + None if value.is_none() => (Some(mixed), true), + None => (self.placeholder.as_ref(), true), + } + } + + /// Whether the faces fit their text: a quiet select, and the selects `fits` names. + fn fits(&self, sizing: Option, in_bar: bool) -> bool { + self.look == SelectLook::Quiet || fits(sizing, in_bar) + } + /// The face of `text`, with the picture's room before it, or the picture alone, when the select has a picture. fn sized_face(&self, text: Label, picture: bool, fit: bool) -> SelectFace<'static> { let face = SelectFace::new(text).fit(fit); @@ -225,6 +260,17 @@ fn fits(sizing: Option, in_bar: bool) -> bool { } } +/// The closed box of a quiet select: the panel surface at the control radius, the hover fill under the pointer, and +/// an edge only in the focus colour while it has focus. +fn quiet(cx: &StyleCx<'_>) -> SurfaceLook { + let colors = &cx.tokens.color; + let (panel, hover) = (cx.color(colors.surface.panel), cx.color(colors.state.hover)); + let fill = Stateful::new(panel).off(States::new(panel, hover, hover, panel)); + // The edge takes the fill's colour in every state, so it shows only with focus. + let edge = fill.clone().when(Flags::FOCUSED, cx.color(colors.line.focus)); + SurfaceLook::new(fill).radius(cx.surface(SurfaceKind::Well).radius).border(edge, cx.tokens.stroke.thin).border_replaces_edge() +} + /// The stop a move over the closed field reaches: `stops` are the positions of the stepped entries and `from` the /// position of the current value. fn step(stops: &[usize], from: Option, mv: NavMove) -> Option { @@ -243,14 +289,19 @@ impl Component for Select<'_, T> { type Style = SelectStyle; type Output = EditResponse; - fn style(cx: &StyleCx<'_>, _: SelectStyleKey) -> SelectStyle { + fn style(cx: &StyleCx<'_>, key: SelectStyleKey) -> SelectStyle { let off = cx.color(cx.tokens.color.text.disabled); let (ink, muted) = (cx.ink(Ink::OnPanel), cx.color(cx.tokens.color.text.faint)); + let (surface, least_width) = match key.look { + SelectLook::Field => (cx.dropdown(), 0.0), + SelectLook::Quiet => (quiet(cx), cx.tokens.size.length.short), + }; SelectStyle { - surface: cx.dropdown(), + surface, metrics: Metrics::new(), text: TextLook::new(TypeRole::Body, Stateful::new(ink).off(States::new(ink, ink, ink, off))), muted: TextLook::new(TypeRole::Body, Stateful::new(muted).off(States::new(muted, muted, muted, off))), + least_width, } } @@ -260,13 +311,20 @@ impl Component for Select<'_, T> { } /// The widest face of an entry (its closed label, or its picture), the placeholder and the mixed word, so the field - /// keeps its size whichever is shown. + /// keeps its size whichever is shown; a quiet select's face as it shows now. At least the least width. fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { let mixed = cx.words::().mixed.clone(); - let entries = self.entries.iter().filter(|entry| entry.is_item()).map(|entry| (entry.face_label(), true)); - let texts = entries.chain(self.placeholder.iter().map(|text| (text, false))).chain(std::iter::once((&mixed, false))); - let fit = fits(cx.resolved.sizing(), cx.env.get::().0); - texts.map(|(text, picture)| cx.face(self.sized_face(cx.env.resolve(text), picture, fit))).fold(Vec2::ZERO, Vec2::max) + let fit = self.fits(cx.resolved.sizing(), cx.env.get::().0); + let face = |(text, picture): (&Label, bool)| cx.face(self.sized_face(cx.env.resolve(text), picture, fit)); + let size = if self.look == SelectLook::Quiet { + let (text, muted) = self.shown(cx.value(), &mixed); + face((text.unwrap_or(&Label::Empty), !muted)) + } else { + let entries = self.entries.iter().filter(|entry| entry.is_item()).map(|entry| (entry.face_label(), true)); + let texts = entries.chain(self.placeholder.iter().map(|text| (text, false))).chain(std::iter::once((&mixed, false))); + texts.map(face).fold(Vec2::ZERO, Vec2::max) + }; + Vec2::new(size.x.max(cx.style.least_width), size.y) } fn bind(&mut self) -> Option> { @@ -434,12 +492,10 @@ impl Component for Select<'_, T> { fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { let held = self.position(cx.value()); - let (text, muted) = match held { - Some(at) => (cx.env.resolve(self.entries[at].face_label()), false), - None if cx.value().is_none() => (cx.env.resolve(&cx.words::().mixed.clone()), true), - None => (self.placeholder.as_ref().map_or(Label::Empty, |text| cx.env.resolve(text)), true), - }; - let mut face = SelectFace::new(text).fit(fits(cx.resolved.sizing(), cx.env.get::().0)); + let mixed = cx.words::().mixed.clone(); + let (text, muted) = self.shown(cx.value(), &mixed); + let text = text.map_or(Label::Empty, |text| cx.env.resolve(text)); + let mut face = SelectFace::new(text).fit(self.fits(cx.resolved.sizing(), cx.env.get::().0)); if let Some(icon) = held.and_then(|at| self.entries[at].icon_spec()) { face = face.leading(icon.clone()); } diff --git a/crates/ui-widgets/tests/it/pickers/select_width.rs b/crates/ui-widgets/tests/it/pickers/select_width.rs index 094c7435c..a42d8d9fb 100644 --- a/crates/ui-widgets/tests/it/pickers/select_width.rs +++ b/crates/ui-widgets/tests/it/pickers/select_width.rs @@ -1,7 +1,7 @@ //! A select's width: the field width by default, its widest entry when it is sized to its content. use craft_ui::contract::{Bind, Entry, Props as _, Show as _, Sizing}; -use craft_ui::pickers::Select; +use craft_ui::pickers::{Select, SelectLook}; use craft_ui::testing::{Fixture, trial}; use std::cell::Cell; use std::rc::Rc; @@ -24,3 +24,22 @@ fn a_content_sized_select_fits_its_widest_entry() { let shown = fixture.texts().iter().find(|run| run.text == "Twelve" && fitted.contains_rect(run.rect)).map(|run| run.elided); assert_eq!(shown, Some(false), "the content-sized select shows its widest entry whole inside its box"); } + +/// The width of a quiet select showing entry `held` of a short and a long entry. +fn quiet_width(held: u8) -> f32 { + let width = Rc::new(Cell::new(0.0)); + let seen = width.clone(); + let mut fixture = Fixture::new(move |ui| { + let entries = [Entry::new(0u8, "Essentials"), Entry::new(1u8, "Print production and prepress")]; + seen.set(Select::new("Workspace", Bind::given(held), &entries).look(SelectLook::Quiet).show(ui).response.rect.width()); + }); + fixture.settle(); + width.get() +} + +/// A quiet select is as wide as the entry it shows, not its widest one: it widens with a longer pick. +#[trial] +fn a_quiet_select_fits_the_entry_it_shows() { + let (short, long) = (quiet_width(0), quiet_width(1)); + assert!(short > 0.0 && short < long, "the quiet select is narrower showing the short entry: {short} against {long}"); +} From 827141f831780d21227e90f9eecbc68ab12b6b89 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:36:53 +0700 Subject: [PATCH 35/76] color-ui: PaintChip::chip_size(PaintChipSize): Regular, Compact (a small well in a control-high slot) and Swatch (a third of a rail button, no popover) --- crates/color-ui/src/ui/mod.rs | 4 +- crates/color-ui/src/ui/paint_chip.rs | 81 ++++++++++++++++---- crates/color-ui/src/ui/paint_chip/stories.rs | 37 ++++++++- crates/color-ui/tests/it/paint_chip.rs | 23 +++++- 4 files changed, 125 insertions(+), 20 deletions(-) diff --git a/crates/color-ui/src/ui/mod.rs b/crates/color-ui/src/ui/mod.rs index 58a1ee6bf..54fb83783 100644 --- a/crates/color-ui/src/ui/mod.rs +++ b/crates/color-ui/src/ui/mod.rs @@ -64,8 +64,8 @@ pub use hud::{ColorHud, ColorHudOutput}; pub use info::{InfoColor, InfoMeasure, InfoPanel, InfoReadings, InfoWords}; pub use lut_picker::{LutChoice, LutPicker, LutPickerOutput, LutWords}; pub use paint_chip::{ - FillKind, GradientPreview, ImagePreview, Paint, PaintChip, PaintChipOutput, PaintEditor, PaintLink, PaintLinkKind, PaintList, PaintListEvent, - PaintListOptions, PaintListOutput, PaintRow, PaintWords, + FillKind, GradientPreview, ImagePreview, Paint, PaintChip, PaintChipOutput, PaintChipSize, PaintEditor, PaintLink, PaintLinkKind, PaintList, + PaintListEvent, PaintListOptions, PaintListOutput, PaintRow, PaintWords, }; pub use pair::{DropAccepts, PairWell, SwatchPair, SwatchPairOutput, Well}; pub use palette::{SwatchPalette, SwatchPaletteOutput}; diff --git a/crates/color-ui/src/ui/paint_chip.rs b/crates/color-ui/src/ui/paint_chip.rs index 4fab430da..8026cac9d 100644 --- a/crates/color-ui/src/ui/paint_chip.rs +++ b/crates/color-ui/src/ui/paint_chip.rs @@ -40,8 +40,10 @@ pub(crate) mod stories; pub use paint_list::{PaintLink, PaintLinkKind, PaintList, PaintListEvent, PaintListOptions, PaintListOutput, PaintRow}; -/// The chip is this many control heights wide. +/// A regular chip is this many control heights wide. const CHIP_WIDTH_IN_HEIGHTS: f32 = 1.5; +/// A swatch chip's side is a rail button's over this, so three to a row fill a one-column rail's cell. +const SWATCHES_PER_RAIL_BUTTON: f32 = 3.0; /// The most tiles a pattern chip draws; a tile so small that more would fit is drawn as one stretched image. const MAX_TILES: f32 = 4096.0; /// The No Color diagonal stops this many control heights short of the chip's edges. @@ -203,6 +205,21 @@ impl PaintEditor<'_, T> { } } +/// How large a [`PaintChip`] is; every size paints the same well. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] +#[non_exhaustive] +pub enum PaintChipSize { + /// A control high and 1.5 times as wide: a panel's or an options bar's chip. + #[default] + Regular, + /// A square well of `size.icon.md` in a slot a control high and `space.gap.item` wider than the well: a chip among + /// a bar's buttons, as a contextual task bar's Fill and Stroke. + Compact, + /// A square a third of `size.rail.button` on a side that opens no popover: a tool rail's Color, Gradient and None, + /// three to a row. + Swatch, +} + /// The style of a paint chip. #[derive(Clone, Debug, PartialEq, ComponentStyle)] #[non_exhaustive] @@ -211,8 +228,10 @@ pub struct PaintChipStyle { metrics: Metrics, #[style(focus)] focus: FocusLook, - /// The chip's height. - height: f32, + /// The well's size. + well: egui::Vec2, + /// The chip's size before the room of its mark: the well's, or for a compact chip the slot round it. + slot: egui::Vec2, /// The chip's corners. radius: egui::CornerRadius, /// The ring on the chip's outline. @@ -238,7 +257,7 @@ impl PaintChipStyle { none_fill: self.none_fill, none_mark: self.none_mark, edge: self.edge, - height: self.height, + height: self.well.y, radius: self.radius, ring, swatch: self.swatch.clone(), @@ -359,7 +378,8 @@ pub(crate) fn paint_well(ui: &mut PaintUi<'_>, cx: &Cx<'_, impl craft_ui::contra } } -/// A paint chip, a control high and 1.5 times as wide, with the room of its [`popup_mark`](Self::popup_mark) after it. +/// A paint chip as large as its [`chip_size`](Self::chip_size) (by default a control high and 1.5 times as wide), with the +/// room of its [`popup_mark`](Self::popup_mark) after it. /// /// - Look: a solid paint fills the chip over the checkerboard (alpha shows); a gradient is a /// start-to-end ramp through its stops; No Color is the field fill with a `status.bad` diagonal @@ -412,6 +432,10 @@ pub struct PaintChip<'a> { /// [`PopupMark::ToolGroup`] draws none. #[prop] popup_mark: PopupMark, + /// How large the chip is; [`PaintChipSize::Regular`] by default. + #[style_key] + #[prop] + chip_size: PaintChipSize, /// The request of the Color Picker… button, for this pass. pick_color: Option, /// The modifiers of this pass's click on a chip without a popover. @@ -439,6 +463,7 @@ impl<'a> PaintChip<'a> { popover: true, ring: false, popup_mark: PopupMark::None, + chip_size: PaintChipSize::Regular, pick_color: None, clicked: None, } @@ -503,6 +528,19 @@ impl<'a> PaintChip<'a> { if self.popup_mark == PopupMark::Menu { style.arrow_room } else { 0.0 } } + /// Whether a click opens the popover: on unless [`popover`](Self::popover) is off or the chip is a swatch. + fn opens(&self) -> bool { + self.popover && self.chip_size != PaintChipSize::Swatch + } + + /// The well and the mark's room in the chip's `rect`: a compact chip's well is centred in its slot, every other + /// fills it. + fn layout(&self, rect: Rect, style: &PaintChipStyle, rtl: bool) -> (Rect, Rect) { + let (slot, mark) = split_mark(rect, self.mark_room(style), rtl); + let well = if self.chip_size == PaintChipSize::Compact { Rect::from_center_size(slot.center(), style.well) } else { slot }; + (well, mark) + } + /// The paint a switch to `kind` sets. fn switched(&self, kind: FillKind, solid: Srgba) -> Paint { match kind { @@ -551,14 +589,29 @@ impl Component for PaintChip<'_> { type Style = PaintChipStyle; type Output = PaintChipOutput; - fn style(cx: &StyleCx<'_>, _: PaintChipStyleKey) -> PaintChipStyle { + fn style(cx: &StyleCx<'_>, key: PaintChipStyleKey) -> PaintChipStyle { let colors = &cx.tokens.color; let metrics = craft_ui::choice::SwatchMetrics::of(cx); let arrow = cx.tokens.size.icon.glyph_sm; + let (well, slot) = match key.chip_size { + PaintChipSize::Regular => { + let well = vec2(metrics.side * CHIP_WIDTH_IN_HEIGHTS, metrics.side); + (well, well) + } + PaintChipSize::Compact => { + let well = egui::Vec2::splat(cx.tokens.size.icon.md); + (well, vec2(well.x + cx.tokens.space.gap.item, metrics.side)) + } + PaintChipSize::Swatch => { + let well = egui::Vec2::splat(cx.tokens.size.rail.button / SWATCHES_PER_RAIL_BUTTON); + (well, well) + } + }; PaintChipStyle { metrics: Metrics::new(), focus: cx.focus_look(), - height: metrics.side, + well, + slot, radius: metrics.radius, edge: cx.color(colors.line.control_edge), none_fill: cx.color(colors.surface.sunken), @@ -575,13 +628,13 @@ impl Component for PaintChip<'_> { } fn measure(&mut self, cx: &craft_ui::contract::MeasureCx<'_, Self>) -> egui::Vec2 { - vec2(cx.style.height * CHIP_WIDTH_IN_HEIGHTS + self.mark_room(cx.style), cx.style.height) + cx.style.slot + vec2(self.mark_room(cx.style), 0.0) } fn parts(&mut self, rect: egui::Rect, cx: &mut PartsCx<'_, Self>) { - let (well, _) = split_mark(rect, self.mark_room(cx.style), cx.flow.is_rtl()); + let (well, _) = self.layout(rect, cx.style, cx.flow.is_rtl()); let part = cx.part(WELL, well); - if self.popover { + if self.opens() { let _ = part.toggles("picker"); } } @@ -597,7 +650,7 @@ impl Component for PaintChip<'_> { cx.memory::().0 = Some(color); } let activation = cx.activation().filter(|_: &Activation| cx.resolved.enabled); - if !self.popover { + if !self.opens() { self.clicked = activation.map(|activation| activation.mods); return; } @@ -613,7 +666,7 @@ impl Component for PaintChip<'_> { } fn overlay(&mut self, ui: &mut OverlayUi<'_>, cx: &mut Cx<'_, Self>) { - if !self.popover { + if !self.opens() { return; } let popup = cx.popup("picker"); @@ -724,13 +777,13 @@ impl Component for PaintChip<'_> { Some(paint) => access.value(value_text(&words, paint)), None => access.value(cx.words::().swatch_mixed.as_str()), }; - if self.popover { + if self.opens() { access.has_popup(PopupKind::Dialog); } } fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { - let (well, mark) = split_mark(cx.rect, self.mark_room(&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); diff --git a/crates/color-ui/src/ui/paint_chip/stories.rs b/crates/color-ui/src/ui/paint_chip/stories.rs index c0b31ab0f..ca6748ed0 100644 --- a/crates/color-ui/src/ui/paint_chip/stories.rs +++ b/crates/color-ui/src/ui/paint_chip/stories.rs @@ -1,13 +1,13 @@ //! Stories of the paint chip and the paint list. -use super::{GradientPreview, ImagePreview, Paint, PaintChip, PaintLink, PaintLinkKind, PaintList, PaintListOptions, PaintRow}; +use super::{GradientPreview, ImagePreview, Paint, PaintChip, PaintChipSize, PaintLink, PaintLinkKind, PaintList, PaintListOptions, PaintRow}; use craft_behavior::Mixed; use craft_theme::Srgba; use craft_ui::buttons::PopupMark; use craft_ui::contract::Role; use craft_ui::contract::{Bind, Props as _, Show as _, ShowContainer as _, Validity}; use craft_ui::display::{Shade, Text}; -use craft_ui::layout_components::Stack; +use craft_ui::layout_components::{Row, Stack}; use craft_ui::patterns::presets::PresetState; use craft_ui::primitives::FacePaint; use craft_ui::runtime::env::Message; @@ -106,6 +106,39 @@ fn paint_chip_menu_mark(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { first.unwrap_or_default() } +/// Compact Fill and Stroke chips in a row, as among a task bar's buttons: a small well in a control-high slot. +#[story(PaintChip<'static>, covers = [], drive = Drive::Never)] +fn paint_chip_compact(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let paints = data.value("paints", [Paint::Solid(BLUE), Paint::Solid(Srgba::rgb(0.1, 0.1, 0.1))]); + let mut first = None; + Row::new().show(ui, |ui, _| { + for (index, (label, paint)) in ["Fill", "Stroke"].into_iter().zip(paints.iter_mut()).enumerate() { + let shown = PaintChip::new(label, Bind::bound(paint), BLUE).ring(index == 1).chip_size(PaintChipSize::Compact).popover(false).show(ui); + if index == 0 { + first = Some(StoryOutput::from(shown)); + } + } + }); + first.unwrap_or_default() +} + +/// A tool rail's Color, Gradient and None as swatch chips, three in a row; a click opens nothing. +#[story(PaintChip<'static>, covers = [], drive = Drive::Never)] +fn paint_chip_swatches(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let gradient = GradientPreview::new(vec![(0.0, Srgba::rgb(1.0, 1.0, 1.0)), (1.0, Srgba::rgb(0.0, 0.0, 0.0))]); + let paints = data.value("paints", [Paint::Solid(BLUE), Paint::Gradient(gradient), Paint::None]); + let mut first = None; + Row::new().show(ui, |ui, _| { + for (index, (label, paint)) in ["Color", "Gradient", "None"].into_iter().zip(paints.iter_mut()).enumerate() { + let shown = PaintChip::new(label, Bind::bound(paint), BLUE).chip_size(PaintChipSize::Swatch).show(ui); + if index == 0 { + first = Some(StoryOutput::from(shown)); + } + } + }); + first.unwrap_or_default() +} + /// A gradient whose face is the host's painter: one coloured rect over the checker. #[story(PaintChip<'static>, covers = [], drive = Drive::Never)] fn paint_chip_gradient_face(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { diff --git a/crates/color-ui/tests/it/paint_chip.rs b/crates/color-ui/tests/it/paint_chip.rs index 08d98c860..ace5e8668 100644 --- a/crates/color-ui/tests/it/paint_chip.rs +++ b/crates/color-ui/tests/it/paint_chip.rs @@ -1,10 +1,12 @@ -//! `PaintChip`'s menu mark: the arrow after the well is part of the chip. +//! `PaintChip`'s menu mark, the arrow after the well that is part of the chip, and its swatch size. -use craft_color_ui::ui::{Paint, PaintChip}; +use craft_color_ui::ui::{Paint, PaintChip, PaintChipSize}; use craft_theme::Srgba; use craft_ui::buttons::PopupMark; use craft_ui::contract::{Bind, Role, Show as _}; use craft_ui::testing::{Fixture, trial}; +use std::cell::Cell; +use std::rc::Rc; /// A click on the menu mark, past the well, opens the chip's popover, as a click on the well does. #[trial] @@ -19,3 +21,20 @@ fn a_click_on_the_menu_mark_opens_the_popover() { fixture.click_at(egui::pos2(chip.rect.right() - 2.0, chip.rect.center().y)).idle(4); assert!(!fixture.by_role(Role::RADIO_BUTTON).is_empty(), "the popover's kind switch shows"); } + +/// A swatch chip opens no popover: a click reports its modifiers for the host's command. +#[trial] +fn a_click_on_a_swatch_chip_opens_nothing_and_reports_the_click() { + let clicked = Rc::new(Cell::new(false)); + let seen = Rc::clone(&clicked); + let mut fixture = Fixture::new(move |ui| { + let mut paint = Paint::None; + let out = PaintChip::new("None", Bind::bound(&mut paint), Srgba::BLACK).chip_size(PaintChipSize::Swatch).show(ui); + seen.set(seen.get() || out.clicked.is_some()); + }); + fixture.settle(); + let chip = fixture.by_role(Role::COLOR_WELL).first().copied().expect("the chip is a colour well"); + fixture.click(&chip).idle(4); + assert!(clicked.get(), "the click is reported"); + assert!(fixture.by_role(Role::RADIO_BUTTON).is_empty(), "no popover opens"); +} From 269ce9d696fd0a8bc1680edaeacfea7608c9bfc1 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:41:25 +0700 Subject: [PATCH 36/76] ui-widgets: NumberPrecision::Measured lets an app show whole percentages (60%) where the standard precision writes one decimal --- crates/ui-widgets/src/text/mod.rs | 4 +-- crates/ui-widgets/src/text/number.rs | 28 ++++++++++++++++--- crates/ui-widgets/src/text/number/stories.rs | 24 +++++++++++++++- .../ui-widgets/tests/it/text/number_look.rs | 26 +++++++++++++++-- 4 files changed, 72 insertions(+), 10 deletions(-) diff --git a/crates/ui-widgets/src/text/mod.rs b/crates/ui-widgets/src/text/mod.rs index 615cb624e..fd6daff8c 100644 --- a/crates/ui-widgets/src/text/mod.rs +++ b/crates/ui-widgets/src/text/mod.rs @@ -19,8 +19,8 @@ pub use chips::{ChipCodec, ChipField, ChipFieldOutput, ChipFieldStyle, ChipWords pub use hex::{HexCodec, HexField}; pub use linked::{LinkMode, LinkedFields, LinkedFieldsStyle, LinkedLayout, LinkedOutput, LinkedWords, follow_equal, follow_ratio, link_toggle}; pub use number::{ - NamedOr, NumberField, NumberLook, NumberName, NumberOutput, NumberPick, NumberStepper, NumberStyle, NumberValue, RangeAlert, StepArrows, - UnitPlacement, + NamedOr, NumberField, NumberLook, NumberName, NumberOutput, NumberPick, NumberPrecision, NumberStepper, NumberStyle, NumberValue, RangeAlert, + StepArrows, UnitPlacement, }; pub use selectable_text::{SelectableStyle, SelectableText}; pub use text_field::TextField; diff --git a/crates/ui-widgets/src/text/number.rs b/crates/ui-widgets/src/text/number.rs index 61cf25d9a..ea5794f99 100644 --- a/crates/ui-widgets/src/text/number.rs +++ b/crates/ui-widgets/src/text/number.rs @@ -85,6 +85,19 @@ pub enum NumberLook { Inline, } +/// How many decimals a number field without a codec, fixed or maximum decimals of its own shows. An app sets it once +/// at its root (`RootEnv::values`); the default is the standard precision. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum NumberPrecision { + /// A percentage reads one decimal, written in full ("100.0%"); other numbers their unit kind's decimals. + #[default] + Standard, + /// A percentage reads whole ("60%"): a drawing app's opacity and scale. + Measured, +} + /// The placeholder of a mixed field. const BLANK: &str = "\u{2014}"; @@ -207,6 +220,8 @@ pub struct NumberField<'a, V: NumberValue + 'static = Option> { scale: f64, /// The scope's look, read from the env in measure and parts. look: NumberLook, + /// The scope's precision, read from the env in measure and parts. + precision: NumberPrecision, options: TextOptions, positive_only: bool, scrub: bool, @@ -286,6 +301,7 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { lengths: None, scale: 1.0, look: NumberLook::Centred, + precision: NumberPrecision::Standard, options: TextOptions::default(), positive_only: false, scrub: false, @@ -344,10 +360,11 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { Rule::new(range.as_ref(), self.step) } - /// Reads the scope's look and a length field's scale from stored to shown from the env. The status bar's zoom + /// Reads the scope's look and precision and a length field's scale from stored to shown from the env. The status bar's zoom /// well keeps its own look. fn settle(&mut self, env: &EnvView<'_>) { self.look = if self.status_zoom { NumberLook::Centred } else { env.get() }; + self.precision = env.get(); if let Some(lengths) = self.lengths { self.scale = env.units().length_scale(lengths).unwrap_or(1.0); } @@ -423,7 +440,7 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { value.and_then(NumberValue::number).map(|stored| self.to_shown(stored)) } - /// Whether the field counts percent: it shows one decimal and its sign right after the number. + /// Whether the field counts percent: it writes its precision's decimals in full, its sign right after the number. fn is_percent(&self) -> bool { self.codec.is_none() && self.unit_kind == Some(UnitKind::Percent) } @@ -450,8 +467,11 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { fn shown_decimals(&self) -> RangeInclusive { match (&self.codec, self.fixed_decimals, self.max_decimals, self.unit_kind) { (Some(codec), _, _, _) => 0..=codec.decimals(), - // A percentage reads "100.0%": one decimal, written in full. - (None, _, _, Some(UnitKind::Percent)) => 1..=1, + // A percentage reads "100.0%": one decimal, written in full; whole at the measured precision. + (None, _, _, Some(UnitKind::Percent)) => match self.precision { + NumberPrecision::Standard => 1..=1, + NumberPrecision::Measured => 0..=0, + }, (None, Some(fixed), _, _) => fixed..=fixed, (None, None, Some(max), _) => 0..=max.min(12), (None, None, None, Some(kind)) => kind.decimals(), diff --git a/crates/ui-widgets/src/text/number/stories.rs b/crates/ui-widgets/src/text/number/stories.rs index a7945be36..c320ed8e3 100644 --- a/crates/ui-widgets/src/text/number/stories.rs +++ b/crates/ui-widgets/src/text/number/stories.rs @@ -1,6 +1,6 @@ //! Stories of `NumberField`. -use super::{NamedOr, NumberField, NumberLook, NumberName, NumberPick, StepArrows, UnitPlacement}; +use super::{NamedOr, NumberField, NumberLook, NumberName, NumberPick, NumberPrecision, StepArrows, UnitPlacement}; use crate::contract::{Bind, Entry, Props as _, Show as _, ShowContainer as _, Validity}; use crate::display::Text; use crate::form::{Field, FieldGroup}; @@ -255,3 +255,25 @@ fn focus_first(fixture: &mut Fixture) { fn number_field_inline_focused(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { inline_fields(ui, data) } + +/// Fields at the measured precision ([`NumberPrecision::Measured`]): a percentage reads whole. +#[story(NumberField<'static>, covers = [], drive = Drive::Never, title = "Measured precision")] +fn number_field_measured(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let out = with_env( + ui, + |overrides| { + overrides.values.set(NumberPrecision::Measured); + }, + |ui| { + FieldGroup::new("Measured precision") + .show(ui, |ui, _| { + let first = row("Percent").show(ui, |ui, _| { + NumberField::new("Opacity", data.bind("opacity", Some(60.0))).range(RANGE).unit_kind(UnitKind::Percent).show(ui).edit + }); + first.inner + }) + .inner + }, + ); + out.flatten().map(StoryOutput::from).unwrap_or_default() +} diff --git a/crates/ui-widgets/tests/it/text/number_look.rs b/crates/ui-widgets/tests/it/text/number_look.rs index d471bd542..8f6f20077 100644 --- a/crates/ui-widgets/tests/it/text/number_look.rs +++ b/crates/ui-widgets/tests/it/text/number_look.rs @@ -1,10 +1,11 @@ -//! The number field's inline look (`NumberLook::Inline`): the number and its unit are one run of the text part, so -//! editing reaches the unit's text as it reaches the number's. +//! The number field's looks an app sets at its root: the inline look (`NumberLook::Inline`), where the number and its +//! unit are one run of the text part, so editing reaches the unit's text as it reaches the number's; and the measured +//! precision (`NumberPrecision::Measured`). use craft_ui::contract::{Bind, Props as _, Show as _}; use craft_ui::runtime::env::{LengthUnits, UnitKind}; use craft_ui::testing::{Fixture, trial}; -use craft_ui::text::{NumberField, NumberLook}; +use craft_ui::text::{NumberField, NumberLook, NumberPrecision}; use egui::{Id, Key, Modifiers, Rect}; use std::cell::Cell; use std::rc::Rc; @@ -70,3 +71,22 @@ fn an_inline_field_edits_its_whole_run_and_commits_the_number() { fixture.settle(); assert_eq!(value.get(), Some(46.0), "the number edited inside the run commits without its unit"); } + +/// At the measured precision a percentage reads whole where the standard precision writes one decimal: the same +/// field shows fewer digits. +#[trial] +fn a_percent_at_the_measured_precision_reads_whole() { + let number = |precision: Option| { + let mut fixture = Fixture::new(|ui| { + NumberField::new("Opacity", Bind::bound(&mut Some(60.0f64))).unit_kind(UnitKind::Percent).range(0.0..=100.0).show(ui); + }); + if let Some(precision) = precision { + fixture.root_value(precision); + } + fixture.settle(); + fixture.texts().iter().map(|run| run.text.clone()).find(|text| text.starts_with("60")).unwrap_or_default() + }; + let (standard, measured) = (number(None), number(Some(NumberPrecision::Measured))); + assert!(standard.starts_with("60") && measured.starts_with("60"), "both show the value: {standard:?} {measured:?}"); + assert!(measured.len() < standard.len() && !measured.contains(['.', ',']), "the measured percent is whole: {measured:?}, standard {standard:?}"); +} From 361012ff9fc033e5b3fb30c515317e39abf3fa4b Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:56:14 +0700 Subject: [PATCH 37/76] ui-canvas: TaskBar::grip(TaskBarGrip::Bar), one rounded bar lit under the pointer and while the bar moves (BodyCx::moving) --- crates/ui-canvas/src/canvas_controls/mod.rs | 2 +- .../ui-canvas/src/canvas_controls/task_bar.rs | 106 ++++++++++++++++-- .../src/canvas_controls/task_bar/stories.rs | 35 +++++- .../tests/it/canvas_controls/task_bar.rs | 33 +++++- crates/ui-contract/src/contract/cx/body.rs | 7 ++ 5 files changed, 172 insertions(+), 11 deletions(-) diff --git a/crates/ui-canvas/src/canvas_controls/mod.rs b/crates/ui-canvas/src/canvas_controls/mod.rs index 58d1094cb..dcf80ef45 100644 --- a/crates/ui-canvas/src/canvas_controls/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/mod.rs @@ -27,7 +27,7 @@ pub use line_preview::{LineGuideStyle, StraightLinePreview}; pub use marquee::{Marquee, MarqueeLook, MarqueeShape, MarqueeStyle, Run}; pub use outline::{HoverMask, HoverOutline, HoverShape, OutlineStyle, SelectionOutline, SelectionOutlineLook, path_runs}; pub use pixel_grid::{GridSegment, PixelGrid, PixelGridStyle}; -pub use task_bar::{TaskBar, TaskBarCx, TaskBarDismiss, TaskBarKind, TaskBarOutput, TaskBarPlace}; +pub use task_bar::{TaskBar, TaskBarCx, TaskBarDismiss, TaskBarGrip, TaskBarKind, TaskBarOutput, TaskBarPlace}; // End of canvas-controls-b. // Brush overlays. diff --git a/crates/ui-canvas/src/canvas_controls/task_bar.rs b/crates/ui-canvas/src/canvas_controls/task_bar.rs index 81e96c0b4..0ffffab13 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar.rs @@ -10,18 +10,19 @@ use crate::buttons::IconButton; use crate::canvas::canvas_space; use crate::contract::overlay::{Anchor, Dismiss, Outside, Place, PlacementChange, PlacementKind}; use crate::contract::{ - Bind, BindMut, Common, Component, Container, ContainerProps, Cx, DragBand, HeaderRegion, Inner, Mount, NoValue, Outcome, Overlay, Pad, PopupKind, - Props as _, Role, Show as _, ShowContainer as _, Sizing, Trigger, + Bind, BindMut, Common, Component, Container, ContainerProps, Cx, DragBand, HeaderRegion, Inner, MeasureCx, Mount, NoValue, Outcome, Overlay, Pad, + PaintUi, PopupKind, Props as _, Role, Show as _, ShowContainer as _, Sizing, Styled as _, Trigger, }; use crate::display::{Divider, Icon}; use crate::menu::{Menu, MenuItem, PanelMenu, PanelRow}; -use crate::primitives::IconSpec; +use crate::primitives::{IconSpec, PaintShape}; use crate::runtime::env::{Env, Label}; use crate::runtime::overlay::CloseReason; -use crate::style::{ComponentStyle, StyleCx, SurfaceKind}; +use crate::style::{ComponentStyle, StyleColor, StyleCx, SurfaceKind, UiTokens}; use craft_behavior::kurbo::Point; use craft_behavior::overlay::{Align, PlaceRequest, Side}; use craft_behavior::{EditEvent, GesturePhase, IconId, Metrics, Mixed, Sense}; +use craft_theme::{Stateful, States}; use egui::{Pos2, Rect, Response, Ui, Vec2}; use std::sync::Arc; @@ -112,6 +113,9 @@ pub struct TaskBar<'a> { /// default. #[prop] compact: bool, + /// How the task bar's grip looks: the `grip` icon by default. + #[prop] + grip: TaskBarGrip, } /// What a bar hangs from: the screen bounds of document points, or the canvas view's top edge, aligned in reading @@ -136,6 +140,19 @@ pub enum TaskBarKind { Fixed, } +/// How the grip of a [`TaskBar`] looks. Either way the grip takes no press of its own: the bar's move band under it +/// moves the bar. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[non_exhaustive] +pub enum TaskBarGrip { + /// The `grip` icon. + #[default] + Icon, + /// One rounded upright bar, a value track's groove wide and the members' line less a row gap at each end tall, in + /// the control edge's line colour; muted text under the pointer and while the bar moves (VectorCraft's). + Bar, +} + /// What an outside press does to a [`TaskBar`]. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[non_exhaustive] @@ -257,6 +274,7 @@ impl<'a> TaskBar<'a> { keep_clear: None, dismiss: TaskBarDismiss::Close, compact: false, + grip: TaskBarGrip::Icon, } } @@ -283,6 +301,7 @@ impl<'a> TaskBar<'a> { keep_clear: None, dismiss: TaskBarDismiss::Close, compact: false, + grip: TaskBarGrip::Icon, } } @@ -311,7 +330,7 @@ impl<'a> TaskBar<'a> { /// Shows the bar inside `area`; `body` fills its members. pub fn show(self, ui: &mut Ui, area: Rect, mut body: impl FnMut(&mut Ui, &mut TaskBarCx<'_>) -> R) -> Inner { - let TaskBar { label, hang, mut place, rows, kind, side, align, keep_clear, dismiss, compact } = self; + let TaskBar { label, hang, mut place, rows, kind, side, align, keep_clear, dismiss, compact, grip: grip_look } = self; let side = side.unwrap_or(match kind { TaskBarKind::Task | TaskBarKind::Fixed => Side::Below, TaskBarKind::Selection => Side::Above, @@ -357,14 +376,21 @@ impl<'a> TaskBar<'a> { let mut menu = MoreMenu { words: Arc::clone(&words), offered: movable, pinned: held.pinned, rows, placed: false, pick: None }; // Only the task bar moves, so only it starts with the grip. let grip = movable.then(|| words.task_bar_move.clone()); - let mut shown = layer.show(ui, |ui, _| { + let mut shown = layer.show(ui, |ui, layer| { + let moving = layer.moving(); // The bar is the one surface: the grip is its first member, on the members' line inside its padding. let bar = Bar::new(Label::Empty, BarKind::Tool).surface(SurfaceKind::Floating).wrap(); // A compact bar takes a popup's smaller corners and lighter shadow, as production's small frame. let bar = if compact { bar.compact().surface(SurfaceKind::Popup) } else { bar }; bar.show(ui, |ui, _| { - if let Some(grip) = &grip { - let _ = Icon::new(IconSpec::svg(IconId::new("grip"))).label(grip.clone()).show(ui); + match (&grip, grip_look) { + (Some(grip), TaskBarGrip::Bar) => { + let _ = GripBar { common: Common::new(), moving }.label(grip.clone()).show(ui); + } + (Some(grip), _) => { + let _ = Icon::new(IconSpec::svg(IconId::new("grip"))).label(grip.clone()).show(ui); + } + (None, _) => {} } menu.placed = false; let inner = body(ui, &mut TaskBarCx { menu: &mut menu }); @@ -498,6 +524,70 @@ fn settled(held: TaskBarPlace, shown: Rect, area: Rect, moved: Option, pic next } +/// The style of the [`TaskBarGrip::Bar`] grip. +#[derive(Clone, Debug, PartialEq, ComponentStyle)] +#[non_exhaustive] +pub struct GripBarStyle { + #[style(metrics)] + metrics: Metrics, + /// The bar's width and height. + size: Vec2, + /// The bar's ink: the line colour at rest, muted text under the pointer. + ink: Stateful, + /// The ink while the bar moves. + moving: StyleColor, +} + +/// The [`TaskBarGrip::Bar`] grip: one rounded upright bar centred on the members' line. It senses only hover, so a +/// press on it reaches the layer's move band under it. +#[derive(crate::contract::Component, crate::contract::Props)] +#[component(unregistered)] +struct GripBar { + #[common] + common: Common, + /// The layer's move band is moving the bar this pass. + moving: bool, +} + +impl Component for GripBar { + const ROLE: Role = Role::IMAGE; + const PARTS: bool = false; + const INPUT: craft_behavior::Input = craft_behavior::Input::Display; + const SHOWS_LABEL: bool = false; + const OVERLAYS: bool = false; + type Style = GripBarStyle; + type Output = Response; + + fn style(cx: &StyleCx<'_>, _: GripBarStyleKey) -> GripBarStyle { + let colors = &cx.tokens.color; + let (rest, lit) = (cx.color(colors.line.control_edge), cx.color(colors.text.muted)); + GripBarStyle { + metrics: Metrics::new(), + size: Vec2::new(cx.tokens.size.groove, cx.control().height - 2.0 * cx.tokens.space.gap.row), + ink: Stateful::new(rest).off(States::new(rest, lit, lit, rest)), + moving: lit, + } + } + + fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { + cx.style.size + } + + fn sense(&self) -> Sense { + Sense::HOVER + } + + fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { + let ink = if self.moving { cx.style.moving } else { cx.resolve(&cx.style.ink) }; + let bar = Rect::from_center_size(cx.rect.center(), cx.style.size); + ui.draw().fill(&PaintShape::Rect(bar, UiTokens::corner(cx.style.size.x / 2.0)), ink); + } + + fn finish(self, cx: Cx<'_, Self>) -> Response { + cx.response.clone() + } +} + /// The style of the task bar's layer: the surface comes from the container. #[derive(Clone, Debug, Default, PartialEq, ComponentStyle)] #[non_exhaustive] diff --git a/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs b/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs index 9d357c830..2dd55983c 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs @@ -1,6 +1,6 @@ //! Stories of `TaskBar`. -use super::{TaskBar, TaskBarDismiss, TaskBarPlace}; +use super::{TaskBar, TaskBarDismiss, TaskBarGrip, TaskBarPlace}; use crate::buttons::{Button, IconButton}; use crate::canvas::testing::canvas_story::{StoryDocument, on_canvas}; use crate::contract::{Props as _, Show as _}; @@ -198,3 +198,36 @@ fn placed_and_pinned(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { .output }) } + +/// Points the pointer at the grip. +fn hover_grip(fixture: &mut Fixture) { + if let Some(grip) = fixture.by_label("Move bar") { + fixture.frame(vec![crate::testing::pointer::moved(grip.center())]); + fixture.idle(8); + } +} + +/// Drags the bar by its grip and holds it there, the button down. +fn drag_grip(fixture: &mut Fixture) { + if let Some(grip) = fixture.by_label("Move bar") { + fixture.drag_hold_at(grip.center(), egui::vec2(-40.0, 30.0)); + } +} + +/// The bar grip: one rounded upright bar in the line colour. +#[story(TaskBar<'static>, covers = [], drive = Drive::Never)] +fn bar_grip(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + configured(ui, data, &turned_frame(), None, |bar| bar.grip(TaskBarGrip::Bar)) +} + +/// The bar grip under the pointer: muted text. +#[story(TaskBar<'static>, covers = [], drive = Drive::Custom(hover_grip))] +fn bar_grip_hovered(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + configured(ui, data, &turned_frame(), None, |bar| bar.grip(TaskBarGrip::Bar)) +} + +/// The bar grip while the bar moves: muted text. +#[story(TaskBar<'static>, covers = [], drive = Drive::Custom(drag_grip))] +fn bar_grip_dragged(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + configured(ui, data, &turned_frame(), None, |bar| bar.grip(TaskBarGrip::Bar)) +} diff --git a/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs b/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs index 74405a091..8cb8ae5fa 100644 --- a/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs @@ -6,7 +6,7 @@ use craft_behavior::CanvasView; use craft_behavior::kurbo::{Point, Vec2 as DocVec}; use craft_behavior::overlay::{Align, Side}; use craft_ui::buttons::Button; -use craft_ui::canvas_controls::{TaskBar, TaskBarDismiss, TaskBarPlace}; +use craft_ui::canvas_controls::{TaskBar, TaskBarDismiss, TaskBarGrip, TaskBarPlace}; use craft_ui::contract::{Bind, Show as _}; use craft_ui::menu::PanelRow; use craft_ui::runtime::commands::{CommandRef, EditCommands}; @@ -523,3 +523,34 @@ fn a_compact_task_bar_is_smaller_and_shows_every_member_whole() { assert!(button.is_positive() && compact.expand(SLACK).contains_rect(button), "each member shows whole in {compact:?}: {button:?}"); } } + +/// The fill of the bar grip painted inside `grip` among `shapes`. +fn grip_ink(shapes: &[egui::Shape], grip: Rect) -> Option { + shapes.iter().find_map(|shape| match shape { + egui::Shape::Rect(rect) if grip.contains_rect(rect.rect) => Some(rect.fill), + _ => None, + }) +} + +/// The bar grip lights under the pointer and while the bar moves, and goes back to its rest ink after the drop. +#[trial] +fn the_bar_grip_lights_under_the_pointer_and_while_the_bar_moves() { + let scene = scene(); + let mut fixture = fixture_with(&scene, |bar| bar.grip(TaskBarGrip::Bar)); + fixture.settle(); + let grip = fixture.by_label("Move bar").expect("the grip is named"); + let rest = grip_ink(&fixture.frame_shapes(), grip.rect).expect("the grip paints its bar"); + + fixture.frame(vec![moved(grip.center())]).idle(8); + let hovered = grip_ink(&fixture.frame_shapes(), grip.rect); + assert!(hovered.is_some_and(|ink| ink != rest), "the grip lights under the pointer: {hovered:?} against {rest:?}"); + + let by = Vec2::new(-60.0, 30.0); + fixture.drag_hold_at(grip.center(), by); + let moving = grip_ink(&fixture.frame_shapes(), grip.rect.translate(by)); + assert!(moving.is_some_and(|ink| ink != rest), "the grip is lit while the bar moves: {moving:?} against {rest:?}"); + + fixture.release_at(grip.center() + by).frame(vec![moved(grip.center() + by + Vec2::new(0.0, 200.0))]).idle(8); + let dropped = fixture.by_label("Move bar").expect("the grip is named"); + assert_eq!(grip_ink(&fixture.frame_shapes(), dropped.rect), Some(rest), "the grip is back to rest once dropped and left"); +} diff --git a/crates/ui-contract/src/contract/cx/body.rs b/crates/ui-contract/src/contract/cx/body.rs index ac8624c33..470504255 100644 --- a/crates/ui-contract/src/contract/cx/body.rs +++ b/crates/ui-contract/src/contract/cx/body.rs @@ -84,6 +84,13 @@ impl<'a> BodyCx<'a> { self.field_message.clone() } + /// Whether a drag of the container's move band (`DragBand::Move`) moves its layer in this pass, from the pass the + /// drag starts to the one before its release: a grip in the body shows the move. + pub fn moving(&self) -> bool { + let band = crate::primitives::sensing::part_press(self.memory.ctx(), self.resolved.id, crate::contract::MOVE_BAND.into()); + matches!(band.press.phase, craft_behavior::PressPhase::DragStart { .. } | craft_behavior::PressPhase::Drag { .. }) + } + /// Whether the body is open. pub fn is_open(&self) -> bool { *self.open From 0a31be98c38305894ece00016e9589656a26c11b Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:56:16 +0700 Subject: [PATCH 38/76] ui-widgets: NumberPrecision::Measured shows a length to a thousandth of a point and a ten-thousandth of the larger units (357.114 pt) --- crates/ui-widgets/src/text/number.rs | 11 ++++++-- crates/ui-widgets/src/text/number/stories.rs | 7 ++++- .../ui-widgets/tests/it/text/number_look.rs | 26 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/crates/ui-widgets/src/text/number.rs b/crates/ui-widgets/src/text/number.rs index ea5794f99..464009b74 100644 --- a/crates/ui-widgets/src/text/number.rs +++ b/crates/ui-widgets/src/text/number.rs @@ -94,7 +94,9 @@ pub enum NumberPrecision { /// A percentage reads one decimal, written in full ("100.0%"); other numbers their unit kind's decimals. #[default] Standard, - /// A percentage reads whole ("60%"): a drawing app's opacity and scale. + /// A percentage reads whole ("60%"), and a length field to a thousandth of points, pixels, picas, Q and Ha and a + /// ten-thousandth of the larger units, without trailing zeros ("357.114 pt", "8.2677 in"): a drawing app's + /// positions and sizes. Measured, } @@ -474,7 +476,12 @@ impl<'a, V: NumberValue + 'static> NumberField<'a, V> { }, (None, Some(fixed), _, _) => fixed..=fixed, (None, None, Some(max), _) => 0..=max.min(12), - (None, None, None, Some(kind)) => kind.decimals(), + (None, None, None, Some(kind)) => match (self.precision, self.lengths) { + (NumberPrecision::Measured, Some(_)) => { + 0..=if matches!(kind, UnitKind::Points | UnitKind::Pixels | UnitKind::Picas | UnitKind::Q | UnitKind::Ha) { 3 } else { 4 } + } + _ => kind.decimals(), + }, (None, None, None, None) => 0..=DEFAULT_DECIMALS, } } diff --git a/crates/ui-widgets/src/text/number/stories.rs b/crates/ui-widgets/src/text/number/stories.rs index c320ed8e3..875809f73 100644 --- a/crates/ui-widgets/src/text/number/stories.rs +++ b/crates/ui-widgets/src/text/number/stories.rs @@ -256,7 +256,8 @@ fn number_field_inline_focused(ui: &mut Ui, data: &mut StoryData) -> StoryOutput inline_fields(ui, data) } -/// Fields at the measured precision ([`NumberPrecision::Measured`]): a percentage reads whole. +/// Fields at the measured precision ([`NumberPrecision::Measured`]): a percentage reads whole, a length to a thousandth +/// of a point. #[story(NumberField<'static>, covers = [], drive = Drive::Never, title = "Measured precision")] fn number_field_measured(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let out = with_env( @@ -270,6 +271,10 @@ fn number_field_measured(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let first = row("Percent").show(ui, |ui, _| { NumberField::new("Opacity", data.bind("opacity", Some(60.0))).range(RANGE).unit_kind(UnitKind::Percent).show(ui).edit }); + row("Length").show(ui, |ui, _| { + let lengths = LengthUnits::new(UnitKind::Points, UnitKind::Points, 72.0); + NumberField::length("X", data.bind("x", Some(357.1138)), lengths).show(ui); + }); first.inner }) .inner diff --git a/crates/ui-widgets/tests/it/text/number_look.rs b/crates/ui-widgets/tests/it/text/number_look.rs index 8f6f20077..d05fdadef 100644 --- a/crates/ui-widgets/tests/it/text/number_look.rs +++ b/crates/ui-widgets/tests/it/text/number_look.rs @@ -90,3 +90,29 @@ fn a_percent_at_the_measured_precision_reads_whole() { assert!(standard.starts_with("60") && measured.starts_with("60"), "both show the value: {standard:?} {measured:?}"); assert!(measured.len() < standard.len() && !measured.contains(['.', ',']), "the measured percent is whole: {measured:?}, standard {standard:?}"); } + +/// At the measured precision a length shows more of its decimals than the standard precision, and none past the +/// value's own ("720", not "720.000"). +#[trial] +fn a_length_at_the_measured_precision_shows_finer_decimals() { + let number = |value: f64, precision: Option| { + let mut fixture = Fixture::new(move |ui| { + let lengths = LengthUnits::new(UnitKind::Points, UnitKind::Points, 72.0); + NumberField::length("X", Bind::bound(&mut Some(value)), lengths).show(ui); + }); + if let Some(precision) = precision { + fixture.root_value(precision); + } + fixture.settle(); + let tree = fixture.tree(); + tree.keys() + .into_iter() + .find_map(|key| tree.value_of(key).filter(|text| text.starts_with(&value.trunc().to_string())).map(str::to_owned)) + .unwrap_or_default() + }; + let (standard, measured) = (number(357.1138, None), number(357.1138, Some(NumberPrecision::Measured))); + let digits = |text: &str| text.chars().filter(char::is_ascii_digit).count(); + assert!(digits(&measured) > digits(&standard), "the measured length shows more decimals: {measured:?}, standard {standard:?}"); + let whole = number(720.0, Some(NumberPrecision::Measured)); + assert!(!whole.is_empty() && whole == number(720.0, None), "a whole length shows no trailing zeros: {whole:?}"); +} From ddd2e3c4e6777210e7c0d9d580b1506c4c252cf8 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:57:13 +0700 Subject: [PATCH 39/76] Filled push buttons: an Emphasis::Filled look on a new surface.control token, and PushButtonLook for an app's default A filled neutral tile with no edge at rest takes the hover fill and the control edge under the pointer and the pressed fill with the accent edge under the press; disabled, it dims as a solid one does. surface.control follows state.hover unless pinned, so only the VectorCraft Modern themes, which pin production's button fills, change. An app sets PushButtonLook::Filled at its root to make it the default of its push and split buttons; a ribbon keeps its flat look and toggles keep the outline. --- crates/theme/src/tokens/color.rs | 6 ++ crates/theme/src/values.rs | 3 + crates/theme/src/variant.rs | 12 ++++ .../tokens/adwaita-dark-high-comfortable.txt | 1 + .../tokens/adwaita-dark-high-compact.txt | 1 + .../adwaita-dark-standard-comfortable.txt | 2 + .../tokens/adwaita-dark-standard-compact.txt | 2 + .../tokens/adwaita-light-high-comfortable.txt | 1 + .../tokens/adwaita-light-high-compact.txt | 1 + .../adwaita-light-standard-comfortable.txt | 2 + .../tokens/adwaita-light-standard-compact.txt | 2 + .../tokens/artcraft-dark-high-comfortable.txt | 1 + .../tokens/artcraft-dark-high-compact.txt | 1 + .../artcraft-dark-standard-comfortable.txt | 3 + .../tokens/artcraft-dark-standard-compact.txt | 3 + .../artcraft-light-high-comfortable.txt | 1 + .../tokens/artcraft-light-high-compact.txt | 1 + .../artcraft-light-standard-comfortable.txt | 2 + .../artcraft-light-standard-compact.txt | 2 + .../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 | 2 + .../tokens/classic-light-standard-compact.txt | 2 + .../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 | 2 + .../tokens/pro-dark-standard-comfortable.txt | 2 + .../tokens/pro-dark-standard-compact.txt | 2 + .../pro-light-gray-light-high-comfortable.txt | 1 + .../pro-light-gray-light-high-compact.txt | 1 + ...-light-gray-light-standard-comfortable.txt | 2 + .../pro-light-gray-light-standard-compact.txt | 2 + .../tokens/pro-light-high-comfortable.txt | 1 + .../dumps/tokens/pro-light-high-compact.txt | 1 + .../tokens/pro-light-standard-comfortable.txt | 2 + .../tokens/pro-light-standard-compact.txt | 2 + .../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 | 4 ++ .../solarized-dark-dark-standard-compact.txt | 4 ++ .../tokens/studio-dark-high-comfortable.txt | 1 + .../dumps/tokens/studio-dark-high-compact.txt | 1 + .../studio-dark-standard-comfortable.txt | 2 + .../tokens/studio-dark-standard-compact.txt | 2 + .../tokens/studio-light-high-comfortable.txt | 1 + .../tokens/studio-light-high-compact.txt | 1 + .../studio-light-standard-comfortable.txt | 2 + .../tokens/studio-light-standard-compact.txt | 2 + ...ctorcraft-modern-dark-high-comfortable.txt | 1 + .../vectorcraft-modern-dark-high-compact.txt | 1 + ...craft-modern-dark-standard-comfortable.txt | 2 + ...ctorcraft-modern-dark-standard-compact.txt | 2 + ...torcraft-modern-light-high-comfortable.txt | 1 + .../vectorcraft-modern-light-high-compact.txt | 1 + ...raft-modern-light-standard-comfortable.txt | 2 + ...torcraft-modern-light-standard-compact.txt | 2 + ...ft-modern-medium-dark-high-comfortable.txt | 1 + ...rcraft-modern-medium-dark-high-compact.txt | 1 + ...odern-medium-dark-standard-comfortable.txt | 3 + ...ft-modern-medium-dark-standard-compact.txt | 3 + ...t-modern-medium-light-high-comfortable.txt | 1 + ...craft-modern-medium-light-high-compact.txt | 1 + ...dern-medium-light-standard-comfortable.txt | 2 + ...t-modern-medium-light-standard-compact.txt | 2 + .../themes/vectorcraft-modern-medium.json | 2 + crates/theme/themes/vectorcraft-modern.json | 2 + crates/ui-widgets/src/buttons/button.rs | 4 +- crates/ui-widgets/src/buttons/mod.rs | 28 ++++++++- crates/ui-widgets/src/buttons/split_button.rs | 4 +- crates/ui-widgets/src/buttons/stories.rs | 28 ++++++++- crates/ui-widgets/tests/it/buttons.rs | 63 ++++++++++++++++++- docs/suite-themes.md | 2 +- 96 files changed, 268 insertions(+), 10 deletions(-) diff --git a/crates/theme/src/tokens/color.rs b/crates/theme/src/tokens/color.rs index 276475311..2ee9247ec 100644 --- a/crates/theme/src/tokens/color.rs +++ b/crates/theme/src/tokens/color.rs @@ -64,6 +64,9 @@ pub struct SurfaceColors { pub raised: Rgba, /// Fields and wells. pub sunken: Rgba, + /// The resting fill of a filled control (`Emphasis::Filled`): a neutral tile with no edge. Follows + /// `state.hover` unless pinned. + pub control: Rgba, /// The face of a knob that rides on a track: slider and switch thumbs. Light in both modes. pub knob: Rgba, /// Translucent cover behind modal surfaces. @@ -321,6 +324,7 @@ impl ColorTokens { chrome: c, raised: c, sunken: c, + control: c, knob: c, scrim: c, inverse: c, @@ -438,6 +442,8 @@ color_tokens! { SurfaceRaised = "surface.raised" => surface.raised; /// `surface.sunken` SurfaceSunken = "surface.sunken" => surface.sunken; + /// `surface.control` + SurfaceControl = "surface.control" => surface.control; /// `surface.knob` SurfaceKnob = "surface.knob" => surface.knob; /// `surface.scrim` diff --git a/crates/theme/src/values.rs b/crates/theme/src/values.rs index e6feee4ff..0debc6f30 100644 --- a/crates/theme/src/values.rs +++ b/crates/theme/src/values.rs @@ -201,6 +201,8 @@ pub(super) fn source(token: ColorToken, mode: Mode) -> ColorSource { T::SurfaceChrome => Same(T::SurfacePanel), T::SurfaceRaised => Anchored(pick(4, 1)), T::SurfaceSunken => Anchored(1), + // A filled tile rests on the theme's own hover fill, so the pointer adds only its edge. + T::SurfaceControl => Same(T::StateHover), // Near white in both modes (dark: about 236/255), as macOS, GNOME and PhotoCraft knobs. A // knob face is not a background grey, so it stays on the curve. T::SurfaceKnob => Neutral(pick(12, 1)), @@ -385,6 +387,7 @@ const TEXT_BGS: &[Bg] = &[ Token(T::SurfaceChrome), Token(T::SurfaceRaised), Token(T::SurfaceSunken), + Token(T::SurfaceControl), Token(T::StateHover), Token(T::StatePressed), ]; diff --git a/crates/theme/src/variant.rs b/crates/theme/src/variant.rs index fb9d58b0d..a9823c4dd 100644 --- a/crates/theme/src/variant.rs +++ b/crates/theme/src/variant.rs @@ -19,6 +19,8 @@ pub enum Emphasis { Outline, /// No fill or edge until a state fills it. Ghost, + /// A neutral tile (`surface.control`) with no edge at rest; the pointer and the press fill it by state and edge it. + Filled, } /// What a variant says about its subject. The one tone type of the component layer: messages, notices, badges and @@ -237,6 +239,16 @@ impl VariantLook { VariantLook::new(state_fill, text(fg)).muted(muted).edge(States::new(edge, lit, lit, c.line.divider)).radius(button) } Emphasis::Ghost => VariantLook::new(state_fill, text(fg)).muted(muted).radius(button).edge(flat(clear)), + // A neutral tile takes the control edge under the pointer and the accent's under the press; a toned one keeps + // its edge. Disabled, it dims as a solid one does. + Emphasis::Filled => { + let (lit, pressed) = if tone == Tone::Neutral { (c.line.control_edge, c.accent.border) } else { (edge, edge) }; + let dimmed = crate::derive::mix(c.surface.control, c.state.disabled_fill, DISABLED_SOLID_DIM); + VariantLook::new(States::new(c.surface.control, c.state.hover, c.state.pressed, dimmed), text(fg)) + .muted(muted) + .edge(States::new(clear, lit, pressed, clear)) + .radius(button) + } } } } 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 5d1a23d50..1f9eae3ae 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #36363aff surface.chrome = #2e2e32ff surface.raised = #404044ff surface.sunken = #404044ff +surface.control = #48484cff surface.knob = #ebebedff surface.scrim = #00000080 surface.inverse = #ebebedff 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 fe791bffa..9a8ebf148 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #36363aff surface.chrome = #2e2e32ff surface.raised = #404044ff surface.sunken = #404044ff +surface.control = #48484cff surface.knob = #ebebedff surface.scrim = #00000080 surface.inverse = #ebebedff 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 af3f43df8..fd2c4f30a 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #36363aff surface.chrome = #2e2e32ff surface.raised = #39393eff surface.sunken = #404044ff +surface.control = #48484cff surface.knob = #ebebedff surface.scrim = #00000080 surface.inverse = #ebebedff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.83 < 4.50 warning = text.faint on surface.chrome: 4.30 < 4.50 warning = text.faint on surface.raised: 3.65 < 4.50 warning = text.faint on surface.sunken: 3.28 < 4.50 +warning = text.faint on surface.control: 2.90 < 4.50 warning = text.faint on state.hover: 2.90 < 4.50 warning = text.faint on state.pressed: 2.32 < 4.50 warning = text.on_accent on accent.solid: 3.77 < 4.50 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 6488a6712..4b74d37ce 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-dark-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #36363aff surface.chrome = #2e2e32ff surface.raised = #39393eff surface.sunken = #404044ff +surface.control = #48484cff surface.knob = #ebebedff surface.scrim = #00000080 surface.inverse = #ebebedff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.83 < 4.50 warning = text.faint on surface.chrome: 4.30 < 4.50 warning = text.faint on surface.raised: 3.65 < 4.50 warning = text.faint on surface.sunken: 3.28 < 4.50 +warning = text.faint on surface.control: 2.90 < 4.50 warning = text.faint on state.hover: 2.90 < 4.50 warning = text.faint on state.pressed: 2.32 < 4.50 warning = text.on_accent on accent.solid: 3.77 < 4.50 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 2b6cd2593..a39cdf930 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #ffffffff surface.chrome = #ffffffff surface.raised = #ffffffff surface.sunken = #ebebedff +surface.control = #e2e2e5ff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262628ff 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 e5a195684..f9a552dc9 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #ffffffff surface.chrome = #ffffffff surface.raised = #ffffffff surface.sunken = #ebebedff +surface.control = #e2e2e5ff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262628ff 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 5070d3350..dc24eaed8 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #ffffffff surface.chrome = #ffffffff surface.raised = #ffffffff surface.sunken = #ebebedff +surface.control = #e2e2e5ff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262628ff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 2.77 < 4.50 warning = text.faint on surface.chrome: 2.77 < 4.50 warning = text.faint on surface.raised: 2.77 < 4.50 warning = text.faint on surface.sunken: 2.32 < 4.50 +warning = text.faint on surface.control: 2.14 < 4.50 warning = text.faint on state.hover: 2.14 < 4.50 warning = text.faint on state.pressed: 1.87 < 4.50 warning = text.on_accent on accent.solid: 3.77 < 4.50 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 842e67f43..2db9b4c30 100644 --- a/crates/theme/tests/dumps/tokens/adwaita-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/adwaita-light-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #ffffffff surface.chrome = #ffffffff surface.raised = #ffffffff surface.sunken = #ebebedff +surface.control = #e2e2e5ff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262628ff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 2.77 < 4.50 warning = text.faint on surface.chrome: 2.77 < 4.50 warning = text.faint on surface.raised: 2.77 < 4.50 warning = text.faint on surface.sunken: 2.32 < 4.50 +warning = text.faint on surface.control: 2.14 < 4.50 warning = text.faint on state.hover: 2.14 < 4.50 warning = text.faint on state.pressed: 1.87 < 4.50 warning = text.on_accent on accent.solid: 3.77 < 4.50 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 f0eecfcea..db47b9019 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #535353ff surface.chrome = #535353ff surface.raised = #595959ff surface.sunken = #454545ff +surface.control = #595959ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff 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 2d3c6d01c..a8e7f44a2 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #535353ff surface.chrome = #535353ff surface.raised = #595959ff surface.sunken = #454545ff +surface.control = #595959ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff 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 ce055072c..469410cc8 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #535353ff surface.chrome = #535353ff surface.raised = #5c5c5cff surface.sunken = #454545ff +surface.control = #626262ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff @@ -254,6 +255,7 @@ warning = accent.solid on surface.panel: 2.30 < 3.00 warning = accent.solid on surface.raised: 2.00 < 3.00 warning = accent.solid on surface.sunken: 2.87 < 3.00 warning = text.normal on state.pressed: 4.27 < 4.50 +warning = text.muted on surface.control: 4.12 < 4.50 warning = text.muted on state.hover: 4.12 < 4.50 warning = text.muted on state.pressed: 3.34 < 4.50 warning = text.faint on surface.background: 3.84 < 4.50 @@ -261,6 +263,7 @@ warning = text.faint on surface.panel: 2.94 < 4.50 warning = text.faint on surface.chrome: 2.94 < 4.50 warning = text.faint on surface.raised: 2.56 < 4.50 warning = text.faint on surface.sunken: 3.67 < 4.50 +warning = text.faint on surface.control: 2.33 < 4.50 warning = text.faint on state.hover: 2.33 < 4.50 warning = text.faint on state.pressed: 1.89 < 4.50 warning = text.on_accent on accent.solid: 3.34 < 4.50 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 a2b9e32bf..98a7dd462 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-dark-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #535353ff surface.chrome = #535353ff surface.raised = #5c5c5cff surface.sunken = #454545ff +surface.control = #626262ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff @@ -254,6 +255,7 @@ warning = accent.solid on surface.panel: 2.30 < 3.00 warning = accent.solid on surface.raised: 2.00 < 3.00 warning = accent.solid on surface.sunken: 2.87 < 3.00 warning = text.normal on state.pressed: 4.27 < 4.50 +warning = text.muted on surface.control: 4.12 < 4.50 warning = text.muted on state.hover: 4.12 < 4.50 warning = text.muted on state.pressed: 3.34 < 4.50 warning = text.faint on surface.background: 3.84 < 4.50 @@ -261,6 +263,7 @@ warning = text.faint on surface.panel: 2.94 < 4.50 warning = text.faint on surface.chrome: 2.94 < 4.50 warning = text.faint on surface.raised: 2.56 < 4.50 warning = text.faint on surface.sunken: 3.67 < 4.50 +warning = text.faint on surface.control: 2.33 < 4.50 warning = text.faint on state.hover: 2.33 < 4.50 warning = text.faint on state.pressed: 1.89 < 4.50 warning = text.on_accent on accent.solid: 3.34 < 4.50 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 ac1b8d28e..d8fd652a3 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #f0f0f0ff surface.chrome = #f0f0f0ff surface.raised = #f6f6f6ff surface.sunken = #ffffffff +surface.control = #e2e2e2ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff 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 134734f33..9e18bdc6e 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #f0f0f0ff surface.chrome = #f0f0f0ff surface.raised = #f6f6f6ff surface.sunken = #ffffffff +surface.control = #e2e2e2ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff 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 aa7569104..db9f3abbf 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #f0f0f0ff surface.chrome = #f0f0f0ff surface.raised = #f6f6f6ff surface.sunken = #ffffffff +surface.control = #e2e2e2ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.87 < 4.50 warning = text.faint on surface.chrome: 3.87 < 4.50 warning = text.faint on surface.raised: 4.09 < 4.50 warning = text.faint on surface.sunken: 4.42 < 4.50 +warning = text.faint on surface.control: 3.41 < 4.50 warning = text.faint on state.hover: 3.41 < 4.50 warning = text.faint on state.pressed: 2.81 < 4.50 warning = text.on_accent on accent.solid: 3.34 < 4.50 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 c03751afd..65b539d13 100644 --- a/crates/theme/tests/dumps/tokens/artcraft-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/artcraft-light-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #f0f0f0ff surface.chrome = #f0f0f0ff surface.raised = #f6f6f6ff surface.sunken = #ffffffff +surface.control = #e2e2e2ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.87 < 4.50 warning = text.faint on surface.chrome: 3.87 < 4.50 warning = text.faint on surface.raised: 4.09 < 4.50 warning = text.faint on surface.sunken: 4.42 < 4.50 +warning = text.faint on surface.control: 3.41 < 4.50 warning = text.faint on state.hover: 3.41 < 4.50 warning = text.faint on state.pressed: 2.81 < 4.50 warning = text.on_accent on accent.solid: 3.34 < 4.50 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 60712a358..f95b37283 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #1d2126ff surface.chrome = #262a30ff surface.raised = #272b30ff surface.sunken = #262a30ff +surface.control = #32363bff surface.knob = #e9ebeeff surface.scrim = #00000080 surface.inverse = #e9ebeeff 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 b4021b657..31a6d61de 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #1d2126ff surface.chrome = #262a30ff surface.raised = #272b30ff surface.sunken = #262a30ff +surface.control = #32363bff surface.knob = #e9ebeeff surface.scrim = #00000080 surface.inverse = #e9ebeeff 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 24760ee19..eba5cd036 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #1d2126ff surface.chrome = #262a30ff surface.raised = #272b30ff surface.sunken = #262a30ff +surface.control = #32363bff surface.knob = #e9ebeeff surface.scrim = #00000080 surface.inverse = #e9ebeeff 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 764eb548a..a0102a05b 100644 --- a/crates/theme/tests/dumps/tokens/breeze-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-dark-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #1d2126ff surface.chrome = #262a30ff surface.raised = #272b30ff surface.sunken = #262a30ff +surface.control = #32363bff surface.knob = #e9ebeeff surface.scrim = #00000080 surface.inverse = #e9ebeeff 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 ba6752c50..f2aec8cb3 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #eceef1ff surface.chrome = #dbdee2ff surface.raised = #f2f4f7ff surface.sunken = #f9fafcff +surface.control = #e2e6ebff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #252729ff 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 f75fbb1fb..9f168e317 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #eceef1ff surface.chrome = #dbdee2ff surface.raised = #f2f4f7ff surface.sunken = #f9fafcff +surface.control = #e2e6ebff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #252729ff 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 29ab888a8..8f4766d8e 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #eceef1ff surface.chrome = #dbdee2ff surface.raised = #f2f4f7ff surface.sunken = #f9fafcff +surface.control = #e2e6ebff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #252729ff 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 b833a27ef..12c4e6aca 100644 --- a/crates/theme/tests/dumps/tokens/breeze-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/breeze-light-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #eceef1ff surface.chrome = #dbdee2ff surface.raised = #f2f4f7ff surface.sunken = #f9fafcff +surface.control = #e2e6ebff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #252729ff 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 4ce8a9c7d..7648c9d10 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #d4d0c8ff surface.chrome = #d4d0c8ff surface.raised = #d4d0c8ff surface.sunken = #ffffffff +surface.control = #e2ded6ff surface.knob = #d4d0c8ff surface.scrim = #00000059 surface.inverse = #282624ff 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 60d43c258..834abb44c 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #d4d0c8ff surface.chrome = #d4d0c8ff surface.raised = #d4d0c8ff surface.sunken = #ffffffff +surface.control = #e2ded6ff surface.knob = #d4d0c8ff surface.scrim = #00000059 surface.inverse = #282624ff 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 340a328e5..897acf3ba 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #d4d0c8ff surface.chrome = #d4d0c8ff surface.raised = #d4d0c8ff surface.sunken = #ffffffff +surface.control = #e2ded6ff surface.knob = #d4d0c8ff surface.scrim = #00000059 surface.inverse = #282624ff @@ -255,5 +256,6 @@ warning = text.faint on surface.panel: 2.57 < 4.50 warning = text.faint on surface.chrome: 2.57 < 4.50 warning = text.faint on surface.raised: 2.57 < 4.50 warning = text.faint on surface.sunken: 3.95 < 4.50 +warning = text.faint on surface.control: 2.94 < 4.50 warning = text.faint on state.hover: 2.94 < 4.50 warning = text.faint on state.pressed: 2.04 < 4.50 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 79c77b1d7..9e0829969 100644 --- a/crates/theme/tests/dumps/tokens/classic-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/classic-light-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #d4d0c8ff surface.chrome = #d4d0c8ff surface.raised = #d4d0c8ff surface.sunken = #ffffffff +surface.control = #e2ded6ff surface.knob = #d4d0c8ff surface.scrim = #00000059 surface.inverse = #282624ff @@ -255,5 +256,6 @@ warning = text.faint on surface.panel: 2.57 < 4.50 warning = text.faint on surface.chrome: 2.57 < 4.50 warning = text.faint on surface.raised: 2.57 < 4.50 warning = text.faint on surface.sunken: 3.95 < 4.50 +warning = text.faint on surface.control: 2.94 < 4.50 warning = text.faint on state.hover: 2.94 < 4.50 warning = text.faint on state.pressed: 2.04 < 4.50 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 b9d505a78..56c41896b 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #26262aff surface.chrome = #26262aff surface.raised = #2e2e33ff surface.sunken = #131317ff +surface.control = #303034ff surface.knob = #ebebedff surface.scrim = #00000080 surface.inverse = #ebebedff 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 e1cad0d55..893d06c78 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #26262aff surface.chrome = #26262aff surface.raised = #2e2e33ff surface.sunken = #131317ff +surface.control = #303034ff surface.knob = #ebebedff surface.scrim = #00000080 surface.inverse = #ebebedff 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 903c5ba99..53eac13b1 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #26262aff surface.chrome = #26262aff surface.raised = #2e2e33ff surface.sunken = #131317ff +surface.control = #303034ff surface.knob = #ebebedff surface.scrim = #00000080 surface.inverse = #ebebedff 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 b138c9204..d62c8b6c1 100644 --- a/crates/theme/tests/dumps/tokens/graphite-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-dark-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #26262aff surface.chrome = #26262aff surface.raised = #2e2e33ff surface.sunken = #131317ff +surface.control = #303034ff surface.knob = #ebebedff surface.scrim = #00000080 surface.inverse = #ebebedff 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 78c9803a9..3df069ddc 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #ffffffff surface.chrome = #ffffffff surface.raised = #ffffffff surface.sunken = #ffffffff +surface.control = #f7f7f7ff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262628ff 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 f83ed8295..81969576f 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #ffffffff surface.chrome = #ffffffff surface.raised = #ffffffff surface.sunken = #ffffffff +surface.control = #f7f7f7ff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262628ff 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 d1bfd929b..42a918849 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #ffffffff surface.chrome = #ffffffff surface.raised = #ffffffff surface.sunken = #ffffffff +surface.control = #f7f7f7ff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262628ff 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 71b3f318d..48b33cc39 100644 --- a/crates/theme/tests/dumps/tokens/graphite-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/graphite-light-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #ffffffff surface.chrome = #ffffffff surface.raised = #ffffffff surface.sunken = #ffffffff +surface.control = #f7f7f7ff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262628ff 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 5be55aa62..f825c8228 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #323232ff surface.chrome = #323232ff surface.raised = #3c3c3cff surface.sunken = #242424ff +surface.control = #424242ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff 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 de51e0f92..3a5c8e924 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #323232ff surface.chrome = #323232ff surface.raised = #3c3c3cff surface.sunken = #242424ff +surface.control = #424242ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff 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 c2eaff5bf..3dcdc4e37 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 @@ -6,6 +6,7 @@ surface.panel = #323232ff surface.chrome = #323232ff surface.raised = #3c3c3cff surface.sunken = #242424ff +surface.control = #424242ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.25 < 4.50 warning = text.faint on surface.chrome: 3.25 < 4.50 warning = text.faint on surface.raised: 2.79 < 4.50 warning = text.faint on surface.sunken: 3.93 < 4.50 +warning = text.faint on surface.control: 2.54 < 4.50 warning = text.faint on state.hover: 2.54 < 4.50 warning = text.faint on state.pressed: 2.11 < 4.50 warning = status.bad.fg on surface.panel: 3.81 < 4.50 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 81b473467..c5fab953d 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #323232ff surface.chrome = #323232ff surface.raised = #3c3c3cff surface.sunken = #242424ff +surface.control = #424242ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.25 < 4.50 warning = text.faint on surface.chrome: 3.25 < 4.50 warning = text.faint on surface.raised: 2.79 < 4.50 warning = text.faint on surface.sunken: 3.93 < 4.50 +warning = text.faint on surface.control: 2.54 < 4.50 warning = text.faint on state.hover: 2.54 < 4.50 warning = text.faint on state.pressed: 2.11 < 4.50 warning = status.bad.fg on surface.panel: 3.81 < 4.50 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 080fa8035..8dff58056 100644 --- a/crates/theme/tests/dumps/tokens/pro-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-dark-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #323232ff surface.chrome = #323232ff surface.raised = #3c3c3cff surface.sunken = #242424ff +surface.control = #424242ff surface.knob = #ebebebff surface.scrim = #00000080 surface.inverse = #ebebebff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.25 < 4.50 warning = text.faint on surface.chrome: 3.25 < 4.50 warning = text.faint on surface.raised: 2.79 < 4.50 warning = text.faint on surface.sunken: 3.93 < 4.50 +warning = text.faint on surface.control: 2.54 < 4.50 warning = text.faint on state.hover: 2.54 < 4.50 warning = text.faint on state.pressed: 2.11 < 4.50 warning = status.bad.fg on surface.panel: 3.81 < 4.50 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 cdfa675c6..049cff744 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 @@ -6,6 +6,7 @@ surface.panel = #b8b8b8ff surface.chrome = #b8b8b8ff surface.raised = #bdbdbdff surface.sunken = #d6d6d6ff +surface.control = #c6c6c6ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff 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 2b5a5f71c..2822049b2 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 @@ -6,6 +6,7 @@ surface.panel = #b8b8b8ff surface.chrome = #b8b8b8ff surface.raised = #bdbdbdff surface.sunken = #d6d6d6ff +surface.control = #c6c6c6ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff 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 56e08dc89..3c6884d23 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 @@ -6,6 +6,7 @@ surface.panel = #b8b8b8ff surface.chrome = #b8b8b8ff surface.raised = #bdbdbdff surface.sunken = #d6d6d6ff +surface.control = #c6c6c6ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff @@ -258,6 +259,7 @@ warning = text.faint on surface.panel: 3.17 < 4.50 warning = text.faint on surface.chrome: 3.17 < 4.50 warning = text.faint on surface.raised: 3.35 < 4.50 warning = text.faint on surface.sunken: 4.33 < 4.50 +warning = text.faint on surface.control: 3.68 < 4.50 warning = text.faint on state.hover: 3.68 < 4.50 warning = text.faint on state.pressed: 2.71 < 4.50 warning = text.on_accent on accent.solid: 3.34 < 4.50 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 dbc152600..7a9877b01 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 @@ -6,6 +6,7 @@ surface.panel = #b8b8b8ff surface.chrome = #b8b8b8ff surface.raised = #bdbdbdff surface.sunken = #d6d6d6ff +surface.control = #c6c6c6ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff @@ -258,6 +259,7 @@ warning = text.faint on surface.panel: 3.17 < 4.50 warning = text.faint on surface.chrome: 3.17 < 4.50 warning = text.faint on surface.raised: 3.35 < 4.50 warning = text.faint on surface.sunken: 4.33 < 4.50 +warning = text.faint on surface.control: 3.68 < 4.50 warning = text.faint on state.hover: 3.68 < 4.50 warning = text.faint on state.pressed: 2.71 < 4.50 warning = text.on_accent on accent.solid: 3.34 < 4.50 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 22be98be1..54b6541f9 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #f0f0f0ff surface.chrome = #f0f0f0ff surface.raised = #f6f6f6ff surface.sunken = #ffffffff +surface.control = #e2e2e2ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff 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 38bc28082..de2f6cfd0 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #f0f0f0ff surface.chrome = #f0f0f0ff surface.raised = #f6f6f6ff surface.sunken = #ffffffff +surface.control = #e2e2e2ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff 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 e876cec31..234837422 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #f0f0f0ff surface.chrome = #f0f0f0ff surface.raised = #f6f6f6ff surface.sunken = #ffffffff +surface.control = #e2e2e2ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.87 < 4.50 warning = text.faint on surface.chrome: 3.87 < 4.50 warning = text.faint on surface.raised: 4.09 < 4.50 warning = text.faint on surface.sunken: 4.42 < 4.50 +warning = text.faint on surface.control: 3.41 < 4.50 warning = text.faint on state.hover: 3.41 < 4.50 warning = text.faint on state.pressed: 2.81 < 4.50 warning = text.on_accent on accent.solid: 3.34 < 4.50 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 8203da6e6..1ac901734 100644 --- a/crates/theme/tests/dumps/tokens/pro-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/pro-light-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #f0f0f0ff surface.chrome = #f0f0f0ff surface.raised = #f6f6f6ff surface.sunken = #ffffffff +surface.control = #e2e2e2ff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262626ff @@ -256,6 +257,7 @@ warning = text.faint on surface.panel: 3.87 < 4.50 warning = text.faint on surface.chrome: 3.87 < 4.50 warning = text.faint on surface.raised: 4.09 < 4.50 warning = text.faint on surface.sunken: 4.42 < 4.50 +warning = text.faint on surface.control: 3.41 < 4.50 warning = text.faint on state.hover: 3.41 < 4.50 warning = text.faint on state.pressed: 2.81 < 4.50 warning = text.on_accent on accent.solid: 3.34 < 4.50 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 f57a89138..26cb7816c 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #363640ff surface.chrome = #3a3a44ff surface.raised = #40404bff surface.sunken = #40404bff +surface.control = #444450ff surface.knob = #eaeaf0ff surface.scrim = #00000080 surface.inverse = #eaeaf0ff 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 1f7c5de6b..b186d8daa 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #363640ff surface.chrome = #3a3a44ff surface.raised = #40404bff surface.sunken = #40404bff +surface.control = #444450ff surface.knob = #eaeaf0ff surface.scrim = #00000080 surface.inverse = #eaeaf0ff 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 707f88624..45b768090 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #363640ff surface.chrome = #3a3a44ff surface.raised = #40404bff surface.sunken = #40404bff +surface.control = #444450ff surface.knob = #eaeaf0ff surface.scrim = #00000080 surface.inverse = #eaeaf0ff 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 9b2f4f060..2d35ed5c8 100644 --- a/crates/theme/tests/dumps/tokens/soft-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-dark-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #363640ff surface.chrome = #3a3a44ff surface.raised = #40404bff surface.sunken = #40404bff +surface.control = #444450ff surface.knob = #eaeaf0ff surface.scrim = #00000080 surface.inverse = #eaeaf0ff 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 d038a9703..6472b113a 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #f0eef3ff surface.chrome = #e8e6ecff surface.raised = #f6f4f9ff surface.sunken = #faf9fcff +surface.control = #e4e2eaff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #272628ff 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 72be51120..8006d9910 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #f0eef3ff surface.chrome = #e8e6ecff surface.raised = #f6f4f9ff surface.sunken = #faf9fcff +surface.control = #e4e2eaff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #272628ff 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 d89410361..89fa5326f 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #f0eef3ff surface.chrome = #e8e6ecff surface.raised = #f6f4f9ff surface.sunken = #faf9fcff +surface.control = #e4e2eaff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #272628ff 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 01b162c40..54b574398 100644 --- a/crates/theme/tests/dumps/tokens/soft-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/soft-light-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #f0eef3ff surface.chrome = #e8e6ecff surface.raised = #f6f4f9ff surface.sunken = #faf9fcff +surface.control = #e4e2eaff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #272628ff 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 b0e805d0c..3e1446cbb 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 @@ -6,6 +6,7 @@ surface.panel = #073642ff surface.chrome = #073642ff surface.raised = #15414dff surface.sunken = #00252fff +surface.control = #0e4a5aff surface.knob = #e2edf1ff surface.scrim = #00000080 surface.inverse = #e2edf1ff 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 01310a50b..d5957ea06 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 @@ -6,6 +6,7 @@ surface.panel = #073642ff surface.chrome = #073642ff surface.raised = #15414dff surface.sunken = #00252fff +surface.control = #0e4a5aff surface.knob = #e2edf1ff surface.scrim = #00000080 surface.inverse = #e2edf1ff 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 577065c0b..3e2d7b11a 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 @@ -6,6 +6,7 @@ surface.panel = #073642ff surface.chrome = #073642ff surface.raised = #15414dff surface.sunken = #00252fff +surface.control = #0e4a5aff surface.knob = #e2edf1ff surface.scrim = #00000080 surface.inverse = #e2edf1ff @@ -253,6 +254,7 @@ motion.reduced = false warning = text.normal on surface.panel: 4.11 < 4.50 warning = text.normal on surface.chrome: 4.11 < 4.50 warning = text.normal on surface.raised: 3.50 < 4.50 +warning = text.normal on surface.control: 3.10 < 4.50 warning = text.normal on state.hover: 3.10 < 4.50 warning = text.normal on state.pressed: 2.49 < 4.50 warning = text.muted on surface.background: 3.61 < 4.50 @@ -260,6 +262,7 @@ warning = text.muted on surface.panel: 2.92 < 4.50 warning = text.muted on surface.chrome: 2.92 < 4.50 warning = text.muted on surface.raised: 2.49 < 4.50 warning = text.muted on surface.sunken: 3.61 < 4.50 +warning = text.muted on surface.control: 2.20 < 4.50 warning = text.muted on state.hover: 2.20 < 4.50 warning = text.muted on state.pressed: 1.77 < 4.50 warning = text.faint on surface.background: 2.99 < 4.50 @@ -267,6 +270,7 @@ warning = text.faint on surface.panel: 2.42 < 4.50 warning = text.faint on surface.chrome: 2.42 < 4.50 warning = text.faint on surface.raised: 2.06 < 4.50 warning = text.faint on surface.sunken: 2.99 < 4.50 +warning = text.faint on surface.control: 1.82 < 4.50 warning = text.faint on state.hover: 1.82 < 4.50 warning = text.faint on state.pressed: 1.46 < 4.50 warning = status.warn.fg on surface.panel: 4.05 < 4.50 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 dd7f24655..613451066 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 @@ -6,6 +6,7 @@ surface.panel = #073642ff surface.chrome = #073642ff surface.raised = #15414dff surface.sunken = #00252fff +surface.control = #0e4a5aff surface.knob = #e2edf1ff surface.scrim = #00000080 surface.inverse = #e2edf1ff @@ -253,6 +254,7 @@ motion.reduced = false warning = text.normal on surface.panel: 4.11 < 4.50 warning = text.normal on surface.chrome: 4.11 < 4.50 warning = text.normal on surface.raised: 3.50 < 4.50 +warning = text.normal on surface.control: 3.10 < 4.50 warning = text.normal on state.hover: 3.10 < 4.50 warning = text.normal on state.pressed: 2.49 < 4.50 warning = text.muted on surface.background: 3.61 < 4.50 @@ -260,6 +262,7 @@ warning = text.muted on surface.panel: 2.92 < 4.50 warning = text.muted on surface.chrome: 2.92 < 4.50 warning = text.muted on surface.raised: 2.49 < 4.50 warning = text.muted on surface.sunken: 3.61 < 4.50 +warning = text.muted on surface.control: 2.20 < 4.50 warning = text.muted on state.hover: 2.20 < 4.50 warning = text.muted on state.pressed: 1.77 < 4.50 warning = text.faint on surface.background: 2.99 < 4.50 @@ -267,6 +270,7 @@ warning = text.faint on surface.panel: 2.42 < 4.50 warning = text.faint on surface.chrome: 2.42 < 4.50 warning = text.faint on surface.raised: 2.06 < 4.50 warning = text.faint on surface.sunken: 2.99 < 4.50 +warning = text.faint on surface.control: 1.82 < 4.50 warning = text.faint on state.hover: 1.82 < 4.50 warning = text.faint on state.pressed: 1.46 < 4.50 warning = status.warn.fg on surface.panel: 4.05 < 4.50 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 0dcd9ab91..8a45f399a 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #1a1a1cff surface.chrome = #141415ff surface.raised = #232325ff surface.sunken = #232326ff +surface.control = #2c2c30ff surface.knob = #ebebecff surface.scrim = #00000080 surface.inverse = #ebebecff 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 b0f1e9c7c..d38fcc6df 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #1a1a1cff surface.chrome = #141415ff surface.raised = #232325ff surface.sunken = #232326ff +surface.control = #2c2c30ff surface.knob = #ebebecff surface.scrim = #00000080 surface.inverse = #ebebecff 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 62ca1f276..5968a2998 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #1a1a1cff surface.chrome = #141415ff surface.raised = #232325ff surface.sunken = #232326ff +surface.control = #2c2c30ff surface.knob = #ebebecff surface.scrim = #00000080 surface.inverse = #ebebecff @@ -256,5 +257,6 @@ warning = text.faint on surface.panel: 2.79 < 4.50 warning = text.faint on surface.chrome: 2.95 < 4.50 warning = text.faint on surface.raised: 2.52 < 4.50 warning = text.faint on surface.sunken: 2.52 < 4.50 +warning = text.faint on surface.control: 2.23 < 4.50 warning = text.faint on state.hover: 2.23 < 4.50 warning = text.faint on state.pressed: 1.87 < 4.50 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 83ce16e5e..15d73fd34 100644 --- a/crates/theme/tests/dumps/tokens/studio-dark-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-dark-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #1a1a1cff surface.chrome = #141415ff surface.raised = #232325ff surface.sunken = #232326ff +surface.control = #2c2c30ff surface.knob = #ebebecff surface.scrim = #00000080 surface.inverse = #ebebecff @@ -256,5 +257,6 @@ warning = text.faint on surface.panel: 2.79 < 4.50 warning = text.faint on surface.chrome: 2.95 < 4.50 warning = text.faint on surface.raised: 2.52 < 4.50 warning = text.faint on surface.sunken: 2.52 < 4.50 +warning = text.faint on surface.control: 2.23 < 4.50 warning = text.faint on state.hover: 2.23 < 4.50 warning = text.faint on state.pressed: 1.87 < 4.50 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 fb7962477..22463d9eb 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-high-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-high-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #fcfcfdff surface.chrome = #f6f6f8ff surface.raised = #ffffffff surface.sunken = #f2f2f5ff +surface.control = #e8e8edff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262627ff 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 93e56fa30..c9cc1a883 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-high-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-high-compact.txt @@ -6,6 +6,7 @@ surface.panel = #fcfcfdff surface.chrome = #f6f6f8ff surface.raised = #ffffffff surface.sunken = #f2f2f5ff +surface.control = #e8e8edff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262627ff 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 3d5f8106b..a2eb2a604 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-standard-comfortable.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-standard-comfortable.txt @@ -6,6 +6,7 @@ surface.panel = #fcfcfdff surface.chrome = #f6f6f8ff surface.raised = #ffffffff surface.sunken = #f2f2f5ff +surface.control = #e8e8edff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262627ff @@ -255,5 +256,6 @@ warning = text.faint on surface.panel: 2.86 < 4.50 warning = text.faint on surface.chrome: 2.71 < 4.50 warning = text.faint on surface.raised: 2.93 < 4.50 warning = text.faint on surface.sunken: 2.62 < 4.50 +warning = text.faint on surface.control: 2.40 < 4.50 warning = text.faint on state.hover: 2.40 < 4.50 warning = text.faint on state.pressed: 2.15 < 4.50 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 9fccbc41a..a2583c33a 100644 --- a/crates/theme/tests/dumps/tokens/studio-light-standard-compact.txt +++ b/crates/theme/tests/dumps/tokens/studio-light-standard-compact.txt @@ -6,6 +6,7 @@ surface.panel = #fcfcfdff surface.chrome = #f6f6f8ff surface.raised = #ffffffff surface.sunken = #f2f2f5ff +surface.control = #e8e8edff surface.knob = #fcfcfcff surface.scrim = #00000059 surface.inverse = #262627ff @@ -255,5 +256,6 @@ warning = text.faint on surface.panel: 2.86 < 4.50 warning = text.faint on surface.chrome: 2.71 < 4.50 warning = text.faint on surface.raised: 2.93 < 4.50 warning = text.faint on surface.sunken: 2.62 < 4.50 +warning = text.faint on surface.control: 2.40 < 4.50 warning = text.faint on state.hover: 2.40 < 4.50 warning = text.faint on state.pressed: 2.15 < 4.50 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 9fb87ac4a..3cca1f007 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 @@ -6,6 +6,7 @@ surface.panel = #181b22ff surface.chrome = #181b22ff surface.raised = #21242cff surface.sunken = #0f1116ff +surface.control = #282d37ff surface.knob = #e9ebf0ff surface.scrim = #00000080 surface.inverse = #e9ebf0ff 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 347403929..7df6bc4d8 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 @@ -6,6 +6,7 @@ surface.panel = #181b22ff surface.chrome = #181b22ff surface.raised = #21242cff surface.sunken = #0f1116ff +surface.control = #282d37ff surface.knob = #e9ebf0ff surface.scrim = #00000080 surface.inverse = #e9ebf0ff 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 86e14c857..51412a6e4 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 @@ -6,6 +6,7 @@ surface.panel = #181b22ff surface.chrome = #181b22ff surface.raised = #21242cff surface.sunken = #0f1116ff +surface.control = #282d37ff surface.knob = #e9ebf0ff surface.scrim = #00000080 surface.inverse = #e9ebf0ff @@ -256,5 +257,6 @@ warning = text.faint on surface.panel: 2.81 < 4.50 warning = text.faint on surface.chrome: 2.81 < 4.50 warning = text.faint on surface.raised: 2.53 < 4.50 warning = text.faint on surface.sunken: 3.08 < 4.50 +warning = text.faint on surface.control: 2.25 < 4.50 warning = text.faint on state.hover: 2.31 < 4.50 warning = text.faint on state.pressed: 1.76 < 4.50 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 1f8f65595..0c4868de8 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 @@ -6,6 +6,7 @@ surface.panel = #181b22ff surface.chrome = #181b22ff surface.raised = #21242cff surface.sunken = #0f1116ff +surface.control = #282d37ff surface.knob = #e9ebf0ff surface.scrim = #00000080 surface.inverse = #e9ebf0ff @@ -256,5 +257,6 @@ warning = text.faint on surface.panel: 2.81 < 4.50 warning = text.faint on surface.chrome: 2.81 < 4.50 warning = text.faint on surface.raised: 2.53 < 4.50 warning = text.faint on surface.sunken: 3.08 < 4.50 +warning = text.faint on surface.control: 2.25 < 4.50 warning = text.faint on state.hover: 2.31 < 4.50 warning = text.faint on state.pressed: 1.76 < 4.50 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 0737f2949..b47954a24 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 @@ -6,6 +6,7 @@ surface.panel = #f3f5f8ff surface.chrome = #f3f5f8ff surface.raised = #f9fbfeff surface.sunken = #ffffffff +surface.control = #e3e7edff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262627ff 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 2ab2ec91b..9979c1797 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 @@ -6,6 +6,7 @@ surface.panel = #f3f5f8ff surface.chrome = #f3f5f8ff surface.raised = #f9fbfeff surface.sunken = #ffffffff +surface.control = #e3e7edff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262627ff 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 d3fa34530..6e1785f6f 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 @@ -6,6 +6,7 @@ surface.panel = #f3f5f8ff surface.chrome = #f3f5f8ff surface.raised = #f9fbfeff surface.sunken = #ffffffff +surface.control = #e3e7edff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262627ff @@ -256,5 +257,6 @@ warning = text.faint on surface.panel: 2.38 < 4.50 warning = text.faint on surface.chrome: 2.38 < 4.50 warning = text.faint on surface.raised: 2.51 < 4.50 warning = text.faint on surface.sunken: 2.60 < 4.50 +warning = text.faint on surface.control: 2.10 < 4.50 warning = text.faint on state.hover: 2.10 < 4.50 warning = text.faint on state.pressed: 1.73 < 4.50 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 0802ea550..2842ce503 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 @@ -6,6 +6,7 @@ surface.panel = #f3f5f8ff surface.chrome = #f3f5f8ff surface.raised = #f9fbfeff surface.sunken = #ffffffff +surface.control = #e3e7edff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #262627ff @@ -256,5 +257,6 @@ warning = text.faint on surface.panel: 2.38 < 4.50 warning = text.faint on surface.chrome: 2.38 < 4.50 warning = text.faint on surface.raised: 2.51 < 4.50 warning = text.faint on surface.sunken: 2.60 < 4.50 +warning = text.faint on surface.control: 2.10 < 4.50 warning = text.faint on state.hover: 2.10 < 4.50 warning = text.faint on state.pressed: 1.73 < 4.50 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 3338fe6e6..811ca6abe 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 @@ -6,6 +6,7 @@ surface.panel = #272c36ff surface.chrome = #272c36ff surface.raised = #313640ff surface.sunken = #1a1e26ff +surface.control = #39404dff surface.knob = #e8ebf1ff surface.scrim = #00000080 surface.inverse = #e8ebf1ff 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 c02aa3eda..42374b03f 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 @@ -6,6 +6,7 @@ surface.panel = #272c36ff surface.chrome = #272c36ff surface.raised = #313640ff surface.sunken = #1a1e26ff +surface.control = #39404dff surface.knob = #e8ebf1ff surface.scrim = #00000080 surface.inverse = #e8ebf1ff 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 6fd9898dd..83e6d3a87 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 @@ -6,6 +6,7 @@ surface.panel = #272c36ff surface.chrome = #272c36ff surface.raised = #313640ff surface.sunken = #1a1e26ff +surface.control = #39404dff surface.knob = #e8ebf1ff surface.scrim = #00000080 surface.inverse = #e8ebf1ff @@ -250,6 +251,7 @@ motion.caret.easing = enter motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false +warning = text.muted on surface.control: 4.05 < 4.50 warning = text.muted on state.hover: 4.31 < 4.50 warning = text.muted on state.pressed: 3.53 < 4.50 warning = text.faint on surface.background: 3.07 < 4.50 @@ -257,5 +259,6 @@ warning = text.faint on surface.panel: 2.60 < 4.50 warning = text.faint on surface.chrome: 2.60 < 4.50 warning = text.faint on surface.raised: 2.25 < 4.50 warning = text.faint on surface.sunken: 3.10 < 4.50 +warning = text.faint on surface.control: 1.94 < 4.50 warning = text.faint on state.hover: 2.06 < 4.50 warning = text.faint on state.pressed: 1.69 < 4.50 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 7343d1164..5c9531f99 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 @@ -6,6 +6,7 @@ surface.panel = #272c36ff surface.chrome = #272c36ff surface.raised = #313640ff surface.sunken = #1a1e26ff +surface.control = #39404dff surface.knob = #e8ebf1ff surface.scrim = #00000080 surface.inverse = #e8ebf1ff @@ -250,6 +251,7 @@ motion.caret.easing = enter motion.outline.millis = 120 motion.outline.easing = standard motion.reduced = false +warning = text.muted on surface.control: 4.05 < 4.50 warning = text.muted on state.hover: 4.31 < 4.50 warning = text.muted on state.pressed: 3.53 < 4.50 warning = text.faint on surface.background: 3.07 < 4.50 @@ -257,5 +259,6 @@ warning = text.faint on surface.panel: 2.60 < 4.50 warning = text.faint on surface.chrome: 2.60 < 4.50 warning = text.faint on surface.raised: 2.25 < 4.50 warning = text.faint on surface.sunken: 3.10 < 4.50 +warning = text.faint on surface.control: 1.94 < 4.50 warning = text.faint on state.hover: 2.06 < 4.50 warning = text.faint on state.pressed: 1.69 < 4.50 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 99b494063..7ceb9a478 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 @@ -6,6 +6,7 @@ surface.panel = #d3d8e0ff surface.chrome = #d3d8e0ff surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff +surface.control = #c9d0daff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #252629ff 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 76037d632..539657efe 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 @@ -6,6 +6,7 @@ surface.panel = #d3d8e0ff surface.chrome = #d3d8e0ff surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff +surface.control = #c9d0daff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #252629ff 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 99d34c458..edb660245 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 @@ -6,6 +6,7 @@ surface.panel = #d3d8e0ff surface.chrome = #d3d8e0ff surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff +surface.control = #c9d0daff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #252629ff @@ -257,5 +258,6 @@ warning = text.faint on surface.panel: 2.59 < 4.50 warning = text.faint on surface.chrome: 2.59 < 4.50 warning = text.faint on surface.raised: 2.75 < 4.50 warning = text.faint on surface.sunken: 3.14 < 4.50 +warning = text.faint on surface.control: 2.39 < 4.50 warning = text.faint on state.hover: 2.30 < 4.50 warning = text.faint on state.pressed: 1.96 < 4.50 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 df681c998..ed3b75eac 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 @@ -6,6 +6,7 @@ surface.panel = #d3d8e0ff surface.chrome = #d3d8e0ff surface.raised = #d9dee6ff surface.sunken = #e9ecf1ff +surface.control = #c9d0daff surface.knob = #fcfcfdff surface.scrim = #00000059 surface.inverse = #252629ff @@ -257,5 +258,6 @@ warning = text.faint on surface.panel: 2.59 < 4.50 warning = text.faint on surface.chrome: 2.59 < 4.50 warning = text.faint on surface.raised: 2.75 < 4.50 warning = text.faint on surface.sunken: 3.14 < 4.50 +warning = text.faint on surface.control: 2.39 < 4.50 warning = text.faint on state.hover: 2.30 < 4.50 warning = text.faint on state.pressed: 1.96 < 4.50 diff --git a/crates/theme/themes/vectorcraft-modern-medium.json b/crates/theme/themes/vectorcraft-modern-medium.json index 77f15a2f5..b2652f598 100644 --- a/crates/theme/themes/vectorcraft-modern-medium.json +++ b/crates/theme/themes/vectorcraft-modern-medium.json @@ -33,6 +33,7 @@ "state.selected": "#d4bbbd", "surface.background": "#c4cad4", "surface.canvas": "#b9c0cb", + "surface.control": "#c9d0da", "surface.panel": "#d3d8e0", "surface.sunken": "#e9ecf1", "text.disabled": "#7d8594", @@ -52,6 +53,7 @@ "state.selected": "#573b3d", "surface.background": "#1b1f27", "surface.canvas": "#1e222a", + "surface.control": "#39404d", "surface.panel": "#272c36", "surface.sunken": "#1a1e26", "text.disabled": "#626b7a", diff --git a/crates/theme/themes/vectorcraft-modern.json b/crates/theme/themes/vectorcraft-modern.json index 98e9193bc..0e1e6336c 100644 --- a/crates/theme/themes/vectorcraft-modern.json +++ b/crates/theme/themes/vectorcraft-modern.json @@ -33,6 +33,7 @@ "state.selected": "#eed2d0", "surface.background": "#e6e9ee", "surface.canvas": "#dfe3e9", + "surface.control": "#e3e7ed", "surface.panel": "#f3f5f8", "surface.sunken": "#ffffff", "text.disabled": "#9aa1ad", @@ -52,6 +53,7 @@ "state.selected": "#4c2e2e", "surface.background": "#0b0d12", "surface.canvas": "#101217", + "surface.control": "#282d37", "surface.panel": "#181b22", "surface.sunken": "#0f1116", "text.disabled": "#5a6271", diff --git a/crates/ui-widgets/src/buttons/button.rs b/crates/ui-widgets/src/buttons/button.rs index f37e6254b..dcf08e463 100644 --- a/crates/ui-widgets/src/buttons/button.rs +++ b/crates/ui-widgets/src/buttons/button.rs @@ -37,7 +37,7 @@ const SIDE_MENU_DISABLED_ALPHA: u8 = 110; /// The style of a push button. #[derive(Clone, Debug, PartialEq, ComponentStyle)] -#[style(variants = [Variant::SECONDARY, Variant::PRIMARY, Variant::GHOST, Variant::DANGER, Variant::look(Emphasis::Outline, Tone::Accent)])] +#[style(variants = [Variant::SECONDARY, Variant::PRIMARY, Variant::GHOST, Variant::DANGER, Variant::look(Emphasis::Outline, Tone::Accent), super::FILLED])] #[non_exhaustive] pub struct ButtonStyle { #[style(surface)] @@ -296,7 +296,7 @@ impl Component for Button<'_> { type Output = ButtonOutput; fn style(cx: &StyleCx<'_>, key: ButtonStyleKey) -> ButtonStyle { - let cx = &super::placed(cx); + let cx = &super::pushed(cx); let mut style = match key.tint { Some(tint) => ButtonStyle::tinted(cx, tint), None => ButtonStyle::of(cx), diff --git a/crates/ui-widgets/src/buttons/mod.rs b/crates/ui-widgets/src/buttons/mod.rs index 101f7d9fd..78815535d 100644 --- a/crates/ui-widgets/src/buttons/mod.rs +++ b/crates/ui-widgets/src/buttons/mod.rs @@ -63,8 +63,25 @@ pub enum ControlPlace { SideMenu, } -/// The style context a push or split button draws in: in a ribbon (`ControlPlace::Ribbon`) the default variant -/// becomes the ghost one, so the button is flat at rest; any other variant, and any other place, stays as it is. +/// The look of a push or split button that asks for no variant (or for the default `Variant::SECONDARY`). An app sets +/// it once at its root (`RootEnv::values`); the default is the outline. A ribbon's flat look (`ControlPlace::Ribbon`) +/// wins over it, and toggles keep the outline. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, EnvValue, MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum PushButtonLook { + /// The outline, filled only by state. + #[default] + Outline, + /// The filled neutral tile with no edge at rest (`Emphasis::Filled`): VectorCraft's buttons. + 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 style context a push, split or labelled toggle button draws in: in a ribbon (`ControlPlace::Ribbon`) the default +/// variant becomes the ghost one, so the button is flat at rest; any other variant, and any other place, stays as it is. pub(crate) fn placed<'a>(cx: &crate::style::StyleCx<'a>) -> crate::style::StyleCx<'a> { if cx.variant == craft_theme::Variant::SECONDARY && cx.env::() == ControlPlace::Ribbon { cx.with_variant(craft_theme::Variant::GHOST) @@ -73,6 +90,13 @@ pub(crate) fn placed<'a>(cx: &crate::style::StyleCx<'a>) -> crate::style::StyleC } } +/// The style context a push or split button draws in: [`placed`], then the default variant becomes the filled one +/// under [`PushButtonLook::Filled`]. +pub(crate) fn pushed<'a>(cx: &crate::style::StyleCx<'a>) -> crate::style::StyleCx<'a> { + let cx = placed(cx); + if cx.variant == craft_theme::Variant::SECONDARY && cx.env::() == PushButtonLook::Filled { cx.with_variant(FILLED) } else { cx } +} + /// The icon sides of the buttons in a ribbon (`ControlPlace::Ribbon`), in points: `large` for a stacked button's /// leading icon, `small` for every other button's icon and an icon-only button's glyph. A side of 0 keeps the /// framework's: `size.icon.lg` (or the control's icon, when larger) for a stacked icon, the control's icon or glyph diff --git a/crates/ui-widgets/src/buttons/split_button.rs b/crates/ui-widgets/src/buttons/split_button.rs index 9e235d706..8f503c36a 100644 --- a/crates/ui-widgets/src/buttons/split_button.rs +++ b/crates/ui-widgets/src/buttons/split_button.rs @@ -22,7 +22,7 @@ const ARROW: PartKey = PartKey::new("arrow"); /// The style of a split button: one surface under both parts, each part's hover and pressed fill over it, and a /// divider between them. #[derive(Clone, Debug, PartialEq, ComponentStyle)] -#[style(variants = [Variant::SECONDARY, Variant::PRIMARY, Variant::GHOST, Variant::DANGER, Variant::look(Emphasis::Outline, Tone::Accent)])] +#[style(variants = [Variant::SECONDARY, Variant::PRIMARY, Variant::GHOST, Variant::DANGER, Variant::look(Emphasis::Outline, Tone::Accent), super::FILLED])] #[non_exhaustive] pub struct SplitButtonStyle { #[style(surface)] @@ -162,7 +162,7 @@ impl Component for SplitButton<'_, T> { type Output = SplitOutput; fn style(cx: &StyleCx<'_>, key: SplitButtonStyleKey) -> SplitButtonStyle { - let cx = &super::placed(cx); + let cx = &super::pushed(cx); let parts = cx.variant_look(); let metrics = face::metrics_of(cx, &parts, key.arrangement); let mut surface = face::surface(cx, &parts); diff --git a/crates/ui-widgets/src/buttons/stories.rs b/crates/ui-widgets/src/buttons/stories.rs index f37944321..a11b1b381 100644 --- a/crates/ui-widgets/src/buttons/stories.rs +++ b/crates/ui-widgets/src/buttons/stories.rs @@ -1,8 +1,8 @@ //! Stories of the buttons. use super::{ - Arrangement, Button, ButtonChord, CommandSearch, ControlPlace, GroupLevel, IconButton, Link, PopupMark, PressFocus, SplitButton, SplitMenu, - ToggleButton, + Arrangement, Button, ButtonChord, CommandSearch, ControlPlace, GroupLevel, IconButton, Link, PopupMark, PressFocus, PushButtonLook, SplitButton, + SplitMenu, ToggleButton, }; use crate::contract::{Bind, BodyCx, Entry, LeastWidth, PopupKind, Props as _, Show as _, ShowContainer as _, Sizing, Trigger, Validity}; use crate::display::{Picture, Shade, Text}; @@ -50,6 +50,30 @@ fn button_variants(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { Grid::new(columns).show(ui, |ui, _| rows(ui, states)).into() } +/// The push buttons of an app that sets `PushButtonLook::Filled` at its root: a button, a split button and a disabled +/// button at each size, filled neutral tiles with no edge at rest. Under the pointer they take the hover fill and the +/// control edge, pressed the pressed fill and the accent edge. +#[story(Button<'static>, covers = [], drive = Drive::Never, group = "Variants", title = "Filled")] +fn button_filled(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + let entries = presets(); + let shown = with_env( + ui, + |overrides| { + overrides.values.set(PushButtonLook::Filled); + }, + |ui| { + Grid::new(&[ColumnWidth::Content; 3]).show(ui, |ui, _| { + for (size_name, size) in SIZES { + Button::new("Cancel").size(size).id_salt(("rest", size_name)).show(ui); + SplitButton::new("Trace", &entries).size(size).id_salt(("split", size_name)).show(ui); + Button::new("Unavailable").size(size).enabled(false).id_salt(("disabled", size_name)).show(ui); + } + }) + }, + ); + shown.into() +} + #[story(Button<'static>, covers = [Default], group = "Playground", title = "Playground")] fn button(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let variants = [("Primary", Variant::PRIMARY), ("Secondary", Variant::SECONDARY), ("Ghost", Variant::GHOST), ("Danger", Variant::DANGER)]; diff --git a/crates/ui-widgets/tests/it/buttons.rs b/crates/ui-widgets/tests/it/buttons.rs index a1952c4f3..db506f20c 100644 --- a/crates/ui-widgets/tests/it/buttons.rs +++ b/crates/ui-widgets/tests/it/buttons.rs @@ -6,7 +6,9 @@ use craft_behavior::{IconId, PartKey}; use craft_theme::ControlSize; use craft_theme::Variant; -use craft_ui::buttons::{Arrangement, Button, ButtonChord, ControlPlace, GroupLevel, IconButton, SplitButton, SplitMenu, ToggleButton}; +use craft_ui::buttons::{ + Arrangement, Button, ButtonChord, ControlPlace, GroupLevel, IconButton, PushButtonLook, SplitButton, SplitMenu, ToggleButton, +}; use craft_ui::contract::tooltip::DELAY; use craft_ui::contract::{Bind, CommandSet, Entry, Hover, PopupKind, Props as _, Role, Show as _, ShowContainer as _, Trigger}; use craft_ui::display::Picture; @@ -466,6 +468,65 @@ fn a_ribbons_buttons_are_flat_at_rest_unless_they_ask_for_a_variant() { assert!(narrow < wide - 0.5, "a ribbon's flat toggle sits close: {narrow} against {wide}"); } +/// Under an app's `PushButtonLook::Filled` a push or split button that asks for no variant draws the filled tile: a fill +/// apart from the outline's clear rest, no edge at rest and one under the pointer. A variant it asks for stays, and a +/// ribbon keeps its flat look. +#[trial] +fn an_apps_filled_look_fills_its_default_push_buttons() { + let filled = |ui: &mut Ui, show: &dyn Fn(&mut Ui)| { + with_env( + ui, + |overrides| { + overrides.values.set(PushButtonLook::Filled); + }, + show, + ) + }; + let button = std::any::type_name::>(); + let (tile, _) = seen(button, "Cancel", move |ui| { + filled(ui, &|ui| { + let _ = Button::new("Cancel").show(ui); + }) + }); + let (outline, _) = seen(button, "Cancel", |ui| { + let _ = Button::new("Cancel").show(ui); + }); + let (primary, _) = seen(button, "Cancel", move |ui| { + filled(ui, &|ui| { + let _ = Button::new("Cancel").variant(Variant::PRIMARY).show(ui); + }) + }); + let (plain_primary, _) = seen(button, "Cancel", |ui| { + let _ = Button::new("Cancel").variant(Variant::PRIMARY).show(ui); + }); + let (ribbon, _) = seen(button, "Cancel", move |ui| { + filled(ui, &|ui| { + in_ribbon(ui, |ui| { + let _ = Button::new("Cancel").show(ui); + }) + }) + }); + let (ghost, _) = seen(button, "Cancel", |ui| { + let _ = Button::new("Cancel").variant(Variant::GHOST).show(ui); + }); + let (tile, outline) = (tile.expect("a filled button has a surface"), outline.expect("a button has a surface")); + assert_ne!(tile.fill.off.rest, outline.fill.off.rest, "a filled button rests on a fill of its own"); + let edge = tile.border.as_ref().expect("a filled button is edged by state").off; + assert_eq!(edge.rest.egui().a(), 0, "a filled button shows no edge at rest"); + assert!(edge.hover.egui().a() > 0 && edge.pressed.egui().a() > 0, "a filled button is edged under the pointer and the press"); + assert_eq!(primary, plain_primary, "a variant asked for stays"); + assert_eq!(ribbon, ghost, "a ribbon's button stays flat"); + + let split = std::any::type_name::>(); + let (split_tile, _) = seen(split, "Paste", move |ui| { + filled(ui, &|ui| { + let entries = [Entry::new(1_usize, "Keep text only")]; + let _ = SplitButton::new("Paste", &entries).show(ui); + }) + }); + assert_eq!(split_tile.map(|look| look.fill.off.rest), Some(tile.fill.off.rest), "a split button takes the same tile"); +} + /// In a ribbon a combo box is as wide as its widest option and its chevron, not a field length. #[trial] fn a_ribbons_combo_box_is_as_wide_as_its_options() { diff --git a/docs/suite-themes.md b/docs/suite-themes.md index a70a0519e..9d7936b41 100644 --- a/docs/suite-themes.md +++ b/docs/suite-themes.md @@ -93,7 +93,7 @@ High contrast meets every minimum below: it moves pinned values that miss one. S | Pair | Standard | High | |---|---|---| -| `text.normal`, `text.muted`, `text.faint` on surfaces (background, panel, chrome, raised, sunken), `state.hover` and `state.pressed` | 4.5 | 7 | +| `text.normal`, `text.muted`, `text.faint` on surfaces (background, panel, chrome, raised, sunken, control), `state.hover` and `state.pressed` | 4.5 | 7 | | `text.on_selected` on `state.selected` and `state.selected_hover`; `text.on_inverse` on `surface.inverse` | 4.5 | 7 | | `accent.text` on `surface.panel`, `surface.raised` and `surface.sunken`; `accent.on_soft` on `accent.soft` | 4.5 | 7 | | Status text (`status.good.fg` ...) on `surface.panel`, `surface.raised` and its own `status.*.bg` | 4.5 | 7 | From 4ae91846fa42afbe24538cd338ad06895bdbf232 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:57:16 +0700 Subject: [PATCH 40/76] title bar: take show_fitted out again; with caption buttons its trailing content stops short of the end and a ranked member narrows instead of leaving --- crates/ui-shell/src/shell/title_bar/bar.rs | 23 +-------- .../src/shell/title_bar/bar/stories.rs | 27 +--------- crates/ui-shell/tests/it/shell/title_bar.rs | 49 ------------------- 3 files changed, 2 insertions(+), 97 deletions(-) diff --git a/crates/ui-shell/src/shell/title_bar/bar.rs b/crates/ui-shell/src/shell/title_bar/bar.rs index defac8b60..fdd75f67b 100644 --- a/crates/ui-shell/src/shell/title_bar/bar.rs +++ b/crates/ui-shell/src/shell/title_bar/bar.rs @@ -11,7 +11,6 @@ use crate::contract::{ PartsCx, Role, ShowContainer as _, Sizing, WordSetCx as _, }; use crate::layout::{Placed, arrange}; -use crate::layout_components::Row; use crate::runtime::access::Name; use crate::runtime::egui::pass; use crate::runtime::env::Env; @@ -68,8 +67,7 @@ impl Outcome for TitleBarOutput { /// In an embedded shell (an app preview, a story) the bar is a picture of a window: it acts on no window and reads /// none. The captions show hover and report their clicks, but send no window command, and the bar has no move band. The body is the leading content; the /// trailing content ([`trailing`](TitleBar::trailing)) sits before the end's captions. [`show_titled`](TitleBar::show_titled) -/// adds the title in the gap between them; [`show_fitted`](TitleBar::show_fitted) puts the trailing content on the -/// body's line, after the leading content. Close never closes the window; see [`TitleBarOutput`]. +/// adds the title in the gap between them. Close never closes the window; see [`TitleBarOutput`]. #[derive(crate::contract::Component, crate::contract::Props)] #[component(container)] pub struct TitleBar<'a> { @@ -248,25 +246,6 @@ impl<'a> TitleBar<'a> { out } - /// Shows the bar with `leading` content at its start and `trailing` content after it on the same line, at the end - /// edge before the end's captions. The trailing content gets the room the leading content's natural width leaves: - /// when the line is short, its members that carry a `fit_rank` leave whole, lowest rank first, before the leading - /// content narrows (an app bar whose menus stay whole while its end controls go). - pub fn show_fitted( - self, - ui: &mut Ui, - mut leading: impl FnMut(&mut Ui, &mut BodyCx<'_>) + 'a, - mut trailing: impl FnMut(&mut Ui, &mut BodyCx<'_>) + 'a, - ) -> TitleBarOutput { - self.show(ui, |ui, cx| { - leading(ui, cx); - // An empty row that fills the line takes what the members leave, so the trailing content sits at the end. - let _ = Row::new().fill_width().show(ui, |_, _| {}); - trailing(ui, cx); - }) - .output - } - /// Shows one end of the bar and records its clicked caption: Close is reported, never acted on. fn end_of(&mut self, ui: &mut Ui, cx: &BodyCx<'_>, end: &End, window: &Window) { if let Some(caption) = show_end(ui, cx, end, window) { diff --git a/crates/ui-shell/src/shell/title_bar/bar/stories.rs b/crates/ui-shell/src/shell/title_bar/bar/stories.rs index 56482c00a..ca430996e 100644 --- a/crates/ui-shell/src/shell/title_bar/bar/stories.rs +++ b/crates/ui-shell/src/shell/title_bar/bar/stories.rs @@ -1,10 +1,8 @@ //! Stories of `TitleBar`: one per frame mode, and a maximized window. use super::TitleBar; -use crate::buttons::Button; -use crate::contract::{Show as _, ShowContainer as _}; +use crate::contract::Show as _; use crate::display::Text; -use crate::layout_components::Row; use crate::shell::Title; use crate::shell::{Caption, CaptionFamily, Captions, Frame, MacInset}; use crate::testing::{Drive, StoryData, StoryOutput, story}; @@ -23,20 +21,6 @@ fn tools(ui: &mut Ui, _: &mut crate::contract::BodyCx<'_>) { Text::new("Share").show(ui); } -/// The width of the narrow fitted bar: the menu and Share fit, the ranked end controls do not. -const FITTED_NARROW: f32 = 420.0; - -/// End controls that leave a short bar by rank, then one that stays. -fn ranked_tools(ui: &mut Ui, _: &mut crate::contract::BodyCx<'_>) { - let _ = Row::new().fit_rank(1).show(ui, |ui, _| { - Button::new("Community").show(ui); - }); - let _ = Row::new().fit_rank(2).show(ui, |ui, _| { - Button::new("Learn").show(ui); - }); - Text::new("Share").show(ui); -} - #[story(TitleBar<'static>, covers = [Default], drive = Drive::Never)] fn title_bar_windows(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { let frame = captions(CaptionFamily::Windows, &[], &[Caption::Minimize, Caption::Maximize, Caption::Close]); @@ -73,12 +57,3 @@ fn title_bar_action_title(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { fn title_bar_native(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { TitleBar::new().frame(Frame::Native).title_when_native().show_titled(ui, Title::new("Landscape.psd"), menu, tools).into() } - -/// A bar whose end controls fit after its menus: in a narrow window the menus stay whole and the end controls leave by -/// rank, the lowest first (Community, then Learn), while the unranked Share stays. -#[story(TitleBar<'static>, covers = [], drive = Drive::Never)] -fn title_bar_fitted_narrow(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { - ui.set_max_width(FITTED_NARROW); - let frame = captions(CaptionFamily::Windows, &[], &[Caption::Minimize, Caption::Maximize, Caption::Close]); - TitleBar::new().frame(frame).show_fitted(ui, menu, ranked_tools).into() -} diff --git a/crates/ui-shell/tests/it/shell/title_bar.rs b/crates/ui-shell/tests/it/shell/title_bar.rs index d07c61394..fdbadce91 100644 --- a/crates/ui-shell/tests/it/shell/title_bar.rs +++ b/crates/ui-shell/tests/it/shell/title_bar.rs @@ -353,52 +353,3 @@ fn the_lights_room_follows_the_lights_without_mirroring_the_bar() { assert!(rect("Home").left() >= lights - 0.5, "Home {:?} after the lights at the left", rect("Home")); assert!(rect("Preferences").right() >= width - 20.0, "Preferences {:?} at the right end", rect("Preferences")); } - -/// What a fitted bar `width` wide shows: the leading button's rect, and whether the trailing buttons ranked 1 and 2 -/// are there. -fn fitted(width: f32) -> (Rect, [bool; 2]) { - use craft_ui::buttons::Button; - use craft_ui::contract::{Show as _, ShowContainer as _}; - use craft_ui::layout_components::Row; - let mut fixture = Fixture::new(|ui| { - let _ = TitleBar::new().frame(Frame::Native).show_fitted( - ui, - |ui, _| { - Button::new("File Edit Object Type Select Effect View Window Help").show(ui); - }, - |ui, _| { - let _ = Row::new().fit_rank(1).show(ui, |ui, _| { - Button::new("Community").show(ui); - }); - let _ = Row::new().fit_rank(2).show(ui, |ui, _| { - Button::new("Learn").show(ui); - }); - }, - ); - }); - fixture.room(vec2(width, 80.0)).settle(); - let leading = fixture.by_label("File Edit Object Type Select Effect View Window Help").expect("the leading button").rect; - (leading, ["Community", "Learn"].map(|label| fixture.by_label(label).is_some())) -} - -/// The trailing content of a fitted bar takes what the leading content leaves: as the bar narrows, the trailing -/// members leave by rank, lowest first, while the leading content keeps its width. -#[trial] -fn a_fitted_bar_drops_its_trailing_members_by_rank_before_the_leading_content_narrows() { - let (whole, all) = fitted(1400.0); - assert_eq!(all, [true; 2], "a wide bar shows every trailing member"); - let shown: Vec<(f32, Rect, [bool; 2])> = (300..=800) - .step_by(20) - .map(|width| { - let (leading, trailing) = fitted(width as f32); - (width as f32, leading, trailing) - }) - .collect(); - for (width, leading, [low, high]) in &shown { - assert!(!(*low && !*high), "rank 2 left before rank 1 at {width}"); - if *low || *high { - assert!(leading.width() >= whole.width() - 0.5, "the leading content narrowed to {leading:?} at {width} while a trailing member stayed"); - } - } - assert!(shown.iter().any(|(_, _, [low, high])| !low && *high), "rank 1 never left alone: {shown:?}"); -} From 95c1456826b3e0fb672a55414261aa0df11ab888 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:57:26 +0700 Subject: [PATCH 41/76] ui-panels: a dense tool rail step: RailDensity::Dense packs the rail's buttons a control high, and DockGrid::density sizes the rail's column with them --- crates/ui-panels/src/docking/spec.rs | 22 +++++++++--- crates/ui-panels/src/docking/targets.rs | 16 +++++++-- crates/ui-panels/src/rails/flyout.rs | 4 +-- crates/ui-panels/src/rails/mod.rs | 4 +-- crates/ui-panels/src/rails/tool.rs | 39 ++++++++++++++++++++-- crates/ui-panels/src/rails/tool/stories.rs | 18 +++++++--- crates/ui-panels/src/rails/tool/trials.rs | 25 +++++++++++++- 7 files changed, 109 insertions(+), 19 deletions(-) diff --git a/crates/ui-panels/src/docking/spec.rs b/crates/ui-panels/src/docking/spec.rs index 8fdb6c8dd..2fed17f8f 100644 --- a/crates/ui-panels/src/docking/spec.rs +++ b/crates/ui-panels/src/docking/spec.rs @@ -3,6 +3,7 @@ use super::DockSizes; use crate::contract::SizeLimits; use crate::primitives::IconSpec; +use crate::rails::RailDensity; use crate::runtime::commands::CommandRef; use crate::runtime::env::Label; use craft_host::target::WindowKind; @@ -71,8 +72,8 @@ enum GridWidths { /// `first`: the content's width at one column, a cell and the content's own padding on both sides; `step`: the /// width each further column adds, a cell and the gap before it. Content { first: f32, step: f32 }, - /// A tool rail's cells, sized by the dock's style. - Rail, + /// A tool rail's cells at a density, sized by the dock's style. + Rail(RailDensity), } impl DockGrid { @@ -84,14 +85,25 @@ impl DockGrid { /// The grid of a tool rail of `cells` cells: a rail button and the control padding on both sides at one column, /// a button and the tight gap for each further column, in the style the dock shows it in. pub fn rail(cells: usize) -> Self { - DockGrid { widths: GridWidths::Rail, most: u16::try_from(cells).unwrap_or(u16::MAX).max(1) } + DockGrid { widths: GridWidths::Rail(RailDensity::Regular), most: u16::try_from(cells).unwrap_or(u16::MAX).max(1) } + } + + /// A [`rail`](Self::rail) grid whose cells are the buttons of a rail at `density`, as the rail shows them + /// ([`ToolRail::density`](crate::rails::ToolRail::density)); a content grid is left as it is. + #[must_use] + pub fn density(mut self, density: RailDensity) -> Self { + if let GridWidths::Rail(at) = &mut self.widths { + *at = density; + } + self } /// The grid with its widths in points: a [`rail`](Self::rail) grid takes the rail widths of `sizes`. pub fn resolved(self, sizes: &DockSizes) -> Self { match self.widths { GridWidths::Content { .. } => self, - GridWidths::Rail => DockGrid::new(sizes.rail_first, sizes.rail_step, self.most), + GridWidths::Rail(RailDensity::Regular) => DockGrid::new(sizes.rail_first, sizes.rail_step, self.most), + GridWidths::Rail(RailDensity::Dense) => DockGrid::new(sizes.dense_rail_first, sizes.dense_rail_step, self.most), } } @@ -100,7 +112,7 @@ impl DockGrid { fn first_step(self) -> (f32, f32) { match self.widths { GridWidths::Content { first, step } => (first, step), - GridWidths::Rail => (0.0, 0.0), + GridWidths::Rail(_) => (0.0, 0.0), } } diff --git a/crates/ui-panels/src/docking/targets.rs b/crates/ui-panels/src/docking/targets.rs index d1a2954d3..7aac54e64 100644 --- a/crates/ui-panels/src/docking/targets.rs +++ b/crates/ui-panels/src/docking/targets.rs @@ -6,6 +6,7 @@ use super::{DragUnit, PanelKey, PanelSpec, scale_widths, width_bounds}; use crate::contract::DropMark; +use crate::rails::RailDensity; use crate::runtime::frame::{self, PassStep, PerViewport, Stamped, Stored}; use crate::style::{RuleKind, RuleWidth, StyleCx}; use craft_behavior::DockSide; @@ -81,6 +82,10 @@ pub struct DockSizes { pub rail_first: f32, /// The width each further column of a tool rail adds: a rail button and the tight gap before it. pub rail_step: f32, + /// [`rail_first`](Self::rail_first) with the buttons of a dense rail ([`RailDensity::Dense`]). + pub dense_rail_first: f32, + /// [`rail_step`](Self::rail_step) with the buttons of a dense rail ([`RailDensity::Dense`]). + pub dense_rail_step: f32, /// The height of a grip strip, the band with the dock's grip marks: above each icon group of a collapsed column, /// and under the column bar of a tool rail (a group whose panel has a [`DockGrid`](super::DockGrid)) that the host /// shows itself: the least hit size, or the theme's grip marks with `space.gap.tight` above and below them. @@ -103,6 +108,11 @@ impl DockSizes { /// The sizes of the style context `cx`. pub fn style(cx: &StyleCx<'_>) -> Self { let size = &cx.tokens.size; + let rail = |density: RailDensity| { + let button = density.button(cx.tokens); + (button + 2.0 * cx.tokens.space.pad.control, button + cx.tokens.space.gap.tight) + }; + let ((rail_first, rail_step), (dense_rail_first, dense_rail_step)) = (rail(RailDensity::Regular), rail(RailDensity::Dense)); DockSizes { zone_depth: size.rail.width, edge_band: size.control.md, @@ -127,8 +137,10 @@ impl DockSizes { jump: cx.control().height, iconic_least: size.rail.width, column: size.dock.column, - rail_first: size.rail.button + 2.0 * cx.tokens.space.pad.control, - rail_step: size.rail.button + cx.tokens.space.gap.tight, + rail_first, + rail_step, + dense_rail_first, + dense_rail_step, grip: super::group::grip_strip(cx.tokens), } } diff --git a/crates/ui-panels/src/rails/flyout.rs b/crates/ui-panels/src/rails/flyout.rs index b724a2066..b96af1e16 100644 --- a/crates/ui-panels/src/rails/flyout.rs +++ b/crates/ui-panels/src/rails/flyout.rs @@ -1,6 +1,6 @@ //! `FlyoutButton`: a rail button that stands for a group of tools and opens them as a flyout. -use super::tool::{RailTool, SlotDrop, SlotId, ToolDrag, ToolDropped, ToolTips}; +use super::tool::{RailDensity, RailTool, SlotDrop, SlotId, ToolDrag, ToolDropped, ToolTips}; use super::words::RailWords; use crate::buttons::{IconButton, PopupMark}; use crate::contract::overlay::{Anchor, Place}; @@ -234,7 +234,7 @@ impl Component for FlyoutButton<'_, T> { type Output = FlyoutOutput; fn style(cx: &StyleCx<'_>, _: FlyoutButtonStyleKey) -> FlyoutButtonStyle { - let side = cx.tokens.size.rail.button; + let side = cx.env::().button(cx.tokens); FlyoutButtonStyle { metrics: Metrics::new().min_size(Vec2::splat(side)), mark: cx.tokens.space.gap.tight, glyphs: cx.glyph_role() } } diff --git a/crates/ui-panels/src/rails/mod.rs b/crates/ui-panels/src/rails/mod.rs index 4f8046fb2..62bda74e8 100644 --- a/crates/ui-panels/src/rails/mod.rs +++ b/crates/ui-panels/src/rails/mod.rs @@ -12,7 +12,7 @@ pub(crate) mod tool; pub use drawer::{DrawerGroup, DrawerKind, ToolbarDrawer, ToolbarDrawerOutput, ToolbarEdit, apply_toolbar_edit, drop_edit}; pub use flyout::{FlyoutButton, FlyoutButtonStyle, FlyoutOutput, SlotEdit}; pub use tool::{ - DropAt, LastUsed, RailFooter, RailTool, SlotId, ToolDrag, ToolDropped, ToolRail, ToolRailOutput, ToolRailStyle, ToolSlot, ToolTips, drop_in_slot, - remembered, shown_tool, visible_slots, + DropAt, LastUsed, RailDensity, RailFooter, RailTool, SlotId, ToolDrag, ToolDropped, ToolRail, ToolRailOutput, ToolRailStyle, ToolSlot, ToolTips, + drop_in_slot, remembered, shown_tool, visible_slots, }; pub use words::RailWords; diff --git a/crates/ui-panels/src/rails/tool.rs b/crates/ui-panels/src/rails/tool.rs index 50730b552..9f34062de 100644 --- a/crates/ui-panels/src/rails/tool.rs +++ b/crates/ui-panels/src/rails/tool.rs @@ -15,8 +15,8 @@ use crate::layout::RowAlign; use crate::layout_components::{Row, Stack}; use crate::runtime::access::Name; use crate::runtime::commands::resolver_in; -use crate::runtime::env::Label; -use crate::style::{ComponentStyle, GlyphRole, StyleCx, SurfaceKind, TypeRole}; +use crate::runtime::env::{AppValues, EnvValue, Label}; +use crate::style::{ComponentStyle, GlyphRole, StyleCx, SurfaceKind, TypeRole, UiTokens}; use crate::tabs::TornOff; use craft_behavior::overlay::Side; use craft_behavior::{IconId, Metrics, NavShape, Proposal, Roving, Sense, Value}; @@ -38,6 +38,30 @@ use drag::RailDrop; pub(crate) use drag::SlotDrop; pub use drag::{DropAt, ToolDrag, ToolDropped, drop_in_slot}; +/// How tightly a tool rail packs its buttons. A rail publishes its density to its content ([`ToolRail::density`]), +/// and the dock sizes the rail's column from the same density ([`DockGrid::density`]). +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, EnvValue, MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum RailDensity { + /// Buttons `size.rail.button` square. + #[default] + Regular, + /// Buttons a control high (`size.control.md`) square: a denser step than the scope's density gives, for an app + /// whose compact toolbar packs its tools tighter than its other controls. + Dense, +} + +impl RailDensity { + /// The side of a rail button at this density. + pub fn button(self, tokens: &UiTokens) -> f32 { + match self { + RailDensity::Regular => tokens.size.rail.button, + RailDensity::Dense => tokens.size.control.md, + } + } +} + /// What the footer closure of [`ToolRail::show_rail`] is told. #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[non_exhaustive] @@ -158,6 +182,9 @@ pub struct ToolRail<'a, T: Value + MemoProps + PlainData + 'static> { /// The tips the tools' buttons and flyout rows show in place of the command tooltip, where a tool has one. #[prop] tips: Option<&'a dyn ToolTips>, + /// How tightly the rail packs its buttons; its columns follow the rail grid at that density. + #[prop] + density: RailDensity, footer: Option>, /// The columns the rail lays out in this pass. columns: usize, @@ -194,6 +221,7 @@ impl<'a, T: Value + MemoProps + PlainData + 'static> ToolRail<'a, T> { mark: None, reveal: None, tips: None, + density: RailDensity::Regular, footer: None, columns: 1, shown: Rc::default(), @@ -225,7 +253,7 @@ impl<'a, T: Value + MemoProps + PlainData + 'static> ToolRail<'a, T> { Some(scope) => StyleCx::with_root_scoped(ui.ctx(), scope, DockSizes::style), None => DockSizes::of_scope(ui), }; - DockGrid::rail(cells).resolved(&sizes) + DockGrid::rail(cells).density(self.density).resolved(&sizes) } /// Sets up the pass for a rail `width` wide: its columns, its roving grid and its footer. Returns what the body @@ -517,6 +545,11 @@ impl Component for ToolRail<'_, T> { } } + /// The rail's density reaches its buttons. + fn content_env(&self, _: &Cx<'_, Self>, values: &mut AppValues) { + values.set(self.density); + } + /// While the toolbar is edited the rail takes the drops its buttons do not: a blank toolbar's, and those in the room /// around the buttons. It registers after them, and declines over them. fn finish(self, mut cx: Cx<'_, Self>) -> ToolRailOutput { diff --git a/crates/ui-panels/src/rails/tool/stories.rs b/crates/ui-panels/src/rails/tool/stories.rs index 65ad66d16..c15ee0579 100644 --- a/crates/ui-panels/src/rails/tool/stories.rs +++ b/crates/ui-panels/src/rails/tool/stories.rs @@ -1,9 +1,8 @@ //! Stories of `ToolRail`, and the commands its stories and the flyout's use as tools. -use super::{LastUsed, RailTool, ToolRail, ToolRailOutput, ToolSlot, ToolTips}; +use super::{LastUsed, RailDensity, RailTool, ToolRail, ToolRailOutput, ToolSlot, ToolTips}; use crate::contract::{MemoProps, Show as _, Tracked}; use crate::display::{Shade, Text}; -use crate::docking::{DockGrid, DockSizes}; use crate::runtime::env::Env; use crate::style::TypeRole; use crate::testing::{Drive, StoryData, StoryOutput, story}; @@ -66,10 +65,10 @@ fn captioned_slots() -> Vec> { ] } -/// Shows `rail` in a room as wide as the grid of `cells` cells at `columns` columns, the stage a dock column of that +/// Shows `rail` in a room as wide as its grid of `cells` cells at `columns` columns, the stage a dock column of that /// many steps gives it, at the reading start and at most `height` high. fn in_columns(ui: &mut Ui, columns: u8, cells: usize, height: Option, rail: ToolRail<'_, u8>) -> ToolRailOutput { - let width = DockGrid::rail(cells).resolved(&DockSizes::of_scope(ui)).width(u16::from(columns)); + let width = rail.grid(ui, cells).width(u16::from(columns)); let room = Flow::new(ui.available_rect_before_wrap(), Env::of(ui).direction.is_rtl()).span(0.0, width); ui.scope_builder(UiBuilder::new().max_rect(room), |ui| { if let Some(height) = height { @@ -116,6 +115,17 @@ fn tool_rail_captions(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { in_columns(ui, columns, slots.len(), None, ToolRail::new("Tools", &slots, &0, &last).captions()).into() } +/// The rail at each density in one or two columns: a dense rail's buttons are a control high, and its columns narrow +/// with them. +#[story(ToolRail<'static, u8>, covers = [], drive = Drive::Never)] +fn tool_rail_density(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let columns = *data.ranged("columns", 1_u8, 1.0..=2.0); + let density = *data.choice("density", RailDensity::Dense, &[("Regular", RailDensity::Regular), ("Dense", RailDensity::Dense)]); + let slots = Tracked::new(slots()); + let last = Tracked::new(LastUsed::default()); + in_columns(ui, columns, slots.len(), None, ToolRail::new("Tools", &slots, &BRUSH, &last).density(density)).into() +} + /// The tips of the brush and the eraser: the tool's name over what it does. #[derive(MemoProps)] struct StoryTips; diff --git a/crates/ui-panels/src/rails/tool/trials.rs b/crates/ui-panels/src/rails/tool/trials.rs index e9241575c..a5067f8bd 100644 --- a/crates/ui-panels/src/rails/tool/trials.rs +++ b/crates/ui-panels/src/rails/tool/trials.rs @@ -4,7 +4,7 @@ use super::super::FlyoutButton; use super::stories::tools; -use super::{DropAt, LastUsed, ToolRail, ToolSlot}; +use super::{DropAt, LastUsed, RailDensity, ToolRail, ToolSlot}; use crate::buttons::Button; use crate::contract::Props as _; use crate::contract::Show as _; @@ -85,6 +85,29 @@ fn a_tool_rail_lays_out_the_most_whole_columns_its_width_holds() { assert_eq!(columns_of(&wide), LABELS.len(), "a wide room fills one row"); } +/// A dense rail's buttons are smaller than a regular rail's, and its dock grid narrows with them: at the dense grid's +/// width of two steps the dense rail shows two columns, as wide as that grid, where a regular rail fits one. +#[trial] +fn a_dense_rail_and_its_grid_narrow_together() { + let ctx = Fixture::new(|_| {}).ctx().clone(); + let sizes = DockSizes::of(&ctx); + let (regular, dense) = (DockGrid::rail(LABELS.len()).resolved(&sizes), DockGrid::rail(LABELS.len()).density(RailDensity::Dense).resolved(&sizes)); + assert!(dense.width(2) < regular.width(2), "the dense grid is narrower: {dense:?} against {regular:?}"); + let shown = |density: RailDensity| { + let (slots, last) = (Tracked::new(slots()), Tracked::new(LastUsed::default())); + let mut fixture = Fixture::new(move |ui| { + ToolRail::new("Tools", &slots, &0, &last).density(density).show_rail(ui, |_, _| {}); + }); + fixture.room(Vec2::new(dense.width(2), 800.0)).settle(); + (columns_of(&fixture), rect(&fixture, "Tools"), rect(&fixture, "Move")) + }; + let ((dense_columns, rail, dense_button), (regular_columns, _, regular_button)) = (shown(RailDensity::Dense), shown(RailDensity::Regular)); + assert_eq!(dense_columns, 2, "the dense rail fills its grid's two steps"); + assert!(near(rail.width(), dense.width(2)), "the dense rail is as wide as its grid: {rail:?}"); + assert!(regular_columns < dense_columns, "a regular rail fits fewer columns in the same width"); + assert!(dense_button.width() < regular_button.width(), "a dense button ({dense_button:?}) is smaller than a regular one ({regular_button:?})"); +} + /// The measure at a width is the size the rail shows at it: exactly its rows plus the footer between equal paddings, /// and fewer columns need more rows. #[trial] From bb06692b13fe9ccca9c793b9b723d8ec487597e7 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:57:45 +0700 Subject: [PATCH 42/76] ui-widgets, ui-panels: ActiveLook::Pressed shows an icon button that is on in the pressed fill with no accent edge; ToolRail::active_look gives it to the rail's buttons --- crates/ui-panels/src/rails/tool.rs | 9 +++++++-- crates/ui-panels/src/rails/tool/stories.rs | 11 +++++++++++ crates/ui-widgets/src/buttons/face.rs | 16 ++++++++++++++-- crates/ui-widgets/src/buttons/mod.rs | 13 +++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/crates/ui-panels/src/rails/tool.rs b/crates/ui-panels/src/rails/tool.rs index 9f34062de..ecd19c185 100644 --- a/crates/ui-panels/src/rails/tool.rs +++ b/crates/ui-panels/src/rails/tool.rs @@ -3,7 +3,7 @@ use super::flyout::{FlyoutButton, SlotEdit}; use super::words::RailWords; -use crate::buttons::IconButton; +use crate::buttons::{ActiveLook, IconButton}; use crate::contract::{ Access, Common, Component, Container, ContainerProps, Cx, FooterRegion, Gap, NoValue, Outcome, Pad, Pointer as _, Props as _, Role, Scroll, Show as _, ShowContainer as _, Sizing, WordSetCx as _, @@ -185,6 +185,9 @@ pub struct ToolRail<'a, T: Value + MemoProps + PlainData + 'static> { /// How tightly the rail packs its buttons; its columns follow the rail grid at that density. #[prop] density: RailDensity, + /// How the button of the current tool shows it is on. + #[prop] + active_look: ActiveLook, footer: Option>, /// The columns the rail lays out in this pass. columns: usize, @@ -222,6 +225,7 @@ impl<'a, T: Value + MemoProps + PlainData + 'static> ToolRail<'a, T> { reveal: None, tips: None, density: RailDensity::Regular, + active_look: ActiveLook::Accent, footer: None, columns: 1, shown: Rc::default(), @@ -545,9 +549,10 @@ impl Component for ToolRail<'_, T> { } } - /// The rail's density reaches its buttons. + /// The rail's density and active look reach its buttons. fn content_env(&self, _: &Cx<'_, Self>, values: &mut AppValues) { values.set(self.density); + values.set(self.active_look); } /// While the toolbar is edited the rail takes the drops its buttons do not: a blank toolbar's, and those in the room diff --git a/crates/ui-panels/src/rails/tool/stories.rs b/crates/ui-panels/src/rails/tool/stories.rs index c15ee0579..f566e9d4a 100644 --- a/crates/ui-panels/src/rails/tool/stories.rs +++ b/crates/ui-panels/src/rails/tool/stories.rs @@ -1,6 +1,7 @@ //! Stories of `ToolRail`, and the commands its stories and the flyout's use as tools. use super::{LastUsed, RailDensity, RailTool, ToolRail, ToolRailOutput, ToolSlot, ToolTips}; +use crate::buttons::ActiveLook; use crate::contract::{MemoProps, Show as _, Tracked}; use crate::display::{Shade, Text}; use crate::runtime::env::Env; @@ -126,6 +127,16 @@ fn tool_rail_density(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { in_columns(ui, columns, slots.len(), None, ToolRail::new("Tools", &slots, &BRUSH, &last).density(density)).into() } +/// The current tool (the brush) in each active look: the accent's soft fill and edge, or the pressed fill with no +/// edge. +#[story(ToolRail<'static, u8>, covers = [], drive = Drive::Never)] +fn tool_rail_active_look(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let look = *data.choice("active look", ActiveLook::Pressed, &[("Accent", ActiveLook::Accent), ("Pressed", ActiveLook::Pressed)]); + let slots = Tracked::new(slots()); + let last = Tracked::new(LastUsed::default()); + in_columns(ui, 1, slots.len(), None, ToolRail::new("Tools", &slots, &BRUSH, &last).active_look(look)).into() +} + /// The tips of the brush and the eraser: the tool's name over what it does. #[derive(MemoProps)] struct StoryTips; diff --git a/crates/ui-widgets/src/buttons/face.rs b/crates/ui-widgets/src/buttons/face.rs index 7a331f0aa..136b28b95 100644 --- a/crates/ui-widgets/src/buttons/face.rs +++ b/crates/ui-widgets/src/buttons/face.rs @@ -1,7 +1,7 @@ //! What a push or toggle button shows: a leading icon (or spinner), a label and a trailing icon, centred in the //! button unless it aligns them to an edge, and the look parts the buttons share. -use super::{ControlPlace, GroupLevel, RibbonLook}; +use super::{ActiveLook, ControlPlace, GroupLevel, RibbonLook}; use crate::contract::{Component, Cx, MeasureCx, PaintUi, Styled as _}; use crate::list::ThumbAspect; use crate::primitives::{HAlign, IconSpec, TextLayout, TextRun}; @@ -396,7 +396,11 @@ pub(crate) struct IconFace { /// button of the old look (a capsule would round the on plate), showing the on look while on. The scope's glyph role /// sets the glyph's side and, in a rail, the quieter ink it rests in. pub(crate) fn icon_face(cx: &StyleCx<'_>) -> IconFace { - let (off, on) = (cx.variant_look(), on_parts(cx)); + let on = match cx.env::() { + ActiveLook::Accent => on_parts(cx), + ActiveLook::Pressed => pressed_parts(cx), + }; + let off = cx.variant_look(); let (icon, text) = (&cx.tokens.size.icon, &cx.tokens.color.text); let (side, rest) = match cx.glyph_role() { GlyphRole::Tool => (icon.md, None), @@ -426,6 +430,14 @@ pub(super) fn on_parts(cx: &StyleCx<'_>) -> VariantParts { VariantParts { fill: Stateful::new(fill), text: Stateful::new(ink).off(States::new(ink, ink, ink, soft.text.off.disabled)), ..soft } } +/// The on look under `ActiveLook::Pressed`: the pressed state's fill with no edge, the normal text colour. +fn pressed_parts(cx: &StyleCx<'_>) -> VariantParts { + let soft = on_parts(cx); + let colors = &cx.tokens.color; + let (fill, ink) = (cx.color(colors.state.pressed), cx.color(colors.text.normal)); + VariantParts { fill: Stateful::new(fill), text: Stateful::new(ink).off(States::new(ink, ink, ink, soft.text.off.disabled)), edge: None, ..soft } +} + /// The focus ring of a button. pub(crate) fn focus(cx: &StyleCx<'_>) -> FocusLook { cx.focus_look() diff --git a/crates/ui-widgets/src/buttons/mod.rs b/crates/ui-widgets/src/buttons/mod.rs index 101f7d9fd..3b9e5ba2a 100644 --- a/crates/ui-widgets/src/buttons/mod.rs +++ b/crates/ui-widgets/src/buttons/mod.rs @@ -63,6 +63,19 @@ 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. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, EnvValue, MemoProps)] +#[env(style)] +#[non_exhaustive] +pub enum ActiveLook { + /// The accent's soft fill and edge, with the accent's text colour. + #[default] + Accent, + /// The pressed state's fill with no edge, and the glyph in the normal text colour. + Pressed, +} + /// The style context a push or split button draws in: in a ribbon (`ControlPlace::Ribbon`) the default variant /// becomes the ghost one, so the button is flat at rest; any other variant, and any other place, stays as it is. pub(crate) fn placed<'a>(cx: &crate::style::StyleCx<'a>) -> crate::style::StyleCx<'a> { From 45a8457c7bc4338dc0d529c4f3e5fa4c09191471 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:58:00 +0700 Subject: [PATCH 43/76] ui-widgets: DocumentTab::name_len, the label's name part, which a modified tab's mark follows: "Untitled-1* @ 93.5 % (RGB/Preview)" --- crates/ui-widgets/src/tabs/document.rs | 14 ++++++ .../ui-widgets/src/tabs/document/stories.rs | 14 ++++++ crates/ui-widgets/src/tabs/tab.rs | 49 ++++++++++++++----- crates/ui-widgets/tests/it/tabs.rs | 30 ++++++++++++ 4 files changed, 95 insertions(+), 12 deletions(-) diff --git a/crates/ui-widgets/src/tabs/document.rs b/crates/ui-widgets/src/tabs/document.rs index 104182da8..ae46d1c59 100644 --- a/crates/ui-widgets/src/tabs/document.rs +++ b/crates/ui-widgets/src/tabs/document.rs @@ -28,6 +28,9 @@ pub struct DocumentTab { pub label: Label, /// Unsaved changes: the tab shows the modified mark. pub modified: bool, + /// The length in bytes of the label's name part (the document's name before its zoom and colour mode): the + /// modified mark follows the name, not the whole label. `None`: the label is all name. + pub name_len: Option, /// The tab shows a close button. pub closable: bool, /// How far the document has opened, between 0 and 1; `None` for a document that is open. @@ -49,6 +52,7 @@ impl DocumentTab { id, label: label.into(), modified: false, + name_len: None, closable: true, progress: None, detail: None, @@ -65,6 +69,13 @@ impl DocumentTab { self } + /// The label's name part: its first `len` bytes, which the modified mark follows. + #[must_use] + pub fn name_len(mut self, len: usize) -> Self { + self.name_len = Some(len); + self + } + /// Whether the tab can be closed. #[must_use] pub fn closable(mut self, on: bool) -> Self { @@ -312,6 +323,9 @@ impl<'a, D: Clone + Eq + Hash + Send + Sync + std::fmt::Debug + 'static> Documen if document.modified { tab = tab.modified(); } + if let Some(len) = document.name_len { + tab = tab.name_len(len); + } if let Some(fraction) = document.progress { tab = tab.progress(fraction); } diff --git a/crates/ui-widgets/src/tabs/document/stories.rs b/crates/ui-widgets/src/tabs/document/stories.rs index ee24bbcb2..fce3c64ac 100644 --- a/crates/ui-widgets/src/tabs/document/stories.rs +++ b/crates/ui-widgets/src/tabs/document/stories.rs @@ -63,3 +63,17 @@ fn large_document_tabs(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let out = DocumentTabs::new("Documents", &tabs).selected(shown).reorderable(true).takes_files(true).large(true).show(ui); out.response.into() } + +/// Modified tabs whose label carries the view after the document's name: with a name part (`name_len`) the modified +/// mark follows the name, "Untitled-1* @ 93.5 % (RGB/Preview)"; without one it follows the whole label. +#[story(DocumentTabs<'static, usize>, covers = [], drive = Drive::Never)] +fn document_tabs_with_name_part(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + const NAME: &str = "Untitled-1"; + let label = format!("{NAME} @ 93.5 % (RGB/Preview)"); + let tabs = [ + DocumentTab::new(0, label.clone()).modified(true).name_len(NAME.len()), + DocumentTab::new(1, label.replace(NAME, "Untitled-2")).modified(true), + ]; + let shown = *data.value("shown", 0_usize); + DocumentTabs::new("Documents", &tabs).selected(shown).show(ui).response.into() +} diff --git a/crates/ui-widgets/src/tabs/tab.rs b/crates/ui-widgets/src/tabs/tab.rs index 6bae784b4..0b69e1e72 100644 --- a/crates/ui-widgets/src/tabs/tab.rs +++ b/crates/ui-widgets/src/tabs/tab.rs @@ -7,6 +7,7 @@ use super::rules::{CloseSide, TabKind, close_side}; use super::words::TabWords; +use std::borrow::Cow; /// The width, in digits of the label role, a document tab shows of its name at most. const MAX_NAME_DIGITS: usize = 22; @@ -189,6 +190,10 @@ pub struct Tab<'a> { /// [`DocumentTabLook::Shrinking`](super::DocumentTabLook::Shrinking). #[prop(flag)] modified: bool, + /// The length in bytes of the label's name part (a document's name before its zoom and colour mode): a modified + /// tab under the `*` look shows the mark right after the name, inside the label. + #[prop] + name_len: Option, /// Whether the tab can be closed; by default whether the kind shows a close button. #[prop] closable: Option, @@ -218,6 +223,7 @@ impl<'a> Tab<'a> { detail: None, icon: None, modified: false, + name_len: None, closable: None, progress: None, close_label: None, @@ -252,9 +258,24 @@ impl<'a> Tab<'a> { self.marked || (self.modified && style.shrinking) } - /// Whether the modified mark `*` shows: a modified tab whose look shows no dot for it. - fn starred(&self, style: &TabStyle) -> bool { - self.modified && !style.shrinking + /// Where in `label` the modified mark `*` goes: after the name part, for a modified tab whose look shows no dot for + /// it. + fn mark_at(&self, style: &TabStyle, label: &str) -> Option { + self.name_len.filter(|at| self.modified && !style.shrinking && label.is_char_boundary(*at)) + } + + /// Whether the modified mark `*` shows after the text: a modified tab whose look shows no dot for it, and whose + /// label holds no name part for the mark to follow. + fn starred(&self, style: &TabStyle, label: &str) -> bool { + self.modified && !style.shrinking && self.mark_at(style, label).is_none() + } + + /// The text the tab shows for `label`: the label, with the modified mark after its name part where it has one. + fn shown_label<'t>(&self, style: &TabStyle, label: &'t str) -> Cow<'t, str> { + match self.mark_at(style, label) { + Some(at) => Cow::Owned(format!("{}{MARK}{}", &label[..at], &label[at..])), + None => Cow::Borrowed(label), + } } /// The modified mark, in the label's type. @@ -285,7 +306,7 @@ impl<'a> Tab<'a> { let label_natural = natural(&self.label_run(style, label)); let detail_natural = self.detail_text().map_or(0.0, |text| natural(&TextRun::new(text).role(style.detail.role))); // The marks keep their room; the label is cut first, then the detail. - let mark_width = if self.starred(style) { natural(&self.mark_run(style)) } else { 0.0 }; + let mark_width = if self.starred(style, label) { natural(&self.mark_run(style)) } else { 0.0 }; let marker_width = if self.dotted(style) { sizes.gap + style.marker } else { 0.0 }; let marks = mark_width + marker_width; let detail_gap = if detail_natural > 0.0 { sizes.gap } else { 0.0 }; @@ -424,16 +445,18 @@ impl Component for Tab<'_> { fn measure(&mut self, cx: &MeasureCx<'_, Self>) -> Vec2 { let sizes = &cx.style.sizes; + let shown = self.shown_label(cx.style, cx.resolved.label); + let label: &str = &shown; // The first letters of the title: the least a shrunk tab shows. let letters = || { - let first: String = cx.resolved.label.chars().take(MIN_LETTERS).collect(); + let first: String = label.chars().take(MIN_LETTERS).collect(); cx.layout_at(&self.label_run(cx.style, &first), f32::INFINITY).size().x }; if cx.proposal == Proposal::Min && !cx.style.shrinking { return Vec2::new(letters(), sizes.label_line); } let width = |run: &TextRun<'_>| cx.layout_at(run, f32::INFINITY).size().x; - let label_width = width(&self.label_run(cx.style, cx.resolved.label)); + let label_width = width(&self.label_run(cx.style, label)); // A document tab never takes more than a name of `MAX_NAME_DIGITS` digits' width, as production's tabs cut a long // name short so the other tabs and the Open control keep their room; the label is cut with an ellipsis. let capped = if cx.style.shrinking { label_width.min(width(&self.label_run(cx.style, &"0".repeat(MAX_NAME_DIGITS)))) } else { label_width }; @@ -444,7 +467,7 @@ impl Component for Tab<'_> { if let Some(detail) = self.detail_text() { natural += sizes.gap + width(&TextRun::new(detail).role(cx.style.detail.role)); } - if self.starred(cx.style) { + if self.starred(cx.style, label) { natural += width(&self.mark_run(cx.style)); } if self.dotted(cx.style) { @@ -454,8 +477,8 @@ impl Component for Tab<'_> { natural += sizes.gap + sizes.close_box; } let measured = if cx.proposal == Proposal::Min { - let end = cx.resolved.label.char_indices().nth(12).map_or(cx.resolved.label.len(), |(index, _)| index); - let prefix = cx.resolved.label.get(..end).unwrap_or(cx.resolved.label); + let end = label.char_indices().nth(12).map_or(label.len(), |(index, _)| index); + let prefix = label.get(..end).unwrap_or(label); let readable = natural - capped + width(&self.label_run(cx.style, prefix)); readable.max(letters()).min(natural) } else { @@ -469,7 +492,8 @@ impl Component for Tab<'_> { } fn parts(&mut self, rect: Rect, cx: &mut PartsCx<'_, Self>) { - let placed = self.place(cx.style, cx.content_rect, cx.flow.is_rtl(), cx.resolved.label, |run| cx.layout_at(run, f32::INFINITY).size().x); + let shown = self.shown_label(cx.style, cx.resolved.label); + let placed = self.place(cx.style, cx.content_rect, cx.flow.is_rtl(), &shown, |run| cx.layout_at(run, f32::INFINITY).size().x); if placed.cut { let full = match self.detail_text() { Some(detail) => format!("{}, {detail}", cx.resolved.label), @@ -530,7 +554,8 @@ impl Component for Tab<'_> { let sizes = style.sizes; let selected = cx.resolved.selected == Some(true) || cx.state().flags.contains(Flags::SELECTED); let draw = ui.draw(); - let placed = self.place(style, cx.content_rect, cx.flow.is_rtl(), cx.resolved.label, |run| draw.layout(run, f32::INFINITY).size().x); + let shown = self.shown_label(style, cx.resolved.label); + let placed = self.place(style, cx.content_rect, cx.flow.is_rtl(), &shown, |run| draw.layout(run, f32::INFINITY).size().x); if style.divider { draw.edge_rule(RuleKind::Divider, rect, RectSide::end(cx.flow.is_rtl())); } @@ -545,7 +570,7 @@ impl Component for Tab<'_> { draw.stroke(&line, StrokeWidth::Thick, style.underline); } let role = if selected { style.label.role } else { style.idle_role }; - let label = TextRun::new(cx.resolved.label).role(role).color(cx.resolve(&style.label.color)); + let label = TextRun::new(&*shown).role(role).color(cx.resolve(&style.label.color)); draw.text(placed.label, &if self.kind.clips_label() { label.wrap(Wrap::Clip) } else { label.elide() }); if let (Some(at), Some(detail)) = (placed.detail, self.detail_text()) { draw.text(at, &TextRun::new(detail).role(style.detail.role).color(cx.resolve(&style.detail.color)).elide()); diff --git a/crates/ui-widgets/tests/it/tabs.rs b/crates/ui-widgets/tests/it/tabs.rs index 5c080d624..a301700c1 100644 --- a/crates/ui-widgets/tests/it/tabs.rs +++ b/crates/ui-widgets/tests/it/tabs.rs @@ -317,6 +317,36 @@ fn a_document_tab_shows_its_own_tooltip() { } } +/// A modified document tab with a name part shows the `*` right after the name, inside its text, and takes the mark's +/// room once, as the same tab whose `*` follows the whole label does. +#[trial] +fn a_modified_tab_shows_its_mark_after_the_name_part() { + use craft_ui::tabs::{DocumentTab, DocumentTabs}; + const NAME: &str = "Untitled-1"; + const LABEL: &str = "Untitled-1 @ 93.5 % (RGB/Preview)"; + let shown = |name_len: Option| { + let mut fixture = Fixture::new(move |ui| { + let mut tab = DocumentTab::new(0_usize, LABEL).modified(true); + if let Some(len) = name_len { + tab = tab.name_len(len); + } + let _ = DocumentTabs::new("Documents", &[tab]).show(ui); + }); + fixture.room(egui::Vec2::new(640.0, 120.0)).settle(); + let texts: Vec<(String, Rect)> = fixture.texts().iter().map(|run| (run.text.clone(), run.rect)).collect(); + (texts, tab_rects(fixture.tree(), &format!("{LABEL}, modified")).first().copied()) + }; + let (named, named_tab) = shown(Some(NAME.len())); + let (whole, whole_tab) = shown(None); + assert!(named.iter().any(|(text, _)| text == "Untitled-1* @ 93.5 % (RGB/Preview)"), "the mark follows the name: {named:?}"); + assert!(!named.iter().any(|(text, _)| text == "*"), "and is not drawn again after the label: {named:?}"); + let star = whole.iter().find(|(text, _)| text == "*").map(|(_, rect)| *rect).expect("without a name part the mark follows the label"); + assert!(whole.iter().any(|(text, _)| text == LABEL), "and the label is drawn whole: {whole:?}"); + let (named_tab, whole_tab) = (named_tab.expect("the named tab's node"), whole_tab.expect("the whole tab's node")); + let apart = (named_tab.width() - whole_tab.width()).abs(); + assert!(apart < star.width() / 2.0, "the mark takes its room once: {named_tab:?} against {whole_tab:?}, the mark {star:?}"); +} + /// A middle click on a document tab asks to close it, unless the tab cannot close; it does not show the tab. #[trial] fn a_middle_click_closes_a_closable_document_tab() { From 8982191687c6d6c220342043603440f12cc8bb4a Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:58:31 +0700 Subject: [PATCH 44/76] title bar: document the surface role it takes and show it on the background surface in a story --- crates/ui-shell/src/shell/title_bar/bar.rs | 3 +++ crates/ui-shell/src/shell/title_bar/bar/stories.rs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/crates/ui-shell/src/shell/title_bar/bar.rs b/crates/ui-shell/src/shell/title_bar/bar.rs index fdd75f67b..027f366b8 100644 --- a/crates/ui-shell/src/shell/title_bar/bar.rs +++ b/crates/ui-shell/src/shell/title_bar/bar.rs @@ -50,6 +50,9 @@ impl Outcome for TitleBarOutput { /// The bar of a window whose frame the app draws. /// +/// The bar paints the chrome surface; `surface` names another role (`SurfaceKind::Background` for an app whose title +/// bar is darker than its other bars). +/// /// The bar fills the width of its room; its height is its content's, the caption strip's `SlotSize::TitleBar`. What it shows follows the window's frame /// (`WindowHost::frame`): /// diff --git a/crates/ui-shell/src/shell/title_bar/bar/stories.rs b/crates/ui-shell/src/shell/title_bar/bar/stories.rs index ca430996e..603af173a 100644 --- a/crates/ui-shell/src/shell/title_bar/bar/stories.rs +++ b/crates/ui-shell/src/shell/title_bar/bar/stories.rs @@ -5,6 +5,7 @@ use crate::contract::Show as _; use crate::display::Text; use crate::shell::Title; use crate::shell::{Caption, CaptionFamily, Captions, Frame, MacInset}; +use crate::style::SurfaceKind; use crate::testing::{Drive, StoryData, StoryOutput, story}; use craft_window::Layout; use egui::Ui; @@ -57,3 +58,11 @@ fn title_bar_action_title(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { fn title_bar_native(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { TitleBar::new().frame(Frame::Native).title_when_native().show_titled(ui, Title::new("Landscape.psd"), menu, tools).into() } + +/// A title bar on the window's background surface instead of the chrome surface (an app whose title bar is darker +/// than its other bars). +#[story(TitleBar<'static>, covers = [], drive = Drive::Never)] +fn title_bar_on_background(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { + let frame = captions(CaptionFamily::Windows, &[], &[Caption::Minimize, Caption::Maximize, Caption::Close]); + TitleBar::new().frame(frame).surface(SurfaceKind::Background).show_titled(ui, Title::new("Landscape.psd"), menu, tools).into() +} From 0d8d3f9c9a9c7c7b0aeea32c9eea9520571cf000 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 12:59:49 +0700 Subject: [PATCH 45/76] ui-canvas: TaskBar::member_gap(Gap) spaces the bar's members, through a new Bar::gap --- crates/ui-canvas/src/canvas_controls/task_bar.rs | 16 +++++++++++++--- .../src/canvas_controls/task_bar/stories.rs | 8 +++++++- crates/ui-widgets/src/bars/bar.rs | 8 ++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/crates/ui-canvas/src/canvas_controls/task_bar.rs b/crates/ui-canvas/src/canvas_controls/task_bar.rs index 0ffffab13..dc2148c50 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar.rs @@ -10,8 +10,8 @@ use crate::buttons::IconButton; use crate::canvas::canvas_space; use crate::contract::overlay::{Anchor, Dismiss, Outside, Place, PlacementChange, PlacementKind}; use crate::contract::{ - Bind, BindMut, Common, Component, Container, ContainerProps, Cx, DragBand, HeaderRegion, Inner, MeasureCx, Mount, NoValue, Outcome, Overlay, Pad, - PaintUi, PopupKind, Props as _, Role, Show as _, ShowContainer as _, Sizing, Styled as _, Trigger, + Bind, BindMut, Common, Component, Container, ContainerProps, Cx, DragBand, Gap, HeaderRegion, Inner, MeasureCx, Mount, NoValue, Outcome, Overlay, + Pad, PaintUi, PopupKind, Props as _, Role, Show as _, ShowContainer as _, Sizing, Styled as _, Trigger, }; use crate::display::{Divider, Icon}; use crate::menu::{Menu, MenuItem, PanelMenu, PanelRow}; @@ -116,6 +116,10 @@ pub struct TaskBar<'a> { /// How the task bar's grip looks: the `grip` icon by default. #[prop] grip: TaskBarGrip, + /// The space between the bar's members, in place of the tool bar's tight gap: `Gap::Item` sets them a control gap + /// apart. + #[prop(into)] + member_gap: Option, } /// What a bar hangs from: the screen bounds of document points, or the canvas view's top edge, aligned in reading @@ -275,6 +279,7 @@ impl<'a> TaskBar<'a> { dismiss: TaskBarDismiss::Close, compact: false, grip: TaskBarGrip::Icon, + member_gap: None, } } @@ -302,6 +307,7 @@ impl<'a> TaskBar<'a> { dismiss: TaskBarDismiss::Close, compact: false, grip: TaskBarGrip::Icon, + member_gap: None, } } @@ -330,7 +336,7 @@ impl<'a> TaskBar<'a> { /// Shows the bar inside `area`; `body` fills its members. pub fn show(self, ui: &mut Ui, area: Rect, mut body: impl FnMut(&mut Ui, &mut TaskBarCx<'_>) -> R) -> Inner { - let TaskBar { label, hang, mut place, rows, kind, side, align, keep_clear, dismiss, compact, grip: grip_look } = self; + let TaskBar { label, hang, mut place, rows, kind, side, align, keep_clear, dismiss, compact, grip: grip_look, member_gap } = self; let side = side.unwrap_or(match kind { TaskBarKind::Task | TaskBarKind::Fixed => Side::Below, TaskBarKind::Selection => Side::Above, @@ -382,6 +388,10 @@ impl<'a> TaskBar<'a> { let bar = Bar::new(Label::Empty, BarKind::Tool).surface(SurfaceKind::Floating).wrap(); // A compact bar takes a popup's smaller corners and lighter shadow, as production's small frame. let bar = if compact { bar.compact().surface(SurfaceKind::Popup) } else { bar }; + let bar = match member_gap { + Some(gap) => bar.gap(gap), + None => bar, + }; bar.show(ui, |ui, _| { match (&grip, grip_look) { (Some(grip), TaskBarGrip::Bar) => { diff --git a/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs b/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs index 2dd55983c..ccf182780 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs @@ -3,7 +3,7 @@ use super::{TaskBar, TaskBarDismiss, TaskBarGrip, TaskBarPlace}; use crate::buttons::{Button, IconButton}; use crate::canvas::testing::canvas_story::{StoryDocument, on_canvas}; -use crate::contract::{Props as _, Show as _}; +use crate::contract::{Gap, Props as _, Show as _}; use crate::menu::PanelRow; use crate::runtime::commands::{CommandRef, EditCommands}; use crate::testing::{Drive, Fixture, StoryData, StoryOutput, story}; @@ -231,3 +231,9 @@ fn bar_grip_hovered(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { fn bar_grip_dragged(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { configured(ui, data, &turned_frame(), None, |bar| bar.grip(TaskBarGrip::Bar)) } + +/// A bar whose members stand a control gap apart. +#[story(TaskBar<'static>, covers = [], drive = Drive::Never)] +fn control_gap(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + configured(ui, data, &turned_frame(), None, |bar| bar.member_gap(Gap::Item)) +} diff --git a/crates/ui-widgets/src/bars/bar.rs b/crates/ui-widgets/src/bars/bar.rs index fcceca8a1..df8c682a8 100644 --- a/crates/ui-widgets/src/bars/bar.rs +++ b/crates/ui-widgets/src/bars/bar.rs @@ -177,6 +177,14 @@ impl<'a> Bar<'a> { self } + /// Spaces the members `gap` apart in place of the kind's spacing: a canvas's task bar can set its members the bar's + /// control gap (`Gap::Item`) apart. + #[must_use] + pub fn gap(mut self, gap: Gap) -> Self { + self.props = self.props.body_gap(gap); + self + } + /// Paints `kind` behind the bar instead of the chrome: a bar that floats on its own, as a canvas's task bar does, /// is a floating surface with its corners and shadow. #[must_use] From 1a17a4963c51f1d8f33dfdda2248e91d049fcc5f Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 13:06:08 +0700 Subject: [PATCH 46/76] ui-canvas: TaskBar::hang_gap(TaskBarHang::ClearOfHandles) hangs the bar the handle ring and a section gap from its anchor --- crates/ui-canvas/src/canvas_controls/mod.rs | 2 +- .../ui-canvas/src/canvas_controls/task_bar.rs | 29 +++++++++++++++---- .../src/canvas_controls/task_bar/stories.rs | 8 ++++- .../tests/it/canvas_controls/task_bar.rs | 17 ++++++++++- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/crates/ui-canvas/src/canvas_controls/mod.rs b/crates/ui-canvas/src/canvas_controls/mod.rs index dcf80ef45..732817ba2 100644 --- a/crates/ui-canvas/src/canvas_controls/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/mod.rs @@ -27,7 +27,7 @@ pub use line_preview::{LineGuideStyle, StraightLinePreview}; pub use marquee::{Marquee, MarqueeLook, MarqueeShape, MarqueeStyle, Run}; pub use outline::{HoverMask, HoverOutline, HoverShape, OutlineStyle, SelectionOutline, SelectionOutlineLook, path_runs}; pub use pixel_grid::{GridSegment, PixelGrid, PixelGridStyle}; -pub use task_bar::{TaskBar, TaskBarCx, TaskBarDismiss, TaskBarGrip, TaskBarKind, TaskBarOutput, TaskBarPlace}; +pub use task_bar::{TaskBar, TaskBarCx, TaskBarDismiss, TaskBarGrip, TaskBarHang, TaskBarKind, TaskBarOutput, TaskBarPlace}; // End of canvas-controls-b. // Brush overlays. diff --git a/crates/ui-canvas/src/canvas_controls/task_bar.rs b/crates/ui-canvas/src/canvas_controls/task_bar.rs index dc2148c50..669d2136d 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar.rs @@ -68,10 +68,10 @@ impl TaskBarPlace { /// members and a More menu (Hide, Pin, Reset, then the host's rows). One place, pin and Hide setting for Crop and /// Frame. /// -/// - Place: on `side` of the anchor's bounds on screen (below, centred, by default), a section gap away, following the -/// anchor each pass; it flips to the other side when there is no room. Dragged by its grip (any free point of the -/// bar), it keeps its offset from that place while the anchor moves or the bar grows; a press with no drag changes -/// nothing. A moved bar whose offset place would cover the `keep_clear` point shows at its unmoved place and keeps +/// - Place: on `side` of the anchor's bounds on screen (below, centred, by default), a section gap away (or as far as +/// [`hang_gap`](Self::hang_gap) says), following the anchor each pass; it flips to the other side when there is no +/// room. Dragged by its grip (any free point of the bar), it keeps its offset from that place while the anchor moves +/// or the bar grows; a press with no drag changes nothing. A moved bar whose offset place would cover the `keep_clear` point shows at its unmoved place and keeps /// its offset. Pinned, it stays where it shows. /// - Area: the bar shows inside `area` (the canvas rect): a move stays inside it, and a stored place outside it comes /// back inside, its left and top edges winning where the bar does not fit. Its members continue on a new line when @@ -120,6 +120,9 @@ pub struct TaskBar<'a> { /// apart. #[prop(into)] member_gap: Option, + /// How far from its anchor's bounds a bar hung from document points hangs: a section gap by default. + #[prop] + hang_gap: TaskBarHang, } /// What a bar hangs from: the screen bounds of document points, or the canvas view's top edge, aligned in reading @@ -157,6 +160,17 @@ pub enum TaskBarGrip { Bar, } +/// How far from its anchor's bounds a [`TaskBar`] hangs. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +#[non_exhaustive] +pub enum TaskBarHang { + /// A section gap away. + #[default] + Gap, + /// The handle ring and a section gap away: clear of a selection's handles on that side and their hit area. + ClearOfHandles, +} + /// What an outside press does to a [`TaskBar`]. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] #[non_exhaustive] @@ -280,6 +294,7 @@ impl<'a> TaskBar<'a> { compact: false, grip: TaskBarGrip::Icon, member_gap: None, + hang_gap: TaskBarHang::Gap, } } @@ -308,6 +323,7 @@ impl<'a> TaskBar<'a> { compact: false, grip: TaskBarGrip::Icon, member_gap: None, + hang_gap: TaskBarHang::Gap, } } @@ -336,7 +352,7 @@ impl<'a> TaskBar<'a> { /// Shows the bar inside `area`; `body` fills its members. pub fn show(self, ui: &mut Ui, area: Rect, mut body: impl FnMut(&mut Ui, &mut TaskBarCx<'_>) -> R) -> Inner { - let TaskBar { label, hang, mut place, rows, kind, side, align, keep_clear, dismiss, compact, grip: grip_look, member_gap } = self; + let TaskBar { label, hang, mut place, rows, kind, side, align, keep_clear, dismiss, compact, grip: grip_look, member_gap, hang_gap } = self; let side = side.unwrap_or(match kind { TaskBarKind::Task | TaskBarKind::Fixed => Side::Below, TaskBarKind::Selection => Side::Above, @@ -354,7 +370,8 @@ impl<'a> TaskBar<'a> { bounds.extend_with(at); bounds }); - let gap = env.tokens.space.gap.section; + let clear = if hang_gap == TaskBarHang::ClearOfHandles { env.tokens.size.handle.ring } else { 0.0 }; + let gap = env.tokens.space.gap.section + clear; // A fixed bar keeps the gap on both sides of its anchor: it opens above when there is no room below. let rect = if kind == TaskBarKind::Fixed { bounds.expand2(Vec2::new(0.0, gap)) } else { hang_rect(bounds, gap, side) }; (room && bounds.is_finite()).then(|| Hung { diff --git a/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs b/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs index ccf182780..0f9e0c80d 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar/stories.rs @@ -1,6 +1,6 @@ //! Stories of `TaskBar`. -use super::{TaskBar, TaskBarDismiss, TaskBarGrip, TaskBarPlace}; +use super::{TaskBar, TaskBarDismiss, TaskBarGrip, TaskBarHang, TaskBarPlace}; use crate::buttons::{Button, IconButton}; use crate::canvas::testing::canvas_story::{StoryDocument, on_canvas}; use crate::contract::{Gap, Props as _, Show as _}; @@ -237,3 +237,9 @@ fn bar_grip_dragged(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { fn control_gap(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { configured(ui, data, &turned_frame(), None, |bar| bar.member_gap(Gap::Item)) } + +/// A bar hung clear of the frame's handles: the handle ring and a section gap below it. +#[story(TaskBar<'static>, covers = [], drive = Drive::Never)] +fn clear_of_handles(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + configured(ui, data, &turned_frame(), None, |bar| bar.hang_gap(TaskBarHang::ClearOfHandles)) +} diff --git a/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs b/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs index 8cb8ae5fa..6aa85685b 100644 --- a/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/tests/it/canvas_controls/task_bar.rs @@ -6,7 +6,7 @@ use craft_behavior::CanvasView; use craft_behavior::kurbo::{Point, Vec2 as DocVec}; use craft_behavior::overlay::{Align, Side}; use craft_ui::buttons::Button; -use craft_ui::canvas_controls::{TaskBar, TaskBarDismiss, TaskBarGrip, TaskBarPlace}; +use craft_ui::canvas_controls::{TaskBar, TaskBarDismiss, TaskBarGrip, TaskBarHang, TaskBarPlace}; use craft_ui::contract::{Bind, Show as _}; use craft_ui::menu::PanelRow; use craft_ui::runtime::commands::{CommandRef, EditCommands}; @@ -554,3 +554,18 @@ fn the_bar_grip_lights_under_the_pointer_and_while_the_bar_moves() { let dropped = fixture.by_label("Move bar").expect("the grip is named"); assert_eq!(grip_ink(&fixture.frame_shapes(), dropped.rect), Some(rest), "the grip is back to rest once dropped and left"); } + +/// A bar hung clear of the handles hangs farther below its anchor than the default, by the handle ring at least. +#[trial] +fn a_bar_clear_of_the_handles_hangs_farther_below_its_anchor() { + let below = |configure: fn(TaskBar<'_>) -> TaskBar<'_>| { + let scene = scene(); + let mut fixture = fixture_with(&scene, configure); + fixture.settle(); + let seen = seen(&scene); + seen.rect.top() - seen.bounds.bottom() + }; + let (default, clear) = (below(|bar| bar), below(|bar| bar.hang_gap(TaskBarHang::ClearOfHandles))); + assert!(default > 0.0, "the bar hangs below its anchor: {default}"); + assert!(clear > default + 2.0 * SLACK, "the bar clear of the handles hangs farther below: {clear} against {default}"); +} From b808cac9fc0b9531da220f02e0049d9c454ebb2c Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 13:10:03 +0700 Subject: [PATCH 47/76] labels: GlyphColon::Form gives a glyph caption (GlyphLabel::caption) a form's colon; draw's X/Y/W/H are captions --- crates/draw/src/ui/artboard/properties.rs | 2 +- crates/draw/src/ui/shape/panel.rs | 2 +- .../draw/src/ui/transform/transform_fields.rs | 2 +- crates/ui-contract/src/contract/label.rs | 2 +- crates/ui-contract/src/contract/label/leaf.rs | 16 +++++---- .../ui-contract/src/contract/label/props.rs | 35 ++++++++++++++++-- crates/ui-contract/src/contract/mod.rs | 2 +- crates/ui-widgets/src/form/stories.rs | 32 +++++++++++++++-- crates/ui-widgets/tests/it/label/scheme.rs | 36 +++++++++++++++++-- 9 files changed, 109 insertions(+), 20 deletions(-) diff --git a/crates/draw/src/ui/artboard/properties.rs b/crates/draw/src/ui/artboard/properties.rs index 3951d5e6b..aa3521991 100644 --- a/crates/draw/src/ui/artboard/properties.rs +++ b/crates/draw/src/ui/artboard/properties.rs @@ -87,7 +87,7 @@ impl<'a> ArtboardProperties<'a> { }); // A glyph-labelled number field; the pairs share a row, as W and H in the shape panel. let field = |ui: &mut Ui, glyph: &Label, name: &Label, value: f64, range: &RangeInclusive| { - let side = SideLabel::new().kind(LabelKind::Glyph(GlyphLabel::text(glyph.clone()))).scrub(true); + let side = SideLabel::new().kind(LabelKind::Glyph(GlyphLabel::caption(glyph.clone()))).scrub(true); Field::new(name.clone()) .side(side) .show(ui, |ui, _| { diff --git a/crates/draw/src/ui/shape/panel.rs b/crates/draw/src/ui/shape/panel.rs index c0fadd96e..7dbd80260 100644 --- a/crates/draw/src/ui/shape/panel.rs +++ b/crates/draw/src/ui/shape/panel.rs @@ -527,7 +527,7 @@ impl<'p, 'a> Cells<'p, 'a> { /// The side label of a cell shown by a short glyph (W, H) instead of its caption, which scrubs it. pub(super) fn glyph_side(glyph: &Label) -> SideLabel { - SideLabel::new().kind(LabelKind::Glyph(GlyphLabel::text(glyph.clone()))).scrub(true) + SideLabel::new().kind(LabelKind::Glyph(GlyphLabel::caption(glyph.clone()))).scrub(true) } /// The change a Sides value makes: a whole number of sides in range. diff --git a/crates/draw/src/ui/transform/transform_fields.rs b/crates/draw/src/ui/transform/transform_fields.rs index b792fe940..cfc007bbf 100644 --- a/crates/draw/src/ui/transform/transform_fields.rs +++ b/crates/draw/src/ui/transform/transform_fields.rs @@ -503,7 +503,7 @@ impl Cells<'_> { /// inside the field. fn side_and_name(&self, field: TransformField, form: Form) -> (SideLabel, Label) { let words = &self.words; - let beside = |glyph: &Label| SideLabel::new().kind(LabelKind::Glyph(GlyphLabel::text(glyph.clone()))); + let beside = |glyph: &Label| SideLabel::new().kind(LabelKind::Glyph(GlyphLabel::caption(glyph.clone()))); let (side, name) = match field { TransformField::X => (beside(&words.x_glyph), &words.x_name), TransformField::Y => (beside(&words.y_glyph), &words.y_name), diff --git a/crates/ui-contract/src/contract/label.rs b/crates/ui-contract/src/contract/label.rs index b10a44bcb..49da6126c 100644 --- a/crates/ui-contract/src/contract/label.rs +++ b/crates/ui-contract/src/contract/label.rs @@ -13,5 +13,5 @@ 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, GlyphLabel, InsideLabel, LabelKind, LabelPress, LabelScheme, Scrub, SideLabel}; +pub use props::{CaptionColumn, CellWidth, FieldLayout, GlyphColon, GlyphLabel, InsideLabel, LabelKind, LabelPress, LabelScheme, 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 671948bf9..3268419fb 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, LabelKind, LabelScheme}; +use super::props::{FieldLayout, Glyph, GlyphColon, LabelKind, LabelScheme}; use super::step::LabelIn; use crate::contract::InBar; use crate::contract::{Component, Props}; @@ -411,18 +411,20 @@ impl Component for LabelLeaf { } /// The colon a beside label draws after its shown text in a form (`LabelScheme::Form`), unless that text ends in one: -/// a text label's, and in a bar a glyph text's as well ("X:"). An inspector's labels draw none. The label's node and -/// the control keep the name as given. +/// a text label's, in a bar a glyph text's as well ("X:"), and under `GlyphColon::Form` a glyph caption's. An +/// inspector's labels draw none. The label's node and the control keep the name as given. pub(super) fn colon(env: &Env, input: &LabelIn<'_>) -> Option { if input.side.layout != FieldLayout::Beside || env.values.get::() == LabelScheme::Inspector { return None; } let text = match &input.side.kind { LabelKind::Text | LabelKind::Short(_) => env.view().resolve(input.side.kind.shown(input.text)), - LabelKind::Glyph(glyph) if env.values.get::().0 => match glyph.resolved(env.view()) { - Glyph::Text(text) => text, - Glyph::Icon(_) => return None, - }, + LabelKind::Glyph(glyph) if env.values.get::().0 || (glyph.caption && env.values.get::() == GlyphColon::Form) => { + match glyph.resolved(env.view()) { + Glyph::Text(text) => text, + Glyph::Icon(_) => return None, + } + } _ => return None, }; if text.as_str().is_empty() || text.as_str().ends_with([':', '\u{ff1a}']) { diff --git a/crates/ui-contract/src/contract/label/props.rs b/crates/ui-contract/src/contract/label/props.rs index 07d50ddcc..01fd5e9c4 100644 --- a/crates/ui-contract/src/contract/label/props.rs +++ b/crates/ui-contract/src/contract/label/props.rs @@ -48,17 +48,26 @@ pub(super) enum Glyph { #[derive(Clone, Debug, PartialEq)] pub struct GlyphLabel { shown: Glyph, + /// The text stands for a word caption ([`GlyphLabel::caption`]). + pub(super) caption: bool, } impl GlyphLabel { /// Shows `icon`, as large as the control's icons. pub fn icon(icon: impl Into>) -> Self { - GlyphLabel { shown: Glyph::Icon(icon.into()) } + GlyphLabel { shown: Glyph::Icon(icon.into()), caption: false } } /// Shows `text`, resolved in the scope's language. pub fn text(text: impl Into

, Rect, &mut Ui, &mut BodyCx<'_>) + 'a, ) -> DockColumnOutput

{ - let (column, spec, auto_collapse, edge, own, arrow) = (self.column, self.spec, self.auto_collapse, self.edge, self.bar, self.arrow); + let (column, spec, auto_collapse, edge, own, arrow, card) = + (self.column, self.spec, self.auto_collapse, self.edge, self.bar, self.arrow, self.card); let mut bar = BarRecord::default(); let shown = &mut bar; let body = move |ui: &mut Ui, body: &mut BodyCx<'_>| { - let Some(sizes) = body.style::>().map(|style| style.sizes) else { return }; + let Some(style) = body.style::>() else { return }; + let sizes = DockSizes { rail_cards: card, ..style.sizes }; + let inner = card_rect(column, spec, body.rect, edge, body.env.direction().is_rtl(), &sizes); + if inner != body.rect { + // The groups' own surfaces keep to the card's rounded corners. + crate::primitives::frame_surfaces(ui, inner, style.card.radius); + } // The bar and the groups at the heights this pass's drag leaves them, in the measuring run and the real // run alike: the same plan `parts` lays out, so the dividers sit at the seams. let drags = |key: u64, divider: &Divider| divider::drag(body.part_press(DIVIDER.at(key)).phase, body.rect, false, divider); - let plan = column_plan(column, spec, body.rect, own, &sizes, drags); + let plan = column_plan(column, spec, inner, own, &sizes, drags); if own == ColumnBar::Own { let band = bar_band(ui, plan.bar, edge); *shown = show_bar(ui, band, true, auto_collapse, arrow, false, column_grip(column, spec, body)); @@ -286,11 +301,30 @@ impl<'a, P: Value + Hash + Debug + 'static> DockColumn<'a, P> { } } + /// The sizes of `style` with the column's card on or off. + fn sizes(&self, style: &DockColumnStyle) -> DockSizes { + DockSizes { rail_cards: self.card, ..style.sizes } + } + + /// Where the column's bar and groups sit in `rect`: inside its card, if it shows as one. + fn inner(&self, rect: Rect, rtl: bool, sizes: &DockSizes) -> Rect { + card_rect(self.column, self.spec, rect, self.edge, rtl, sizes) + } + fn anchor(&self, group: usize) -> Option<&P> { self.column.groups.get(group).and_then(|group| group.panels.first()) } } +/// The card of `column` in `rect`, the column's rect in a dock on the window edge `edge`: `rect` inset by the card's +/// inset ([`DockSizes::card_inset`]) on its outer side, the one towards `edge`, and on its top and bottom; `rect` for a +/// column that is no card. +fn card_rect

(column: &Column

, spec: &dyn Fn(&P) -> PanelSpec, rect: Rect, edge: DockEdge, rtl: bool, sizes: &DockSizes) -> Rect { + let inset = sizes.card_inset(column, spec); + let card = rect.shrink2(egui::vec2(0.0, inset)); + if (edge == DockEdge::Start) != rtl { card.with_min_x(card.left() + inset) } else { card.with_max_x(card.right() - inset) } +} + /// Where the groups of `column` sit in `rect`, the column's rect with its bar `bar`, as the column lays them out while /// no divider between them is dragged. pub fn group_rects

(column: &Column

, spec: &dyn Fn(&P) -> PanelSpec, rect: Rect, bar: ColumnBar, sizes: &DockSizes) -> Vec { @@ -390,7 +424,13 @@ impl Component for DockColumn<'_, P> { } fn style(cx: &StyleCx<'_>, _: DockColumnStyleKey

) -> DockColumnStyle { - DockColumnStyle { metrics: Metrics::new(), sizes: DockSizes::style(cx) } + let card = SurfaceStyle { + radius: UiTokens::corner(cx.tokens.shape.radius.surface), + edge: SurfaceEdge::None, + shadow: None, + ..cx.surface(SurfaceKind::Panel) + }; + DockColumnStyle { metrics: Metrics::new(), sizes: DockSizes::style(cx), card } } fn sense(&self) -> Sense { @@ -400,8 +440,8 @@ impl Component for DockColumn<'_, P> { /// The chevron at the bar's outer end, a divider between every two open groups and the inner edge's divider; a /// column in a floating window has the group dividers only. fn parts(&mut self, rect: Rect, cx: &mut PartsCx<'_, Self>) { - let sizes = cx.style.sizes; - let plan = column_plan(self.column, self.spec, rect, self.bar, &sizes, |_, _| None); + let sizes = self.sizes(cx.style); + let plan = column_plan(self.column, self.spec, self.inner(rect, cx.flow.is_rtl(), &sizes), self.bar, &sizes, |_, _| None); if self.bar == ColumnBar::Own && self.arrow.shown() { let (chevron, _) = bar_slots(plan.bar, self.edge, cx.flow.is_rtl()); let name = self.arrow.name(&cx.words::(), true); @@ -418,12 +458,13 @@ impl Component for DockColumn<'_, P> { } fn update(&mut self, cx: &mut Cx<'_, Self>) { - let sizes = cx.style.sizes; + let sizes = self.sizes(cx.style); let (rect, rtl, ctx) = (cx.rect, cx.flow.is_rtl(), cx.core.ctx.clone()); let own = self.bar == ColumnBar::Own; self.collapse = own && self.arrow.shown() && cx.part_activated(CHEVRON).is_some(); let Some(base) = self.laid.take() else { return }; - let mut plan = column_plan(self.column, self.spec, rect, self.bar, &sizes, |key, divider| divider::pointer(cx, DIVIDER, key, divider)); + let inner = self.inner(rect, rtl, &sizes); + let mut plan = column_plan(self.column, self.spec, inner, self.bar, &sizes, |key, divider| divider::pointer(cx, DIVIDER, key, divider)); let dividers = base.dividers(rect, sizes.reach); let keyed: Vec<(u64, Divider)> = dividers.iter().map(|(key, _, divider)| (*key, *divider)).collect(); if let Some((key, coord)) = divider::keys(cx, DIVIDER, &keyed, sizes.step, sizes.jump) @@ -455,9 +496,19 @@ impl Component for DockColumn<'_, P> { fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { let Some(plan) = self.laid.as_ref() else { return }; // Painted here, not as the container's surface, which lies over what `paint` draws. - ui.draw().surface(cx.rect, SurfaceKind::Panel, Corners::All); + let card = self.inner(cx.rect, cx.flow.is_rtl(), &self.sizes(cx.style)); + let carded = card != cx.rect; + if carded { + // The card on the dock's background; the bar is part of the card. + ui.draw().surface(cx.rect, SurfaceKind::Background, Corners::None); + ui.draw().surface_styled(card, &cx.style.card); + } else { + ui.draw().surface(cx.rect, SurfaceKind::Panel, Corners::All); + } if self.bar == ColumnBar::Own { - ui.draw().surface(plan.bar, SurfaceKind::Background, Corners::None); + if !carded { + ui.draw().surface(plan.bar, SurfaceKind::Background, Corners::None); + } if self.arrow.shown() { paint_chevron(ui, self.edge, self.arrow, true, cx.flow.is_rtl(), &cx.words::()); } @@ -473,19 +524,22 @@ impl Component for DockColumn<'_, P> { } return; } - ui.draw().surface(cx.rect, SurfaceKind::Frame, Corners::None); + // A card has no frame. + if self.inner(cx.rect, cx.flow.is_rtl(), &self.sizes(cx.style)) == cx.rect { + ui.draw().surface(cx.rect, SurfaceKind::Frame, Corners::None); + } for pair in plan.open.windows(2) { ui.face(DIVIDER.at(pair[0] as u64), Splitter::new(Axis::Y)); } // The edge's line lies on the column's inner edge, over the frame; its handle stays inside the column. - let (rect, edge) = (cx.rect, self.edge_divider(cx.rect, &cx.style.sizes)); + let (rect, edge) = (cx.rect, self.edge_divider(cx.rect, &self.sizes(cx.style))); let x = if cx.flow.is_rtl() { rect.right() - (edge.at - rect.left()) } else { edge.at }; ui.face(EDGE.at(0), Splitter::new(Axis::X).boundary(x)); } fn access(&self, access: &mut Access, cx: &Cx<'_, Self>) { let words = cx.words::(); - let sizes = cx.style.sizes; + let sizes = self.sizes(cx.style); let Some(plan) = self.laid.as_ref() else { return }; for (key, _, divider) in plan.dividers(cx.rect, sizes.reach) { divider::describe(access, DIVIDER, key, ÷r, words.resize.as_str(), sizes.step); diff --git a/crates/ui-panels/src/docking/dock_column/stories.rs b/crates/ui-panels/src/docking/dock_column/stories.rs index 9e7409a50..98b42d0ae 100644 --- a/crates/ui-panels/src/docking/dock_column/stories.rs +++ b/crates/ui-panels/src/docking/dock_column/stories.rs @@ -1,12 +1,19 @@ //! Stories of `DockColumn`. -use crate::contract::ShowContainer as _; -use crate::docking::{ColumnBar, DockColumn, PanelSpec}; +use crate::contract::{ShowContainer as _, Tracked}; +use crate::docking::{ColumnBar, DockColumn, DockGrid, DockSizes, PanelSpec}; +use crate::rails::tool::stories::{BRUSH, tools}; +use crate::rails::{LastUsed, RailDensity, ToolRail, ToolSlot}; +use crate::runtime::env::Env; use crate::sections::Panel; use crate::testing::memory::global; use crate::testing::{Drive, StoryData, StoryOutput, story}; +use craft_behavior::Flow; use craft_behavior::dock::{Column, Group}; -use egui::Ui; +use egui::{Ui, UiBuilder}; + +/// The height of the rail card story's column. +const CARD_HEIGHT: f32 = 160.0; fn spec(panel: &u8) -> PanelSpec { PanelSpec::new(format!("Panel {panel}")) @@ -36,3 +43,29 @@ fn in_a_floating_window(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { }) .into() } + +/// A docked column of a tool rail shown as a card (`DockConfig::rail_cards`), at each rail density and one or two +/// steps: inset on its outer, top and bottom sides, where the dock's background shows, with its bar and its rail on +/// the rounded panel card. The column is wider than its steps by the inset. +#[story(DockColumn<'static, u8>, covers = [], drive = Drive::Never)] +fn a_tool_rail_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let density = *data.choice("density", RailDensity::Dense, &[("Regular", RailDensity::Regular), ("Dense", RailDensity::Dense)]); + let steps = *data.ranged("steps", 1_u16, 1.0..=2.0); + let slots = Tracked::new((0..4_u8).map(|slot| ToolSlot::new(u32::from(slot), tools(&[slot]))).collect::>()); + let last = Tracked::new(LastUsed::default()); + let cells = slots.len(); + let spec = move |_: &u8| PanelSpec::new("Tools").grid(DockGrid::rail(cells).density(density)); + let column = Column::new(vec![Group::new(vec![0], 0)]).with_steps(steps); + let sizes = DockSizes { rail_cards: true, ..DockSizes::of_scope(ui) }; + let width = sizes.natural(std::slice::from_ref(&column), &spec).first().map_or(0.0, |(width, _)| *width); + let room = Flow::new(ui.available_rect_before_wrap(), Env::of(ui).direction.is_rtl()).span(0.0, width); + let rect = room.with_max_y(room.top() + CARD_HEIGHT); + // The column takes the cell a dock gives it, as high as the dock, whatever its rail's height. + let shown = + DockColumn::new("Panels", global("dock column", "rail card story"), &column, &spec).card(true).show_groups_at(ui, rect, |_, rect, ui, _| { + let rail = ToolRail::new("Tools", &slots, &BRUSH, &last).density(density); + ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| rail.show_rail(ui, |_, _| {})); + }); + ui.advance_cursor_after_rect(rect); + shown.into() +} diff --git a/crates/ui-panels/src/docking/spec.rs b/crates/ui-panels/src/docking/spec.rs index 2fed17f8f..dbdea4370 100644 --- a/crates/ui-panels/src/docking/spec.rs +++ b/crates/ui-panels/src/docking/spec.rs @@ -107,6 +107,11 @@ impl DockGrid { } } + /// Whether the grid is a [`rail`](Self::rail) grid, before it is [`resolved`](Self::resolved). + pub(crate) fn is_rail(self) -> bool { + matches!(self.widths, GridWidths::Rail(_)) + } + /// The content's width at one column and the width each further column adds; zero for a rail grid not yet /// [`resolved`](Self::resolved). fn first_step(self) -> (f32, f32) { diff --git a/crates/ui-panels/src/docking/targets.rs b/crates/ui-panels/src/docking/targets.rs index 7aac54e64..bd29d87c0 100644 --- a/crates/ui-panels/src/docking/targets.rs +++ b/crates/ui-panels/src/docking/targets.rs @@ -4,7 +4,7 @@ //! previous pass's registry, because a drop is decided against what was on screen when the pointer moved. Every //! zone is a rect. A spot names a group by an anchor panel, as the dock model does. -use super::{DragUnit, PanelKey, PanelSpec, scale_widths, width_bounds}; +use super::{DockGrid, DragUnit, PanelKey, PanelSpec, scale_widths, width_bounds}; use crate::contract::DropMark; use crate::rails::RailDensity; use crate::runtime::frame::{self, PassStep, PerViewport, Stamped, Stored}; @@ -86,6 +86,12 @@ pub struct DockSizes { pub dense_rail_first: f32, /// [`rail_step`](Self::rail_step) with the buttons of a dense rail ([`RailDensity::Dense`]). pub dense_rail_step: f32, + /// The inset of a docked tool rail's column shown as a card ([`rail_cards`](Self::rail_cards)) on its outer, top + /// and bottom sides: `space.gap.stack`. + pub rail_card: f32, + /// Whether the dock shows its docked tool rails as cards ([`DockConfig::rail_cards`](super::DockConfig::rail_cards)): + /// off in the style, set by the dock that shows them. + pub rail_cards: bool, /// The height of a grip strip, the band with the dock's grip marks: above each icon group of a collapsed column, /// and under the column bar of a tool rail (a group whose panel has a [`DockGrid`](super::DockGrid)) that the host /// shows itself: the least hit size, or the theme's grip marks with `space.gap.tight` above and below them. @@ -141,6 +147,8 @@ impl DockSizes { rail_step, dense_rail_first, dense_rail_step, + rail_card: cx.tokens.space.gap.stack, + rail_cards: false, grip: super::group::grip_strip(cx.tokens), } } @@ -188,6 +196,23 @@ impl DockSizes { column.width.unwrap_or(self.column).clamp(lo, hi) } + /// The inset of `column`'s card: [`rail_card`](Self::rail_card) for an expanded stepped column of a tool rail + /// ([`DockGrid::rail`](super::DockGrid::rail)) in a dock that shows [`rail_cards`](Self::rail_cards), else none. + /// A docked column is that much wider than its steps. + pub fn card_inset

(&self, column: &Column

, spec: &dyn Fn(&P) -> PanelSpec) -> f32 { + let rail = || { + column.steps.is_some() + && column.panels().find_map(|panel| spec(panel).grid.filter(|grid| grid.resolved(self).valid())).is_some_and(DockGrid::is_rail) + }; + if self.rail_cards && !column.iconic && rail() { self.rail_card } else { 0.0 } + } + + /// The width of a docked column before the dock's room shrinks it: its [`width`](Self::width) and its card's + /// inset. + fn docked_width

(&self, column: &Column

, spec: &dyn Fn(&P) -> PanelSpec) -> f32 { + self.width(column, spec) + self.card_inset(column, spec) + } + /// The width bounds of a column collapsed to icons, docked or floating: the rail width up to the width it expands /// to. A docked column's inner edge and a floating window's sides resize it within them. pub fn iconic_bounds

(&self, column: &Column

, spec: &dyn Fn(&P) -> PanelSpec) -> (f32, f32) { @@ -201,7 +226,8 @@ impl DockSizes { if column.iconic { self.iconic_bounds(column, spec) } else if let Some((grid, _)) = self.stepped(column, spec) { - (grid.width(1), grid.width(grid.most)) + let inset = self.card_inset(column, spec); + (grid.width(1) + inset, grid.width(grid.most) + inset) } else { self.width_bounds(column, spec) } @@ -241,7 +267,7 @@ impl DockSizes { let current: Vec<(f32, (f32, f32))> = columns .iter() .map(|column| { - let width = self.width(column, spec); + let width = self.docked_width(column, spec); (width, if fixed(column) { (width, width) } else { self.shown_bounds(column, spec) }) }) .collect(); @@ -264,7 +290,7 @@ impl DockSizes { .iter() .map(|column| { let keeps = column.iconic || self.stepped(column, spec).is_some(); - (self.width(column, spec), (!keeps).then(|| self.width_bounds(column, spec).0.max(1.0))) + (self.docked_width(column, spec), (!keeps).then(|| self.width_bounds(column, spec).0.max(1.0))) }) .collect() } diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index 2ebfa1692..7b990f63e 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -254,7 +254,7 @@ impl Drops<'_, P> { /// Takes a group or tab drag released on the root. fn take(&self, cx: &mut Cx<'_, DockRoot<'_, DockDropped

>>) -> Option> { let ctx = cx.core.ctx.clone(); - let sizes = *cx.style.sizes(); + let sizes = area_sizes(*cx.style.sizes(), self.config); let shell = cx.env.get::().0; let bounds = inset_top(shell.as_ref().map_or(cx.rect, ShellCx::float_bounds), self.top_inset); let space = float_space(&ctx, bounds, &sizes, self.config, self.specs); @@ -271,6 +271,13 @@ impl Drops<'_, P> { } } +/// The sizes a dock area lays out with: the dock's style, with its docked tool rails as cards when `config` shows +/// them ([`DockConfig::rail_cards`]). +fn area_sizes(mut sizes: DockSizes, config: &DockConfig) -> DockSizes { + sizes.rail_cards = config.rail_cards; + sizes +} + /// What the area collects while it shows its parts. struct Report

{ actions: Vec>, @@ -526,7 +533,7 @@ impl<'a, P: Clone + Eq + Hash + Debug + Send + Sync + 'static> DockArea<'a, P> { let mut passed = None; open_requests::

(&ctx); let shown = root.show(ui, |ui, body| { - let Some(sizes) = body.style::>>().map(|style| *style.sizes()) else { return }; + let Some(sizes) = body.style::>>().map(|style| area_sizes(*style.sizes(), &config)) else { return }; let memory = body.memory::>(); memory.window_floor = memory.window_floor.max(current.layout().window_floor()); let input = Input { @@ -1390,7 +1397,8 @@ impl Pass<'_, P> { .bar(bar) .arrow(self.arrow_of(column)) .within(within) - .auto_collapse(scene.auto_collapse); + .auto_collapse(scene.auto_collapse) + .card(scene.sizes.rail_cards && !in_window); let output = shown.show_groups_at(ui, cell, |group, rect, ui, body| { self.group_of(ui, body, group, GroupAt::Show(rect), in_window); }); @@ -1421,9 +1429,10 @@ impl Pass<'_, P> { let spec = |panel: &P| scene.spec(panel); if let Some(width) = work.width { match scene.sizes.stepped(column, &spec) { - // The edge of a stepped column moves in whole steps: the most that fit where it is dragged. + // The edge of a stepped column moves in whole steps: the most that fit where it is dragged, inside its + // card. Some((grid, steps)) if !column.iconic => { - let to = grid.steps_within(width); + let to = grid.steps_within(width - scene.sizes.card_inset(column, &spec)); if to != steps { self.report.actions.push(Action::set_column_steps(first.clone(), to)); } diff --git a/crates/ui-patterns/tests/it/docking/columns.rs b/crates/ui-patterns/tests/it/docking/columns.rs index fdfc36ace..e274aefde 100644 --- a/crates/ui-patterns/tests/it/docking/columns.rs +++ b/crates/ui-patterns/tests/it/docking/columns.rs @@ -4,11 +4,14 @@ use craft_behavior::Axis; use craft_behavior::dock::{Action, Column, DockEdge, Floating, Group, Layout, Node, Permissions, SplitSize, Workspace, node_at}; use craft_ui::contract::{Bind, BodyCx, PlainData, Role, Show as _, SizeLimits, Tracked}; use craft_ui::display::Text; -use craft_ui::docking::{DockConfig, DockGrid, DockHeights, DockPanels, DockSizes, GroupSize, IconicMode, PanelSpec, PanelSpecs, group_heights}; +use craft_ui::docking::{ + DockConfig, DockGrid, DockHeights, DockPanels, DockSizes, GroupAt, GroupSize, IconicMode, PanelSpec, PanelSpecs, group_heights, +}; use craft_ui::patterns::dock::DockArea; +use craft_ui::runtime::env::Direction; use craft_ui::testing::{Fixture, pointer, trial}; use egui::{Pos2, Rect, Ui, Vec2}; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; use std::rc::Rc; use std::sync::Arc; @@ -470,3 +473,85 @@ fn a_menu_opens_from_the_rail_footer() { fixture.frame(vec![pointer::moved(at), pointer::press(at), pointer::release(at)]).settle(); assert!(fixture.by_label("Rail option").is_some(), "a same-frame click opens the menu"); } + +/// A toolbar of six rail cells beside a side panel. +#[derive(PlainData)] +struct RailTools; + +impl PanelSpecs for RailTools { + fn spec(&self, panel: &u32) -> PanelSpec { + if *panel == TOOLS { PanelSpec::new("Tools").grid(DockGrid::rail(6)) } else { PanelSpec::new("Side") } + } + + fn permissions(&self, panel: &u32) -> Permissions { + if *panel == TOOLS { Permissions::ALL.collapses(false).shares_column(false) } else { Permissions::ALL } + } +} + +/// Panels that record the rect the toolbar's group gets, the rail's stage. +struct RailStage(Rc>>); + +impl DockPanels for RailStage { + fn body(&mut self, _: &u32, _: &mut Ui, _: &mut BodyCx<'_>) {} + + fn group_view(&mut self, panels: &[u32], _: usize, _: &mut Ui, at: GroupAt, _: &mut BodyCx<'_>) -> Option { + if !panels.contains(&TOOLS) { + return None; + } + Some(match at { + GroupAt::Measure(_) => 0.0, + GroupAt::Show(rect) => { + self.0.set(Some(rect)); + rect.height() + } + }) + } +} + +/// A start dock in `direction` of a toolbar column of two rail steps, at the window edge, and a side column beside it, +/// with `DockConfig::rail_cards` set to `cards`: the toolbar's cell, the side column's cell and the rail's stage. +fn rail_dock(cards: bool, direction: Direction) -> (Rect, Rect, Rect) { + let columns = vec![Column::new(vec![Group::new(vec![TOOLS], 0)]).with_steps(2), Column::new(vec![Group::new(vec![2], 0)]).with_width(150.0)]; + let root = Node::split(Axis::X, SplitSize::FixedFirst(300.0), Node::dock(DockEdge::Start, columns), Node::tabs(vec![1], 0)); + let workspace = Rc::new(RefCell::new(Arc::new(Workspace::new(Layout::new(Some(root), Vec::new()))))); + let placed: Rc>> = Rc::default(); + let stage: Rc>> = Rc::default(); + let (held, seen, shown, specs) = (Rc::clone(&workspace), Rc::clone(&placed), Rc::clone(&stage), Tracked::new(RailTools)); + let mut fixture = Fixture::new(move |ui| { + let mut workspace = held.borrow().clone(); + let config = DockConfig::default().rail_cards(cards); + let out = DockArea::new("Rail dock", Bind::bound(&mut workspace), &specs, &mut RailStage(Rc::clone(&shown)), config).show(ui); + *held.borrow_mut() = workspace; + *seen.borrow_mut() = out.columns; + }); + fixture.direction(direction).room(Vec2::new(800.0, 500.0)).settle(); + let cell = |panel: u32| placed.borrow().iter().find(|(at, _)| *at == panel).map(|(_, rect)| *rect).expect("the column shows"); + (cell(TOOLS), cell(2), stage.get().expect("the rail's group shows")) +} + +/// A docked tool rail shown as a card is inset alike on its outer side, the window edge's, and on its top and bottom, +/// its bar and grip on the card above the rail as without one, and flush with its inner edge; the column beside it starts past its cell; and its +/// rail gets the same width as without the card, so it shows the same steps, its column wider by the inset. Right to +/// left mirrors the outer side. +#[trial] +fn a_rail_card_is_inset_alike_on_three_sides_and_keeps_its_steps() { + for direction in [Direction::Ltr, Direction::Rtl] { + let rtl = direction == Direction::Rtl; + let (plain_cell, _, plain) = rail_dock(false, direction); + let (cell, side, card) = rail_dock(true, direction); + let (outer, inner) = + if rtl { (cell.right() - card.right(), card.left() - cell.left()) } else { (card.left() - cell.left(), cell.right() - card.right()) }; + let top = (card.top() - cell.top()) - (plain.top() - plain_cell.top()); + let bottom = (cell.bottom() - card.bottom()) - (plain_cell.bottom() - plain.bottom()); + assert!(outer > 0.5, "{direction:?}: the card is inset from the window edge: {card:?} in {cell:?}"); + assert!((top - outer).abs() <= 0.5 && (bottom - outer).abs() <= 0.5, "{direction:?}: insets outer {outer}, top {top}, bottom {bottom}"); + assert!(inner.abs() <= 0.5, "{direction:?}: the card keeps to the inner edge: {card:?} in {cell:?}"); + let clear = if rtl { side.right() <= cell.left() + 0.5 } else { side.left() >= cell.right() - 0.5 }; + assert!(clear, "{direction:?}: the side column {side:?} overlaps the toolbar {cell:?}"); + assert!((card.width() - plain.width()).abs() <= 0.5, "{direction:?}: the rail's stage {card:?} differs from {plain:?} without the card"); + assert!( + (cell.width() - plain_cell.width() - outer).abs() <= 0.5, + "{direction:?}: the column {cell:?} grows by the inset from {plain_cell:?}" + ); + } +} From a4b6d3b6ca04a65d5972339b808d1049a14c7167 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 16:37:57 +0700 Subject: [PATCH 62/76] ui-contract: MOVE_BAND is re-exported in every build, not only the suite's, since BodyCx::moving reads it; an app building without the suite feature compiles again --- crates/ui-contract/src/contract/body.rs | 1 - crates/ui-contract/src/contract/mod.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/crates/ui-contract/src/contract/body.rs b/crates/ui-contract/src/contract/body.rs index a40c502f6..34dc4a864 100644 --- a/crates/ui-contract/src/contract/body.rs +++ b/crates/ui-contract/src/contract/body.rs @@ -33,7 +33,6 @@ pub use regions::pad_of; #[doc(hidden)] pub use reorder::REORDER_BAND; pub use scroll::{STRIP_BACK, STRIP_FORWARD}; -#[cfg(feature = "suite")] pub(crate) use window::MOVE_BAND; use window::WindowMode; pub use window::grip_band; diff --git a/crates/ui-contract/src/contract/mod.rs b/crates/ui-contract/src/contract/mod.rs index b86e2c642..eb92e07be 100644 --- a/crates/ui-contract/src/contract/mod.rs +++ b/crates/ui-contract/src/contract/mod.rs @@ -124,7 +124,6 @@ use std::hash::Hash; use std::ops::Deref; pub use crate::runtime::drag::{DragPreview, DropMark, DropTarget, DropZone, OsFile, OsFiles, WindowDropTarget}; -#[cfg(feature = "suite")] pub(crate) use body::MOVE_BAND; pub use craft_behavior::ColumnKey; pub use craft_behavior::DropOperation; From 2eb195b88907079ebf8a837e48bbb1c331a85d6f Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 17:45:08 +0700 Subject: [PATCH 63/76] ui-panels, dock area: DockConfig::column_cards (was rail_cards) shows every docked column as a card, expanded or collapsed to icons: surface.panel with shape.radius.surface corners on the dock's background, inset by space.gap.stack on top, bottom and at the window edge, and space.gap.tight between neighbouring cards; each column wider by its inset so its content keeps its width; group dividers stay inside the card; container surfaces keep to their layer's frame --- crates/ui-contract/src/primitives/surface.rs | 5 +- crates/ui-panels/src/docking/config.rs | 19 ++-- crates/ui-panels/src/docking/dock_column.rs | 103 ++++++++++-------- .../src/docking/dock_column/stories.rs | 44 ++++++-- crates/ui-panels/src/docking/iconic.rs | 29 ++++- .../ui-panels/src/docking/iconic/stories.rs | 32 +++++- crates/ui-panels/src/docking/spec.rs | 5 - crates/ui-panels/src/docking/targets.rs | 77 +++++++------ crates/ui-patterns/src/patterns/dock/area.rs | 54 +++++---- .../ui-patterns/tests/it/docking/columns.rs | 103 +++++++++++++++++- 10 files changed, 336 insertions(+), 135 deletions(-) diff --git a/crates/ui-contract/src/primitives/surface.rs b/crates/ui-contract/src/primitives/surface.rs index 1bf9a7a63..a220e4f83 100644 --- a/crates/ui-contract/src/primitives/surface.rs +++ b/crates/ui-contract/src/primitives/surface.rs @@ -136,9 +136,10 @@ impl SurfaceSlot { SurfaceSlot { painter, slot } } - /// Paints the surface `kind` over `rect`. + /// Paints the surface `kind` over `rect`, kept to its layer's frame ([`frame_surfaces`]). pub(crate) fn paint(&self, tokens: &UiTokens, kind: SurfaceKind, rect: Rect, direction: Direction) { - let shapes = Surface::shapes(&surface_style(tokens, kind), None, rect, Corners::All, direction, self.painter.pixels_per_point()); + let mut shapes = Surface::shapes(&surface_style(tokens, kind), None, rect, Corners::All, direction, self.painter.pixels_per_point()); + fit_to_frame(self.painter.ctx(), self.painter.layer_id(), &mut shapes); self.painter.set(self.slot, Shape::Vec(shapes)); } } diff --git a/crates/ui-panels/src/docking/config.rs b/crates/ui-panels/src/docking/config.rs index 4dccf3741..e2d19ff42 100644 --- a/crates/ui-panels/src/docking/config.rs +++ b/crates/ui-panels/src/docking/config.rs @@ -80,12 +80,13 @@ pub struct DockConfig { /// sides ([`FloatingGroup::rounded_body`](super::FloatingGroup)): a floating tool rail reads as one rounded piece. /// Off: the panels and rails inside paint their own square surfaces to the window's edge. pub floating_rounded_body: bool, - /// A docked column of a tool rail (a stepped column whose panel has a [`DockGrid::rail`](super::DockGrid::rail)) - /// shows as a card: inset by `space.gap.stack` on its outer, top and bottom sides, where the dock's background - /// shows, and painted `surface.panel` with `shape.radius.surface` corners and no frame. The column is wider by the - /// inset, so it keeps its steps; its dividers, drop bands and edge handle stay on its outer rect. Off: the column + /// Every docked column, expanded or collapsed to icons, shows as a card on the dock's `surface.background`: + /// painted `surface.panel` with `shape.radius.surface` corners and no frame, inset by `space.gap.stack` on its top + /// and bottom and, for the column at the window edge, on its outer side; each further column stands + /// `space.gap.tight` from its outer neighbour's card. A column is wider by its inset, so it keeps its content's + /// width (a tool rail its steps); its dividers, drop bands and edge handle stay on its outer rect. Off: a column /// fills its cell. - pub rail_cards: bool, + pub column_cards: bool, /// Shows a close button on the tabs of closable panels in docked and floating groups, where a middle click also /// closes them, for tabs that act as documents. Off: panels close from their menu. Accordion headers and iconic /// columns never show it. @@ -126,7 +127,7 @@ impl Default for DockConfig { close_button: true, floating_grip: false, floating_rounded_body: false, - rail_cards: false, + column_cards: false, tab_close_buttons: false, titled_headers: false, wheel_selects_tabs: false, @@ -245,10 +246,10 @@ impl DockConfig { self } - /// Docked tool rails as cards on or off ([`rail_cards`](Self::rail_cards)). + /// Docked columns as cards on or off ([`column_cards`](Self::column_cards)). #[must_use] - pub fn rail_cards(mut self, on: bool) -> Self { - self.rail_cards = on; + pub fn column_cards(mut self, on: bool) -> Self { + self.column_cards = on; self } diff --git a/crates/ui-panels/src/docking/dock_column.rs b/crates/ui-panels/src/docking/dock_column.rs index 70511455e..3d3b0ecba 100644 --- a/crates/ui-panels/src/docking/dock_column.rs +++ b/crates/ui-panels/src/docking/dock_column.rs @@ -156,8 +156,7 @@ pub struct DockColumnStyle { #[style(metrics)] metrics: Metrics, sizes: DockSizes, - /// The card of a column shown as one ([`card`](DockColumn::card)): `surface.panel` with `shape.radius.surface` - /// corners and no edge. + /// The card of a column shown as one ([`card`](DockColumn::card)). card: SurfaceStyle, } @@ -198,10 +197,11 @@ pub struct DockColumn<'a, P: Value + Hash + 'static> { /// The rect the dock may grow within, which bounds how wide its inner edge can make the column. #[prop] within: Rect, - /// Whether a column of a tool rail shows as a card ([`DockConfig::rail_cards`](super::DockConfig::rail_cards)): - /// its bar and groups inset by the card's inset ([`DockSizes::card_inset`]) on its outer, top and bottom sides. + /// The inset on the outer side of the column's card, when it shows as one + /// ([`DockConfig::column_cards`](super::DockConfig::column_cards), [`DockSizes::card_inset`]): its bar and groups + /// sit inside the card, inset by that on its outer side and by [`DockSizes::card`] on its top and bottom. #[prop] - card: bool, + card: Option, /// The plan `parts` laid out this pass, which update, paint and access read. laid: Option, resized: Vec<(P, f32)>, @@ -225,7 +225,7 @@ impl<'a, P: Value + Hash + Debug + 'static> DockColumn<'a, P> { bar: ColumnBar::Own, arrow: ColumnArrow::Collapse, within: Rect::NOTHING, - card: false, + card: None, laid: None, resized: Vec::new(), width: None, @@ -258,8 +258,8 @@ impl<'a, P: Value + Hash + Debug + 'static> DockColumn<'a, P> { let shown = &mut bar; let body = move |ui: &mut Ui, body: &mut BodyCx<'_>| { let Some(style) = body.style::>() else { return }; - let sizes = DockSizes { rail_cards: card, ..style.sizes }; - let inner = card_rect(column, spec, body.rect, edge, body.env.direction().is_rtl(), &sizes); + let sizes = style.sizes; + let inner = card_rect(body.rect, card, &sizes, edge, body.env.direction().is_rtl()); if inner != body.rect { // The groups' own surfaces keep to the card's rounded corners. crate::primitives::frame_surfaces(ui, inner, style.card.radius); @@ -287,9 +287,12 @@ impl<'a, P: Value + Hash + Debug + 'static> DockColumn<'a, P> { } /// The divider on the column's inner edge, which moves between the width bounds of its panels, or of its steps - /// for a stepped column ([`stepped`](super::stepped)), whose host takes the width as whole steps. + /// for a stepped column ([`stepped`](super::stepped)), whose host takes the width as whole steps; a card's inset + /// on top. fn edge_divider(&self, rect: Rect, sizes: &DockSizes) -> Divider { let (least, most) = sizes.shown_bounds(self.column, self.spec); + let inset = self.card.unwrap_or(0.0); + let (least, most) = (least + inset, most + inset); Divider::column_edge(rect, self.edge, (least, most.min((self.within.width() - sizes.least_pane).max(rect.width()))), sizes.reach) } @@ -301,14 +304,9 @@ impl<'a, P: Value + Hash + Debug + 'static> DockColumn<'a, P> { } } - /// The sizes of `style` with the column's card on or off. - fn sizes(&self, style: &DockColumnStyle) -> DockSizes { - DockSizes { rail_cards: self.card, ..style.sizes } - } - /// Where the column's bar and groups sit in `rect`: inside its card, if it shows as one. fn inner(&self, rect: Rect, rtl: bool, sizes: &DockSizes) -> Rect { - card_rect(self.column, self.spec, rect, self.edge, rtl, sizes) + card_rect(rect, self.card, sizes, self.edge, rtl) } fn anchor(&self, group: usize) -> Option<&P> { @@ -316,13 +314,30 @@ impl<'a, P: Value + Hash + Debug + 'static> DockColumn<'a, P> { } } -/// The card of `column` in `rect`, the column's rect in a dock on the window edge `edge`: `rect` inset by the card's -/// inset ([`DockSizes::card_inset`]) on its outer side, the one towards `edge`, and on its top and bottom; `rect` for a -/// column that is no card. -fn card_rect

(column: &Column

, spec: &dyn Fn(&P) -> PanelSpec, rect: Rect, edge: DockEdge, rtl: bool, sizes: &DockSizes) -> Rect { - let inset = sizes.card_inset(column, spec); - let card = rect.shrink2(egui::vec2(0.0, inset)); - if (edge == DockEdge::Start) != rtl { card.with_min_x(card.left() + inset) } else { card.with_max_x(card.right() - inset) } +/// The card of a docked column in `rect`, the column's rect in a dock on the window edge `edge`: `rect` inset by +/// `card`, the card's outer inset ([`DockSizes::card_inset`]), on its outer side, the one towards `edge`, and by +/// [`DockSizes::card`] on its top and bottom; `rect` for a column that is no card. +pub(crate) fn card_rect(rect: Rect, card: Option, sizes: &DockSizes, edge: DockEdge, rtl: bool) -> Rect { + let Some(outer) = card else { return rect }; + let inner = rect.shrink2(egui::vec2(0.0, sizes.card)); + if (edge == DockEdge::Start) != rtl { inner.with_min_x(inner.left() + outer) } else { inner.with_max_x(inner.right() - outer) } +} + +/// The look of a docked column's card ([`DockConfig::column_cards`](super::DockConfig::column_cards)): `surface.panel` +/// with `shape.radius.surface` corners and no edge. +pub(crate) fn card_style(cx: &StyleCx<'_>) -> SurfaceStyle { + SurfaceStyle { radius: UiTokens::corner(cx.tokens.shape.radius.surface), edge: SurfaceEdge::None, shadow: None, ..cx.surface(SurfaceKind::Panel) } +} + +/// Paints a column in `rect` whose content sits in `card`: the card over the dock's background where the column is +/// one, else the column's panel surface. +pub(crate) fn paint_card(ui: &mut PaintUi<'_>, rect: Rect, card: Rect, style: &SurfaceStyle) { + if card == rect { + ui.draw().surface(rect, SurfaceKind::Panel, Corners::All); + } else { + ui.draw().surface(rect, SurfaceKind::Background, Corners::None); + ui.draw().surface_styled(card, style); + } } /// Where the groups of `column` sit in `rect`, the column's rect with its bar `bar`, as the column lays them out while @@ -398,6 +413,12 @@ impl Plan { /// The divider after each open group but the last: its part index (the group above it), its position among the open /// groups and the divider. + /// The room the dividers between the groups take in the column's `rect`: the body, inside the column's card if it + /// shows as one, in the frame of `rect` mirrored for right-to-left that dividers are declared in. + fn divider_room(&self, rect: Rect, rtl: bool) -> Rect { + Flow::new(rect, rtl).to_physical(self.body) + } + fn dividers(&self, rect: Rect, reach: f32) -> Vec<(u64, usize, Divider)> { let row = self.row(); self.open @@ -424,13 +445,7 @@ impl Component for DockColumn<'_, P> { } fn style(cx: &StyleCx<'_>, _: DockColumnStyleKey

) -> DockColumnStyle { - let card = SurfaceStyle { - radius: UiTokens::corner(cx.tokens.shape.radius.surface), - edge: SurfaceEdge::None, - shadow: None, - ..cx.surface(SurfaceKind::Panel) - }; - DockColumnStyle { metrics: Metrics::new(), sizes: DockSizes::style(cx), card } + DockColumnStyle { metrics: Metrics::new(), sizes: DockSizes::style(cx), card: card_style(cx) } } fn sense(&self) -> Sense { @@ -440,14 +455,14 @@ impl Component for DockColumn<'_, P> { /// The chevron at the bar's outer end, a divider between every two open groups and the inner edge's divider; a /// column in a floating window has the group dividers only. fn parts(&mut self, rect: Rect, cx: &mut PartsCx<'_, Self>) { - let sizes = self.sizes(cx.style); + let sizes = cx.style.sizes; let plan = column_plan(self.column, self.spec, self.inner(rect, cx.flow.is_rtl(), &sizes), self.bar, &sizes, |_, _| None); if self.bar == ColumnBar::Own && self.arrow.shown() { let (chevron, _) = bar_slots(plan.bar, self.edge, cx.flow.is_rtl()); let name = self.arrow.name(&cx.words::(), true); let _ = cx.part(CHEVRON, chevron).sense(Sense::CLICK | Sense::FOCUS).focusable().tooltip(name); } - let dividers = plan.dividers(rect, sizes.reach); + let dividers = plan.dividers(plan.divider_room(rect, cx.flow.is_rtl()), sizes.reach); for (key, _, divider) in dividers { divider::declare(cx, rect, DIVIDER, key, ÷r); } @@ -458,14 +473,14 @@ impl Component for DockColumn<'_, P> { } fn update(&mut self, cx: &mut Cx<'_, Self>) { - let sizes = self.sizes(cx.style); + let sizes = cx.style.sizes; let (rect, rtl, ctx) = (cx.rect, cx.flow.is_rtl(), cx.core.ctx.clone()); let own = self.bar == ColumnBar::Own; self.collapse = own && self.arrow.shown() && cx.part_activated(CHEVRON).is_some(); let Some(base) = self.laid.take() else { return }; let inner = self.inner(rect, rtl, &sizes); let mut plan = column_plan(self.column, self.spec, inner, self.bar, &sizes, |key, divider| divider::pointer(cx, DIVIDER, key, divider)); - let dividers = base.dividers(rect, sizes.reach); + let dividers = base.dividers(base.divider_room(rect, rtl), sizes.reach); let keyed: Vec<(u64, Divider)> = dividers.iter().map(|(key, _, divider)| (*key, *divider)).collect(); if let Some((key, coord)) = divider::keys(cx, DIVIDER, &keyed, sizes.step, sizes.jump) && let Some((_, index, divider)) = dividers.iter().find(|(at, ..)| *at == key) @@ -496,17 +511,11 @@ impl Component for DockColumn<'_, P> { fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { let Some(plan) = self.laid.as_ref() else { return }; // Painted here, not as the container's surface, which lies over what `paint` draws. - let card = self.inner(cx.rect, cx.flow.is_rtl(), &self.sizes(cx.style)); - let carded = card != cx.rect; - if carded { - // The card on the dock's background; the bar is part of the card. - ui.draw().surface(cx.rect, SurfaceKind::Background, Corners::None); - ui.draw().surface_styled(card, &cx.style.card); - } else { - ui.draw().surface(cx.rect, SurfaceKind::Panel, Corners::All); - } + let card = self.inner(cx.rect, cx.flow.is_rtl(), &cx.style.sizes); + paint_card(ui, cx.rect, card, &cx.style.card); if self.bar == ColumnBar::Own { - if !carded { + // A card's bar is part of the card. + if card == cx.rect { ui.draw().surface(plan.bar, SurfaceKind::Background, Corners::None); } if self.arrow.shown() { @@ -525,23 +534,23 @@ impl Component for DockColumn<'_, P> { return; } // A card has no frame. - if self.inner(cx.rect, cx.flow.is_rtl(), &self.sizes(cx.style)) == cx.rect { + if self.card.is_none() { ui.draw().surface(cx.rect, SurfaceKind::Frame, Corners::None); } for pair in plan.open.windows(2) { ui.face(DIVIDER.at(pair[0] as u64), Splitter::new(Axis::Y)); } // The edge's line lies on the column's inner edge, over the frame; its handle stays inside the column. - let (rect, edge) = (cx.rect, self.edge_divider(cx.rect, &self.sizes(cx.style))); + let (rect, edge) = (cx.rect, self.edge_divider(cx.rect, &cx.style.sizes)); let x = if cx.flow.is_rtl() { rect.right() - (edge.at - rect.left()) } else { edge.at }; ui.face(EDGE.at(0), Splitter::new(Axis::X).boundary(x)); } fn access(&self, access: &mut Access, cx: &Cx<'_, Self>) { let words = cx.words::(); - let sizes = self.sizes(cx.style); + let sizes = cx.style.sizes; let Some(plan) = self.laid.as_ref() else { return }; - for (key, _, divider) in plan.dividers(cx.rect, sizes.reach) { + for (key, _, divider) in plan.dividers(plan.divider_room(cx.rect, cx.flow.is_rtl()), sizes.reach) { divider::describe(access, DIVIDER, key, ÷r, words.resize.as_str(), sizes.step); } if self.bar == ColumnBar::Own { diff --git a/crates/ui-panels/src/docking/dock_column/stories.rs b/crates/ui-panels/src/docking/dock_column/stories.rs index 98b42d0ae..ef8d5f3b0 100644 --- a/crates/ui-panels/src/docking/dock_column/stories.rs +++ b/crates/ui-panels/src/docking/dock_column/stories.rs @@ -12,9 +12,12 @@ use craft_behavior::Flow; use craft_behavior::dock::{Column, Group}; use egui::{Ui, UiBuilder}; -/// The height of the rail card story's column. +/// The height of the card stories' columns. const CARD_HEIGHT: f32 = 160.0; +/// The width of the panel card story's column, before its card's inset. +const CARD_WIDTH: f32 = 240.0; + fn spec(panel: &u8) -> PanelSpec { PanelSpec::new(format!("Panel {panel}")) } @@ -44,9 +47,9 @@ fn in_a_floating_window(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { .into() } -/// A docked column of a tool rail shown as a card (`DockConfig::rail_cards`), at each rail density and one or two -/// steps: inset on its outer, top and bottom sides, where the dock's background shows, with its bar and its rail on -/// the rounded panel card. The column is wider than its steps by the inset. +/// A docked column of a tool rail at the window edge shown as a card (`DockConfig::column_cards`), at each rail density +/// and one or two steps: inset on its outer, top and bottom sides, where the dock's background shows, with its bar and +/// its rail on the rounded panel card. The column is wider than its steps by the inset. #[story(DockColumn<'static, u8>, covers = [], drive = Drive::Never)] fn a_tool_rail_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let density = *data.choice("density", RailDensity::Dense, &[("Regular", RailDensity::Regular), ("Dense", RailDensity::Dense)]); @@ -56,16 +59,41 @@ fn a_tool_rail_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let cells = slots.len(); let spec = move |_: &u8| PanelSpec::new("Tools").grid(DockGrid::rail(cells).density(density)); let column = Column::new(vec![Group::new(vec![0], 0)]).with_steps(steps); - let sizes = DockSizes { rail_cards: true, ..DockSizes::of_scope(ui) }; + let sizes = DockSizes { column_cards: true, ..DockSizes::of_scope(ui) }; let width = sizes.natural(std::slice::from_ref(&column), &spec).first().map_or(0.0, |(width, _)| *width); let room = Flow::new(ui.available_rect_before_wrap(), Env::of(ui).direction.is_rtl()).span(0.0, width); let rect = room.with_max_y(room.top() + CARD_HEIGHT); // The column takes the cell a dock gives it, as high as the dock, whatever its rail's height. - let shown = - DockColumn::new("Panels", global("dock column", "rail card story"), &column, &spec).card(true).show_groups_at(ui, rect, |_, rect, ui, _| { + let shown = DockColumn::new("Panels", global("dock column", "rail card story"), &column, &spec).card(sizes.card_inset(0)).show_groups_at( + ui, + rect, + |_, rect, ui, _| { let rail = ToolRail::new("Tools", &slots, &BRUSH, &last).density(density); ui.scope_builder(UiBuilder::new().max_rect(rect), |ui| rail.show_rail(ui, |_, _| {})); - }); + }, + ); + ui.advance_cursor_after_rect(rect); + shown.into() +} + +/// A docked panel column of two groups shown as a card (`DockConfig::column_cards`), at the window edge or inward of +/// another column: inset on its top and bottom, and on its outer side by the window edge's inset or by the gutter +/// between two cards, its bar and groups on the rounded panel card with no frame. +#[story(DockColumn<'static, u8>, covers = [], drive = Drive::Never)] +fn a_panel_column_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let at = *data.choice("place", 0_usize, &[("At the window edge", 0), ("Inward of another column", 1)]); + let column = Column::new(vec![Group::new(vec![0, 1], 0), Group::new(vec![2], 0)]); + let inset = DockSizes { column_cards: true, ..DockSizes::of_scope(ui) }.card_inset(at); + let room = Flow::new(ui.available_rect_before_wrap(), Env::of(ui).direction.is_rtl()).span(0.0, CARD_WIDTH + inset); + let rect = room.with_max_y(room.top() + 2.0 * CARD_HEIGHT); + let shown = DockColumn::new("Panels", global("dock column", "panel card story"), &column, &spec).card(inset).show_groups_at( + ui, + rect, + |group, rect, ui, _| { + let title = group.active_panel().map_or_else(String::new, |panel| spec(panel).label.as_str().to_owned()); + Panel::new(title).show_at(ui, rect, |_, _| ()); + }, + ); ui.advance_cursor_after_rect(rect); shown.into() } diff --git a/crates/ui-panels/src/docking/iconic.rs b/crates/ui-panels/src/docking/iconic.rs index 7f5edb52d..42e0c7f4d 100644 --- a/crates/ui-panels/src/docking/iconic.rs +++ b/crates/ui-panels/src/docking/iconic.rs @@ -2,7 +2,8 @@ use super::divider::{self, Divider, Drag}; use super::dock_column::{ - BarRecord, CHEVRON, ColumnArrow, ColumnBar, bar_band, bar_slots, column_grip, describe_chevron, paint_chevron, register_edges, show_bar, + BarRecord, CHEVRON, ColumnArrow, ColumnBar, bar_band, bar_slots, card_rect, card_style, column_grip, describe_chevron, paint_card, paint_chevron, + register_edges, show_bar, }; use super::group::GripMarks; use super::{DockSizes, DockSpot, DockTargets, DockWords, DragUnit, Flyout, GroupAt, PanelKey, PanelSpec, Splitter, start_icon_drag}; @@ -17,7 +18,7 @@ use crate::menu::GroupItem; use crate::primitives::{IconSpec, TextRun}; use crate::runtime::env::Label; use crate::runtime::focus::KeyUse; -use crate::style::{ComponentStyle, Corners, GlyphRole, StyleColor, StyleCx, SurfaceKind}; +use crate::style::{ComponentStyle, Corners, GlyphRole, StyleColor, StyleCx, SurfaceKind, SurfaceStyle}; use craft_behavior::dock::{Column, DockEdge, Group}; use craft_behavior::overlay::Side; use craft_behavior::{Axis, CursorIcon, DockSide, Metrics, PartKey, PressPhase, Sense, Value}; @@ -163,6 +164,8 @@ pub struct IconicColumnStyle { name_gap: f32, /// The marks of a group's grip. grip: GripMarks, + /// The card of a column shown as one ([`card`](IconicColumn::card)). + card: SurfaceStyle, } /// A column collapsed to icons: the column bar over icon groups, one cell per panel. A panel without an icon shows the @@ -222,6 +225,11 @@ pub struct IconicColumn<'a, P: Value + Hash + 'static> { /// palette window, the work area. #[prop] within: Rect, + /// The inset on the outer side of the docked column's card, when it shows as one + /// ([`DockConfig::column_cards`](super::DockConfig::column_cards), [`DockSizes::card_inset`]): its bar and icons + /// sit inside the card, inset by that on its outer side and by [`DockSizes::card`] on its top and bottom. + #[prop] + card: Option, open: Bind<'a, Option

>, view: Option>, /// The bar's rect this pass. @@ -283,6 +291,7 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> { auto_collapse: false, mode: IconicMode::Flyouts, within: Rect::NOTHING, + card: None, open, view: None, bar_rect: Rect::NOTHING, @@ -352,9 +361,12 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> { } } - /// The divider on the column's inner edge: the width runs from the rail to the width the column expands to. + /// The divider on the column's inner edge: the width runs from the rail to the width the column expands to, and + /// a card's inset on top. fn edge_divider(&self, rect: Rect, sizes: &DockSizes) -> Divider { let (least, most) = sizes.iconic_bounds(self.column, self.spec); + let inset = self.card.unwrap_or(0.0); + let (least, most) = (least + inset, most + inset); let most = most.min((self.within.width() - sizes.least_pane).max(rect.width())); Divider::column_edge(rect, self.edge, (least, most), sizes.reach) } @@ -375,7 +387,9 @@ impl<'a, P: Value + Hash + Debug + 'static> IconicColumn<'a, P> { self.column.groups.get(group).and_then(|group| group.panels.get(panel)) } + /// Where the parts sit in the column's `rect`: inside its card, if it shows as one. fn plan(&self, rect: Rect, sizes: &IconicSizes, rtl: bool) -> Plan { + let rect = card_rect(rect, self.card, &sizes.column, self.edge, rtl); let bar = Rect::from_min_max(rect.min, Pos2::new(rect.right(), (rect.top() + self.bar.height(&sizes.column)).min(rect.bottom()))); let body = Rect::from_min_max(Pos2::new(rect.left(), bar.bottom()), rect.max); let wide = body.width() >= sizes.labels; @@ -473,6 +487,7 @@ impl Component for IconicColumn<'_, P> { name_gap: cx.tokens.space.gap.item, // The references' grip: a row of upright ticks, in the theme's grip ink. grip: GripMarks::style(cx), + card: card_style(cx), } } @@ -613,9 +628,13 @@ impl Component for IconicColumn<'_, P> { fn paint(&mut self, ui: &mut PaintUi<'_>, cx: &Cx<'_, Self>) { // Painted here, not as the container's surface, which lies over what `paint` draws. - ui.draw().surface(cx.rect, SurfaceKind::Panel, Corners::All); + let card = card_rect(cx.rect, self.card, &cx.style.sizes.column, self.edge, cx.flow.is_rtl()); + paint_card(ui, cx.rect, card, &cx.style.card); if self.bar == ColumnBar::Own { - ui.draw().surface(self.bar_rect, SurfaceKind::Background, Corners::None); + // A card's bar is part of the card. + if self.card.is_none() { + ui.draw().surface(self.bar_rect, SurfaceKind::Background, Corners::None); + } paint_chevron(ui, self.edge, ColumnArrow::Collapse, self.expanded(), cx.flow.is_rtl(), &cx.words::()); } let flat = self.flat(); diff --git a/crates/ui-panels/src/docking/iconic/stories.rs b/crates/ui-panels/src/docking/iconic/stories.rs index 7d79e2699..27b3d9ee6 100644 --- a/crates/ui-panels/src/docking/iconic/stories.rs +++ b/crates/ui-panels/src/docking/iconic/stories.rs @@ -4,7 +4,7 @@ use super::CELL; use crate::buttons::Button; use crate::contract::ShowContainer as _; use crate::contract::{Bind, BodyCx, Show as _, Validity}; -use crate::docking::{ColumnBar, GroupAt, IconicColumn, IconicColumnOutput, IconicMode, PanelSpec}; +use crate::docking::{ColumnBar, DockSizes, GroupAt, IconicColumn, IconicColumnOutput, IconicMode, PanelSpec}; use crate::runtime::commands::{CommandState, CommandStates}; use crate::runtime::env::{Env, Message}; use crate::sections::Panel; @@ -56,10 +56,20 @@ fn at_stage<'a>( ui: &mut Ui, column: IconicColumn<'a, u8>, view: impl FnMut(&Group, GroupAt, &mut Ui, &mut BodyCx<'_>) -> Option + 'a, +) -> IconicColumnOutput { + at_stage_wider(ui, column, 0.0, view) +} + +/// [`at_stage`] with the column `extra` wider than the rail: a card's inset. +fn at_stage_wider<'a>( + ui: &mut Ui, + column: IconicColumn<'a, u8>, + extra: f32, + view: impl FnMut(&Group, GroupAt, &mut Ui, &mut BodyCx<'_>) -> Option + 'a, ) -> IconicColumnOutput { let room = stage(ui); let env = Env::of(ui); - let width = env.tokens.tokens().size.rail.width; // design: allow[style/token-read](a story sizes its stage from the rail token) + let width = env.tokens.tokens().size.rail.width + extra; // design: allow[style/token-read](a story sizes its stage from the rail token) let cell = if env.direction.is_rtl() { Rect::from_min_max(room.min, egui::pos2(room.left() + width, room.bottom())) } else { @@ -81,6 +91,24 @@ fn icon_groups(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { .into() } +/// A docked column of icons shown as a card (`DockConfig::column_cards`), at the window edge or inward of another +/// column: inset on its top and bottom, and on its outer side by the window edge's inset or by the gutter between two +/// cards, its bar and icons on the rounded panel card over the dock's background. +#[story(IconicColumn<'static, u8>, covers = [], drive = Drive::Never)] +fn icons_as_a_card(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let at = *data.choice("place", 1_usize, &[("At the window edge", 0), ("Inward of another column", 1)]); + let inset = DockSizes { column_cards: true, ..DockSizes::of_scope(ui) }.card_inset(at); + let column = Column::new(vec![Group::new(vec![0, 1], 0), Group::new(vec![2], 0)]); + let column = IconicColumn::new("Panels", global("iconic column", "card story"), &column, Bind::kept(), &spec).card(inset); + at_stage_wider(ui, column, inset, |group, at, ui, _| { + let GroupAt::Show(rect) = at else { return None }; + let title = group.active_panel().map_or_else(String::new, |panel| spec(panel).label.as_str().to_owned()); + Panel::new(title).titled().show_at(ui, rect, |_, _| ()); + None + }) + .into() +} + /// Cells bound to their panels' toggle commands: a marked command whose panel is closed shows the marker. #[story(IconicColumn<'static, u8>, covers = [Default], drive = Drive::Never, commands = marked_states)] fn icon_groups_with_marked_panels(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { diff --git a/crates/ui-panels/src/docking/spec.rs b/crates/ui-panels/src/docking/spec.rs index dbdea4370..2fed17f8f 100644 --- a/crates/ui-panels/src/docking/spec.rs +++ b/crates/ui-panels/src/docking/spec.rs @@ -107,11 +107,6 @@ impl DockGrid { } } - /// Whether the grid is a [`rail`](Self::rail) grid, before it is [`resolved`](Self::resolved). - pub(crate) fn is_rail(self) -> bool { - matches!(self.widths, GridWidths::Rail(_)) - } - /// The content's width at one column and the width each further column adds; zero for a rail grid not yet /// [`resolved`](Self::resolved). fn first_step(self) -> (f32, f32) { diff --git a/crates/ui-panels/src/docking/targets.rs b/crates/ui-panels/src/docking/targets.rs index bd29d87c0..467df4b57 100644 --- a/crates/ui-panels/src/docking/targets.rs +++ b/crates/ui-panels/src/docking/targets.rs @@ -4,7 +4,7 @@ //! previous pass's registry, because a drop is decided against what was on screen when the pointer moved. Every //! zone is a rect. A spot names a group by an anchor panel, as the dock model does. -use super::{DockGrid, DragUnit, PanelKey, PanelSpec, scale_widths, width_bounds}; +use super::{DragUnit, PanelKey, PanelSpec, scale_widths, width_bounds}; use crate::contract::DropMark; use crate::rails::RailDensity; use crate::runtime::frame::{self, PassStep, PerViewport, Stamped, Stored}; @@ -86,12 +86,16 @@ pub struct DockSizes { pub dense_rail_first: f32, /// [`rail_step`](Self::rail_step) with the buttons of a dense rail ([`RailDensity::Dense`]). pub dense_rail_step: f32, - /// The inset of a docked tool rail's column shown as a card ([`rail_cards`](Self::rail_cards)) on its outer, top - /// and bottom sides: `space.gap.stack`. - pub rail_card: f32, - /// Whether the dock shows its docked tool rails as cards ([`DockConfig::rail_cards`](super::DockConfig::rail_cards)): - /// off in the style, set by the dock that shows them. - pub rail_cards: bool, + /// The inset of a docked column shown as a card ([`column_cards`](Self::column_cards)) on its top and bottom, and + /// on its outer side at the dock's window edge: `space.gap.stack`. + pub card: f32, + /// The gutter between two neighbouring cards of a dock, on the outer side of each card past the window edge's: + /// `space.gap.tight`. + pub card_gutter: f32, + /// Whether the dock shows its docked columns as cards + /// ([`DockConfig::column_cards`](super::DockConfig::column_cards)): off in the style, set by the dock that shows + /// them. + pub column_cards: bool, /// The height of a grip strip, the band with the dock's grip marks: above each icon group of a collapsed column, /// and under the column bar of a tool rail (a group whose panel has a [`DockGrid`](super::DockGrid)) that the host /// shows itself: the least hit size, or the theme's grip marks with `space.gap.tight` above and below them. @@ -147,8 +151,9 @@ impl DockSizes { rail_step, dense_rail_first, dense_rail_step, - rail_card: cx.tokens.space.gap.stack, - rail_cards: false, + card: cx.tokens.space.gap.stack, + card_gutter: cx.tokens.space.gap.tight, + column_cards: false, grip: super::group::grip_strip(cx.tokens), } } @@ -196,21 +201,16 @@ impl DockSizes { column.width.unwrap_or(self.column).clamp(lo, hi) } - /// The inset of `column`'s card: [`rail_card`](Self::rail_card) for an expanded stepped column of a tool rail - /// ([`DockGrid::rail`](super::DockGrid::rail)) in a dock that shows [`rail_cards`](Self::rail_cards), else none. - /// A docked column is that much wider than its steps. - pub fn card_inset

(&self, column: &Column

, spec: &dyn Fn(&P) -> PanelSpec) -> f32 { - let rail = || { - column.steps.is_some() - && column.panels().find_map(|panel| spec(panel).grid.filter(|grid| grid.resolved(self).valid())).is_some_and(DockGrid::is_rail) - }; - if self.rail_cards && !column.iconic && rail() { self.rail_card } else { 0.0 } - } - - /// The width of a docked column before the dock's room shrinks it: its [`width`](Self::width) and its card's - /// inset. - fn docked_width

(&self, column: &Column

, spec: &dyn Fn(&P) -> PanelSpec) -> f32 { - self.width(column, spec) + self.card_inset(column, spec) + /// The inset on the outer side of the card of a dock's docked column `at` from the window edge inwards: none + /// without [`column_cards`](Self::column_cards); [`card`](Self::card) for the first column, at the window edge; + /// [`card_gutter`](Self::card_gutter) for the others, which stand that far from their outer neighbour's card. A + /// docked column is that much wider than its content. + pub fn card_inset(&self, at: usize) -> f32 { + match (self.column_cards, at) { + (false, _) => 0.0, + (true, 0) => self.card, + (true, _) => self.card_gutter, + } } /// The width bounds of a column collapsed to icons, docked or floating: the rail width up to the width it expands @@ -226,8 +226,7 @@ impl DockSizes { if column.iconic { self.iconic_bounds(column, spec) } else if let Some((grid, _)) = self.stepped(column, spec) { - let inset = self.card_inset(column, spec); - (grid.width(1) + inset, grid.width(grid.most) + inset) + (grid.width(1), grid.width(grid.most)) } else { self.width_bounds(column, spec) } @@ -264,33 +263,41 @@ impl DockSizes { _ => return Vec::new(), }; let fixed = |column: &Column

| !column.iconic && self.stepped(column, spec).is_some(); + // Each column with its card's inset, which the scaling leaves as it is. let current: Vec<(f32, (f32, f32))> = columns .iter() - .map(|column| { - let width = self.docked_width(column, spec); - (width, if fixed(column) { (width, width) } else { self.shown_bounds(column, spec) }) + .enumerate() + .map(|(at, column)| { + let (width, inset) = (self.width(column, spec), self.card_inset(at)); + let (lo, hi) = if fixed(column) { (width, width) } else { self.shown_bounds(column, spec) }; + (width + inset, (lo + inset, hi + inset)) }) .collect(); let widths = scale_widths(¤t, total); columns .iter() + .enumerate() .zip(current.iter().zip(widths)) - .filter(|(column, ((width, _), scaled))| !fixed(column) && (scaled - width).abs() >= 0.01) - .filter_map(|(column, (_, width))| { + .filter(|((_, column), ((width, _), scaled))| !fixed(column) && (scaled - width).abs() >= 0.01) + .filter_map(|((at, column), (_, width))| { + let width = width - self.card_inset(at); let panel = column.groups.iter().find_map(|group| group.panels.first())?.clone(); Some(if column.iconic { Action::resize_iconic(panel, Some(width)) } else { Action::resize_column(panel, width) }) }) .collect() } - /// The `(width, floor)` of every column, for [`fit_widths`](super::fit_widths): an expanded column shrinks down to - /// its least width, an iconic or stepped one keeps its width. + /// The `(width, floor)` of every column of a dock, from its window edge inwards, for + /// [`fit_widths`](super::fit_widths), each with its card's inset ([`card_inset`](Self::card_inset)): an expanded + /// column shrinks down to its least width, an iconic or stepped one keeps its width. pub fn natural

(&self, columns: &[Column

], spec: &dyn Fn(&P) -> PanelSpec) -> Vec<(f32, Option)> { columns .iter() - .map(|column| { + .enumerate() + .map(|(at, column)| { let keeps = column.iconic || self.stepped(column, spec).is_some(); - (self.docked_width(column, spec), (!keeps).then(|| self.width_bounds(column, spec).0.max(1.0))) + let inset = self.card_inset(at); + (self.width(column, spec) + inset, (!keeps).then(|| self.width_bounds(column, spec).0.max(1.0) + inset)) }) .collect() } diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index 78ac389cf..f4e5c57fe 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -271,10 +271,10 @@ impl Drops<'_, P> { } } -/// The sizes a dock area lays out with: the dock's style, with its docked tool rails as cards when `config` shows -/// them ([`DockConfig::rail_cards`]). +/// The sizes a dock area lays out with: the dock's style, with its docked columns as cards when `config` shows them +/// ([`DockConfig::column_cards`]). fn area_sizes(mut sizes: DockSizes, config: &DockConfig) -> DockSizes { - sizes.rail_cards = config.rail_cards; + sizes.column_cards = config.column_cards; sizes } @@ -451,6 +451,8 @@ struct ColumnAt

{ bar: ColumnBar, within: Rect, open: Option

, + /// The outer inset of the column's card, a docked column's in a dock that shows cards ([`DockSizes::card_inset`]). + card: Option, } /// What a column reported. @@ -1226,7 +1228,7 @@ impl Pass<'_, P> { let reading = plan.flow.to_physical(plan.rect); let start = plan.edge == DockEdge::Start; let mut cursor = if start { reading.left() } else { reading.right() }; - for (column, width) in plan.columns.iter().zip(widths) { + for (at, (column, width)) in plan.columns.iter().zip(widths).enumerate() { let span = if start { (cursor, cursor + width) } else { (cursor - width, cursor) }; cursor = if start { span.1 } else { span.0 }; let cell = plan.flow.to_physical(Rect::from_x_y_ranges(span.0..=span.1, reading.y_range())); @@ -1236,7 +1238,8 @@ impl Pass<'_, P> { // (photocraft#16461). Content taller than the dock scrolls inside. Only a floating stepped window is as // tall as its content. self.report.placed.push((first.clone(), cell)); - let at = ColumnAt { cell, edge: plan.edge, bar: ColumnBar::Own, within: body.rect, open: plan.open.clone() }; + let card = scene.sizes.column_cards.then(|| scene.sizes.card_inset(at)); + let at = ColumnAt { cell, edge: plan.edge, bar: ColumnBar::Own, within: body.rect, open: plan.open.clone(), card }; self.column(ui, body, column, at); } } @@ -1329,7 +1332,7 @@ impl Pass<'_, P> { let spec = |panel: &P| scene.spec(panel); let name = Label::from(body.words::().panels.as_str().to_owned()); let dock = self.dock; - let ColumnAt { mut cell, edge, bar, within, open } = at; + let ColumnAt { mut cell, edge, bar, within, open, card } = at; let in_window = bar == ColumnBar::Window; if in_window { DockTargets::

::register_room(ui.ctx(), dock, cell); @@ -1337,18 +1340,24 @@ impl Pass<'_, P> { let opens = if edge == DockEdge::Start { Side::End } else { Side::Start }; // Only a docked column's icons are a rail; a floating window's open flyouts. let mode = if in_window { IconicMode::Flyouts } else { scene.config.iconic_mode }; - let mut icons = |cell: Rect, open: Option

| { + // The width the user gives a column by its inner edge leaves out its card's inset. + let inset = card.unwrap_or(0.0); + let mut icons = |cell: Rect, open: Option

, card: Option| { let footer = scene.rail_footer.filter(|panel| mode == IconicMode::Rail && column.panels().any(|item| item == *panel)); let pass = RefCell::new(&mut *self); let draw = |ui: &mut Ui, rect: Rect, open: Option

| { - IconicColumn::new(name.clone(), dock, column, Bind::given(open), &spec) + let shown = IconicColumn::new(name.clone(), dock, column, Bind::given(open), &spec) .edge(edge) .opens(opens) .bar(bar) .within(within) .auto_collapse(scene.auto_collapse) - .mode(mode) - .show_flyouts_at(ui, rect, |group, at, ui, body| pass.borrow_mut().group_of(ui, body, group, at, in_window)) + .mode(mode); + let shown = match card { + Some(inset) => shown.card(inset), + None => shown, + }; + shown.show_flyouts_at(ui, rect, |group, at, ui, body| pass.borrow_mut().group_of(ui, body, group, at, in_window)) }; if let Some(panel) = footer { let height = IconicSizes::of(ui.ctx()).icons_height(column) + scene.sizes.bar; @@ -1370,10 +1379,11 @@ impl Pass<'_, P> { } }; let work = if column.iconic { - let Some(output) = icons(cell, open) else { return }; + let Some(output) = icons(cell, open, card) else { return }; self.report.flyout.extend(output.edit.events); self.rail_work(output.front); - ColumnWork { iconic: output.iconic, picked: output.picked, resized: Vec::new(), width: output.width, flyout: output.flyout } + let width = output.width.map(|width| width - inset); + ColumnWork { iconic: output.iconic, picked: output.picked, resized: Vec::new(), width, flyout: output.flyout } } else { if !in_window && scene.rail_beside(column) { // The rail keeps to the dock's window edge and the expanded column shows inward of it. @@ -1385,7 +1395,8 @@ impl Pass<'_, P> { (cell.with_min_x(cell.right() - rail), cell.with_max_x(cell.right() - rail)) }; cell = rest; - let Some(output) = icons(rail_cell, None) else { return }; + // The rail stands square at the window edge; the expanded column's card is inward of it. + let Some(output) = icons(rail_cell, None, None) else { return }; self.rail_work(output.front); // The rail's inner edge sets its own width, not the expanded column's. self.column_work(column, ColumnWork { iconic: output.iconic, picked: output.picked, resized: Vec::new(), width: None, flyout: None }); @@ -1398,12 +1409,16 @@ impl Pass<'_, P> { .bar(bar) .arrow(self.arrow_of(column)) .within(within) - .auto_collapse(scene.auto_collapse) - .card(scene.sizes.rail_cards && !in_window); + .auto_collapse(scene.auto_collapse); + let shown = match card { + Some(inset) => shown.card(inset), + None => shown, + }; let output = shown.show_groups_at(ui, cell, |group, rect, ui, body| { self.group_of(ui, body, group, GroupAt::Show(rect), in_window); }); - ColumnWork { iconic: output.iconic, picked: output.picked, resized: output.resized, width: output.width, flyout: None } + let width = output.width.map(|width| width - inset); + ColumnWork { iconic: output.iconic, picked: output.picked, resized: output.resized, width, flyout: None } }; self.column_work(column, work); } @@ -1430,10 +1445,9 @@ impl Pass<'_, P> { let spec = |panel: &P| scene.spec(panel); if let Some(width) = work.width { match scene.sizes.stepped(column, &spec) { - // The edge of a stepped column moves in whole steps: the most that fit where it is dragged, inside its - // card. + // The edge of a stepped column moves in whole steps: the most that fit where it is dragged. Some((grid, steps)) if !column.iconic => { - let to = grid.steps_within(width - scene.sizes.card_inset(column, &spec)); + let to = grid.steps_within(width); if to != steps { self.report.actions.push(Action::set_column_steps(first.clone(), to)); } @@ -1594,7 +1608,7 @@ impl Pass<'_, P> { // An OS window's flyouts and other layers take the room around the window (`overlay::layer_room`); an // in-app window's stay in the float area. let within = if opening.spec.is_some() { Rect::NOTHING } else { scene.bounds }; - let at = ColumnAt { cell: body.rect, edge, bar: ColumnBar::Window, within, open: open.clone() }; + let at = ColumnAt { cell: body.rect, edge, bar: ColumnBar::Window, within, open: open.clone(), card: None }; self.column(ui, body, &window.column, at); }); self.dock = area_dock; diff --git a/crates/ui-patterns/tests/it/docking/columns.rs b/crates/ui-patterns/tests/it/docking/columns.rs index e274aefde..217f91ad0 100644 --- a/crates/ui-patterns/tests/it/docking/columns.rs +++ b/crates/ui-patterns/tests/it/docking/columns.rs @@ -509,7 +509,7 @@ impl DockPanels for RailStage { } /// A start dock in `direction` of a toolbar column of two rail steps, at the window edge, and a side column beside it, -/// with `DockConfig::rail_cards` set to `cards`: the toolbar's cell, the side column's cell and the rail's stage. +/// with `DockConfig::column_cards` set to `cards`: the toolbar's cell, the side column's cell and the rail's stage. fn rail_dock(cards: bool, direction: Direction) -> (Rect, Rect, Rect) { let columns = vec![Column::new(vec![Group::new(vec![TOOLS], 0)]).with_steps(2), Column::new(vec![Group::new(vec![2], 0)]).with_width(150.0)]; let root = Node::split(Axis::X, SplitSize::FixedFirst(300.0), Node::dock(DockEdge::Start, columns), Node::tabs(vec![1], 0)); @@ -519,7 +519,7 @@ fn rail_dock(cards: bool, direction: Direction) -> (Rect, Rect, Rect) { let (held, seen, shown, specs) = (Rc::clone(&workspace), Rc::clone(&placed), Rc::clone(&stage), Tracked::new(RailTools)); let mut fixture = Fixture::new(move |ui| { let mut workspace = held.borrow().clone(); - let config = DockConfig::default().rail_cards(cards); + let config = DockConfig::default().column_cards(cards); let out = DockArea::new("Rail dock", Bind::bound(&mut workspace), &specs, &mut RailStage(Rc::clone(&shown)), config).show(ui); *held.borrow_mut() = workspace; *seen.borrow_mut() = out.columns; @@ -555,3 +555,102 @@ fn a_rail_card_is_inset_alike_on_three_sides_and_keeps_its_steps() { ); } } + +/// The panel of the card dock's expanded column, and of its column collapsed to icons. +const SIDE: u32 = 2; +const ICONS: u32 = 4; + +/// Panels named for the card dock: an expanded column's panel, and a collapsed column's, whose icon the trial finds by +/// its name. +#[derive(PlainData)] +struct CardPanels; + +impl PanelSpecs for CardPanels { + fn spec(&self, panel: &u32) -> PanelSpec { + PanelSpec::new(if *panel == ICONS { "Icons" } else { "Side" }) + } +} + +/// Panels that record the rect the expanded column's group gets. +struct CardStage(Rc>>); + +impl DockPanels for CardStage { + fn body(&mut self, panel: &u32, _: &mut Ui, body: &mut BodyCx<'_>) { + if *panel == SIDE { + self.0.set(Some(body.rect)); + } + } +} + +/// What a card dock trial reads: the cells of the expanded column and of the column of icons, the body of the expanded +/// column's panel and the icon's cell. +struct CardDock { + side: Rect, + icons: Rect, + body: Rect, + icon: Rect, +} + +/// An end dock in `direction` beside the canvas: an expanded column at the window edge and, inward of it, a column +/// collapsed to icons, with `DockConfig::column_cards` set to `cards`. +fn card_dock(cards: bool, direction: Direction) -> CardDock { + let mut iconic = Column::new(vec![Group::new(vec![ICONS], 0)]); + iconic.iconic = true; + let columns = vec![Column::new(vec![Group::new(vec![SIDE], 0)]).with_width(220.0), iconic]; + let root = Node::split(Axis::X, SplitSize::Ratio(0.6), Node::tabs(vec![1], 0), Node::dock(DockEdge::End, columns)); + let workspace = Rc::new(RefCell::new(Arc::new(Workspace::new(Layout::new(Some(root), Vec::new()))))); + let placed: Rc>> = Rc::default(); + let body: Rc>> = Rc::default(); + let (held, seen, shown, specs) = (Rc::clone(&workspace), Rc::clone(&placed), Rc::clone(&body), Tracked::new(CardPanels)); + let mut fixture = Fixture::new(move |ui| { + let mut workspace = held.borrow().clone(); + let config = DockConfig::default().column_cards(cards); + let out = DockArea::new("Card dock", Bind::bound(&mut workspace), &specs, &mut CardStage(Rc::clone(&shown)), config).show(ui); + *held.borrow_mut() = workspace; + *seen.borrow_mut() = out.columns; + }); + fixture.direction(direction).room(Vec2::new(900.0, 500.0)).settle(); + let cell = |panel: u32| placed.borrow().iter().find(|(at, _)| *at == panel).map(|(_, rect)| *rect).expect("the column shows"); + let icon = fixture.by_label("Icons").expect("the icon shows").rect; + CardDock { side: cell(SIDE), icons: cell(ICONS), body: body.get().expect("the side panel shows"), icon } +} + +/// The insets of `inner` in `cell` on the outer side, the window edge's (the right in left to right), and on the inner +/// side. +fn sides(cell: Rect, inner: Rect, rtl: bool) -> (f32, f32) { + if rtl { (inner.left() - cell.left(), cell.right() - inner.right()) } else { (cell.right() - inner.right(), inner.left() - cell.left()) } +} + +/// Every docked column shows as a card: the column at the window edge is inset alike on its outer side and its foot, +/// the column of icons inward of it stands a gutter from its card, narrower than the edge's inset, and both cards keep +/// to their inner edges. The columns do not overlap, and each is wider than without cards by its inset, so its +/// content keeps its width. Right to left mirrors the outer sides. +#[trial] +fn every_docked_column_is_a_card_with_gutters_between_them() { + for direction in [Direction::Ltr, Direction::Rtl] { + let rtl = direction == Direction::Rtl; + let plain = card_dock(false, direction); + let cards = card_dock(true, direction); + // Each inset is measured against the same column without cards, so a panel's own padding cancels out. + let inset = |cell: Rect, inner: Rect, plain_cell: Rect, plain_inner: Rect| { + let ((outer, inward), (plain_outer, plain_inward)) = (sides(cell, inner, rtl), sides(plain_cell, plain_inner, rtl)); + (outer - plain_outer, inward - plain_inward) + }; + let (edge, side_inner) = inset(cards.side, cards.body, plain.side, plain.body); + let foot = (cards.side.bottom() - cards.body.bottom()) - (plain.side.bottom() - plain.body.bottom()); + assert!(edge > 0.5, "{direction:?}: the edge column's card is inset from the window edge: {:?} in {:?}", cards.body, cards.side); + assert!((foot - edge).abs() <= 0.5, "{direction:?}: the edge column's card is inset {edge} at the edge and {foot} at its foot"); + assert!(side_inner.abs() <= 0.5, "{direction:?}: the edge column's card keeps to its inner edge"); + let (gutter, icons_inner) = inset(cards.icons, cards.icon, plain.icons, plain.icon); + assert!( + gutter > 0.5 && gutter < edge, + "{direction:?}: the icons' card stands a gutter {gutter} from its neighbour's, under the edge's {edge}" + ); + assert!(icons_inner.abs() <= 0.5, "{direction:?}: the icons' card keeps to its inner edge"); + let apart = if rtl { cards.icons.left() >= cards.side.right() - 0.5 } else { cards.icons.right() <= cards.side.left() + 0.5 }; + assert!(apart, "{direction:?}: the icons' column {:?} overlaps the edge column {:?}", cards.icons, cards.side); + assert!((cards.body.width() - plain.body.width()).abs() <= 0.5, "{direction:?}: the panel keeps its width in its card"); + assert!((cards.side.width() - plain.side.width() - edge).abs() <= 0.5, "{direction:?}: the edge column grows by its inset"); + assert!((cards.icons.width() - plain.icons.width() - gutter).abs() <= 0.5, "{direction:?}: the icons' column grows by its gutter"); + } +} From 06e94d7321869b721e5b4c815fc09c7685327863 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 24 Nov 2026 17:59:45 +0700 Subject: [PATCH 64/76] tabs, dock: PanelTabLook::Pill shows a panel strip's shown tab on a filled rounded pill (surface.control, shape.radius.control, size.control.sm high in the middle of the strip; a hovered tab shows it too); TabStrip::panel_look and DockConfig::tab_look choose it, Plain by default --- crates/ui-panels/src/docking/config.rs | 12 +++++++ crates/ui-panels/src/docking/group.rs | 9 ++++- crates/ui-patterns/src/patterns/dock/area.rs | 1 + crates/ui-widgets/src/tabs/mod.rs | 2 +- crates/ui-widgets/src/tabs/rules.rs | 13 ++++++++ crates/ui-widgets/src/tabs/strip.rs | 8 +++-- crates/ui-widgets/src/tabs/strip/stories.rs | 9 ++++- crates/ui-widgets/src/tabs/tab.rs | 35 +++++++++++++++++++- 8 files changed, 83 insertions(+), 6 deletions(-) diff --git a/crates/ui-panels/src/docking/config.rs b/crates/ui-panels/src/docking/config.rs index e2d19ff42..d3b885867 100644 --- a/crates/ui-panels/src/docking/config.rs +++ b/crates/ui-panels/src/docking/config.rs @@ -3,6 +3,7 @@ use super::IconicMode; use super::targets::ZoneRule; +use crate::tabs::PanelTabLook; use craft_behavior::{DockSide, IconId}; /// A set of the sides of the layout's outer edge or of a group. @@ -97,6 +98,9 @@ pub struct DockConfig { pub titled_headers: bool, /// The wheel over a tab strip shows the next or previous panel, one per wheel notch. pub wheel_selects_tabs: bool, + /// The look of the groups' panel tabs: the shown tab on the panel surface ([`PanelTabLook::Plain`]), or on a + /// filled rounded pill ([`PanelTabLook::Pill`]). + pub tab_look: PanelTabLook, /// A floating window opens in an OS window of its own where the window host opens OS windows and reports where /// they are on the desktop (not on Wayland) and its panels allow it (`PanelSpec::allow_native`). Elsewhere, and /// with this off, it shows in the app window. @@ -131,6 +135,7 @@ impl Default for DockConfig { tab_close_buttons: false, titled_headers: false, wheel_selects_tabs: false, + tab_look: PanelTabLook::Plain, native_windows: true, group_order_items: false, panel_menu_always: false, @@ -253,6 +258,13 @@ impl DockConfig { self } + /// The look of the groups' panel tabs ([`tab_look`](Self::tab_look)). + #[must_use] + pub fn tab_look(mut self, look: PanelTabLook) -> Self { + self.tab_look = look; + self + } + /// Close buttons on tabs on or off. #[must_use] pub fn tab_close_buttons(mut self, on: bool) -> Self { diff --git a/crates/ui-panels/src/docking/group.rs b/crates/ui-panels/src/docking/group.rs index cc7a1bcb7..16184feac 100644 --- a/crates/ui-panels/src/docking/group.rs +++ b/crates/ui-panels/src/docking/group.rs @@ -21,7 +21,7 @@ use crate::runtime::focus::{self, FocusTarget}; use crate::runtime::memory::sub; use crate::sections::FooterBar; use crate::style::{ComponentStyle, Corners, RuleLook, RuleWidth, StyleColor, StyleCx, SurfaceKind, TypeRole}; -use crate::tabs::{Tab, TabKind, TabStrip, TornOff}; +use crate::tabs::{PanelTabLook, Tab, TabKind, TabStrip, TornOff}; use craft_behavior::{CursorIcon, CursorPriority, DockSide, IconId, Metrics, PartKey, PressPhase, Sense, keyed}; use craft_theme::{ControlSize, GripMark, GripShape, Tokens}; use egui::{Id, Pos2, Rect, Response, Ui, Vec2}; @@ -347,6 +347,9 @@ pub struct DockGroup<'a, P: Clone + Hash + Send + Sync + 'static> { /// The wheel over the tabs shows the next or previous panel, one per wheel notch. #[prop(flag)] wheel_selects_tabs: bool, + /// The look of the tabs ([`DockConfig::tab_look`](super::DockConfig::tab_look)). + #[prop] + tab_look: PanelTabLook, /// The header shows the shown panel's title (with its count) and a close button in place of the tab strip, as a /// single titled panel does: the panels are shown from a rail, not by tabs. #[prop(flag)] @@ -402,6 +405,7 @@ impl<'a, P: Clone + Hash + Send + Sync + PartialEq + Debug + 'static> DockGroup< movable: true, closable: false, wheel_selects_tabs: false, + tab_look: PanelTabLook::Plain, titled: false, dock: None, zones: ZoneRule::Fraction, @@ -666,6 +670,7 @@ impl Container for active: self.active, closable: self.closable, wheel_selects: self.wheel_selects_tabs, + look: self.tab_look, dock: self.dock, sent: Outbox::new(&mut sent), }; @@ -740,6 +745,7 @@ struct TabRow<'a, P> { active: PanelKey, closable: bool, wheel_selects: bool, + look: PanelTabLook, dock: Option, sent: Outbox<'a, TabEvent>, } @@ -768,6 +774,7 @@ fn tab_row(row: &mu let kind = if panels.iter().any(closes) { TabKind::Document } else { TabKind::Panel }; let mut strip = TabStrip::new(name) .kind(kind) + .panel_look(row.look) .shown(active) .tear_off() .natural_height(true) diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index f4e5c57fe..c8f50a75a 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -1104,6 +1104,7 @@ impl Pass<'_, P> { .menu(move || panel_menu_rows(scene, &mut **panels.borrow_mut(), words, shown).0) .panel_menu_shown(*hosted || scene.config.panel_menu_always) .panel_menu_icon(scene.config.panel_menu_icon.clone()) + .tab_look(scene.config.tab_look) .command_states(states.clone()); if look.in_window { group = group.in_window(); diff --git a/crates/ui-widgets/src/tabs/mod.rs b/crates/ui-widgets/src/tabs/mod.rs index 43a3f8982..4e27b1c62 100644 --- a/crates/ui-widgets/src/tabs/mod.rs +++ b/crates/ui-widgets/src/tabs/mod.rs @@ -6,7 +6,7 @@ mod words; mod rules; pub(crate) mod tab; -pub use rules::{CloseSide, DocumentTabLook, FitMode, OverflowMenu, OverflowPlace, TabKind, close_side}; +pub use rules::{CloseSide, DocumentTabLook, FitMode, OverflowMenu, OverflowPlace, PanelTabLook, TabKind, close_side}; pub use tab::{Tab, TabOutput, TabPartEvent, TabRole, TabStyle}; pub use words::TabWords; diff --git a/crates/ui-widgets/src/tabs/rules.rs b/crates/ui-widgets/src/tabs/rules.rs index 3583682b3..19a74b597 100644 --- a/crates/ui-widgets/src/tabs/rules.rs +++ b/crates/ui-widgets/src/tabs/rules.rs @@ -17,6 +17,19 @@ pub enum DocumentTabLook { Shrinking, } +/// The look of panel tabs ([`TabKind::Panel`]): a strip's choice ([`TabStrip::panel_look`](super::TabStrip)), which a +/// dock makes for its groups' tabs. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::contract::MemoProps)] +#[non_exhaustive] +pub enum PanelTabLook { + /// The shown tab on the panel surface, square and as tall as the strip. + #[default] + Plain, + /// VectorCraft's tabs: the shown tab on a filled pill (`surface.control` with `shape.radius.control` corners), a + /// small control high in the middle of the strip; a tab under the pointer shows the pill too. + Pill, +} + /// The kind of a strip. It sets the defaults below; the host picks one per strip. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] #[non_exhaustive] diff --git a/crates/ui-widgets/src/tabs/strip.rs b/crates/ui-widgets/src/tabs/strip.rs index 4d48ba9e1..da1ab7e01 100644 --- a/crates/ui-widgets/src/tabs/strip.rs +++ b/crates/ui-widgets/src/tabs/strip.rs @@ -516,6 +516,9 @@ pub struct TabStrip<'a, K: Clone + Eq + Hash + Send + Sync + std::fmt::Debug + ' /// The strip's taller form with the body type. #[prop(flag)] large: bool, + /// The look of a panel strip's tabs ([`TabKind::Panel`]). + #[prop] + panel_look: super::PanelTabLook, /// The tab the host shows. A click, Space, Enter or a drop reports the new one in the output. #[prop] shown: Option, @@ -586,6 +589,7 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + std::fmt::Debug + 'static> TabStri .primary_picks(TabKind::Document.primary_shows()), kind: TabKind::Document, large: false, + panel_look: super::PanelTabLook::Plain, shown: None, tear_off: false, wheel_selects: false, @@ -1023,9 +1027,9 @@ impl Collection StripLayout::new(count, Vec2::new(width, cx.tokens.size.bar.tab), tab_gap, fitting, self.report.clone(), cx.frame_ctx().clone()) } - /// Every tab takes the strip's kind and size. + /// Every tab takes the strip's kind, panel look and size. fn dress<'r>(&self, tab: Self::Item<'r>, _: &RowState) -> Self::Item<'r> { - let tab = tab.kind(self.kind); + let tab = tab.kind(self.kind).panel_look(self.panel_look); if self.large { tab.large() } else { tab } } diff --git a/crates/ui-widgets/src/tabs/strip/stories.rs b/crates/ui-widgets/src/tabs/strip/stories.rs index 1d38a446f..863e07c5a 100644 --- a/crates/ui-widgets/src/tabs/strip/stories.rs +++ b/crates/ui-widgets/src/tabs/strip/stories.rs @@ -3,7 +3,7 @@ use super::{StripEnd, TabKind, TabStrip}; use crate::contract::{CollectionEvent, Entry, ReorderRule, ShowCollection as _}; use crate::runtime::commands::{CommandRef, EditCommands}; -use crate::tabs::{Tab, TabRole}; +use crate::tabs::{PanelTabLook, Tab, TabRole}; use crate::testing::{Drive, Fixture, StoryData, StoryOutput, story}; use craft_behavior::{DisplayOrder, IconId, ItemSource, SelectionChange}; use egui::{Key, Modifiers, Ui}; @@ -94,6 +94,13 @@ fn tab_strip_panel(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { strip(ui, data, TabStrip::new("Panels").shown(1), &TITLES, 4, TabKind::Panel) } +/// Panel tabs in the pill look (`PanelTabLook::Pill`, a dock's `DockConfig::tab_look`): the shown tab on a filled +/// rounded pill in the middle of the strip, the others bare until the pointer rests on one. +#[story(TabStrip<'static, usize>, covers = [], drive = Drive::Never)] +fn tab_strip_panel_pill(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + strip(ui, data, TabStrip::new("Panels").shown(1).panel_look(PanelTabLook::Pill), &TITLES, 4, TabKind::Panel) +} + /// The width the narrow panel story's room is held to: the shown tab whole, the others at their first letters. const NARROW_ROOM: f32 = 260.0; diff --git a/crates/ui-widgets/src/tabs/tab.rs b/crates/ui-widgets/src/tabs/tab.rs index 0b69e1e72..729f598f3 100644 --- a/crates/ui-widgets/src/tabs/tab.rs +++ b/crates/ui-widgets/src/tabs/tab.rs @@ -5,7 +5,7 @@ //! measure is its natural width (`Proposal::Min` the room for the first letters of its title), and a narrower rect cuts the label //! first, then the detail, and shows the whole text as a tooltip. -use super::rules::{CloseSide, TabKind, close_side}; +use super::rules::{CloseSide, PanelTabLook, TabKind, close_side}; use super::words::TabWords; use std::borrow::Cow; @@ -133,6 +133,8 @@ pub struct TabStyle { indicator: Option, /// A divider at the tab's trailing edge. divider: bool, + /// The pill a panel tab in [`PanelTabLook::Pill`] shows under its label in place of the surface. + pill: Option, close_side: CloseSide, sizes: Sizes, /// Document tabs in [`DocumentTabLook::Shrinking`](super::DocumentTabLook::Shrinking): a name capped at @@ -146,6 +148,15 @@ pub struct TabStyle { marker_edge: StyleColor, } +/// The pill of a panel tab in [`PanelTabLook::Pill`]: its fill in each state, its corners and its height, in the +/// middle of the tab's height. +#[derive(Clone, Debug, PartialEq)] +struct Pill { + fill: Stateful, + radius: egui::CornerRadius, + height: f32, +} + /// Where the parts of a tab lie in its content rect. #[derive(Clone, Copy, Debug)] struct Placed { @@ -180,6 +191,10 @@ pub struct Tab<'a> { #[style_key] #[prop(flag)] large: bool, + /// The look of a panel tab ([`TabKind::Panel`]); the other kinds have their own. + #[style_key] + #[prop] + panel_look: PanelTabLook, /// Secondary text after the label (a colour mode, a zoom). #[prop(into)] detail: Option