fw sync: cargo fmt --all (including drift that predates the sync)

This commit is contained in:
Dylan M. Taylor committed 2026-11-23 03:04:16 -05:00
1 parent 32fae648a6
commit 173d63d915
21 files changed
+142 -68

No files matched your search

@@ -357,11 +357,8 @@ fn clip_quad(mesh: PreviewMesh, quad: [Point; 4], source: bool) -> PreviewMesh {
}
let distance = |edge: usize, p: Point| cross(quad[edge], quad[(edge + 1) % 4], p) * area.signum();
let inside = |p: &Point| (0..4).all(|edge| distance(edge, *p) >= 0.0);
let entirely_inside = if source {
mesh.uv.iter().all(|uv| inside(&Point::new(f64::from(uv[0]), f64::from(uv[1]))))
} else {
mesh.points.iter().all(inside)
};
let entirely_inside =
if source { mesh.uv.iter().all(|uv| inside(&Point::new(f64::from(uv[0]), f64::from(uv[1])))) } else { mesh.points.iter().all(inside) };
if entirely_inside {
return mesh;
}
+2 -1
View File
@@ -63,5 +63,6 @@ pub use thumbnails::{
ThumbnailWords, moved_page,
};
pub use view::{
GoTo, GoToPlace, PICTURE_REACH, PageBody, PageInsets, PageRegion, PageRevision, PageSnap, PageSource, PageView, PageViewOutput, PageViewState, PageViewWords, PlacedPage,
GoTo, GoToPlace, PICTURE_REACH, PageBody, PageInsets, PageRegion, PageRevision, PageSnap, PageSource, PageView, PageViewOutput, PageViewState,
PageViewWords, PlacedPage,
};
+2 -2
View File
@@ -8,8 +8,8 @@ pub(crate) mod stories;
use super::view::PageSource;
use craft_behavior::{Input, Metrics, PartKey, Proposal, Sense};
use craft_ui::contract::{
Bind, CommandSet, Common, Component, Cx, DisabledLook, MeasureCx, NoValue,
Outcome, PaintUi, PartsCx, Props as _, Role, RowAlign, Show as _, ShowContainer,
Bind, CommandSet, Common, Component, Cx, DisabledLook, MeasureCx, NoValue, Outcome, PaintUi, PartsCx, Props as _, Role, RowAlign, Show as _,
ShowContainer,
};
use craft_ui::dialog::Dialog;
use craft_ui::layout_components::Row;
+2 -2
View File
@@ -9,8 +9,8 @@ use craft_behavior::{Codec, NotAValue, NumberCodec};
use craft_ui::buttons::IconButton;
use craft_ui::choice::{Radio, RadioGroup};
use craft_ui::contract::{
Bind, EditResponse, Entry, FieldLayout, LabelKind, LabelScheme, NoValue, Outcome, Pattern, Props as _, Show as _, ShowContainer as _, SideLabel, Trigger,
Validity,
Bind, EditResponse, Entry, FieldLayout, LabelKind, LabelScheme, NoValue, Outcome, Pattern, Props as _, Show as _, ShowContainer as _, SideLabel,
Trigger, Validity,
};
use craft_ui::display::Text;
use craft_ui::form::Field;
+7 -1
View File
@@ -456,7 +456,13 @@ impl<'a> PageThumbnails<'a> {
let tail: Vec<TailRow<usize>> = if new_page_row { vec![TailRow::new(new_page, words.new_page.clone())] } else { Vec::new() };
// Organize uses a portrait page frame for every page, so landscape pages fit inside it
// instead of collapsing the room reserved for the controls around the picture.
let aspect = if organize { 0.85 } else if count == 0 { 1.0 } else { aspect_of(source, 0) };
let aspect = if organize {
0.85
} else if count == 0 {
1.0
} else {
aspect_of(source, 0)
};
let mut grid = TileGrid::<usize>::new(label)
.id_source(id)
.selection(Bind::bound(&mut *picked))
+6 -2
View File
@@ -78,8 +78,12 @@ fn organize_keeps_room_above_and_below_landscape_pages() {
}
}
impl craft_pages::ui::PageSource for Landscape {
fn page_count(&self) -> usize { 1 }
fn page_size(&self, _: usize) -> craft_behavior::kurbo::Size { craft_behavior::kurbo::Size::new(792.0, 612.0) }
fn page_count(&self) -> usize {
1
}
fn page_size(&self, _: usize) -> craft_behavior::kurbo::Size {
craft_behavior::kurbo::Size::new(792.0, 612.0)
}
}
let pages = Landscape(DemoPages::new(1));
let mut picked = Selection::default();
+25 -4
View File
@@ -42,15 +42,36 @@ fn a_rejected_picker_downloads_once_unless_cancelled() {
fn a_write_goes_to_the_embedding_page_and_downloads_only_without_one() {
let page = |name: &str, bytes: &[u8], save_as: bool| Some(if save_as { Err(format!("{name} {}", bytes.len())) } else { Ok(()) });
let mut downloads = 0;
assert_eq!(page_or_download(Some(&page), "a.pdf", b"pdf", false, || { downloads += 1; Ok(()) }), Ok(true));
assert_eq!(
page_or_download(Some(&page), "a.pdf", b"pdf", true, || { downloads += 1; Ok(()) }),
page_or_download(Some(&page), "a.pdf", b"pdf", false, || {
downloads += 1;
Ok(())
}),
Ok(true)
);
assert_eq!(
page_or_download(Some(&page), "a.pdf", b"pdf", true, || {
downloads += 1;
Ok(())
}),
Err(craft_host::FileError::Other("a.pdf 3".into())),
"the page's refusal is the write's"
);
assert_eq!(downloads, 0, "a page that answers is the only save");
let unhosted = |_: &str, _: &[u8], _: bool| None;
assert_eq!(page_or_download(Some(&unhosted), "a.pdf", b"pdf", false, || { downloads += 1; Ok(()) }), Ok(false));
assert_eq!(page_or_download(None, "a.pdf", b"pdf", false, || { downloads += 1; Ok(()) }), Ok(false));
assert_eq!(
page_or_download(Some(&unhosted), "a.pdf", b"pdf", false, || {
downloads += 1;
Ok(())
}),
Ok(false)
);
assert_eq!(
page_or_download(None, "a.pdf", b"pdf", false, || {
downloads += 1;
Ok(())
}),
Ok(false)
);
assert_eq!(downloads, 2, "without a page each write downloads once");
}
+3 -1
View File
@@ -95,7 +95,9 @@ impl Spool {
#[cfg(feature = "ui")]
pub fn discoverer(&self) -> crate::ui::Discover {
let spool = self.clone();
Box::new(move || spool.listed(|printer| crate::ui::Printer { name: printer.name, label: printer.description, default: printer.default, own_dialog: None }))
Box::new(move || {
spool.listed(|printer| crate::ui::Printer { name: printer.name, label: printer.description, default: printer.default, own_dialog: None })
})
}
/// Asks the backend for its printers in a job and sends them through `map`; a platform that
+8 -4
View File
@@ -7,9 +7,8 @@ use craft_behavior::{CursorIcon, EditEvent, EditEvents, Metrics, Mixed, PartKey,
use craft_theme::variant::Tone;
use craft_ui::buttons::Button;
use craft_ui::contract::{
LabelScheme,
Access, Bind, BindMut, Common, Component, Cx, Edit as _, EditResponse, Input, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Pointer as _,
Props as _, Role, Scroll, Show as _, ShowContainer as _, WordSetCx as _, clicked,
Access, Bind, BindMut, Common, Component, Cx, Edit as _, EditResponse, Input, LabelScheme, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx,
Pointer as _, Props as _, Role, Scroll, Show as _, ShowContainer as _, WordSetCx as _, clicked,
};
use craft_ui::dialog::{DialogId, DialogResult, DialogStack, FieldRefusal, HeldAnswer, HeldOk, StackDialog, dialog_id};
use craft_ui::display::{Shade, Text};
@@ -564,7 +563,12 @@ impl Component for PrintPreview<'_> {
pos2((visible.min.x - image.min.x) / image.width(), (visible.min.y - image.min.y) / image.height()),
pos2((visible.max.x - image.min.x) / image.width(), (visible.max.y - image.min.y) / image.height()),
);
ui.content_painter(cx).data_shapes([Shape::mesh(page_quad(picture.id, [visible.left_top(), visible.right_top(), visible.right_bottom(), visible.left_bottom()], uv, tint))]);
ui.content_painter(cx).data_shapes([Shape::mesh(page_quad(
picture.id,
[visible.left_top(), visible.right_top(), visible.right_bottom(), visible.left_bottom()],
uv,
tint,
))]);
}
Some(image)
}
+10 -3
View File
@@ -3,7 +3,9 @@
use super::{Destination, Duplex, Printer, Settings, shown_names};
use craft_ui::buttons::Button;
use craft_ui::choice::Checkbox;
use craft_ui::contract::{Bind, Entry, FieldLayout, Held, LabelScheme, NoValue, Outcome, Props as _, Show as _, ShowContainer as _, SideLabel, clicked};
use craft_ui::contract::{
Bind, Entry, FieldLayout, Held, LabelScheme, NoValue, Outcome, Props as _, Show as _, ShowContainer as _, SideLabel, clicked,
};
use craft_ui::display::{Shade, Text};
use craft_ui::form::{Field, FieldGroup};
use craft_ui::layout_components::Row;
@@ -230,8 +232,13 @@ impl<'a> PrintPanel<'a> {
if let Some(on) = collate.value().copied() {
now.collate = on;
}
let grayscale =
cx.labelled(ui, "grayscale", if inline { words.print_in_grayscale.clone() } else { words.grayscale.clone() }, after, Checkbox::new(Bind::given(now.grayscale)).enabled(free));
let grayscale = cx.labelled(
ui,
"grayscale",
if inline { words.print_in_grayscale.clone() } else { words.grayscale.clone() },
after,
Checkbox::new(Bind::given(now.grayscale)).enabled(free),
);
if let Some(on) = grayscale.value().copied() {
now.grayscale = on;
}
+8 -9
View File
@@ -3,17 +3,17 @@
use std::collections::HashMap;
use craft_behavior::{GesturePhase, IconId, Metrics, Sense};
use craft_theme::{ControlSize, Mode};
use craft_theme::variant::Variant;
use craft_theme::{ControlSize, Mode};
use craft_ui::buttons::{Button, IconButton, PressFocus};
use craft_ui::contract::overlay::{PlacementChange, PlacementKind, ResizeEdges};
use craft_ui::contract::{
Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, Cx, DragBand, HeaderRegion, MeasureCx, Mount, NoValue, Outcome, Overlay,
Gap, Pad, PaintUi, Pattern, Props as _, Role, Show as _, ShowContainer as _, SizeLimits, Sizing, ThemeScope, clicked,
Bind, BindMut, BodyCx, Common, Component, Container, ContainerProps, Cx, DragBand, Gap, HeaderRegion, MeasureCx, Mount, NoValue, Outcome,
Overlay, Pad, PaintUi, Pattern, Props as _, Role, Show as _, ShowContainer as _, SizeLimits, Sizing, ThemeScope, clicked,
};
use craft_ui::display::{Shade, Text};
use craft_ui::layout_components::{Row, Stack};
use craft_ui::layout::RowAlign;
use craft_ui::layout_components::{Row, Stack};
use craft_ui::primitives::{IconSpec, PaintShape, TextRun, Wrap};
use craft_ui::runtime::env::{Env, EnvView, Label};
use craft_ui::runtime::overlay::CloseReason;
@@ -363,7 +363,8 @@ impl<'a> NotePopup<'a> {
Overlay::floating().modeless().movable(allowed).resize_edges(grip).body_scroll(true).size_limits(NOTE_POPUP_LIMITS).placed(shown_at);
let layer = NoteWindow::new(label, overlay, NoteLook { title, age, fill }, words.close.clone(), allowed, anchor, selected)
.id_salt(("note-popup", id));
let mut content = NoteBody { id, messages, drafts, allowed, now, tint_color: Color32::from_rgb(pale(r), pale(g), pale(b)), body: None, reply: None };
let mut content =
NoteBody { id, messages, drafts, allowed, now, tint_color: Color32::from_rgb(pale(r), pale(g), pale(b)), body: None, reply: None };
let shown = layer.show(ui, |ui, _| content.show(ui, &words, &view));
let NoteBody { drafts, mut body, reply, .. } = content;
let out = shown.output;
@@ -514,10 +515,8 @@ struct NoteWindow {
impl NoteWindow {
fn new(label: Label, overlay: Overlay, look: NoteLook, close_label: Label, allowed: bool, anchor: Option<(Rect, bool)>, selected: bool) -> Self {
let props = ContainerProps::new()
.mount(Mount::Layer(overlay))
.surface(SurfaceKind::Floating)
.header(HeaderRegion::new().band(DragBand::Move));
let props =
ContainerProps::new().mount(Mount::Layer(overlay)).surface(SurfaceKind::Floating).header(HeaderRegion::new().band(DragBand::Move));
NoteWindow {
common: Common::new(),
props,
+15 -19
View File
@@ -796,32 +796,28 @@ fn the_overlay_draws_round_handles_and_no_second_leader() {
let annotations = vec![annotation(1, AnnotationKind::Rectangle, Rect::new(20.0, 20.0, 100.0, 60.0)), callout];
let selected = vec![AnnotationId(2)];
let shown = annotations.clone();
let mut overlay = ToolFixture::with_view(
"Document",
AnnotateTool::new(AnnotationTool::Select, 0),
view,
move |ui, cx| {
AnnotationOverlay::new("Annotations", &shown, &selected).show_at(ui, cx.rect);
},
);
let mut overlay = ToolFixture::with_view("Document", AnnotateTool::new(AnnotationTool::Select, 0), view, move |ui, cx| {
AnnotationOverlay::new("Annotations", &shown, &selected).show_at(ui, cx.rect);
});
let tip = on_screen(&overlay, Point::new(60.0, 160.0));
let shapes = overlay.fixture().frame_shapes();
let leaders: Vec<&egui::epaint::PathShape> =
shapes.iter().filter_map(|shape| if let Shape::Path(p) = shape { Some(p) } else { None }).filter(|p| p.points.first().is_some_and(|q| (*q - tip).length() < 0.5)).collect();
let leaders: Vec<&egui::epaint::PathShape> = shapes
.iter()
.filter_map(|shape| if let Shape::Path(p) = shape { Some(p) } else { None })
.filter(|p| p.points.first().is_some_and(|q| (*q - tip).length() < 0.5))
.collect();
assert!(!leaders.is_empty(), "the leader paints");
assert!(leaders.iter().all(|p| p.stroke.color == ColorMode::Solid(Color32::from_rgb(255, 0, 0))), "every leader stroke is the annotation's colour");
assert!(
leaders.iter().all(|p| p.stroke.color == ColorMode::Solid(Color32::from_rgb(255, 0, 0))),
"every leader stroke is the annotation's colour"
);
let mut boxed = annotations;
boxed.truncate(1);
let selected = vec![AnnotationId(1)];
let mut overlay = ToolFixture::with_view(
"Document",
AnnotateTool::new(AnnotationTool::Select, 0),
view,
move |ui, cx| {
AnnotationOverlay::new("Annotations", &boxed, &selected).show_at(ui, cx.rect);
},
);
let mut overlay = ToolFixture::with_view("Document", AnnotateTool::new(AnnotationTool::Select, 0), view, move |ui, cx| {
AnnotationOverlay::new("Annotations", &boxed, &selected).show_at(ui, cx.rect);
});
let shapes = overlay.fixture().frame_shapes();
let discs = shapes.iter().filter(|shape| matches!(shape, Shape::Circle(c) if c.radius < 8.0)).count();
assert!(discs >= 8, "the eight resize handles are round: {discs}");
+9 -1
View File
@@ -16,7 +16,15 @@ fn thread(id: u64, text: &str) -> CommentThread {
anchor: CommentAnchor::Page { page: 0, at: [0.0, 0.0] },
kind: None,
color: None,
messages: vec![CommentMessage { author: "Ana".into(), created: 0, modified: None, text: text.into(), reactions: Vec::new(), read: true, deletable: true }],
messages: vec![CommentMessage {
author: "Ana".into(),
created: 0,
modified: None,
text: text.into(),
reactions: Vec::new(),
read: true,
deletable: true,
}],
statuses: Vec::new(),
reply_statuses: Vec::new(),
marked: false,
+4 -1
View File
@@ -553,7 +553,10 @@ fn a_selected_card_is_a_raised_surface_not_a_selection_fill() {
_ => None,
})
.collect();
assert!(fills.iter().all(|fill| fill.r() < 0x60 && i32::from(fill.b()) - i32::from(fill.r()) < 40), "the card fill is a quiet surface: {fills:?}");
assert!(
fills.iter().all(|fill| fill.r() < 0x60 && i32::from(fill.b()) - i32::from(fill.r()) < 40),
"the card fill is a quiet surface: {fills:?}"
);
}
/// The avatars of a card's messages are muted discs, not accent-coloured ones.
+5 -1
View File
@@ -84,7 +84,11 @@ impl Lengths<'_> {
let LengthRow { label, side, value, range, presets, disabled } = spec;
let points = value.map_or(Mixed::Mixed, |value| Mixed::Same(Some(f64::from(value))));
let field = Field::new(label.clone()).side(side).show(ui, |ui, _| {
let field = length_field(self.unit, label.clone(), points, range.clone()).presets(presets).scrub_by_label().mixed_word(true).sizing(Sizing::FillWidth);
let field = length_field(self.unit, label.clone(), points, range.clone())
.presets(presets)
.scrub_by_label()
.mixed_word(true)
.sizing(Sizing::FillWidth);
let out = disabled_for(field, &label, disabled.as_ref()).show(ui);
(out.edit.events, out.preset)
});
+2 -1
View File
@@ -217,7 +217,8 @@ impl<'a> FindBar<'a> {
*open = !*open;
}
let active = options.match_case || options.whole_word;
let button = IconButton::new(IconId::new("adjustments")).label(words.options.clone()).popup(PopupKind::Menu).selected(active).show(ui);
let button =
IconButton::new(IconId::new("adjustments")).label(words.options.clone()).popup(PopupKind::Menu).selected(active).show(ui);
let entries = [
Entry::new(BarOption::WholeWords, words.whole_words_only.clone()).checked(options.whole_word),
Entry::new(BarOption::MatchCase, words.case_sensitive.clone()).checked(options.match_case),
+6 -2
View File
@@ -5,8 +5,8 @@ use std::rc::Rc;
use craft_behavior::EditEvent;
use craft_text::ui::character::{CharacterChange, CharacterValues, FormatControl, FormatText, FormatTextChange, LineSpacing, ParagraphValues};
use craft_ui::contract::tooltip::DELAY;
use craft_ui::contract::ShowContainer as _;
use craft_ui::contract::tooltip::DELAY;
use craft_ui::runtime::env::Label;
use craft_ui::testing::pointer::moved;
use craft_ui::testing::{Fixture, trial};
@@ -100,7 +100,11 @@ fn the_size_field_keeps_room_for_its_value_in_a_narrow_panel() {
fixture.idle(10);
let size = fixture.by_label("Font size").expect("the size field is shown");
assert!(size.rect.width() >= 64.0, "the size field is {} wide: {:?}", size.rect.width(), size.rect);
assert!(fixture.texts().iter().any(|run| run.text == "Mixed"), "a mixed size reads Mixed: {:?}", fixture.texts().iter().map(|run| run.text.clone()).collect::<Vec<_>>());
assert!(
fixture.texts().iter().any(|run| run.text == "Mixed"),
"a mixed size reads Mixed: {:?}",
fixture.texts().iter().map(|run| run.text.clone()).collect::<Vec<_>>()
);
}
/// In the Tools pane's width (272 points less its padding, Comfortable density) the size field still reads its value:
+13 -3
View File
@@ -395,9 +395,18 @@ impl<'a> SplitViews<'a> {
pub fn new(label: impl Into<Label>, layout: SplitLayout, at: Bind<'a, SplitAt>) -> Self {
let props = ContainerProps::new().arena(true).sizing(Sizing::Fill).pad(Pad::None);
SplitViews {
common: Common::new(), props, layout, at, active: 0, pane_press: PanePress::default(), count: 0, activated: None, accepts: None,
common: Common::new(),
props,
layout,
at,
active: 0,
pane_press: PanePress::default(),
count: 0,
activated: None,
accepts: None,
tab_drop: None,
}.label(label)
}
.label(label)
}
/// Takes a dragged document strip tab over the views: an unsplit body offers its reading-end half, a split body
@@ -499,7 +508,8 @@ impl<D: Clone + Send + Sync + 'static> Component for SplitViews<'_, D> {
if pane == active {
cx.part(PANE.at(pane as u64), pane_rect).priority(HitPriority::new(HitLevel::Background, 0));
} else {
let part = cx.part(PANE.at(pane as u64), pane_rect)
let part = cx
.part(PANE.at(pane as u64), pane_rect)
.sense(Sense::CLICK | Sense::TAKE_FOCUS)
.priority(HitPriority::new(if self.pane_press == PanePress::Select { HitLevel::Body } else { HitLevel::Background }, 0));
if self.pane_press == PanePress::Select {
@@ -63,7 +63,17 @@ impl CommandSearch {
}
fn spec<'s>(&'s self, label: &'s str) -> FaceSpec<'s> {
FaceSpec { arrangement: Arrangement::Inline, label, role: Some(TypeRole::Body), lead: Some(&self.glyph), picture: None, trail: None, loading: false, mnemonic: None, align: HAlign::Start }
FaceSpec {
arrangement: Arrangement::Inline,
label,
role: Some(TypeRole::Body),
lead: Some(&self.glyph),
picture: None,
trail: None,
loading: false,
mnemonic: None,
align: HAlign::Start,
}
}
}
+1 -2
View File
@@ -3,8 +3,7 @@
use super::item::{RowInput, close_on_pick};
use super::level::{MenuLevel, Row};
use crate::contract::{
Access, Common, Component, Cx, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Pointer as _, Props as _, Role, SetPosition,
Styled as _,
Access, Common, Component, Cx, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Pointer as _, Props as _, Role, SetPosition, Styled as _,
};
use crate::primitives::IconSpec;
use crate::runtime::env::Label;
+1 -3
View File
@@ -27,9 +27,7 @@ impl BrowserFiles {
/// waiting to be taken stay under `max_read` bytes.
pub fn new(wake: Wake, max_read: u64) -> Self {
let limits = PickLimits { pending_bytes: usize::try_from(max_read).unwrap_or(usize::MAX), ..PickLimits::DEFAULT };
let inner = PlatformFiles::new(move || wake.wake())
.limits(limits)
.page_saves(page_save);
let inner = PlatformFiles::new(move || wake.wake()).limits(limits).page_saves(page_save);
Self { inner }
}
}