diff --git a/crates/atomic/src/lib.rs b/crates/atomic/src/lib.rs index c0bbcf5553..2fa589d099 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; diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rs index b2f9fdd1d0..c6808156d7 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; + } + } } diff --git a/crates/platform/src/browser_files.rs b/crates/platform/src/browser_files.rs index a00309b253..3d18b37caa 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/text/src/ui/character/format_text.rs b/crates/text/src/ui/character/format_text.rs index 5f697ac1ab..5a5de1ef6c 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 diff --git a/crates/ui-contract/src/contract/cx/pointer.rs b/crates/ui-contract/src/contract/cx/pointer.rs index f7dc0b3cc3..9f31c12991 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 7039260b80..f25092d50c 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 72b61d9100..405d60dcc9 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 df7c599778..cf6819543d 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 423bc707e1..bfe0156945 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) }) }) } diff --git a/crates/ui-contract/src/runtime/keys/intents.rs b/crates/ui-contract/src/runtime/keys/intents.rs index b3ca4df20b..a60d21cc5b 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 = diff --git a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs index cbc7b8c4f3..b95aee9bb3 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 ce5933cfee..af852f73f3 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. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs index 9ff040e87d..4b4b03b869 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. diff --git a/crates/ui-widgets/Cargo.toml b/crates/ui-widgets/Cargo.toml index 63d0e4bdf9..3b84b7f388 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 = [] diff --git a/crates/web-host/src/files.rs b/crates/web-host/src/files.rs index bc9bcf5cca..dcd15a8839 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> {