mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 20:14:31 +01:00
Merge remote-tracking branch 'origin/next' into fix/vc-theme-and-focus
# Conflicts: # crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-comfortable.txt # crates/theme/tests/dumps/tokens/vectorcraft-modern-medium-dark-high-compact.txt
This commit is contained in:
commit
f2ee94bfc4
15 files changed
+122
-76
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -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<ControlRequest>,
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<dyn Fn(&str, &[u8], bool) -> Option<Result<(), String>> + Send + Sync>;
|
||||
pub type PageSave = Arc<PageSaveFn>;
|
||||
|
||||
/// The callback behind a [`PageSave`].
|
||||
pub type PageSaveFn = dyn Fn(&str, &[u8], bool) -> Option<Result<(), String>> + 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<Result<(), String>> + Send + Sync)>,
|
||||
page: Option<&PageSaveFn>,
|
||||
name: &str,
|
||||
bytes: &[u8],
|
||||
save_as: bool,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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::<P>()).then_some(drop)
|
||||
}
|
||||
|
||||
|
||||
@@ -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<C: Collection> ShapeHooks<C> 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<C: Collection> 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<C::ItemEvent>) {
|
||||
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<ItemOpener>) -> Vec<(ItemOpener, egui::Response)> {
|
||||
item_openers(ui, ctx, id, enabled, openers)
|
||||
|
||||
@@ -74,7 +74,7 @@ pub enum DropMark {
|
||||
},
|
||||
}
|
||||
|
||||
crate::stays!(Arc<crate::style::UiTokens>, DropOperation);
|
||||
crate::stays!(Arc<crate::style::UiTokens>, 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<UiTokens>,
|
||||
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<DropMark>) {
|
||||
}
|
||||
|
||||
/// 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<UiTokens>,
|
||||
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<UiTokens>, 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::<Targets>::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<T: DropTarget<dyn Any + Send + Sync>>(
|
||||
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<Id>, bool)> = PerViewport::<Targets>::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<bool> =
|
||||
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::<Targets>::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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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<Id>, 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 =
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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<PendingPick> {
|
||||
self.inner.pending_pick()
|
||||
}
|
||||
|
||||
fn read(&self, path: &Path) -> Result<Vec<u8>, FileError> {
|
||||
|
||||
Reference in new issue
Block a user