diff --git a/crates/draw/src/ui/gradient/palette/mod.rs b/crates/draw/src/ui/gradient/palette/mod.rs index 82b60fba8..0fde15cef 100644 --- a/crates/draw/src/ui/gradient/palette/mod.rs +++ b/crates/draw/src/ui/gradient/palette/mod.rs @@ -233,11 +233,8 @@ impl<'a> GradientPalette<'a> { }; let most = Env::of(ui).tokens.size.control.sm * MAX_ROWS; let shape = if square { CellShape::Square } else { CellShape::ratio(wide, high) }; - let mut browser = PresetBrowser::new(self.label, self.state, &rows) - .cell_shape(shape) - .tiles(PresetTiles::Chips) - .room_height(most) - .thumb(thumb); + let mut browser = + PresetBrowser::new(self.label, self.state, &rows).cell_shape(shape).tiles(PresetTiles::Chips).room_height(most).thumb(thumb); if let Some(selected) = self.selected { browser = browser.selected(selected); } diff --git a/crates/draw/src/ui/gradient/swatch/stories.rs b/crates/draw/src/ui/gradient/swatch/stories.rs index b8f410d86..3fd6d2d31 100644 --- a/crates/draw/src/ui/gradient/swatch/stories.rs +++ b/crates/draw/src/ui/gradient/swatch/stories.rs @@ -65,10 +65,8 @@ fn gradient_swatch(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { fn gradient_swatch_tiles(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { let stops = GradientStops::new(vec![stop(0.0, [0.96, 0.65, 0.14]), stop(1.0, [0.24, 0.39, 0.87])]); let focus = egui::Rect::from_min_max(egui::pos2(0.25, 0.25), egui::pos2(0.5, 0.5)); - let mut tiles: Vec<(String, GradientTile)> = GradientStyle::ALL - .into_iter() - .map(|style| (format!("{style:?}"), GradientTile::Style { style, angle: -45.0 })) - .collect(); + let mut tiles: Vec<(String, GradientTile)> = + GradientStyle::ALL.into_iter().map(|style| (format!("{style:?}"), GradientTile::Style { style, angle: -45.0 })).collect(); tiles.push(("Focus, circle".to_owned(), GradientTile::Focus { outline: FocusOutline::Circle, focus })); tiles.push(("Focus, rectangle".to_owned(), GradientTile::Focus { outline: FocusOutline::Rect, focus })); Stack::new().show(ui, |ui, _| { diff --git a/crates/draw/src/ui/mod.rs b/crates/draw/src/ui/mod.rs index 65dcc21bb..f81c4c9d9 100644 --- a/crates/draw/src/ui/mod.rs +++ b/crates/draw/src/ui/mod.rs @@ -77,11 +77,11 @@ pub use crop::{ CropPresetList, CropPresetListOutput, CropSizeTarget, PerspectiveCropBar, PerspectiveCropBarOutput, PerspectiveCropPass, PerspectiveInput, }; pub use crop::{PerspectiveCropQuad, PerspectiveQuad}; -pub use gradient::{GradientFill, GradientFillEditor, GradientFillEditorOutput, GradientFillWords, GradientStyle}; pub use gradient::{ FocusOutline, GradientGroup, GradientItem, GradientLine, GradientMap, GradientMapEditor, GradientMapOutput, GradientOverlay, GradientPalette, GradientRef, GradientSwatch, GradientTile, LineGradient, LinePart, }; +pub use gradient::{GradientFill, GradientFillEditor, GradientFillEditorOutput, GradientFillWords, GradientStyle}; pub use measure::{ MIN_LINE, RulerBar, RulerBarOutput, RulerLine, RulerOverlay, RulerPass, RulerTool, RulerWords, box_distances, ruler_line_form, show_ruler, }; diff --git a/crates/draw/src/ui/transform/transform_box.rs b/crates/draw/src/ui/transform/transform_box.rs index 7ba508dab..027ac9207 100644 --- a/crates/draw/src/ui/transform/transform_box.rs +++ b/crates/draw/src/ui/transform/transform_box.rs @@ -246,10 +246,7 @@ impl LineLook { /// (on a level or upright line, the side). A line of no length, or one with free ends, has none. fn end_parts(&self) -> impl Iterator { let boxed = self.ends == LineEnds::Box; - [(self.from, self.to), (self.to, self.from)] - .into_iter() - .filter(move |_| boxed) - .filter_map(|(end, other)| Some((end_part(end, other)?, end))) + [(self.from, self.to), (self.to, self.from)].into_iter().filter(move |_| boxed).filter_map(|(end, other)| Some((end_part(end, other)?, end))) } /// Each free end with its point, in [`LineEnds::Free`]; none when the ends are box handles. diff --git a/crates/draw/src/ui/transform/transform_box/stories.rs b/crates/draw/src/ui/transform/transform_box/stories.rs index 6ccdedd56..2a6796b77 100644 --- a/crates/draw/src/ui/transform/transform_box/stories.rs +++ b/crates/draw/src/ui/transform/transform_box/stories.rs @@ -32,11 +32,7 @@ fn on_canvas(ui: &mut Ui, data: &mut StoryData, make: impl for<'a> Fn(Bind<'a, B } /// [`on_canvas`] with the box's whole output. -fn shown_on_canvas( - ui: &mut Ui, - data: &mut StoryData, - make: impl for<'a> Fn(Bind<'a, BoxState>) -> TransformBox<'a>, -) -> Option { +fn shown_on_canvas(ui: &mut Ui, data: &mut StoryData, make: impl for<'a> Fn(Bind<'a, BoxState>) -> TransformBox<'a>) -> Option { let state = data.value("box", BoxState::from_rect(PICTURE)); let room = craft_ui::testing::stage(ui); let view = craft_ui::testing::canvas_story::story_view(room, ui.pixels_per_point(), PICTURE.center(), 100.0); diff --git a/crates/draw/tests/it/gradient_fill.rs b/crates/draw/tests/it/gradient_fill.rs index 9e415be9c..2c0db1cca 100644 --- a/crates/draw/tests/it/gradient_fill.rs +++ b/crates/draw/tests/it/gradient_fill.rs @@ -5,7 +5,9 @@ use std::rc::Rc; use craft_behavior::EditEvent; use craft_color_ui::ui::gradient::{ColorStop, GradientStops}; -use craft_draw::ui::gradient::{FocusOutline, GradientFill, GradientFillEditor, GradientGroup, GradientItem, GradientRef, GradientStyle, GradientTile}; +use craft_draw::ui::gradient::{ + FocusOutline, GradientFill, GradientFillEditor, GradientGroup, GradientItem, GradientRef, GradientStyle, GradientTile, +}; use craft_theme::Srgba; use craft_ui::contract::{Bind, Role}; use craft_ui::patterns::presets::PresetState; diff --git a/crates/ui-contract/src/contract/editor.rs b/crates/ui-contract/src/contract/editor.rs index 3c3442385..c8a7774f2 100644 --- a/crates/ui-contract/src/contract/editor.rs +++ b/crates/ui-contract/src/contract/editor.rs @@ -98,7 +98,6 @@ pub struct EditorHandle { read_only: bool, } - impl EditorHandle { /// The handle of the editor part step 8b set up. fn of(info: &EditorInfo) -> EditorHandle { diff --git a/crates/ui-contract/src/contract/mod.rs b/crates/ui-contract/src/contract/mod.rs index dbea6fe56..09dc8bd12 100644 --- a/crates/ui-contract/src/contract/mod.rs +++ b/crates/ui-contract/src/contract/mod.rs @@ -80,8 +80,8 @@ pub use hosted::{Hosted, HostedKey, Hosting}; pub use items::lead_position; #[doc(hidden)] pub use items::put_toggle_names; -pub use items::{measure_item, show_item, show_item_in_flow}; pub use items::{ColumnCommands, SweepApply, SweepStep, item_part_open, request_rename, section_part}; +pub use items::{measure_item, show_item, show_item_in_flow}; #[doc(hidden)] pub use label::colon_of; pub use label::{CellWidth, FieldLabelRole, FieldLayout, GlyphLabel, InsideLabel, LabelKind, LabelScheme, Scrub, SideLabel}; diff --git a/crates/ui-contract/src/contract/text.rs b/crates/ui-contract/src/contract/text.rs index 1236b4d8d..30cecdabf 100644 --- a/crates/ui-contract/src/contract/text.rs +++ b/crates/ui-contract/src/contract/text.rs @@ -430,8 +430,8 @@ pub(crate) fn run( // The bound caret is compared with the widget's before anything else this pass moves it (AccessKit, Select All, // the typing): last pass reported the widget's caret, so only an app write differs here. A composition keeps its // caret. - let caret_placed = state.preedit.is_none() - && adapter::place_caret(&ctx, widget, state.draft.as_deref().unwrap_or(&decl.shown), decl.options.caret); + let caret_placed = + state.preedit.is_none() && adapter::place_caret(&ctx, widget, state.draft.as_deref().unwrap_or(&decl.shown), decl.options.caret); serve_access(cx, &mut state, widget, &decl.shown, read_only); if std::mem::take(&mut state.select_all) { let len = state.draft.as_deref().unwrap_or(&decl.shown).chars().count(); diff --git a/crates/ui-contract/src/runtime/commands/mod.rs b/crates/ui-contract/src/runtime/commands/mod.rs index b6c261985..a43f6fa8e 100644 --- a/crates/ui-contract/src/runtime/commands/mod.rs +++ b/crates/ui-contract/src/runtime/commands/mod.rs @@ -20,11 +20,11 @@ pub use board::declare_child; #[doc(hidden)] pub use board::focus_within; pub use board::keymap; -#[doc(hidden)] -pub use board::note_page_root; #[cfg(feature = "testing")] #[doc(hidden)] pub use board::keymap_builds; +#[doc(hidden)] +pub use board::note_page_root; pub(crate) use board::publish as publish_for; pub(crate) use board::take as take_for_instance; pub(crate) use board::{ diff --git a/crates/ui-gallery/src/foundations/stories.rs b/crates/ui-gallery/src/foundations/stories.rs index ec5f35ca5..b3007e0ec 100644 --- a/crates/ui-gallery/src/foundations/stories.rs +++ b/crates/ui-gallery/src/foundations/stories.rs @@ -14,7 +14,6 @@ fn semantic(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { StoryOutput::default() } - // Each surface kind in the story's own theme, with the ink that reads on it. #[story(Surfaces<'static>, covers = [], drive = Drive::Never, title = "Surface kinds")] fn surface_kinds(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { diff --git a/crates/ui-patterns/src/patterns/dock/panes/stories.rs b/crates/ui-patterns/src/patterns/dock/panes/stories.rs index 060d6221e..a4791b1f6 100644 --- a/crates/ui-patterns/src/patterns/dock/panes/stories.rs +++ b/crates/ui-patterns/src/patterns/dock/panes/stories.rs @@ -57,8 +57,7 @@ impl PaneContent for Panes { /// The two panes around a document, each docking only at `edges`. fn area(ui: &mut Ui, edges: PaneEdges) -> StoryOutput { let size = &Env::of(ui).tokens.size; - let mut content = - Panes { float: Vec2::new(size.float.width, size.float.height), side: size.length.field.md, layers: layer_names(), edges }; + let mut content = Panes { float: Vec2::new(size.float.width, size.float.height), side: size.length.field.md, layers: layer_names(), edges }; let open = [0_u32, 1]; PaneArea::new("Panes", &open, &mut content) .show(ui, |ui, _| { diff --git a/crates/ui-patterns/src/patterns/panels/palette/stories.rs b/crates/ui-patterns/src/patterns/panels/palette/stories.rs index a2e69ba88..138d35ca5 100644 --- a/crates/ui-patterns/src/patterns/panels/palette/stories.rs +++ b/crates/ui-patterns/src/patterns/panels/palette/stories.rs @@ -67,7 +67,8 @@ fn configured( ) -> StoryOutput { // The palette binds two story values; it edits a copy of `open`, which goes back after the pass. let mut open = *data.value("open", open_at_start); - let palette = CommandPalette::new("Command palette", ENTRIES.as_slice(), Bind::bound(&mut open)).recents(Bind::bound(data.value("recents", recents))); + let palette = + CommandPalette::new("Command palette", ENTRIES.as_slice(), Bind::bound(&mut open)).recents(Bind::bound(data.value("recents", recents))); let out = configure(palette).show(ui); *data.value("open", open_at_start) = open; let last = data.value("last", None::); diff --git a/crates/ui-patterns/src/patterns/preferences/page.rs b/crates/ui-patterns/src/patterns/preferences/page.rs index 02540b4e7..17583e54e 100644 --- a/crates/ui-patterns/src/patterns/preferences/page.rs +++ b/crates/ui-patterns/src/patterns/preferences/page.rs @@ -9,8 +9,8 @@ use super::search::{self, Listed}; use super::window::PreferencesState; use super::words::PreferencesWords; use crate::contract::{ - ActivateOn, Bind, CollectionEvent, NoValue, Outcome, Pattern, Props, Scroll, SelectMode, Show as _, ShowCollection as _, - ShowContainer as _, Sizing, + ActivateOn, Bind, CollectionEvent, NoValue, Outcome, Pattern, Props, Scroll, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, + Sizing, }; use crate::display::{Divider, Shade, Text}; use crate::form::FieldGroup; diff --git a/crates/ui-patterns/tests/it/form_dialogs/about.rs b/crates/ui-patterns/tests/it/form_dialogs/about.rs index 982dab1f8..8d9f25dcf 100644 --- a/crates/ui-patterns/tests/it/form_dialogs/about.rs +++ b/crates/ui-patterns/tests/it/form_dialogs/about.rs @@ -85,8 +85,7 @@ fn an_app_tab_shows_after_models_and_is_a_tab_field_value() { fixture.idle(10); assert_eq!(drawn.load(Ordering::Relaxed), 0, "the dialog opens on About"); - let tabs: Vec = - fixture.by_role(Role::TAB).iter().filter_map(|tab| access::name(fixture.tree(), tab.node).map(str::to_owned)).collect(); + let tabs: Vec = fixture.by_role(Role::TAB).iter().filter_map(|tab| access::name(fixture.tree(), tab.node).map(str::to_owned)).collect(); let models = tabs.iter().position(|name| name == "Models").expect("the strip lists Models"); assert_eq!(tabs.get(models + 1).map(String::as_str), Some("Languages"), "the app tab follows Models: {tabs:?}"); diff --git a/crates/ui-patterns/tests/it/preferences/page.rs b/crates/ui-patterns/tests/it/preferences/page.rs index aa205252b..812d1581f 100644 --- a/crates/ui-patterns/tests/it/preferences/page.rs +++ b/crates/ui-patterns/tests/it/preferences/page.rs @@ -1,9 +1,7 @@ //! `PreferencesPage` over a model with no draft: each edit reaches the model in the pass it lands in. use craft_ui::contract::{Bind, Role}; -use craft_ui::patterns::preferences::{ - PageSpec, PrefValue, PreferencesModel, PreferencesPage, PreferencesState, PreferencesWords, RowKind, RowSpec, -}; +use craft_ui::patterns::preferences::{PageSpec, PrefValue, PreferencesModel, PreferencesPage, PreferencesState, PreferencesWords, RowKind, RowSpec}; use craft_ui::runtime::env::Env; use craft_ui::runtime::words::CommonWords; use craft_ui::testing::pointer::{moved, press, release}; diff --git a/crates/ui-shell/src/shell/app_shell.rs b/crates/ui-shell/src/shell/app_shell.rs index e9d05bbd4..367257dcf 100644 --- a/crates/ui-shell/src/shell/app_shell.rs +++ b/crates/ui-shell/src/shell/app_shell.rs @@ -708,11 +708,8 @@ impl<'a, S> AppShell<'a, S> { edges.extend(scope.revealed_rects()); kept.reveal.record(edges); // The screen bar and the drop-down slot show by the mode, never by a reveal. - let revealed = only - && slots - .iter() - .zip(&visible) - .any(|(placed, shown)| *shown && !placed.slot.is_screen_bar() && !placed.slot.drops_down()); + let revealed = + only && slots.iter().zip(&visible).any(|(placed, shown)| *shown && !placed.slot.is_screen_bar() && !placed.slot.drops_down()); *cx.keep::() = kept; Parts { regions, revealed, panels_hidden, mode, dropped: dropped_shown } }; diff --git a/crates/ui-shell/src/shell/recent_list.rs b/crates/ui-shell/src/shell/recent_list.rs index 47e9b054a..99ad9a332 100644 --- a/crates/ui-shell/src/shell/recent_list.rs +++ b/crates/ui-shell/src/shell/recent_list.rs @@ -8,7 +8,8 @@ use super::start::{ use super::words::ShellWords; use crate::buttons::Button; use crate::contract::{ - ActivateOn, BodyCx, CollectionEvent, Gap, Props as _, Remember as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing, clicked, + ActivateOn, BodyCx, CollectionEvent, Gap, Props as _, Remember as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing, + clicked, }; use crate::list::{List, ListRow, RowEvent, ThumbAspect, ThumbSize, TrailingFace}; use crate::menu::{Menu, MenuItem}; diff --git a/crates/ui-shell/src/shell/start.rs b/crates/ui-shell/src/shell/start.rs index ca7de7192..60dbe09be 100644 --- a/crates/ui-shell/src/shell/start.rs +++ b/crates/ui-shell/src/shell/start.rs @@ -329,13 +329,7 @@ impl<'p> Page<'p> { /// The thumbnail of `key` in `rect`, asked for at the size it paints. The store paints the placeholder while the /// picture is not ready and the failure mark when it failed; a key the source has no picture for (`Blank`) gets the /// file icon on the sunken tile. -pub(super) fn paint_thumb( - cx: &ContentPainterCx, - rect: Rect, - thumbnails: &Thumbnails, - source: &dyn ThumbSource, - key: &ThumbKey, -) { +pub(super) fn paint_thumb(cx: &ContentPainterCx, rect: Rect, thumbnails: &Thumbnails, source: &dyn ThumbSource, key: &ThumbKey) { let request = ThumbRequest::for_cell(rect.width().max(rect.height()), cx.pixels_per_point()); let state = thumbnails.state(cx.painter.ctx(), source, key, &request, Priority::VISIBLE); if thumbnails.paint(cx, rect, &state, &ThumbPaint::default()) { diff --git a/crates/ui-shell/tests/it/shell/app_shell.rs b/crates/ui-shell/tests/it/shell/app_shell.rs index 3dea8ef63..75ea0449d 100644 --- a/crates/ui-shell/tests/it/shell/app_shell.rs +++ b/crates/ui-shell/tests/it/shell/app_shell.rs @@ -215,11 +215,7 @@ fn caption_widths(windows: &Windows, runs: &mut PageRuns, names: &[&str]) -> Vec names .iter() .map(|name| { - buttons - .iter() - .find(|key| tree.name_of(**key) == Some(*name)) - .and_then(|key| tree.bounds_of(*key)) - .map_or(0.0, |rect| rect.width()) + buttons.iter().find(|key| tree.name_of(**key) == Some(*name)).and_then(|key| tree.bounds_of(*key)).map_or(0.0, |rect| rect.width()) }) .collect() } @@ -265,8 +261,7 @@ fn a_page_hides_the_slots_and_its_band_keeps_the_window_ends_and_moves_the_windo let bands = regions.moves.iter().filter(|area| band.rect.contains_rect(**area)).count(); let to = free + egui::vec2(40.0, 0.0); let mut sent = Vec::new(); - for events in [vec![craft_ui::testing::pointer::moved(free)], vec![press(free)], vec![craft_ui::testing::pointer::moved(to)], vec![release(to)]] - { + for events in [vec![craft_ui::testing::pointer::moved(free)], vec![press(free)], vec![craft_ui::testing::pointer::moved(to)], vec![release(to)]] { sent.extend(page_frame(&windows, &mut runs, false, events)); } assert!(sent.contains(&egui::ViewportCommand::StartDrag), "a drag of the free band moves the window: {sent:?}"); diff --git a/crates/ui-shell/tests/it/shell/start.rs b/crates/ui-shell/tests/it/shell/start.rs index aeba07598..a14136e3d 100644 --- a/crates/ui-shell/tests/it/shell/start.rs +++ b/crates/ui-shell/tests/it/shell/start.rs @@ -129,7 +129,10 @@ fn a_recent_row_names_its_full_path_and_reveals_remove_on_hover_or_focus() { fixture.idle(2); let revealed = fixture.by_role(Role::BUTTON); assert!(revealed.len() > buttons_focused - 1, "hovering a row keeps its remove part shown"); - let remove = revealed.into_iter().find(|button| row.rect.contains(button.center()) && button.center().x > row.center().x).expect("hovering the row reveals its remove part"); + let remove = revealed + .into_iter() + .find(|button| row.rect.contains(button.center()) && button.center().x > row.center().x) + .expect("hovering the row reveals its remove part"); fixture.click(&remove).idle(2); assert!(log.borrow().contains(&StartAction::RemoveRecent(poster)), "the remove part removes that row's file: {:?}", log.borrow()); diff --git a/crates/ui-shell/tests/it/shell/title_bar.rs b/crates/ui-shell/tests/it/shell/title_bar.rs index 892ce2656..a202200ab 100644 --- a/crates/ui-shell/tests/it/shell/title_bar.rs +++ b/crates/ui-shell/tests/it/shell/title_bar.rs @@ -150,8 +150,7 @@ fn titled(title: &'static str) -> (Fixture, Rc>) { let out = Rc::clone(&seen); let mut fixture = Fixture::new(move |ui| { // The title shows whatever frame the trial's host decides. - let shown = - TitleBar::new().title_when_native().show_titled(ui, Title::new(title).action("Rename the document"), |_, _| {}, |_, _| {}); + let shown = TitleBar::new().title_when_native().show_titled(ui, Title::new(title).action("Rename the document"), |_, _| {}, |_, _| {}); let mut now = out.get(); now.bar = shown.response.rect; now.activations += usize::from(shown.title_activated); diff --git a/crates/ui-widgets/src/display/text.rs b/crates/ui-widgets/src/display/text.rs index 6552a63a9..49c41cf09 100644 --- a/crates/ui-widgets/src/display/text.rs +++ b/crates/ui-widgets/src/display/text.rs @@ -87,8 +87,17 @@ pub struct Text { impl Text { /// `text`, which is also its accessible name, in body type and the normal shade. pub fn new(text: impl Into