From f8dddb2a55ffac76325d58f1834dd4512dba0b7c Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 09:23:28 +0100 Subject: [PATCH 01/22] Split UI test kit from story suite --- crates/automation/Cargo.toml | 3 +- crates/automation/src/lib.rs | 1 + crates/automation/src/ui/actions/mod.rs | 2 +- crates/automation/src/ui/agents/mod.rs | 2 +- crates/browse/Cargo.toml | 3 +- crates/browse/src/ui/bin/mod.rs | 2 +- crates/browse/src/ui/compare/mod.rs | 2 +- crates/browse/src/ui/freebin/mod.rs | 2 +- crates/browse/src/ui/mod.rs | 1 + crates/browse/src/ui/places/mod.rs | 2 +- crates/browse/src/ui/relink/mod.rs | 2 +- crates/color-ui/Cargo.toml | 3 +- crates/color-ui/src/ui/area.rs | 2 +- crates/color-ui/src/ui/choice.rs | 2 +- crates/color-ui/src/ui/compare.rs | 2 +- crates/color-ui/src/ui/disc.rs | 2 +- crates/color-ui/src/ui/droppers.rs | 2 +- crates/color-ui/src/ui/eyedropper.rs | 2 +- crates/color-ui/src/ui/gradient/editor.rs | 2 +- crates/color-ui/src/ui/harmony.rs | 2 +- crates/color-ui/src/ui/hud.rs | 2 +- crates/color-ui/src/ui/info.rs | 2 +- crates/color-ui/src/ui/lut_picker.rs | 2 +- crates/color-ui/src/ui/paint_chip.rs | 2 +- crates/color-ui/src/ui/pair.rs | 2 +- crates/color-ui/src/ui/palette.rs | 2 +- crates/color-ui/src/ui/panel.rs | 2 +- crates/color-ui/src/ui/picker/mod.rs | 2 +- crates/color-ui/src/ui/popover.rs | 2 +- crates/color-ui/src/ui/profile_prompts.rs | 2 +- crates/color-ui/src/ui/ramp.rs | 2 +- crates/color-ui/src/ui/readout.rs | 2 +- crates/color-ui/src/ui/samplers.rs | 2 +- crates/color-ui/src/ui/screen_picker.rs | 2 +- crates/color-ui/src/ui/strip.rs | 2 +- crates/color-ui/src/ui/swatches.rs | 2 +- crates/color-ui/src/ui/testing.rs | 1 + crates/color-ui/src/ui/warning.rs | 2 +- crates/color-ui/src/ui/wheel.rs | 2 +- crates/craft/Cargo.toml | 1 + crates/dialogs/Cargo.toml | 3 +- crates/dialogs/src/lib.rs | 1 + crates/dialogs/src/ui/mod.rs | 2 +- crates/draw/Cargo.toml | 3 +- crates/draw/src/lib.rs | 1 + crates/draw/src/ui/add_beside/mod.rs | 2 +- crates/draw/src/ui/artboard/mod.rs | 2 +- crates/draw/src/ui/brush_presets/mod.rs | 2 +- crates/draw/src/ui/brush_settings/mod.rs | 2 +- crates/draw/src/ui/connector/mod.rs | 2 +- crates/draw/src/ui/corner/mod.rs | 2 +- crates/draw/src/ui/crop/bar.rs | 2 +- crates/draw/src/ui/crop/perspective_bar.rs | 2 +- crates/draw/src/ui/crop/perspective_crop.rs | 2 +- crates/draw/src/ui/crop/tool.rs | 2 +- crates/draw/src/ui/gradient/fill_editor.rs | 2 +- .../src/ui/gradient/gradient_overlay/mod.rs | 2 +- crates/draw/src/ui/gradient/map/mod.rs | 2 +- crates/draw/src/ui/gradient/palette/mod.rs | 2 +- crates/draw/src/ui/gradient/swatch.rs | 2 +- crates/draw/src/ui/measure/mod.rs | 2 +- crates/draw/src/ui/paint_bar.rs | 2 +- crates/draw/src/ui/paths/mod.rs | 2 +- crates/draw/src/ui/pattern/mod.rs | 2 +- crates/draw/src/ui/pen/bezier/mod.rs | 2 +- crates/draw/src/ui/pen/mod.rs | 2 +- crates/draw/src/ui/picture_fill/mod.rs | 2 +- crates/draw/src/ui/shape/mod.rs | 2 +- crates/draw/src/ui/shape_presets.rs | 2 +- crates/draw/src/ui/slice/mod.rs | 2 +- crates/draw/src/ui/stroke/mod.rs | 2 +- crates/draw/src/ui/symmetry/mod.rs | 2 +- crates/draw/src/ui/transform/session_bar.rs | 2 +- .../draw/src/ui/transform/session_overlay.rs | 2 +- crates/draw/src/ui/transform/transform_box.rs | 2 +- .../draw/src/ui/transform/transform_fields.rs | 2 +- crates/feature-root/Cargo.toml | 34 ++++++++-------- crates/font-manager/Cargo.toml | 5 ++- crates/font-manager/src/axes/sliders.rs | 2 +- crates/font-manager/src/glyphs.rs | 2 +- crates/font-manager/src/lib.rs | 1 + crates/font-manager/src/missing.rs | 2 +- crates/font-manager/src/panel/app.rs | 2 +- crates/font-manager/src/panel/browse.rs | 2 +- crates/font-manager/src/panel/details.rs | 2 +- crates/font-manager/src/panel/sources.rs | 2 +- crates/font-manager/src/panel/specimen.rs | 2 +- crates/font-manager/src/picker.rs | 2 +- crates/imaging/Cargo.toml | 3 +- crates/imaging/src/lib.rs | 1 + crates/imaging/src/ui/adjust/basic.rs | 2 +- crates/imaging/src/ui/adjust/curves_panel.rs | 2 +- .../imaging/src/ui/adjust/hue_saturation.rs | 2 +- crates/imaging/src/ui/adjust/levels_editor.rs | 2 +- crates/imaging/src/ui/adjust/levels_panel.rs | 2 +- crates/imaging/src/ui/adjust/mixers.rs | 2 +- crates/imaging/src/ui/adjust/panel.rs | 2 +- crates/imaging/src/ui/adjust/session.rs | 2 +- crates/imaging/src/ui/adjust/sliders.rs | 2 +- crates/imaging/src/ui/adjust/tone.rs | 2 +- crates/imaging/src/ui/blur_pins/mod.rs | 2 +- crates/imaging/src/ui/channels/mod.rs | 2 +- crates/imaging/src/ui/color_range/mod.rs | 2 +- crates/imaging/src/ui/curve/mod.rs | 2 +- crates/imaging/src/ui/fill/mod.rs | 2 +- crates/imaging/src/ui/filter_gallery/mod.rs | 2 +- crates/imaging/src/ui/histogram/mod.rs | 2 +- .../src/ui/layer_style/blend_if/mod.rs | 2 +- .../imaging/src/ui/layer_style/contour/mod.rs | 2 +- crates/imaging/src/ui/layer_style/mod.rs | 2 +- crates/imaging/src/ui/liquify/mod.rs | 2 +- crates/imaging/src/ui/mask_view/mod.rs | 2 +- crates/imaging/src/ui/raw_develop/mod.rs | 2 +- crates/imaging/src/ui/scopes/mod.rs | 2 +- crates/imaging/src/ui/select/mod.rs | 2 +- crates/imaging/src/ui/select_mask/mod.rs | 2 +- crates/imaging/src/ui/selection/mod.rs | 2 +- .../imaging/src/ui/transform_preview/mod.rs | 2 +- crates/imaging/src/ui/vanishing_point/mod.rs | 2 +- crates/imaging/src/ui/warp/cylinder.rs | 2 +- crates/imaging/src/ui/warp/mod.rs | 2 +- crates/imaging/src/ui/warp/perspective/mod.rs | 2 +- crates/imaging/src/ui/warp/pin/mod.rs | 2 +- crates/imaging/src/ui/wide_angle/mod.rs | 2 +- crates/layers/Cargo.toml | 5 ++- crates/layers/src/lib.rs | 2 + crates/layers/src/ui/comps/mod.rs | 2 +- crates/layers/src/ui/filter/mod.rs | 2 +- crates/layers/src/ui/options/mod.rs | 2 +- crates/layers/src/ui/panel/mod.rs | 2 +- crates/layers/src/ui/rows/mod.rs | 2 +- crates/menu/Cargo.toml | 3 +- crates/menu/src/bar.rs | 2 +- crates/menu/src/lib.rs | 1 + crates/menu/src/shortcuts/mod.rs | 2 +- crates/menu/src/shortcuts/recorder.rs | 2 +- crates/menu/src/shortcuts/view.rs | 2 +- crates/pages/Cargo.toml | 3 +- crates/pages/src/lib.rs | 1 + crates/pages/src/ui/column_bar.rs | 2 +- crates/pages/src/ui/grid.rs | 2 +- crates/pages/src/ui/header_footer.rs | 2 +- crates/pages/src/ui/list.rs | 2 +- crates/pages/src/ui/margins.rs | 2 +- crates/pages/src/ui/marks.rs | 2 +- crates/pages/src/ui/preview.rs | 2 +- crates/pages/src/ui/range.rs | 2 +- crates/pages/src/ui/reading.rs | 2 +- crates/pages/src/ui/setup.rs | 2 +- crates/pages/src/ui/table/mod.rs | 2 +- crates/pages/src/ui/text_selection.rs | 2 +- crates/pages/src/ui/thumbnails.rs | 2 +- crates/pages/src/ui/view.rs | 2 +- crates/print/Cargo.toml | 3 +- crates/print/src/lib.rs | 1 + crates/print/src/ui/mod.rs | 2 +- crates/review/Cargo.toml | 3 +- crates/review/src/lib.rs | 1 + crates/review/src/ui/annotate.rs | 2 +- crates/review/src/ui/avatar.rs | 2 +- crates/review/src/ui/chat.rs | 2 +- crates/review/src/ui/comments.rs | 2 +- crates/review/src/ui/join.rs | 2 +- crates/review/src/ui/presence.rs | 2 +- crates/review/src/ui/revisions.rs | 2 +- crates/review/src/ui/signature.rs | 2 +- crates/review/src/ui/thread.rs | 2 +- crates/review/src/ui/versions.rs | 2 +- crates/review/src/ui/vote.rs | 2 +- crates/table/Cargo.toml | 5 ++- crates/table/src/ui/chart.rs | 2 +- crates/table/src/ui/conditions.rs | 2 +- crates/table/src/ui/error_tag.rs | 2 +- crates/table/src/ui/fields.rs | 2 +- crates/table/src/ui/filter.rs | 2 +- crates/table/src/ui/grid.rs | 2 +- crates/table/src/ui/mod.rs | 1 + crates/table/src/ui/outline.rs | 2 +- crates/table/src/ui/slicer.rs | 2 +- crates/table/src/ui/stats.rs | 2 +- crates/text/Cargo.toml | 3 +- crates/text/src/lib.rs | 1 + crates/text/src/ui/character.rs | 2 +- crates/text/src/ui/character/style_options.rs | 2 +- crates/text/src/ui/columns.rs | 2 +- crates/text/src/ui/editor.rs | 2 +- crates/text/src/ui/find.rs | 2 +- crates/text/src/ui/hyperlink.rs | 2 +- crates/text/src/ui/notes.rs | 2 +- crates/text/src/ui/path_text.rs | 2 +- crates/text/src/ui/ruler.rs | 2 +- crates/text/src/ui/spelling.rs | 2 +- crates/text/src/ui/style_panel.rs | 2 +- crates/text/src/ui/tabs_dialog.rs | 2 +- crates/text/src/ui/type_bar.rs | 2 +- crates/theme-editor/Cargo.toml | 3 +- crates/theme-editor/src/lib.rs | 3 +- crates/theme-store/Cargo.toml | 3 +- crates/theme-store/src/ui/mod.rs | 3 +- crates/timeline/Cargo.toml | 3 +- crates/timeline/src/lib.rs | 1 + crates/timeline/src/ui/graph.rs | 2 +- crates/timeline/src/ui/keyframes.rs | 2 +- crates/timeline/src/ui/markers.rs | 2 +- crates/timeline/src/ui/overview.rs | 2 +- crates/timeline/src/ui/panel.rs | 2 +- crates/timeline/src/ui/preview.rs | 2 +- crates/timeline/src/ui/render_queue.rs | 2 +- crates/timeline/src/ui/ruler.rs | 2 +- crates/timeline/src/ui/stack.rs | 2 +- crates/timeline/src/ui/timecode.rs | 2 +- crates/timeline/src/ui/transport.rs | 2 +- crates/timeline/src/ui/view.rs | 2 +- crates/ui-canvas/Cargo.toml | 3 +- crates/ui-canvas/src/canvas/crop/mod.rs | 2 +- crates/ui-canvas/src/canvas/full_window.rs | 4 +- .../ui-canvas/src/canvas/full_window_parts.rs | 2 +- crates/ui-canvas/src/canvas/mod.rs | 2 +- crates/ui-canvas/src/canvas/navigate/mod.rs | 2 +- crates/ui-canvas/src/canvas/navigator/mod.rs | 2 +- .../ui-canvas/src/canvas/navigator_panel.rs | 2 +- crates/ui-canvas/src/canvas/pasteboard/mod.rs | 2 +- crates/ui-canvas/src/canvas/raster/mod.rs | 2 +- crates/ui-canvas/src/canvas/rulers/mod.rs | 2 +- crates/ui-canvas/src/canvas/scrollbars/mod.rs | 2 +- crates/ui-canvas/src/canvas/split/mod.rs | 2 +- .../src/canvas_controls/brush/mod.rs | 2 +- .../ui-canvas/src/canvas_controls/grid/mod.rs | 2 +- .../src/canvas_controls/guides/mod.rs | 2 +- .../src/canvas_controls/marquee/mod.rs | 2 +- .../src/canvas_controls/outline/mod.rs | 2 +- .../src/canvas_controls/pixel_grid/mod.rs | 2 +- .../src/canvas_controls/smart_guides/mod.rs | 2 +- .../ui-canvas/src/canvas_controls/task_bar.rs | 2 +- crates/ui-canvas/src/lib.rs | 3 +- crates/ui-contract/Cargo.toml | 10 ++--- crates/ui-contract/src/contract/body.rs | 2 +- crates/ui-contract/src/contract/mod.rs | 10 ++--- crates/ui-contract/src/contract/registry.rs | 18 ++++----- crates/ui-contract/src/runtime/egui/access.rs | 2 +- crates/ui-contract/src/runtime/egui/areas.rs | 6 +-- .../ui-contract/src/runtime/egui/fixture.rs | 9 +++++ .../ui-contract/src/runtime/egui/widgets.rs | 10 +++-- crates/ui-contract/src/runtime/keys.rs | 2 +- .../ui-contract/src/runtime/keys/intents.rs | 2 +- crates/ui-contract/src/runtime/overlay.rs | 2 +- crates/ui-contract/src/runtime/pointer.rs | 4 +- crates/ui-contract/src/testing/mod.rs | 16 +++++++- crates/ui-contract/src/testing/story.rs | 4 ++ crates/ui-gallery/Cargo.toml | 40 +++++++++---------- crates/ui-macros/src/component.rs | 8 ++-- crates/ui-macros/src/lib.rs | 6 +++ crates/ui-macros/src/tests.rs | 8 ++-- crates/ui-panels/Cargo.toml | 3 +- crates/ui-panels/src/dialog/mod.rs | 4 +- crates/ui-panels/src/dialog/prompt.rs | 2 +- crates/ui-panels/src/docking/dock_column.rs | 2 +- crates/ui-panels/src/docking/floating.rs | 2 +- crates/ui-panels/src/docking/iconic.rs | 4 +- crates/ui-panels/src/docking/mod.rs | 2 +- crates/ui-panels/src/docking/root.rs | 2 +- crates/ui-panels/src/lib.rs | 3 +- crates/ui-panels/src/rails/drawer.rs | 2 +- crates/ui-panels/src/rails/flyout.rs | 2 +- crates/ui-panels/src/rails/tool.rs | 4 +- crates/ui-panels/src/sections/footer.rs | 2 +- crates/ui-panels/src/sections/group_box.rs | 2 +- crates/ui-panels/src/sections/mod.rs | 2 +- crates/ui-panels/src/sections/panel.rs | 2 +- crates/ui-panels/src/sections/reorderable.rs | 2 +- crates/ui-panels/src/sections/section.rs | 2 +- crates/ui-panels/src/sections/stack.rs | 2 +- crates/ui-panels/src/sections/title_row.rs | 2 +- crates/ui-patterns/Cargo.toml | 3 +- crates/ui-patterns/src/lib.rs | 3 +- crates/ui-patterns/src/patterns/dock/area.rs | 2 +- crates/ui-patterns/src/patterns/dock/panes.rs | 2 +- .../ui-patterns/src/patterns/dock/switcher.rs | 2 +- .../src/patterns/dock/workspace_dialogs.rs | 2 +- .../src/patterns/form_dialogs/about.rs | 2 +- .../src/patterns/form_dialogs/dialog.rs | 2 +- .../src/patterns/form_dialogs/export.rs | 2 +- .../src/patterns/form_dialogs/file_list.rs | 2 +- .../src/patterns/form_dialogs/form.rs | 2 +- .../src/patterns/form_dialogs/guides.rs | 4 +- .../src/patterns/form_dialogs/list_manager.rs | 2 +- .../form_dialogs/navigator_options.rs | 2 +- .../src/patterns/form_dialogs/new_document.rs | 2 +- .../src/patterns/form_dialogs/password.rs | 2 +- .../src/patterns/form_dialogs/path_row.rs | 2 +- .../src/patterns/form_dialogs/pdf_export.rs | 2 +- .../src/patterns/form_dialogs/preview.rs | 2 +- .../src/patterns/form_dialogs/properties.rs | 2 +- .../src/patterns/form_dialogs/report.rs | 2 +- .../src/patterns/form_dialogs/rows.rs | 2 +- .../src/patterns/form_dialogs/save_for_web.rs | 2 +- .../src/patterns/form_dialogs/sizing.rs | 2 +- .../src/patterns/form_dialogs/watermark.rs | 2 +- .../src/patterns/panels/history.rs | 2 +- .../src/patterns/panels/inspector.rs | 2 +- .../src/patterns/panels/modifier_keys.rs | 2 +- .../src/patterns/panels/palette.rs | 2 +- .../ui-patterns/src/patterns/panels/tour.rs | 2 +- .../src/patterns/preferences/path_setting.rs | 2 +- .../src/patterns/preferences/window.rs | 2 +- .../src/patterns/presets/browser.rs | 2 +- .../src/patterns/presets/footer.rs | 2 +- .../src/patterns/presets/manager.rs | 2 +- .../ui-patterns/src/patterns/presets/named.rs | 2 +- .../src/patterns/presets/picker.rs | 2 +- crates/ui-shell/Cargo.toml | 3 +- crates/ui-shell/src/lib.rs | 3 +- crates/ui-shell/src/shell/app_shell.rs | 2 +- crates/ui-shell/src/shell/canvas_shell.rs | 2 +- crates/ui-shell/src/shell/caption_button.rs | 2 +- crates/ui-shell/src/shell/document_window.rs | 2 +- crates/ui-shell/src/shell/opening.rs | 2 +- .../ui-shell/src/shell/screen_mode_button.rs | 2 +- crates/ui-shell/src/shell/start.rs | 2 +- crates/ui-shell/src/shell/title_bar/bar.rs | 2 +- crates/ui-shell/src/shell/viewport_window.rs | 2 +- crates/ui-widgets/Cargo.toml | 3 +- crates/ui-widgets/src/bars/align.rs | 2 +- crates/ui-widgets/src/bars/breadcrumb.rs | 2 +- .../ui-widgets/src/bars/constraint_fields.rs | 2 +- crates/ui-widgets/src/bars/mod.rs | 2 +- crates/ui-widgets/src/bars/status_readout.rs | 2 +- crates/ui-widgets/src/buttons/mod.rs | 2 +- crates/ui-widgets/src/choice/check.rs | 2 +- crates/ui-widgets/src/choice/radio.rs | 2 +- crates/ui-widgets/src/choice/rating.rs | 2 +- crates/ui-widgets/src/choice/segmented.rs | 2 +- crates/ui-widgets/src/choice/swatch.rs | 2 +- crates/ui-widgets/src/choice/swatch_table.rs | 2 +- crates/ui-widgets/src/choice/switch.rs | 2 +- crates/ui-widgets/src/controls/mod.rs | 2 +- crates/ui-widgets/src/display/badge.rs | 2 +- crates/ui-widgets/src/display/divider.rs | 2 +- crates/ui-widgets/src/display/icon.rs | 2 +- .../ui-widgets/src/display/inspect_overlay.rs | 2 +- crates/ui-widgets/src/display/kbd.rs | 2 +- crates/ui-widgets/src/display/picture.rs | 2 +- crates/ui-widgets/src/display/progress.rs | 2 +- crates/ui-widgets/src/display/spinner.rs | 2 +- crates/ui-widgets/src/display/target_mark.rs | 2 +- crates/ui-widgets/src/display/text.rs | 2 +- crates/ui-widgets/src/form/mod.rs | 2 +- crates/ui-widgets/src/form/slider_field.rs | 2 +- crates/ui-widgets/src/graph/mod.rs | 2 +- .../ui-widgets/src/layout_components/mod.rs | 2 +- crates/ui-widgets/src/lib.rs | 4 +- crates/ui-widgets/src/list/mod.rs | 4 +- crates/ui-widgets/src/menu/bar.rs | 2 +- crates/ui-widgets/src/menu/mod.rs | 2 +- crates/ui-widgets/src/notices/mod.rs | 2 +- crates/ui-widgets/src/pickers/combo_box.rs | 2 +- crates/ui-widgets/src/pickers/date.rs | 2 +- crates/ui-widgets/src/pickers/face.rs | 2 +- crates/ui-widgets/src/pickers/icon_picker.rs | 2 +- .../ui-widgets/src/pickers/reference_point.rs | 2 +- crates/ui-widgets/src/pickers/select.rs | 2 +- crates/ui-widgets/src/pickers/tree_picker.rs | 2 +- crates/ui-widgets/src/pickers/unit_select.rs | 2 +- crates/ui-widgets/src/popover/anchored.rs | 2 +- crates/ui-widgets/src/popover/drop_veil.rs | 2 +- crates/ui-widgets/src/popover/popup_list.rs | 2 +- crates/ui-widgets/src/table/metadata.rs | 2 +- crates/ui-widgets/src/table/mod.rs | 2 +- crates/ui-widgets/src/tabs/document.rs | 2 +- crates/ui-widgets/src/tabs/strip.rs | 2 +- crates/ui-widgets/src/tabs/tab.rs | 2 +- crates/ui-widgets/src/text/alt_text.rs | 2 +- crates/ui-widgets/src/text/chips.rs | 2 +- crates/ui-widgets/src/text/hex.rs | 2 +- crates/ui-widgets/src/text/linked.rs | 2 +- crates/ui-widgets/src/text/number.rs | 2 +- crates/ui-widgets/src/text/selectable_text.rs | 2 +- crates/ui-widgets/src/text/text_field.rs | 2 +- crates/ui-widgets/src/text/zoom_field.rs | 2 +- crates/ui-widgets/src/tile_grid/grid.rs | 2 +- crates/ui-widgets/src/tile_grid/mod.rs | 2 +- .../ui-widgets/src/value_drag/angle_dial.rs | 2 +- .../ui-widgets/src/value_drag/point_picker.rs | 2 +- .../ui-widgets/src/value_drag/range_slider.rs | 2 +- crates/ui-widgets/src/value_drag/slider.rs | 2 +- crates/ui-widgets/src/value_drag/thumb_row.rs | 2 +- crates/ui/Cargo.toml | 3 +- crates/ui/src/lib.rs | 4 ++ crates/update/Cargo.toml | 3 +- crates/update/src/lib.rs | 1 + crates/update/src/stack_dialogs.rs | 2 +- docs/development.md | 4 +- tools/cl | 6 ++- 393 files changed, 538 insertions(+), 445 deletions(-) diff --git a/crates/automation/Cargo.toml b/crates/automation/Cargo.toml index f82a4c14f..5a2b801d5 100644 --- a/crates/automation/Cargo.toml +++ b/crates/automation/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The egui parts: the Actions panel, the control channel's server side (screenshots, synthetic # input) and `ui` stories. Without it the crate has no egui: `ControlOptions`, `ControlClient`, @@ -55,5 +56,5 @@ thiserror = { workspace = true } [dev-dependencies] tempfile = "3" -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } egui = { workspace = true } diff --git a/crates/automation/src/lib.rs b/crates/automation/src/lib.rs index 52e967ead..7757692df 100644 --- a/crates/automation/src/lib.rs +++ b/crates/automation/src/lib.rs @@ -57,6 +57,7 @@ pub use security::AutomationError; /// The trials this crate registers, for its integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/automation/src/ui/actions/mod.rs b/crates/automation/src/ui/actions/mod.rs index 2b9ed4304..390a60cec 100644 --- a/crates/automation/src/ui/actions/mod.rs +++ b/crates/automation/src/ui/actions/mod.rs @@ -17,7 +17,7 @@ pub mod mock; mod panel; mod prompt; mod rows; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/automation/src/ui/agents/mod.rs b/crates/automation/src/ui/agents/mod.rs index 01b5a9115..39fd04c67 100644 --- a/crates/automation/src/ui/agents/mod.rs +++ b/crates/automation/src/ui/agents/mod.rs @@ -1,6 +1,6 @@ //! `AgentsPage`: the Agents page of Preferences, over the agent settings in the Preferences draft. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/browse/Cargo.toml b/crates/browse/Cargo.toml index b30cf10b3..177c2a836 100644 --- a/crates/browse/Cargo.toml +++ b/crates/browse/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The browsing widgets (`craft_browse::ui`) and `FileThumbSource`. ui = ["dep:craft-behavior", "dep:craft-ui", "dep:egui", "dep:kurbo"] @@ -37,6 +38,6 @@ kurbo = { workspace = true, optional = true } serde = { workspace = true } [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } egui = { workspace = true } tempfile = "3" diff --git a/crates/browse/src/ui/bin/mod.rs b/crates/browse/src/ui/bin/mod.rs index 2e775e243..de3efdcbc 100644 --- a/crates/browse/src/ui/bin/mod.rs +++ b/crates/browse/src/ui/bin/mod.rs @@ -23,7 +23,7 @@ mod free_view; mod icon; mod list; mod search; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::cell::RefCell; diff --git a/crates/browse/src/ui/compare/mod.rs b/crates/browse/src/ui/compare/mod.rs index 0d4d83f22..2cad58294 100644 --- a/crates/browse/src/ui/compare/mod.rs +++ b/crates/browse/src/ui/compare/mod.rs @@ -14,7 +14,7 @@ mod arrange; mod caption; mod pill; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod style; mod tile; diff --git a/crates/browse/src/ui/freebin/mod.rs b/crates/browse/src/ui/freebin/mod.rs index 9f922f85e..341116b98 100644 --- a/crates/browse/src/ui/freebin/mod.rs +++ b/crates/browse/src/ui/freebin/mod.rs @@ -5,7 +5,7 @@ //! End, the marquee, the move gesture, rename, delete and the context menu. `FreeBin` adds the placement and turns the //! move gesture into the cards' new positions. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::cell::RefCell; diff --git a/crates/browse/src/ui/mod.rs b/crates/browse/src/ui/mod.rs index bb6c5d2cb..910e7d8bc 100644 --- a/crates/browse/src/ui/mod.rs +++ b/crates/browse/src/ui/mod.rs @@ -21,5 +21,6 @@ pub use relink::{LinkList, LinkListWords, RelinkDialog, RelinkWords, StatusBadge /// The stories and trials this crate registers for the integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/browse/src/ui/places/mod.rs b/crates/browse/src/ui/places/mod.rs index b129fd351..f6ebde7d2 100644 --- a/crates/browse/src/ui/places/mod.rs +++ b/crates/browse/src/ui/places/mod.rs @@ -15,7 +15,7 @@ //! } //! ``` -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::path::{Path, PathBuf}; diff --git a/crates/browse/src/ui/relink/mod.rs b/crates/browse/src/ui/relink/mod.rs index 9973ea727..1816678b9 100644 --- a/crates/browse/src/ui/relink/mod.rs +++ b/crates/browse/src/ui/relink/mod.rs @@ -18,7 +18,7 @@ mod badge; mod dialog; mod list; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use badge::StatusBadge; diff --git a/crates/color-ui/Cargo.toml b/crates/color-ui/Cargo.toml index f7f775023..d6cbb1c10 100644 --- a/crates/color-ui/Cargo.toml +++ b/crates/color-ui/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The colour widgets (`craft_color_ui::ui`). ui = ["dep:craft-behavior", "dep:craft-keymap", "dep:craft-ui", "dep:egui", "dep:craft-settings", "dep:craft-window", "craft-platform/screen", "dep:serde_json"] @@ -39,7 +40,7 @@ serde = { workspace = true } serde_json = { workspace = true, optional = true } [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } egui = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] diff --git a/crates/color-ui/src/ui/area.rs b/crates/color-ui/src/ui/area.rs index 0f3fe324b..d151bcf57 100644 --- a/crates/color-ui/src/ui/area.rs +++ b/crates/color-ui/src/ui/area.rs @@ -13,7 +13,7 @@ use craft_ui::style::{ComponentStyle, StyleCx}; use craft_ui::value_drag::{PointMark, PointPicker}; use egui::{Mesh, Pos2, Rect, Vec2, pos2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// Vertices along each side of the area's colour mesh (PhotoCraft's 32). diff --git a/crates/color-ui/src/ui/choice.rs b/crates/color-ui/src/ui/choice.rs index cc6025243..17ec7be7b 100644 --- a/crates/color-ui/src/ui/choice.rs +++ b/crates/color-ui/src/ui/choice.rs @@ -1,7 +1,7 @@ //! `ColorChoice`: a choice among named colours with a custom colour, as Photoshop's pasteboard colour //! (Preferences, Interface), the Crop shield colour and the Note colour. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_theme::Srgba; diff --git a/crates/color-ui/src/ui/compare.rs b/crates/color-ui/src/ui/compare.rs index de84255b3..9edb518b9 100644 --- a/crates/color-ui/src/ui/compare.rs +++ b/crates/color-ui/src/ui/compare.rs @@ -12,7 +12,7 @@ use egui::{CornerRadius, Rect, Response, Vec2, pos2}; use super::picker::ColorPickerWords; use super::warning::{ColorWarning, ColorWarningChip}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a compare block: the size of the block and of each half, the edge round it and the gap between a diff --git a/crates/color-ui/src/ui/disc.rs b/crates/color-ui/src/ui/disc.rs index 1f3cc430c..dab85370f 100644 --- a/crates/color-ui/src/ui/disc.rs +++ b/crates/color-ui/src/ui/disc.rs @@ -16,7 +16,7 @@ use craft_ui::runtime::focus::{ActivateKeys, FocusShape, KeepKeys, KeyUse}; use craft_ui::style::{ComponentStyle, FocusLook, MarkerLook, StyleColor, StyleCx}; use egui::{Color32, Mesh, Pos2, Response, Vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The disc: a press on it grabs the nearest marker within reach. diff --git a/crates/color-ui/src/ui/droppers.rs b/crates/color-ui/src/ui/droppers.rs index 1e74fa220..8d5c4fe67 100644 --- a/crates/color-ui/src/ui/droppers.rs +++ b/crates/color-ui/src/ui/droppers.rs @@ -31,7 +31,7 @@ use craft_ui::runtime::env::Label; use craft_ui::runtime::requests::EyedropperRequest; use egui::{Pos2, Response, Ui, Vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The pipette icon's tip, in the icon's own 24-unit box. diff --git a/crates/color-ui/src/ui/eyedropper.rs b/crates/color-ui/src/ui/eyedropper.rs index a094917b4..5670cf4aa 100644 --- a/crates/color-ui/src/ui/eyedropper.rs +++ b/crates/color-ui/src/ui/eyedropper.rs @@ -35,7 +35,7 @@ use craft_ui::runtime::env::{Env, Label}; use craft_ui::style::DataColor; use egui::{Color32, Pos2, Response, Ui, Vec2, vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/color-ui/src/ui/gradient/editor.rs b/crates/color-ui/src/ui/gradient/editor.rs index fc92f3978..7a83ebd9d 100644 --- a/crates/color-ui/src/ui/gradient/editor.rs +++ b/crates/color-ui/src/ui/gradient/editor.rs @@ -17,7 +17,7 @@ use crate::gradient::{GradientStops, Sampler, StopRules}; mod bar; mod fields; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use bar::GradientBar; diff --git a/crates/color-ui/src/ui/harmony.rs b/crates/color-ui/src/ui/harmony.rs index 9fbe06703..807ba048d 100644 --- a/crates/color-ui/src/ui/harmony.rs +++ b/crates/color-ui/src/ui/harmony.rs @@ -19,7 +19,7 @@ use super::picker::{ChannelRow, ChannelRule}; use crate::harmony::{Guide, GuideOptions, Harmony, Variation}; use craft_ui::choice::{SwatchTable, SwatchTableOutput}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/color-ui/src/ui/hud.rs b/crates/color-ui/src/ui/hud.rs index 412c62ea0..f9b6ecc60 100644 --- a/crates/color-ui/src/ui/hud.rs +++ b/crates/color-ui/src/ui/hud.rs @@ -17,7 +17,7 @@ use craft_ui::runtime::pointer; use craft_ui::style::{ComponentStyle, StyleCx, UiTokens}; use egui::{Pos2, Rect, Response, Ui, Vec2, pos2, vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The model the HUD picks in: saturation and brightness across and down, hue in the strip. diff --git a/crates/color-ui/src/ui/info.rs b/crates/color-ui/src/ui/info.rs index 46238e585..cb192b03b 100644 --- a/crates/color-ui/src/ui/info.rs +++ b/crates/color-ui/src/ui/info.rs @@ -13,7 +13,7 @@ use egui::{Response, Ui}; use super::SamplerReadout; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// What a missing value shows. diff --git a/crates/color-ui/src/ui/lut_picker.rs b/crates/color-ui/src/ui/lut_picker.rs index 8c2609d36..bb40074c7 100644 --- a/crates/color-ui/src/ui/lut_picker.rs +++ b/crates/color-ui/src/ui/lut_picker.rs @@ -19,7 +19,7 @@ use craft_ui::runtime::env::Label; use craft_ui::style::{ComponentStyle, StyleCx}; use egui::{Response, Vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/color-ui/src/ui/paint_chip.rs b/crates/color-ui/src/ui/paint_chip.rs index 098395b95..55c42cc6b 100644 --- a/crates/color-ui/src/ui/paint_chip.rs +++ b/crates/color-ui/src/ui/paint_chip.rs @@ -34,7 +34,7 @@ use super::{PickedColor, ScreenPickGesture, SwatchKey, SwatchPalette, SwatchesWo use crate::palette::{SwatchColor, SwatchGroup}; mod paint_list; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use paint_list::{PaintLink, PaintLinkKind, PaintList, PaintListEvent, PaintListOptions, PaintListOutput, PaintRow}; diff --git a/crates/color-ui/src/ui/pair.rs b/crates/color-ui/src/ui/pair.rs index 3b1204c6d..454bebee9 100644 --- a/crates/color-ui/src/ui/pair.rs +++ b/crates/color-ui/src/ui/pair.rs @@ -18,7 +18,7 @@ use egui::{Color32, CornerRadius, Painter, Pos2, Rect, Response, Shape, Stroke, use super::popover::compact_picker; use super::{ColorPicker, PickedColor, ScreenPickGesture}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// One of the wells, `WELL.at(0)` the primary and `WELL.at(1)` the secondary. diff --git a/crates/color-ui/src/ui/palette.rs b/crates/color-ui/src/ui/palette.rs index c97450556..f8200fd8c 100644 --- a/crates/color-ui/src/ui/palette.rs +++ b/crates/color-ui/src/ui/palette.rs @@ -10,7 +10,7 @@ use craft_ui::runtime::env::Label; use egui::{Response, Ui}; use std::sync::Arc; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// What a [`SwatchPalette`] reports. diff --git a/crates/color-ui/src/ui/panel.rs b/crates/color-ui/src/ui/panel.rs index acb53d2a1..05d31faa3 100644 --- a/crates/color-ui/src/ui/panel.rs +++ b/crates/color-ui/src/ui/panel.rs @@ -29,7 +29,7 @@ use super::{ }; use crate::{CmykModel, GrayModel, not_web_safe}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/color-ui/src/ui/picker/mod.rs b/crates/color-ui/src/ui/picker/mod.rs index 3cb865a6a..10e6b13f5 100644 --- a/crates/color-ui/src/ui/picker/mod.rs +++ b/crates/color-ui/src/ui/picker/mod.rs @@ -6,7 +6,7 @@ mod channel; mod compact; mod full; mod screen_pick; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod value; diff --git a/crates/color-ui/src/ui/popover.rs b/crates/color-ui/src/ui/popover.rs index d599b7455..e995bbd43 100644 --- a/crates/color-ui/src/ui/popover.rs +++ b/crates/color-ui/src/ui/popover.rs @@ -11,7 +11,7 @@ use egui::{Response, Ui}; use super::{ColorPicker, ColorPickerLayout, ColorPickerOutput, PickedColor, ScreenPickGesture}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The setup closure of the picker in the popover. diff --git a/crates/color-ui/src/ui/profile_prompts.rs b/crates/color-ui/src/ui/profile_prompts.rs index 6ff093604..32a4a97f4 100644 --- a/crates/color-ui/src/ui/profile_prompts.rs +++ b/crates/color-ui/src/ui/profile_prompts.rs @@ -18,7 +18,7 @@ use serde_json::{Value, json}; use crate::display::MonitorProblem; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/color-ui/src/ui/ramp.rs b/crates/color-ui/src/ui/ramp.rs index 63bb1a38d..f074258ef 100644 --- a/crates/color-ui/src/ui/ramp.rs +++ b/crates/color-ui/src/ui/ramp.rs @@ -17,7 +17,7 @@ use egui::{Color32, CornerRadius, Mesh, Pos2, Rect, Response, Vec2, pos2}; use std::hash::{DefaultHasher, Hash, Hasher}; use std::sync::Arc; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The bar: a press picks the colour under the pointer. diff --git a/crates/color-ui/src/ui/readout.rs b/crates/color-ui/src/ui/readout.rs index 34887e221..79baeb9c1 100644 --- a/crates/color-ui/src/ui/readout.rs +++ b/crates/color-ui/src/ui/readout.rs @@ -1,6 +1,6 @@ //! `ColorReadout`: a colour as a hex field and editable R, G and B fields (the readout of a Color panel). -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{EditEvent, EditEvents, Mixed}; diff --git a/crates/color-ui/src/ui/samplers.rs b/crates/color-ui/src/ui/samplers.rs index a0edd1a07..23f8c13d3 100644 --- a/crates/color-ui/src/ui/samplers.rs +++ b/crates/color-ui/src/ui/samplers.rs @@ -34,7 +34,7 @@ use super::{InfoColor, SampleSize, SampleSizeSelect}; use craft_ui::style::{ComponentStyle, StyleColor, StyleCx}; use egui::{Pos2, Response, Ui, Vec2, vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/color-ui/src/ui/screen_picker.rs b/crates/color-ui/src/ui/screen_picker.rs index 1184d9fef..89cbe238f 100644 --- a/crates/color-ui/src/ui/screen_picker.rs +++ b/crates/color-ui/src/ui/screen_picker.rs @@ -33,7 +33,7 @@ use egui::{Color32, Context, Pos2, Rect, Ui, pos2, vec2}; use super::ScreenPickGesture; mod capture; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use capture::{CaptureView, CaptureWindow}; diff --git a/crates/color-ui/src/ui/strip.rs b/crates/color-ui/src/ui/strip.rs index 2ac3a38ce..c26e62e91 100644 --- a/crates/color-ui/src/ui/strip.rs +++ b/crates/color-ui/src/ui/strip.rs @@ -15,7 +15,7 @@ use craft_ui::runtime::focus::{ActivateKeys, KeepKeys, KeyUse}; use craft_ui::style::{ComponentStyle, DataColor, FocusLook, StyleColor, StyleCx}; use egui::{CornerRadius, Mesh, Pos2, Rect, Vec2, pos2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The strip itself: a press on it sets the value there. diff --git a/crates/color-ui/src/ui/swatches.rs b/crates/color-ui/src/ui/swatches.rs index 6293e937f..b450b92c1 100644 --- a/crates/color-ui/src/ui/swatches.rs +++ b/crates/color-ui/src/ui/swatches.rs @@ -6,7 +6,7 @@ mod library; mod menu; mod panel; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use library::{SwatchAt, SwatchEdit, SwatchKey, SwatchLibrary, SwatchesState, swatch_rows}; diff --git a/crates/color-ui/src/ui/testing.rs b/crates/color-ui/src/ui/testing.rs index 0c557eaa6..f84385a15 100644 --- a/crates/color-ui/src/ui/testing.rs +++ b/crates/color-ui/src/ui/testing.rs @@ -1 +1,2 @@ +#[cfg(feature = "suite")] craft_ui::testing_registered!(); diff --git a/crates/color-ui/src/ui/warning.rs b/crates/color-ui/src/ui/warning.rs index 40949d67e..b67de633c 100644 --- a/crates/color-ui/src/ui/warning.rs +++ b/crates/color-ui/src/ui/warning.rs @@ -11,7 +11,7 @@ use craft_ui::runtime::env::Label; use craft_ui::style::{ComponentStyle, StyleCx}; use egui::{Rect, Response, Vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// A warning the host shows beside a colour's swatch, as the out-of-gamut and web-colour warnings of Photoshop's Color diff --git a/crates/color-ui/src/ui/wheel.rs b/crates/color-ui/src/ui/wheel.rs index b2c3b0ca1..615789773 100644 --- a/crates/color-ui/src/ui/wheel.rs +++ b/crates/color-ui/src/ui/wheel.rs @@ -15,7 +15,7 @@ use craft_ui::style::{ComponentStyle, FocusLook, MarkerLook, StyleColor, StyleCx use egui::{Mesh, Pos2, Rect, Vec2, vec2}; use std::f32::consts::TAU; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The hue ring: a press on it sets the hue to the pointer's angle. diff --git a/crates/craft/Cargo.toml b/crates/craft/Cargo.toml index 708bbf2b6..be3b61959 100644 --- a/crates/craft/Cargo.toml +++ b/crates/craft/Cargo.toml @@ -215,6 +215,7 @@ craft-suite-account = { workspace = true, optional = true } craft-xfa = { workspace = true, optional = true } [features] +suite = ["screen-testing", "craft-ui/suite", "craft-automation?/suite", "craft-browse?/suite", "craft-color-ui?/suite", "craft-dialogs?/suite", "craft-draw?/suite", "craft-font-manager?/suite", "craft-imaging?/suite", "craft-layers?/suite", "craft-menu?/suite", "craft-pages?/suite", "craft-print?/suite", "craft-review?/suite", "craft-table?/suite", "craft-text?/suite", "craft-theme-editor?/suite", "craft-theme-store?/suite", "craft-timeline?/suite", "craft-update?/suite"] ui = [ "dep:craft-ui", "dep:egui", diff --git a/crates/dialogs/Cargo.toml b/crates/dialogs/Cargo.toml index 9a8087341..cbda38030 100644 --- a/crates/dialogs/Cargo.toml +++ b/crates/dialogs/Cargo.toml @@ -45,6 +45,7 @@ log = "0.4" zbus = { version = "5", default-features = false, features = ["async-io", "blocking-api"] } [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # `craft_dialogs::ui`: `PathField` and the other egui parts of the file service. ui = ["dep:craft-behavior", "dep:craft-ui", "dep:egui"] @@ -52,7 +53,7 @@ ui = ["dep:craft-behavior", "dep:craft-ui", "dep:egui"] screen-testing = ["ui", "craft-ui/testing"] [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } [lints] workspace = true diff --git a/crates/dialogs/src/lib.rs b/crates/dialogs/src/lib.rs index 299d5accc..7b3356385 100644 --- a/crates/dialogs/src/lib.rs +++ b/crates/dialogs/src/lib.rs @@ -34,6 +34,7 @@ pub mod ui; /// The registrations of this crate's UI types, for its integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/dialogs/src/ui/mod.rs b/crates/dialogs/src/ui/mod.rs index 0d48dcf9b..eda6b23dd 100644 --- a/crates/dialogs/src/ui/mod.rs +++ b/crates/dialogs/src/ui/mod.rs @@ -1,7 +1,7 @@ //! The file service's UI part: [`PathField`], and the words of the service's native boxes. mod path_field; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use path_field::{PathField, PathFieldOutput, PathFieldWords}; diff --git a/crates/draw/Cargo.toml b/crates/draw/Cargo.toml index bcb5b6c7e..9a8c91cb5 100644 --- a/crates/draw/Cargo.toml +++ b/crates/draw/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite", "craft-color-ui/suite"] default = [] # The tool widgets (`craft_draw::ui`). ui = ["dep:craft-behavior", "dep:craft-keymap", "dep:craft-ui", "dep:egui", "dep:craft-color-ui", "craft-color-ui/ui", "dep:craft-settings", "dep:serde_json"] @@ -38,5 +39,5 @@ serde = { version = "1", features = ["derive"] } serde_json = { workspace = true, optional = true } [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } egui = { workspace = true } diff --git a/crates/draw/src/lib.rs b/crates/draw/src/lib.rs index a27622d1f..4111d49bc 100644 --- a/crates/draw/src/lib.rs +++ b/crates/draw/src/lib.rs @@ -9,6 +9,7 @@ pub mod ui; #[cfg(feature = "screen-testing")] pub mod testing { //! The registrations of this crate's stories, for the `tests/it` harness. + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/draw/src/ui/add_beside/mod.rs b/crates/draw/src/ui/add_beside/mod.rs index fb1856c79..ecc1d9042 100644 --- a/crates/draw/src/ui/add_beside/mod.rs +++ b/crates/draw/src/ui/add_beside/mod.rs @@ -2,7 +2,7 @@ //! (Photoshop) or a connected object (FigJam) there. One canvas control for the Artboard tool and the connector //! tools: its buttons are parts in the canvas's arena, so a press on one reaches the control before the tool. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/draw/src/ui/artboard/mod.rs b/crates/draw/src/ui/artboard/mod.rs index edab421c1..acec3ed2d 100644 --- a/crates/draw/src/ui/artboard/mod.rs +++ b/crates/draw/src/ui/artboard/mod.rs @@ -19,7 +19,7 @@ mod background; mod bar; mod overlay; mod properties; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod tool; mod words; diff --git a/crates/draw/src/ui/brush_presets/mod.rs b/crates/draw/src/ui/brush_presets/mod.rs index 617a57bfb..6c263431b 100644 --- a/crates/draw/src/ui/brush_presets/mod.rs +++ b/crates/draw/src/ui/brush_presets/mod.rs @@ -14,7 +14,7 @@ mod panel; mod picker; mod rows; mod settings; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/draw/src/ui/brush_settings/mod.rs b/crates/draw/src/ui/brush_settings/mod.rs index 2c2155da5..dce1efb64 100644 --- a/crates/draw/src/ui/brush_settings/mod.rs +++ b/crates/draw/src/ui/brush_settings/mod.rs @@ -19,7 +19,7 @@ mod preview; mod rows; mod sections; mod size_field; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/draw/src/ui/connector/mod.rs b/crates/draw/src/ui/connector/mod.rs index 943bda0e3..29c4cc5ee 100644 --- a/crates/draw/src/ui/connector/mod.rs +++ b/crates/draw/src/ui/connector/mod.rs @@ -14,7 +14,7 @@ mod place; mod tool; mod words; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::EditEvent; diff --git a/crates/draw/src/ui/corner/mod.rs b/crates/draw/src/ui/corner/mod.rs index c4e163fed..002a8a780 100644 --- a/crates/draw/src/ui/corner/mod.rs +++ b/crates/draw/src/ui/corner/mod.rs @@ -6,7 +6,7 @@ //! arc the app's engine draws. mod geometry; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod style; mod widgets; diff --git a/crates/draw/src/ui/crop/bar.rs b/crates/draw/src/ui/crop/bar.rs index c9e2f4892..5b2aaee26 100644 --- a/crates/draw/src/ui/crop/bar.rs +++ b/crates/draw/src/ui/crop/bar.rs @@ -21,7 +21,7 @@ use craft_ui::runtime::requests::ColorRequest; use craft_ui::text::NumberField; use egui::{Response, Ui}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The ratio, a ratio field, a preset or W × H × Resolution changed. diff --git a/crates/draw/src/ui/crop/perspective_bar.rs b/crates/draw/src/ui/crop/perspective_bar.rs index 3a7ffd72f..72b437f4a 100644 --- a/crates/draw/src/ui/crop/perspective_bar.rs +++ b/crates/draw/src/ui/crop/perspective_bar.rs @@ -11,7 +11,7 @@ use craft_ui::layout_components::Row; use craft_ui::runtime::env::Env; use egui::{Response, Ui}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The Perspective Crop options: W × H × Resolution, Front Image, Clear, a divider and Show Grid. diff --git a/crates/draw/src/ui/crop/perspective_crop.rs b/crates/draw/src/ui/crop/perspective_crop.rs index c4bae9736..000a02bdc 100644 --- a/crates/draw/src/ui/crop/perspective_crop.rs +++ b/crates/draw/src/ui/crop/perspective_crop.rs @@ -487,5 +487,5 @@ pub fn grid_lines(view: &CanvasView, q: &[Point; 4], step: f32) -> Vec<[Pos2; 2] out } -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/draw/src/ui/crop/tool.rs b/crates/draw/src/ui/crop/tool.rs index d5de11c8a..b6484d7bc 100644 --- a/crates/draw/src/ui/crop/tool.rs +++ b/crates/draw/src/ui/crop/tool.rs @@ -788,5 +788,5 @@ pub fn crop_to_form(words: &CropWords, frame: &CropBox) -> ParamDialog<'static> ParamDialog::command(CROP_TO_KEY, words.crop_to.clone(), params) } -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/draw/src/ui/gradient/fill_editor.rs b/crates/draw/src/ui/gradient/fill_editor.rs index 81f6f36f7..b6b09c818 100644 --- a/crates/draw/src/ui/gradient/fill_editor.rs +++ b/crates/draw/src/ui/gradient/fill_editor.rs @@ -222,5 +222,5 @@ impl<'a> GradientFillEditor<'a> { } } -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/draw/src/ui/gradient/gradient_overlay/mod.rs b/crates/draw/src/ui/gradient/gradient_overlay/mod.rs index d82d7625b..00d8ff9cd 100644 --- a/crates/draw/src/ui/gradient/gradient_overlay/mod.rs +++ b/crates/draw/src/ui/gradient/gradient_overlay/mod.rs @@ -5,7 +5,7 @@ mod keys; mod parts; mod pointer; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/draw/src/ui/gradient/map/mod.rs b/crates/draw/src/ui/gradient/map/mod.rs index 7866b8f49..c75a048bb 100644 --- a/crates/draw/src/ui/gradient/map/mod.rs +++ b/crates/draw/src/ui/gradient/map/mod.rs @@ -4,7 +4,7 @@ //! It lives here rather than with the other adjustment editors in craft-imaging because it picks from the palette's //! [`GradientGroup`] presets, and a family crate depends on no other family crate but craft-color-ui. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{EditEvent, Mixed}; diff --git a/crates/draw/src/ui/gradient/palette/mod.rs b/crates/draw/src/ui/gradient/palette/mod.rs index cb1866ba6..9d320e9d7 100644 --- a/crates/draw/src/ui/gradient/palette/mod.rs +++ b/crates/draw/src/ui/gradient/palette/mod.rs @@ -7,7 +7,7 @@ use craft_ui::patterns::presets::{CellShape, PresetBrowser, PresetEvent, PresetR use craft_ui::runtime::env::{Env, Label}; use egui::{Response, Ui}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_color_ui::ui::gradient::{GradientRamp, GradientStops, Sampler, StopRows, default_sampler}; diff --git a/crates/draw/src/ui/gradient/swatch.rs b/crates/draw/src/ui/gradient/swatch.rs index 16cf2f0b7..e6698f38b 100644 --- a/crates/draw/src/ui/gradient/swatch.rs +++ b/crates/draw/src/ui/gradient/swatch.rs @@ -10,7 +10,7 @@ use egui::{CornerRadius, Response, Vec2}; use craft_color_ui::ui::gradient::{GradientRamp, GradientStops, Sampler, StopRows, default_sampler}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a gradient swatch: the colour swatch's height, corners and ring. diff --git a/crates/draw/src/ui/measure/mod.rs b/crates/draw/src/ui/measure/mod.rs index 034445420..e7a492e34 100644 --- a/crates/draw/src/ui/measure/mod.rs +++ b/crates/draw/src/ui/measure/mod.rs @@ -9,7 +9,7 @@ mod bar; mod distances; mod model; mod overlay; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod tool; mod words; diff --git a/crates/draw/src/ui/paint_bar.rs b/crates/draw/src/ui/paint_bar.rs index 74a61e601..977519a02 100644 --- a/crates/draw/src/ui/paint_bar.rs +++ b/crates/draw/src/ui/paint_bar.rs @@ -20,7 +20,7 @@ use craft_ui::runtime::env::{Env, Label, UnitKind}; use craft_ui::text::{NumberField, RangeAlert}; use egui::{Response, Ui}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/draw/src/ui/paths/mod.rs b/crates/draw/src/ui/paths/mod.rs index d751cff17..96396f58b 100644 --- a/crates/draw/src/ui/paths/mod.rs +++ b/crates/draw/src/ui/paths/mod.rs @@ -6,7 +6,7 @@ mod menu; mod model; mod panel; mod rows; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/draw/src/ui/pattern/mod.rs b/crates/draw/src/ui/pattern/mod.rs index b74f303af..473e821e5 100644 --- a/crates/draw/src/ui/pattern/mod.rs +++ b/crates/draw/src/ui/pattern/mod.rs @@ -6,7 +6,7 @@ use craft_theme::Srgba; mod dialog; mod editor; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/draw/src/ui/pen/bezier/mod.rs b/crates/draw/src/ui/pen/bezier/mod.rs index d99b541df..dd9c80570 100644 --- a/crates/draw/src/ui/pen/bezier/mod.rs +++ b/crates/draw/src/ui/pen/bezier/mod.rs @@ -5,7 +5,7 @@ mod hit_test; mod mark; mod model; mod ops; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod style; mod tools; diff --git a/crates/draw/src/ui/pen/mod.rs b/crates/draw/src/ui/pen/mod.rs index 61395d61a..0924c3783 100644 --- a/crates/draw/src/ui/pen/mod.rs +++ b/crates/draw/src/ui/pen/mod.rs @@ -9,7 +9,7 @@ pub(crate) mod bezier; mod curvature_mode; mod mode; mod options; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod tool; mod words; diff --git a/crates/draw/src/ui/picture_fill/mod.rs b/crates/draw/src/ui/picture_fill/mod.rs index 99f742b10..a1445e5a4 100644 --- a/crates/draw/src/ui/picture_fill/mod.rs +++ b/crates/draw/src/ui/picture_fill/mod.rs @@ -8,7 +8,7 @@ //! ``` mod editor; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/draw/src/ui/shape/mod.rs b/crates/draw/src/ui/shape/mod.rs index 0ccad43ad..7295249bd 100644 --- a/crates/draw/src/ui/shape/mod.rs +++ b/crates/draw/src/ui/shape/mod.rs @@ -15,7 +15,7 @@ mod bar; mod gear; mod mode_select; mod panel; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod stroke_cells; mod words; diff --git a/crates/draw/src/ui/shape_presets.rs b/crates/draw/src/ui/shape_presets.rs index 579b431a7..4595c453c 100644 --- a/crates/draw/src/ui/shape_presets.rs +++ b/crates/draw/src/ui/shape_presets.rs @@ -11,7 +11,7 @@ use craft_ui::style::UiTokens; use egui::{Color32, Mesh, Painter, Pos2, Rect, Shape, Stroke, Ui, pos2}; use kurbo::{BezPath, PathEl}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The error bound, in points, when the glyph's curves are flattened. diff --git a/crates/draw/src/ui/slice/mod.rs b/crates/draw/src/ui/slice/mod.rs index 8ce3f4f59..cc6202f64 100644 --- a/crates/draw/src/ui/slice/mod.rs +++ b/crates/draw/src/ui/slice/mod.rs @@ -38,7 +38,7 @@ use std::sync::Arc; mod bar; mod dialogs; mod overlay; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod tool; mod words; diff --git a/crates/draw/src/ui/stroke/mod.rs b/crates/draw/src/ui/stroke/mod.rs index 7eb02bec6..a5bb3a2a6 100644 --- a/crates/draw/src/ui/stroke/mod.rs +++ b/crates/draw/src/ui/stroke/mod.rs @@ -8,7 +8,7 @@ mod button; mod editor; mod preview; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/draw/src/ui/symmetry/mod.rs b/crates/draw/src/ui/symmetry/mod.rs index a4676ddea..96bf3515d 100644 --- a/crates/draw/src/ui/symmetry/mod.rs +++ b/crates/draw/src/ui/symmetry/mod.rs @@ -9,7 +9,7 @@ mod handles; mod menu; mod model; mod overlay; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod transform; diff --git a/crates/draw/src/ui/transform/session_bar.rs b/crates/draw/src/ui/transform/session_bar.rs index d0d9a8247..150dbd15b 100644 --- a/crates/draw/src/ui/transform/session_bar.rs +++ b/crates/draw/src/ui/transform/session_bar.rs @@ -1,6 +1,6 @@ //! `TransformBar`: the options bar of an open Free Transform session. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use super::session::{TransformEdit, TransformPhase, TransformSession, TransformSettings, TransformWarp}; diff --git a/crates/draw/src/ui/transform/session_overlay.rs b/crates/draw/src/ui/transform/session_overlay.rs index c86781be7..685bc46d7 100644 --- a/crates/draw/src/ui/transform/session_overlay.rs +++ b/crates/draw/src/ui/transform/session_overlay.rs @@ -1,7 +1,7 @@ //! `TransformOverlay`: the open session's box on the canvas, which shows a [`TransformBox`](super::TransformBox) //! and turns its reports into [`TransformEdit`]s, and `TransformTool`: the canvas tool of the open session. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::CancelReason; diff --git a/crates/draw/src/ui/transform/transform_box.rs b/crates/draw/src/ui/transform/transform_box.rs index cc9232870..cbb62d333 100644 --- a/crates/draw/src/ui/transform/transform_box.rs +++ b/crates/draw/src/ui/transform/transform_box.rs @@ -2,7 +2,7 @@ //! corners, edges, reference point, inside and outside are parts in the canvas's arena; the value is the box in //! document units. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::geometry::quad::{self, BoxAllow, BoxDrag, BoxPart, BoxRules, BoxState, ScaleRule, TransformMode}; diff --git a/crates/draw/src/ui/transform/transform_fields.rs b/crates/draw/src/ui/transform/transform_fields.rs index 86c62b5ad..9b620e2f0 100644 --- a/crates/draw/src/ui/transform/transform_fields.rs +++ b/crates/draw/src/ui/transform/transform_fields.rs @@ -1,7 +1,7 @@ //! `TransformFields`: the X, Y, W, H, angle and skew fields of a transform box, as an options-bar strip or a panel's //! rows. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod units; diff --git a/crates/feature-root/Cargo.toml b/crates/feature-root/Cargo.toml index e21c56c8d..3392e7ef4 100644 --- a/crates/feature-root/Cargo.toml +++ b/crates/feature-root/Cargo.toml @@ -31,22 +31,22 @@ workspace = true [dependencies] craft-ui-gallery = { path = "../ui-gallery", default-features = false } # The gallery's optional domain crates, with the gallery's features (`cl doctor` checks that the lists match). -craft-automation = { workspace = true, features = ["screen-testing"] } -craft-browse = { workspace = true, features = ["screen-testing"] } -craft-color-ui = { workspace = true, features = ["screen-testing"] } -craft-draw = { workspace = true, features = ["screen-testing"] } -craft-imaging = { workspace = true, features = ["screen-testing"] } -craft-layers = { workspace = true, features = ["screen-testing"] } -craft-menu = { workspace = true, features = ["screen-testing"] } -craft-pages = { workspace = true, features = ["screen-testing"] } -craft-print = { workspace = true, features = ["screen-testing"] } -craft-review = { workspace = true, features = ["screen-testing"] } -craft-table = { workspace = true, features = ["screen-testing"] } -craft-text = { workspace = true, features = ["screen-testing", "find"] } -craft-theme-store = { workspace = true, features = ["screen-testing"] } -craft-timeline = { workspace = true, features = ["screen-testing", "xml", "otio"] } +craft-automation = { workspace = true, features = ["suite"] } +craft-browse = { workspace = true, features = ["suite"] } +craft-color-ui = { workspace = true, features = ["suite"] } +craft-draw = { workspace = true, features = ["suite"] } +craft-imaging = { workspace = true, features = ["suite"] } +craft-layers = { workspace = true, features = ["suite"] } +craft-menu = { workspace = true, features = ["suite"] } +craft-pages = { workspace = true, features = ["suite"] } +craft-print = { workspace = true, features = ["suite"] } +craft-review = { workspace = true, features = ["suite"] } +craft-table = { workspace = true, features = ["suite"] } +craft-text = { workspace = true, features = ["suite", "find"] } +craft-theme-store = { workspace = true, features = ["suite"] } +craft-timeline = { workspace = true, features = ["suite", "xml", "otio"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -craft-dialogs = { workspace = true, features = ["screen-testing"] } -craft-font-manager = { workspace = true, features = ["screen-testing"] } -craft-update = { workspace = true, features = ["screen-testing"] } +craft-dialogs = { workspace = true, features = ["suite"] } +craft-font-manager = { workspace = true, features = ["suite"] } +craft-update = { workspace = true, features = ["suite"] } diff --git a/crates/font-manager/Cargo.toml b/crates/font-manager/Cargo.toml index c8f5148bc..f3a18f1c6 100644 --- a/crates/font-manager/Cargo.toml +++ b/crates/font-manager/Cargo.toml @@ -12,6 +12,7 @@ repository.workspace = true test = false [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # `FontsPanel`: the whole interface as one egui panel (it builds for the web too), with the picker, the Glyphs panel, the axis sliders and the # Missing Fonts dialog. @@ -40,13 +41,13 @@ log = { version = "0.4", optional = true } skrifa = { version = "0.44", default-features = false, features = ["std"] } [dev-dependencies] -craft-font-manager = { path = ".", features = ["screen-testing"] } +craft-font-manager = { path = ".", features = ["suite"] } [[test]] name = "it" path = "tests/it/main.rs" harness = false -required-features = ["screen-testing"] +required-features = ["suite"] [lints] workspace = true diff --git a/crates/font-manager/src/axes/sliders.rs b/crates/font-manager/src/axes/sliders.rs index 0e09b95af..51ed8904b 100644 --- a/crates/font-manager/src/axes/sliders.rs +++ b/crates/font-manager/src/axes/sliders.rs @@ -1,6 +1,6 @@ //! The row of sliders that edits the axes of a face (Photoshop's Properties › Character axis sliders; FigCraft's axis panel). -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/glyphs.rs b/crates/font-manager/src/glyphs.rs index 0a20f136f..a52059e89 100644 --- a/crates/font-manager/src/glyphs.rs +++ b/crates/font-manager/src/glyphs.rs @@ -2,7 +2,7 @@ //! Currency, ...), a grid of glyph cells drawn by the app's text engine, a zoom slider, and the recently used //! glyphs in a row at the top. Double-click or Enter inserts the glyph where the app can insert. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/lib.rs b/crates/font-manager/src/lib.rs index ce2598faa..ccb334ac7 100644 --- a/crates/font-manager/src/lib.rs +++ b/crates/font-manager/src/lib.rs @@ -40,5 +40,6 @@ pub use panel::{ /// The registered stories and trials of this crate. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/font-manager/src/missing.rs b/crates/font-manager/src/missing.rs index 14c73dd05..45af646b3 100644 --- a/crates/font-manager/src/missing.rs +++ b/crates/font-manager/src/missing.rs @@ -2,7 +2,7 @@ //! are not installed, and the dialog that lists them with a replacement for each (Photoshop's //! "missing fonts" warning on open; VectorCraft's and FigCraft's Document Fonts lists). -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::borrow::Cow; diff --git a/crates/font-manager/src/panel/app.rs b/crates/font-manager/src/panel/app.rs index dc92fc3af..f1b099d91 100644 --- a/crates/font-manager/src/panel/app.rs +++ b/crates/font-manager/src/panel/app.rs @@ -1,7 +1,7 @@ //! The panel's model, what the host calls, and the view: the tabs and search across the top, the filters at the //! reading start, the family cards, the details sheet and the download consent. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::collections::HashMap; diff --git a/crates/font-manager/src/panel/browse.rs b/crates/font-manager/src/panel/browse.rs index d954b2c05..5b31c135a 100644 --- a/crates/font-manager/src/panel/browse.rs +++ b/crates/font-manager/src/panel/browse.rs @@ -1,6 +1,6 @@ //! The tabs and search, the filters, the sample toolbar and the list of family cards. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod cards; diff --git a/crates/font-manager/src/panel/details.rs b/crates/font-manager/src/panel/details.rs index c47105448..36592c7e0 100644 --- a/crates/font-manager/src/panel/details.rs +++ b/crates/font-manager/src/panel/details.rs @@ -2,7 +2,7 @@ //! installing or removing it whole or a style at a time. mod rows; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/panel/sources.rs b/crates/font-manager/src/panel/sources.rs index e46f24eeb..450b1cbe7 100644 --- a/crates/font-manager/src/panel/sources.rs +++ b/crates/font-manager/src/panel/sources.rs @@ -2,7 +2,7 @@ //! added (never curated, and flagged when their file changed since it was added), adding one, //! and downloading them all again. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/panel/specimen.rs b/crates/font-manager/src/panel/specimen.rs index 83e1181d9..85cfe0dbf 100644 --- a/crates/font-manager/src/panel/specimen.rs +++ b/crates/font-manager/src/panel/specimen.rs @@ -12,7 +12,7 @@ use crate::Catalog; use crate::FaceInfo; use crate::panel::faces::{self, Owner, Shown}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The ink of a sample: the text colour for a face that drew, the muted one for the interface face standing in. diff --git a/crates/font-manager/src/picker.rs b/crates/font-manager/src/picker.rs index 3e4c413a0..5a9f6c91c 100644 --- a/crates/font-manager/src/picker.rs +++ b/crates/font-manager/src/picker.rs @@ -5,7 +5,7 @@ mod rank; mod rows; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/imaging/Cargo.toml b/crates/imaging/Cargo.toml index 5ae89a619..92e2f5aae 100644 --- a/crates/imaging/Cargo.toml +++ b/crates/imaging/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The editing widgets (`craft_imaging::ui`). ui = ["craft-color-ui/ui", "dep:serde_json", "dep:craft-behavior", "dep:craft-keymap", "dep:craft-ui", "dep:egui", "dep:kurbo"] @@ -37,7 +38,7 @@ serde = { workspace = true } serde_json = { workspace = true, optional = true } [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } egui = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] diff --git a/crates/imaging/src/lib.rs b/crates/imaging/src/lib.rs index 52bc4632b..8e5016486 100644 --- a/crates/imaging/src/lib.rs +++ b/crates/imaging/src/lib.rs @@ -16,6 +16,7 @@ pub mod wide_angle; /// The registered stories and suite cases of the widgets, for `tests/it`. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/imaging/src/ui/adjust/basic.rs b/crates/imaging/src/ui/adjust/basic.rs index 543bb9223..a8143b3c5 100644 --- a/crates/imaging/src/ui/adjust/basic.rs +++ b/crates/imaging/src/ui/adjust/basic.rs @@ -3,7 +3,7 @@ mod brightness_contrast; mod color_balance; mod photo_filter; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod threshold; diff --git a/crates/imaging/src/ui/adjust/curves_panel.rs b/crates/imaging/src/ui/adjust/curves_panel.rs index f01d19b13..2e6ce2d83 100644 --- a/crates/imaging/src/ui/adjust/curves_panel.rs +++ b/crates/imaging/src/ui/adjust/curves_panel.rs @@ -3,7 +3,7 @@ //! and the hint line; and the ⌘/Ctrl-click-on-the-image helper //! ([`CurvesPanel::add_point_from_sample`]). -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/imaging/src/ui/adjust/hue_saturation.rs b/crates/imaging/src/ui/adjust/hue_saturation.rs index 82f81bc04..2ae72ba3d 100644 --- a/crates/imaging/src/ui/adjust/hue_saturation.rs +++ b/crates/imaging/src/ui/adjust/hue_saturation.rs @@ -1,7 +1,7 @@ //! [`HueSaturationEditor`]: Master and six colour ranges, Colorize, the two spectrum bars and the four range thumbs //! that wrap at 360°. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::Mixed; diff --git a/crates/imaging/src/ui/adjust/levels_editor.rs b/crates/imaging/src/ui/adjust/levels_editor.rs index 26c3762d3..10988ddf7 100644 --- a/crates/imaging/src/ui/adjust/levels_editor.rs +++ b/crates/imaging/src/ui/adjust/levels_editor.rs @@ -1,7 +1,7 @@ //! [`LevelsEditor`]: a levels adjustment's histogram, input thumbs and fields, output bar, thumbs //! and fields, editing one channel's [`Levels`]. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::ops::RangeInclusive; diff --git a/crates/imaging/src/ui/adjust/levels_panel.rs b/crates/imaging/src/ui/adjust/levels_panel.rs index 62951796c..e381f24b5 100644 --- a/crates/imaging/src/ui/adjust/levels_panel.rs +++ b/crates/imaging/src/ui/adjust/levels_panel.rs @@ -1,7 +1,7 @@ //! [`LevelsPanel`]: the Levels adjustment around the [`LevelsEditor`]: the point pickers, the //! Channel select, Auto and the editor over the shown channel's histogram. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/imaging/src/ui/adjust/mixers.rs b/crates/imaging/src/ui/adjust/mixers.rs index 97bbef63b..53cba62db 100644 --- a/crates/imaging/src/ui/adjust/mixers.rs +++ b/crates/imaging/src/ui/adjust/mixers.rs @@ -3,7 +3,7 @@ mod black_white; mod channel_mixer; mod selective_color; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use black_white::{BlackWhite, BlackWhiteEditor, BlackWhiteOutput}; diff --git a/crates/imaging/src/ui/adjust/panel.rs b/crates/imaging/src/ui/adjust/panel.rs index cce9abba3..73b8687d5 100644 --- a/crates/imaging/src/ui/adjust/panel.rs +++ b/crates/imaging/src/ui/adjust/panel.rs @@ -1,6 +1,6 @@ //! [`AdjustmentsPanel`]: the grid of adjustment buttons a document panel offers for adding an adjustment layer. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{Metrics, NavShape, Roving, Sense}; diff --git a/crates/imaging/src/ui/adjust/session.rs b/crates/imaging/src/ui/adjust/session.rs index 039a312dd..5d1664960 100644 --- a/crates/imaging/src/ui/adjust/session.rs +++ b/crates/imaging/src/ui/adjust/session.rs @@ -1,7 +1,7 @@ //! [`AdjustSession`]: the Properties panel's memory of the settings it found on an adjustment //! layer, so Reset returns to them once the user edited. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The settings an adjustment layer had when the Properties panel started showing it, and whether diff --git a/crates/imaging/src/ui/adjust/sliders.rs b/crates/imaging/src/ui/adjust/sliders.rs index 9ec8dcd6b..ceb9a2357 100644 --- a/crates/imaging/src/ui/adjust/sliders.rs +++ b/crates/imaging/src/ui/adjust/sliders.rs @@ -5,7 +5,7 @@ //! rows' edits are lifted onto the editor's value ([`Run`]), so one slider drag, one typed number or one reset is one //! gesture of the whole value. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::ops::RangeInclusive; diff --git a/crates/imaging/src/ui/adjust/tone.rs b/crates/imaging/src/ui/adjust/tone.rs index 711bdd0dc..5ffd10e66 100644 --- a/crates/imaging/src/ui/adjust/tone.rs +++ b/crates/imaging/src/ui/adjust/tone.rs @@ -5,7 +5,7 @@ //! The library reports the sample; turning it into a Levels or Curves value needs the document's //! colour management and mode, so the app does that, as with the Eyedropper. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{CancelReason, Cursor, IconId, PaintedCursor}; diff --git a/crates/imaging/src/ui/blur_pins/mod.rs b/crates/imaging/src/ui/blur_pins/mod.rs index ff5c99259..df9271b5f 100644 --- a/crates/imaging/src/ui/blur_pins/mod.rs +++ b/crates/imaging/src/ui/blur_pins/mod.rs @@ -20,7 +20,7 @@ mod grab; mod model; mod overlay; mod panel; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod style; mod words; diff --git a/crates/imaging/src/ui/channels/mod.rs b/crates/imaging/src/ui/channels/mod.rs index 12272b4c5..15ce167df 100644 --- a/crates/imaging/src/ui/channels/mod.rs +++ b/crates/imaging/src/ui/channels/mod.rs @@ -7,7 +7,7 @@ mod menu; mod model; mod panel; mod rows; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; pub use footer::ChannelsFooterButton; diff --git a/crates/imaging/src/ui/color_range/mod.rs b/crates/imaging/src/ui/color_range/mod.rs index 4cae58410..05b693a7f 100644 --- a/crates/imaging/src/ui/color_range/mod.rs +++ b/crates/imaging/src/ui/color_range/mod.rs @@ -13,7 +13,7 @@ mod dialog; mod hosted; mod labels; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod value; diff --git a/crates/imaging/src/ui/curve/mod.rs b/crates/imaging/src/ui/curve/mod.rs index 8ecb410ac..b8cf17175 100644 --- a/crates/imaging/src/ui/curve/mod.rs +++ b/crates/imaging/src/ui/curve/mod.rs @@ -5,7 +5,7 @@ mod graph; mod model; mod preview; mod ramp; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/imaging/src/ui/fill/mod.rs b/crates/imaging/src/ui/fill/mod.rs index 7653eea8d..b11ab1485 100644 --- a/crates/imaging/src/ui/fill/mod.rs +++ b/crates/imaging/src/ui/fill/mod.rs @@ -29,7 +29,7 @@ mod overlay; mod panel; mod preview_pane; mod session; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod tool; mod words; diff --git a/crates/imaging/src/ui/filter_gallery/mod.rs b/crates/imaging/src/ui/filter_gallery/mod.rs index 1452e91ed..7a40b878d 100644 --- a/crates/imaging/src/ui/filter_gallery/mod.rs +++ b/crates/imaging/src/ui/filter_gallery/mod.rs @@ -24,7 +24,7 @@ mod catalog; mod parameters; mod session; mod stack; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod tree; mod words; diff --git a/crates/imaging/src/ui/histogram/mod.rs b/crates/imaging/src/ui/histogram/mod.rs index ab2799cf6..e8b9d7773 100644 --- a/crates/imaging/src/ui/histogram/mod.rs +++ b/crates/imaging/src/ui/histogram/mod.rs @@ -8,7 +8,7 @@ mod data; pub mod paint; mod plot; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/imaging/src/ui/layer_style/blend_if/mod.rs b/crates/imaging/src/ui/layer_style/blend_if/mod.rs index 21d6a8f8f..5a9998901 100644 --- a/crates/imaging/src/ui/layer_style/blend_if/mod.rs +++ b/crates/imaging/src/ui/layer_style/blend_if/mod.rs @@ -1,6 +1,6 @@ //! `BlendIfBar`: one Blend If slider (This Layer or Underlying Layer) with its four handles, over `ThumbRow`. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{EditEvents, Mixed}; diff --git a/crates/imaging/src/ui/layer_style/contour/mod.rs b/crates/imaging/src/ui/layer_style/contour/mod.rs index c9f7914f5..f99b6cc03 100644 --- a/crates/imaging/src/ui/layer_style/contour/mod.rs +++ b/crates/imaging/src/ui/layer_style/contour/mod.rs @@ -2,7 +2,7 @@ //! the contour as a curve. mod editor; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/imaging/src/ui/layer_style/mod.rs b/crates/imaging/src/ui/layer_style/mod.rs index ecaa2ceea..87d3b8f7d 100644 --- a/crates/imaging/src/ui/layer_style/mod.rs +++ b/crates/imaging/src/ui/layer_style/mod.rs @@ -30,7 +30,7 @@ mod hosted; mod labels; mod list; mod page; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod styles; diff --git a/crates/imaging/src/ui/liquify/mod.rs b/crates/imaging/src/ui/liquify/mod.rs index b0346aebf..8da163f54 100644 --- a/crates/imaging/src/ui/liquify/mod.rs +++ b/crates/imaging/src/ui/liquify/mod.rs @@ -48,7 +48,7 @@ mod canvas; mod commands; mod panel; mod session; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod tools; mod words; diff --git a/crates/imaging/src/ui/mask_view/mod.rs b/crates/imaging/src/ui/mask_view/mod.rs index a4ad4e47f..60dea75ba 100644 --- a/crates/imaging/src/ui/mask_view/mod.rs +++ b/crates/imaging/src/ui/mask_view/mod.rs @@ -23,7 +23,7 @@ mod controls; mod keys; mod state; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; pub use controls::{MaskViewControls, MaskViewControlsOutput}; diff --git a/crates/imaging/src/ui/raw_develop/mod.rs b/crates/imaging/src/ui/raw_develop/mod.rs index 06f209fbd..0011b018c 100644 --- a/crates/imaging/src/ui/raw_develop/mod.rs +++ b/crates/imaging/src/ui/raw_develop/mod.rs @@ -19,7 +19,7 @@ mod mixer; mod preview; mod scopes; mod source; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/imaging/src/ui/scopes/mod.rs b/crates/imaging/src/ui/scopes/mod.rs index eff571c3e..f22787f55 100644 --- a/crates/imaging/src/ui/scopes/mod.rs +++ b/crates/imaging/src/ui/scopes/mod.rs @@ -28,7 +28,7 @@ mod clipping; mod menu; mod panel; mod plot; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod vectorscope; mod words; diff --git a/crates/imaging/src/ui/select/mod.rs b/crates/imaging/src/ui/select/mod.rs index 780ddceeb..ca49a38e4 100644 --- a/crates/imaging/src/ui/select/mod.rs +++ b/crates/imaging/src/ui/select/mod.rs @@ -55,7 +55,7 @@ mod lasso; mod magnetic; mod marquee; mod polygon; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; pub mod operations; diff --git a/crates/imaging/src/ui/select_mask/mod.rs b/crates/imaging/src/ui/select_mask/mod.rs index 4982a9b00..a58118f9c 100644 --- a/crates/imaging/src/ui/select_mask/mod.rs +++ b/crates/imaging/src/ui/select_mask/mod.rs @@ -43,7 +43,7 @@ mod commands; mod edits; mod panel; mod session; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod tools; mod words; diff --git a/crates/imaging/src/ui/selection/mod.rs b/crates/imaging/src/ui/selection/mod.rs index 96bab02a5..968b5d00c 100644 --- a/crates/imaging/src/ui/selection/mod.rs +++ b/crates/imaging/src/ui/selection/mod.rs @@ -10,7 +10,7 @@ //! [`QuickMaskLook`]: crate::selection::QuickMaskLook mod overlay; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; pub use overlay::{OutlineSource, PointMap, SelectionOverlay, SelectionOverlayOutput, SelectionWords}; diff --git a/crates/imaging/src/ui/transform_preview/mod.rs b/crates/imaging/src/ui/transform_preview/mod.rs index d89c55877..3c2af1c32 100644 --- a/crates/imaging/src/ui/transform_preview/mod.rs +++ b/crates/imaging/src/ui/transform_preview/mod.rs @@ -20,7 +20,7 @@ //! ``` mod maps; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod styled; mod textures; diff --git a/crates/imaging/src/ui/vanishing_point/mod.rs b/crates/imaging/src/ui/vanishing_point/mod.rs index 507b004ba..c7f0bc264 100644 --- a/crates/imaging/src/ui/vanishing_point/mod.rs +++ b/crates/imaging/src/ui/vanishing_point/mod.rs @@ -27,7 +27,7 @@ mod draw; mod editor; mod new_plane; mod planes; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod style; mod words; diff --git a/crates/imaging/src/ui/warp/cylinder.rs b/crates/imaging/src/ui/warp/cylinder.rs index c5b29e473..db96973c6 100644 --- a/crates/imaging/src/ui/warp/cylinder.rs +++ b/crates/imaging/src/ui/warp/cylinder.rs @@ -21,7 +21,7 @@ use egui::{CornerRadius, Pos2, Rect, Response, Vec2}; use super::WarpMesh; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The bend of both arcs the Cylinder starts with, in units of the half axis: about a quarter of the width. diff --git a/crates/imaging/src/ui/warp/mod.rs b/crates/imaging/src/ui/warp/mod.rs index 32987fa8a..c63d5630d 100644 --- a/crates/imaging/src/ui/warp/mod.rs +++ b/crates/imaging/src/ui/warp/mod.rs @@ -12,7 +12,7 @@ mod mesh; mod model; pub mod perspective; pub mod pin; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use cylinder::{CylinderHandle, CylinderValues, CylinderWarp, CylinderWarpOutput, CylinderWarpStyle}; diff --git a/crates/imaging/src/ui/warp/perspective/mod.rs b/crates/imaging/src/ui/warp/perspective/mod.rs index 585877dcd..6f9ada6b8 100644 --- a/crates/imaging/src/ui/warp/perspective/mod.rs +++ b/crates/imaging/src/ui/warp/perspective/mod.rs @@ -5,7 +5,7 @@ mod bar; mod overlay; mod session; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; pub use bar::{PerspectiveBar, PerspectiveBarOutput, PerspectiveBarWords}; diff --git a/crates/imaging/src/ui/warp/pin/mod.rs b/crates/imaging/src/ui/warp/pin/mod.rs index a0fc21393..2cbd631d5 100644 --- a/crates/imaging/src/ui/warp/pin/mod.rs +++ b/crates/imaging/src/ui/warp/pin/mod.rs @@ -5,7 +5,7 @@ mod bar; mod overlay; mod session; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; pub use bar::{PinWarpBar, PinWarpBarOutput, PinWarpBarWords}; diff --git a/crates/imaging/src/ui/wide_angle/mod.rs b/crates/imaging/src/ui/wide_angle/mod.rs index 34df37299..19ed8ced1 100644 --- a/crates/imaging/src/ui/wide_angle/mod.rs +++ b/crates/imaging/src/ui/wide_angle/mod.rs @@ -18,7 +18,7 @@ mod commands; mod lines; mod panel; mod session; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; mod tool; mod words; diff --git a/crates/layers/Cargo.toml b/crates/layers/Cargo.toml index f3d58a9d1..eede73357 100644 --- a/crates/layers/Cargo.toml +++ b/crates/layers/Cargo.toml @@ -16,8 +16,9 @@ workspace = true # UI-only: egui and craft-ui are plain dependencies, so there is no `ui` feature. [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] -# The stories, `mock` and the integration tests (`tests/it`). +# The test kit and `mock` helpers. screen-testing = ["craft-ui/testing"] [dependencies] @@ -37,4 +38,4 @@ serde_json = { workspace = true } name = "it" path = "tests/it/main.rs" harness = false -required-features = ["screen-testing"] +required-features = ["suite"] diff --git a/crates/layers/src/lib.rs b/crates/layers/src/lib.rs index 1881cc192..a283d7986 100644 --- a/crates/layers/src/lib.rs +++ b/crates/layers/src/lib.rs @@ -17,6 +17,8 @@ pub mod testing { use egui::accesskit::NodeId; use egui::{Context, Rect}; + #[cfg(feature = "suite")] + craft_ui::testing_registered!(); /// The rect of the thumbnail that shows `part` of the layer `info`, in the row whose node is `row`, as the row diff --git a/crates/layers/src/ui/comps/mod.rs b/crates/layers/src/ui/comps/mod.rs index 122a463a6..768bd8b6e 100644 --- a/crates/layers/src/ui/comps/mod.rs +++ b/crates/layers/src/ui/comps/mod.rs @@ -3,7 +3,7 @@ mod body; mod events; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/layers/src/ui/filter/mod.rs b/crates/layers/src/ui/filter/mod.rs index 09566dff0..1851e2a47 100644 --- a/crates/layers/src/ui/filter/mod.rs +++ b/crates/layers/src/ui/filter/mod.rs @@ -5,7 +5,7 @@ //! plain code, so a host's control channel can read and set the criteria (PhotoCraft's //! `ui.set layerFilter {by, kinds, name, effect, mode, attribute, color, smart}`) without the panel. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{EditEvent, IconId, Mixed, SelectionChange}; diff --git a/crates/layers/src/ui/options/mod.rs b/crates/layers/src/ui/options/mod.rs index 9511e2752..852c60cf9 100644 --- a/crates/layers/src/ui/options/mod.rs +++ b/crates/layers/src/ui/options/mod.rs @@ -3,7 +3,7 @@ //! `LayersSettings` is the panel's persisted section (`.settings(&mut ..)` on the panel); //! `LayersOptions` is the value the dialog edits and returns, held by the settings. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_ui::choice::{Checkbox, Radio, RadioGroup}; diff --git a/crates/layers/src/ui/panel/mod.rs b/crates/layers/src/ui/panel/mod.rs index 1402b2661..3956f91a6 100644 --- a/crates/layers/src/ui/panel/mod.rs +++ b/crates/layers/src/ui/panel/mod.rs @@ -11,7 +11,7 @@ mod events; mod footer; mod menu; mod row; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use drag::{LayersDrag, document_hash}; diff --git a/crates/layers/src/ui/rows/mod.rs b/crates/layers/src/ui/rows/mod.rs index 71d97e9e5..b1861f45f 100644 --- a/crates/layers/src/ui/rows/mod.rs +++ b/crates/layers/src/ui/rows/mod.rs @@ -1,6 +1,6 @@ //! `BlendRows`: Blend mode, Opacity, Lock and Fill as one block. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{EditEvent, EditEvents, IconId}; diff --git a/crates/menu/Cargo.toml b/crates/menu/Cargo.toml index df82fa938..017db5b2a 100644 --- a/crates/menu/Cargo.toml +++ b/crates/menu/Cargo.toml @@ -25,6 +25,7 @@ serde = { workspace = true } serde_json = { workspace = true } [features] +suite = ["screen-testing", "craft-ui/suite"] screen-testing = ["craft-ui/testing"] [dev-dependencies] @@ -35,7 +36,7 @@ egui = { workspace = true } name = "it" path = "tests/it/main.rs" harness = false -required-features = ["screen-testing"] +required-features = ["suite"] # AppKit end to end: runs on the main thread, so no harness; on other platforms it does nothing. [[test]] diff --git a/crates/menu/src/bar.rs b/crates/menu/src/bar.rs index 3907b35de..1a483d8f0 100644 --- a/crates/menu/src/bar.rs +++ b/crates/menu/src/bar.rs @@ -8,7 +8,7 @@ //! choice reaches the app as a fired command with [`craft_ui::runtime::commands::FireSource::Menu`]. //! `Builtin::Quit` and `Builtin::Minimize` act on the root window through the runtime. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_keymap::{CommandRef, Platform}; diff --git a/crates/menu/src/lib.rs b/crates/menu/src/lib.rs index 086baa59c..923c92cf8 100644 --- a/crates/menu/src/lib.rs +++ b/crates/menu/src/lib.rs @@ -131,5 +131,6 @@ pub use theme::{THEME_COMMAND, ThemeChoice, ThemeLabels, ThemeMenu, ThemeRow}; #[cfg(feature = "screen-testing")] /// The stories and words this crate registers, for the story tests. pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/menu/src/shortcuts/mod.rs b/crates/menu/src/shortcuts/mod.rs index 6c08bb9d3..d68bc0e21 100644 --- a/crates/menu/src/shortcuts/mod.rs +++ b/crates/menu/src/shortcuts/mod.rs @@ -110,7 +110,7 @@ mod review; mod rows; mod sets; mod state; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub mod summary; mod view; diff --git a/crates/menu/src/shortcuts/recorder.rs b/crates/menu/src/shortcuts/recorder.rs index affa21849..f00a71a0c 100644 --- a/crates/menu/src/shortcuts/recorder.rs +++ b/crates/menu/src/shortcuts/recorder.rs @@ -17,7 +17,7 @@ use craft_ui::runtime::focus::{self, FocusTarget, KeepKeys, KeyUse}; use craft_ui::style::{ComponentStyle, FocusLook, Ink, StyleCx, SurfaceKind, SurfaceLook, TextLook, TypeRole}; use egui::{Rect, Response, Ui, Vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The field claims bare Escape while recording, so it reaches the field as a chord (the keymap's recorder reads it as diff --git a/crates/menu/src/shortcuts/view.rs b/crates/menu/src/shortcuts/view.rs index cbb4858d7..66eb2fe12 100644 --- a/crates/menu/src/shortcuts/view.rs +++ b/crates/menu/src/shortcuts/view.rs @@ -7,7 +7,7 @@ mod bars; mod detail; mod header; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod table; diff --git a/crates/pages/Cargo.toml b/crates/pages/Cargo.toml index 3bce55f00..56e4703e0 100644 --- a/crates/pages/Cargo.toml +++ b/crates/pages/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The page widgets (`craft_pages::ui`), on craft-ui. ui = ["dep:craft-behavior", "dep:craft-ui", "dep:craft-theme", "dep:egui"] @@ -34,6 +35,6 @@ craft-theme = { workspace = true, optional = true } egui = { workspace = true, optional = true } [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } egui = { workspace = true } craft-i18n = { workspace = true } diff --git a/crates/pages/src/lib.rs b/crates/pages/src/lib.rs index b369fa26f..f9b94f692 100644 --- a/crates/pages/src/lib.rs +++ b/crates/pages/src/lib.rs @@ -42,6 +42,7 @@ pub use setup::{MARGIN_PRESETS, MarginPreset, Margins, Orientation, PAPER_SIZES, /// The stories and trials this crate registers. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/pages/src/ui/column_bar.rs b/crates/pages/src/ui/column_bar.rs index 13fb5497a..64b4ec37d 100644 --- a/crates/pages/src/ui/column_bar.rs +++ b/crates/pages/src/ui/column_bar.rs @@ -2,7 +2,7 @@ //! column widths. A divider moves only the two columns it divides (`craft_behavior::divider`, `Give::Pair`); each keeps //! its least share, and the other columns keep theirs. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::divider::{Give, Segment, resize, travel}; diff --git a/crates/pages/src/ui/grid.rs b/crates/pages/src/ui/grid.rs index 063bee593..c434aef53 100644 --- a/crates/pages/src/ui/grid.rs +++ b/crates/pages/src/ui/grid.rs @@ -2,7 +2,7 @@ //! boundaries (violet) and the baseline grid (light blue, from its zoom threshold) are hairlines drawn over the //! pages, under the selection. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use super::view::PlacedPage; diff --git a/crates/pages/src/ui/header_footer.rs b/crates/pages/src/ui/header_footer.rs index 52611db91..b079bd2e4 100644 --- a/crates/pages/src/ui/header_footer.rs +++ b/crates/pages/src/ui/header_footer.rs @@ -3,7 +3,7 @@ //! empty, a double click (or Enter on the focused section) starts editing it, and the app's editor takes the section's //! rectangle. What a section holds, its fields and the editor are the app's. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::kurbo::Point; diff --git a/crates/pages/src/ui/list.rs b/crates/pages/src/ui/list.rs index b6498c983..5d192e127 100644 --- a/crates/pages/src/ui/list.rs +++ b/crates/pages/src/ui/list.rs @@ -20,7 +20,7 @@ //! } //! ``` -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{ColumnKey, ColumnWidth, EditEvent, IconId, Mixed, Selection, SelectionChange, keyed}; diff --git a/crates/pages/src/ui/margins.rs b/crates/pages/src/ui/margins.rs index cc1f8a6f0..f204ac92f 100644 --- a/crates/pages/src/ui/margins.rs +++ b/crates/pages/src/ui/margins.rs @@ -2,7 +2,7 @@ //! each ruler is the margin, the white the text area; the pointer over an edge shows a resize cursor and the margin's //! name, and a drag moves the margin as one edit gesture (one undo step). -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::ops::RangeInclusive; diff --git a/crates/pages/src/ui/marks.rs b/crates/pages/src/ui/marks.rs index da2516dc0..af7dc43b4 100644 --- a/crates/pages/src/ui/marks.rs +++ b/crates/pages/src/ui/marks.rs @@ -3,7 +3,7 @@ //! ° no-break spaces, ¶ paragraph ends, # the end of a story. Extras: the overset mark (a red + in the out port) on a //! frame whose story does not fit, and frame outlines with their in and out ports. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::kurbo::{Point, Rect}; diff --git a/crates/pages/src/ui/preview.rs b/crates/pages/src/ui/preview.rs index 9c0736c42..ae75489ee 100644 --- a/crates/pages/src/ui/preview.rs +++ b/crates/pages/src/ui/preview.rs @@ -2,7 +2,7 @@ //! Files preview and VectorCraft's Place PDF page choice show it: the page as large as fits, "Page 3 of 12" under it, //! the arrow and Page keys to step from anywhere in the preview, Escape or Close to leave. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use super::view::PageSource; diff --git a/crates/pages/src/ui/range.rs b/crates/pages/src/ui/range.rs index 413656d2f..7dc4dfd92 100644 --- a/crates/pages/src/ui/range.rs +++ b/crates/pages/src/ui/range.rs @@ -2,7 +2,7 @@ //! page choices, showing the pages back in the same format; and `PageRangeOptions`, the All pages / Pages from-to / Subset rows of //! Acrobat's Page Range Options. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{Codec, NotAValue, NumberCodec}; diff --git a/crates/pages/src/ui/reading.rs b/crates/pages/src/ui/reading.rs index 122fa690f..6ca523173 100644 --- a/crates/pages/src/ui/reading.rs +++ b/crates/pages/src/ui/reading.rs @@ -22,7 +22,7 @@ use egui::{CornerRadius, Pos2, Rect, Response, Ui, Vec2, pos2, vec2}; use super::view::PageSource; use crate::layout::SCREEN_POINTS_PER_POINT; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The page-turn parts: one over each gap between the columns and one over each side margin, indexed from the left. diff --git a/crates/pages/src/ui/setup.rs b/crates/pages/src/ui/setup.rs index 3eb897549..e2b60b4e8 100644 --- a/crates/pages/src/ui/setup.rs +++ b/crates/pages/src/ui/setup.rs @@ -8,7 +8,7 @@ //! if let Some(choice) = PageLayoutMenus::new(&doc.page_setup()).unit(prefs.unit).margins(ui, &margins_button) { doc.apply(choice) } //! ``` -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::ops::RangeInclusive; diff --git a/crates/pages/src/ui/table/mod.rs b/crates/pages/src/ui/table/mod.rs index a69f17f02..04eab7759 100644 --- a/crates/pages/src/ui/table/mod.rs +++ b/crates/pages/src/ui/table/mod.rs @@ -6,7 +6,7 @@ pub mod edges; pub mod properties; pub mod selection; pub mod size_picker; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use edges::{BorderEdges, BorderPreset, EdgeKey, EdgePicker, EdgePickerStyle, EdgePickerWords}; diff --git a/crates/pages/src/ui/text_selection.rs b/crates/pages/src/ui/text_selection.rs index d8b60b164..422891087 100644 --- a/crates/pages/src/ui/text_selection.rs +++ b/crates/pages/src/ui/text_selection.rs @@ -17,7 +17,7 @@ use egui::{CornerRadius, Pos2, Response, Vec2, pos2}; use super::view::PlacedPage; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// A page's text as the selection reads it, glyph by glyph in reading order. Rectangles are page points (origin diff --git a/crates/pages/src/ui/thumbnails.rs b/crates/pages/src/ui/thumbnails.rs index 2f5e54fbe..d45ce5015 100644 --- a/crates/pages/src/ui/thumbnails.rs +++ b/crates/pages/src/ui/thumbnails.rs @@ -20,7 +20,7 @@ //! } //! ``` -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use super::view::PageSource; diff --git a/crates/pages/src/ui/view.rs b/crates/pages/src/ui/view.rs index 478ecd3b9..b9893ff3b 100644 --- a/crates/pages/src/ui/view.rs +++ b/crates/pages/src/ui/view.rs @@ -19,7 +19,7 @@ //! ``` mod pictures; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use self::pictures::{PageMetrics, PagePictures}; diff --git a/crates/print/Cargo.toml b/crates/print/Cargo.toml index a3a14b1b8..347de2d6b 100644 --- a/crates/print/Cargo.toml +++ b/crates/print/Cargo.toml @@ -14,6 +14,7 @@ autotests = false harness = false [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The printer and job settings widgets (`craft_print::ui`). ui = ["dep:craft-behavior", "dep:craft-ui", "dep:egui", "dep:serde_json"] @@ -65,7 +66,7 @@ roxmltree = "0.21" miniz_oxide = "0.9" [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } tempfile = "3" roxmltree = "0.21" miniz_oxide = "0.9" diff --git a/crates/print/src/lib.rs b/crates/print/src/lib.rs index 356d3f7c9..05c6c287b 100644 --- a/crates/print/src/lib.rs +++ b/crates/print/src/lib.rs @@ -39,6 +39,7 @@ pub mod ui; /// The registrations of this crate's UI types, for its integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/print/src/ui/mod.rs b/crates/print/src/ui/mod.rs index 5ee97c047..e3033f364 100644 --- a/crates/print/src/ui/mod.rs +++ b/crates/print/src/ui/mod.rs @@ -3,7 +3,7 @@ mod dialog; mod panel; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use dialog::{HostedPrint, PrintAnswer, PrintDialog, PrintDialogOutput, PrintDialogWords, PrintFinish, PrintMarks, PrintSection, PrintSheet}; diff --git a/crates/review/Cargo.toml b/crates/review/Cargo.toml index ec5db4281..08fb97f3d 100644 --- a/crates/review/Cargo.toml +++ b/crates/review/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The review widgets (`craft_review::ui`). ui = ["dep:craft-keymap", "dep:craft-ui", "dep:craft-host", "dep:craft-theme", "dep:egui", "dep:image"] @@ -36,6 +37,6 @@ kurbo = { workspace = true, features = ["serde"] } serde = { workspace = true } [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } egui = { workspace = true } serde_json = { workspace = true } diff --git a/crates/review/src/lib.rs b/crates/review/src/lib.rs index c27a790fd..22379b114 100644 --- a/crates/review/src/lib.rs +++ b/crates/review/src/lib.rs @@ -20,6 +20,7 @@ pub mod ui; /// The stories and word sets the integration tests register. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/review/src/ui/annotate.rs b/crates/review/src/ui/annotate.rs index 7472397a7..559fdb29f 100644 --- a/crates/review/src/ui/annotate.rs +++ b/crates/review/src/ui/annotate.rs @@ -1,7 +1,7 @@ //! The annotation tool on the canvas, the overlay that draws annotations, and the toolbar. mod overlay; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod tool; mod toolbar; diff --git a/crates/review/src/ui/avatar.rs b/crates/review/src/ui/avatar.rs index 567ccce63..696b38fd5 100644 --- a/crates/review/src/ui/avatar.rs +++ b/crates/review/src/ui/avatar.rs @@ -9,7 +9,7 @@ use egui::{Color32, Rect, Response, Vec2}; use crate::collab::initials; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// Paints a round face filling `rect`: `fill` with the initials of `name` centred on it, in the ink that reads on `fill`. diff --git a/crates/review/src/ui/chat.rs b/crates/review/src/ui/chat.rs index 5afeb7313..ba07516af 100644 --- a/crates/review/src/ui/chat.rs +++ b/crates/review/src/ui/chat.rs @@ -14,7 +14,7 @@ use egui::{Color32, CornerRadius, Pos2, Rect, Response, Ui, Vec2}; use crate::collab::CollabRequest; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/review/src/ui/comments.rs b/crates/review/src/ui/comments.rs index b6eabc76a..627550981 100644 --- a/crates/review/src/ui/comments.rs +++ b/crates/review/src/ui/comments.rs @@ -14,7 +14,7 @@ mod list; mod menus; mod row; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::collections::BTreeMap; diff --git a/crates/review/src/ui/join.rs b/crates/review/src/ui/join.rs index 78b8a6119..fdfacbcc0 100644 --- a/crates/review/src/ui/join.rs +++ b/crates/review/src/ui/join.rs @@ -12,7 +12,7 @@ use egui::{Response, Ui}; use crate::collab::{CollabRequest, CollabTransport, JoinState}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/review/src/ui/presence.rs b/crates/review/src/ui/presence.rs index f229a24ad..a20e7ec69 100644 --- a/crates/review/src/ui/presence.rs +++ b/crates/review/src/ui/presence.rs @@ -22,7 +22,7 @@ use super::avatar::Avatar; use super::chat::{BubbleLook, paint_chat_bubble}; use crate::collab::{CHAT_FADE_S, CHAT_HOLD_S, CollabRequest, CollabTransport, Participant, ParticipantId, chat_alpha}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// Most selection outlines drawn for one person. diff --git a/crates/review/src/ui/revisions.rs b/crates/review/src/ui/revisions.rs index 7d74a3662..b7cba275c 100644 --- a/crates/review/src/ui/revisions.rs +++ b/crates/review/src/ui/revisions.rs @@ -16,7 +16,7 @@ use egui::{CornerRadius, Response, Ui, Vec2}; use crate::revisions::{Revision, RevisionAction, RevisionKind}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The detail lines a card shows. diff --git a/crates/review/src/ui/signature.rs b/crates/review/src/ui/signature.rs index 217b6aad8..7155eeff3 100644 --- a/crates/review/src/ui/signature.rs +++ b/crates/review/src/ui/signature.rs @@ -28,7 +28,7 @@ use egui::{ColorImage, Pos2, Rect, Vec2}; use crate::signature::{MAX_IMAGE_BYTES, MAX_IMAGE_SIDE, MAX_SIGNATURE_CHARS, SavedSignature, SignatureDraft, SignatureImage, SignatureTab}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The pad's width over its height. diff --git a/crates/review/src/ui/thread.rs b/crates/review/src/ui/thread.rs index 6687ef653..25ae66c4d 100644 --- a/crates/review/src/ui/thread.rs +++ b/crates/review/src/ui/thread.rs @@ -8,7 +8,7 @@ mod mention; mod pins; mod popover; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use mention::{insert_mention, mention_matches, mention_query}; diff --git a/crates/review/src/ui/versions.rs b/crates/review/src/ui/versions.rs index bcd7877d1..2844b6a4c 100644 --- a/crates/review/src/ui/versions.rs +++ b/crates/review/src/ui/versions.rs @@ -29,7 +29,7 @@ use crate::versions::{Branch, BranchId, BranchState, HistoryRow, Version, Versio /// The most lines of a version's description a row shows. const DESCRIPTION_LINES: u8 = 3; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/review/src/ui/vote.rs b/crates/review/src/ui/vote.rs index 9937b547a..ea137108f 100644 --- a/crates/review/src/ui/vote.rs +++ b/crates/review/src/ui/vote.rs @@ -13,7 +13,7 @@ use egui::{Response, Ui}; use crate::collab::{CollabRequest, CollabTransport, VoteScope}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// Votes per person a new vote starts with. diff --git a/crates/table/Cargo.toml b/crates/table/Cargo.toml index c1573bdb9..ae1866289 100644 --- a/crates/table/Cargo.toml +++ b/crates/table/Cargo.toml @@ -15,6 +15,7 @@ test = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The table widgets (`craft_table::ui`). ui = ["dep:craft-ui", "dep:craft-behavior", "dep:craft-keymap", "dep:craft-theme", "dep:egui"] @@ -29,11 +30,11 @@ craft-ui = { workspace = true, optional = true } egui = { workspace = true, optional = true } [dev-dependencies] -craft-table = { path = ".", features = ["screen-testing"] } +craft-table = { path = ".", features = ["suite"] } egui = { workspace = true } [[test]] name = "it" path = "tests/it/main.rs" harness = false -required-features = ["screen-testing"] +required-features = ["suite"] diff --git a/crates/table/src/ui/chart.rs b/crates/table/src/ui/chart.rs index 74ec98171..23d04e0b4 100644 --- a/crates/table/src/ui/chart.rs +++ b/crates/table/src/ui/chart.rs @@ -5,7 +5,7 @@ use craft_ui::primitives::{DataStrokeWidth, Draw, PaintShape, TextRun}; use craft_ui::style::{DataColor, StyleColor}; use egui::{CornerRadius, Pos2, Rect, pos2, vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// A document line width never shrinks below this share of its width at 100 % zoom (a zoom floor, not a size). diff --git a/crates/table/src/ui/conditions.rs b/crates/table/src/ui/conditions.rs index 3825a0508..5a4433ad6 100644 --- a/crates/table/src/ui/conditions.rs +++ b/crates/table/src/ui/conditions.rs @@ -18,7 +18,7 @@ use craft_ui::style::SurfaceKind; use craft_ui::text::{NumberField, TextField}; use egui::{Response, Ui}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/table/src/ui/error_tag.rs b/crates/table/src/ui/error_tag.rs index c91db70db..9178f8887 100644 --- a/crates/table/src/ui/error_tag.rs +++ b/crates/table/src/ui/error_tag.rs @@ -16,7 +16,7 @@ use craft_ui::runtime::env::WordSet as _; use craft_ui::style::{ComponentStyle, FocusLook, IconLook, StyleCx, SurfaceLook}; use egui::{Rect, Response, Vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/table/src/ui/fields.rs b/crates/table/src/ui/fields.rs index a94e17f20..5bd4c1f1d 100644 --- a/crates/table/src/ui/fields.rs +++ b/crates/table/src/ui/fields.rs @@ -21,7 +21,7 @@ use craft_ui::sections::Panel; use craft_ui::style::{SurfaceKind, TypeRole}; use egui::{Id, Response, Ui}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/table/src/ui/filter.rs b/crates/table/src/ui/filter.rs index 2bd5488cd..4e15592d9 100644 --- a/crates/table/src/ui/filter.rs +++ b/crates/table/src/ui/filter.rs @@ -11,7 +11,7 @@ use craft_ui::primitives::IconSpec; use craft_ui::style::{ComponentStyle, FocusLook, IconLook, StyleCx, SurfaceLook}; use egui::{Rect, Response, Vec2, pos2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/table/src/ui/grid.rs b/crates/table/src/ui/grid.rs index 5fb00d400..afb4fa0cc 100644 --- a/crates/table/src/ui/grid.rs +++ b/crates/table/src/ui/grid.rs @@ -26,7 +26,7 @@ mod model; mod paint; mod reference; mod row; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use geometry::{GridLayout, HEADER_MIN_ZOOM, SheetGeometry, SheetMetrics}; diff --git a/crates/table/src/ui/mod.rs b/crates/table/src/ui/mod.rs index 2386a8e7a..91660e5d4 100644 --- a/crates/table/src/ui/mod.rs +++ b/crates/table/src/ui/mod.rs @@ -30,6 +30,7 @@ pub mod stats; /// The registrations of the table widgets' stories and trials. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/table/src/ui/outline.rs b/crates/table/src/ui/outline.rs index 40ea459f5..0ef2efa2b 100644 --- a/crates/table/src/ui/outline.rs +++ b/crates/table/src/ui/outline.rs @@ -12,7 +12,7 @@ use egui::{CornerRadius, Pos2, Rect, Response, Vec2, pos2, vec2}; use super::grid::{CellAt, CellRange, SheetGeometry, column_letters}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/table/src/ui/slicer.rs b/crates/table/src/ui/slicer.rs index a3cf1863b..bc05f8347 100644 --- a/crates/table/src/ui/slicer.rs +++ b/crates/table/src/ui/slicer.rs @@ -17,7 +17,7 @@ use craft_ui::sections::{HeaderStrength, TitleRow}; use craft_ui::style::{ComponentStyle, Flags, FocusLook, Stateful, StyleColor, StyleCx, SurfaceKind, SurfaceLook, TextLook, TypeRole, UiTokens}; use egui::{Rect, Response, Ui, Vec2, pos2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/table/src/ui/stats.rs b/crates/table/src/ui/stats.rs index 22ff65ea5..182bc6332 100644 --- a/crates/table/src/ui/stats.rs +++ b/crates/table/src/ui/stats.rs @@ -15,7 +15,7 @@ use craft_ui::runtime::env::Label; use craft_ui::style::{ComponentStyle, FocusLook, StyleCx, TextLook}; use egui::{Rect, Response, Vec2}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/text/Cargo.toml b/crates/text/Cargo.toml index 39be25683..f173f309a 100644 --- a/crates/text/Cargo.toml +++ b/crates/text/Cargo.toml @@ -45,13 +45,14 @@ serde_json = { workspace = true, optional = true } [dev-dependencies] unicode-segmentation = "1.13" -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } [[example]] name = "hyphgen" required-features = ["generator"] [features] +suite = ["screen-testing", "craft-ui/suite"] positioned = ["dep:kurbo"] default = ["hyphen", "bidi", "segment"] # Hyphenation points; English (bundled dictionary and patterns) needs no further feature. diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index 8b1230a65..d402923f4 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -58,6 +58,7 @@ pub mod ui; /// The stories and trials of the crate's UI, registered in craft-ui's registry. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/text/src/ui/character.rs b/crates/text/src/ui/character.rs index 4d45ed78f..c74e61afb 100644 --- a/crates/text/src/ui/character.rs +++ b/crates/text/src/ui/character.rs @@ -32,7 +32,7 @@ use egui::{Response, Ui}; pub(crate) mod paragraph; mod paragraph_dialog; pub(crate) mod rows; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod style_options; diff --git a/crates/text/src/ui/character/style_options.rs b/crates/text/src/ui/character/style_options.rs index d0f100b66..4de90ff8d 100644 --- a/crates/text/src/ui/character/style_options.rs +++ b/crates/text/src/ui/character/style_options.rs @@ -30,7 +30,7 @@ use crate::ui::length::DocUnit; #[cfg(feature = "font-picker")] use super::FontPickerSource; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/text/src/ui/columns.rs b/crates/text/src/ui/columns.rs index 959d21c78..9e20f79a7 100644 --- a/crates/text/src/ui/columns.rs +++ b/crates/text/src/ui/columns.rs @@ -23,7 +23,7 @@ use craft_ui::text::{NumberField, NumberOutput}; use egui::{Pos2, Rect, Ui, Vec2, pos2, vec2}; use std::cell::Cell; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The most columns PowerPoint takes; the diff --git a/crates/text/src/ui/editor.rs b/crates/text/src/ui/editor.rs index ddc86013a..2a69077ed 100644 --- a/crates/text/src/ui/editor.rs +++ b/crates/text/src/ui/editor.rs @@ -23,7 +23,7 @@ mod commands; mod edits; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::ops::Range; diff --git a/crates/text/src/ui/find.rs b/crates/text/src/ui/find.rs index 7e6754ef9..b952d3ecb 100644 --- a/crates/text/src/ui/find.rs +++ b/crates/text/src/ui/find.rs @@ -3,7 +3,7 @@ //! Replace and Go To tabs, Search Options, Replace and Replace All) and PowerPoint's simpler Find / Replace, on the //! dialog stack. Both search with [`crate::find`]; the document's text and the replacing are the app's. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod bar; diff --git a/crates/text/src/ui/hyperlink.rs b/crates/text/src/ui/hyperlink.rs index ee0705b04..05b840783 100644 --- a/crates/text/src/ui/hyperlink.rs +++ b/crates/text/src/ui/hyperlink.rs @@ -19,7 +19,7 @@ use craft_ui::sections::{DialogRole, FooterButton}; use craft_ui::text::TextField; use egui::{Context, Response, Ui}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/text/src/ui/notes.rs b/crates/text/src/ui/notes.rs index c55c616e2..34584de01 100644 --- a/crates/text/src/ui/notes.rs +++ b/crates/text/src/ui/notes.rs @@ -5,7 +5,7 @@ //! //! The notes are the app's; [`NotesText`] is the shape the editor reads and writes. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod text; diff --git a/crates/text/src/ui/path_text.rs b/crates/text/src/ui/path_text.rs index c9473f093..06c5f252b 100644 --- a/crates/text/src/ui/path_text.rs +++ b/crates/text/src/ui/path_text.rs @@ -1,6 +1,6 @@ //! `PathTextMarkers`: the start, end and overflow marks of text laid on a path, a canvas control. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::kurbo::{Point, Vec2 as PathVec}; diff --git a/crates/text/src/ui/ruler.rs b/crates/text/src/ui/ruler.rs index fd2e4c1c8..d67e4178b 100644 --- a/crates/text/src/ui/ruler.rs +++ b/crates/text/src/ui/ruler.rs @@ -28,7 +28,7 @@ mod geometry; mod items; mod paint; mod run; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use geometry::{Geometry, Shapes}; diff --git a/crates/text/src/ui/spelling.rs b/crates/text/src/ui/spelling.rs index 97951e67f..8fdbb163e 100644 --- a/crates/text/src/ui/spelling.rs +++ b/crates/text/src/ui/spelling.rs @@ -41,7 +41,7 @@ use egui::{Context, Response, Ui}; use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/text/src/ui/style_panel.rs b/crates/text/src/ui/style_panel.rs index 53b87ee00..8cbd44b44 100644 --- a/crates/text/src/ui/style_panel.rs +++ b/crates/text/src/ui/style_panel.rs @@ -19,7 +19,7 @@ use egui::{Response, Ui}; use std::cell::Cell; mod picker; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use picker::{NamedStyleRow, StylePreview, style_rows}; diff --git a/crates/text/src/ui/tabs_dialog.rs b/crates/text/src/ui/tabs_dialog.rs index 293cea5ec..315364933 100644 --- a/crates/text/src/ui/tabs_dialog.rs +++ b/crates/text/src/ui/tabs_dialog.rs @@ -30,7 +30,7 @@ use egui::Ui; use std::borrow::Cow; use std::cell::RefCell; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; const POSITION: ColumnKey = ColumnKey::new("position"); diff --git a/crates/text/src/ui/type_bar.rs b/crates/text/src/ui/type_bar.rs index 10d3b6214..b53637718 100644 --- a/crates/text/src/ui/type_bar.rs +++ b/crates/text/src/ui/type_bar.rs @@ -29,7 +29,7 @@ use crate::ui::type_options::{TextAntiAlias, TextOrientation, TypeOptionWords}; #[cfg(feature = "font-picker")] use crate::ui::character::FontPickerSource; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/theme-editor/Cargo.toml b/crates/theme-editor/Cargo.toml index 117c883be..2df8725a8 100644 --- a/crates/theme-editor/Cargo.toml +++ b/crates/theme-editor/Cargo.toml @@ -13,6 +13,7 @@ autotests = false harness = false [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The panels' stories. screen-testing = ["craft-ui/testing"] @@ -24,7 +25,7 @@ craft-ui = { workspace = true } egui = { workspace = true } [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } [lints] workspace = true diff --git a/crates/theme-editor/src/lib.rs b/crates/theme-editor/src/lib.rs index 22bb4063d..ff5bd4e04 100644 --- a/crates/theme-editor/src/lib.rs +++ b/crates/theme-editor/src/lib.rs @@ -10,7 +10,7 @@ mod detail; mod layer; mod problems; mod rows; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; mod subject; mod words; @@ -26,6 +26,7 @@ pub use words::summary; /// The stories this crate registers for the integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/theme-store/Cargo.toml b/crates/theme-store/Cargo.toml index d92130fcd..7e46b9911 100644 --- a/crates/theme-store/Cargo.toml +++ b/crates/theme-store/Cargo.toml @@ -14,6 +14,7 @@ autotests = false harness = false [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # `craft_theme_store::ui`: the Preferences appearance page and its theme chips. ui = ["dep:craft-behavior", "dep:craft-ui", "dep:egui"] @@ -33,7 +34,7 @@ craft-atomic = { workspace = true } dirs = "7" [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } tempfile = "3" [lints] diff --git a/crates/theme-store/src/ui/mod.rs b/crates/theme-store/src/ui/mod.rs index cd11f8476..b2b89756a 100644 --- a/crates/theme-store/src/ui/mod.rs +++ b/crates/theme-store/src/ui/mod.rs @@ -2,10 +2,11 @@ mod chip; mod page; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; #[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] craft_ui::testing_registered!(); pub use chip::{ThemeChip, ThemeChipOutput, ThemeChipStyle}; diff --git a/crates/timeline/Cargo.toml b/crates/timeline/Cargo.toml index a588eb43a..165a0c499 100644 --- a/crates/timeline/Cargo.toml +++ b/crates/timeline/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] default = [] # The timeline widgets (`craft_timeline::ui`). ui = ["dep:craft-behavior", "dep:craft-keymap", "dep:craft-theme", "dep:craft-ui", "dep:egui"] @@ -40,7 +41,7 @@ serde_json = { workspace = true, optional = true } web-time = "1.1" [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } egui = { workspace = true } proptest = { workspace = true } serde_json = { workspace = true } diff --git a/crates/timeline/src/lib.rs b/crates/timeline/src/lib.rs index 38f91b735..5f15caa64 100644 --- a/crates/timeline/src/lib.rs +++ b/crates/timeline/src/lib.rs @@ -86,6 +86,7 @@ mod timecode_tests; /// The stories and trials this crate registers. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/timeline/src/ui/graph.rs b/crates/timeline/src/ui/graph.rs index 0f90f62bf..1ab5d846c 100644 --- a/crates/timeline/src/ui/graph.rs +++ b/crates/timeline/src/ui/graph.rs @@ -1,7 +1,7 @@ //! `GraphEditor`: keyframed values (or their speed) as curves over time (N1.08), a leaf with a content painter for the //! plot and parts for the keys, the handles and the bottom bar. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::kurbo; diff --git a/crates/timeline/src/ui/keyframes.rs b/crates/timeline/src/ui/keyframes.rs index fb5aa620f..a5da02a59 100644 --- a/crates/timeline/src/ui/keyframes.rs +++ b/crates/timeline/src/ui/keyframes.rs @@ -1,6 +1,6 @@ //! Keyframe lanes, the keyframe navigator and the animation toggle (N1.04). -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/timeline/src/ui/markers.rs b/crates/timeline/src/ui/markers.rs index 897e1f542..bad737ea8 100644 --- a/crates/timeline/src/ui/markers.rs +++ b/crates/timeline/src/ui/markers.rs @@ -1,7 +1,7 @@ //! Markers on a ruler or a clip bar, and the Marker dialog (N1.12). mod dialog; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; pub use dialog::{MarkerDialog, MarkerDialogAction, MarkerDialogResult, MarkerDraft}; diff --git a/crates/timeline/src/ui/overview.rs b/crates/timeline/src/ui/overview.rs index 42c349c2f..1a40d565f 100644 --- a/crates/timeline/src/ui/overview.rs +++ b/crates/timeline/src/ui/overview.rs @@ -1,6 +1,6 @@ //! The whole timeline in miniature (N1.13). -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{Axis, Metrics, PointerButton, PressPhase, Sense}; diff --git a/crates/timeline/src/ui/panel.rs b/crates/timeline/src/ui/panel.rs index c9b1f656b..059da322e 100644 --- a/crates/timeline/src/ui/panel.rs +++ b/crates/timeline/src/ui/panel.rs @@ -872,7 +872,7 @@ pub struct TopStripStyle { metrics: Metrics, } -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; /// The model of the pattern's registration probe: no tracks. diff --git a/crates/timeline/src/ui/preview.rs b/crates/timeline/src/ui/preview.rs index 75486fe73..42029e1b7 100644 --- a/crates/timeline/src/ui/preview.rs +++ b/crates/timeline/src/ui/preview.rs @@ -1,6 +1,6 @@ //! A decoded frame fitted in a panel, with a status line. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{Axis, Metrics, Sense}; diff --git a/crates/timeline/src/ui/render_queue.rs b/crates/timeline/src/ui/render_queue.rs index 38694bad9..0e67d99f3 100644 --- a/crates/timeline/src/ui/render_queue.rs +++ b/crates/timeline/src/ui/render_queue.rs @@ -1,6 +1,6 @@ //! The render (export) queue list. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use std::borrow::Cow; diff --git a/crates/timeline/src/ui/ruler.rs b/crates/timeline/src/ui/ruler.rs index a5b132deb..0fc261e49 100644 --- a/crates/timeline/src/ui/ruler.rs +++ b/crates/timeline/src/ui/ruler.rs @@ -1,7 +1,7 @@ //! `TimelineRuler`: the time ruler across the top of a timeline (N1.01), a leaf that reads the `TimeAxis` of the //! `TimelineView` around it. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{Axis, CursorIcon, HitLevel, HitPriority, Metrics, NavMove, PartKey, PointerButton, PressPhase, RulerUnits, Sense, Ticks}; diff --git a/crates/timeline/src/ui/stack.rs b/crates/timeline/src/ui/stack.rs index 84346cb84..6a466738a 100644 --- a/crates/timeline/src/ui/stack.rs +++ b/crates/timeline/src/ui/stack.rs @@ -817,5 +817,5 @@ pub(crate) fn set_event(before: T, after: T, label: &str) -> EditEvent { EditEvent::set(Mixed::Same(before), after, Arc::from(label), None) } -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/timeline/src/ui/timecode.rs b/crates/timeline/src/ui/timecode.rs index 096363dec..18b2dfe55 100644 --- a/crates/timeline/src/ui/timecode.rs +++ b/crates/timeline/src/ui/timecode.rs @@ -1,7 +1,7 @@ //! The timecode field, its codec and the Timecode panel. mod readout; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::nav::LARGE_STEPS; diff --git a/crates/timeline/src/ui/transport.rs b/crates/timeline/src/ui/transport.rs index b8c8a457d..3021732a2 100644 --- a/crates/timeline/src/ui/transport.rs +++ b/crates/timeline/src/ui/transport.rs @@ -1,6 +1,6 @@ //! A monitor's transport bar and the compact media controls. -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; use craft_behavior::{EditEvents, IconId}; diff --git a/crates/timeline/src/ui/view.rs b/crates/timeline/src/ui/view.rs index d3420d63d..6787c3147 100644 --- a/crates/timeline/src/ui/view.rs +++ b/crates/timeline/src/ui/view.rs @@ -632,5 +632,5 @@ impl Outcome for TimelineViewOutput { } } -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/ui-canvas/Cargo.toml b/crates/ui-canvas/Cargo.toml index fe58c3059..4353a3d3d 100644 --- a/crates/ui-canvas/Cargo.toml +++ b/crates/ui-canvas/Cargo.toml @@ -15,6 +15,7 @@ test = false workspace = true [features] +suite = ["testing", "craft-ui-panels/suite"] default = [] # `craft_ui::testing` with the canvas test helpers (`ToolFixture`, `tool_story`, `canvas_story`). testing = ["craft-ui-panels/testing"] @@ -31,7 +32,7 @@ serde = { workspace = true } serde_json = { workspace = true } [dev-dependencies] -craft-ui-canvas = { path = ".", features = ["testing"] } +craft-ui-canvas = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-keymap = { workspace = true, features = ["egui"] } craft-ui-test-kit = { workspace = true } diff --git a/crates/ui-canvas/src/canvas/crop/mod.rs b/crates/ui-canvas/src/canvas/crop/mod.rs index f2a9256ac..0177699e7 100644 --- a/crates/ui-canvas/src/canvas/crop/mod.rs +++ b/crates/ui-canvas/src/canvas/crop/mod.rs @@ -5,7 +5,7 @@ mod gesture; mod paint; mod shield; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::words::CanvasWords; diff --git a/crates/ui-canvas/src/canvas/full_window.rs b/crates/ui-canvas/src/canvas/full_window.rs index 8634c82fc..ca4ec5727 100644 --- a/crates/ui-canvas/src/canvas/full_window.rs +++ b/crates/ui-canvas/src/canvas/full_window.rs @@ -21,9 +21,9 @@ use egui::Ui; pub use hosted::{FullWindowWorkspace, HostedWorkspace, WorkspaceCx, WorkspacePass}; mod hosted; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod trials; /// The style of a full-window dialog: the surface comes from the container. diff --git a/crates/ui-canvas/src/canvas/full_window_parts.rs b/crates/ui-canvas/src/canvas/full_window_parts.rs index 93aa1264b..de4ecfa5a 100644 --- a/crates/ui-canvas/src/canvas/full_window_parts.rs +++ b/crates/ui-canvas/src/canvas/full_window_parts.rs @@ -4,7 +4,7 @@ mod canvas; mod side; mod status; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod title; mod view; diff --git a/crates/ui-canvas/src/canvas/mod.rs b/crates/ui-canvas/src/canvas/mod.rs index 2439b191d..fd14825bc 100644 --- a/crates/ui-canvas/src/canvas/mod.rs +++ b/crates/ui-canvas/src/canvas/mod.rs @@ -15,7 +15,7 @@ pub(crate) mod full_window_parts; mod march; mod readout; mod space; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; #[cfg(feature = "testing")] pub(crate) mod testing; diff --git a/crates/ui-canvas/src/canvas/navigate/mod.rs b/crates/ui-canvas/src/canvas/navigate/mod.rs index 93b3a3263..def611c7f 100644 --- a/crates/ui-canvas/src/canvas/navigate/mod.rs +++ b/crates/ui-canvas/src/canvas/navigate/mod.rs @@ -9,7 +9,7 @@ mod bar; mod keys; mod options; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod wheel; diff --git a/crates/ui-canvas/src/canvas/navigator/mod.rs b/crates/ui-canvas/src/canvas/navigator/mod.rs index 87d4d7c8c..356c4aea5 100644 --- a/crates/ui-canvas/src/canvas/navigator/mod.rs +++ b/crates/ui-canvas/src/canvas/navigator/mod.rs @@ -12,7 +12,7 @@ mod menu; mod preview; mod proxy; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod zoom_row; diff --git a/crates/ui-canvas/src/canvas/navigator_panel.rs b/crates/ui-canvas/src/canvas/navigator_panel.rs index eea453822..24ec2e0aa 100644 --- a/crates/ui-canvas/src/canvas/navigator_panel.rs +++ b/crates/ui-canvas/src/canvas/navigator_panel.rs @@ -8,7 +8,7 @@ use craft_behavior::kurbo::Size; use craft_behavior::{CanvasView, EditEvents}; use egui::{Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// What the Navigator panel reports. diff --git a/crates/ui-canvas/src/canvas/pasteboard/mod.rs b/crates/ui-canvas/src/canvas/pasteboard/mod.rs index ecc5d9c90..7426f103c 100644 --- a/crates/ui-canvas/src/canvas/pasteboard/mod.rs +++ b/crates/ui-canvas/src/canvas/pasteboard/mod.rs @@ -3,7 +3,7 @@ //! preferences; the default colour is the canvas surround. Artboards show their names above them, and a click on a //! name selects the artboard. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::space::canvas_space; diff --git a/crates/ui-canvas/src/canvas/raster/mod.rs b/crates/ui-canvas/src/canvas/raster/mod.rs index 8aa376bbd..81b8e6e57 100644 --- a/crates/ui-canvas/src/canvas/raster/mod.rs +++ b/crates/ui-canvas/src/canvas/raster/mod.rs @@ -15,7 +15,7 @@ //! The display takes no pointer and no keys and declares no parts: a press on it reaches the canvas's tool. mod detail; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use detail::{DetailPlan, snap_to_texels}; diff --git a/crates/ui-canvas/src/canvas/rulers/mod.rs b/crates/ui-canvas/src/canvas/rulers/mod.rs index f30d57f3a..0e02bdf01 100644 --- a/crates/ui-canvas/src/canvas/rulers/mod.rs +++ b/crates/ui-canvas/src/canvas/rulers/mod.rs @@ -2,7 +2,7 @@ //! control (20.6). The strips and the corner are parts at handle priority in the canvas's arena. A drag from a strip //! reports a guide being placed; a drag from the corner moves the zero point. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod ticks; diff --git a/crates/ui-canvas/src/canvas/scrollbars/mod.rs b/crates/ui-canvas/src/canvas/scrollbars/mod.rs index 021b78a5b..677e6c0f6 100644 --- a/crates/ui-canvas/src/canvas/scrollbars/mod.rs +++ b/crates/ui-canvas/src/canvas/scrollbars/mod.rs @@ -9,7 +9,7 @@ //! The bars measure the view along the screen axes, so on a rotated view they show the extent of the unrotated //! document. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::words::CanvasWords; diff --git a/crates/ui-canvas/src/canvas/split/mod.rs b/crates/ui-canvas/src/canvas/split/mod.rs index 0f2804e87..739496afa 100644 --- a/crates/ui-canvas/src/canvas/split/mod.rs +++ b/crates/ui-canvas/src/canvas/split/mod.rs @@ -7,7 +7,7 @@ //! the [`SplitAt`] the caller binds ([`SplitAt::placed`]). A linked pane follows the active view's zoom and position //! ([`SplitViews::follow`]). -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::words::SplitWords; diff --git a/crates/ui-canvas/src/canvas_controls/brush/mod.rs b/crates/ui-canvas/src/canvas_controls/brush/mod.rs index 25475f0c5..d030aab84 100644 --- a/crates/ui-canvas/src/canvas_controls/brush/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/brush/mod.rs @@ -26,7 +26,7 @@ mod cursor; mod falloff; mod resize; mod source_marker; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod tip; mod trail; diff --git a/crates/ui-canvas/src/canvas_controls/grid/mod.rs b/crates/ui-canvas/src/canvas_controls/grid/mod.rs index c37b1929d..885f861b8 100644 --- a/crates/ui-canvas/src/canvas_controls/grid/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/grid/mod.rs @@ -2,7 +2,7 @@ //! the document grid of Preferences > Guides, Grid & Slices. Display only: it senses nothing, so the host's menu item //! carries the state. Show it before guides and frames. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(super) mod stories; use crate::canvas::{CanvasSpace, GuideLine, canvas_space}; diff --git a/crates/ui-canvas/src/canvas_controls/guides/mod.rs b/crates/ui-canvas/src/canvas_controls/guides/mod.rs index 36be120da..e6ab7a77d 100644 --- a/crates/ui-canvas/src/canvas_controls/guides/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/guides/mod.rs @@ -3,7 +3,7 @@ mod place; pub mod reading; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use reading::GuideReading; diff --git a/crates/ui-canvas/src/canvas_controls/marquee/mod.rs b/crates/ui-canvas/src/canvas_controls/marquee/mod.rs index 410bfa559..b96d07fb1 100644 --- a/crates/ui-canvas/src/canvas_controls/marquee/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/marquee/mod.rs @@ -2,7 +2,7 @@ //! selection band or an outline being drawn over the canvas, mapped from document geometry through the canvas's view. //! It takes no pointer and no key: the press, the drag and the modifier rules are the canvas tool's. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(super) mod stories; use super::words::CanvasControlWords; diff --git a/crates/ui-canvas/src/canvas_controls/outline/mod.rs b/crates/ui-canvas/src/canvas_controls/outline/mod.rs index 150ffeb5b..e9f78090c 100644 --- a/crates/ui-canvas/src/canvas_controls/outline/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/outline/mod.rs @@ -3,7 +3,7 @@ //! share one stroking function over `kit::outline` (halo and line) and `kit::dashed`. mod hover; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(super) mod stories; use crate::canvas::canvas_space; diff --git a/crates/ui-canvas/src/canvas_controls/pixel_grid/mod.rs b/crates/ui-canvas/src/canvas_controls/pixel_grid/mod.rs index 5901a8598..1cbc42d83 100644 --- a/crates/ui-canvas/src/canvas_controls/pixel_grid/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/pixel_grid/mod.rs @@ -7,7 +7,7 @@ //! display and keeps the merged line segments per revision and padded region in the control's memory, so panning //! within the padding costs nothing and the work is bounded by the viewport. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(super) mod stories; use crate::canvas::{PixelRect, RasterSource, canvas_space}; diff --git a/crates/ui-canvas/src/canvas_controls/smart_guides/mod.rs b/crates/ui-canvas/src/canvas_controls/smart_guides/mod.rs index 265c9b2b1..2ba6bd6e0 100644 --- a/crates/ui-canvas/src/canvas_controls/smart_guides/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/smart_guides/mod.rs @@ -1,7 +1,7 @@ //! `SmartGuides`: the alignment lines and distances shown while something moves, a canvas control that only paints //! (20.6). It has no parts, so a press never lands on it. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use crate::canvas::{CanvasRulers, canvas_space}; diff --git a/crates/ui-canvas/src/canvas_controls/task_bar.rs b/crates/ui-canvas/src/canvas_controls/task_bar.rs index 10bc17e55..ad8c0b5c6 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar.rs @@ -1,6 +1,6 @@ //! `TaskBar`: the contextual task bar over a canvas, hung below its anchor until the user moves it. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::CanvasControlWords; diff --git a/crates/ui-canvas/src/lib.rs b/crates/ui-canvas/src/lib.rs index b1c40a728..7b26db86c 100644 --- a/crates/ui-canvas/src/lib.rs +++ b/crates/ui-canvas/src/lib.rs @@ -12,7 +12,7 @@ extern crate self as craft_ui; #[doc(hidden)] pub use craft_ui_panels::canvas_data; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] #[doc(hidden)] pub use craft_ui_panels::story_kit; #[cfg(feature = "testing")] @@ -51,5 +51,6 @@ pub mod testing { }; pub use craft_ui_panels::testing::*; + #[cfg(feature = "suite")] crate::testing_registered!(); } diff --git a/crates/ui-contract/Cargo.toml b/crates/ui-contract/Cargo.toml index 112697346..4e364cf52 100644 --- a/crates/ui-contract/Cargo.toml +++ b/crates/ui-contract/Cargo.toml @@ -16,10 +16,10 @@ workspace = true [features] default = [] -# `craft_ui::testing`: the fixture and suite runner, with the snapshot renderer. One feature for all of the test kit, -# so every test build of every crate asks the runtime for the same thing and builds it once; a crate that depends on -# the runtime through another framework crate cannot name the runtime's features on the command line. -testing = ["dep:libtest-mimic", "snapshot", "craft-platform/testing"] +# `craft_ui::testing`: the fixture and helpers used by application tests. +# The suite runner, stories, registrations and snapshots are opt-in. +testing = ["craft-platform/testing"] +suite = ["testing", "dep:libtest-mimic", "snapshot"] # `craft_ui::testing::snapshot`: stories rendered to images offscreen (desktop only). snapshot = ["dep:egui_kittest", "dep:image"] # Draw colour glyphs (COLR, sbix, CBDT), e.g. colour emoji. @@ -89,7 +89,7 @@ flate2 = { version = "1", default-features = false, features = ["rust_backend"] epaint_default_fonts = { version = "0.37", features = ["monochrome_emoji_fonts"] } [dev-dependencies] -craft-ui-contract = { path = ".", features = ["testing"] } +craft-ui-contract = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-fonts-build = { workspace = true } craft-host = { workspace = true } diff --git a/crates/ui-contract/src/contract/body.rs b/crates/ui-contract/src/contract/body.rs index ab1d798f2..c09194699 100644 --- a/crates/ui-contract/src/contract/body.rs +++ b/crates/ui-contract/src/contract/body.rs @@ -33,7 +33,7 @@ pub use regions::pad_of; #[doc(hidden)] pub use reorder::REORDER_BAND; pub use scroll::{STRIP_BACK, STRIP_FORWARD}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) use window::MOVE_BAND; use window::WindowMode; pub(crate) use window::keep_inside; diff --git a/crates/ui-contract/src/contract/mod.rs b/crates/ui-contract/src/contract/mod.rs index 6c4877339..28b5bc634 100644 --- a/crates/ui-contract/src/contract/mod.rs +++ b/crates/ui-contract/src/contract/mod.rs @@ -15,9 +15,9 @@ mod hosted; mod items; mod label; mod lazy; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod level; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod level_table; mod looks; mod mount; @@ -87,7 +87,7 @@ pub use label::colon_of; pub use label::{CellWidth, FieldLabelRole, FieldLayout, GlyphLabel, InsideLabel, LabelKind, LabelScheme, Scrub, SideLabel}; pub use lazy::Lazy; #[doc(hidden)] -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub use level::{Catalog, CatalogEntry, Level, StoryLayout, Surface, catalog, stale_table_rows, story_title}; pub use looks::Looks; pub use overlay::{Overlay, OverlayUi, Overlays, Popup, PopupHandle, SizeLimits, Trigger}; @@ -95,7 +95,7 @@ pub use pages::Pages; pub use paint_ui::PaintUi; pub use props::{Common, Props, Resolved, Tooltip, TooltipAt, TooltipSpec, TooltipWhen}; #[doc(hidden)] -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub use registry::registrations; #[doc(hidden)] pub use registry::{CollectionEntry, ContainerEntry, Exemption, LeafEntry, PatternKind, PatternProbe, Probe, Registration, ShowEntry}; @@ -115,7 +115,7 @@ use std::hash::Hash; use std::ops::Deref; pub use crate::runtime::drag::{DragPreview, DropMark, DropTarget, DropZone, OsFile, OsFiles, WindowDropTarget}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) use body::MOVE_BAND; pub use craft_behavior::ColumnKey; pub use craft_behavior::DropOperation; diff --git a/crates/ui-contract/src/contract/registry.rs b/crates/ui-contract/src/contract/registry.rs index d200a2e6c..272fc37be 100644 --- a/crates/ui-contract/src/contract/registry.rs +++ b/crates/ui-contract/src/contract/registry.rs @@ -370,12 +370,12 @@ impl Registration { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] inventory::collect!(Registration); /// Every registration in the running binary, by crate, module and type name. #[doc(hidden)] -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub fn registrations() -> Vec<&'static Registration> { let mut all: Vec<_> = inventory::iter::().collect(); all.sort_by_key(|registration| match registration { @@ -390,7 +390,7 @@ pub fn registrations() -> Vec<&'static Registration> { /// and the `$purpose` line of its doc comment. #[doc(hidden)] #[macro_export] -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] macro_rules! __register_contract { ($ty:ty, $shape:ident, $overlay:expr, [$(($case:expr, $reason:expr)),*], [], $purpose:expr) => { const _: () = { @@ -416,7 +416,7 @@ macro_rules! __register_contract { /// The registration static of `__register_contract!`; `$with` is the probe's further builder calls. #[doc(hidden)] #[macro_export] -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] macro_rules! __register_probe { ($ty:ty, $shape:ident, $overlay:expr, [$(($case:expr, $reason:expr)),*], $purpose:expr, $($with:tt)*) => { const EXEMPT: &[$crate::contract::Exemption] = &[$($crate::contract::Exemption::new($case, $reason)),*]; @@ -434,7 +434,7 @@ macro_rules! __register_probe { /// `PatternProbe` constructor of its kind: `PatternProbe::of`, `canvas::tool_probe` or `dialog::dialog_probe`. #[doc(hidden)] #[macro_export] -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] macro_rules! __register_pattern { ($ty:ty, $purpose:expr) => { $crate::__register_pattern!($ty, $purpose, $crate::contract::PatternProbe::of); @@ -448,18 +448,18 @@ macro_rules! __register_pattern { }; } -/// Registers the pattern type `$ty`; without the `testing` feature there is nothing to register. +/// Registers the pattern type `$ty`; without the `suite` feature there is nothing to register. #[doc(hidden)] #[macro_export] -#[cfg(not(feature = "testing"))] +#[cfg(not(feature = "suite"))] macro_rules! __register_pattern { ($ty:ty, $purpose:expr $(, $($probe:tt)+)?) => {}; } -/// Registers the component type `$ty`; without the `testing` feature there is nothing to register. +/// Registers the component type `$ty`; without the `suite` feature there is nothing to register. #[doc(hidden)] #[macro_export] -#[cfg(not(feature = "testing"))] +#[cfg(not(feature = "suite"))] macro_rules! __register_contract { ($ty:ty, $shape:ident, $overlay:expr, [$(($case:expr, $reason:expr)),*], [$($sample:path)?], $purpose:expr) => {}; } diff --git a/crates/ui-contract/src/runtime/egui/access.rs b/crates/ui-contract/src/runtime/egui/access.rs index 8eee24e44..5f7579893 100644 --- a/crates/ui-contract/src/runtime/egui/access.rs +++ b/crates/ui-contract/src/runtime/egui/access.rs @@ -58,7 +58,7 @@ pub(crate) fn node_id(id: Id) -> NodeId { pub(crate) type NodeRole = accesskit::Role; /// The AccessKit vocabulary the testing kit reads a tree in. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) use accesskit::{Role, Toggled}; /// The AccessKit node number of `id`, the key an action request's target is matched by. diff --git a/crates/ui-contract/src/runtime/egui/areas.rs b/crates/ui-contract/src/runtime/egui/areas.rs index de412613f..57079b8fa 100644 --- a/crates/ui-contract/src/runtime/egui/areas.rs +++ b/crates/ui-contract/src/runtime/egui/areas.rs @@ -416,19 +416,19 @@ pub(crate) fn popup_open(ctx: &Context) -> bool { } /// A host's own egui popup `id` at `at`, shown while egui's memory holds it open. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn host_popup(ui: &Ui, id: egui::Id, at: Pos2) { egui::Popup::new(id, ui.ctx().clone(), at, ui.layer_id()).open_memory(None).show(|ui| ui.allocate_space(ui.spacing().interact_size)); } /// Opens the host's egui popup `id`. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn open_host_popup(ctx: &Context, id: egui::Id) { egui::Popup::open_id(ctx, id); } /// Whether the host's egui popup `id` is open. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn host_popup_open(ctx: &Context, id: egui::Id) -> bool { egui::Popup::is_id_open(ctx, id) } diff --git a/crates/ui-contract/src/runtime/egui/fixture.rs b/crates/ui-contract/src/runtime/egui/fixture.rs index c5f87706f..7695a8ac7 100644 --- a/crates/ui-contract/src/runtime/egui/fixture.rs +++ b/crates/ui-contract/src/runtime/egui/fixture.rs @@ -305,6 +305,7 @@ pub(crate) fn allow_zoom_keys(ctx: &Context) { /// Sets egui's click options, as an app does for its own widgets: the longest movement and the longest press that /// still count as a click. +#[cfg(feature = "suite")] pub(crate) fn set_click_options(ctx: &Context, distance: f32, seconds: f64) { ctx.options_mut(|options| { options.input_options.max_click_dist = distance; @@ -314,17 +315,20 @@ pub(crate) fn set_click_options(ctx: &Context, distance: f32, seconds: f64) { /// Sets egui's surrender option, the app's rule for its own focused widgets: with `never`, a click elsewhere leaves /// their focus; otherwise egui's default, which surrenders it on a click elsewhere. +#[cfg(feature = "suite")] pub(crate) fn set_app_surrender(ctx: &Context, never: bool) { let rule = if never { egui::SurrenderFocusOn::Never } else { egui::SurrenderFocusOn::Clicks }; ctx.options_mut(|options| options.input_options.surrender_focus_on = rule); } /// Whether egui's surrender option is egui's default, a click elsewhere. +#[cfg(feature = "suite")] pub(crate) fn app_surrenders_on_click(ctx: &Context) -> bool { ctx.options(|options| options.input_options.surrender_focus_on == egui::SurrenderFocusOn::Clicks) } /// egui's click options: the longest movement and the longest press that still count as a click. +#[cfg(feature = "suite")] pub(crate) fn click_options(ctx: &Context) -> (f32, f64) { ctx.options(|options| (options.input_options.max_click_dist, options.input_options.max_click_duration)) } @@ -416,29 +420,34 @@ pub(crate) fn focusable_widget(ui: &mut Ui, id: egui::Id) -> Rect { /// A host's own single-line egui text field of `id` over `text`, as an app that keeps its own widgets beside the /// framework's draws it; returns its rect. +#[cfg(feature = "suite")] pub(crate) fn host_field(ui: &mut Ui, id: egui::Id, text: &mut String) -> Rect { ui.add(egui::TextEdit::singleline(text).id(id)).rect } /// Gives the host's own egui widget `id` key focus, as the host's code does. +#[cfg(feature = "suite")] pub(crate) fn host_focus(ctx: &Context, id: egui::Id) { ctx.memory_mut(|memory| memory.request_focus(id)); } /// A host's own clickable egui widget `id` at `rect`, a focus stop for egui's own focus moves; returns whether egui /// reports a click on it, by egui's click options. +#[cfg(feature = "suite")] pub(crate) fn host_button(ui: &Ui, id: egui::Id, rect: Rect) -> bool { ui.interact(rect, id, egui::Sense::click()).clicked() } /// A host's own egui drag area `id` at `rect`; returns whether egui reports it dragged and whether its drag stopped /// this pass. +#[cfg(feature = "suite")] pub(crate) fn host_drag_area(ui: &Ui, id: egui::Id, rect: Rect) -> (bool, bool) { let response = ui.interact(rect, id, egui::Sense::drag()); (response.dragged(), response.drag_stopped()) } /// A host's own selectable egui label of `text`; returns its rect. +#[cfg(feature = "suite")] pub(crate) fn host_label(ui: &mut Ui, text: &str) -> Rect { ui.add(egui::Label::new(text).selectable(true)).rect } diff --git a/crates/ui-contract/src/runtime/egui/widgets.rs b/crates/ui-contract/src/runtime/egui/widgets.rs index f5e916732..1a972cad0 100644 --- a/crates/ui-contract/src/runtime/egui/widgets.rs +++ b/crates/ui-contract/src/runtime/egui/widgets.rs @@ -65,7 +65,7 @@ pub(crate) fn note_node(_: &Context, _: Id) {} /// A scroll region the runtime showed: `view` is the rect that shows it and cuts what lies outside, `content` the rect /// of what it holds, which scrolls through the view along the region's axes and lies within the view along the others. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] #[derive(Clone, Copy, Debug)] pub(crate) struct ScrollRegion { pub view: Rect, @@ -73,16 +73,16 @@ pub(crate) struct ScrollRegion { } /// Notes a scroll region of the running pass, for the suite's size cases. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn note_scroll_region(ctx: &Context, view: Rect, content: Rect) { noted::with(ctx, |pass| pass.scrolls.push(ScrollRegion { view, content })); } -#[cfg(not(feature = "testing"))] +#[cfg(not(feature = "suite"))] pub(crate) fn note_scroll_region(_: &Context, _: Rect, _: Rect) {} /// The scroll regions the runtime noted in the root viewport's latest pass. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn scroll_regions(ctx: &Context) -> Vec { noted::scrolls(ctx) } @@ -124,6 +124,7 @@ pub(crate) mod noted { pub(super) struct Pass { pub(super) widgets: HashSet, pub(super) nodes: HashSet, + #[cfg(feature = "suite")] pub(super) scrolls: Vec, } @@ -139,6 +140,7 @@ pub(crate) mod noted { } /// The root viewport's scroll regions of its latest pass. + #[cfg(feature = "suite")] pub(super) fn scrolls(ctx: &Context) -> Vec { crate::runtime::pass_state::with(ctx, |noted: &mut Noted| noted.pass.scrolls.clone()) } diff --git a/crates/ui-contract/src/runtime/keys.rs b/crates/ui-contract/src/runtime/keys.rs index 61f108ae8..f096cb2f2 100644 --- a/crates/ui-contract/src/runtime/keys.rs +++ b/crates/ui-contract/src/runtime/keys.rs @@ -32,7 +32,7 @@ pub(crate) use input::{input_hook, queue_nav, take_menu_keys, take_nav}; pub use intents::Intents; #[doc(hidden)] pub use intents::intents_of; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) use intents::lent_taken; #[doc(hidden)] pub use intents::settle; diff --git a/crates/ui-contract/src/runtime/keys/intents.rs b/crates/ui-contract/src/runtime/keys/intents.rs index 102d82524..ada5a65c6 100644 --- a/crates/ui-contract/src/runtime/keys/intents.rs +++ b/crates/ui-contract/src/runtime/keys/intents.rs @@ -393,7 +393,7 @@ pub(crate) fn give_back(ctx: &Context, to: Id, lent: Lent) { /// How many lent keys session members have taken so far in the current viewport: a check of keyboard parity reads /// it before and after its input, since a lent key is the session control's, not the focused component's. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn lent_taken(ctx: &Context) -> u64 { current(ctx, |stage| stage.lent_taken) } diff --git a/crates/ui-contract/src/runtime/overlay.rs b/crates/ui-contract/src/runtime/overlay.rs index 1553099a3..6eec89210 100644 --- a/crates/ui-contract/src/runtime/overlay.rs +++ b/crates/ui-contract/src/runtime/overlay.rs @@ -412,7 +412,7 @@ pub fn family(ctx: &Context, id: Id) -> SmallVec<[Id; 4]> { } /// Every layer of the running viewport shown last frame, not exiting, parent first. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn open_entries(ctx: &Context) -> Vec { with_pass(ctx, |pass| pass.last.iter().filter(|entry| !entry.exiting).cloned().collect()) } diff --git a/crates/ui-contract/src/runtime/pointer.rs b/crates/ui-contract/src/runtime/pointer.rs index beeb9b20f..352ebbdd5 100644 --- a/crates/ui-contract/src/runtime/pointer.rs +++ b/crates/ui-contract/src/runtime/pointer.rs @@ -511,7 +511,7 @@ pub(crate) fn part_bounds(ctx: &Context, owner: Id, part: craft_behavior::PartRe } /// Whether the part `part` of `owner` (the arena root or a member) senses all of `sense` in last pass's shape record. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn part_senses(ctx: &Context, owner: Id, part: craft_behavior::PartRef, sense: craft_behavior::Sense) -> bool { let viewport = pass::current_viewport(ctx); PerViewport::::with(ctx, viewport, |record| { @@ -546,7 +546,7 @@ fn owned_part_bounds(ctx: &Context, owner: impl Fn(Id) -> bool, part: craft_beha /// The bounds of the part `part` that senses `sense`, on a component other than `subject` and lying inside the /// subject's own shapes in last pass's shape record: where a component's child keeps the part a drive acts on. When /// several children match, the first by top edge, then start edge, then root id. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(crate) fn child_part_bounds(ctx: &Context, subject: Id, part: craft_behavior::PartRef, sense: craft_behavior::Sense) -> Option { let viewport = pass::current_viewport(ctx); PerViewport::::with(ctx, viewport, |record| { diff --git a/crates/ui-contract/src/testing/mod.rs b/crates/ui-contract/src/testing/mod.rs index 90ed467df..75b5ebb8f 100644 --- a/crates/ui-contract/src/testing/mod.rs +++ b/crates/ui-contract/src/testing/mod.rs @@ -13,24 +13,31 @@ pub mod dump; pub mod fixture; pub mod focus; pub mod frames; +#[cfg(feature = "suite")] mod host_key_trials; +#[cfg(feature = "suite")] mod icon_trials; +#[cfg(feature = "suite")] pub mod index; pub mod input; +#[cfg(feature = "suite")] mod key_trials; pub mod layout; pub mod memory; pub mod pictures; pub mod pointer; pub mod relations; +#[cfg(feature = "suite")] mod replay_trials; pub mod sensing; #[cfg(all(feature = "snapshot", not(target_arch = "wasm32")))] pub mod snapshot; mod stage; +#[cfg(feature = "suite")] mod stories; pub mod story; pub mod style; +#[cfg(feature = "suite")] pub mod suite; pub mod surface; pub mod text; @@ -48,9 +55,11 @@ pub use craft_ui_macros::{story, trial}; pub use fixture::{Fixture, Impure, Room, Target}; pub use frames::Frames; pub use stage::{room_height, stage, stage_fitting, stage_width}; +#[cfg(feature = "suite")] +pub use story::stories; #[doc(hidden)] pub use story::{ - CollectionKind, Drive, EditKind, Grip, Required, Story, StoryData, StoryOutput, StoryRegistration, StorySnapshot, show_as_only_item, stories, + CollectionKind, Drive, EditKind, Grip, Required, Story, StoryData, StoryOutput, StoryRegistration, StorySnapshot, show_as_only_item, }; pub use windows::install_spec; @@ -88,9 +97,11 @@ impl Trial { } } +#[cfg(feature = "suite")] inventory::collect!(Trial); /// Every `#[trial]` linked into the running binary, by full name. +#[cfg(feature = "suite")] pub fn trials() -> Vec<&'static Trial> { let mut all: Vec<_> = inventory::iter::().collect(); all.sort_by_key(|trial| trial.full_name()); @@ -100,6 +111,7 @@ pub fn trials() -> Vec<&'static Trial> { /// Runs a test executable and exits: the `#[trial]`s declared in the crate whose root module is `crate_root` or in /// `package`'s library crate, and the suite's trials over `registered`. Every test executable's `main` calls it, with /// its own `module_path!()`. +#[cfg(feature = "suite")] pub fn run(crate_root: &str, package: &'static str, registered: &[&'static Registration]) -> ! { let library = package.replace('-', "_"); let own = |module: &str| { @@ -126,6 +138,7 @@ pub fn run(crate_root: &str, package: &'static str, registered: &[&'static Regis /// Every registration declared in the library crate of the package `crate_name` and linked into the running /// binary, by module and type name. Types declared in the package's integration binaries are fixtures, not the package's. +#[cfg(feature = "suite")] pub fn registered_in(crate_name: &str) -> Vec<&'static Registration> { let library = crate_name.replace('-', "_"); crate::contract::registrations() @@ -148,6 +161,7 @@ macro_rules! testing_registered { }; } +#[cfg(feature = "suite")] testing_registered!(); #[doc(hidden)] diff --git a/crates/ui-contract/src/testing/story.rs b/crates/ui-contract/src/testing/story.rs index d58471713..70d1639a6 100644 --- a/crates/ui-contract/src/testing/story.rs +++ b/crates/ui-contract/src/testing/story.rs @@ -144,12 +144,14 @@ impl Story { /// The name of the story's group as a story of the type whose display name is `type_name`: its group, else its /// caption. + #[cfg(feature = "suite")] pub fn group_name(&self, type_name: &str) -> String { self.group.map_or_else(|| self.caption(type_name), str::to_owned) } /// The story's caption as a story of the type whose display name is `type_name`: its title, else the one its /// name makes ([`crate::contract::story_title`]). + #[cfg(feature = "suite")] pub fn caption(&self, type_name: &str) -> String { self.title.map_or_else(|| crate::contract::story_title(type_name, self.name), str::to_owned) } @@ -206,11 +208,13 @@ impl StoryRegistration { } } +#[cfg(feature = "suite")] inventory::collect!(StoryRegistration); /// Every story linked into the running binary, by type name; of each type, the stories of the package that registers /// it first, then those other packages declare; each in the order they are declared in. #[doc(hidden)] +#[cfg(feature = "suite")] pub fn stories() -> Vec<&'static StoryRegistration> { let homes: HashMap<&str, &str> = crate::contract::registrations() .into_iter() diff --git a/crates/ui-gallery/Cargo.toml b/crates/ui-gallery/Cargo.toml index 1e9167542..67727bdd6 100644 --- a/crates/ui-gallery/Cargo.toml +++ b/crates/ui-gallery/Cargo.toml @@ -48,7 +48,7 @@ review = ["dep:craft-review"] table = ["dep:craft-table"] text = ["dep:craft-text"] # The theme panels are linked in every build (the Theme workspace uses them); the feature adds their stories. -theme-editor = ["craft-theme-editor/screen-testing"] +theme-editor = ["craft-theme-editor/suite"] theme-store = ["dep:craft-theme-store"] timeline = ["dep:craft-timeline"] dialogs = ["dep:craft-dialogs"] @@ -64,7 +64,7 @@ harness = false workspace = true [dependencies] -craft-ui = { workspace = true, features = ["app", "testing"] } +craft-ui = { workspace = true, features = ["app", "suite"] } craft-i18n = { workspace = true } craft-theme = { workspace = true } craft-theme-editor = { workspace = true } @@ -82,27 +82,27 @@ serde = { workspace = true } serde_json = { workspace = true } web-time = "1.1" -# The domain crates' stories, registered under each crate's `screen-testing`. -craft-automation = { workspace = true, features = ["screen-testing"], optional = true } -craft-browse = { workspace = true, features = ["screen-testing"], optional = true } -craft-color-ui = { workspace = true, features = ["screen-testing"], optional = true } -craft-draw = { workspace = true, features = ["screen-testing"], optional = true } -craft-imaging = { workspace = true, features = ["screen-testing"], optional = true } -craft-layers = { workspace = true, features = ["screen-testing"], optional = true } -craft-menu = { workspace = true, features = ["screen-testing"], optional = true } -craft-pages = { workspace = true, features = ["screen-testing"], optional = true } -craft-print = { workspace = true, features = ["screen-testing"], optional = true } -craft-review = { workspace = true, features = ["screen-testing"], optional = true } -craft-table = { workspace = true, features = ["screen-testing"], optional = true } -craft-text = { workspace = true, features = ["screen-testing", "find"], optional = true } -craft-theme-store = { workspace = true, features = ["screen-testing"], optional = true } -craft-timeline = { workspace = true, features = ["screen-testing"], optional = true } +# The domain crates' stories, registered under each crate's `suite`. +craft-automation = { workspace = true, features = ["suite"], optional = true } +craft-browse = { workspace = true, features = ["suite"], optional = true } +craft-color-ui = { workspace = true, features = ["suite"], optional = true } +craft-draw = { workspace = true, features = ["suite"], optional = true } +craft-imaging = { workspace = true, features = ["suite"], optional = true } +craft-layers = { workspace = true, features = ["suite"], optional = true } +craft-menu = { workspace = true, features = ["suite"], optional = true } +craft-pages = { workspace = true, features = ["suite"], optional = true } +craft-print = { workspace = true, features = ["suite"], optional = true } +craft-review = { workspace = true, features = ["suite"], optional = true } +craft-table = { workspace = true, features = ["suite"], optional = true } +craft-text = { workspace = true, features = ["suite", "find"], optional = true } +craft-theme-store = { workspace = true, features = ["suite"], optional = true } +craft-timeline = { workspace = true, features = ["suite"], optional = true } # Native only: these crates do not build for the web, so their stories are not in the web gallery. [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -craft-dialogs = { workspace = true, features = ["screen-testing"], optional = true } -craft-font-manager = { workspace = true, features = ["screen-testing"], optional = true } -craft-update = { workspace = true, features = ["screen-testing"], optional = true } +craft-dialogs = { workspace = true, features = ["suite"], optional = true } +craft-font-manager = { workspace = true, features = ["suite"], optional = true } +craft-update = { workspace = true, features = ["suite"], optional = true } [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen-futures = "0.4" diff --git a/crates/ui-macros/src/component.rs b/crates/ui-macros/src/component.rs index 90e66c05b..aa7f82897 100644 --- a/crates/ui-macros/src/component.rs +++ b/crates/ui-macros/src/component.rs @@ -178,13 +178,13 @@ pub(crate) fn purpose_of(attrs: &[Attribute]) -> String { } /// The attributes on a registration block, from the crate being compiled. See `gate_for`. -fn registration_gate() -> TokenStream { +pub(crate) fn registration_gate() -> TokenStream { let manifest = std::env::var_os("CARGO_MANIFEST_DIR").and_then(|dir| std::fs::read_to_string(std::path::Path::new(&dir).join("Cargo.toml")).ok()); gate_for(manifest.as_deref().unwrap_or_default()) } /// The attributes on a registration block. The registration's types can exist only under the defining package's -/// `screen-testing` feature, which may be off while craft-ui's `testing` is on, so the block is gated on it (the cfg +/// `suite` feature, which may be off while craft-ui's `testing` is on, so the block is gated on it (the cfg /// is evaluated in the defining crate) when the package's `manifest` declares that feature, and is not gated otherwise. pub(crate) fn gate_for(manifest: &str) -> TokenStream { let mut in_features = false; @@ -193,9 +193,9 @@ pub(crate) fn gate_for(manifest: &str) -> TokenStream { in_features = line.trim_end_matches(|c: char| c.is_whitespace()) == "[features]"; return false; } - in_features && line.strip_prefix("screen-testing").is_some_and(|rest| rest.trim_start().starts_with('=')) + in_features && line.strip_prefix("suite").is_some_and(|rest| rest.trim_start().starts_with('=')) }); - if declares { quote!(#[cfg(feature = "screen-testing")]) } else { quote!() } + if declares { quote!(#[cfg(feature = "suite")]) } else { quote!() } } fn registrations(k: &TokenStream, types: &[Type], declared: &Declared, shape: Shape) -> syn::Result { diff --git a/crates/ui-macros/src/lib.rs b/crates/ui-macros/src/lib.rs index 06c321c09..c0c4ada83 100644 --- a/crates/ui-macros/src/lib.rs +++ b/crates/ui-macros/src/lib.rs @@ -135,9 +135,12 @@ pub fn trial(attr: TokenStream, item: TokenStream) -> TokenStream { } let ident = &sig.ident; let name = ident.to_string(); + let gate = component::registration_gate(); quote! { + #gate #func + #gate #k::testing::__private::inventory::submit! { #k::testing::Trial::#register(module_path!(), #name, #ident) } @@ -213,9 +216,12 @@ pub fn story(attr: TokenStream, item: TokenStream) -> TokenStream { let title = args.title.as_ref().map(|title| quote!(.title(#title))); let group = args.group.as_ref().map(|group| quote!(.group(#group))); let commands = args.commands.as_ref().map(|commands| quote!(.commands(#commands))); + let gate = component::registration_gate(); quote! { + #gate #func + #gate #k::testing::__private::inventory::submit! { #k::testing::StoryRegistration::new( env!("CARGO_PKG_NAME"), diff --git a/crates/ui-macros/src/tests.rs b/crates/ui-macros/src/tests.rs index 6ced7341c..b6ae5d5d6 100644 --- a/crates/ui-macros/src/tests.rs +++ b/crates/ui-macros/src/tests.rs @@ -3,11 +3,11 @@ use proc_macro2::TokenStream; #[test] -fn registration_is_gated_only_when_the_package_declares_screen_testing() { +fn registration_is_gated_only_when_the_package_declares_suite() { let compact = |tokens: TokenStream| tokens.to_string().split_whitespace().collect::(); - let declared = "[package]\nname = \"app\"\n\n[features]\nscreen-testing = [\"craft-ui/testing\"]\n"; - assert_eq!(compact(crate::component::gate_for(declared)), "#[cfg(feature=\"screen-testing\")]"); - let undeclared = "[package]\nname = \"gallery\"\nscreen-testing = 1\n\n[dependencies]\nscreen-testing = \"1\"\n"; + let declared = "[package]\nname = \"app\"\n\n[features]\nsuite = [\"craft-ui/testing\"]\n"; + assert_eq!(compact(crate::component::gate_for(declared)), "#[cfg(feature=\"suite\")]"); + let undeclared = "[package]\nname = \"gallery\"\nsuite = 1\n\n[dependencies]\nsuite = \"1\"\n"; assert_eq!(compact(crate::component::gate_for(undeclared)), ""); assert_eq!(compact(crate::component::gate_for("")), ""); } diff --git a/crates/ui-panels/Cargo.toml b/crates/ui-panels/Cargo.toml index 2e2703415..44aff9e89 100644 --- a/crates/ui-panels/Cargo.toml +++ b/crates/ui-panels/Cargo.toml @@ -15,6 +15,7 @@ test = false workspace = true [features] +suite = ["testing", "craft-ui-widgets/suite"] default = [] # `craft_ui::testing` with `testing::internals`. testing = ["craft-ui-widgets/testing"] @@ -34,7 +35,7 @@ serde = { workspace = true } serde_json = { workspace = true } [dev-dependencies] -craft-ui-panels = { path = ".", features = ["testing"] } +craft-ui-panels = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-keymap = { workspace = true, features = ["egui"] } egui = { workspace = true } diff --git a/crates/ui-panels/src/dialog/mod.rs b/crates/ui-panels/src/dialog/mod.rs index fb7f85e99..ca828462c 100644 --- a/crates/ui-panels/src/dialog/mod.rs +++ b/crates/ui-panels/src/dialog/mod.rs @@ -14,10 +14,10 @@ mod prompts; mod recovery; mod serde_fields; mod stack; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] #[doc(hidden)] pub mod stories; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod trials; mod unsaved; mod words; diff --git a/crates/ui-panels/src/dialog/prompt.rs b/crates/ui-panels/src/dialog/prompt.rs index 7def4e717..1a793086e 100644 --- a/crates/ui-panels/src/dialog/prompt.rs +++ b/crates/ui-panels/src/dialog/prompt.rs @@ -14,7 +14,7 @@ use craft_keymap::{Chord, mnemonic}; use craft_theme::variant::Tone; use egui::{Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// One answer of a prompt before its button exists: the label, what the button means, whether it has a letter and diff --git a/crates/ui-panels/src/docking/dock_column.rs b/crates/ui-panels/src/docking/dock_column.rs index 190d78a49..75b3e6197 100644 --- a/crates/ui-panels/src/docking/dock_column.rs +++ b/crates/ui-panels/src/docking/dock_column.rs @@ -22,7 +22,7 @@ use craft_behavior::{Axis, DockSide, Flow, Metrics, PartKey, Sense, Value}; use egui::{Context, Id, Pos2, Rect, Response, Ui}; use std::hash::Hash; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod bar; diff --git a/crates/ui-panels/src/docking/floating.rs b/crates/ui-panels/src/docking/floating.rs index 8e8d95d08..a78f1511c 100644 --- a/crates/ui-panels/src/docking/floating.rs +++ b/crates/ui-panels/src/docking/floating.rs @@ -31,7 +31,7 @@ use egui::{Id, Pos2, Rect, Response, Ui, Vec2}; use std::cell::RefCell; use std::hash::Hash; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The height of a floating group's title row: a strong `TitleRow`, which is as tall as a panel header. diff --git a/crates/ui-panels/src/docking/iconic.rs b/crates/ui-panels/src/docking/iconic.rs index a0b0fd26f..d70fbec11 100644 --- a/crates/ui-panels/src/docking/iconic.rs +++ b/crates/ui-panels/src/docking/iconic.rs @@ -26,9 +26,9 @@ use craft_theme::ControlSize; use egui::{Id, Pos2, Rect, Response, Ui, Vec2}; use std::hash::Hash; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod trials; const CELL: PartKey = PartKey::new("cell"); diff --git a/crates/ui-panels/src/docking/mod.rs b/crates/ui-panels/src/docking/mod.rs index dc680bb41..d7c7b098a 100644 --- a/crates/ui-panels/src/docking/mod.rs +++ b/crates/ui-panels/src/docking/mod.rs @@ -18,7 +18,7 @@ mod root; mod spec; mod splitter; pub mod stack; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub mod targets; pub mod tree; diff --git a/crates/ui-panels/src/docking/root.rs b/crates/ui-panels/src/docking/root.rs index 8b0c59c68..0a3b07b56 100644 --- a/crates/ui-panels/src/docking/root.rs +++ b/crates/ui-panels/src/docking/root.rs @@ -13,7 +13,7 @@ use crate::style::{ComponentStyle, StyleCx}; use craft_behavior::{Metrics, Sense}; use egui::Response; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a dock root: the docking sizes of its drop bands, columns, groups and floating windows. Colours, diff --git a/crates/ui-panels/src/lib.rs b/crates/ui-panels/src/lib.rs index 8a7337eb4..57873fae1 100644 --- a/crates/ui-panels/src/lib.rs +++ b/crates/ui-panels/src/lib.rs @@ -9,7 +9,7 @@ // The derives' output names the crate as `craft_ui`, here as in every other crate. extern crate self as craft_ui; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] #[doc(hidden)] pub use craft_ui_widgets::story_kit; #[cfg(feature = "testing")] @@ -43,5 +43,6 @@ pub mod testing { pub use crate::testing_internals::*; } + #[cfg(feature = "suite")] crate::testing_registered!(); } diff --git a/crates/ui-panels/src/rails/drawer.rs b/crates/ui-panels/src/rails/drawer.rs index 833ba59a8..1fcba24ff 100644 --- a/crates/ui-panels/src/rails/drawer.rs +++ b/crates/ui-panels/src/rails/drawer.rs @@ -24,7 +24,7 @@ use craft_behavior::{DisplayOrder, IconId, ItemSource, Value}; use egui::{Rect, Response, Ui}; use std::borrow::Cow; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// A group of the drawer: a heading over the tools that belong under it. diff --git a/crates/ui-panels/src/rails/flyout.rs b/crates/ui-panels/src/rails/flyout.rs index 24d76a66d..64577d9d1 100644 --- a/crates/ui-panels/src/rails/flyout.rs +++ b/crates/ui-panels/src/rails/flyout.rs @@ -15,7 +15,7 @@ use craft_behavior::overlay::{Align, Side}; use craft_behavior::{HitLevel, HitPriority, IconId, Metrics, PartKey, PointerButton, PressPhase, Sense, Value}; use egui::{Rect, Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The face over the whole button. diff --git a/crates/ui-panels/src/rails/tool.rs b/crates/ui-panels/src/rails/tool.rs index 4484234a9..94db961fa 100644 --- a/crates/ui-panels/src/rails/tool.rs +++ b/crates/ui-panels/src/rails/tool.rs @@ -23,9 +23,9 @@ use egui::{Response, Ui, Vec2}; mod data; mod drag; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] pub(super) mod stories; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod trials; use data::row_groups; diff --git a/crates/ui-panels/src/sections/footer.rs b/crates/ui-panels/src/sections/footer.rs index 517dbe2a4..8b579722a 100644 --- a/crates/ui-panels/src/sections/footer.rs +++ b/crates/ui-panels/src/sections/footer.rs @@ -25,7 +25,7 @@ use std::any::Any; use std::fmt; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a footer bar. A bar of panel actions sits under a divider rule along its top edge, with the control diff --git a/crates/ui-panels/src/sections/group_box.rs b/crates/ui-panels/src/sections/group_box.rs index a43d3a3d5..fcb41e24b 100644 --- a/crates/ui-panels/src/sections/group_box.rs +++ b/crates/ui-panels/src/sections/group_box.rs @@ -10,7 +10,7 @@ use crate::style::{ComponentStyle, StyleCx, SurfaceKind}; use craft_behavior::{Metrics, Sense}; use egui::Ui; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The heading level AccessKit reports for a section header. diff --git a/crates/ui-panels/src/sections/mod.rs b/crates/ui-panels/src/sections/mod.rs index 84760feb1..fc85268b7 100644 --- a/crates/ui-panels/src/sections/mod.rs +++ b/crates/ui-panels/src/sections/mod.rs @@ -2,7 +2,7 @@ pub(crate) mod footer; mod group_box; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod sample; mod section; mod stack; diff --git a/crates/ui-panels/src/sections/panel.rs b/crates/ui-panels/src/sections/panel.rs index 4d4786d73..ec1dd4cbb 100644 --- a/crates/ui-panels/src/sections/panel.rs +++ b/crates/ui-panels/src/sections/panel.rs @@ -18,7 +18,7 @@ use crate::style::{ComponentStyle, StyleColor, StyleCx, SurfaceKind, UiTokens}; use craft_behavior::{Metrics, Sense}; use egui::{CornerRadius, Id, Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a panel: the surface and padding come from the container. diff --git a/crates/ui-panels/src/sections/reorderable.rs b/crates/ui-panels/src/sections/reorderable.rs index 2fab48c83..2de08e6fe 100644 --- a/crates/ui-panels/src/sections/reorderable.rs +++ b/crates/ui-panels/src/sections/reorderable.rs @@ -16,7 +16,7 @@ use egui::{Response, Ui}; use std::cell::RefCell; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The commands of a section, run on the section that holds the focus: its header menu rows and any chord the keymap diff --git a/crates/ui-panels/src/sections/section.rs b/crates/ui-panels/src/sections/section.rs index 31e3b09d8..d9ac2829a 100644 --- a/crates/ui-panels/src/sections/section.rs +++ b/crates/ui-panels/src/sections/section.rs @@ -15,7 +15,7 @@ use crate::style::{ComponentStyle, StyleCx}; use craft_behavior::{Metrics, PointerButton, PressPhase, Sense}; use egui::{Id, Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a section: no surface or padding of its own; the header and body carry the look. diff --git a/crates/ui-panels/src/sections/stack.rs b/crates/ui-panels/src/sections/stack.rs index d7ee0de3f..6b70b0bf7 100644 --- a/crates/ui-panels/src/sections/stack.rs +++ b/crates/ui-panels/src/sections/stack.rs @@ -15,7 +15,7 @@ use craft_behavior::{Axis, EditEvent, Metrics, Mixed, Sense}; use egui::{Pos2, Rect, Response, Ui}; use std::sync::{Arc, Mutex, PoisonError}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// What a section of a stack is told about its place: `Section::in_stack` reads it. diff --git a/crates/ui-panels/src/sections/title_row.rs b/crates/ui-panels/src/sections/title_row.rs index 9e8764d99..a6b17e9ea 100644 --- a/crates/ui-panels/src/sections/title_row.rs +++ b/crates/ui-panels/src/sections/title_row.rs @@ -20,7 +20,7 @@ use craft_theme::variant::Tone; use craft_theme::{ControlSize, Stateful, States}; use egui::{Id, Rect, Response, Ui, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// How much weight a header carries. diff --git a/crates/ui-patterns/Cargo.toml b/crates/ui-patterns/Cargo.toml index dc63a22b4..a7e70a5b6 100644 --- a/crates/ui-patterns/Cargo.toml +++ b/crates/ui-patterns/Cargo.toml @@ -15,6 +15,7 @@ test = false workspace = true [features] +suite = ["testing", "craft-ui-panels/suite"] default = [] # `craft_ui::testing`. testing = ["craft-ui-panels/testing"] @@ -40,7 +41,7 @@ craft-pdf = { path = "../pdf", version = "=0.1.0", default-features = false } zeroize = "1.9" [dev-dependencies] -craft-ui-patterns = { path = ".", features = ["testing"] } +craft-ui-patterns = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-theme = { workspace = true } craft-ui-test-kit = { workspace = true } diff --git a/crates/ui-patterns/src/lib.rs b/crates/ui-patterns/src/lib.rs index 906d4b154..cd7982b15 100644 --- a/crates/ui-patterns/src/lib.rs +++ b/crates/ui-patterns/src/lib.rs @@ -10,7 +10,7 @@ extern crate self as craft_ui; #[doc(hidden)] pub use craft_ui_panels::canvas_data; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] #[doc(hidden)] pub use craft_ui_panels::story_kit; #[cfg(feature = "testing")] @@ -31,5 +31,6 @@ pub mod patterns; pub mod testing { pub use craft_ui_panels::testing::*; + #[cfg(feature = "suite")] crate::testing_registered!(); } diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index 902dda70e..7a7e50121 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -35,7 +35,7 @@ use std::fmt::Debug; use std::hash::Hash; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// A layout the dock cannot show: the workspace failed `Workspace::validate`. The area draws nothing for it. diff --git a/crates/ui-patterns/src/patterns/dock/panes.rs b/crates/ui-patterns/src/patterns/dock/panes.rs index d4aa504b5..ed31d02a5 100644 --- a/crates/ui-patterns/src/patterns/dock/panes.rs +++ b/crates/ui-patterns/src/patterns/dock/panes.rs @@ -29,7 +29,7 @@ use std::cell::RefCell; use std::fmt::Debug; use std::hash::Hash; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// Where a pane is shown. diff --git a/crates/ui-patterns/src/patterns/dock/switcher.rs b/crates/ui-patterns/src/patterns/dock/switcher.rs index 7a8b94497..a3bb100ff 100644 --- a/crates/ui-patterns/src/patterns/dock/switcher.rs +++ b/crates/ui-patterns/src/patterns/dock/switcher.rs @@ -1,6 +1,6 @@ //! `WorkspaceSwitcher`: a select over the workspace set's names with the workspace commands in its list. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use crate::contract::{Bind, Entry, NoValue, Outcome, Props as _, Show as _, Sizing}; diff --git a/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs b/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs index f711d7e58..8d744fd80 100644 --- a/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs +++ b/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs @@ -1,7 +1,7 @@ //! `NewWorkspaceDialog` and `DeleteWorkspaceDialog`: the questions `run_workspace` returns as `WorkspaceAsk::Name` //! and `WorkspaceAsk::Which`. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::words::WorkspaceDialogWords; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/about.rs b/crates/ui-patterns/src/patterns/form_dialogs/about.rs index 916387830..4a695dbe0 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/about.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/about.rs @@ -3,7 +3,7 @@ mod contributors; mod credits; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use contributors::{CommitShare, ContributorSort, NameMode}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs index 0a7b55ae0..e9faf5ab0 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs @@ -40,7 +40,7 @@ use serde_json::Value; use std::borrow::Cow; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/ui-patterns/src/patterns/form_dialogs/export.rs b/crates/ui-patterns/src/patterns/form_dialogs/export.rs index e589aa5dd..1d18124f0 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/export.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/export.rs @@ -8,7 +8,7 @@ mod as_dialog; mod options; mod path_row; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::PreviewRequest; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/file_list.rs b/crates/ui-patterns/src/patterns/form_dialogs/file_list.rs index a09eb5b82..eb0e09586 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/file_list.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/file_list.rs @@ -20,7 +20,7 @@ use std::borrow::Cow; use std::cell::RefCell; use std::path::{Path, PathBuf}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The list shows this many rows, then scrolls. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/form.rs b/crates/ui-patterns/src/patterns/form_dialogs/form.rs index 3c3a8e50b..ebaa05092 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/form.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/form.rs @@ -30,7 +30,7 @@ use std::ops::{Deref, DerefMut}; use std::rc::Rc; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/ui-patterns/src/patterns/form_dialogs/guides.rs b/crates/ui-patterns/src/patterns/form_dialogs/guides.rs index de5c16e2c..70e260d73 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/guides.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/guides.rs @@ -10,9 +10,9 @@ mod layout; mod new_guide; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod trials; pub use layout::{GuideGroup, GuideLayoutError, GuideLayoutOptions, GuideLayoutPreset, GuideLength, GuideRect, GuideTarget, GuideUnits, MAX_COUNT}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs b/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs index 045df006b..5a68a116a 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs @@ -20,7 +20,7 @@ use egui::{Response, Ui}; use std::borrow::Cow; use std::cell::{Cell, RefCell}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/ui-patterns/src/patterns/form_dialogs/navigator_options.rs b/crates/ui-patterns/src/patterns/form_dialogs/navigator_options.rs index 2bd2b187e..29792fa9d 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/navigator_options.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/navigator_options.rs @@ -14,7 +14,7 @@ use crate::runtime::env::{Env, Label}; use crate::runtime::overlay::CloseReason; use egui::{Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The [`ColorRequest::key`](crate::runtime::requests::ColorRequest::key) of Panel Options' Custom… colour. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs b/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs index 95b449b17..00f53921e 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs @@ -4,7 +4,7 @@ mod cards; mod details; mod presets; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::form::{read_bind, write_bind}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/password.rs b/crates/ui-patterns/src/patterns/form_dialogs/password.rs index 907672343..14f07a8dd 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/password.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/password.rs @@ -21,7 +21,7 @@ use std::any::Any; use std::cell::{Cell, RefCell}; use std::fmt; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/ui-patterns/src/patterns/form_dialogs/path_row.rs b/crates/ui-patterns/src/patterns/form_dialogs/path_row.rs index 3ce657d83..8748183a4 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/path_row.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/path_row.rs @@ -1,6 +1,6 @@ //! `PathRow`: a path typed in a text field, with a Browse button that asks the host to pick one. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use crate::buttons::Button; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/pdf_export.rs b/crates/ui-patterns/src/patterns/form_dialogs/pdf_export.rs index 85a89d70d..a3992f27f 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/pdf_export.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/pdf_export.rs @@ -4,7 +4,7 @@ mod sections; mod summary; mod words; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use self::sections::{ArtboardChoice, PasswordSwitches, Sections}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/preview.rs b/crates/ui-patterns/src/patterns/form_dialogs/preview.rs index 84fda5c1e..da68bc79b 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/preview.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/preview.rs @@ -21,7 +21,7 @@ use egui::load::SizedTexture; use egui::{Pos2, Rect, Response, Ui, Vec2, pos2}; use std::ops::RangeInclusive; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The well: a drag on it pans the picture and a click centres the view on the point clicked. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/properties.rs b/crates/ui-patterns/src/patterns/form_dialogs/properties.rs index e4f5e105a..69e596225 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/properties.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/properties.rs @@ -15,7 +15,7 @@ use egui::{Response, Ui}; use std::borrow::Cow; use std::cell::RefCell; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// One row of a properties tab. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/report.rs b/crates/ui-patterns/src/patterns/form_dialogs/report.rs index 570bc1d9a..db3ed6040 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/report.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/report.rs @@ -16,7 +16,7 @@ use craft_theme::variant::Tone; use egui::{Response, Ui}; use serde_json::{Value, json}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; craft_ui::words! { diff --git a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs index 2ee03c78a..b1995c608 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs @@ -38,7 +38,7 @@ use std::ops::RangeInclusive; use std::path::PathBuf; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// Where a grid or point row's numbers go: whole numbers have no decimals. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/save_for_web.rs b/crates/ui-patterns/src/patterns/form_dialogs/save_for_web.rs index 417d06a7e..1732c1728 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/save_for_web.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/save_for_web.rs @@ -34,7 +34,7 @@ use std::path::{Path, PathBuf}; mod options; mod panes; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use panes::WebPane; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/sizing.rs b/crates/ui-patterns/src/patterns/form_dialogs/sizing.rs index 58d162681..63ea9a59e 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/sizing.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/sizing.rs @@ -22,7 +22,7 @@ use std::sync::Arc; mod canvas; mod image; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use canvas::{CanvasSize, CanvasSizeOutput, CanvasSizeResult, CanvasSizeValues, HostedCanvasSize}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/watermark.rs b/crates/ui-patterns/src/patterns/form_dialogs/watermark.rs index 839add6fa..ee87b3599 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/watermark.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/watermark.rs @@ -25,7 +25,7 @@ use serde::{Deserialize, Serialize}; use std::ops::RangeInclusive; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The key of the image request the Choose button files. diff --git a/crates/ui-patterns/src/patterns/panels/history.rs b/crates/ui-patterns/src/patterns/panels/history.rs index 1028486df..026ff0523 100644 --- a/crates/ui-patterns/src/patterns/panels/history.rs +++ b/crates/ui-patterns/src/patterns/panels/history.rs @@ -20,7 +20,7 @@ use std::cell::RefCell; use std::collections::HashSet; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The column of the source marks. diff --git a/crates/ui-patterns/src/patterns/panels/inspector.rs b/crates/ui-patterns/src/patterns/panels/inspector.rs index aae2c3fe0..1bfcf73f0 100644 --- a/crates/ui-patterns/src/patterns/panels/inspector.rs +++ b/crates/ui-patterns/src/patterns/panels/inspector.rs @@ -9,7 +9,7 @@ use crate::sections::{HeaderAction, HeaderStrength, MenuRows, Panel, PanelOutput use craft_theme::variant::Tone; use egui::{AsIdSalt, IdSalt, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// A properties panel: a `Panel` whose header names the target (icon and name, and the kind at the end), and whose body diff --git a/crates/ui-patterns/src/patterns/panels/modifier_keys.rs b/crates/ui-patterns/src/patterns/panels/modifier_keys.rs index 96e951869..cfdf1c14b 100644 --- a/crates/ui-patterns/src/patterns/panels/modifier_keys.rs +++ b/crates/ui-patterns/src/patterns/panels/modifier_keys.rs @@ -9,7 +9,7 @@ use craft_keymap::{Mods, Platform}; use egui::{Response, Ui}; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The panel's buttons in their fixed order, each with the one modifier it latches: Shift, the command key (⌘ on diff --git a/crates/ui-patterns/src/patterns/panels/palette.rs b/crates/ui-patterns/src/patterns/panels/palette.rs index 3bcbcb44c..494bb6f68 100644 --- a/crates/ui-patterns/src/patterns/panels/palette.rs +++ b/crates/ui-patterns/src/patterns/panels/palette.rs @@ -22,7 +22,7 @@ use egui::{Response, Ui}; use std::hash::{Hash, Hasher}; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The most commands the empty query lists when the app has run none. diff --git a/crates/ui-patterns/src/patterns/panels/tour.rs b/crates/ui-patterns/src/patterns/panels/tour.rs index c782f4343..81c253cc3 100644 --- a/crates/ui-patterns/src/patterns/panels/tour.rs +++ b/crates/ui-patterns/src/patterns/panels/tour.rs @@ -19,7 +19,7 @@ use craft_theme::variant::Variant; use egui::{Rect, Ui}; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The keys of a tour: Right goes to the next step and Left back (the keymap mirrors them in a right-to-left diff --git a/crates/ui-patterns/src/patterns/preferences/path_setting.rs b/crates/ui-patterns/src/patterns/preferences/path_setting.rs index 495eb85f4..90ab8972a 100644 --- a/crates/ui-patterns/src/patterns/preferences/path_setting.rs +++ b/crates/ui-patterns/src/patterns/preferences/path_setting.rs @@ -1,6 +1,6 @@ //! `PathSetting`: a path setting of Preferences, typed or picked through the host's file service, kept in the draft. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::SettingsDraft; diff --git a/crates/ui-patterns/src/patterns/preferences/window.rs b/crates/ui-patterns/src/patterns/preferences/window.rs index 29305e148..5c880039f 100644 --- a/crates/ui-patterns/src/patterns/preferences/window.rs +++ b/crates/ui-patterns/src/patterns/preferences/window.rs @@ -1,7 +1,7 @@ //! `PreferencesWindow`: the preferences body in an app-modal `Dialog` that opens in its own OS window where windows //! exist. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::body::{self, BodyOut}; diff --git a/crates/ui-patterns/src/patterns/presets/browser.rs b/crates/ui-patterns/src/patterns/presets/browser.rs index b8478dd70..ead741bf4 100644 --- a/crates/ui-patterns/src/patterns/presets/browser.rs +++ b/crates/ui-patterns/src/patterns/presets/browser.rs @@ -7,7 +7,7 @@ //! presets as rows of the same collection in both views: the grid's tail rows, the list's last rows. mod reorder; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use reorder::PresetReorder; diff --git a/crates/ui-patterns/src/patterns/presets/footer.rs b/crates/ui-patterns/src/patterns/presets/footer.rs index 219eabf4f..61e35f26e 100644 --- a/crates/ui-patterns/src/patterns/presets/footer.rs +++ b/crates/ui-patterns/src/patterns/presets/footer.rs @@ -11,7 +11,7 @@ use egui::{Response, Ui}; use std::marker::PhantomData; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// What a [`PresetFooter`] reports. A browser's footer reports these as `PresetEvent::Footer`, in order with its diff --git a/crates/ui-patterns/src/patterns/presets/manager.rs b/crates/ui-patterns/src/patterns/presets/manager.rs index ff588d268..12f7f2053 100644 --- a/crates/ui-patterns/src/patterns/presets/manager.rs +++ b/crates/ui-patterns/src/patterns/presets/manager.rs @@ -1,7 +1,7 @@ //! `PresetManager`: a dialog body for managing the presets of several kinds: a kind select over the presets of that //! kind, with rename and delete, and the host's own action buttons. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::browser::PresetBrowser; diff --git a/crates/ui-patterns/src/patterns/presets/named.rs b/crates/ui-patterns/src/patterns/presets/named.rs index b5e03f2ed..e57be9646 100644 --- a/crates/ui-patterns/src/patterns/presets/named.rs +++ b/crates/ui-patterns/src/patterns/presets/named.rs @@ -5,7 +5,7 @@ //! commits the name, Escape or Cancel closes it, and a name the host refuses shows its message under the field and //! keeps the prompt open. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::event::PresetEvent; diff --git a/crates/ui-patterns/src/patterns/presets/picker.rs b/crates/ui-patterns/src/patterns/presets/picker.rs index bbc557008..08a4e44e3 100644 --- a/crates/ui-patterns/src/patterns/presets/picker.rs +++ b/crates/ui-patterns/src/patterns/presets/picker.rs @@ -5,7 +5,7 @@ //! (`keep_open`), give the browser a footer, set how far the thumbnails zoom, open the popover at a point without the //! field (`open_at`) and let the user resize it (`resizable`). -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use std::sync::Arc; diff --git a/crates/ui-shell/Cargo.toml b/crates/ui-shell/Cargo.toml index d55e80fcb..828982e81 100644 --- a/crates/ui-shell/Cargo.toml +++ b/crates/ui-shell/Cargo.toml @@ -15,6 +15,7 @@ test = false workspace = true [features] +suite = ["testing", "craft-ui-panels/suite"] default = [] # `shell::app`: the eframe entry point. app = ["dep:eframe", "craft-window/ui"] @@ -45,7 +46,7 @@ web-time = "1.1" craft-window = { workspace = true, features = ["appkit"] } [dev-dependencies] -craft-ui-shell = { path = ".", features = ["testing"] } +craft-ui-shell = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-host = { workspace = true } craft-theme = { workspace = true } diff --git a/crates/ui-shell/src/lib.rs b/crates/ui-shell/src/lib.rs index c6db34059..267f8e077 100644 --- a/crates/ui-shell/src/lib.rs +++ b/crates/ui-shell/src/lib.rs @@ -10,7 +10,7 @@ extern crate self as craft_ui; #[doc(hidden)] pub use craft_ui_panels::canvas_data; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] #[doc(hidden)] pub use craft_ui_panels::story_kit; #[cfg(feature = "testing")] @@ -31,5 +31,6 @@ pub mod shell; pub mod testing { pub use craft_ui_panels::testing::*; + #[cfg(feature = "suite")] crate::testing_registered!(); } diff --git a/crates/ui-shell/src/shell/app_shell.rs b/crates/ui-shell/src/shell/app_shell.rs index ef3c9bd83..345f37f6e 100644 --- a/crates/ui-shell/src/shell/app_shell.rs +++ b/crates/ui-shell/src/shell/app_shell.rs @@ -3,7 +3,7 @@ //! name of each region come from the pipeline. mod dialogs; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use self::dialogs::{ShellDialogsCx, WindowDialogs}; diff --git a/crates/ui-shell/src/shell/canvas_shell.rs b/crates/ui-shell/src/shell/canvas_shell.rs index 5167630fc..ebb3ade00 100644 --- a/crates/ui-shell/src/shell/canvas_shell.rs +++ b/crates/ui-shell/src/shell/canvas_shell.rs @@ -18,7 +18,7 @@ //! +----------------------+ //! ``` -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::app_shell::{RegionBody, ShellRegion}; diff --git a/crates/ui-shell/src/shell/caption_button.rs b/crates/ui-shell/src/shell/caption_button.rs index c8e3f73a9..8ceafc2db 100644 --- a/crates/ui-shell/src/shell/caption_button.rs +++ b/crates/ui-shell/src/shell/caption_button.rs @@ -15,7 +15,7 @@ use craft_theme::{Stateful, States}; use egui::emath::GuiRounding as _; use egui::{Color32, ColorImage, CornerRadius, Painter, Pos2, Rect, Response, Stroke, StrokeKind, Vec2, pos2, vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The button's one part: the whole slot. diff --git a/crates/ui-shell/src/shell/document_window.rs b/crates/ui-shell/src/shell/document_window.rs index 7425692b0..6aef5f494 100644 --- a/crates/ui-shell/src/shell/document_window.rs +++ b/crates/ui-shell/src/shell/document_window.rs @@ -1,6 +1,6 @@ //! `DocumentWindow`: a document's window, a container in its own OS viewport. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use crate::contract::overlay::OverlayFit; diff --git a/crates/ui-shell/src/shell/opening.rs b/crates/ui-shell/src/shell/opening.rs index d82b31ad3..2f322695d 100644 --- a/crates/ui-shell/src/shell/opening.rs +++ b/crates/ui-shell/src/shell/opening.rs @@ -10,7 +10,7 @@ use crate::runtime::env::{Env, Label}; use crate::style::{SurfaceKind, TypeRole}; use egui::{Layout, Response, Ui, UiBuilder}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// A centred card: "Opening {name}…" elided on one line with the full text on hover, the muted message, a progress bar diff --git a/crates/ui-shell/src/shell/screen_mode_button.rs b/crates/ui-shell/src/shell/screen_mode_button.rs index 3817ae02d..0e2566b71 100644 --- a/crates/ui-shell/src/shell/screen_mode_button.rs +++ b/crates/ui-shell/src/shell/screen_mode_button.rs @@ -7,7 +7,7 @@ use crate::rails::{FlyoutButton, RailTool}; use crate::runtime::env::Env; use egui::{Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// A flyout button over the three screen modes, with `mode` marked: a click, Enter or Space cycles; a hold, a drag away diff --git a/crates/ui-shell/src/shell/start.rs b/crates/ui-shell/src/shell/start.rs index 311e10148..35d13a288 100644 --- a/crates/ui-shell/src/shell/start.rs +++ b/crates/ui-shell/src/shell/start.rs @@ -1,7 +1,7 @@ //! `StartScreen`: the page an app shows with no document open: New and Open, the recent files as a grid or a list, //! pinned folders and templates. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::recent::{RecentFile, RecentSort, RecentView, Template, ThumbKey, sort_recent}; diff --git a/crates/ui-shell/src/shell/title_bar/bar.rs b/crates/ui-shell/src/shell/title_bar/bar.rs index 0cad197ed..454a579c9 100644 --- a/crates/ui-shell/src/shell/title_bar/bar.rs +++ b/crates/ui-shell/src/shell/title_bar/bar.rs @@ -1,6 +1,6 @@ //! `TitleBar`: the app-drawn bar of a window, in the title slot of an `AppShell`. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::measure::{End, Ends, Strip}; diff --git a/crates/ui-shell/src/shell/viewport_window.rs b/crates/ui-shell/src/shell/viewport_window.rs index 90e8ad5a9..a6fbf287c 100644 --- a/crates/ui-shell/src/shell/viewport_window.rs +++ b/crates/ui-shell/src/shell/viewport_window.rs @@ -1,6 +1,6 @@ //! `ViewportWindow`: an app window in its own OS window where windows exist, else a dialog layer over the parent. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use crate::contract::{Bind, BodyCx, NoValue, Outcome, Overlay, Pattern, Props, SaveKey, ShowContainer as _}; diff --git a/crates/ui-widgets/Cargo.toml b/crates/ui-widgets/Cargo.toml index 1be428234..3e5521ab0 100644 --- a/crates/ui-widgets/Cargo.toml +++ b/crates/ui-widgets/Cargo.toml @@ -15,6 +15,7 @@ test = false workspace = true [features] +suite = ["testing", "craft-ui-contract/suite"] default = [] # `craft_ui::testing` with the story helpers that show components. testing = ["craft-ui-contract/testing"] @@ -32,7 +33,7 @@ smallvec = { workspace = true } serde = { workspace = true } [dev-dependencies] -craft-ui-widgets = { path = ".", features = ["testing"] } +craft-ui-widgets = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-host = { workspace = true } craft-i18n = { workspace = true, features = ["collate"] } diff --git a/crates/ui-widgets/src/bars/align.rs b/crates/ui-widgets/src/bars/align.rs index 8f915e9eb..c0b9f0d43 100644 --- a/crates/ui-widgets/src/bars/align.rs +++ b/crates/ui-widgets/src/bars/align.rs @@ -10,7 +10,7 @@ use crate::style::GlyphRole; use craft_behavior::fit::FitKeep; use egui::{Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// One align or distribute command. The commands are app commands: the app gates them with command state and takes diff --git a/crates/ui-widgets/src/bars/breadcrumb.rs b/crates/ui-widgets/src/bars/breadcrumb.rs index 6e993e622..90ae6e3d2 100644 --- a/crates/ui-widgets/src/bars/breadcrumb.rs +++ b/crates/ui-widgets/src/bars/breadcrumb.rs @@ -17,7 +17,7 @@ use craft_behavior::fit::{FitItem, FitKeep, fit_items}; use craft_behavior::{Axis, CursorIcon, Flow, IconId, Metrics, NavShape, PartKey, PartRef, Roving, Sense, Value}; use egui::{Rect, Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; const HIDDEN: PartKey = PartKey::new("hidden"); diff --git a/crates/ui-widgets/src/bars/constraint_fields.rs b/crates/ui-widgets/src/bars/constraint_fields.rs index c0dffc57e..188f438b5 100644 --- a/crates/ui-widgets/src/bars/constraint_fields.rs +++ b/crates/ui-widgets/src/bars/constraint_fields.rs @@ -16,7 +16,7 @@ use egui::{Response, Ui}; use std::ops::RangeInclusive; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The three kinds of [`Constraint`], as the Style select lists them. diff --git a/crates/ui-widgets/src/bars/mod.rs b/crates/ui-widgets/src/bars/mod.rs index c9dc5bb6e..0b4e4c236 100644 --- a/crates/ui-widgets/src/bars/mod.rs +++ b/crates/ui-widgets/src/bars/mod.rs @@ -8,7 +8,7 @@ mod items; mod lead; mod status; mod status_readout; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/ui-widgets/src/bars/status_readout.rs b/crates/ui-widgets/src/bars/status_readout.rs index cf64231a6..2e0f2683e 100644 --- a/crates/ui-widgets/src/bars/status_readout.rs +++ b/crates/ui-widgets/src/bars/status_readout.rs @@ -15,7 +15,7 @@ use craft_behavior::{CanvasView, EditEvents, IconId, Mixed, PixelSize}; use egui::{Response, Ui}; use std::time::Duration; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// Shown for an item whose value the host does not know. diff --git a/crates/ui-widgets/src/buttons/mod.rs b/crates/ui-widgets/src/buttons/mod.rs index fc6299fb7..0b3e133fc 100644 --- a/crates/ui-widgets/src/buttons/mod.rs +++ b/crates/ui-widgets/src/buttons/mod.rs @@ -5,7 +5,7 @@ pub(crate) mod face; pub mod icon_button; pub mod link; pub mod split_button; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub mod toggle_button; mod words; diff --git a/crates/ui-widgets/src/choice/check.rs b/crates/ui-widgets/src/choice/check.rs index 2412a8bc1..5aac81ec6 100644 --- a/crates/ui-widgets/src/choice/check.rs +++ b/crates/ui-widgets/src/choice/check.rs @@ -92,5 +92,5 @@ impl Component for Checkbox<'_> { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/ui-widgets/src/choice/radio.rs b/crates/ui-widgets/src/choice/radio.rs index 518309780..8e2b846b0 100644 --- a/crates/ui-widgets/src/choice/radio.rs +++ b/crates/ui-widgets/src/choice/radio.rs @@ -223,5 +223,5 @@ impl Component for Radio { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/ui-widgets/src/choice/rating.rs b/crates/ui-widgets/src/choice/rating.rs index 77202885e..0db4d1c26 100644 --- a/crates/ui-widgets/src/choice/rating.rs +++ b/crates/ui-widgets/src/choice/rating.rs @@ -203,5 +203,5 @@ impl Component for Rating<'_> { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/ui-widgets/src/choice/segmented.rs b/crates/ui-widgets/src/choice/segmented.rs index 2541c9458..0ea652ad0 100644 --- a/crates/ui-widgets/src/choice/segmented.rs +++ b/crates/ui-widgets/src/choice/segmented.rs @@ -250,5 +250,5 @@ impl Component for Segment { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/ui-widgets/src/choice/swatch.rs b/crates/ui-widgets/src/choice/swatch.rs index f65ad8def..008cf2be5 100644 --- a/crates/ui-widgets/src/choice/swatch.rs +++ b/crates/ui-widgets/src/choice/swatch.rs @@ -14,7 +14,7 @@ use craft_behavior::{Metrics, Mixed, Sense, Value}; use craft_theme::{Rgba, Srgba, Stateful, States, over}; use egui::{Color32, CornerRadius, Rect, Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// Opacity of the black or white ring that stands out from a well's colour. diff --git a/crates/ui-widgets/src/choice/swatch_table.rs b/crates/ui-widgets/src/choice/swatch_table.rs index e731a695e..adf28392e 100644 --- a/crates/ui-widgets/src/choice/swatch_table.rs +++ b/crates/ui-widgets/src/choice/swatch_table.rs @@ -12,7 +12,7 @@ use craft_behavior::{DisplayOrder, ItemSource, Metrics, Selection, TileLayout}; use craft_theme::Srgba; use egui::{Response, Ui, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The entries of a colour table as an item source: keyed by index, named for type-ahead. diff --git a/crates/ui-widgets/src/choice/switch.rs b/crates/ui-widgets/src/choice/switch.rs index 9bd4a6e20..d00031722 100644 --- a/crates/ui-widgets/src/choice/switch.rs +++ b/crates/ui-widgets/src/choice/switch.rs @@ -113,5 +113,5 @@ impl Component for Switch<'_> { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/ui-widgets/src/controls/mod.rs b/crates/ui-widgets/src/controls/mod.rs index 5fedaf35f..c25e18cbc 100644 --- a/crates/ui-widgets/src/controls/mod.rs +++ b/crates/ui-widgets/src/controls/mod.rs @@ -1,5 +1,5 @@ //! Value controls: `Disclosure`. pub mod disclosure; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/ui-widgets/src/display/badge.rs b/crates/ui-widgets/src/display/badge.rs index 40deb2149..ee54e5926 100644 --- a/crates/ui-widgets/src/display/badge.rs +++ b/crates/ui-widgets/src/display/badge.rs @@ -12,7 +12,7 @@ use craft_theme::{ use egui::{Response, Vec2}; use std::borrow::Cow; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The largest count a count badge shows; more reads `99+`. diff --git a/crates/ui-widgets/src/display/divider.rs b/crates/ui-widgets/src/display/divider.rs index c373f0506..44efb3b5b 100644 --- a/crates/ui-widgets/src/display/divider.rs +++ b/crates/ui-widgets/src/display/divider.rs @@ -5,7 +5,7 @@ use crate::style::{ComponentStyle, RuleWidth, StyleCx}; use craft_behavior::{Metrics, Sense}; use egui::{Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a divider. diff --git a/crates/ui-widgets/src/display/icon.rs b/crates/ui-widgets/src/display/icon.rs index 390af10d1..3a217dcdf 100644 --- a/crates/ui-widgets/src/display/icon.rs +++ b/crates/ui-widgets/src/display/icon.rs @@ -8,7 +8,7 @@ use craft_theme::variant::Tone; use craft_theme::{Stateful, States}; use egui::{Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of an icon. diff --git a/crates/ui-widgets/src/display/inspect_overlay.rs b/crates/ui-widgets/src/display/inspect_overlay.rs index baacd2f6f..96cde9cb1 100644 --- a/crates/ui-widgets/src/display/inspect_overlay.rs +++ b/crates/ui-widgets/src/display/inspect_overlay.rs @@ -10,7 +10,7 @@ use craft_theme::Opacity; use egui::{CornerRadius, Pos2, Rect, Response, Vec2}; use std::sync::Arc; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// Which drawings an [`InspectOverlay`] shows. diff --git a/crates/ui-widgets/src/display/kbd.rs b/crates/ui-widgets/src/display/kbd.rs index 8649c36da..b2e3ef5e3 100644 --- a/crates/ui-widgets/src/display/kbd.rs +++ b/crates/ui-widgets/src/display/kbd.rs @@ -12,7 +12,7 @@ use craft_keymap::{Chord, Layout, ReturnGlyph, Trigger}; use craft_theme::Stateful; use egui::{Rect, Response, Vec2, pos2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a chord. diff --git a/crates/ui-widgets/src/display/picture.rs b/crates/ui-widgets/src/display/picture.rs index dbd617fb8..d47be3ec9 100644 --- a/crates/ui-widgets/src/display/picture.rs +++ b/crates/ui-widgets/src/display/picture.rs @@ -9,7 +9,7 @@ use crate::style::{ComponentStyle, StyleCx}; use craft_behavior::{Metrics, Sense}; use egui::{ColorImage, Id, Pos2, Rect, Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// How large a picture is: its height, from a token. diff --git a/crates/ui-widgets/src/display/progress.rs b/crates/ui-widgets/src/display/progress.rs index 0d80c770e..0e4061ed7 100644 --- a/crates/ui-widgets/src/display/progress.rs +++ b/crates/ui-widgets/src/display/progress.rs @@ -8,7 +8,7 @@ use craft_theme::variant::{Emphasis, Tone}; use craft_theme::{Stateful, Variant}; use egui::{CornerRadius, Rect, Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// Seconds for the unknown-extent segment to cross the track. diff --git a/crates/ui-widgets/src/display/spinner.rs b/crates/ui-widgets/src/display/spinner.rs index ad3b34b35..f9f28ccdd 100644 --- a/crates/ui-widgets/src/display/spinner.rs +++ b/crates/ui-widgets/src/display/spinner.rs @@ -10,7 +10,7 @@ use craft_theme::Stateful; use egui::{Pos2, Response, Vec2, vec2}; use std::f32::consts::{PI, TAU}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// How long the spinner takes for a turn, in seconds. diff --git a/crates/ui-widgets/src/display/target_mark.rs b/crates/ui-widgets/src/display/target_mark.rs index 3f192b9cb..20753fb94 100644 --- a/crates/ui-widgets/src/display/target_mark.rs +++ b/crates/ui-widgets/src/display/target_mark.rs @@ -13,7 +13,7 @@ use craft_theme::Mix as _; use egui::{CornerRadius, Rect, Response, Ui}; use std::f32::consts::TAU; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The period of the pulse in seconds: a sine of four radians per second. diff --git a/crates/ui-widgets/src/display/text.rs b/crates/ui-widgets/src/display/text.rs index 666161ab6..cc84c50b9 100644 --- a/crates/ui-widgets/src/display/text.rs +++ b/crates/ui-widgets/src/display/text.rs @@ -8,7 +8,7 @@ use craft_behavior::{Metrics, Proposal, Sense}; use craft_theme::{Stateful, States, variant::Tone}; use egui::{Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// How strongly the text reads against its surface. diff --git a/crates/ui-widgets/src/form/mod.rs b/crates/ui-widgets/src/form/mod.rs index da36f14f9..efa196c15 100644 --- a/crates/ui-widgets/src/form/mod.rs +++ b/crates/ui-widgets/src/form/mod.rs @@ -3,7 +3,7 @@ mod field; mod group; mod slider_field; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/ui-widgets/src/form/slider_field.rs b/crates/ui-widgets/src/form/slider_field.rs index 13b6b2a8f..015429972 100644 --- a/crates/ui-widgets/src/form/slider_field.rs +++ b/crates/ui-widgets/src/form/slider_field.rs @@ -1,6 +1,6 @@ //! `SliderField`: a slider and a number field over one value. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use crate::contract::{ diff --git a/crates/ui-widgets/src/graph/mod.rs b/crates/ui-widgets/src/graph/mod.rs index ee9273e19..0d0793784 100644 --- a/crates/ui-widgets/src/graph/mod.rs +++ b/crates/ui-widgets/src/graph/mod.rs @@ -6,7 +6,7 @@ mod kind; mod node; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use kind::{NodeEvent, NodeId, NodeKind, PortRef, Wire, WireDrag}; diff --git a/crates/ui-widgets/src/layout_components/mod.rs b/crates/ui-widgets/src/layout_components/mod.rs index c4cee2fa6..78e0f94f3 100644 --- a/crates/ui-widgets/src/layout_components/mod.rs +++ b/crates/ui-widgets/src/layout_components/mod.rs @@ -10,7 +10,7 @@ use crate::style::{ComponentStyle, StyleCx}; use craft_behavior::{ColumnWidth, Insets, Metrics, Sense}; use egui::{Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of the layout components: no minimum size, and padding only at the start edge, one diff --git a/crates/ui-widgets/src/lib.rs b/crates/ui-widgets/src/lib.rs index 3ec71b0ef..446d09a5e 100644 --- a/crates/ui-widgets/src/lib.rs +++ b/crates/ui-widgets/src/lib.rs @@ -30,7 +30,7 @@ pub mod menu; pub mod notices; pub mod pickers; pub mod popover; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] #[doc(hidden)] pub mod story_kit; pub mod table; @@ -43,8 +43,10 @@ pub mod value_drag; /// `story_props`. #[cfg(feature = "testing")] pub mod testing { + #[cfg(feature = "suite")] pub use crate::story_kit::{props, story_props}; pub use craft_ui_contract::testing::*; + #[cfg(feature = "suite")] crate::testing_registered!(); } diff --git a/crates/ui-widgets/src/list/mod.rs b/crates/ui-widgets/src/list/mod.rs index 1f7c2930b..b5d9824e5 100644 --- a/crates/ui-widgets/src/list/mod.rs +++ b/crates/ui-widgets/src/list/mod.rs @@ -5,13 +5,13 @@ mod findings; mod predicate; #[doc(hidden)] pub mod row; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod toggle; mod tree; mod undo; mod view; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod view_stories; mod view_words; mod words; diff --git a/crates/ui-widgets/src/menu/bar.rs b/crates/ui-widgets/src/menu/bar.rs index c8cdac79d..87fee1fc6 100644 --- a/crates/ui-widgets/src/menu/bar.rs +++ b/crates/ui-widgets/src/menu/bar.rs @@ -15,7 +15,7 @@ //! The Help menu can start with a search field over a list of `HelpEntry` commands: typing lists up to `search::MAX_RESULTS` //! matches by label, English label or menu path, each as a command row with its path as detail. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::search::{HelpEntry, search_order}; diff --git a/crates/ui-widgets/src/menu/mod.rs b/crates/ui-widgets/src/menu/mod.rs index 3fc886ffe..7271572a5 100644 --- a/crates/ui-widgets/src/menu/mod.rs +++ b/crates/ui-widgets/src/menu/mod.rs @@ -8,7 +8,7 @@ pub mod level; mod panel; mod popup; pub mod search; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod words; diff --git a/crates/ui-widgets/src/notices/mod.rs b/crates/ui-widgets/src/notices/mod.rs index cdfb18bc3..386586e52 100644 --- a/crates/ui-widgets/src/notices/mod.rs +++ b/crates/ui-widgets/src/notices/mod.rs @@ -7,7 +7,7 @@ mod settings; mod toasts; mod words; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use center::{NoticeCenter, NoticeCenterOutput, NoticeEnd, PostedNotice}; diff --git a/crates/ui-widgets/src/pickers/combo_box.rs b/crates/ui-widgets/src/pickers/combo_box.rs index 0f9eb9247..52dcd9f6f 100644 --- a/crates/ui-widgets/src/pickers/combo_box.rs +++ b/crates/ui-widgets/src/pickers/combo_box.rs @@ -4,7 +4,7 @@ //! component's own popup on the dropdown preset, so focus stays in the text part and the host hands the list keys to //! the list. The option the keys make active puts its text in the field; the list's Escape puts back what was typed. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::dress::RowDress; diff --git a/crates/ui-widgets/src/pickers/date.rs b/crates/ui-widgets/src/pickers/date.rs index eb4e282f8..46327edbf 100644 --- a/crates/ui-widgets/src/pickers/date.rs +++ b/crates/ui-widgets/src/pickers/date.rs @@ -7,7 +7,7 @@ mod calendar; mod codec; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; pub use calendar::{Calendar, CalendarOutput, CalendarStyle, CalendarView, local_month_grid, month_grid}; diff --git a/crates/ui-widgets/src/pickers/face.rs b/crates/ui-widgets/src/pickers/face.rs index c4afb34fb..fff9d93f5 100644 --- a/crates/ui-widgets/src/pickers/face.rs +++ b/crates/ui-widgets/src/pickers/face.rs @@ -249,7 +249,7 @@ impl Component for SelectFace<'_> { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// Opens the popup of a picker whose face part toggles it, from the keyboard: Enter and Space (an activation by key) diff --git a/crates/ui-widgets/src/pickers/icon_picker.rs b/crates/ui-widgets/src/pickers/icon_picker.rs index 6220a3839..0b556a4ca 100644 --- a/crates/ui-widgets/src/pickers/icon_picker.rs +++ b/crates/ui-widgets/src/pickers/icon_picker.rs @@ -3,7 +3,7 @@ //! The pattern puts a `TextField::search` over a `TileGrid`. The field drives the grid: Up and Down move into the //! tiles, Enter picks the active tile, and focus stays in the field. A click on a tile picks it. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::words::PickerWords; diff --git a/crates/ui-widgets/src/pickers/reference_point.rs b/crates/ui-widgets/src/pickers/reference_point.rs index e66ee2a65..5e8162485 100644 --- a/crates/ui-widgets/src/pickers/reference_point.rs +++ b/crates/ui-widgets/src/pickers/reference_point.rs @@ -14,7 +14,7 @@ use crate::style::{ComponentStyle, Flags, FocusLook, Stateful, States, StyleColo use craft_behavior::{Anchor9, Metrics, NavShape, PartKey, PartRef, Roving, Sense}; use egui::{Pos2, Rect, Vec2, vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; const CELL: PartKey = PartKey::new("cell"); diff --git a/crates/ui-widgets/src/pickers/select.rs b/crates/ui-widgets/src/pickers/select.rs index b6ebb1f1e..7a0f2fee3 100644 --- a/crates/ui-widgets/src/pickers/select.rs +++ b/crates/ui-widgets/src/pickers/select.rs @@ -31,7 +31,7 @@ use craft_theme::{Stateful, States}; use egui::{Rect, Ui, Vec2}; use std::borrow::Cow; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The part that shows the face over the whole field and opens the list on a click. diff --git a/crates/ui-widgets/src/pickers/tree_picker.rs b/crates/ui-widgets/src/pickers/tree_picker.rs index 30b6fc81d..2f41e422e 100644 --- a/crates/ui-widgets/src/pickers/tree_picker.rs +++ b/crates/ui-widgets/src/pickers/tree_picker.rs @@ -4,7 +4,7 @@ //! list: folders open and close with Left, Right, Enter and a click, and an item is picked with Enter or a click. //! Typing lists the items whose path holds every typed word instead of the tree. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::SelectFace; diff --git a/crates/ui-widgets/src/pickers/unit_select.rs b/crates/ui-widgets/src/pickers/unit_select.rs index e303f3374..e0b7accc3 100644 --- a/crates/ui-widgets/src/pickers/unit_select.rs +++ b/crates/ui-widgets/src/pickers/unit_select.rs @@ -11,7 +11,7 @@ use craft_behavior::{EditEvents, Flow, Metrics, Mixed, NumberCodec, Proposal, Se use egui::{Rect, Response, Vec2, pos2}; use std::ops::{Deref, RangeInclusive}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a unit select: the gap between the field and the select, and the number field's width. diff --git a/crates/ui-widgets/src/popover/anchored.rs b/crates/ui-widgets/src/popover/anchored.rs index 3c51a81c7..d3d158a84 100644 --- a/crates/ui-widgets/src/popover/anchored.rs +++ b/crates/ui-widgets/src/popover/anchored.rs @@ -206,5 +206,5 @@ impl Container for Popover<'_> { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; diff --git a/crates/ui-widgets/src/popover/drop_veil.rs b/crates/ui-widgets/src/popover/drop_veil.rs index b27b9dbe9..26a248183 100644 --- a/crates/ui-widgets/src/popover/drop_veil.rs +++ b/crates/ui-widgets/src/popover/drop_veil.rs @@ -12,7 +12,7 @@ use crate::style::{ComponentStyle, Corners, Insets, Stateful, StyleCx, SurfaceKi use craft_behavior::{Metrics, Proposal, Sense}; use egui::{Rect, Response}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a drop veil: the scrim comes from the surface kind; the card is a child. diff --git a/crates/ui-widgets/src/popover/popup_list.rs b/crates/ui-widgets/src/popover/popup_list.rs index 38465aa75..85533caca 100644 --- a/crates/ui-widgets/src/popover/popup_list.rs +++ b/crates/ui-widgets/src/popover/popup_list.rs @@ -8,7 +8,7 @@ use crate::style::{ComponentStyle, StyleCx, SurfaceKind}; use craft_behavior::{Metrics, Sense}; use egui::Response; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The style of a popup list: the surface comes from the container. diff --git a/crates/ui-widgets/src/table/metadata.rs b/crates/ui-widgets/src/table/metadata.rs index 861b7a99c..36183c8c4 100644 --- a/crates/ui-widgets/src/table/metadata.rs +++ b/crates/ui-widgets/src/table/metadata.rs @@ -325,7 +325,7 @@ impl<'a> MetadataTable<'a> { } } -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The rows stamp of a filter query: the same query keeps the layout, another one rebuilds it. diff --git a/crates/ui-widgets/src/table/mod.rs b/crates/ui-widgets/src/table/mod.rs index 392a02dcf..be0a212ac 100644 --- a/crates/ui-widgets/src/table/mod.rs +++ b/crates/ui-widgets/src/table/mod.rs @@ -2,7 +2,7 @@ mod metadata; mod sort; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod view; mod words; diff --git a/crates/ui-widgets/src/tabs/document.rs b/crates/ui-widgets/src/tabs/document.rs index 340dc95b7..8bb6147a3 100644 --- a/crates/ui-widgets/src/tabs/document.rs +++ b/crates/ui-widgets/src/tabs/document.rs @@ -2,7 +2,7 @@ //! strip through the drag session, and tear off when released over no strip; the host areas at both ends of the strip //! are the caller's closures. Files from the OS drop between the tabs when the host takes them. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::{Tab, TabStrip}; diff --git a/crates/ui-widgets/src/tabs/strip.rs b/crates/ui-widgets/src/tabs/strip.rs index 0d7ef1981..c1be1b4b3 100644 --- a/crates/ui-widgets/src/tabs/strip.rs +++ b/crates/ui-widgets/src/tabs/strip.rs @@ -6,7 +6,7 @@ //! `ItemSource::text` is each tab's name in the overflow menu. The drag payload of a tab is `ListDrag`; a dock that //! carries panels reads the same payload with the panel key as `K`. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::rules::{FitMode, OverflowMenu, OverflowPlace, TabKind}; diff --git a/crates/ui-widgets/src/tabs/tab.rs b/crates/ui-widgets/src/tabs/tab.rs index 2909a2577..e54c3c658 100644 --- a/crates/ui-widgets/src/tabs/tab.rs +++ b/crates/ui-widgets/src/tabs/tab.rs @@ -20,7 +20,7 @@ use craft_behavior::{Flow, IconId, Insets, Metrics, PartKey, PointerButton, Pres use craft_theme::{Contrast, Rgba, Stateful, States, TypeRole}; use egui::{Pos2, Rect, Response, Vec2}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// What a tab's own parts report, besides what the collection reads from the pointer. diff --git a/crates/ui-widgets/src/text/alt_text.rs b/crates/ui-widgets/src/text/alt_text.rs index a93a82aa1..1d4a3f4cf 100644 --- a/crates/ui-widgets/src/text/alt_text.rs +++ b/crates/ui-widgets/src/text/alt_text.rs @@ -1,6 +1,6 @@ //! `AltTextField`: an object's description for people who cannot see it, with a Mark as decorative check. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::{FieldStyle, text_part}; diff --git a/crates/ui-widgets/src/text/chips.rs b/crates/ui-widgets/src/text/chips.rs index 9aeaae597..d48f4e7f6 100644 --- a/crates/ui-widgets/src/text/chips.rs +++ b/crates/ui-widgets/src/text/chips.rs @@ -1,7 +1,7 @@ //! `ChipField`: a list of text chips in lines, each removable, with a draft text part after the last chip, "+N more" //! where a line limit stops the list, and Clear All. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::{FieldStyle, text_part}; diff --git a/crates/ui-widgets/src/text/hex.rs b/crates/ui-widgets/src/text/hex.rs index 08d6fbb6a..9ea16d0b8 100644 --- a/crates/ui-widgets/src/text/hex.rs +++ b/crates/ui-widgets/src/text/hex.rs @@ -1,7 +1,7 @@ //! `HexField`: a text field over a colour's hex digits, the `#` side label its row shows before it, and `HexCodec`, //! the codec behind it. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::TextField; diff --git a/crates/ui-widgets/src/text/linked.rs b/crates/ui-widgets/src/text/linked.rs index 930533ba2..87bc66acd 100644 --- a/crates/ui-widgets/src/text/linked.rs +++ b/crates/ui-widgets/src/text/linked.rs @@ -1,7 +1,7 @@ //! `LinkedFields`: number fields joined by a link toggle that keeps their values in proportion (width and height) or //! equal (four sides). -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::NumberField; diff --git a/crates/ui-widgets/src/text/number.rs b/crates/ui-widgets/src/text/number.rs index b7a0d27f7..ef033a6ab 100644 --- a/crates/ui-widgets/src/text/number.rs +++ b/crates/ui-widgets/src/text/number.rs @@ -4,7 +4,7 @@ //! range every written value stays in and the step that arrows, the wheel and a scrub move by. A drag on a field that //! is not in edit scrubs it; a click enters edit, where a drag selects text. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::adorn::{Adornment, Placed, place, reserve}; diff --git a/crates/ui-widgets/src/text/selectable_text.rs b/crates/ui-widgets/src/text/selectable_text.rs index e802598b6..c04393052 100644 --- a/crates/ui-widgets/src/text/selectable_text.rs +++ b/crates/ui-widgets/src/text/selectable_text.rs @@ -1,6 +1,6 @@ //! `SelectableText`: read-only text the user can focus, select and copy. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use crate::contract::{Access, Common, Component, Cx, MeasureCx, PaintUi, PartsCx, Props as _, Role, Styled as _}; diff --git a/crates/ui-widgets/src/text/text_field.rs b/crates/ui-widgets/src/text/text_field.rs index 439c90430..a58112cf3 100644 --- a/crates/ui-widgets/src/text/text_field.rs +++ b/crates/ui-widgets/src/text/text_field.rs @@ -1,6 +1,6 @@ //! `TextField`: a text field over a codec, with the search form and the adornment layout. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::adorn::{self, Adornment}; diff --git a/crates/ui-widgets/src/text/zoom_field.rs b/crates/ui-widgets/src/text/zoom_field.rs index dc5db73ce..cf859db1e 100644 --- a/crates/ui-widgets/src/text/zoom_field.rs +++ b/crates/ui-widgets/src/text/zoom_field.rs @@ -9,7 +9,7 @@ use craft_behavior::kurbo::Size; use craft_behavior::{CanvasView, EditEvents, ZoomLadder}; use egui::{Response, Ui}; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The decimals the zoom range's ends are written with in the message, as the field shows a zoom. diff --git a/crates/ui-widgets/src/tile_grid/grid.rs b/crates/ui-widgets/src/tile_grid/grid.rs index f02ea9d77..06348f3b8 100644 --- a/crates/ui-widgets/src/tile_grid/grid.rs +++ b/crates/ui-widgets/src/tile_grid/grid.rs @@ -5,7 +5,7 @@ //! the item step that hold the lead), and the rating keys. It owns what its cards have in common: where the //! caption goes, whether a detail line is reserved, and the zoom. -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; use super::headers::Outline; diff --git a/crates/ui-widgets/src/tile_grid/mod.rs b/crates/ui-widgets/src/tile_grid/mod.rs index 19322017a..f3705281e 100644 --- a/crates/ui-widgets/src/tile_grid/mod.rs +++ b/crates/ui-widgets/src/tile_grid/mod.rs @@ -7,7 +7,7 @@ mod grid; mod headers; mod layout; mod slider; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; mod tile; mod words; diff --git a/crates/ui-widgets/src/value_drag/angle_dial.rs b/crates/ui-widgets/src/value_drag/angle_dial.rs index a0518a233..ce5b9060a 100644 --- a/crates/ui-widgets/src/value_drag/angle_dial.rs +++ b/crates/ui-widgets/src/value_drag/angle_dial.rs @@ -17,7 +17,7 @@ use craft_theme::{Stateful, States}; use egui::{CornerRadius, Pos2, Rect, Vec2}; use std::ops::RangeInclusive; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The face: the circle the pointer points at. diff --git a/crates/ui-widgets/src/value_drag/point_picker.rs b/crates/ui-widgets/src/value_drag/point_picker.rs index 6f877c725..89f5df8b3 100644 --- a/crates/ui-widgets/src/value_drag/point_picker.rs +++ b/crates/ui-widgets/src/value_drag/point_picker.rs @@ -19,7 +19,7 @@ use craft_behavior::{ use egui::{Pos2, Rect, Vec2, pos2}; use std::ops::RangeInclusive; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The point: a drag on it follows the pointer. diff --git a/crates/ui-widgets/src/value_drag/range_slider.rs b/crates/ui-widgets/src/value_drag/range_slider.rs index 5ecce7e4b..c97893c7a 100644 --- a/crates/ui-widgets/src/value_drag/range_slider.rs +++ b/crates/ui-widgets/src/value_drag/range_slider.rs @@ -16,7 +16,7 @@ use craft_theme::Stateful; use egui::{Pos2, Rect, Vec2}; use std::ops::RangeInclusive; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The track both thumbs ride on. diff --git a/crates/ui-widgets/src/value_drag/slider.rs b/crates/ui-widgets/src/value_drag/slider.rs index e63553c07..54bbf032d 100644 --- a/crates/ui-widgets/src/value_drag/slider.rs +++ b/crates/ui-widgets/src/value_drag/slider.rs @@ -17,7 +17,7 @@ use craft_theme::Stateful; use egui::{Pos2, Rect, Vec2}; use std::ops::RangeInclusive; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The track the thumb rides on. diff --git a/crates/ui-widgets/src/value_drag/thumb_row.rs b/crates/ui-widgets/src/value_drag/thumb_row.rs index f11da91d0..d96044e60 100644 --- a/crates/ui-widgets/src/value_drag/thumb_row.rs +++ b/crates/ui-widgets/src/value_drag/thumb_row.rs @@ -32,7 +32,7 @@ use std::ops::RangeInclusive; /// How far a thumb's width runs past the standard handle side, in small handle sides (the old levels thumb: 8 + 6 / 2). const THUMB_WIDTH_IN_SMALL_HANDLES: f32 = 0.5; -#[cfg(feature = "testing")] +#[cfg(feature = "suite")] mod stories; /// The row-wide part: a press off the thumbs lands here. diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.toml index 4bf541158..5b8644d4e 100644 --- a/crates/ui/Cargo.toml +++ b/crates/ui/Cargo.toml @@ -16,6 +16,7 @@ test = false workspace = true [features] +suite = ["testing", "craft-ui-contract/suite", "craft-ui-widgets/suite", "craft-ui-panels/suite", "craft-ui-canvas/suite", "craft-ui-patterns/suite", "craft-ui-shell/suite"] default = [] # `shell::app`: the eframe entry point. app = ["craft-ui-shell/app"] @@ -51,7 +52,7 @@ craft-ui-shell = { workspace = true } craft-cloud-ui = { workspace = true } [dev-dependencies] -craft-ui = { path = ".", features = ["testing"] } +craft-ui = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-i18n = { workspace = true, features = ["collate"] } egui = { workspace = true } diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index bd7618f67..0188f2d49 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -46,12 +46,15 @@ pub mod patterns { pub mod testing { pub use craft_ui_canvas::testing::*; + #[cfg(feature = "suite")] crate::testing_registered!(); /// A crate's `registered`. + #[cfg(feature = "suite")] type Registered = fn() -> Vec<&'static Registration>; /// The crates of the library, each with its `registered`. + #[cfg(feature = "suite")] const LIBRARY: [(&str, Registered); 7] = [ ("craft-ui", registered), ("craft-ui-contract", craft_ui_contract::testing::registered), @@ -64,6 +67,7 @@ pub mod testing { /// Every registration declared in the library crates of the library: this crate and the six it re-exports. /// Types declared in integration binaries are fixtures and are left out. + #[cfg(feature = "suite")] pub fn library_registrations() -> Vec<&'static Registration> { // A crate's registrations run only in a binary that links the crate; naming each crate's `registered` // links them all. diff --git a/crates/update/Cargo.toml b/crates/update/Cargo.toml index db6a8d872..0325ea8f9 100644 --- a/crates/update/Cargo.toml +++ b/crates/update/Cargo.toml @@ -17,6 +17,7 @@ harness = false workspace = true [features] +suite = ["screen-testing", "craft-ui/suite"] # Opt-in migration of first party Flatpak bundles to the ArtCraft OCI remote. oci_migration = [] default = [] @@ -43,7 +44,7 @@ chrono = { workspace = true } semver = { version = "1", features = ["serde"] } [dev-dependencies] -craft-ui = { workspace = true, features = ["testing"] } +craft-ui = { workspace = true, features = ["suite"] } flate2 = "1" [target.'cfg(unix)'.dependencies] diff --git a/crates/update/src/lib.rs b/crates/update/src/lib.rs index 97ff5e342..ebe40129b 100644 --- a/crates/update/src/lib.rs +++ b/crates/update/src/lib.rs @@ -51,6 +51,7 @@ pub use version::{Version, is_newer, parse as parse_version}; #[cfg(feature = "screen-testing")] /// The registrations of this package for the integration binary. pub mod testing { + #[cfg(feature = "suite")] craft_ui::testing_registered!(); } diff --git a/crates/update/src/stack_dialogs.rs b/crates/update/src/stack_dialogs.rs index a66fa939c..fa3c405eb 100644 --- a/crates/update/src/stack_dialogs.rs +++ b/crates/update/src/stack_dialogs.rs @@ -23,7 +23,7 @@ use crate::release::{Release, safe_web_link}; use crate::self_update; use crate::updater::Status; -#[cfg(feature = "screen-testing")] +#[cfg(feature = "suite")] mod stories; const PROMPT_KEY: &str = "updateDialog.prompt"; diff --git a/docs/development.md b/docs/development.md index 0a5ec0911..0cf6e7a25 100644 --- a/docs/development.md +++ b/docs/development.md @@ -28,10 +28,12 @@ A fix to one gallery component, from the edit to its old/new picture on a page: cargo compiles a crate once per distinct feature set, and every crate above it once more, and it unifies features only over the packages a command selects. A framework crate's tests have no eframe in their graph; a domain crate's tests do; the gallery adds every domain crate, whose dependencies turn on more features of egui, wgpu, craft-window, image and others below the framework. Each kind of command would build its own copy of the framework, and wgpu with it. -`cl` selects the `feature-root` package beside the package of every command (`-p -p feature-root`). Its dependencies are the gallery's, with every domain crate's `screen-testing`, so every local build resolves features as the gallery does, and a target directory holds one build of each crate. Nothing of `feature-root` is compiled: its one target is a bin no `cl` command selects (`cl` names the crate's own targets), and only the targets a command names are built, so a render still links one domain crate and a framework crate's tests still link no app. On top, `cl` adds the crate's own test feature (`screen-testing`, else `testing`). The Mac's and CI's commands never select `feature-root` and are unaffected. +`cl` selects the `feature-root` package beside the package of every command (`-p -p feature-root`). Its dependencies are the gallery's, with every domain crate's `suite`, so every local build resolves features as the gallery does, and a target directory holds one build of each crate. Nothing of `feature-root` is compiled: its one target is a bin no `cl` command selects (`cl` names the crate's own targets), and only the targets a command names are built, so a render still links one domain crate and a framework crate's tests still link no app. On top, `cl` adds the crate's own test feature (`suite`, else `screen-testing`, else `testing`). The Mac's and CI's commands never select `feature-root` and are unaffected. Four manifest facts keep this true, and `cl doctor` checks them: `feature-root` lists every optional domain crate of the gallery with the gallery's features, and depends on the gallery without its default features (so the gallery lib's own features stay each command's: `apps` for the gallery, one crate for a render); the story renderer asks its shared dependencies for no feature the gallery's lines lack; dev-dependency lines ask egui for no features (a feature there differs between a crate's tests and everything else); the proc-macro crate pins syn's and proc-macro2's features to everything other derive crates may add, so the one syn every proc macro shares is the same with or without design-lint in the graph. `cl` names any new build of a framework crate in the target directory after each command; after a manifest change one is expected, otherwise run `cl doctor`. +The `testing` feature (or `screen-testing` on domain crates) supplies fixtures and helpers for app tests. The `suite` feature implies that kit and adds framework stories, registrations, trials, snapshots, and the suite runner. Framework and gallery tests enable `suite`; apps should use the kit without it. + ## App workspaces `tools/cl` finds its workspace with `git rev-parse --show-toplevel` from the current directory, so `/path/to/craft-libs/tools/cl` run inside an app's tree builds and tests that tree. An app workspace is one whose root `Cargo.toml` has a `[workspace.metadata.cl]` table. There every command selects the same packages (`selection`), in test mode, without `--features` (the test features come from the dev-dependencies). Each package brings features the others lack, so a command that drops one builds a second copy of the shared crates below it (in PhotoCraft egui, photocraft-io and craft-affinity) and of everything above them. The craft-libs workspace has no such table and keeps the commands above. diff --git a/tools/cl b/tools/cl index 76f421fca..69f327c45 100755 --- a/tools/cl +++ b/tools/cl @@ -31,7 +31,7 @@ the story renderer each pull in different crates, which turn on different featur others below the framework, so each would build its own copy of the framework (minutes, and wgpu again). cl selects the `feature-root` package beside every command's package: its dependencies are the gallery's, with every domain crate, so every command resolves features as the gallery does and builds only the targets it names. The crate's own -test feature (`screen-testing`, else `testing`) is added on top. Builds that take other features (CI's +test feature (`suite`, else `screen-testing`, else `testing`) is added on top. Builds that take other features (CI's `--all-features`, wasm checks) belong on GitHub. docs/development.md has the whole picture. Records: every build cl composes passes cargo's --timings (a report per build in /cargo-timings/, the newest @@ -183,6 +183,8 @@ def package(packages, name): def canonical(packages, name): """The package's name and the features cl adds for it, qualified: its own test feature.""" p = package(packages, name) + if "suite" in p["features"]: + return p["name"], [p["name"] + "/suite"] if "screen-testing" in p["features"]: return p["name"], [p["name"] + "/screen-testing"] if "testing" in p["features"] and p["name"] != "craft-ui-test-kit": @@ -219,7 +221,7 @@ def doctor(top, packages, quiet=False): gallery = packages.get("craft-ui-gallery") if gallery: for d in gallery["dependencies"]: - if d["name"].startswith("craft-") and "screen-testing" in d["features"] and not d["optional"]: + if d["name"].startswith("craft-") and "suite" in d["features"] and not d["optional"]: problems.append(f"crates/ui-gallery/Cargo.toml: {d['name']} must be optional (one feature per domain crate), or the story renderer links every crate") root = packages.get(ROOT) if not root: From b04d18a735879a01e0c8f905f7051f86356de0ca Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 12:20:08 +0100 Subject: [PATCH 02/22] Select UI suite items through explicit registries --- Cargo.lock | 1 + crates/automation/src/actions/mod.rs | 2 +- crates/automation/src/agents/mod.rs | 2 +- crates/automation/src/agents/settings.rs | 2 +- crates/automation/src/client.rs | 2 +- crates/automation/src/lib.rs | 7 +- crates/automation/src/security.rs | 2 +- crates/automation/src/ui/actions/mod.rs | 4 +- crates/automation/src/ui/agents/mod.rs | 2 +- crates/automation/tests/it/main.rs | 12 +- crates/browse/src/lib.rs | 4 +- crates/browse/src/links/mod.rs | 2 +- crates/browse/src/places/mod.rs | 2 +- crates/browse/src/ui/bin/mod.rs | 2 +- crates/browse/src/ui/compare/mod.rs | 6 +- crates/browse/src/ui/freebin/mod.rs | 2 +- crates/browse/src/ui/mod.rs | 3 +- crates/browse/src/ui/places/mod.rs | 2 +- crates/browse/src/ui/relink/mod.rs | 6 +- crates/browse/tests/it/main.rs | 10 +- crates/color-ui/src/display.rs | 2 +- crates/color-ui/src/lib.rs | 4 +- crates/color-ui/src/palette.rs | 2 +- crates/color-ui/src/ui/area.rs | 2 +- crates/color-ui/src/ui/choice.rs | 2 +- crates/color-ui/src/ui/compare.rs | 2 +- crates/color-ui/src/ui/disc.rs | 2 +- crates/color-ui/src/ui/droppers.rs | 2 +- crates/color-ui/src/ui/eyedropper.rs | 2 +- crates/color-ui/src/ui/gradient/editor.rs | 2 +- crates/color-ui/src/ui/gradient/mod.rs | 2 +- crates/color-ui/src/ui/harmony.rs | 2 +- crates/color-ui/src/ui/hud.rs | 2 +- crates/color-ui/src/ui/info.rs | 2 +- crates/color-ui/src/ui/lut_picker.rs | 2 +- crates/color-ui/src/ui/mod.rs | 52 ++-- crates/color-ui/src/ui/paint_chip.rs | 4 +- crates/color-ui/src/ui/pair.rs | 2 +- crates/color-ui/src/ui/palette.rs | 2 +- crates/color-ui/src/ui/panel.rs | 4 +- crates/color-ui/src/ui/picker/mod.rs | 6 +- crates/color-ui/src/ui/popover.rs | 2 +- crates/color-ui/src/ui/profile_prompts.rs | 2 +- crates/color-ui/src/ui/ramp.rs | 2 +- crates/color-ui/src/ui/readout.rs | 2 +- crates/color-ui/src/ui/samplers.rs | 2 +- crates/color-ui/src/ui/screen_picker.rs | 4 +- crates/color-ui/src/ui/strip.rs | 2 +- crates/color-ui/src/ui/swatches.rs | 6 +- crates/color-ui/src/ui/swatches/library.rs | 2 +- crates/color-ui/src/ui/testing.rs | 2 +- crates/color-ui/src/ui/warning.rs | 2 +- crates/color-ui/src/ui/wheel.rs | 2 +- crates/color-ui/tests/it/main.rs | 16 +- crates/design-lint/src/contract/mod.rs | 7 +- .../src/contract/registry_expansion.rs | 121 +++++++++ crates/dialogs/src/lib.rs | 15 +- crates/dialogs/src/portal.rs | 2 +- crates/dialogs/src/probe.rs | 2 +- crates/dialogs/src/service.rs | 2 +- crates/dialogs/src/ui/mod.rs | 4 +- crates/dialogs/tests/it/main.rs | 2 +- crates/draw/src/geometry/mod.rs | 8 +- crates/draw/src/lib.rs | 7 +- crates/draw/src/stroke/mod.rs | 2 +- crates/draw/src/ui/artboard/mod.rs | 8 +- crates/draw/src/ui/brush_presets/mod.rs | 4 +- crates/draw/src/ui/brush_settings/mod.rs | 12 +- crates/draw/src/ui/connector/mod.rs | 6 +- crates/draw/src/ui/corner/mod.rs | 2 +- crates/draw/src/ui/crop/bar.rs | 2 +- crates/draw/src/ui/crop/mod.rs | 12 +- crates/draw/src/ui/crop/perspective_bar.rs | 2 +- crates/draw/src/ui/crop/perspective_crop.rs | 2 +- crates/draw/src/ui/crop/tool.rs | 2 +- crates/draw/src/ui/gradient/fill_editor.rs | 2 +- .../src/ui/gradient/gradient_overlay/mod.rs | 2 +- crates/draw/src/ui/gradient/map/mod.rs | 2 +- crates/draw/src/ui/gradient/mod.rs | 6 +- crates/draw/src/ui/gradient/palette/mod.rs | 2 +- crates/draw/src/ui/gradient/swatch.rs | 2 +- crates/draw/src/ui/measure/mod.rs | 6 +- crates/draw/src/ui/paint_bar.rs | 2 +- crates/draw/src/ui/paths/mod.rs | 2 +- crates/draw/src/ui/pattern/mod.rs | 2 +- crates/draw/src/ui/pen/bezier/mod.rs | 2 +- crates/draw/src/ui/pen/mod.rs | 2 +- crates/draw/src/ui/picture_fill/mod.rs | 4 +- crates/draw/src/ui/shape/mod.rs | 12 +- crates/draw/src/ui/shape_presets.rs | 2 +- crates/draw/src/ui/slice/mod.rs | 6 +- crates/draw/src/ui/stroke/mod.rs | 4 +- crates/draw/src/ui/symmetry/mod.rs | 8 +- crates/draw/src/ui/transform/mod.rs | 8 +- crates/draw/src/ui/transform/session_bar.rs | 2 +- .../draw/src/ui/transform/session_overlay.rs | 2 +- crates/draw/src/ui/transform/transform_box.rs | 2 +- .../draw/src/ui/transform/transform_fields.rs | 2 +- crates/draw/tests/it/main.rs | 56 ++-- crates/font-manager/src/axes.rs | 2 +- crates/font-manager/src/axes/sliders.rs | 2 +- crates/font-manager/src/glyphs.rs | 2 +- crates/font-manager/src/lib.rs | 5 +- crates/font-manager/src/missing.rs | 2 +- crates/font-manager/src/panel/app.rs | 2 +- crates/font-manager/src/panel/browse.rs | 4 +- crates/font-manager/src/panel/details.rs | 4 +- crates/font-manager/src/panel/mod.rs | 8 +- crates/font-manager/src/panel/sources.rs | 2 +- crates/font-manager/src/panel/specimen.rs | 2 +- crates/font-manager/src/picker.rs | 4 +- crates/font-manager/src/picker/rank.rs | 2 +- crates/font-manager/tests/it/main.rs | 14 +- crates/imaging/src/layer_style/mod.rs | 2 +- crates/imaging/src/lib.rs | 7 +- crates/imaging/src/scopes/mod.rs | 2 +- crates/imaging/src/trace/mod.rs | 2 +- crates/imaging/src/ui/adjust/basic.rs | 10 +- crates/imaging/src/ui/adjust/curves_panel.rs | 2 +- .../imaging/src/ui/adjust/hue_saturation.rs | 2 +- crates/imaging/src/ui/adjust/levels_editor.rs | 2 +- crates/imaging/src/ui/adjust/levels_panel.rs | 2 +- crates/imaging/src/ui/adjust/mixers.rs | 8 +- crates/imaging/src/ui/adjust/mod.rs | 20 +- crates/imaging/src/ui/adjust/panel.rs | 2 +- crates/imaging/src/ui/adjust/session.rs | 2 +- crates/imaging/src/ui/adjust/sliders.rs | 2 +- crates/imaging/src/ui/adjust/tone.rs | 2 +- crates/imaging/src/ui/blur_pins/mod.rs | 4 +- crates/imaging/src/ui/channels/mod.rs | 2 +- crates/imaging/src/ui/color_range/mod.rs | 4 +- crates/imaging/src/ui/curve/mod.rs | 8 +- crates/imaging/src/ui/fill/mod.rs | 6 +- crates/imaging/src/ui/filter_gallery/mod.rs | 6 +- crates/imaging/src/ui/histogram/mod.rs | 2 +- .../src/ui/layer_style/blend_if/mod.rs | 2 +- .../imaging/src/ui/layer_style/contour/mod.rs | 2 +- crates/imaging/src/ui/layer_style/mod.rs | 10 +- crates/imaging/src/ui/liquify/canvas.rs | 2 +- crates/imaging/src/ui/liquify/mod.rs | 4 +- crates/imaging/src/ui/mask_view/mod.rs | 2 +- crates/imaging/src/ui/raw_develop/mod.rs | 8 +- crates/imaging/src/ui/scopes/mod.rs | 8 +- crates/imaging/src/ui/select_mask/mod.rs | 4 +- crates/imaging/src/ui/selection/mod.rs | 2 +- .../src/ui/vanishing_point/editor/mod.rs | 2 +- crates/imaging/src/ui/vanishing_point/mod.rs | 4 +- crates/imaging/src/ui/warp/cylinder.rs | 2 +- crates/imaging/src/ui/warp/mod.rs | 10 +- crates/imaging/src/ui/warp/perspective/mod.rs | 4 +- crates/imaging/src/ui/warp/pin/mod.rs | 4 +- crates/imaging/src/ui/wide_angle/mod.rs | 4 +- crates/imaging/tests/it/main.rs | 50 ++-- crates/layers/src/lib.rs | 2 +- crates/layers/src/ui/comps/mod.rs | 2 +- crates/layers/src/ui/filter/mod.rs | 2 +- crates/layers/src/ui/options/mod.rs | 2 +- crates/layers/src/ui/panel/mod.rs | 2 +- crates/layers/src/ui/rows/mod.rs | 2 +- crates/layers/tests/it/main.rs | 20 +- crates/menu/src/bar.rs | 2 +- crates/menu/src/lib.rs | 3 +- crates/menu/src/shortcuts/mod.rs | 8 +- crates/menu/src/shortcuts/recorder.rs | 2 +- crates/menu/src/shortcuts/view.rs | 4 +- crates/menu/tests/it/main.rs | 12 +- crates/menu/tests/it/shortcuts/mod.rs | 8 +- crates/pages/src/lib.rs | 11 +- crates/pages/src/ui/column_bar.rs | 2 +- crates/pages/src/ui/grid.rs | 2 +- crates/pages/src/ui/header_footer.rs | 2 +- crates/pages/src/ui/list.rs | 2 +- crates/pages/src/ui/margins.rs | 2 +- crates/pages/src/ui/marks.rs | 2 +- crates/pages/src/ui/preview.rs | 2 +- crates/pages/src/ui/range.rs | 2 +- crates/pages/src/ui/reading.rs | 2 +- crates/pages/src/ui/setup.rs | 2 +- crates/pages/src/ui/table/mod.rs | 2 +- crates/pages/src/ui/text_selection.rs | 2 +- crates/pages/src/ui/thumbnails.rs | 2 +- crates/pages/src/ui/view.rs | 4 +- crates/pages/tests/it/main.rs | 12 +- crates/print/src/cups/mod.rs | 2 +- crates/print/src/lib.rs | 19 +- crates/print/src/progress.rs | 2 +- crates/print/src/sheets.rs | 2 +- crates/print/src/tests.rs | 4 +- crates/print/src/ticket.rs | 2 +- crates/print/src/ui/mod.rs | 6 +- crates/print/src/windows.rs | 2 +- crates/print/src/xml.rs | 2 +- crates/print/tests/it/main.rs | 4 +- crates/review/src/lib.rs | 11 +- crates/review/src/ui/annotate.rs | 6 +- crates/review/src/ui/avatar.rs | 2 +- crates/review/src/ui/chat.rs | 2 +- crates/review/src/ui/comments.rs | 6 +- crates/review/src/ui/join.rs | 2 +- crates/review/src/ui/presence.rs | 2 +- crates/review/src/ui/revisions.rs | 2 +- crates/review/src/ui/signature.rs | 2 +- crates/review/src/ui/thread.rs | 6 +- crates/review/src/ui/versions.rs | 2 +- crates/review/src/ui/vote.rs | 2 +- crates/review/tests/it/main.rs | 6 +- crates/table/src/ui/chart.rs | 2 +- crates/table/src/ui/conditions.rs | 2 +- crates/table/src/ui/error_tag.rs | 2 +- crates/table/src/ui/fields.rs | 2 +- crates/table/src/ui/filter.rs | 2 +- crates/table/src/ui/grid.rs | 4 +- crates/table/src/ui/mod.rs | 3 +- crates/table/src/ui/outline.rs | 2 +- crates/table/src/ui/slicer.rs | 2 +- crates/table/src/ui/stats.rs | 2 +- crates/table/tests/it/main.rs | 12 +- crates/text/src/bidi/mod.rs | 2 +- crates/text/src/composer.rs | 2 +- crates/text/src/hyphen/dict.rs | 2 +- crates/text/src/hyphen/mod.rs | 6 +- crates/text/src/lib.rs | 13 +- crates/text/src/linebreak/mod.rs | 2 +- crates/text/src/positioned.rs | 2 +- crates/text/src/segment/mod.rs | 2 +- crates/text/src/ui/character.rs | 6 +- crates/text/src/ui/character/style_options.rs | 2 +- crates/text/src/ui/columns.rs | 2 +- crates/text/src/ui/editor.rs | 2 +- crates/text/src/ui/find.rs | 6 +- crates/text/src/ui/hyperlink.rs | 2 +- crates/text/src/ui/notes.rs | 2 +- crates/text/src/ui/path_text.rs | 2 +- crates/text/src/ui/ruler.rs | 2 +- crates/text/src/ui/spelling.rs | 2 +- crates/text/src/ui/style_panel.rs | 2 +- crates/text/src/ui/tabs_dialog.rs | 2 +- crates/text/src/ui/type_bar.rs | 2 +- crates/text/tests/it/main.rs | 14 +- crates/theme-editor/src/lib.rs | 15 +- crates/theme-store/src/client.rs | 2 +- crates/theme-store/src/lib.rs | 14 +- crates/theme-store/src/selection.rs | 2 +- crates/theme-store/src/ui/mod.rs | 9 +- crates/theme-store/src/watch.rs | 2 +- crates/timeline/src/ale.rs | 2 +- crates/timeline/src/build.rs | 2 +- crates/timeline/src/edl.rs | 4 +- crates/timeline/src/fcpxml.rs | 2 +- crates/timeline/src/interchange.rs | 2 +- crates/timeline/src/lib.rs | 23 +- crates/timeline/src/otio.rs | 2 +- crates/timeline/src/path.rs | 2 +- crates/timeline/src/rate.rs | 2 +- crates/timeline/src/report.rs | 2 +- crates/timeline/src/ui/graph.rs | 2 +- crates/timeline/src/ui/keyframes.rs | 2 +- crates/timeline/src/ui/markers.rs | 4 +- crates/timeline/src/ui/overview.rs | 2 +- crates/timeline/src/ui/panel.rs | 2 +- crates/timeline/src/ui/preview.rs | 2 +- crates/timeline/src/ui/render_queue.rs | 2 +- crates/timeline/src/ui/ruler.rs | 2 +- crates/timeline/src/ui/stack.rs | 2 +- crates/timeline/src/ui/timecode.rs | 4 +- crates/timeline/src/ui/transport.rs | 2 +- crates/timeline/src/xml.rs | 2 +- crates/timeline/tests/it/main.rs | 18 +- crates/ui-canvas/Cargo.toml | 2 +- crates/ui-canvas/src/canvas/crop/mod.rs | 2 +- crates/ui-canvas/src/canvas/full_window.rs | 4 +- .../src/canvas/full_window/trials.rs | 2 +- .../ui-canvas/src/canvas/full_window_parts.rs | 12 +- crates/ui-canvas/src/canvas/mod.rs | 20 +- crates/ui-canvas/src/canvas/navigate/mod.rs | 4 +- crates/ui-canvas/src/canvas/navigator/mod.rs | 6 +- .../ui-canvas/src/canvas/navigator_panel.rs | 2 +- crates/ui-canvas/src/canvas/pasteboard/mod.rs | 2 +- crates/ui-canvas/src/canvas/raster/mod.rs | 2 +- crates/ui-canvas/src/canvas/rulers/mod.rs | 2 +- crates/ui-canvas/src/canvas/scrollbars/mod.rs | 2 +- crates/ui-canvas/src/canvas/split/mod.rs | 2 +- .../src/canvas_controls/brush/mod.rs | 10 +- .../ui-canvas/src/canvas_controls/grid/mod.rs | 2 +- .../src/canvas_controls/guides/mod.rs | 2 +- .../src/canvas_controls/marquee/mod.rs | 2 +- crates/ui-canvas/src/canvas_controls/mod.rs | 16 +- .../src/canvas_controls/outline/mod.rs | 2 +- .../src/canvas_controls/pixel_grid/mod.rs | 2 +- .../src/canvas_controls/smart_guides/mod.rs | 2 +- .../ui-canvas/src/canvas_controls/task_bar.rs | 2 +- crates/ui-canvas/src/lib.rs | 6 +- crates/ui-canvas/tests/it/canvas/mod.rs | 32 +-- .../ui-canvas/tests/it/canvas_controls/mod.rs | 12 +- crates/ui-canvas/tests/it/contract/derives.rs | 6 +- crates/ui-canvas/tests/it/contract/mod.rs | 2 +- .../ui-canvas/tests/it/full_window_parts.rs | 10 +- crates/ui-canvas/tests/it/main.rs | 16 +- crates/ui-contract/Cargo.toml | 2 +- crates/ui-contract/src/contract/items.rs | 2 +- crates/ui-contract/src/contract/label.rs | 2 +- crates/ui-contract/src/contract/level.rs | 48 +--- crates/ui-contract/src/contract/mod.rs | 9 +- crates/ui-contract/src/contract/registry.rs | 39 +-- crates/ui-contract/src/lib.rs | 2 +- .../ui-contract/src/runtime/commands/mod.rs | 2 + .../src/runtime/commands/registry.rs | 53 +++- crates/ui-contract/src/testing/index.rs | 6 +- crates/ui-contract/src/testing/mod.rs | 72 ++---- crates/ui-contract/src/testing/registry.rs | 84 ++++++ crates/ui-contract/src/testing/story.rs | 35 +-- crates/ui-contract/src/testing/suite.rs | 34 +-- crates/ui-contract/src/testing/suite/style.rs | 4 +- crates/ui-contract/tests/it/access/mod.rs | 16 +- crates/ui-contract/tests/it/body/mod.rs | 6 +- crates/ui-contract/tests/it/canvas/mod.rs | 4 +- crates/ui-contract/tests/it/collection/mod.rs | 18 +- crates/ui-contract/tests/it/contract/level.rs | 23 ++ crates/ui-contract/tests/it/contract/mod.rs | 15 +- .../tests/it/contract/visited_type.rs | 29 ++- crates/ui-contract/tests/it/fonts/mod.rs | 8 +- crates/ui-contract/tests/it/layout/mod.rs | 8 +- crates/ui-contract/tests/it/main.rs | 43 ++-- crates/ui-contract/tests/it/motion/mod.rs | 6 +- crates/ui-contract/tests/it/paint/mod.rs | 10 +- crates/ui-contract/tests/it/runtime/mod.rs | 28 +- crates/ui-contract/tests/it/style/mod.rs | 8 +- crates/ui-contract/tests/it/text/mod.rs | 4 +- crates/ui-gallery/Cargo.toml | 1 + crates/ui-gallery/src/bin/components-index.rs | 4 +- crates/ui-gallery/src/foundations/mod.rs | 6 +- crates/ui-gallery/src/lib.rs | 67 +++-- crates/ui-gallery/src/main.rs | 15 +- crates/ui-gallery/src/mock/mod.rs | 6 +- crates/ui-gallery/src/viewer/catalog.rs | 11 +- crates/ui-gallery/tests/it/main.rs | 11 +- crates/ui-gallery/tests/it/registry.rs | 49 ++++ crates/ui-macros/src/command_set.rs | 27 +- crates/ui-macros/src/component.rs | 28 +- crates/ui-macros/src/lib.rs | 41 ++- crates/ui-macros/src/registry.rs | 243 ++++++++++++++++++ .../tests/fixtures/registry/child.rs | 7 + .../tests/fixtures/registry/included.rs | 2 + .../tests/fixtures/registry/other.rs | 2 + .../ui-macros/tests/fixtures/registry/root.rs | 2 + crates/ui-panels/src/dialog/mod.rs | 16 +- crates/ui-panels/src/dialog/prompt.rs | 2 +- crates/ui-panels/src/docking/dock_column.rs | 2 +- crates/ui-panels/src/docking/floating.rs | 2 +- crates/ui-panels/src/docking/iconic.rs | 4 +- crates/ui-panels/src/docking/mod.rs | 16 +- crates/ui-panels/src/docking/root.rs | 2 +- crates/ui-panels/src/lib.rs | 6 +- crates/ui-panels/src/rails/drawer.rs | 2 +- crates/ui-panels/src/rails/flyout.rs | 2 +- crates/ui-panels/src/rails/mod.rs | 6 +- crates/ui-panels/src/rails/tool.rs | 4 +- crates/ui-panels/src/sections/footer.rs | 2 +- crates/ui-panels/src/sections/group_box.rs | 2 +- crates/ui-panels/src/sections/mod.rs | 12 +- crates/ui-panels/src/sections/panel.rs | 2 +- crates/ui-panels/src/sections/reorderable.rs | 2 +- crates/ui-panels/src/sections/section.rs | 2 +- crates/ui-panels/src/sections/stack.rs | 2 +- crates/ui-panels/src/sections/title_row.rs | 2 +- crates/ui-panels/tests/it/access/mod.rs | 2 +- crates/ui-panels/tests/it/body/mod.rs | 4 +- crates/ui-panels/tests/it/edit/mod.rs | 2 +- crates/ui-panels/tests/it/focus/mod.rs | 10 +- crates/ui-panels/tests/it/list/mod.rs | 2 +- crates/ui-panels/tests/it/main.rs | 24 +- crates/ui-panels/tests/it/popup_surface.rs | 5 +- crates/ui-panels/tests/it/rails/drawer.rs | 5 +- crates/ui-panels/tests/it/rails/mod.rs | 2 +- crates/ui-panels/tests/it/sections/mod.rs | 12 +- crates/ui-patterns/Cargo.toml | 2 +- crates/ui-patterns/src/lib.rs | 6 +- crates/ui-patterns/src/patterns/dock/area.rs | 2 +- crates/ui-patterns/src/patterns/dock/mod.rs | 8 +- crates/ui-patterns/src/patterns/dock/panes.rs | 2 +- .../ui-patterns/src/patterns/dock/switcher.rs | 2 +- .../src/patterns/dock/workspace_dialogs.rs | 2 +- .../src/patterns/form_dialogs/about.rs | 2 +- .../src/patterns/form_dialogs/dialog.rs | 2 +- .../src/patterns/form_dialogs/export.rs | 8 +- .../src/patterns/form_dialogs/file_list.rs | 2 +- .../src/patterns/form_dialogs/form.rs | 2 +- .../src/patterns/form_dialogs/guides.rs | 6 +- .../src/patterns/form_dialogs/list_manager.rs | 2 +- .../src/patterns/form_dialogs/mod.rs | 38 +-- .../form_dialogs/navigator_options.rs | 2 +- .../src/patterns/form_dialogs/new_document.rs | 2 +- .../src/patterns/form_dialogs/password.rs | 2 +- .../src/patterns/form_dialogs/path_row.rs | 2 +- .../src/patterns/form_dialogs/pdf_export.rs | 2 +- .../src/patterns/form_dialogs/preview.rs | 2 +- .../src/patterns/form_dialogs/properties.rs | 2 +- .../src/patterns/form_dialogs/report.rs | 2 +- .../src/patterns/form_dialogs/rows.rs | 2 +- .../src/patterns/form_dialogs/save_for_web.rs | 2 +- .../src/patterns/form_dialogs/sizing.rs | 6 +- .../src/patterns/form_dialogs/watermark.rs | 2 +- .../src/patterns/panels/history.rs | 2 +- .../src/patterns/panels/inspector.rs | 2 +- crates/ui-patterns/src/patterns/panels/mod.rs | 10 +- .../src/patterns/panels/modifier_keys.rs | 2 +- .../src/patterns/panels/palette.rs | 2 +- .../ui-patterns/src/patterns/panels/tour.rs | 2 +- .../src/patterns/preferences/mod.rs | 4 +- .../src/patterns/preferences/path_setting.rs | 2 +- .../src/patterns/preferences/window.rs | 2 +- .../src/patterns/presets/browser.rs | 2 +- .../src/patterns/presets/footer.rs | 2 +- .../src/patterns/presets/manager.rs | 2 +- .../ui-patterns/src/patterns/presets/mod.rs | 10 +- .../ui-patterns/src/patterns/presets/named.rs | 2 +- .../src/patterns/presets/picker.rs | 2 +- crates/ui-patterns/tests/it/docking/mod.rs | 30 +-- .../ui-patterns/tests/it/form_dialogs/mod.rs | 24 +- crates/ui-patterns/tests/it/main.rs | 20 +- crates/ui-patterns/tests/it/panels/mod.rs | 6 +- crates/ui-patterns/tests/it/panels/palette.rs | 5 +- .../ui-patterns/tests/it/preferences/mod.rs | 4 +- crates/ui-patterns/tests/it/presets/mod.rs | 8 +- crates/ui-shell/Cargo.toml | 2 +- crates/ui-shell/src/lib.rs | 6 +- crates/ui-shell/src/shell/app_shell.rs | 2 +- crates/ui-shell/src/shell/canvas_shell.rs | 2 +- crates/ui-shell/src/shell/caption_button.rs | 2 +- crates/ui-shell/src/shell/document_window.rs | 2 +- crates/ui-shell/src/shell/mod.rs | 16 +- crates/ui-shell/src/shell/opening.rs | 2 +- .../ui-shell/src/shell/screen_mode_button.rs | 2 +- crates/ui-shell/src/shell/start.rs | 2 +- crates/ui-shell/src/shell/title_bar.rs | 2 +- crates/ui-shell/src/shell/title_bar/bar.rs | 2 +- crates/ui-shell/src/shell/viewport_window.rs | 2 +- crates/ui-shell/tests/it/body/mod.rs | 2 +- crates/ui-shell/tests/it/commands/mod.rs | 8 +- crates/ui-shell/tests/it/contract/mod.rs | 2 +- crates/ui-shell/tests/it/dialog/mod.rs | 4 +- crates/ui-shell/tests/it/main.rs | 20 +- crates/ui-shell/tests/it/measure/mod.rs | 2 +- crates/ui-shell/tests/it/shell/mod.rs | 22 +- crates/ui-test-kit/Cargo.toml | 3 + crates/ui-test-kit/src/lib.rs | 6 + crates/ui-widgets/Cargo.toml | 2 +- crates/ui-widgets/src/bars/align.rs | 2 +- crates/ui-widgets/src/bars/breadcrumb.rs | 2 +- .../ui-widgets/src/bars/constraint_fields.rs | 2 +- crates/ui-widgets/src/bars/mod.rs | 18 +- crates/ui-widgets/src/bars/status_readout.rs | 2 +- crates/ui-widgets/src/buttons/mod.rs | 2 +- crates/ui-widgets/src/choice/check.rs | 2 +- crates/ui-widgets/src/choice/mod.rs | 10 +- crates/ui-widgets/src/choice/radio.rs | 2 +- crates/ui-widgets/src/choice/rating.rs | 2 +- crates/ui-widgets/src/choice/segmented.rs | 2 +- crates/ui-widgets/src/choice/swatch.rs | 2 +- crates/ui-widgets/src/choice/swatch_table.rs | 2 +- crates/ui-widgets/src/choice/switch.rs | 2 +- crates/ui-widgets/src/controls/mod.rs | 2 +- crates/ui-widgets/src/display/badge.rs | 2 +- crates/ui-widgets/src/display/divider.rs | 2 +- crates/ui-widgets/src/display/icon.rs | 2 +- .../ui-widgets/src/display/inspect_overlay.rs | 2 +- crates/ui-widgets/src/display/kbd.rs | 2 +- crates/ui-widgets/src/display/mod.rs | 20 +- crates/ui-widgets/src/display/picture.rs | 2 +- crates/ui-widgets/src/display/progress.rs | 2 +- crates/ui-widgets/src/display/spinner.rs | 2 +- crates/ui-widgets/src/display/target_mark.rs | 2 +- crates/ui-widgets/src/display/text.rs | 2 +- crates/ui-widgets/src/form/mod.rs | 8 +- crates/ui-widgets/src/form/slider_field.rs | 2 +- crates/ui-widgets/src/graph/mod.rs | 4 +- .../ui-widgets/src/layout_components/mod.rs | 11 +- crates/ui-widgets/src/lib.rs | 4 +- crates/ui-widgets/src/list/mod.rs | 12 +- crates/ui-widgets/src/list/row.rs | 2 +- crates/ui-widgets/src/menu/bar.rs | 2 +- crates/ui-widgets/src/menu/mod.rs | 8 +- crates/ui-widgets/src/notices/mod.rs | 10 +- crates/ui-widgets/src/pickers/combo_box.rs | 2 +- crates/ui-widgets/src/pickers/date.rs | 4 +- crates/ui-widgets/src/pickers/face.rs | 2 +- crates/ui-widgets/src/pickers/icon_picker.rs | 2 +- crates/ui-widgets/src/pickers/mod.rs | 16 +- .../ui-widgets/src/pickers/reference_point.rs | 2 +- crates/ui-widgets/src/pickers/select.rs | 2 +- crates/ui-widgets/src/pickers/tree_picker.rs | 2 +- crates/ui-widgets/src/pickers/unit_select.rs | 2 +- crates/ui-widgets/src/popover/anchored.rs | 2 +- crates/ui-widgets/src/popover/drop_veil.rs | 2 +- crates/ui-widgets/src/popover/mod.rs | 6 +- crates/ui-widgets/src/popover/popup_list.rs | 2 +- crates/ui-widgets/src/table/metadata.rs | 2 +- crates/ui-widgets/src/table/mod.rs | 6 +- crates/ui-widgets/src/tabs/document.rs | 2 +- crates/ui-widgets/src/tabs/mod.rs | 6 +- crates/ui-widgets/src/tabs/strip.rs | 2 +- crates/ui-widgets/src/tabs/tab.rs | 2 +- crates/ui-widgets/src/text/alt_text.rs | 2 +- crates/ui-widgets/src/text/chips.rs | 2 +- crates/ui-widgets/src/text/hex.rs | 2 +- crates/ui-widgets/src/text/linked.rs | 2 +- crates/ui-widgets/src/text/mod.rs | 16 +- crates/ui-widgets/src/text/number.rs | 2 +- crates/ui-widgets/src/text/selectable_text.rs | 2 +- crates/ui-widgets/src/text/text_field.rs | 2 +- crates/ui-widgets/src/text/zoom_field.rs | 2 +- crates/ui-widgets/src/tile_grid/grid.rs | 2 +- crates/ui-widgets/src/tile_grid/mod.rs | 8 +- .../ui-widgets/src/value_drag/angle_dial.rs | 2 +- crates/ui-widgets/src/value_drag/mod.rs | 10 +- .../ui-widgets/src/value_drag/point_picker.rs | 2 +- .../ui-widgets/src/value_drag/range_slider.rs | 2 +- crates/ui-widgets/src/value_drag/slider.rs | 2 +- crates/ui-widgets/src/value_drag/thumb_row.rs | 2 +- crates/ui-widgets/tests/it/access/mod.rs | 4 +- crates/ui-widgets/tests/it/bars/mod.rs | 10 +- crates/ui-widgets/tests/it/body/mod.rs | 4 +- crates/ui-widgets/tests/it/commands/mod.rs | 2 +- crates/ui-widgets/tests/it/contract/mod.rs | 8 +- crates/ui-widgets/tests/it/label/mod.rs | 20 +- crates/ui-widgets/tests/it/layer/mod.rs | 2 +- crates/ui-widgets/tests/it/layout/mod.rs | 30 +-- crates/ui-widgets/tests/it/main.rs | 62 ++--- crates/ui-widgets/tests/it/menu/mod.rs | 16 +- crates/ui-widgets/tests/it/overlay/mod.rs | 8 +- crates/ui-widgets/tests/it/pickers/mod.rs | 12 +- crates/ui-widgets/tests/it/popover/mod.rs | 6 +- crates/ui-widgets/tests/it/runtime/mod.rs | 4 +- crates/ui-widgets/tests/it/suite_rules.rs | 7 +- crates/ui-widgets/tests/it/text/chips.rs | 2 +- crates/ui-widgets/tests/it/text/mod.rs | 26 +- crates/ui-widgets/tests/it/tile_grid/mod.rs | 8 +- crates/ui-widgets/tests/it/value_drag.rs | 4 +- crates/ui-widgets/tests/it/values/mod.rs | 10 +- crates/ui/src/lib.rs | 52 ++-- crates/ui/tests/it/canvas/mod.rs | 2 +- crates/ui/tests/it/components_index.rs | 7 +- crates/ui/tests/it/form_dialogs/mod.rs | 2 +- crates/ui/tests/it/main.rs | 18 +- crates/ui/tests/it/shell/mod.rs | 2 +- crates/update/src/app.rs | 2 +- crates/update/src/desktop_entry.rs | 2 +- crates/update/src/detect.rs | 2 +- crates/update/src/install.rs | 2 +- crates/update/src/install/tests.rs | 2 +- crates/update/src/lib.rs | 13 +- crates/update/src/manifest.rs | 2 +- crates/update/src/msi_context.rs | 2 +- crates/update/src/msi_copy.rs | 2 +- crates/update/src/msi_migrate.rs | 2 +- crates/update/src/packages.rs | 8 +- crates/update/src/paths.rs | 2 +- crates/update/src/pins.rs | 2 +- crates/update/src/platform.rs | 2 +- crates/update/src/portable.rs | 2 +- crates/update/src/process.rs | 6 +- crates/update/src/proxy.rs | 2 +- crates/update/src/queue.rs | 2 +- crates/update/src/release.rs | 2 +- crates/update/src/self_update.rs | 2 +- crates/update/src/source.rs | 2 +- crates/update/src/stack_dialogs.rs | 2 +- crates/update/src/updater.rs | 2 +- crates/update/src/version.rs | 2 +- crates/update/tests/it/main.rs | 2 +- 570 files changed, 2273 insertions(+), 1605 deletions(-) create mode 100644 crates/design-lint/src/contract/registry_expansion.rs create mode 100644 crates/ui-contract/src/testing/registry.rs create mode 100644 crates/ui-contract/tests/it/contract/level.rs create mode 100644 crates/ui-gallery/tests/it/registry.rs create mode 100644 crates/ui-macros/src/registry.rs create mode 100644 crates/ui-macros/tests/fixtures/registry/child.rs create mode 100644 crates/ui-macros/tests/fixtures/registry/included.rs create mode 100644 crates/ui-macros/tests/fixtures/registry/other.rs create mode 100644 crates/ui-macros/tests/fixtures/registry/root.rs diff --git a/Cargo.lock b/Cargo.lock index 263fc929a..48d12ab3f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4251,6 +4251,7 @@ dependencies = [ "serde", "serde_json", "syn 2.0.119", + "toml", "wasm-bindgen-futures", "web-time", ] diff --git a/crates/automation/src/actions/mod.rs b/crates/automation/src/actions/mod.rs index a4dee0272..777272ebc 100644 --- a/crates/automation/src/actions/mod.rs +++ b/crates/automation/src/actions/mod.rs @@ -20,7 +20,7 @@ mod model; mod player; mod recording; #[cfg(test)] -mod tests; +pub(crate) mod tests; pub use file::{ActionsFile, ActionsFileError}; pub use list::{ActionList, ActionListError, LibraryEdit, MergedFile, moved_index}; diff --git a/crates/automation/src/agents/mod.rs b/crates/automation/src/agents/mod.rs index 949740ed8..55d0323ef 100644 --- a/crates/automation/src/agents/mod.rs +++ b/crates/automation/src/agents/mod.rs @@ -27,7 +27,7 @@ //! //! The Agents page of Preferences is [`crate::ui::agents`]. -mod settings; +pub(crate) mod settings; pub use settings::{AgentSettings, WhenAppClosed, agents_allowed, folder}; #[cfg(all(feature = "agents", not(target_arch = "wasm32")))] diff --git a/crates/automation/src/agents/settings.rs b/crates/automation/src/agents/settings.rs index 1b5918759..7395fd519 100644 --- a/crates/automation/src/agents/settings.rs +++ b/crates/automation/src/agents/settings.rs @@ -95,7 +95,7 @@ pub fn agents_allowed(mcp_flag: bool, launcher: bool, legacy: bool) -> bool { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/automation/src/client.rs b/crates/automation/src/client.rs index b32b98d28..2d57b4d10 100644 --- a/crates/automation/src/client.rs +++ b/crates/automation/src/client.rs @@ -89,4 +89,4 @@ enum Failure { #[cfg(all(test, feature = "ui"))] #[path = "client_tests.rs"] -mod client_tests; +pub(crate) mod client_tests; diff --git a/crates/automation/src/lib.rs b/crates/automation/src/lib.rs index 7757692df..339015183 100644 --- a/crates/automation/src/lib.rs +++ b/crates/automation/src/lib.rs @@ -57,17 +57,18 @@ pub use security::AutomationError; /// The trials this crate registers, for its integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(all(test, feature = "screen-testing"))] extern crate self as craft_automation; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/automation/src/security.rs b/crates/automation/src/security.rs index 96ac748c6..b294c15dd 100644 --- a/crates/automation/src/security.rs +++ b/crates/automation/src/security.rs @@ -473,4 +473,4 @@ impl std::io::Read for AuthDeadlineStream { #[cfg(test)] #[path = "security_tests.rs"] -mod security_tests; +pub(crate) mod security_tests; diff --git a/crates/automation/src/ui/actions/mod.rs b/crates/automation/src/ui/actions/mod.rs index 390a60cec..d8a30be9f 100644 --- a/crates/automation/src/ui/actions/mod.rs +++ b/crates/automation/src/ui/actions/mod.rs @@ -14,11 +14,11 @@ mod footer; mod menu; #[cfg(feature = "screen-testing")] pub mod mock; -mod panel; +pub(crate) mod panel; mod prompt; mod rows; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; pub use body::{ActionMove, ActionPlace}; diff --git a/crates/automation/src/ui/agents/mod.rs b/crates/automation/src/ui/agents/mod.rs index 39fd04c67..a22425b5f 100644 --- a/crates/automation/src/ui/agents/mod.rs +++ b/crates/automation/src/ui/agents/mod.rs @@ -1,7 +1,7 @@ //! `AgentsPage`: the Agents page of Preferences, over the agent settings in the Preferences draft. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; pub use words::AgentsWords; diff --git a/crates/automation/tests/it/main.rs b/crates/automation/tests/it/main.rs index 89d9855b2..047ef22da 100644 --- a/crates/automation/tests/it/main.rs +++ b/crates/automation/tests/it/main.rs @@ -2,9 +2,9 @@ // Unwrapping, expecting and panicking on failure is fine in tests, unlike in shipped code. #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] -mod actions; -mod agents; -mod control; -mod dialogs; -mod screenshot; -mod synthetic; +pub(crate) mod actions; +pub(crate) mod agents; +pub(crate) mod control; +pub(crate) mod dialogs; +pub(crate) mod screenshot; +pub(crate) mod synthetic; diff --git a/crates/browse/src/lib.rs b/crates/browse/src/lib.rs index afcce888d..2ca6cba0a 100644 --- a/crates/browse/src/lib.rs +++ b/crates/browse/src/lib.rs @@ -20,9 +20,9 @@ pub mod ui; extern crate self as craft_browse; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::ui::testing::register])); } diff --git a/crates/browse/src/links/mod.rs b/crates/browse/src/links/mod.rs index 1a5cef609..0884e5e4d 100644 --- a/crates/browse/src/links/mod.rs +++ b/crates/browse/src/links/mod.rs @@ -13,7 +13,7 @@ //! ``` #[cfg(test)] -mod tests; +pub(crate) mod tests; use std::collections::HashMap; use std::hash::Hash; diff --git a/crates/browse/src/places/mod.rs b/crates/browse/src/places/mod.rs index 271248a67..da2ada627 100644 --- a/crates/browse/src/places/mod.rs +++ b/crates/browse/src/places/mod.rs @@ -17,7 +17,7 @@ mod cache; mod directories; #[cfg(test)] -mod tests; +pub(crate) mod tests; use std::path::{Path, PathBuf}; diff --git a/crates/browse/src/ui/bin/mod.rs b/crates/browse/src/ui/bin/mod.rs index de3efdcbc..1b6389b94 100644 --- a/crates/browse/src/ui/bin/mod.rs +++ b/crates/browse/src/ui/bin/mod.rs @@ -24,7 +24,7 @@ mod icon; mod list; mod search; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::cell::RefCell; use std::hash::Hash; diff --git a/crates/browse/src/ui/compare/mod.rs b/crates/browse/src/ui/compare/mod.rs index 2cad58294..29d55f7cc 100644 --- a/crates/browse/src/ui/compare/mod.rs +++ b/crates/browse/src/ui/compare/mod.rs @@ -13,11 +13,11 @@ mod arrange; mod caption; -mod pill; +pub(crate) mod pill; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod style; -mod tile; +pub(crate) mod tile; pub use arrange::{ArrangeSpace, ComparePair, survey_cell, survey_columns}; pub use caption::CompareCaption; diff --git a/crates/browse/src/ui/freebin/mod.rs b/crates/browse/src/ui/freebin/mod.rs index 341116b98..9f7b7c8f9 100644 --- a/crates/browse/src/ui/freebin/mod.rs +++ b/crates/browse/src/ui/freebin/mod.rs @@ -6,7 +6,7 @@ //! move gesture into the cards' new positions. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::cell::RefCell; use std::collections::HashMap; diff --git a/crates/browse/src/ui/mod.rs b/crates/browse/src/ui/mod.rs index 910e7d8bc..7933f87d4 100644 --- a/crates/browse/src/ui/mod.rs +++ b/crates/browse/src/ui/mod.rs @@ -21,6 +21,7 @@ pub use relink::{LinkList, LinkListWords, RelinkDialog, RelinkWords, StatusBadge /// The stories and trials this crate registers for the integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } diff --git a/crates/browse/src/ui/places/mod.rs b/crates/browse/src/ui/places/mod.rs index f6ebde7d2..88f085861 100644 --- a/crates/browse/src/ui/places/mod.rs +++ b/crates/browse/src/ui/places/mod.rs @@ -16,7 +16,7 @@ //! ``` #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::path::{Path, PathBuf}; diff --git a/crates/browse/src/ui/relink/mod.rs b/crates/browse/src/ui/relink/mod.rs index 1816678b9..4a54c1a0b 100644 --- a/crates/browse/src/ui/relink/mod.rs +++ b/crates/browse/src/ui/relink/mod.rs @@ -16,10 +16,10 @@ //! ``` mod badge; -mod dialog; -mod list; +pub(crate) mod dialog; +pub(crate) mod list; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use badge::StatusBadge; pub use dialog::{CandidateChecker, RelinkCriterion, RelinkDialog, RelinkLayout, RelinkOptions, RelinkOutcome, RelinkRow, RelinkWords}; diff --git a/crates/browse/tests/it/main.rs b/crates/browse/tests/it/main.rs index 3bfce312a..af3c15cc6 100644 --- a/crates/browse/tests/it/main.rs +++ b/crates/browse/tests/it/main.rs @@ -1,7 +1,7 @@ //! The screen tests of craft-browse, folded into the lib's test target. -mod bin; -mod freebin; -mod places; -mod relink; -mod thumbs; +pub(crate) mod bin; +pub(crate) mod freebin; +pub(crate) mod places; +pub(crate) mod relink; +pub(crate) mod thumbs; diff --git a/crates/color-ui/src/display.rs b/crates/color-ui/src/display.rs index 00a4428df..bf891985c 100644 --- a/crates/color-ui/src/display.rs +++ b/crates/color-ui/src/display.rs @@ -298,7 +298,7 @@ impl DisplayCaches { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/color-ui/src/lib.rs b/crates/color-ui/src/lib.rs index 8daa51bd2..fba4f89c7 100644 --- a/crates/color-ui/src/lib.rs +++ b/crates/color-ui/src/lib.rs @@ -27,9 +27,9 @@ pub use web::{not_web_safe, web_safe}; extern crate self as craft_color_ui; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::ui::testing::register])); } diff --git a/crates/color-ui/src/palette.rs b/crates/color-ui/src/palette.rs index 260060f7f..b8d97267e 100644 --- a/crates/color-ui/src/palette.rs +++ b/crates/color-ui/src/palette.rs @@ -490,7 +490,7 @@ mod aco; mod ase; mod reader; #[cfg(test)] -mod tests; +pub(crate) mod tests; mod text; use aco::{AcoColor, act_used, from_aco, parse_aco, to_aco, write_aco}; diff --git a/crates/color-ui/src/ui/area.rs b/crates/color-ui/src/ui/area.rs index d151bcf57..bbc1922a4 100644 --- a/crates/color-ui/src/ui/area.rs +++ b/crates/color-ui/src/ui/area.rs @@ -14,7 +14,7 @@ use craft_ui::value_drag::{PointMark, PointPicker}; use egui::{Mesh, Pos2, Rect, Vec2, pos2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Vertices along each side of the area's colour mesh (PhotoCraft's 32). const MESH: usize = 32; diff --git a/crates/color-ui/src/ui/choice.rs b/crates/color-ui/src/ui/choice.rs index 17ec7be7b..0cd393e88 100644 --- a/crates/color-ui/src/ui/choice.rs +++ b/crates/color-ui/src/ui/choice.rs @@ -2,7 +2,7 @@ //! (Preferences, Interface), the Crop shield colour and the Note colour. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_theme::Srgba; use craft_ui::contract::{Bind, Entry, NoValue, Outcome, Props as _, Show as _}; diff --git a/crates/color-ui/src/ui/compare.rs b/crates/color-ui/src/ui/compare.rs index 9edb518b9..d45e75509 100644 --- a/crates/color-ui/src/ui/compare.rs +++ b/crates/color-ui/src/ui/compare.rs @@ -13,7 +13,7 @@ use super::picker::ColorPickerWords; use super::warning::{ColorWarning, ColorWarningChip}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a compare block: the size of the block and of each half, the edge round it and the gap between a /// caption and the block. diff --git a/crates/color-ui/src/ui/disc.rs b/crates/color-ui/src/ui/disc.rs index dab85370f..dda1ca904 100644 --- a/crates/color-ui/src/ui/disc.rs +++ b/crates/color-ui/src/ui/disc.rs @@ -17,7 +17,7 @@ use craft_ui::style::{ComponentStyle, FocusLook, MarkerLook, StyleColor, StyleCx use egui::{Color32, Mesh, Pos2, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The disc: a press on it grabs the nearest marker within reach. const DISC: PartKey = PartKey::new("disc"); diff --git a/crates/color-ui/src/ui/droppers.rs b/crates/color-ui/src/ui/droppers.rs index 8d5c4fe67..1b6187e81 100644 --- a/crates/color-ui/src/ui/droppers.rs +++ b/crates/color-ui/src/ui/droppers.rs @@ -32,7 +32,7 @@ use craft_ui::runtime::requests::EyedropperRequest; use egui::{Pos2, Response, Ui, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The pipette icon's tip, in the icon's own 24-unit box. const HOTSPOT: [f32; 2] = [2.0, 22.0]; diff --git a/crates/color-ui/src/ui/eyedropper.rs b/crates/color-ui/src/ui/eyedropper.rs index 5670cf4aa..9a238c286 100644 --- a/crates/color-ui/src/ui/eyedropper.rs +++ b/crates/color-ui/src/ui/eyedropper.rs @@ -36,7 +36,7 @@ use craft_ui::style::DataColor; use egui::{Color32, Pos2, Response, Ui, Vec2, vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The Eyedropper options bar's words, English by default. diff --git a/crates/color-ui/src/ui/gradient/editor.rs b/crates/color-ui/src/ui/gradient/editor.rs index 7a83ebd9d..1bdc268cb 100644 --- a/crates/color-ui/src/ui/gradient/editor.rs +++ b/crates/color-ui/src/ui/gradient/editor.rs @@ -18,7 +18,7 @@ use crate::gradient::{GradientStops, Sampler, StopRules}; mod bar; mod fields; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use bar::GradientBar; pub use bar::StopDrop; diff --git a/crates/color-ui/src/ui/gradient/mod.rs b/crates/color-ui/src/ui/gradient/mod.rs index f64eeca7a..8957f93ae 100644 --- a/crates/color-ui/src/ui/gradient/mod.rs +++ b/crates/color-ui/src/ui/gradient/mod.rs @@ -3,7 +3,7 @@ //! The model and the stop rules ([`GradientStops`], [`stops`]) need no egui and live in [`crate::gradient`]; they are //! re-exported here so a widget user imports the editor and its model from one path. -mod editor; +pub(crate) mod editor; mod ramp; mod value; mod words; diff --git a/crates/color-ui/src/ui/harmony.rs b/crates/color-ui/src/ui/harmony.rs index 807ba048d..22abd4bbc 100644 --- a/crates/color-ui/src/ui/harmony.rs +++ b/crates/color-ui/src/ui/harmony.rs @@ -20,7 +20,7 @@ use crate::harmony::{Guide, GuideOptions, Harmony, Variation}; use craft_ui::choice::{SwatchTable, SwatchTableOutput}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The words of the harmony controls and of the Color Guide panel menu. diff --git a/crates/color-ui/src/ui/hud.rs b/crates/color-ui/src/ui/hud.rs index f9b6ecc60..f8a15f453 100644 --- a/crates/color-ui/src/ui/hud.rs +++ b/crates/color-ui/src/ui/hud.rs @@ -18,7 +18,7 @@ use craft_ui::style::{ComponentStyle, StyleCx, UiTokens}; use egui::{Pos2, Rect, Response, Ui, Vec2, pos2, vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The model the HUD picks in: saturation and brightness across and down, hue in the strip. const MODE: AreaMode = AreaMode::Hue; diff --git a/crates/color-ui/src/ui/info.rs b/crates/color-ui/src/ui/info.rs index cb192b03b..5ba247992 100644 --- a/crates/color-ui/src/ui/info.rs +++ b/crates/color-ui/src/ui/info.rs @@ -14,7 +14,7 @@ use egui::{Response, Ui}; use super::SamplerReadout; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// What a missing value shows. const DASH: &str = "–"; diff --git a/crates/color-ui/src/ui/lut_picker.rs b/crates/color-ui/src/ui/lut_picker.rs index bb40074c7..afdb6a71d 100644 --- a/crates/color-ui/src/ui/lut_picker.rs +++ b/crates/color-ui/src/ui/lut_picker.rs @@ -20,7 +20,7 @@ use craft_ui::style::{ComponentStyle, StyleCx}; use egui::{Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The LUT picker's rows, English by default, and the built-in looks' names in diff --git a/crates/color-ui/src/ui/mod.rs b/crates/color-ui/src/ui/mod.rs index 16e5671cd..183564f01 100644 --- a/crates/color-ui/src/ui/mod.rs +++ b/crates/color-ui/src/ui/mod.rs @@ -11,39 +11,39 @@ //! Colour edits are values of a colour model ([`ModelValues`](craft_theme::ModelValues)) or of [`PickedColor`], and //! report through the edit lifecycle of the contract. -mod area; +pub(crate) mod area; mod channels; -mod choice; -mod compare; -mod disc; -mod droppers; -mod eyedropper; +pub(crate) mod choice; +pub(crate) mod compare; +pub(crate) mod disc; +pub(crate) mod droppers; +pub(crate) mod eyedropper; pub mod gradient; -mod harmony; +pub(crate) mod harmony; mod hex; -mod hud; -mod info; -mod lut_picker; -mod paint_chip; -mod pair; -mod palette; -mod panel; -mod picker; +pub(crate) mod hud; +pub(crate) mod info; +pub(crate) mod lut_picker; +pub(crate) mod paint_chip; +pub(crate) mod pair; +pub(crate) mod palette; +pub(crate) mod panel; +pub(crate) mod picker; mod picker_dialog; -mod popover; -mod profile_prompts; -mod ramp; -mod readout; -mod sample_size; -mod samplers; -mod screen_picker; -mod strip; -mod swatches; +pub(crate) mod popover; +pub(crate) mod profile_prompts; +pub(crate) mod ramp; +pub(crate) mod readout; +pub(crate) mod sample_size; +pub(crate) mod samplers; +pub(crate) mod screen_picker; +pub(crate) mod strip; +pub(crate) mod swatches; /// The stories and trials this crate registers for the integration binary. #[cfg(feature = "screen-testing")] pub mod testing; -mod warning; -mod wheel; +pub(crate) mod warning; +pub(crate) mod wheel; pub use crate::AreaMode; pub use area::{AreaShape, ColorArea, ColorAreaStyle}; diff --git a/crates/color-ui/src/ui/paint_chip.rs b/crates/color-ui/src/ui/paint_chip.rs index 55c42cc6b..8db24aab3 100644 --- a/crates/color-ui/src/ui/paint_chip.rs +++ b/crates/color-ui/src/ui/paint_chip.rs @@ -33,9 +33,9 @@ use super::popover::compact_picker; use super::{PickedColor, ScreenPickGesture, SwatchKey, SwatchPalette, SwatchesWords, swatch_rows}; use crate::palette::{SwatchColor, SwatchGroup}; -mod paint_list; +pub(crate) mod paint_list; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use paint_list::{PaintLink, PaintLinkKind, PaintList, PaintListEvent, PaintListOptions, PaintListOutput, PaintRow}; diff --git a/crates/color-ui/src/ui/pair.rs b/crates/color-ui/src/ui/pair.rs index 454bebee9..a11d1756e 100644 --- a/crates/color-ui/src/ui/pair.rs +++ b/crates/color-ui/src/ui/pair.rs @@ -19,7 +19,7 @@ use super::popover::compact_picker; use super::{ColorPicker, PickedColor, ScreenPickGesture}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// One of the wells, `WELL.at(0)` the primary and `WELL.at(1)` the secondary. const WELL: PartKey = PartKey::new("well"); diff --git a/crates/color-ui/src/ui/palette.rs b/crates/color-ui/src/ui/palette.rs index f8200fd8c..14f864d46 100644 --- a/crates/color-ui/src/ui/palette.rs +++ b/crates/color-ui/src/ui/palette.rs @@ -11,7 +11,7 @@ use egui::{Response, Ui}; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// What a [`SwatchPalette`] reports. #[derive(Debug)] diff --git a/crates/color-ui/src/ui/panel.rs b/crates/color-ui/src/ui/panel.rs index 05d31faa3..76c85e775 100644 --- a/crates/color-ui/src/ui/panel.rs +++ b/crates/color-ui/src/ui/panel.rs @@ -30,7 +30,7 @@ use super::{ use crate::{CmykModel, GrayModel, not_web_safe}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The Color panel's words. @@ -821,7 +821,7 @@ impl Body<'_> { const WEB_STEP: f64 = 51.0; #[cfg(test)] -mod tests { +pub(crate) mod tests { use craft_ui::testing::trial; use super::*; diff --git a/crates/color-ui/src/ui/picker/mod.rs b/crates/color-ui/src/ui/picker/mod.rs index 10e6b13f5..238d22873 100644 --- a/crates/color-ui/src/ui/picker/mod.rs +++ b/crates/color-ui/src/ui/picker/mod.rs @@ -2,12 +2,12 @@ //! host adds. A container: its body lays the parts out with the form layouts, the "Field shows" choice is a //! `RadioGroup` and the channel rows share one label column. -mod channel; +pub(crate) mod channel; mod compact; mod full; -mod screen_pick; +pub(crate) mod screen_pick; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod value; use std::sync::Arc; diff --git a/crates/color-ui/src/ui/popover.rs b/crates/color-ui/src/ui/popover.rs index e995bbd43..36793dbce 100644 --- a/crates/color-ui/src/ui/popover.rs +++ b/crates/color-ui/src/ui/popover.rs @@ -12,7 +12,7 @@ use egui::{Response, Ui}; use super::{ColorPicker, ColorPickerLayout, ColorPickerOutput, PickedColor, ScreenPickGesture}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The setup closure of the picker in the popover. type Setup<'a> = Box Fn(ColorPicker<'b>) -> ColorPicker<'b> + 'a>; diff --git a/crates/color-ui/src/ui/profile_prompts.rs b/crates/color-ui/src/ui/profile_prompts.rs index 32a4a97f4..d0e822332 100644 --- a/crates/color-ui/src/ui/profile_prompts.rs +++ b/crates/color-ui/src/ui/profile_prompts.rs @@ -19,7 +19,7 @@ use serde_json::{Value, json}; use crate::display::MonitorProblem; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The profile prompts' words, English by default. diff --git a/crates/color-ui/src/ui/ramp.rs b/crates/color-ui/src/ui/ramp.rs index f074258ef..11e269b5f 100644 --- a/crates/color-ui/src/ui/ramp.rs +++ b/crates/color-ui/src/ui/ramp.rs @@ -18,7 +18,7 @@ use std::hash::{DefaultHasher, Hash, Hasher}; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The bar: a press picks the colour under the pointer. const BAR: PartKey = PartKey::new("bar"); diff --git a/crates/color-ui/src/ui/readout.rs b/crates/color-ui/src/ui/readout.rs index 79baeb9c1..e7ed9e214 100644 --- a/crates/color-ui/src/ui/readout.rs +++ b/crates/color-ui/src/ui/readout.rs @@ -1,7 +1,7 @@ //! `ColorReadout`: a colour as a hex field and editable R, G and B fields (the readout of a Color panel). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{EditEvent, EditEvents, Mixed}; use craft_theme::{ColorModel as _, RgbModel, Rgba}; diff --git a/crates/color-ui/src/ui/samplers.rs b/crates/color-ui/src/ui/samplers.rs index 23f8c13d3..e33f7bf58 100644 --- a/crates/color-ui/src/ui/samplers.rs +++ b/crates/color-ui/src/ui/samplers.rs @@ -35,7 +35,7 @@ use craft_ui::style::{ComponentStyle, StyleColor, StyleCx}; use egui::{Pos2, Response, Ui, Vec2, vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The colour samplers' words, English by default. diff --git a/crates/color-ui/src/ui/screen_picker.rs b/crates/color-ui/src/ui/screen_picker.rs index 89cbe238f..c8097e098 100644 --- a/crates/color-ui/src/ui/screen_picker.rs +++ b/crates/color-ui/src/ui/screen_picker.rs @@ -32,9 +32,9 @@ use egui::{Color32, Context, Pos2, Rect, Ui, pos2, vec2}; use super::ScreenPickGesture; -mod capture; +pub(crate) mod capture; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use capture::{CaptureView, CaptureWindow}; diff --git a/crates/color-ui/src/ui/strip.rs b/crates/color-ui/src/ui/strip.rs index c26e62e91..de21ac7e2 100644 --- a/crates/color-ui/src/ui/strip.rs +++ b/crates/color-ui/src/ui/strip.rs @@ -16,7 +16,7 @@ use craft_ui::style::{ComponentStyle, DataColor, FocusLook, StyleColor, StyleCx} use egui::{CornerRadius, Mesh, Pos2, Rect, Vec2, pos2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The strip itself: a press on it sets the value there. const STRIP: PartKey = PartKey::new("strip"); diff --git a/crates/color-ui/src/ui/swatches.rs b/crates/color-ui/src/ui/swatches.rs index b450b92c1..d23ea3970 100644 --- a/crates/color-ui/src/ui/swatches.rs +++ b/crates/color-ui/src/ui/swatches.rs @@ -3,11 +3,11 @@ //! change as a resolved [`SwatchEdit`] (new, rename, delete, move, group edits, import) that the host runs, with //! [`SwatchLibrary::apply`] for an in-memory host. -mod library; +pub(crate) mod library; mod menu; -mod panel; +pub(crate) mod panel; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use library::{SwatchAt, SwatchEdit, SwatchKey, SwatchLibrary, SwatchesState, swatch_rows}; pub use menu::{SwatchesCommand, SwatchesFileOutput, SwatchesMenu, SwatchesMenuOutput}; diff --git a/crates/color-ui/src/ui/swatches/library.rs b/crates/color-ui/src/ui/swatches/library.rs index 3653c61b9..6ae896f9a 100644 --- a/crates/color-ui/src/ui/swatches/library.rs +++ b/crates/color-ui/src/ui/swatches/library.rs @@ -569,7 +569,7 @@ pub fn swatch_rows(groups: &[SwatchGroup], words: &SwatchesWords) -> Vec, &mut Vec); /// REGISTRY: add a rule by adding its `check` here and its ids to [`IDS`]. -const REGISTRY: [Check; 21] = [ +const REGISTRY: [Check; 22] = [ egui_import::check, runtime_egui::check, text_edit::check, @@ -106,6 +108,7 @@ const REGISTRY: [Check; 21] = [ entry::check, shape::check, unsafe_allow::check, + registry_expansion::check, ]; /// One file as the rules see it. diff --git a/crates/design-lint/src/contract/registry_expansion.rs b/crates/design-lint/src/contract/registry_expansion.rs new file mode 100644 index 000000000..3a85f01a5 --- /dev/null +++ b/crates/design-lint/src/contract/registry_expansion.rs @@ -0,0 +1,121 @@ +//! Reject suite registrations hidden from the source-tree registry walker. + +use proc_macro2::{Delimiter, TokenStream, TokenTree}; +use std::str::FromStr as _; +use syn::spanned::Spanned as _; +use syn::visit::{self, Visit}; + +use super::Cx; +use crate::report::Finding; + +/// Suite items inside expansions cannot be discovered by `registry!`. +pub const ID: &str = "registry/expansion"; + +fn attribute(tree: &TokenTree) -> Option { + match tree { + TokenTree::Group(group) if group.delimiter() == Delimiter::Bracket => Some(group.stream().to_string()), + _ => None, + } +} + +fn words(attr: &str) -> Vec<&str> { + attr.split(|c: char| !c.is_alphanumeric() && c != '_').filter(|s| !s.is_empty()).collect() +} + +fn has_registration(tokens: TokenStream) -> bool { + let trees: Vec<_> = tokens.into_iter().collect(); + let mut i = 0; + while i < trees.len() { + if matches!(&trees[i], TokenTree::Punct(p) if p.as_char() == '#') { + let mut attrs = Vec::new(); + while i + 1 < trees.len() && matches!(&trees[i], TokenTree::Punct(p) if p.as_char() == '#') { + let Some(attr) = attribute(&trees[i + 1]) else { break }; + attrs.push(attr); + i += 2; + } + if attrs.iter().any(|attr| words(attr).first().is_some_and(|word| *word == "story" || *word == "trial")) { + return true; + } + let unregistered = attrs.iter().any(|attr| { + let words = words(attr); + words.first() == Some(&"component") && words.contains(&"unregistered") + }); + if !unregistered + && attrs.iter().any(|attr| { + let words = words(attr); + words.first() == Some(&"derive") && (words.contains(&"Component") || words.contains(&"Pattern")) + }) + { + return true; + } + let story_set = attrs.iter().any(|attr| { + let words = words(attr); + words.first() == Some(&"command") && words.contains(&"story") + }); + if story_set + && attrs.iter().any(|attr| { + let words = words(attr); + words.first() == Some(&"derive") && words.contains(&"CommandSet") + }) + { + return true; + } + continue; + } + if let TokenTree::Ident(ident) = &trees[i] { + if ident == "register_contract" && trees.get(i + 1).is_some_and(|t| matches!(t, TokenTree::Punct(p) if p.as_char() == '!')) { + return true; + } + } + if let TokenTree::Group(group) = &trees[i] { + if has_registration(group.stream()) { + return true; + } + } + i += 1; + } + false +} + +struct Walk<'a, 'b> { + cx: &'a Cx<'b>, + out: &'a mut Vec, +} + +impl<'ast> Visit<'ast> for Walk<'_, '_> { + fn visit_item_macro(&mut self, item: &'ast syn::ItemMacro) { + let hidden = if item.mac.path.is_ident("macro_rules") { + has_registration(item.mac.tokens.clone()) + } else if item.mac.path.is_ident("include") { + syn::parse2::(item.mac.tokens.clone()) + .ok() + .and_then(|path| self.cx.path.parent().map(|parent| parent.join(path.value()))) + .and_then(|path| std::fs::read_to_string(path).ok()) + .and_then(|source| TokenStream::from_str(&source).ok()) + .is_some_and(has_registration) + } else { + false + }; + if hidden { + self.cx.flag_span(self.out, ID, ID, item.span(), "suite registration inside a macro or include is invisible to registry!".to_owned()); + } + visit::visit_item_macro(self, item); + } +} + +pub(super) fn check(cx: &Cx<'_>, out: &mut Vec) { + Walk { cx, out }.visit_file(cx.file); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn detects_hidden_registrations_and_allows_unregistered_derive() { + let hidden = TokenStream::from_str("#[derive(Component)] struct A; #[trial] fn t() {} ").unwrap_or_default(); + let ordinary = TokenStream::from_str("#[derive(Component)] #[component(unregistered)] struct A; ").unwrap_or_default(); + assert!(has_registration(hidden)); + assert!(!has_registration(ordinary)); + } +} diff --git a/crates/dialogs/src/lib.rs b/crates/dialogs/src/lib.rs index 7b3356385..763876054 100644 --- a/crates/dialogs/src/lib.rs +++ b/crates/dialogs/src/lib.rs @@ -22,11 +22,11 @@ mod filter; mod native; #[cfg(target_os = "linux")] -mod portal; -mod probe; +pub(crate) mod portal; +pub(crate) mod probe; pub mod save; #[cfg(test)] -mod save_tests; +pub(crate) mod save_tests; pub mod service; #[cfg(feature = "ui")] pub mod ui; @@ -34,15 +34,16 @@ pub mod ui; /// The registrations of this crate's UI types, for its integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(target_os = "macos")] mod macos; #[cfg(test)] -mod tests; +pub(crate) mod tests; use std::collections::VecDeque; use std::panic::{AssertUnwindSafe, catch_unwind}; @@ -395,9 +396,9 @@ fn panic_text(panic: &(dyn std::any::Any + Send)) -> Option<&str> { extern crate self as craft_dialogs; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/dialogs/src/portal.rs b/crates/dialogs/src/portal.rs index 1c6e75b04..10ee1692e 100644 --- a/crates/dialogs/src/portal.rs +++ b/crates/dialogs/src/portal.rs @@ -261,4 +261,4 @@ pub(crate) fn save_as(mut req: SaveRequest) -> Result, String> { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/dialogs/src/probe.rs b/crates/dialogs/src/probe.rs index c06691b42..065851246 100644 --- a/crates/dialogs/src/probe.rs +++ b/crates/dialogs/src/probe.rs @@ -186,4 +186,4 @@ fn classify_error(e: &zbus::Error) -> Option { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/dialogs/src/service.rs b/crates/dialogs/src/service.rs index a2204531a..e8bb0d1a1 100644 --- a/crates/dialogs/src/service.rs +++ b/crates/dialogs/src/service.rs @@ -569,7 +569,7 @@ impl Files for FileService { } #[cfg(test)] -mod service_tests { +pub(crate) mod service_tests { //! Behaviour tests with `Dialogs::set_override` standing in for the panels. use craft_ui::testing::trial; diff --git a/crates/dialogs/src/ui/mod.rs b/crates/dialogs/src/ui/mod.rs index eda6b23dd..05897522c 100644 --- a/crates/dialogs/src/ui/mod.rs +++ b/crates/dialogs/src/ui/mod.rs @@ -1,8 +1,8 @@ //! The file service's UI part: [`PathField`], and the words of the service's native boxes. -mod path_field; +pub(crate) mod path_field; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use path_field::{PathField, PathFieldOutput, PathFieldWords}; diff --git a/crates/dialogs/tests/it/main.rs b/crates/dialogs/tests/it/main.rs index 818669df3..8a3736ca8 100644 --- a/crates/dialogs/tests/it/main.rs +++ b/crates/dialogs/tests/it/main.rs @@ -2,4 +2,4 @@ // Expecting on failure is fine here, unlike in shipped code. #![allow(clippy::expect_used)] -mod files; +pub(crate) mod files; diff --git a/crates/draw/src/geometry/mod.rs b/crates/draw/src/geometry/mod.rs index e55e53029..f2f21927a 100644 --- a/crates/draw/src/geometry/mod.rs +++ b/crates/draw/src/geometry/mod.rs @@ -2,16 +2,16 @@ pub mod artboard; #[cfg(test)] -mod artboard_tests; +pub(crate) mod artboard_tests; pub mod connector; #[cfg(test)] -mod connector_tests; +pub(crate) mod connector_tests; pub mod curvature; #[cfg(test)] -mod curvature_tests; +pub(crate) mod curvature_tests; pub mod fillet; #[cfg(test)] -mod fillet_tests; +pub(crate) mod fillet_tests; pub mod presets; pub mod shape; pub mod slice; diff --git a/crates/draw/src/lib.rs b/crates/draw/src/lib.rs index 4111d49bc..2e7e1ea2a 100644 --- a/crates/draw/src/lib.rs +++ b/crates/draw/src/lib.rs @@ -9,17 +9,18 @@ pub mod ui; #[cfg(feature = "screen-testing")] pub mod testing { //! The registrations of this crate's stories, for the `tests/it` harness. + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(all(test, feature = "screen-testing"))] extern crate self as craft_draw; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/draw/src/stroke/mod.rs b/crates/draw/src/stroke/mod.rs index 0e9d38b51..949b8d4c1 100644 --- a/crates/draw/src/stroke/mod.rs +++ b/crates/draw/src/stroke/mod.rs @@ -12,7 +12,7 @@ use kurbo::{BezPath, CubicBez, Line, ParamCurve, ParamCurveArclen, PathEl, PathS use serde::{Deserialize, Serialize}; #[cfg(test)] -mod dash_tests; +pub(crate) mod dash_tests; /// The shortest run (between corners and path ends) and the smallest pattern total `Corners` fits. const MIN_RUN: f64 = 1e-6; diff --git a/crates/draw/src/ui/artboard/mod.rs b/crates/draw/src/ui/artboard/mod.rs index acec3ed2d..7ca0ca2b4 100644 --- a/crates/draw/src/ui/artboard/mod.rs +++ b/crates/draw/src/ui/artboard/mod.rs @@ -16,11 +16,11 @@ use craft_theme::Srgba; use std::sync::Arc; mod background; -mod bar; -mod overlay; -mod properties; +pub(crate) mod bar; +pub(crate) mod overlay; +pub(crate) mod properties; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod tool; mod words; diff --git a/crates/draw/src/ui/brush_presets/mod.rs b/crates/draw/src/ui/brush_presets/mod.rs index 6c263431b..c89cd0ce8 100644 --- a/crates/draw/src/ui/brush_presets/mod.rs +++ b/crates/draw/src/ui/brush_presets/mod.rs @@ -10,8 +10,8 @@ //! The app paints the tip and stroke images from its engine; the library never sees an engine type. Presets are //! keyed by the app's key type (PhotoCraft: `PresetKey`, by name). -mod panel; -mod picker; +pub(crate) mod panel; +pub(crate) mod picker; mod rows; mod settings; #[cfg(feature = "suite")] diff --git a/crates/draw/src/ui/brush_settings/mod.rs b/crates/draw/src/ui/brush_settings/mod.rs index dce1efb64..42dc7aa02 100644 --- a/crates/draw/src/ui/brush_settings/mod.rs +++ b/crates/draw/src/ui/brush_settings/mod.rs @@ -13,12 +13,12 @@ //! draws the frame and the shared rows, and every control reports edit events the app sends to its //! tool options host. -mod ellipse; -mod panel; -mod preview; -mod rows; -mod sections; -mod size_field; +pub(crate) mod ellipse; +pub(crate) mod panel; +pub(crate) mod preview; +pub(crate) mod rows; +pub(crate) mod sections; +pub(crate) mod size_field; #[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/draw/src/ui/connector/mod.rs b/crates/draw/src/ui/connector/mod.rs index 29c4cc5ee..7dfdfea41 100644 --- a/crates/draw/src/ui/connector/mod.rs +++ b/crates/draw/src/ui/connector/mod.rs @@ -7,15 +7,15 @@ //! on an object, the handles (a canvas control) take a press on the selected connector's ends and //! bends before the tool sees it. -mod bar; -mod handles; +pub(crate) mod bar; +pub(crate) mod handles; mod overlay; mod place; mod tool; mod words; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::EditEvent; use kurbo::{Point, Rect}; diff --git a/crates/draw/src/ui/corner/mod.rs b/crates/draw/src/ui/corner/mod.rs index 002a8a780..a25f4e3d8 100644 --- a/crates/draw/src/ui/corner/mod.rs +++ b/crates/draw/src/ui/corner/mod.rs @@ -9,7 +9,7 @@ mod geometry; #[cfg(feature = "suite")] pub(crate) mod stories; mod style; -mod widgets; +pub(crate) mod widgets; mod words; use kurbo::Point; diff --git a/crates/draw/src/ui/crop/bar.rs b/crates/draw/src/ui/crop/bar.rs index 5b2aaee26..f87f85a00 100644 --- a/crates/draw/src/ui/crop/bar.rs +++ b/crates/draw/src/ui/crop/bar.rs @@ -22,7 +22,7 @@ use craft_ui::text::NumberField; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The ratio, a ratio field, a preset or W × H × Resolution changed. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/draw/src/ui/crop/mod.rs b/crates/draw/src/ui/crop/mod.rs index 2afc9b86e..bc6551221 100644 --- a/crates/draw/src/ui/crop/mod.rs +++ b/crates/draw/src/ui/crop/mod.rs @@ -8,17 +8,17 @@ //! The tool reports events and never crops the document: the app crops on [`CropEvent::Apply`] with the //! [`CropCommit`] it carries. -mod bar; +pub(crate) mod bar; mod bar_words; -mod menus; +pub(crate) mod menus; mod options; -mod perspective_bar; -mod perspective_crop; +pub(crate) mod perspective_bar; +pub(crate) mod perspective_crop; mod perspective_tool; -mod preset_list; +pub(crate) mod preset_list; mod session; mod size_cells; -mod tool; +pub(crate) mod tool; mod words; pub use bar::{CropBar, CropBarOutput, CropRatioChange}; diff --git a/crates/draw/src/ui/crop/perspective_bar.rs b/crates/draw/src/ui/crop/perspective_bar.rs index 72b437f4a..e8588e06d 100644 --- a/crates/draw/src/ui/crop/perspective_bar.rs +++ b/crates/draw/src/ui/crop/perspective_bar.rs @@ -12,7 +12,7 @@ use craft_ui::runtime::env::Env; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The Perspective Crop options: W × H × Resolution, Front Image, Clear, a divider and Show Grid. /// diff --git a/crates/draw/src/ui/crop/perspective_crop.rs b/crates/draw/src/ui/crop/perspective_crop.rs index 000a02bdc..2f58c20e3 100644 --- a/crates/draw/src/ui/crop/perspective_crop.rs +++ b/crates/draw/src/ui/crop/perspective_crop.rs @@ -488,4 +488,4 @@ pub fn grid_lines(view: &CanvasView, q: &[Point; 4], step: f32) -> Vec<[Pos2; 2] } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/draw/src/ui/crop/tool.rs b/crates/draw/src/ui/crop/tool.rs index b6484d7bc..d39356acd 100644 --- a/crates/draw/src/ui/crop/tool.rs +++ b/crates/draw/src/ui/crop/tool.rs @@ -789,4 +789,4 @@ pub fn crop_to_form(words: &CropWords, frame: &CropBox) -> ParamDialog<'static> } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/draw/src/ui/gradient/fill_editor.rs b/crates/draw/src/ui/gradient/fill_editor.rs index b6b09c818..86b8cdb5d 100644 --- a/crates/draw/src/ui/gradient/fill_editor.rs +++ b/crates/draw/src/ui/gradient/fill_editor.rs @@ -223,4 +223,4 @@ impl<'a> GradientFillEditor<'a> { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/draw/src/ui/gradient/gradient_overlay/mod.rs b/crates/draw/src/ui/gradient/gradient_overlay/mod.rs index 00d8ff9cd..e91e10ca9 100644 --- a/crates/draw/src/ui/gradient/gradient_overlay/mod.rs +++ b/crates/draw/src/ui/gradient/gradient_overlay/mod.rs @@ -6,7 +6,7 @@ mod keys; mod parts; mod pointer; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/draw/src/ui/gradient/map/mod.rs b/crates/draw/src/ui/gradient/map/mod.rs index c75a048bb..3627df131 100644 --- a/crates/draw/src/ui/gradient/map/mod.rs +++ b/crates/draw/src/ui/gradient/map/mod.rs @@ -5,7 +5,7 @@ //! [`GradientGroup`] presets, and a family crate depends on no other family crate but craft-color-ui. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{EditEvent, Mixed}; use craft_ui::buttons::Button; diff --git a/crates/draw/src/ui/gradient/mod.rs b/crates/draw/src/ui/gradient/mod.rs index 1f2a1ae11..f9c08db15 100644 --- a/crates/draw/src/ui/gradient/mod.rs +++ b/crates/draw/src/ui/gradient/mod.rs @@ -8,12 +8,12 @@ //! there. mod fill; -mod fill_editor; +pub(crate) mod fill_editor; pub mod gradient_line; pub mod gradient_overlay; pub mod map; -mod palette; -mod swatch; +pub(crate) mod palette; +pub(crate) mod swatch; pub use fill::{GradientFill, GradientStyle}; pub use fill_editor::{GradientFillEditor, GradientFillEditorOutput, GradientFillWords}; diff --git a/crates/draw/src/ui/gradient/palette/mod.rs b/crates/draw/src/ui/gradient/palette/mod.rs index 9d320e9d7..c58851597 100644 --- a/crates/draw/src/ui/gradient/palette/mod.rs +++ b/crates/draw/src/ui/gradient/palette/mod.rs @@ -8,7 +8,7 @@ use craft_ui::runtime::env::{Env, Label}; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_color_ui::ui::gradient::{GradientRamp, GradientStops, Sampler, StopRows, default_sampler}; diff --git a/crates/draw/src/ui/gradient/swatch.rs b/crates/draw/src/ui/gradient/swatch.rs index e6698f38b..f58735eb4 100644 --- a/crates/draw/src/ui/gradient/swatch.rs +++ b/crates/draw/src/ui/gradient/swatch.rs @@ -11,7 +11,7 @@ use egui::{CornerRadius, Response, Vec2}; use craft_color_ui::ui::gradient::{GradientRamp, GradientStops, Sampler, StopRows, default_sampler}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a gradient swatch: the colour swatch's height, corners and ring. #[derive(Clone, Debug, PartialEq, ComponentStyle)] diff --git a/crates/draw/src/ui/measure/mod.rs b/crates/draw/src/ui/measure/mod.rs index e7a492e34..333082e42 100644 --- a/crates/draw/src/ui/measure/mod.rs +++ b/crates/draw/src/ui/measure/mod.rs @@ -5,12 +5,12 @@ //! The Ruler line is document state outside the undo history: the tool reports `EditEvent>` and the //! app stores the line. -mod bar; +pub(crate) mod bar; mod distances; mod model; -mod overlay; +pub(crate) mod overlay; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod tool; mod words; diff --git a/crates/draw/src/ui/paint_bar.rs b/crates/draw/src/ui/paint_bar.rs index 977519a02..fec07db9e 100644 --- a/crates/draw/src/ui/paint_bar.rs +++ b/crates/draw/src/ui/paint_bar.rs @@ -21,7 +21,7 @@ use craft_ui::text::{NumberField, RangeAlert}; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; pub use words::PaintBarWords; diff --git a/crates/draw/src/ui/paths/mod.rs b/crates/draw/src/ui/paths/mod.rs index 96396f58b..64d180b76 100644 --- a/crates/draw/src/ui/paths/mod.rs +++ b/crates/draw/src/ui/paths/mod.rs @@ -4,7 +4,7 @@ mod footer; mod menu; mod model; -mod panel; +pub(crate) mod panel; mod rows; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/draw/src/ui/pattern/mod.rs b/crates/draw/src/ui/pattern/mod.rs index 473e821e5..18f81b6a2 100644 --- a/crates/draw/src/ui/pattern/mod.rs +++ b/crates/draw/src/ui/pattern/mod.rs @@ -5,7 +5,7 @@ use craft_theme::Srgba; mod dialog; -mod editor; +pub(crate) mod editor; #[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/draw/src/ui/pen/bezier/mod.rs b/crates/draw/src/ui/pen/bezier/mod.rs index dd9c80570..26de454dd 100644 --- a/crates/draw/src/ui/pen/bezier/mod.rs +++ b/crates/draw/src/ui/pen/bezier/mod.rs @@ -6,7 +6,7 @@ mod mark; mod model; mod ops; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod style; mod tools; mod words; diff --git a/crates/draw/src/ui/pen/mod.rs b/crates/draw/src/ui/pen/mod.rs index 0924c3783..69160afd6 100644 --- a/crates/draw/src/ui/pen/mod.rs +++ b/crates/draw/src/ui/pen/mod.rs @@ -8,7 +8,7 @@ mod auto; pub(crate) mod bezier; mod curvature_mode; mod mode; -mod options; +pub(crate) mod options; #[cfg(feature = "suite")] pub(crate) mod stories; mod tool; diff --git a/crates/draw/src/ui/picture_fill/mod.rs b/crates/draw/src/ui/picture_fill/mod.rs index a1445e5a4..383d13392 100644 --- a/crates/draw/src/ui/picture_fill/mod.rs +++ b/crates/draw/src/ui/picture_fill/mod.rs @@ -7,9 +7,9 @@ //! if let Some(request) = out.requests.take_path() { /* open the file dialog, store the picture, set `fill.source` */ } //! ``` -mod editor; +pub(crate) mod editor; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; pub use editor::{PICTURE_FILL_KEY, PictureFillEditor, PictureFillOutput}; diff --git a/crates/draw/src/ui/shape/mod.rs b/crates/draw/src/ui/shape/mod.rs index 7295249bd..02995f04d 100644 --- a/crates/draw/src/ui/shape/mod.rs +++ b/crates/draw/src/ui/shape/mod.rs @@ -10,14 +10,14 @@ use crate::stroke::StrokeStyle; use super::shape_drag::{BoxConstraints, ShapeDragOptions, ShapeKind}; -mod arrowheads; -mod bar; -mod gear; -mod mode_select; -mod panel; +pub(crate) mod arrowheads; +pub(crate) mod bar; +pub(crate) mod gear; +pub(crate) mod mode_select; +pub(crate) mod panel; #[cfg(feature = "suite")] pub(crate) mod stories; -mod stroke_cells; +pub(crate) mod stroke_cells; mod words; pub use arrowheads::{ArrowheadsOutput, ArrowheadsPopover}; diff --git a/crates/draw/src/ui/shape_presets.rs b/crates/draw/src/ui/shape_presets.rs index 4595c453c..b9f92030f 100644 --- a/crates/draw/src/ui/shape_presets.rs +++ b/crates/draw/src/ui/shape_presets.rs @@ -12,7 +12,7 @@ use egui::{Color32, Mesh, Painter, Pos2, Rect, Shape, Stroke, Ui, pos2}; use kurbo::{BezPath, PathEl}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The error bound, in points, when the glyph's curves are flattened. const FLATTEN_TOLERANCE: f64 = 0.1; diff --git a/crates/draw/src/ui/slice/mod.rs b/crates/draw/src/ui/slice/mod.rs index cc6202f64..5b19a6580 100644 --- a/crates/draw/src/ui/slice/mod.rs +++ b/crates/draw/src/ui/slice/mod.rs @@ -35,11 +35,11 @@ use craft_behavior::{Axis, CancelReason, EditEvent, GestureId, Mixed}; use craft_keymap::Mods; use std::sync::Arc; -mod bar; +pub(crate) mod bar; mod dialogs; -mod overlay; +pub(crate) mod overlay; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod tool; mod words; diff --git a/crates/draw/src/ui/stroke/mod.rs b/crates/draw/src/ui/stroke/mod.rs index a5bb3a2a6..5b9e5ef5e 100644 --- a/crates/draw/src/ui/stroke/mod.rs +++ b/crates/draw/src/ui/stroke/mod.rs @@ -5,8 +5,8 @@ //! and named stroke types. The editor edits geometry only; width, colour and paint are the host's //! controls. The value is [`StrokeStyle`], re-exported here. -mod button; -mod editor; +pub(crate) mod button; +pub(crate) mod editor; mod preview; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/draw/src/ui/symmetry/mod.rs b/crates/draw/src/ui/symmetry/mod.rs index 96bf3515d..431dc6c1f 100644 --- a/crates/draw/src/ui/symmetry/mod.rs +++ b/crates/draw/src/ui/symmetry/mod.rs @@ -5,12 +5,12 @@ //! Stroke reflection, path symmetry and the brush engine stay in the app's paint engine; the library carries only the //! axis geometry the screens need. -mod handles; -mod menu; +pub(crate) mod handles; +pub(crate) mod menu; mod model; -mod overlay; +pub(crate) mod overlay; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod transform; pub use handles::{SymmetryHandles, SymmetryHandlesOutput, SymmetryHandlesStyle}; diff --git a/crates/draw/src/ui/transform/mod.rs b/crates/draw/src/ui/transform/mod.rs index 2d4ecbd30..a64aef6b3 100644 --- a/crates/draw/src/ui/transform/mod.rs +++ b/crates/draw/src/ui/transform/mod.rs @@ -2,10 +2,10 @@ //! the open session around them ([`TransformSession`], [`TransformOverlay`], [`TransformTool`], [`TransformBar`]). mod session; -mod session_bar; -mod session_overlay; -mod transform_box; -mod transform_fields; +pub(crate) mod session_bar; +pub(crate) mod session_overlay; +pub(crate) mod transform_box; +pub(crate) mod transform_fields; pub use session::{ Interpolation, TransformChoice, TransformEdit, TransformMenuWords, TransformPhase, TransformPreset, TransformRequest, TransformResult, diff --git a/crates/draw/src/ui/transform/session_bar.rs b/crates/draw/src/ui/transform/session_bar.rs index 150dbd15b..c4a722465 100644 --- a/crates/draw/src/ui/transform/session_bar.rs +++ b/crates/draw/src/ui/transform/session_bar.rs @@ -1,7 +1,7 @@ //! `TransformBar`: the options bar of an open Free Transform session. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::session::{TransformEdit, TransformPhase, TransformSession, TransformSettings, TransformWarp}; use super::transform_fields::{TransformFields, TransformGroups, TransformRow, size_unit_of}; diff --git a/crates/draw/src/ui/transform/session_overlay.rs b/crates/draw/src/ui/transform/session_overlay.rs index 685bc46d7..e28ceddc8 100644 --- a/crates/draw/src/ui/transform/session_overlay.rs +++ b/crates/draw/src/ui/transform/session_overlay.rs @@ -2,7 +2,7 @@ //! and turns its reports into [`TransformEdit`]s, and `TransformTool`: the canvas tool of the open session. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::CancelReason; use craft_behavior::geometry::SnapLine; diff --git a/crates/draw/src/ui/transform/transform_box.rs b/crates/draw/src/ui/transform/transform_box.rs index cbb62d333..ec165539e 100644 --- a/crates/draw/src/ui/transform/transform_box.rs +++ b/crates/draw/src/ui/transform/transform_box.rs @@ -3,7 +3,7 @@ //! document units. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::geometry::quad::{self, BoxAllow, BoxDrag, BoxPart, BoxRules, BoxState, ScaleRule, TransformMode}; use craft_behavior::geometry::{SNAP_PX, SnapKind, SnapKinds, SnapLine}; diff --git a/crates/draw/src/ui/transform/transform_fields.rs b/crates/draw/src/ui/transform/transform_fields.rs index 9b620e2f0..fe1da4280 100644 --- a/crates/draw/src/ui/transform/transform_fields.rs +++ b/crates/draw/src/ui/transform/transform_fields.rs @@ -2,7 +2,7 @@ //! rows. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod units; use self::units::Conversion; diff --git a/crates/draw/tests/it/main.rs b/crates/draw/tests/it/main.rs index 0cc22bf8a..ac971aca5 100644 --- a/crates/draw/tests/it/main.rs +++ b/crates/draw/tests/it/main.rs @@ -1,59 +1,59 @@ //! The screen tests of craft-draw, folded into the lib's test target. // draw-shape -mod add_beside; -mod corner; -mod shape_cells; +pub(crate) mod add_beside; +pub(crate) mod corner; +pub(crate) mod shape_cells; // draw-gradient-b -mod gradient_fill; -mod gradient_overlay; +pub(crate) mod gradient_fill; +pub(crate) mod gradient_overlay; // draw-connector -mod connector; -mod shape_drag; +pub(crate) mod connector; +pub(crate) mod shape_drag; // draw-paths -mod paths_panel; +pub(crate) mod paths_panel; // draw-pen-a -mod bezier; +pub(crate) mod bezier; // draw-pen-b -mod pen; +pub(crate) mod pen; // draw-crop-b -mod crop_size; -mod crop_tool; -mod perspective_crop; +pub(crate) mod crop_size; +pub(crate) mod crop_tool; +pub(crate) mod perspective_crop; // draw-artboard -mod artboard; +pub(crate) mod artboard; // draw-bars -mod measure; -mod slice; -mod slice_divide; +pub(crate) mod measure; +pub(crate) mod slice; +pub(crate) mod slice_divide; // draw-stroke -mod stroke_button; -mod stroke_editor; +pub(crate) mod stroke_button; +pub(crate) mod stroke_editor; // draw-brush-presets -mod brush_presets; -mod brush_size; -mod paint_bar; +pub(crate) mod brush_presets; +pub(crate) mod brush_size; +pub(crate) mod paint_bar; // draw-transform-a -mod transform_box; -mod transform_session; +pub(crate) mod transform_box; +pub(crate) mod transform_session; // draw-transform-b -mod symmetry; -mod transform_fields; +pub(crate) mod symmetry; +pub(crate) mod transform_fields; // draw-presets -mod presets; +pub(crate) mod presets; // dialogs-w13 -mod pattern_fill; +pub(crate) mod pattern_fill; diff --git a/crates/font-manager/src/axes.rs b/crates/font-manager/src/axes.rs index 6401367c6..84b61a6f1 100644 --- a/crates/font-manager/src/axes.rs +++ b/crates/font-manager/src/axes.rs @@ -3,7 +3,7 @@ //! and reading them from a font are always available; the sliders are on `ui`. #[cfg(feature = "ui")] -mod sliders; +pub(crate) mod sliders; #[cfg(feature = "ui")] pub use sliders::*; diff --git a/crates/font-manager/src/axes/sliders.rs b/crates/font-manager/src/axes/sliders.rs index 51ed8904b..f9e4ee499 100644 --- a/crates/font-manager/src/axes/sliders.rs +++ b/crates/font-manager/src/axes/sliders.rs @@ -1,7 +1,7 @@ //! The row of sliders that edits the axes of a face (Photoshop's Properties › Character axis sliders; FigCraft's axis panel). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/glyphs.rs b/crates/font-manager/src/glyphs.rs index a52059e89..3d9bbca2d 100644 --- a/crates/font-manager/src/glyphs.rs +++ b/crates/font-manager/src/glyphs.rs @@ -3,7 +3,7 @@ //! glyphs in a row at the top. Double-click or Enter inserts the glyph where the app can insert. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/lib.rs b/crates/font-manager/src/lib.rs index ccb334ac7..f3bb0d1ac 100644 --- a/crates/font-manager/src/lib.rs +++ b/crates/font-manager/src/lib.rs @@ -25,7 +25,7 @@ pub mod glyphs; #[cfg(feature = "ui")] pub mod missing; #[cfg(feature = "ui")] -mod panel; +pub(crate) mod panel; #[cfg(feature = "ui")] pub mod picker; @@ -40,6 +40,7 @@ pub use panel::{ /// The registered stories and trials of this crate. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } diff --git a/crates/font-manager/src/missing.rs b/crates/font-manager/src/missing.rs index 45af646b3..cb5dc5e11 100644 --- a/crates/font-manager/src/missing.rs +++ b/crates/font-manager/src/missing.rs @@ -3,7 +3,7 @@ //! "missing fonts" warning on open; VectorCraft's and FigCraft's Document Fonts lists). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::borrow::Cow; use std::sync::Arc; diff --git a/crates/font-manager/src/panel/app.rs b/crates/font-manager/src/panel/app.rs index f1b099d91..563af58e8 100644 --- a/crates/font-manager/src/panel/app.rs +++ b/crates/font-manager/src/panel/app.rs @@ -2,7 +2,7 @@ //! reading start, the family cards, the details sheet and the download consent. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::collections::HashMap; use std::sync::Arc; diff --git a/crates/font-manager/src/panel/browse.rs b/crates/font-manager/src/panel/browse.rs index 5b31c135a..fe8bc234b 100644 --- a/crates/font-manager/src/panel/browse.rs +++ b/crates/font-manager/src/panel/browse.rs @@ -1,9 +1,9 @@ //! The tabs and search, the filters, the sample toolbar and the list of family cards. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; -mod cards; +pub(crate) mod cards; use std::borrow::Cow; use std::sync::Arc; diff --git a/crates/font-manager/src/panel/details.rs b/crates/font-manager/src/panel/details.rs index 36592c7e0..480ad4be3 100644 --- a/crates/font-manager/src/panel/details.rs +++ b/crates/font-manager/src/panel/details.rs @@ -1,9 +1,9 @@ //! The details sheet: a family's every style in its own face, its facts and languages, and //! installing or removing it whole or a style at a time. -mod rows; +pub(crate) mod rows; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/panel/mod.rs b/crates/font-manager/src/panel/mod.rs index 0efc27e10..4746d488b 100644 --- a/crates/font-manager/src/panel/mod.rs +++ b/crates/font-manager/src/panel/mod.rs @@ -3,16 +3,16 @@ mod i18n; -mod app; +pub(crate) mod app; pub(crate) mod browse; -mod details; +pub(crate) mod details; pub(crate) mod faces; #[cfg(feature = "screen-testing")] pub(crate) mod fixtures; pub(crate) mod jobs; pub(crate) mod samples; -mod sources; -mod specimen; +pub(crate) mod sources; +pub(crate) mod specimen; pub use app::{ FontsCommand, FontsPanel, FontsPanelOutput, FontsPanelSettings, FontsPanelView, FontsPanelWords, Options, Preset, Tab, install_interface_fonts, diff --git a/crates/font-manager/src/panel/sources.rs b/crates/font-manager/src/panel/sources.rs index 450b1cbe7..3c87a484e 100644 --- a/crates/font-manager/src/panel/sources.rs +++ b/crates/font-manager/src/panel/sources.rs @@ -3,7 +3,7 @@ //! and downloading them all again. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/panel/specimen.rs b/crates/font-manager/src/panel/specimen.rs index 85cfe0dbf..fad35bc7d 100644 --- a/crates/font-manager/src/panel/specimen.rs +++ b/crates/font-manager/src/panel/specimen.rs @@ -13,7 +13,7 @@ use crate::FaceInfo; use crate::panel::faces::{self, Owner, Shown}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The ink of a sample: the text colour for a face that drew, the muted one for the interface face standing in. #[derive(Clone, Debug, PartialEq, ComponentStyle)] diff --git a/crates/font-manager/src/picker.rs b/crates/font-manager/src/picker.rs index 5a9f6c91c..c049e1914 100644 --- a/crates/font-manager/src/picker.rs +++ b/crates/font-manager/src/picker.rs @@ -3,10 +3,10 @@ //! drawn in their own face, favourites (stars), recent families at the top, class and feature filters above the //! list and a "similar fonts" filter. Behaviour follows Photoshop's font menu. -mod rank; +pub(crate) mod rank; mod rows; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/font-manager/src/picker/rank.rs b/crates/font-manager/src/picker/rank.rs index fd27c0509..7d6637864 100644 --- a/crates/font-manager/src/picker/rank.rs +++ b/crates/font-manager/src/picker/rank.rs @@ -377,7 +377,7 @@ pub(super) fn list(catalog: &Arc, infos: &Infos, listing: &Listing<'_>, } #[cfg(test)] -mod tests { +pub(crate) mod tests { use craft_ui::testing::trial; use super::{ARABIC_CORE, has_arabic_sample}; diff --git a/crates/font-manager/tests/it/main.rs b/crates/font-manager/tests/it/main.rs index 76d76dfab..cb108c42e 100644 --- a/crates/font-manager/tests/it/main.rs +++ b/crates/font-manager/tests/it/main.rs @@ -1,11 +1,15 @@ //! The integration binary of craft-font-manager: every test is a registered trial. -mod missing; -mod panel; -mod picker; +pub(crate) mod missing; +pub(crate) mod panel; +pub(crate) mod picker; -use craft_font_manager::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run( + module_path!(), + env!("CARGO_PKG_NAME"), + &craft_ui::testing::Registry::of(&[register, craft_font_manager::testing::register]), + ); } diff --git a/crates/imaging/src/layer_style/mod.rs b/crates/imaging/src/layer_style/mod.rs index 5c4176b2a..7b31d5e18 100644 --- a/crates/imaging/src/layer_style/mod.rs +++ b/crates/imaging/src/layer_style/mod.rs @@ -30,7 +30,7 @@ mod drag; mod model; mod spec; #[cfg(test)] -mod tests; +pub(crate) mod tests; pub use contour::{Contour, ContourPoint}; pub use draft::LayerStyleDraft; diff --git a/crates/imaging/src/lib.rs b/crates/imaging/src/lib.rs index 8e5016486..77b7dac13 100644 --- a/crates/imaging/src/lib.rs +++ b/crates/imaging/src/lib.rs @@ -16,17 +16,18 @@ pub mod wide_angle; /// The registered stories and suite cases of the widgets, for `tests/it`. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(all(test, feature = "screen-testing"))] extern crate self as craft_imaging; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/imaging/src/scopes/mod.rs b/crates/imaging/src/scopes/mod.rs index 7e4019ae0..01096b674 100644 --- a/crates/imaging/src/scopes/mod.rs +++ b/crates/imaging/src/scopes/mod.rs @@ -15,7 +15,7 @@ mod clipping; mod statistics; #[cfg(test)] -mod tests; +pub(crate) mod tests; mod vectorscope; pub use clipping::{ChannelMask, ClippedChannels, ClippingMask, clipping}; diff --git a/crates/imaging/src/trace/mod.rs b/crates/imaging/src/trace/mod.rs index 799194c35..492e3e1f3 100644 --- a/crates/imaging/src/trace/mod.rs +++ b/crates/imaging/src/trace/mod.rs @@ -15,7 +15,7 @@ use std::hash::{Hash, Hasher}; #[cfg(test)] -mod tests; +pub(crate) mod tests; /// One boundary segment in document pixels, from one end to the other. Every segment is /// horizontal or vertical. diff --git a/crates/imaging/src/ui/adjust/basic.rs b/crates/imaging/src/ui/adjust/basic.rs index a8143b3c5..dfb53cbae 100644 --- a/crates/imaging/src/ui/adjust/basic.rs +++ b/crates/imaging/src/ui/adjust/basic.rs @@ -1,11 +1,11 @@ //! Photoshop's four small adjustments: Brightness/Contrast, Threshold, Color Balance and Photo Filter. -mod brightness_contrast; -mod color_balance; -mod photo_filter; +pub(crate) mod brightness_contrast; +pub(crate) mod color_balance; +pub(crate) mod photo_filter; #[cfg(feature = "suite")] -mod stories; -mod threshold; +pub(crate) mod stories; +pub(crate) mod threshold; pub use brightness_contrast::{BrightnessContrast, BrightnessContrastEditor}; pub use color_balance::{ColorBalance, ColorBalanceEditor, ColorBalanceOutput, ColorBalanceTone}; diff --git a/crates/imaging/src/ui/adjust/curves_panel.rs b/crates/imaging/src/ui/adjust/curves_panel.rs index 2e6ce2d83..9f401fbd2 100644 --- a/crates/imaging/src/ui/adjust/curves_panel.rs +++ b/crates/imaging/src/ui/adjust/curves_panel.rs @@ -4,7 +4,7 @@ //! ([`CurvesPanel::add_point_from_sample`]). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/imaging/src/ui/adjust/hue_saturation.rs b/crates/imaging/src/ui/adjust/hue_saturation.rs index 2ae72ba3d..ebaec581b 100644 --- a/crates/imaging/src/ui/adjust/hue_saturation.rs +++ b/crates/imaging/src/ui/adjust/hue_saturation.rs @@ -2,7 +2,7 @@ //! that wrap at 360°. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::Mixed; use craft_theme::{Hsb, Srgba}; diff --git a/crates/imaging/src/ui/adjust/levels_editor.rs b/crates/imaging/src/ui/adjust/levels_editor.rs index 10988ddf7..5f1bc2ad4 100644 --- a/crates/imaging/src/ui/adjust/levels_editor.rs +++ b/crates/imaging/src/ui/adjust/levels_editor.rs @@ -2,7 +2,7 @@ //! and fields, editing one channel's [`Levels`]. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::ops::RangeInclusive; diff --git a/crates/imaging/src/ui/adjust/levels_panel.rs b/crates/imaging/src/ui/adjust/levels_panel.rs index e381f24b5..aa0ef971d 100644 --- a/crates/imaging/src/ui/adjust/levels_panel.rs +++ b/crates/imaging/src/ui/adjust/levels_panel.rs @@ -2,7 +2,7 @@ //! Channel select, Auto and the editor over the shown channel's histogram. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/imaging/src/ui/adjust/mixers.rs b/crates/imaging/src/ui/adjust/mixers.rs index 53cba62db..155fa450c 100644 --- a/crates/imaging/src/ui/adjust/mixers.rs +++ b/crates/imaging/src/ui/adjust/mixers.rs @@ -1,10 +1,10 @@ //! The channel-mixing adjustments: Black & White, Channel Mixer and Selective Color. -mod black_white; -mod channel_mixer; -mod selective_color; +pub(crate) mod black_white; +pub(crate) mod channel_mixer; +pub(crate) mod selective_color; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use black_white::{BlackWhite, BlackWhiteEditor, BlackWhiteOutput}; pub use channel_mixer::{ChannelMixer, ChannelMixerEditor}; diff --git a/crates/imaging/src/ui/adjust/mod.rs b/crates/imaging/src/ui/adjust/mod.rs index 021d1cb48..1e773ef6f 100644 --- a/crates/imaging/src/ui/adjust/mod.rs +++ b/crates/imaging/src/ui/adjust/mod.rs @@ -15,21 +15,21 @@ //! //! Gradient Map is `craft_draw::ui::gradient::map`, beside the gradient editor it builds on. -mod basic; +pub(crate) mod basic; mod context; -mod curves_panel; +pub(crate) mod curves_panel; mod hosted; -mod hue_saturation; +pub(crate) mod hue_saturation; mod kinds; mod labels; -mod levels_editor; -mod levels_panel; -mod mixers; -mod panel; -mod session; -mod sliders; +pub(crate) mod levels_editor; +pub(crate) mod levels_panel; +pub(crate) mod mixers; +pub(crate) mod panel; +pub(crate) mod session; +pub(crate) mod sliders; mod style; -mod tone; +pub(crate) mod tone; pub use basic::{ BrightnessContrast, BrightnessContrastEditor, ColorBalance, ColorBalanceEditor, ColorBalanceOutput, ColorBalanceTone, PhotoFilter, diff --git a/crates/imaging/src/ui/adjust/panel.rs b/crates/imaging/src/ui/adjust/panel.rs index 73b8687d5..3e69d8df5 100644 --- a/crates/imaging/src/ui/adjust/panel.rs +++ b/crates/imaging/src/ui/adjust/panel.rs @@ -1,7 +1,7 @@ //! [`AdjustmentsPanel`]: the grid of adjustment buttons a document panel offers for adding an adjustment layer. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{Metrics, NavShape, Roving, Sense}; use craft_ui::buttons::IconButton; diff --git a/crates/imaging/src/ui/adjust/session.rs b/crates/imaging/src/ui/adjust/session.rs index 5d1664960..c0c2cf1bd 100644 --- a/crates/imaging/src/ui/adjust/session.rs +++ b/crates/imaging/src/ui/adjust/session.rs @@ -2,7 +2,7 @@ //! layer, so Reset returns to them once the user edited. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The settings an adjustment layer had when the Properties panel started showing it, and whether /// the panel edited them since (or since the last Reset). A plain value the app keeps per panel; diff --git a/crates/imaging/src/ui/adjust/sliders.rs b/crates/imaging/src/ui/adjust/sliders.rs index ceb9a2357..d64de0bb6 100644 --- a/crates/imaging/src/ui/adjust/sliders.rs +++ b/crates/imaging/src/ui/adjust/sliders.rs @@ -6,7 +6,7 @@ //! gesture of the whole value. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::ops::RangeInclusive; use std::sync::Arc; diff --git a/crates/imaging/src/ui/adjust/tone.rs b/crates/imaging/src/ui/adjust/tone.rs index 5ffd10e66..e14d03d44 100644 --- a/crates/imaging/src/ui/adjust/tone.rs +++ b/crates/imaging/src/ui/adjust/tone.rs @@ -6,7 +6,7 @@ //! colour management and mode, so the app does that, as with the Eyedropper. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{CancelReason, Cursor, IconId, PaintedCursor}; use craft_theme::Srgba; diff --git a/crates/imaging/src/ui/blur_pins/mod.rs b/crates/imaging/src/ui/blur_pins/mod.rs index df9271b5f..23e9538bc 100644 --- a/crates/imaging/src/ui/blur_pins/mod.rs +++ b/crates/imaging/src/ui/blur_pins/mod.rs @@ -18,8 +18,8 @@ mod grab; mod model; -mod overlay; -mod panel; +pub(crate) mod overlay; +pub(crate) mod panel; #[cfg(feature = "suite")] pub(crate) mod stories; mod style; diff --git a/crates/imaging/src/ui/channels/mod.rs b/crates/imaging/src/ui/channels/mod.rs index 15ce167df..875a16d1f 100644 --- a/crates/imaging/src/ui/channels/mod.rs +++ b/crates/imaging/src/ui/channels/mod.rs @@ -5,7 +5,7 @@ mod footer; mod labels; mod menu; mod model; -mod panel; +pub(crate) mod panel; mod rows; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/imaging/src/ui/color_range/mod.rs b/crates/imaging/src/ui/color_range/mod.rs index 05b693a7f..e9d0c436f 100644 --- a/crates/imaging/src/ui/color_range/mod.rs +++ b/crates/imaging/src/ui/color_range/mod.rs @@ -10,11 +10,11 @@ //! - [`ColorRangeValue`]: the command's parameters. [`ColorSamples`] holds the sampled points and the order they were //! made in; its `pick` is also Replace Color's sampling rule. -mod dialog; +pub(crate) mod dialog; mod hosted; mod labels; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod value; pub use dialog::{ColorRangeDialog, ColorRangeOutput}; diff --git a/crates/imaging/src/ui/curve/mod.rs b/crates/imaging/src/ui/curve/mod.rs index b8cf17175..6ac9b238e 100644 --- a/crates/imaging/src/ui/curve/mod.rs +++ b/crates/imaging/src/ui/curve/mod.rs @@ -1,10 +1,10 @@ //! The curve editor: the tone curve value and its point rules, the graph, the preview and the gradient ramp. -mod editor; -mod graph; +pub(crate) mod editor; +pub(crate) mod graph; mod model; -mod preview; -mod ramp; +pub(crate) mod preview; +pub(crate) mod ramp; #[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/imaging/src/ui/fill/mod.rs b/crates/imaging/src/ui/fill/mod.rs index b11ab1485..e419bc8ec 100644 --- a/crates/imaging/src/ui/fill/mod.rs +++ b/crates/imaging/src/ui/fill/mod.rs @@ -22,12 +22,12 @@ //! [`FullWindowDialog`]: craft_ui::dialog::FullWindowDialog //! [`EditHistory`]: craft_behavior::EditHistory -mod bar; +pub(crate) mod bar; mod commands; mod lasso; mod overlay; -mod panel; -mod preview_pane; +pub(crate) mod panel; +pub(crate) mod preview_pane; mod session; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/imaging/src/ui/filter_gallery/mod.rs b/crates/imaging/src/ui/filter_gallery/mod.rs index 7a40b878d..ca7f5ad08 100644 --- a/crates/imaging/src/ui/filter_gallery/mod.rs +++ b/crates/imaging/src/ui/filter_gallery/mod.rs @@ -21,12 +21,12 @@ //! [`EditHistory`]: craft_behavior::EditHistory mod catalog; -mod parameters; +pub(crate) mod parameters; mod session; -mod stack; +pub(crate) mod stack; #[cfg(feature = "suite")] pub(crate) mod stories; -mod tree; +pub(crate) mod tree; mod words; pub use catalog::{FilterCatalog, FilterCategory, FilterGallerySource, FilterIndex, GalleryFilter, GalleryThumb}; diff --git a/crates/imaging/src/ui/histogram/mod.rs b/crates/imaging/src/ui/histogram/mod.rs index e8b9d7773..da219a9ba 100644 --- a/crates/imaging/src/ui/histogram/mod.rs +++ b/crates/imaging/src/ui/histogram/mod.rs @@ -7,7 +7,7 @@ mod data; pub mod paint; -mod plot; +pub(crate) mod plot; #[cfg(feature = "suite")] pub(crate) mod stories; mod words; diff --git a/crates/imaging/src/ui/layer_style/blend_if/mod.rs b/crates/imaging/src/ui/layer_style/blend_if/mod.rs index 5a9998901..9f35c0d94 100644 --- a/crates/imaging/src/ui/layer_style/blend_if/mod.rs +++ b/crates/imaging/src/ui/layer_style/blend_if/mod.rs @@ -1,7 +1,7 @@ //! `BlendIfBar`: one Blend If slider (This Layer or Underlying Layer) with its four handles, over `ThumbRow`. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{EditEvents, Mixed}; use craft_ui::contract::{Bind, EditResponse, Props as _, Show as _, ShowContainer as _}; diff --git a/crates/imaging/src/ui/layer_style/contour/mod.rs b/crates/imaging/src/ui/layer_style/contour/mod.rs index f99b6cc03..c2f410b15 100644 --- a/crates/imaging/src/ui/layer_style/contour/mod.rs +++ b/crates/imaging/src/ui/layer_style/contour/mod.rs @@ -3,7 +3,7 @@ mod editor; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/imaging/src/ui/layer_style/mod.rs b/crates/imaging/src/ui/layer_style/mod.rs index 87d3b8f7d..1af53d05a 100644 --- a/crates/imaging/src/ui/layer_style/mod.rs +++ b/crates/imaging/src/ui/layer_style/mod.rs @@ -22,16 +22,16 @@ //! } //! ``` -mod blend_if; +pub(crate) mod blend_if; mod blending; -mod contour; -mod dialog; -mod hosted; +pub(crate) mod contour; +pub(crate) mod dialog; +pub(crate) mod hosted; mod labels; mod list; mod page; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod styles; pub use blend_if::{BlendIfBar, BlendIfWords}; diff --git a/crates/imaging/src/ui/liquify/canvas.rs b/crates/imaging/src/ui/liquify/canvas.rs index a51bef5db..d50245784 100644 --- a/crates/imaging/src/ui/liquify/canvas.rs +++ b/crates/imaging/src/ui/liquify/canvas.rs @@ -1,7 +1,7 @@ //! Liquify's canvas: the canvas tool, the backdrop layering, the freeze mask source, the lasso line, the mesh. mod backdrop; -mod lasso; +pub(crate) mod lasso; mod mesh; pub(super) use backdrop::MaskAtTexel; diff --git a/crates/imaging/src/ui/liquify/mod.rs b/crates/imaging/src/ui/liquify/mod.rs index 8da163f54..a33eb6154 100644 --- a/crates/imaging/src/ui/liquify/mod.rs +++ b/crates/imaging/src/ui/liquify/mod.rs @@ -44,9 +44,9 @@ //! [`FullWindowSide`]: craft_ui::dialog::FullWindowSide //! [`EditHistory`]: craft_behavior::EditHistory -mod canvas; +pub(crate) mod canvas; mod commands; -mod panel; +pub(crate) mod panel; mod session; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/imaging/src/ui/mask_view/mod.rs b/crates/imaging/src/ui/mask_view/mod.rs index 60dea75ba..db736cdf5 100644 --- a/crates/imaging/src/ui/mask_view/mod.rs +++ b/crates/imaging/src/ui/mask_view/mod.rs @@ -20,7 +20,7 @@ //! SelectionOverlay::new("Selection", &proxy_mask).visible(state.view.recipe().ants).reduction(k).show_at(ui, canvas_rect); //! ``` -mod controls; +pub(crate) mod controls; mod keys; mod state; #[cfg(feature = "suite")] diff --git a/crates/imaging/src/ui/raw_develop/mod.rs b/crates/imaging/src/ui/raw_develop/mod.rs index 0011b018c..d9e1183f9 100644 --- a/crates/imaging/src/ui/raw_develop/mod.rs +++ b/crates/imaging/src/ui/raw_develop/mod.rs @@ -13,14 +13,14 @@ //! [`FullWindowWorkspace`]: craft_ui::dialog::FullWindowWorkspace mod commands; -mod controls; -mod filmstrip; +pub(crate) mod controls; +pub(crate) mod filmstrip; mod mixer; mod preview; -mod scopes; +pub(crate) mod scopes; mod source; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; use std::cell::RefCell; diff --git a/crates/imaging/src/ui/scopes/mod.rs b/crates/imaging/src/ui/scopes/mod.rs index f22787f55..b81bdee44 100644 --- a/crates/imaging/src/ui/scopes/mod.rs +++ b/crates/imaging/src/ui/scopes/mod.rs @@ -24,15 +24,15 @@ //! | Clipping | [`ClipWarning`], [`ClippingOverlay`], [`ClippingMode`], [`ClippingWarnings`], [`ClippingDiagnostic`] | //! | Vectorscope alone | [`VectorscopePlot`], [`scope_point`] | -mod clipping; +pub(crate) mod clipping; mod menu; -mod panel; +pub(crate) mod panel; mod plot; #[cfg(feature = "suite")] pub(crate) mod stories; -mod vectorscope; +pub(crate) mod vectorscope; mod words; -mod zones; +pub(crate) mod zones; pub use clipping::{ClipWarning, ClippingDiagnostic, ClippingFrame, ClippingMode, ClippingOverlay, ClippingWarnings}; pub use menu::{ScopeCommand, ScopeMenuAction}; diff --git a/crates/imaging/src/ui/select_mask/mod.rs b/crates/imaging/src/ui/select_mask/mod.rs index a58118f9c..3d8ed06ce 100644 --- a/crates/imaging/src/ui/select_mask/mod.rs +++ b/crates/imaging/src/ui/select_mask/mod.rs @@ -38,10 +38,10 @@ //! [`EditHistory`]: craft_behavior::EditHistory //! [`FullWindowWorkspace`]: craft_ui::dialog::FullWindowWorkspace -mod bar; +pub(crate) mod bar; mod commands; mod edits; -mod panel; +pub(crate) mod panel; mod session; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/imaging/src/ui/selection/mod.rs b/crates/imaging/src/ui/selection/mod.rs index 968b5d00c..849aa4e49 100644 --- a/crates/imaging/src/ui/selection/mod.rs +++ b/crates/imaging/src/ui/selection/mod.rs @@ -9,7 +9,7 @@ //! [`PreviewMode`]: crate::selection::PreviewMode //! [`QuickMaskLook`]: crate::selection::QuickMaskLook -mod overlay; +pub(crate) mod overlay; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/imaging/src/ui/vanishing_point/editor/mod.rs b/crates/imaging/src/ui/vanishing_point/editor/mod.rs index 10d6f2b8f..ed41f5ebc 100644 --- a/crates/imaging/src/ui/vanishing_point/editor/mod.rs +++ b/crates/imaging/src/ui/vanishing_point/editor/mod.rs @@ -2,7 +2,7 @@ //! ([`VanishingPointPass`]) and its two faces on a canvas, [`VanishingPointTool`] (Create Plane, the paste and Stamp //! presses) and [`VanishingPlanes`] (the planes on the canvas, each corner and edge node a part). -mod control; +pub(crate) mod control; mod tool; mod work; diff --git a/crates/imaging/src/ui/vanishing_point/mod.rs b/crates/imaging/src/ui/vanishing_point/mod.rs index c7f0bc264..c78d00647 100644 --- a/crates/imaging/src/ui/vanishing_point/mod.rs +++ b/crates/imaging/src/ui/vanishing_point/mod.rs @@ -20,11 +20,11 @@ //! [`FullWindowDialog`]: craft_ui::dialog::FullWindowDialog //! [`EditHistory`]: craft_behavior::EditHistory -mod bar; +pub(crate) mod bar; mod command; mod commands; mod draw; -mod editor; +pub(crate) mod editor; mod new_plane; mod planes; #[cfg(feature = "suite")] diff --git a/crates/imaging/src/ui/warp/cylinder.rs b/crates/imaging/src/ui/warp/cylinder.rs index db96973c6..526229537 100644 --- a/crates/imaging/src/ui/warp/cylinder.rs +++ b/crates/imaging/src/ui/warp/cylinder.rs @@ -22,7 +22,7 @@ use egui::{CornerRadius, Pos2, Rect, Response, Vec2}; use super::WarpMesh; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The bend of both arcs the Cylinder starts with, in units of the half axis: about a quarter of the width. const DEFAULT_DEPTH: f64 = 0.5; diff --git a/crates/imaging/src/ui/warp/mod.rs b/crates/imaging/src/ui/warp/mod.rs index c63d5630d..5712e026f 100644 --- a/crates/imaging/src/ui/warp/mod.rs +++ b/crates/imaging/src/ui/warp/mod.rs @@ -5,15 +5,15 @@ //! Perspective Warp ([`perspective`]), the Cylinder warp's editor ([`CylinderWarp`]) and the one painter of a deformed mesh's lines //! (`MeshLines`). -mod cylinder; -mod fields; -mod grid; -mod mesh; +pub(crate) mod cylinder; +pub(crate) mod fields; +pub(crate) mod grid; +pub(crate) mod mesh; mod model; pub mod perspective; pub mod pin; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use cylinder::{CylinderHandle, CylinderValues, CylinderWarp, CylinderWarpOutput, CylinderWarpStyle}; pub use fields::{WarpFieldValues, WarpFields, WarpFieldsEdit, WarpFieldsOutput, WarpFieldsWords, WarpGridChoice, WarpStyleEntry}; diff --git a/crates/imaging/src/ui/warp/perspective/mod.rs b/crates/imaging/src/ui/warp/perspective/mod.rs index 6f9ada6b8..b82705888 100644 --- a/crates/imaging/src/ui/warp/perspective/mod.rs +++ b/crates/imaging/src/ui/warp/perspective/mod.rs @@ -2,8 +2,8 @@ //! ([`PerspectiveSession`], [`PerspectiveWarp`], [`PerspectiveBar`]). The warp map is the app's; //! the warped picture is drawn by the transform preview through `PreviewMap::function`. -mod bar; -mod overlay; +pub(crate) mod bar; +pub(crate) mod overlay; mod session; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/imaging/src/ui/warp/pin/mod.rs b/crates/imaging/src/ui/warp/pin/mod.rs index 2cbd631d5..dc6215a01 100644 --- a/crates/imaging/src/ui/warp/pin/mod.rs +++ b/crates/imaging/src/ui/warp/pin/mod.rs @@ -2,8 +2,8 @@ //! [`PinWarpBar`]). The solver is the app's ([`PinSolver`]); the warped picture is drawn by the //! transform preview through `PreviewMap::pins`. -mod bar; -mod overlay; +pub(crate) mod bar; +pub(crate) mod overlay; mod session; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/imaging/src/ui/wide_angle/mod.rs b/crates/imaging/src/ui/wide_angle/mod.rs index 19ed8ced1..7a9e663e0 100644 --- a/crates/imaging/src/ui/wide_angle/mod.rs +++ b/crates/imaging/src/ui/wide_angle/mod.rs @@ -15,8 +15,8 @@ //! [`EditHistory`]: craft_behavior::EditHistory mod commands; -mod lines; -mod panel; +pub(crate) mod lines; +pub(crate) mod panel; mod session; #[cfg(feature = "suite")] pub(crate) mod stories; diff --git a/crates/imaging/tests/it/main.rs b/crates/imaging/tests/it/main.rs index 4b4b02eff..149beaa38 100644 --- a/crates/imaging/tests/it/main.rs +++ b/crates/imaging/tests/it/main.rs @@ -1,27 +1,27 @@ //! The screen tests of craft-imaging, folded into the lib's test target. -mod adjust_editors; -mod adjust_tone; -mod blur_pins; -mod color_range; -mod contour_field; -mod curve; -mod fill; -mod filter_gallery; -mod histogram; -mod hosted_dialogs; -mod layer_style; -mod liquify; -mod live_preview; -mod perspective_warp; -mod pin_warp; -mod raw_develop; -mod scopes; -mod select; -mod select_mask; -mod selection; -mod threshold; -mod transform_preview; -mod vanishing_point; -mod warp; -mod wide_angle; +pub(crate) mod adjust_editors; +pub(crate) mod adjust_tone; +pub(crate) mod blur_pins; +pub(crate) mod color_range; +pub(crate) mod contour_field; +pub(crate) mod curve; +pub(crate) mod fill; +pub(crate) mod filter_gallery; +pub(crate) mod histogram; +pub(crate) mod hosted_dialogs; +pub(crate) mod layer_style; +pub(crate) mod liquify; +pub(crate) mod live_preview; +pub(crate) mod perspective_warp; +pub(crate) mod pin_warp; +pub(crate) mod raw_develop; +pub(crate) mod scopes; +pub(crate) mod select; +pub(crate) mod select_mask; +pub(crate) mod selection; +pub(crate) mod threshold; +pub(crate) mod transform_preview; +pub(crate) mod vanishing_point; +pub(crate) mod warp; +pub(crate) mod wide_angle; diff --git a/crates/layers/src/lib.rs b/crates/layers/src/lib.rs index a283d7986..df20b8777 100644 --- a/crates/layers/src/lib.rs +++ b/crates/layers/src/lib.rs @@ -19,7 +19,7 @@ pub mod testing { #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); /// The rect of the thumbnail that shows `part` of the layer `info`, in the row whose node is `row`, as the row /// recorded it last pass; `None` when the row shows no such thumbnail. `row` is the layer's row, or for diff --git a/crates/layers/src/ui/comps/mod.rs b/crates/layers/src/ui/comps/mod.rs index 768bd8b6e..29a752082 100644 --- a/crates/layers/src/ui/comps/mod.rs +++ b/crates/layers/src/ui/comps/mod.rs @@ -4,7 +4,7 @@ mod body; mod events; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; pub use events::{LayerCompsEvent, LayerCompsOutput, LayerCompsRowCommands}; diff --git a/crates/layers/src/ui/filter/mod.rs b/crates/layers/src/ui/filter/mod.rs index 1851e2a47..beb2e9023 100644 --- a/crates/layers/src/ui/filter/mod.rs +++ b/crates/layers/src/ui/filter/mod.rs @@ -6,7 +6,7 @@ //! `ui.set layerFilter {by, kinds, name, effect, mode, attribute, color, smart}`) without the panel. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{EditEvent, IconId, Mixed, SelectionChange}; use craft_theme::{ControlSize, LabelColor}; diff --git a/crates/layers/src/ui/options/mod.rs b/crates/layers/src/ui/options/mod.rs index 852c60cf9..6169c156a 100644 --- a/crates/layers/src/ui/options/mod.rs +++ b/crates/layers/src/ui/options/mod.rs @@ -4,7 +4,7 @@ //! `LayersOptions` is the value the dialog edits and returns, held by the settings. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_ui::choice::{Checkbox, Radio, RadioGroup}; use craft_ui::contract::{Bind, FieldLayout, LabelKind, Props as _, Show as _, ShowContainer as _, SideLabel}; diff --git a/crates/layers/src/ui/panel/mod.rs b/crates/layers/src/ui/panel/mod.rs index 3956f91a6..94aa032d6 100644 --- a/crates/layers/src/ui/panel/mod.rs +++ b/crates/layers/src/ui/panel/mod.rs @@ -12,7 +12,7 @@ mod footer; mod menu; mod row; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use drag::{LayersDrag, document_hash}; pub use events::{ diff --git a/crates/layers/src/ui/rows/mod.rs b/crates/layers/src/ui/rows/mod.rs index b1861f45f..614f7a586 100644 --- a/crates/layers/src/ui/rows/mod.rs +++ b/crates/layers/src/ui/rows/mod.rs @@ -1,7 +1,7 @@ //! `BlendRows`: Blend mode, Opacity, Lock and Fill as one block. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{EditEvent, EditEvents, IconId}; use craft_theme::ControlSize; diff --git a/crates/layers/tests/it/main.rs b/crates/layers/tests/it/main.rs index 0fb972e0e..6060bcd6f 100644 --- a/crates/layers/tests/it/main.rs +++ b/crates/layers/tests/it/main.rs @@ -1,14 +1,16 @@ //! The integration binary of craft-layers: every test is a registered trial. -mod blend_rows; -mod comps; -mod panel_drag_menu; -mod panel_filter; -mod panel_input; -mod panel_order; -mod panel_reveal; -mod panel_rows; +pub(crate) mod blend_rows; +pub(crate) mod comps; +pub(crate) mod panel_drag_menu; +pub(crate) mod panel_filter; +pub(crate) mod panel_input; +pub(crate) mod panel_order; +pub(crate) mod panel_reveal; +pub(crate) mod panel_rows; + +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_layers::testing::registered()); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register, craft_layers::testing::register])); } diff --git a/crates/menu/src/bar.rs b/crates/menu/src/bar.rs index 1a483d8f0..57741109a 100644 --- a/crates/menu/src/bar.rs +++ b/crates/menu/src/bar.rs @@ -9,7 +9,7 @@ //! `Builtin::Quit` and `Builtin::Minimize` act on the root window through the runtime. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_keymap::{CommandRef, Platform}; use craft_ui::contract::Show as _; diff --git a/crates/menu/src/lib.rs b/crates/menu/src/lib.rs index 923c92cf8..d89e6bcef 100644 --- a/crates/menu/src/lib.rs +++ b/crates/menu/src/lib.rs @@ -131,6 +131,7 @@ pub use theme::{THEME_COMMAND, ThemeChoice, ThemeLabels, ThemeMenu, ThemeRow}; #[cfg(feature = "screen-testing")] /// The stories and words this crate registers, for the story tests. pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } diff --git a/crates/menu/src/shortcuts/mod.rs b/crates/menu/src/shortcuts/mod.rs index d68bc0e21..1c98cb867 100644 --- a/crates/menu/src/shortcuts/mod.rs +++ b/crates/menu/src/shortcuts/mod.rs @@ -103,17 +103,17 @@ macro_rules! fill { mod codec; mod import_offer; -mod keyboard; +pub(crate) mod keyboard; mod pages; -mod recorder; +pub(crate) mod recorder; mod review; mod rows; mod sets; mod state; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub mod summary; -mod view; +pub(crate) mod view; mod words; pub use codec::ChordCodec; diff --git a/crates/menu/src/shortcuts/recorder.rs b/crates/menu/src/shortcuts/recorder.rs index f00a71a0c..283776d9a 100644 --- a/crates/menu/src/shortcuts/recorder.rs +++ b/crates/menu/src/shortcuts/recorder.rs @@ -18,7 +18,7 @@ use craft_ui::style::{ComponentStyle, FocusLook, Ink, StyleCx, SurfaceKind, Surf use egui::{Rect, Response, Ui, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The field claims bare Escape while recording, so it reaches the field as a chord (the keymap's recorder reads it as /// cancel) and neither leaves the row nor closes the dialog. diff --git a/crates/menu/src/shortcuts/view.rs b/crates/menu/src/shortcuts/view.rs index 66eb2fe12..af6bed4ba 100644 --- a/crates/menu/src/shortcuts/view.rs +++ b/crates/menu/src/shortcuts/view.rs @@ -8,8 +8,8 @@ mod bars; mod detail; mod header; #[cfg(feature = "suite")] -mod stories; -mod table; +pub(crate) mod stories; +pub(crate) mod table; use std::borrow::Cow; diff --git a/crates/menu/tests/it/main.rs b/crates/menu/tests/it/main.rs index dccdaddd3..f407964b6 100644 --- a/crates/menu/tests/it/main.rs +++ b/crates/menu/tests/it/main.rs @@ -1,11 +1,13 @@ //! The integration binary of craft-menu: every test is a registered trial. -mod layout; -mod mnemonic; -mod native; +pub(crate) mod layout; +pub(crate) mod mnemonic; +pub(crate) mod native; mod sample; -mod shortcuts; +pub(crate) mod shortcuts; + +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_menu::testing::registered()); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register, craft_menu::testing::register])); } diff --git a/crates/menu/tests/it/shortcuts/mod.rs b/crates/menu/tests/it/shortcuts/mod.rs index b7d702d49..ec7e2de90 100644 --- a/crates/menu/tests/it/shortcuts/mod.rs +++ b/crates/menu/tests/it/shortcuts/mod.rs @@ -1,6 +1,6 @@ //! The Keyboard Shortcuts dialog, driven pass by pass through `craft_ui::testing::Fixture`. mod fixture; -mod import_offer; -mod recorder; -mod rows; -mod sets; +pub(crate) mod import_offer; +pub(crate) mod recorder; +pub(crate) mod rows; +pub(crate) mod sets; diff --git a/crates/pages/src/lib.rs b/crates/pages/src/lib.rs index f9b94f692..3a58fdb6d 100644 --- a/crates/pages/src/lib.rs +++ b/crates/pages/src/lib.rs @@ -22,11 +22,11 @@ pub mod layout; #[cfg(test)] -mod layout_tests; +pub(crate) mod layout_tests; pub mod numbering; pub mod range; #[cfg(test)] -mod range_tests; +pub(crate) mod range_tests; pub mod setup; #[cfg(feature = "ui")] pub mod ui; @@ -42,17 +42,18 @@ pub use setup::{MARGIN_PRESETS, MarginPreset, Margins, Orientation, PAPER_SIZES, /// The stories and trials this crate registers. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(all(test, feature = "screen-testing"))] extern crate self as craft_pages; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/pages/src/ui/column_bar.rs b/crates/pages/src/ui/column_bar.rs index 64b4ec37d..7d4fbc344 100644 --- a/crates/pages/src/ui/column_bar.rs +++ b/crates/pages/src/ui/column_bar.rs @@ -3,7 +3,7 @@ //! its least share, and the other columns keep theirs. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::divider::{Give, Segment, resize, travel}; use craft_behavior::{Axis, Metrics, PartKey}; diff --git a/crates/pages/src/ui/grid.rs b/crates/pages/src/ui/grid.rs index c434aef53..c09dbda65 100644 --- a/crates/pages/src/ui/grid.rs +++ b/crates/pages/src/ui/grid.rs @@ -3,7 +3,7 @@ //! pages, under the selection. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::view::PlacedPage; use craft_behavior::{Input, Metrics, Sense}; diff --git a/crates/pages/src/ui/header_footer.rs b/crates/pages/src/ui/header_footer.rs index b079bd2e4..bdc93c1b5 100644 --- a/crates/pages/src/ui/header_footer.rs +++ b/crates/pages/src/ui/header_footer.rs @@ -4,7 +4,7 @@ //! rectangle. What a section holds, its fields and the editor are the app's. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::kurbo::Point; use craft_behavior::{HitLevel, HitPriority, Input, Intent, Metrics, PartKey, Sense}; diff --git a/crates/pages/src/ui/list.rs b/crates/pages/src/ui/list.rs index 5d192e127..a43d75b84 100644 --- a/crates/pages/src/ui/list.rs +++ b/crates/pages/src/ui/list.rs @@ -21,7 +21,7 @@ //! ``` #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{ColumnKey, ColumnWidth, EditEvent, IconId, Mixed, Selection, SelectionChange, keyed}; use craft_ui::contract::{ diff --git a/crates/pages/src/ui/margins.rs b/crates/pages/src/ui/margins.rs index f204ac92f..4b0b36835 100644 --- a/crates/pages/src/ui/margins.rs +++ b/crates/pages/src/ui/margins.rs @@ -3,7 +3,7 @@ //! name, and a drag moves the margin as one edit gesture (one undo step). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::ops::RangeInclusive; diff --git a/crates/pages/src/ui/marks.rs b/crates/pages/src/ui/marks.rs index af7dc43b4..f1c32e4be 100644 --- a/crates/pages/src/ui/marks.rs +++ b/crates/pages/src/ui/marks.rs @@ -4,7 +4,7 @@ //! frame whose story does not fit, and frame outlines with their in and out ports. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::kurbo::{Point, Rect}; use craft_behavior::{CanvasView, Input, Metrics, Sense}; diff --git a/crates/pages/src/ui/preview.rs b/crates/pages/src/ui/preview.rs index ae75489ee..dfe1b5864 100644 --- a/crates/pages/src/ui/preview.rs +++ b/crates/pages/src/ui/preview.rs @@ -3,7 +3,7 @@ //! the arrow and Page keys to step from anywhere in the preview, Escape or Close to leave. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::view::PageSource; use craft_behavior::IconId; diff --git a/crates/pages/src/ui/range.rs b/crates/pages/src/ui/range.rs index 7dc4dfd92..e271a470b 100644 --- a/crates/pages/src/ui/range.rs +++ b/crates/pages/src/ui/range.rs @@ -3,7 +3,7 @@ //! Acrobat's Page Range Options. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{Codec, NotAValue, NumberCodec}; use craft_ui::buttons::IconButton; diff --git a/crates/pages/src/ui/reading.rs b/crates/pages/src/ui/reading.rs index 6ca523173..4abf73670 100644 --- a/crates/pages/src/ui/reading.rs +++ b/crates/pages/src/ui/reading.rs @@ -23,7 +23,7 @@ use super::view::PageSource; use crate::layout::SCREEN_POINTS_PER_POINT; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The page-turn parts: one over each gap between the columns and one over each side margin, indexed from the left. /// A click on one turns toward its side and a swipe starting on one turns by the swipe's direction. diff --git a/crates/pages/src/ui/setup.rs b/crates/pages/src/ui/setup.rs index e2b60b4e8..9f9b934d5 100644 --- a/crates/pages/src/ui/setup.rs +++ b/crates/pages/src/ui/setup.rs @@ -9,7 +9,7 @@ //! ``` #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::ops::RangeInclusive; diff --git a/crates/pages/src/ui/table/mod.rs b/crates/pages/src/ui/table/mod.rs index 04eab7759..8d201a03d 100644 --- a/crates/pages/src/ui/table/mod.rs +++ b/crates/pages/src/ui/table/mod.rs @@ -7,7 +7,7 @@ pub mod properties; pub mod selection; pub mod size_picker; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use edges::{BorderEdges, BorderPreset, EdgeKey, EdgePicker, EdgePickerStyle, EdgePickerWords}; pub use properties::{CellAlign, RowHeight, TableChange, TableProperties, TablePropertiesOutput, TablePropertiesWords, TableValues, TextDirection}; diff --git a/crates/pages/src/ui/text_selection.rs b/crates/pages/src/ui/text_selection.rs index 422891087..3652c7d4a 100644 --- a/crates/pages/src/ui/text_selection.rs +++ b/crates/pages/src/ui/text_selection.rs @@ -18,7 +18,7 @@ use egui::{CornerRadius, Pos2, Response, Vec2, pos2}; use super::view::PlacedPage; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// A page's text as the selection reads it, glyph by glyph in reading order. Rectangles are page points (origin /// top-left). diff --git a/crates/pages/src/ui/thumbnails.rs b/crates/pages/src/ui/thumbnails.rs index d45ce5015..0a293d644 100644 --- a/crates/pages/src/ui/thumbnails.rs +++ b/crates/pages/src/ui/thumbnails.rs @@ -21,7 +21,7 @@ //! ``` #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::view::PageSource; use craft_behavior::{EditEvent, IconId, Selection, SelectionChange, keyed}; diff --git a/crates/pages/src/ui/view.rs b/crates/pages/src/ui/view.rs index b9893ff3b..fa7b7848c 100644 --- a/crates/pages/src/ui/view.rs +++ b/crates/pages/src/ui/view.rs @@ -18,9 +18,9 @@ //! if let Some(view) = reply.and_then(|reply| reply.view) { out.adopt(&mut view_state, &view); } //! ``` -mod pictures; +pub(crate) mod pictures; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use self::pictures::{PageMetrics, PagePictures}; use super::access::AccessDescriber; diff --git a/crates/pages/tests/it/main.rs b/crates/pages/tests/it/main.rs index 23691595a..2eb8595cc 100644 --- a/crates/pages/tests/it/main.rs +++ b/crates/pages/tests/it/main.rs @@ -1,8 +1,8 @@ //! The screen tests of craft-pages, folded into the lib's test target. -mod range; -mod setup; -mod size_picker; -mod text_tables; -mod thumbnails; -mod views; +pub(crate) mod range; +pub(crate) mod setup; +pub(crate) mod size_picker; +pub(crate) mod text_tables; +pub(crate) mod thumbnails; +pub(crate) mod views; diff --git a/crates/print/src/cups/mod.rs b/crates/print/src/cups/mod.rs index 94df2070b..970745d5a 100644 --- a/crates/print/src/cups/mod.rs +++ b/crates/print/src/cups/mod.rs @@ -16,7 +16,7 @@ #[cfg(test)] #[cfg(unix)] -mod tests; +pub(crate) mod tests; use super::{Duplex, Error, Job, Printer, Scaling}; use std::io::{Read, Write}; diff --git a/crates/print/src/lib.rs b/crates/print/src/lib.rs index 05c6c287b..86922604e 100644 --- a/crates/print/src/lib.rs +++ b/crates/print/src/lib.rs @@ -13,17 +13,17 @@ pub mod cups; #[cfg(any(test, windows))] -mod progress; +pub(crate) mod progress; #[cfg(any(test, windows))] -mod sheets; +pub(crate) mod sheets; #[cfg(test)] -mod tests; +pub(crate) mod tests; #[cfg(any(test, windows))] -mod ticket; +pub(crate) mod ticket; #[cfg(windows)] -mod windows; +pub(crate) mod windows; #[cfg(any(test, windows))] -mod xml; +pub(crate) mod xml; /// Native Windows driver settings, printable geometry and explicit RGB/GDI transport. /// Callers perform ICC conversion and compose page pixels/vector strokes. Other platforms @@ -39,8 +39,9 @@ pub mod ui; /// The registrations of this crate's UI types, for its integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } /// A system spooler failure. Document permissions belong to the caller. @@ -1085,9 +1086,9 @@ pub fn command_preview(job: &Job) -> Result, Error> { extern crate self as craft_print; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/print/src/progress.rs b/crates/print/src/progress.rs index a02de2865..faf4d8d62 100644 --- a/crates/print/src/progress.rs +++ b/crates/print/src/progress.rs @@ -26,7 +26,7 @@ pub(crate) fn run( } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/print/src/sheets.rs b/crates/print/src/sheets.rs index 4b61925e6..1893fd2a3 100644 --- a/crates/print/src/sheets.rs +++ b/crates/print/src/sheets.rs @@ -51,4 +51,4 @@ pub(crate) use update::Repeat; #[cfg(test)] #[path = "tests/pdf_bounds.rs"] -mod tests; +pub(crate) mod tests; diff --git a/crates/print/src/tests.rs b/crates/print/src/tests.rs index 10b8a3199..cc86e6da6 100644 --- a/crates/print/src/tests.rs +++ b/crates/print/src/tests.rs @@ -2,7 +2,7 @@ use super::*; use crate as spool; use craft_ui::testing::trial; -mod windows_native; +pub(crate) mod windows_native; /// Set on the child process when a test runs this test binary as a stand-in for `lp`. const STAND_IN_LP: &str = "CRAFT_STAND_IN_LP"; @@ -210,7 +210,7 @@ fn macos_offers_auto_select_where_the_driver_would_pick_its_default_tray() { } #[cfg(all(unix, not(target_arch = "wasm32")))] -mod lpstat_limits { +pub(crate) mod lpstat_limits { use super::*; use craft_ui::testing::trial; use std::process::Command; diff --git a/crates/print/src/ticket.rs b/crates/print/src/ticket.rs index 7436a7b67..fdcc07760 100644 --- a/crates/print/src/ticket.rs +++ b/crates/print/src/ticket.rs @@ -868,4 +868,4 @@ pub(crate) fn job_filename(title: &str) -> String { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/print/src/ui/mod.rs b/crates/print/src/ui/mod.rs index e3033f364..6d3f937a7 100644 --- a/crates/print/src/ui/mod.rs +++ b/crates/print/src/ui/mod.rs @@ -1,10 +1,10 @@ //! Printer selection and asynchronous job feedback, independent of any spooler or document. //! Hosts provide workers; applications own PDF generation, commands and translated wording. -mod dialog; -mod panel; +pub(crate) mod dialog; +pub(crate) mod panel; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use dialog::{HostedPrint, PrintAnswer, PrintDialog, PrintDialogOutput, PrintDialogWords, PrintFinish, PrintMarks, PrintSection, PrintSheet}; pub use panel::{PrintPanel, PrintPanelOutput, PrintWords}; diff --git a/crates/print/src/windows.rs b/crates/print/src/windows.rs index f3fbc88e2..d783201ee 100644 --- a/crates/print/src/windows.rs +++ b/crates/print/src/windows.rs @@ -438,7 +438,7 @@ pub(crate) fn submit_with_progress(pdf: &[u8], job: &Job, progress: &mut dyn FnM } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/print/src/xml.rs b/crates/print/src/xml.rs index e1a9cd467..348bc88ce 100644 --- a/crates/print/src/xml.rs +++ b/crates/print/src/xml.rs @@ -125,7 +125,7 @@ fn attribute_name(tag: &[u8]) -> &[u8] { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/print/tests/it/main.rs b/crates/print/tests/it/main.rs index 302b1dd4f..26e17f8f9 100644 --- a/crates/print/tests/it/main.rs +++ b/crates/print/tests/it/main.rs @@ -2,5 +2,5 @@ // Unwrapping, expecting and panicking on failure is fine in tests, unlike in shipped code. #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] -mod dialog; -mod print; +pub(crate) mod dialog; +pub(crate) mod print; diff --git a/crates/review/src/lib.rs b/crates/review/src/lib.rs index 22379b114..5beb64ebb 100644 --- a/crates/review/src/lib.rs +++ b/crates/review/src/lib.rs @@ -20,14 +20,15 @@ pub mod ui; /// The stories and word sets the integration tests register. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(test)] -mod annotate_tests; +pub(crate) mod annotate_tests; #[cfg(test)] -mod versions_tests; +pub(crate) mod versions_tests; #[cfg(feature = "ui")] pub use annotate::AnnotationEdit; @@ -41,9 +42,9 @@ pub use versions::{Branch, BranchId, BranchState, HistoryRow, Version, VersionId extern crate self as craft_review; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/review/src/ui/annotate.rs b/crates/review/src/ui/annotate.rs index 559fdb29f..c546cc9d7 100644 --- a/crates/review/src/ui/annotate.rs +++ b/crates/review/src/ui/annotate.rs @@ -1,10 +1,10 @@ //! The annotation tool on the canvas, the overlay that draws annotations, and the toolbar. -mod overlay; +pub(crate) mod overlay; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod tool; -mod toolbar; +pub(crate) mod toolbar; mod words; pub use overlay::{AnnotationOverlay, AnnotationOverlayStyle}; diff --git a/crates/review/src/ui/avatar.rs b/crates/review/src/ui/avatar.rs index 696b38fd5..343b15986 100644 --- a/crates/review/src/ui/avatar.rs +++ b/crates/review/src/ui/avatar.rs @@ -10,7 +10,7 @@ use egui::{Color32, Rect, Response, Vec2}; use crate::collab::initials; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Paints a round face filling `rect`: `fill` with the initials of `name` centred on it, in the ink that reads on `fill`. pub fn paint_avatar(ui: &PaintUi<'_>, rect: Rect, name: &str, fill: DataColor) { diff --git a/crates/review/src/ui/chat.rs b/crates/review/src/ui/chat.rs index ba07516af..6cd659d4c 100644 --- a/crates/review/src/ui/chat.rs +++ b/crates/review/src/ui/chat.rs @@ -15,7 +15,7 @@ use egui::{Color32, CornerRadius, Pos2, Rect, Response, Ui, Vec2}; use crate::collab::CollabRequest; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The chat box's words, English by default. diff --git a/crates/review/src/ui/comments.rs b/crates/review/src/ui/comments.rs index 627550981..09ee6d5a1 100644 --- a/crates/review/src/ui/comments.rs +++ b/crates/review/src/ui/comments.rs @@ -11,11 +11,11 @@ //! } //! ``` -mod list; +pub(crate) mod list; mod menus; -mod row; +pub(crate) mod row; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::collections::BTreeMap; diff --git a/crates/review/src/ui/join.rs b/crates/review/src/ui/join.rs index fdfacbcc0..713c0aabe 100644 --- a/crates/review/src/ui/join.rs +++ b/crates/review/src/ui/join.rs @@ -13,7 +13,7 @@ use egui::{Response, Ui}; use crate::collab::{CollabRequest, CollabTransport, JoinState}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The field's words, English by default. diff --git a/crates/review/src/ui/presence.rs b/crates/review/src/ui/presence.rs index a20e7ec69..9c28ea751 100644 --- a/crates/review/src/ui/presence.rs +++ b/crates/review/src/ui/presence.rs @@ -23,7 +23,7 @@ use super::chat::{BubbleLook, paint_chat_bubble}; use crate::collab::{CHAT_FADE_S, CHAT_HOLD_S, CollabRequest, CollabTransport, Participant, ParticipantId, chat_alpha}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Most selection outlines drawn for one person. const MAX_OUTLINES: usize = 500; diff --git a/crates/review/src/ui/revisions.rs b/crates/review/src/ui/revisions.rs index b7cba275c..60f56bf82 100644 --- a/crates/review/src/ui/revisions.rs +++ b/crates/review/src/ui/revisions.rs @@ -17,7 +17,7 @@ use egui::{CornerRadius, Response, Ui, Vec2}; use crate::revisions::{Revision, RevisionAction, RevisionKind}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The detail lines a card shows. const DETAIL_LINES: usize = 8; diff --git a/crates/review/src/ui/signature.rs b/crates/review/src/ui/signature.rs index 7155eeff3..1880b2fe5 100644 --- a/crates/review/src/ui/signature.rs +++ b/crates/review/src/ui/signature.rs @@ -29,7 +29,7 @@ use egui::{ColorImage, Pos2, Rect, Vec2}; use crate::signature::{MAX_IMAGE_BYTES, MAX_IMAGE_SIDE, MAX_SIGNATURE_CHARS, SavedSignature, SignatureDraft, SignatureImage, SignatureTab}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The pad's width over its height. const PAD_ASPECT: f32 = 460.0 / 150.0; diff --git a/crates/review/src/ui/thread.rs b/crates/review/src/ui/thread.rs index 25ae66c4d..79fb335bb 100644 --- a/crates/review/src/ui/thread.rs +++ b/crates/review/src/ui/thread.rs @@ -6,10 +6,10 @@ //! ``` mod mention; -mod pins; -mod popover; +pub(crate) mod pins; +pub(crate) mod popover; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use mention::{insert_mention, mention_matches, mention_query}; pub use pins::{CommentPin, CommentPins, CommentPinsOutput, PinCluster, PinMove, cluster}; diff --git a/crates/review/src/ui/versions.rs b/crates/review/src/ui/versions.rs index 2844b6a4c..cebc5f335 100644 --- a/crates/review/src/ui/versions.rs +++ b/crates/review/src/ui/versions.rs @@ -30,7 +30,7 @@ use crate::versions::{Branch, BranchId, BranchState, HistoryRow, Version, Versio const DESCRIPTION_LINES: u8 = 3; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The panel's words, English by default. diff --git a/crates/review/src/ui/vote.rs b/crates/review/src/ui/vote.rs index ea137108f..d85e00150 100644 --- a/crates/review/src/ui/vote.rs +++ b/crates/review/src/ui/vote.rs @@ -14,7 +14,7 @@ use egui::{Response, Ui}; use crate::collab::{CollabRequest, CollabTransport, VoteScope}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Votes per person a new vote starts with. const DEFAULT_VOTES: u32 = 3; diff --git a/crates/review/tests/it/main.rs b/crates/review/tests/it/main.rs index 0bbe792a5..79c8c1864 100644 --- a/crates/review/tests/it/main.rs +++ b/crates/review/tests/it/main.rs @@ -1,5 +1,5 @@ //! The screen tests of craft-review, folded into the lib's test target. -mod annotate; -mod collab; -mod comments; +pub(crate) mod annotate; +pub(crate) mod collab; +pub(crate) mod comments; diff --git a/crates/table/src/ui/chart.rs b/crates/table/src/ui/chart.rs index 23d04e0b4..c0c3de9e8 100644 --- a/crates/table/src/ui/chart.rs +++ b/crates/table/src/ui/chart.rs @@ -6,7 +6,7 @@ use craft_ui::style::{DataColor, StyleColor}; use egui::{CornerRadius, Pos2, Rect, pos2, vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// A document line width never shrinks below this share of its width at 100 % zoom (a zoom floor, not a size). const MIN_STROKE_ZOOM: f32 = 0.5; diff --git a/crates/table/src/ui/conditions.rs b/crates/table/src/ui/conditions.rs index 5a4433ad6..d4f2131c0 100644 --- a/crates/table/src/ui/conditions.rs +++ b/crates/table/src/ui/conditions.rs @@ -19,7 +19,7 @@ use craft_ui::text::{NumberField, TextField}; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The builder's words, English by default. diff --git a/crates/table/src/ui/error_tag.rs b/crates/table/src/ui/error_tag.rs index 9178f8887..237d85c9e 100644 --- a/crates/table/src/ui/error_tag.rs +++ b/crates/table/src/ui/error_tag.rs @@ -17,7 +17,7 @@ use craft_ui::style::{ComponentStyle, FocusLook, IconLook, StyleCx, SurfaceLook} use egui::{Rect, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The tag's accessible name, English by default (Excel's). diff --git a/crates/table/src/ui/fields.rs b/crates/table/src/ui/fields.rs index 5bd4c1f1d..cb9ef6ddb 100644 --- a/crates/table/src/ui/fields.rs +++ b/crates/table/src/ui/fields.rs @@ -22,7 +22,7 @@ use craft_ui::style::{SurfaceKind, TypeRole}; use egui::{Id, Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The pane's words, English by default. diff --git a/crates/table/src/ui/filter.rs b/crates/table/src/ui/filter.rs index 4e15592d9..1f504337c 100644 --- a/crates/table/src/ui/filter.rs +++ b/crates/table/src/ui/filter.rs @@ -12,7 +12,7 @@ use craft_ui::style::{ComponentStyle, FocusLook, IconLook, StyleCx, SurfaceLook} use egui::{Rect, Response, Vec2, pos2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The filter button's words, English by default. diff --git a/crates/table/src/ui/grid.rs b/crates/table/src/ui/grid.rs index afb4fa0cc..c62058180 100644 --- a/crates/table/src/ui/grid.rs +++ b/crates/table/src/ui/grid.rs @@ -25,9 +25,9 @@ mod input; mod model; mod paint; mod reference; -mod row; +pub(crate) mod row; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use geometry::{GridLayout, HEADER_MIN_ZOOM, SheetGeometry, SheetMetrics}; pub use model::{CellEdit, CellProblem, ColumnFilter, GridEdit, GridMenuTarget, GridModel, GridState}; diff --git a/crates/table/src/ui/mod.rs b/crates/table/src/ui/mod.rs index 91660e5d4..e57c39d1d 100644 --- a/crates/table/src/ui/mod.rs +++ b/crates/table/src/ui/mod.rs @@ -30,8 +30,9 @@ pub mod stats; /// The registrations of the table widgets' stories and trials. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } pub use chart::{ChartPrimitive, HAlign, VAlign, paint_chart}; diff --git a/crates/table/src/ui/outline.rs b/crates/table/src/ui/outline.rs index 0ef2efa2b..04723faac 100644 --- a/crates/table/src/ui/outline.rs +++ b/crates/table/src/ui/outline.rs @@ -13,7 +13,7 @@ use egui::{CornerRadius, Pos2, Rect, Response, Vec2, pos2, vec2}; use super::grid::{CellAt, CellRange, SheetGeometry, column_letters}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The band buttons' accessible names, English by default (Excel's). diff --git a/crates/table/src/ui/slicer.rs b/crates/table/src/ui/slicer.rs index bc05f8347..35bcf293a 100644 --- a/crates/table/src/ui/slicer.rs +++ b/crates/table/src/ui/slicer.rs @@ -18,7 +18,7 @@ use craft_ui::style::{ComponentStyle, Flags, FocusLook, Stateful, StyleColor, St use egui::{Rect, Response, Ui, Vec2, pos2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The slicer's words, English by default. diff --git a/crates/table/src/ui/stats.rs b/crates/table/src/ui/stats.rs index 182bc6332..02c41d4e4 100644 --- a/crates/table/src/ui/stats.rs +++ b/crates/table/src/ui/stats.rs @@ -16,7 +16,7 @@ use craft_ui::style::{ComponentStyle, FocusLook, StyleCx, TextLook}; use egui::{Rect, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The statistics' names, English by default (Excel's). diff --git a/crates/table/tests/it/main.rs b/crates/table/tests/it/main.rs index 1510ba3f8..8ffe46c6c 100644 --- a/crates/table/tests/it/main.rs +++ b/crates/table/tests/it/main.rs @@ -1,12 +1,12 @@ //! The integration binary of craft-table: every test is a registered trial. -mod grid; -mod outline; -mod refpick; -mod slicer; +pub(crate) mod grid; +pub(crate) mod outline; +pub(crate) mod refpick; +pub(crate) mod slicer; -use craft_table::ui::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register, craft_table::ui::testing::register])); } diff --git a/crates/text/src/bidi/mod.rs b/crates/text/src/bidi/mod.rs index 51c6ec50d..f245a0d64 100644 --- a/crates/text/src/bidi/mod.rs +++ b/crates/text/src/bidi/mod.rs @@ -415,4 +415,4 @@ fn l1_reset(class: BidiClass, trailing: &mut bool) -> bool { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/text/src/composer.rs b/crates/text/src/composer.rs index df80f4711..a3ff19eb8 100644 --- a/crates/text/src/composer.rs +++ b/crates/text/src/composer.rs @@ -341,7 +341,7 @@ pub fn compose_with( } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/text/src/hyphen/dict.rs b/crates/text/src/hyphen/dict.rs index bb5bec930..33e155b19 100644 --- a/crates/text/src/hyphen/dict.rs +++ b/crates/text/src/hyphen/dict.rs @@ -154,7 +154,7 @@ pub fn parse_hyphenated(s: &str) -> (String, u64) { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/text/src/hyphen/mod.rs b/crates/text/src/hyphen/mod.rs index 31b130494..d664811ec 100644 --- a/crates/text/src/hyphen/mod.rs +++ b/crates/text/src/hyphen/mod.rs @@ -14,9 +14,9 @@ //! Then the paragraph's limits ([`Limits`]) are applied. #[cfg(feature = "generator")] -pub mod dict; +pub(crate) mod dict; #[cfg(not(feature = "generator"))] -mod dict; +pub(crate) mod dict; #[cfg(feature = "generator")] pub mod patgen; mod patterns; @@ -516,4 +516,4 @@ fn heuristic_points(c: &[char]) -> Vec { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index d402923f4..4c724fbe7 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -37,20 +37,20 @@ pub mod bidi; #[cfg(feature = "find")] pub mod find; #[cfg(all(test, feature = "find"))] -mod find_tests; +pub(crate) mod find_tests; #[cfg(feature = "hyphen")] pub mod hyphen; pub mod linebreak; pub mod lists; #[cfg(test)] -mod lists_tests; +pub(crate) mod lists_tests; pub mod quotes; #[cfg(feature = "segment")] pub mod segment; #[cfg(feature = "spell")] pub mod spell; #[cfg(all(test, feature = "spell"))] -mod spell_tests; +pub(crate) mod spell_tests; pub mod styles; #[cfg(feature = "ui")] pub mod ui; @@ -58,19 +58,20 @@ pub mod ui; /// The stories and trials of the crate's UI, registered in craft-ui's registry. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(all(test, feature = "screen-testing"))] extern crate self as craft_text; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } /// Paragraph-wide line composition with stateful line measurement. diff --git a/crates/text/src/linebreak/mod.rs b/crates/text/src/linebreak/mod.rs index 895ad4bc9..88f3dbb68 100644 --- a/crates/text/src/linebreak/mod.rs +++ b/crates/text/src/linebreak/mod.rs @@ -23,7 +23,7 @@ mod greedy; mod knuth_plass; #[cfg(test)] -mod tests; +pub(crate) mod tests; use std::ops::Range; diff --git a/crates/text/src/positioned.rs b/crates/text/src/positioned.rs index 0c15132a3..11217990f 100644 --- a/crates/text/src/positioned.rs +++ b/crates/text/src/positioned.rs @@ -136,7 +136,7 @@ impl PositionedGlyph { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/text/src/segment/mod.rs b/crates/text/src/segment/mod.rs index 9aadf9a78..6a783a401 100644 --- a/crates/text/src/segment/mod.rs +++ b/crates/text/src/segment/mod.rs @@ -23,7 +23,7 @@ mod complex; mod kinsoku; #[cfg(test)] -mod tests; +pub(crate) mod tests; use std::ops::Range; diff --git a/crates/text/src/ui/character.rs b/crates/text/src/ui/character.rs index c74e61afb..21f1d8f88 100644 --- a/crates/text/src/ui/character.rs +++ b/crates/text/src/ui/character.rs @@ -30,11 +30,11 @@ use craft_ui::text::{NamedOr, NumberName, NumberPick, NumberValue as _}; use egui::{Response, Ui}; pub(crate) mod paragraph; -mod paragraph_dialog; +pub(crate) mod paragraph_dialog; pub(crate) mod rows; #[cfg(feature = "suite")] -mod stories; -mod style_options; +pub(crate) mod stories; +pub(crate) mod style_options; pub use paragraph::{ParagraphChange, ParagraphControls, ParagraphControlsOutput, ParagraphDirection, ParagraphValues, ParagraphWords, TextAlign}; pub use paragraph_dialog::{ diff --git a/crates/text/src/ui/character/style_options.rs b/crates/text/src/ui/character/style_options.rs index 4de90ff8d..cf1620355 100644 --- a/crates/text/src/ui/character/style_options.rs +++ b/crates/text/src/ui/character/style_options.rs @@ -31,7 +31,7 @@ use crate::ui::length::DocUnit; use super::FontPickerSource; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The words of the style options editor, English by default: the three short alignment names its rows show. The diff --git a/crates/text/src/ui/columns.rs b/crates/text/src/ui/columns.rs index 9e20f79a7..e58110f6e 100644 --- a/crates/text/src/ui/columns.rs +++ b/crates/text/src/ui/columns.rs @@ -24,7 +24,7 @@ use egui::{Pos2, Rect, Ui, Vec2, pos2, vec2}; use std::cell::Cell; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The most columns PowerPoint takes; the /// dialog's limit without [`word`](TextColumnsDialog::word) and the default for a host that diff --git a/crates/text/src/ui/editor.rs b/crates/text/src/ui/editor.rs index 2a69077ed..fad53f083 100644 --- a/crates/text/src/ui/editor.rs +++ b/crates/text/src/ui/editor.rs @@ -24,7 +24,7 @@ mod commands; mod edits; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::ops::Range; diff --git a/crates/text/src/ui/find.rs b/crates/text/src/ui/find.rs index b952d3ecb..03145b451 100644 --- a/crates/text/src/ui/find.rs +++ b/crates/text/src/ui/find.rs @@ -4,10 +4,10 @@ //! dialog stack. Both search with [`crate::find`]; the document's text and the replacing are the app's. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; -mod bar; -mod dialog; +pub(crate) mod bar; +pub(crate) mod dialog; pub use bar::{FindBar, FindBarOutput, FindBarState, FindStep}; pub use dialog::{FindReplaceDialog, FindRequest, FindTab}; diff --git a/crates/text/src/ui/hyperlink.rs b/crates/text/src/ui/hyperlink.rs index 05b840783..f1ad14c71 100644 --- a/crates/text/src/ui/hyperlink.rs +++ b/crates/text/src/ui/hyperlink.rs @@ -20,7 +20,7 @@ use craft_ui::text::TextField; use egui::{Context, Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The dialog's words, English by default. diff --git a/crates/text/src/ui/notes.rs b/crates/text/src/ui/notes.rs index 34584de01..ec81cc79b 100644 --- a/crates/text/src/ui/notes.rs +++ b/crates/text/src/ui/notes.rs @@ -6,7 +6,7 @@ //! The notes are the app's; [`NotesText`] is the shape the editor reads and writes. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod text; diff --git a/crates/text/src/ui/path_text.rs b/crates/text/src/ui/path_text.rs index 06c5f252b..78debe5b0 100644 --- a/crates/text/src/ui/path_text.rs +++ b/crates/text/src/ui/path_text.rs @@ -1,7 +1,7 @@ //! `PathTextMarkers`: the start, end and overflow marks of text laid on a path, a canvas control. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::kurbo::{Point, Vec2 as PathVec}; use craft_behavior::{ diff --git a/crates/text/src/ui/ruler.rs b/crates/text/src/ui/ruler.rs index d67e4178b..30450451d 100644 --- a/crates/text/src/ui/ruler.rs +++ b/crates/text/src/ui/ruler.rs @@ -29,7 +29,7 @@ mod items; mod paint; mod run; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use geometry::{Geometry, Shapes}; use items::{COLUMN, Item, SELECTOR, STRIP}; diff --git a/crates/text/src/ui/spelling.rs b/crates/text/src/ui/spelling.rs index 8fdbb163e..183d764f0 100644 --- a/crates/text/src/ui/spelling.rs +++ b/crates/text/src/ui/spelling.rs @@ -42,7 +42,7 @@ use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The dialog's words, English by default. diff --git a/crates/text/src/ui/style_panel.rs b/crates/text/src/ui/style_panel.rs index 8cbd44b44..d1372b934 100644 --- a/crates/text/src/ui/style_panel.rs +++ b/crates/text/src/ui/style_panel.rs @@ -20,7 +20,7 @@ use std::cell::Cell; mod picker; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use picker::{NamedStyleRow, StylePreview, style_rows}; diff --git a/crates/text/src/ui/tabs_dialog.rs b/crates/text/src/ui/tabs_dialog.rs index 315364933..1f4d597db 100644 --- a/crates/text/src/ui/tabs_dialog.rs +++ b/crates/text/src/ui/tabs_dialog.rs @@ -31,7 +31,7 @@ use std::borrow::Cow; use std::cell::RefCell; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; const POSITION: ColumnKey = ColumnKey::new("position"); const ALIGNMENT: ColumnKey = ColumnKey::new("alignment"); diff --git a/crates/text/src/ui/type_bar.rs b/crates/text/src/ui/type_bar.rs index b53637718..b5acaf4c0 100644 --- a/crates/text/src/ui/type_bar.rs +++ b/crates/text/src/ui/type_bar.rs @@ -30,7 +30,7 @@ use crate::ui::type_options::{TextAntiAlias, TextOrientation, TypeOptionWords}; use crate::ui::character::FontPickerSource; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The type bar's tooltips, English by default (PhotoCraft's). Family, alignment and direction names are diff --git a/crates/text/tests/it/main.rs b/crates/text/tests/it/main.rs index 7145e43f1..9c3276bb2 100644 --- a/crates/text/tests/it/main.rs +++ b/crates/text/tests/it/main.rs @@ -2,11 +2,11 @@ // Unwrapping, expecting and panicking on failure is fine in tests, unlike in shipped code. #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] -mod editor; -mod notes; -mod path_text; +pub(crate) mod editor; +pub(crate) mod notes; +pub(crate) mod path_text; -mod ruler; -mod style_options; -mod style_panel; -mod tabs; +pub(crate) mod ruler; +pub(crate) mod style_options; +pub(crate) mod style_panel; +pub(crate) mod tabs; diff --git a/crates/theme-editor/src/lib.rs b/crates/theme-editor/src/lib.rs index ff5bd4e04..2c33c17c9 100644 --- a/crates/theme-editor/src/lib.rs +++ b/crates/theme-editor/src/lib.rs @@ -4,14 +4,14 @@ #![warn(missing_docs)] -mod browser; +pub(crate) mod browser; mod chip; -mod detail; -mod layer; -mod problems; +pub(crate) mod detail; +pub(crate) mod layer; +pub(crate) mod problems; mod rows; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod subject; mod words; @@ -26,11 +26,12 @@ pub use words::summary; /// The stories this crate registers for the integration binary. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/theme-store/src/client.rs b/crates/theme-store/src/client.rs index 72cea2c6d..263f4cc7d 100644 --- a/crates/theme-store/src/client.rs +++ b/crates/theme-store/src/client.rs @@ -334,7 +334,7 @@ impl SuiteClient { } #[cfg(test)] -mod tests; +pub(crate) mod tests; /// The suite as a reading page sees it: [`SuiteClient::shown`] and the latest snapshot, as of [`SuiteClient::view`]. #[derive(Clone)] diff --git a/crates/theme-store/src/lib.rs b/crates/theme-store/src/lib.rs index ce039617d..33f491219 100644 --- a/crates/theme-store/src/lib.rs +++ b/crates/theme-store/src/lib.rs @@ -37,17 +37,17 @@ #![warn(missing_docs)] mod backend; -mod client; +pub(crate) mod client; mod copy; mod dir; #[cfg(not(target_arch = "wasm32"))] mod disk; -mod selection; +pub(crate) mod selection; mod store; pub mod testing; #[cfg(feature = "ui")] pub mod ui; -mod watch; +pub(crate) mod watch; pub use backend::{FileStamp, LibraryFile}; pub use client::{SuiteClient, SuiteView}; @@ -61,18 +61,18 @@ pub use store::{Imported, LOCK_TIMEOUT, Library, ParseCounts, Problem, Saved, St pub use watch::{Op, OpOutput, RESULTS_KEPT, STAT_INTERVAL, Snapshot, SuiteWatch, VERIFY_INTERVAL}; #[cfg(test)] -mod tests; +pub(crate) mod tests; #[cfg(test)] extern crate self as craft_theme_store; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] #[path = "../tests/two_processes.rs"] -mod two_processes; +pub(crate) mod two_processes; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::ui::register])); } diff --git a/crates/theme-store/src/selection.rs b/crates/theme-store/src/selection.rs index 6add0ca2f..04ee17dad 100644 --- a/crates/theme-store/src/selection.rs +++ b/crates/theme-store/src/selection.rs @@ -384,7 +384,7 @@ impl fmt::Display for SelectionError { impl std::error::Error for SelectionError {} #[cfg(test)] -mod tests { +pub(crate) mod tests { use craft_ui::testing::trial; use serde_json::json; diff --git a/crates/theme-store/src/ui/mod.rs b/crates/theme-store/src/ui/mod.rs index b2b89756a..6c9737701 100644 --- a/crates/theme-store/src/ui/mod.rs +++ b/crates/theme-store/src/ui/mod.rs @@ -1,13 +1,12 @@ //! The Preferences appearance page over the suite selection: [`AppearancePage`] and its [`ThemeChip`]s. -mod chip; -mod page; +pub(crate) mod chip; +pub(crate) mod page; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; -#[cfg(feature = "screen-testing")] #[cfg(feature = "suite")] -craft_ui::testing_registered!(); +craft_ui::registry!(); pub use chip::{ThemeChip, ThemeChipOutput, ThemeChipStyle}; pub use page::{AppearancePage, AppearancePageOutput, AppearanceWords}; diff --git a/crates/theme-store/src/watch.rs b/crates/theme-store/src/watch.rs index 1bed2bb8e..64c2184bc 100644 --- a/crates/theme-store/src/watch.rs +++ b/crates/theme-store/src/watch.rs @@ -915,4 +915,4 @@ impl Engine { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/timeline/src/ale.rs b/crates/timeline/src/ale.rs index eeaeb2e25..3024353e5 100644 --- a/crates/timeline/src/ale.rs +++ b/crates/timeline/src/ale.rs @@ -183,7 +183,7 @@ pub fn row_range(doc: &AleDoc, row: usize) -> Option<(Tick, Tick)> { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use crate::timecode::format_timecode_frames; use craft_ui::testing::trial; diff --git a/crates/timeline/src/build.rs b/crates/timeline/src/build.rs index 306c95cef..d1ef56133 100644 --- a/crates/timeline/src/build.rs +++ b/crates/timeline/src/build.rs @@ -429,7 +429,7 @@ pub fn gain_to_db(g: f64) -> f64 { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use crate::fx::Standard; use crate::time::TimeRange; diff --git a/crates/timeline/src/edl.rs b/crates/timeline/src/edl.rs index d4c5a2cb1..82681a0d9 100644 --- a/crates/timeline/src/edl.rs +++ b/crates/timeline/src/edl.rs @@ -419,7 +419,7 @@ pub fn write(header: &OutHeader, events: &[OutEvent]) -> String { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; @@ -595,7 +595,7 @@ M2 A001 -012.0 00;00;00;00\n\ } #[cfg(test)] -mod report_limit_tests { +pub(crate) mod report_limit_tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/timeline/src/fcpxml.rs b/crates/timeline/src/fcpxml.rs index 83bb63597..ac61f0c16 100644 --- a/crates/timeline/src/fcpxml.rs +++ b/crates/timeline/src/fcpxml.rs @@ -1441,7 +1441,7 @@ fn marker_xml(m: &Marker, local: Tick, rate: FrameRate) -> String { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/timeline/src/interchange.rs b/crates/timeline/src/interchange.rs index 25cff8e29..745f93732 100644 --- a/crates/timeline/src/interchange.rs +++ b/crates/timeline/src/interchange.rs @@ -1098,7 +1098,7 @@ pub fn decode_text(bytes: &[u8]) -> String { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/timeline/src/lib.rs b/crates/timeline/src/lib.rs index 5f15caa64..679c94ea0 100644 --- a/crates/timeline/src/lib.rs +++ b/crates/timeline/src/lib.rs @@ -50,7 +50,7 @@ pub mod report; pub mod time; pub mod timecode; #[cfg(feature = "xml")] -mod xml; +pub(crate) mod xml; #[cfg(feature = "ui")] pub mod ui; @@ -69,34 +69,35 @@ pub use time::{TICKS_PER_SECOND, Tick, TimeRange, TimeView}; pub use timecode::{TimeDisplay, TimeFormat, TimecodeError, format_time, parse_frames, parse_time}; #[cfg(test)] -mod cache_tests; +pub(crate) mod cache_tests; #[cfg(test)] -mod clips_tests; +pub(crate) mod clips_tests; #[cfg(test)] -mod clock_tests; +pub(crate) mod clock_tests; #[cfg(test)] -mod frames_tests; +pub(crate) mod frames_tests; #[cfg(test)] -mod preflight_tests; +pub(crate) mod preflight_tests; #[cfg(test)] -mod time_tests; +pub(crate) mod time_tests; #[cfg(test)] -mod timecode_tests; +pub(crate) mod timecode_tests; /// The stories and trials this crate registers. #[cfg(feature = "screen-testing")] pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } #[cfg(all(test, feature = "screen-testing"))] extern crate self as craft_timeline; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/timeline/src/otio.rs b/crates/timeline/src/otio.rs index 544071dd2..849377d46 100644 --- a/crates/timeline/src/otio.rs +++ b/crates/timeline/src/otio.rs @@ -1242,7 +1242,7 @@ impl Imp<'_, '_, '_> { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/timeline/src/path.rs b/crates/timeline/src/path.rs index 5b6a268fb..ec9de541d 100644 --- a/crates/timeline/src/path.rs +++ b/crates/timeline/src/path.rs @@ -224,7 +224,7 @@ pub fn extension(path: &str) -> String { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/timeline/src/rate.rs b/crates/timeline/src/rate.rs index 5a66e8db6..6cffa793a 100644 --- a/crates/timeline/src/rate.rs +++ b/crates/timeline/src/rate.rs @@ -63,7 +63,7 @@ pub fn rate_from_f64(r: f64) -> FrameRate { // --------------------------------------------------------------------------------------------- #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/timeline/src/report.rs b/crates/timeline/src/report.rs index 7ef375170..1c815e1a5 100644 --- a/crates/timeline/src/report.rs +++ b/crates/timeline/src/report.rs @@ -96,7 +96,7 @@ impl std::fmt::Display for Report { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/timeline/src/ui/graph.rs b/crates/timeline/src/ui/graph.rs index 1ab5d846c..cdf5450c2 100644 --- a/crates/timeline/src/ui/graph.rs +++ b/crates/timeline/src/ui/graph.rs @@ -2,7 +2,7 @@ //! plot and parts for the keys, the handles and the bottom bar. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::kurbo; use craft_behavior::{ diff --git a/crates/timeline/src/ui/keyframes.rs b/crates/timeline/src/ui/keyframes.rs index a5da02a59..4442ae4d3 100644 --- a/crates/timeline/src/ui/keyframes.rs +++ b/crates/timeline/src/ui/keyframes.rs @@ -1,7 +1,7 @@ //! Keyframe lanes, the keyframe navigator and the animation toggle (N1.04). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/timeline/src/ui/markers.rs b/crates/timeline/src/ui/markers.rs index bad737ea8..0b6592cca 100644 --- a/crates/timeline/src/ui/markers.rs +++ b/crates/timeline/src/ui/markers.rs @@ -1,8 +1,8 @@ //! Markers on a ruler or a clip bar, and the Marker dialog (N1.12). -mod dialog; +pub(crate) mod dialog; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use dialog::{MarkerDialog, MarkerDialogAction, MarkerDialogResult, MarkerDraft}; diff --git a/crates/timeline/src/ui/overview.rs b/crates/timeline/src/ui/overview.rs index 1a40d565f..deb082072 100644 --- a/crates/timeline/src/ui/overview.rs +++ b/crates/timeline/src/ui/overview.rs @@ -1,7 +1,7 @@ //! The whole timeline in miniature (N1.13). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{Axis, Metrics, PointerButton, PressPhase, Sense}; use craft_ui::contract::{ diff --git a/crates/timeline/src/ui/panel.rs b/crates/timeline/src/ui/panel.rs index 059da322e..bb0257096 100644 --- a/crates/timeline/src/ui/panel.rs +++ b/crates/timeline/src/ui/panel.rs @@ -873,7 +873,7 @@ pub struct TopStripStyle { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The model of the pattern's registration probe: no tracks. struct EmptySequence(crate::time::TimeView); diff --git a/crates/timeline/src/ui/preview.rs b/crates/timeline/src/ui/preview.rs index 42029e1b7..9ebf0c3ed 100644 --- a/crates/timeline/src/ui/preview.rs +++ b/crates/timeline/src/ui/preview.rs @@ -1,7 +1,7 @@ //! A decoded frame fitted in a panel, with a status line. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{Axis, Metrics, Sense}; use craft_theme::Stateful; diff --git a/crates/timeline/src/ui/render_queue.rs b/crates/timeline/src/ui/render_queue.rs index 0e67d99f3..3d7a9c519 100644 --- a/crates/timeline/src/ui/render_queue.rs +++ b/crates/timeline/src/ui/render_queue.rs @@ -1,7 +1,7 @@ //! The render (export) queue list. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::borrow::Cow; use std::cell::RefCell; diff --git a/crates/timeline/src/ui/ruler.rs b/crates/timeline/src/ui/ruler.rs index 0fc261e49..132528b7b 100644 --- a/crates/timeline/src/ui/ruler.rs +++ b/crates/timeline/src/ui/ruler.rs @@ -2,7 +2,7 @@ //! `TimelineView` around it. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{Axis, CursorIcon, HitLevel, HitPriority, Metrics, NavMove, PartKey, PointerButton, PressPhase, RulerUnits, Sense, Ticks}; use craft_ui::canvas::{Rulers, StepLadder, TickRule}; diff --git a/crates/timeline/src/ui/stack.rs b/crates/timeline/src/ui/stack.rs index 6a466738a..8211a767f 100644 --- a/crates/timeline/src/ui/stack.rs +++ b/crates/timeline/src/ui/stack.rs @@ -818,4 +818,4 @@ pub(crate) fn set_event(before: T, after: T, label: &str) -> EditEvent { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/timeline/src/ui/timecode.rs b/crates/timeline/src/ui/timecode.rs index 18b2dfe55..18e914e9a 100644 --- a/crates/timeline/src/ui/timecode.rs +++ b/crates/timeline/src/ui/timecode.rs @@ -1,8 +1,8 @@ //! The timecode field, its codec and the Timecode panel. -mod readout; +pub(crate) mod readout; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::nav::LARGE_STEPS; use craft_behavior::{Caret, Codec, IconId, NavMove, NotAValue, PartKey, Sense, ValueDrag}; diff --git a/crates/timeline/src/ui/transport.rs b/crates/timeline/src/ui/transport.rs index 3021732a2..0e7056311 100644 --- a/crates/timeline/src/ui/transport.rs +++ b/crates/timeline/src/ui/transport.rs @@ -1,7 +1,7 @@ //! A monitor's transport bar and the compact media controls. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use craft_behavior::{EditEvents, IconId}; use craft_ui::bars::{Bar, BarKind}; diff --git a/crates/timeline/src/xml.rs b/crates/timeline/src/xml.rs index da76c396b..900f6aa9a 100644 --- a/crates/timeline/src/xml.rs +++ b/crates/timeline/src/xml.rs @@ -145,7 +145,7 @@ impl XmlWriter { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/timeline/tests/it/main.rs b/crates/timeline/tests/it/main.rs index deca537c0..4f6c90176 100644 --- a/crates/timeline/tests/it/main.rs +++ b/crates/timeline/tests/it/main.rs @@ -2,16 +2,16 @@ //! the `xml` and `otio` features the interchange round trips. #[cfg(all(feature = "xml", feature = "otio"))] -mod fcp7; +pub(crate) mod fcp7; #[cfg(all(feature = "xml", feature = "otio"))] -mod fcpxml; -mod features; -mod lanes; +pub(crate) mod fcpxml; +pub(crate) mod features; +pub(crate) mod lanes; #[cfg(all(feature = "xml", feature = "otio"))] -mod otio; -mod panel; -mod ruler; +pub(crate) mod otio; +pub(crate) mod panel; +pub(crate) mod ruler; #[cfg(all(feature = "xml", feature = "otio"))] mod support; -mod timecode; -mod transport; +pub(crate) mod timecode; +pub(crate) mod transport; diff --git a/crates/ui-canvas/Cargo.toml b/crates/ui-canvas/Cargo.toml index 4353a3d3d..b111ff8b8 100644 --- a/crates/ui-canvas/Cargo.toml +++ b/crates/ui-canvas/Cargo.toml @@ -35,7 +35,7 @@ serde_json = { workspace = true } craft-ui-canvas = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-keymap = { workspace = true, features = ["egui"] } -craft-ui-test-kit = { workspace = true } +craft-ui-test-kit = { workspace = true, features = ["suite"] } egui = { workspace = true } [[test]] diff --git a/crates/ui-canvas/src/canvas/crop/mod.rs b/crates/ui-canvas/src/canvas/crop/mod.rs index 0177699e7..709dfe651 100644 --- a/crates/ui-canvas/src/canvas/crop/mod.rs +++ b/crates/ui-canvas/src/canvas/crop/mod.rs @@ -6,7 +6,7 @@ mod gesture; mod paint; mod shield; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::words::CanvasWords; use super::{CanvasSpace, NUDGE, NUDGE_FAR, canvas_snap, canvas_space, context_click, readout}; diff --git a/crates/ui-canvas/src/canvas/full_window.rs b/crates/ui-canvas/src/canvas/full_window.rs index ca4ec5727..8e3b79625 100644 --- a/crates/ui-canvas/src/canvas/full_window.rs +++ b/crates/ui-canvas/src/canvas/full_window.rs @@ -22,9 +22,9 @@ pub use hosted::{FullWindowWorkspace, HostedWorkspace, WorkspaceCx, WorkspacePas mod hosted; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; #[cfg(feature = "suite")] -mod trials; +pub(crate) mod trials; /// The style of a full-window dialog: the surface comes from the container. #[derive(Clone, Debug, Default, PartialEq, ComponentStyle)] diff --git a/crates/ui-canvas/src/canvas/full_window/trials.rs b/crates/ui-canvas/src/canvas/full_window/trials.rs index 6fed71d36..fd807eb57 100644 --- a/crates/ui-canvas/src/canvas/full_window/trials.rs +++ b/crates/ui-canvas/src/canvas/full_window/trials.rs @@ -36,7 +36,7 @@ fn a_footer_letter_activates_its_button_in_a_full_window_dialog() { } /// The sample workspace on a dialog host, run once per frame. -mod hosting { +pub(crate) mod hosting { use super::super::HostedWorkspace; use super::super::stories::{BrushChanged, BrushWorkspace, Flat}; use crate::contract::Role; diff --git a/crates/ui-canvas/src/canvas/full_window_parts.rs b/crates/ui-canvas/src/canvas/full_window_parts.rs index de4ecfa5a..df7aaf354 100644 --- a/crates/ui-canvas/src/canvas/full_window_parts.rs +++ b/crates/ui-canvas/src/canvas/full_window_parts.rs @@ -1,14 +1,14 @@ //! The parts of a full-window dialog's body: the side column, the zoom bar, the title text, the status line and the //! canvas region, with the view they share. `FullWindowDialog` is the shell they fill. -mod canvas; -mod side; -mod status; +pub(crate) mod canvas; +pub(crate) mod side; +pub(crate) mod status; #[cfg(feature = "suite")] -mod stories; -mod title; +pub(crate) mod stories; +pub(crate) mod title; mod view; -mod zoom_bar; +pub(crate) mod zoom_bar; pub use canvas::{FullWindowCanvas, FullWindowCanvasOutput, RasterOverlay}; pub use side::{FullWindowSide, FullWindowSideOutput, FullWindowSideStyle, SideFooter}; diff --git a/crates/ui-canvas/src/canvas/mod.rs b/crates/ui-canvas/src/canvas/mod.rs index fd14825bc..ba2bd30b8 100644 --- a/crates/ui-canvas/src/canvas/mod.rs +++ b/crates/ui-canvas/src/canvas/mod.rs @@ -7,7 +7,7 @@ //! commands routed to it ([`ViewCommands`]), keeps the document in view with Overscroll off, eases a zoom under //! Animated Zoom, publishes the view it shows as a [`CanvasSpace`] to its body, and reports the view the app copies. -mod crop; +pub(crate) mod crop; mod frame_step; // The full-window dialog family; `dialog` re-exports it. pub(crate) mod full_window; @@ -16,7 +16,7 @@ mod march; mod readout; mod space; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; #[cfg(feature = "testing")] pub(crate) mod testing; mod words; @@ -42,14 +42,14 @@ pub use tool_host::{ContextRequest, StandInKey, ToolHost, ToolHostResponse, Tool mod raster_source; pub use raster_source::{PixelRect, RasterSource}; -mod pasteboard; -mod split; +pub(crate) mod pasteboard; +pub(crate) mod split; pub use pasteboard::{PageBorder, PageFrame, Pasteboard, PasteboardColor, PasteboardOutput, PasteboardStyle}; pub use split::{SplitAt, SplitLayout, SplitPane, SplitStyle, SplitViews, SplitViewsOutput}; pub use words::SplitWords; mod app_paint; -mod raster; +pub(crate) mod raster; pub use app_paint::AppPaint; pub use raster::{DetailPlan, Extent, RasterDisplay, RasterDisplayOutput, RasterStyle, snap_to_texels}; @@ -65,8 +65,8 @@ pub use space::{BackgroundPress, BodyKeys, CanvasRulers, context_click}; // canvas-navigate-a mod momentary; -mod navigate; -mod rotate; +pub(crate) mod navigate; +pub(crate) mod rotate; mod tools; mod zoom_motion; @@ -78,15 +78,15 @@ pub use rotate::{RotateView, RotateViewOutput, RotateViewStyle, ViewTurn}; pub use tools::{HandTool, LayerBounds, RotateViewTool, ViewCommands, ViewRequest, ViewTarget, ZoomTool}; pub use zoom_motion::{HoldZoom, ZoomAnimation, ZoomDrag, easing_view}; -mod rulers; -mod scrollbars; +pub(crate) mod rulers; +pub(crate) mod scrollbars; pub use rulers::{ INCH_EIGHTHS, INCH_SIXTEENTHS, LABEL_STEP_MIN, RulerCommands, RulerMargins, RulerPart, RulerTick, Rulers, RulersOutput, StepLadder, TickRule, }; pub use scrollbars::{CanvasScrollbars, CanvasScrollbarsOutput}; // canvas-navigator-a -mod navigator; +pub(crate) mod navigator; pub use navigator::{ Navigator, NavigatorCommands, NavigatorOutput, NavigatorPreview, NavigatorZoomRow, NavigatorZoomRowOutput, preview_rect, proxy_quad, view_center_for, zoom_to_document_rect, diff --git a/crates/ui-canvas/src/canvas/navigate/mod.rs b/crates/ui-canvas/src/canvas/navigate/mod.rs index def611c7f..0f0f61e98 100644 --- a/crates/ui-canvas/src/canvas/navigate/mod.rs +++ b/crates/ui-canvas/src/canvas/navigate/mod.rs @@ -6,11 +6,11 @@ //! `craft_behavior::canvas::zoom` and clamp to the [`ZoomLadder`](craft_behavior::ZoomLadder). With Overscroll off //! the caller clamps the result with the canvas's scroll limits. -mod bar; +pub(crate) mod bar; mod keys; mod options; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod wheel; pub use bar::{NavigateBar, NavigateBarOutput}; diff --git a/crates/ui-canvas/src/canvas/navigator/mod.rs b/crates/ui-canvas/src/canvas/navigator/mod.rs index 356c4aea5..db3dbd034 100644 --- a/crates/ui-canvas/src/canvas/navigator/mod.rs +++ b/crates/ui-canvas/src/canvas/navigator/mod.rs @@ -10,11 +10,11 @@ //! | The panel menu | [`NavigatorCommands`] | mod menu; -mod preview; +pub(crate) mod preview; mod proxy; #[cfg(feature = "suite")] -mod stories; -mod zoom_row; +pub(crate) mod stories; +pub(crate) mod zoom_row; pub use menu::NavigatorCommands; pub use preview::{Navigator, NavigatorOutput, NavigatorPreview, NavigatorStyle}; diff --git a/crates/ui-canvas/src/canvas/navigator_panel.rs b/crates/ui-canvas/src/canvas/navigator_panel.rs index 24ec2e0aa..0d194f056 100644 --- a/crates/ui-canvas/src/canvas/navigator_panel.rs +++ b/crates/ui-canvas/src/canvas/navigator_panel.rs @@ -9,7 +9,7 @@ use craft_behavior::{CanvasView, EditEvents}; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// What the Navigator panel reports. #[derive(Debug)] diff --git a/crates/ui-canvas/src/canvas/pasteboard/mod.rs b/crates/ui-canvas/src/canvas/pasteboard/mod.rs index 7426f103c..f7a62f005 100644 --- a/crates/ui-canvas/src/canvas/pasteboard/mod.rs +++ b/crates/ui-canvas/src/canvas/pasteboard/mod.rs @@ -4,7 +4,7 @@ //! name selects the artboard. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::space::canvas_space; use crate::contract::{Access, Common, Component, Cx, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Props as _, Role}; diff --git a/crates/ui-canvas/src/canvas/raster/mod.rs b/crates/ui-canvas/src/canvas/raster/mod.rs index 81b8e6e57..cc95aa33f 100644 --- a/crates/ui-canvas/src/canvas/raster/mod.rs +++ b/crates/ui-canvas/src/canvas/raster/mod.rs @@ -16,7 +16,7 @@ mod detail; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use detail::{DetailPlan, snap_to_texels}; diff --git a/crates/ui-canvas/src/canvas/rulers/mod.rs b/crates/ui-canvas/src/canvas/rulers/mod.rs index 0e02bdf01..db205d857 100644 --- a/crates/ui-canvas/src/canvas/rulers/mod.rs +++ b/crates/ui-canvas/src/canvas/rulers/mod.rs @@ -3,7 +3,7 @@ //! reports a guide being placed; a drag from the corner moves the zero point. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod ticks; pub use ticks::{INCH_EIGHTHS, INCH_SIXTEENTHS, LABEL_STEP_MIN, RulerTick, StepLadder, TickRule}; diff --git a/crates/ui-canvas/src/canvas/scrollbars/mod.rs b/crates/ui-canvas/src/canvas/scrollbars/mod.rs index 677e6c0f6..972e8650b 100644 --- a/crates/ui-canvas/src/canvas/scrollbars/mod.rs +++ b/crates/ui-canvas/src/canvas/scrollbars/mod.rs @@ -10,7 +10,7 @@ //! document. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::words::CanvasWords; use crate::contract::{ diff --git a/crates/ui-canvas/src/canvas/split/mod.rs b/crates/ui-canvas/src/canvas/split/mod.rs index 739496afa..dc1994baa 100644 --- a/crates/ui-canvas/src/canvas/split/mod.rs +++ b/crates/ui-canvas/src/canvas/split/mod.rs @@ -8,7 +8,7 @@ //! ([`SplitViews::follow`]). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::words::SplitWords; use crate::contract::{ diff --git a/crates/ui-canvas/src/canvas_controls/brush/mod.rs b/crates/ui-canvas/src/canvas_controls/brush/mod.rs index d030aab84..a71511bc2 100644 --- a/crates/ui-canvas/src/canvas_controls/brush/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/brush/mod.rs @@ -22,14 +22,14 @@ //! [`BrushCursor::tip_cell`] at the canvas rect in the canvas body, and the tool hands //! [`BrushResize::readout_rows`] to `ToolContext::readout`. -mod cursor; -mod falloff; +pub(crate) mod cursor; +pub(crate) mod falloff; mod resize; -mod source_marker; +pub(crate) mod source_marker; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod tip; -mod trail; +pub(crate) mod trail; pub use cursor::{BrushCursor, BrushCursorOptions, PaintingCursor, TipCell, TipCellStyle}; pub use falloff::{FalloffPreview, FalloffPreviewStyle, TipFalloff}; diff --git a/crates/ui-canvas/src/canvas_controls/grid/mod.rs b/crates/ui-canvas/src/canvas_controls/grid/mod.rs index 885f861b8..37ed6db16 100644 --- a/crates/ui-canvas/src/canvas_controls/grid/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/grid/mod.rs @@ -3,7 +3,7 @@ //! carries the state. Show it before guides and frames. #[cfg(feature = "suite")] -pub(super) mod stories; +pub(crate) mod stories; use crate::canvas::{CanvasSpace, GuideLine, canvas_space}; use crate::contract::{Access, Common, Component, Cx, MeasureCx, PaintUi, Props as _, Role}; diff --git a/crates/ui-canvas/src/canvas_controls/guides/mod.rs b/crates/ui-canvas/src/canvas_controls/guides/mod.rs index e6ab7a77d..25ee98221 100644 --- a/crates/ui-canvas/src/canvas_controls/guides/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/guides/mod.rs @@ -4,7 +4,7 @@ mod place; pub mod reading; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use reading::GuideReading; diff --git a/crates/ui-canvas/src/canvas_controls/marquee/mod.rs b/crates/ui-canvas/src/canvas_controls/marquee/mod.rs index b96d07fb1..82d680ccd 100644 --- a/crates/ui-canvas/src/canvas_controls/marquee/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/marquee/mod.rs @@ -3,7 +3,7 @@ //! It takes no pointer and no key: the press, the drag and the modifier rules are the canvas tool's. #[cfg(feature = "suite")] -pub(super) mod stories; +pub(crate) mod stories; use super::words::CanvasControlWords; use crate::canvas::{MARCH_SECONDS, MARCH_TICK, canvas_space, march_shift}; diff --git a/crates/ui-canvas/src/canvas_controls/mod.rs b/crates/ui-canvas/src/canvas_controls/mod.rs index 0d0145a52..6b2be4f1e 100644 --- a/crates/ui-canvas/src/canvas_controls/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/mod.rs @@ -4,8 +4,8 @@ mod words; // Guides and smart guides. -mod guides; -mod smart_guides; +pub(crate) mod guides; +pub(crate) mod smart_guides; pub(crate) use smart_guides::paint_lines; pub use guides::{GuideCommands, GuideStyle, Guides, GuidesOutput, reading}; @@ -14,12 +14,12 @@ pub use words::CanvasControlWords; // Selection outlines, grids and previews (canvas-controls-b). mod bands; -mod grid; -mod line_preview; -mod marquee; -mod outline; -mod pixel_grid; -mod task_bar; +pub(crate) mod grid; +pub(crate) mod line_preview; +pub(crate) mod marquee; +pub(crate) mod outline; +pub(crate) mod pixel_grid; +pub(crate) mod task_bar; pub use bands::{range_bands, rect_around}; pub use grid::{CanvasGrid, GridAxis, GridLine, GridLines, GridStyle, MAX_LINES}; diff --git a/crates/ui-canvas/src/canvas_controls/outline/mod.rs b/crates/ui-canvas/src/canvas_controls/outline/mod.rs index e9f78090c..a0a71e84c 100644 --- a/crates/ui-canvas/src/canvas_controls/outline/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/outline/mod.rs @@ -4,7 +4,7 @@ mod hover; #[cfg(feature = "suite")] -pub(super) mod stories; +pub(crate) mod stories; use crate::canvas::canvas_space; use crate::contract::{Access, Common, Component, Cx, MeasureCx, PaintUi, Props as _, Role}; diff --git a/crates/ui-canvas/src/canvas_controls/pixel_grid/mod.rs b/crates/ui-canvas/src/canvas_controls/pixel_grid/mod.rs index 1cbc42d83..22e0290d2 100644 --- a/crates/ui-canvas/src/canvas_controls/pixel_grid/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/pixel_grid/mod.rs @@ -8,7 +8,7 @@ //! within the padding costs nothing and the work is bounded by the viewport. #[cfg(feature = "suite")] -pub(super) mod stories; +pub(crate) mod stories; use crate::canvas::{PixelRect, RasterSource, canvas_space}; use crate::contract::{Access, Common, Component, Cx, MeasureCx, PaintUi, Props as _, Role}; diff --git a/crates/ui-canvas/src/canvas_controls/smart_guides/mod.rs b/crates/ui-canvas/src/canvas_controls/smart_guides/mod.rs index 2ba6bd6e0..9f8011346 100644 --- a/crates/ui-canvas/src/canvas_controls/smart_guides/mod.rs +++ b/crates/ui-canvas/src/canvas_controls/smart_guides/mod.rs @@ -2,7 +2,7 @@ //! (20.6). It has no parts, so a press never lands on it. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use crate::canvas::{CanvasRulers, canvas_space}; use crate::contract::{Common, Component, Cx, MeasureCx, PaintUi, Role}; diff --git a/crates/ui-canvas/src/canvas_controls/task_bar.rs b/crates/ui-canvas/src/canvas_controls/task_bar.rs index ad8c0b5c6..d32c6f144 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar.rs @@ -1,7 +1,7 @@ //! `TaskBar`: the contextual task bar over a canvas, hung below its anchor until the user moves it. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::CanvasControlWords; use crate::bars::{Bar, BarKind}; diff --git a/crates/ui-canvas/src/lib.rs b/crates/ui-canvas/src/lib.rs index 7b26db86c..faeef0e77 100644 --- a/crates/ui-canvas/src/lib.rs +++ b/crates/ui-canvas/src/lib.rs @@ -12,11 +12,11 @@ extern crate self as craft_ui; #[doc(hidden)] pub use craft_ui_panels::canvas_data; +#[cfg(feature = "testing")] +pub use craft_ui_panels::registry; #[cfg(feature = "suite")] #[doc(hidden)] pub use craft_ui_panels::story_kit; -#[cfg(feature = "testing")] -pub use craft_ui_panels::testing_registered; #[doc(hidden)] pub use craft_ui_panels::{__private, __register_command_set, __register_contract, __register_pattern}; pub use craft_ui_panels::{InstallError, InstallSpec, contract, fonts, install, layout, primitives, runtime, style, words}; @@ -52,5 +52,5 @@ pub mod testing { pub use craft_ui_panels::testing::*; #[cfg(feature = "suite")] - crate::testing_registered!(); + crate::registry!(); } diff --git a/crates/ui-canvas/tests/it/canvas/mod.rs b/crates/ui-canvas/tests/it/canvas/mod.rs index 315dbd878..a5e36c6ce 100644 --- a/crates/ui-canvas/tests/it/canvas/mod.rs +++ b/crates/ui-canvas/tests/it/canvas/mod.rs @@ -1,33 +1,33 @@ //! `Canvas` (20.6): a press away from every canvas control's parts reaches the tool. -mod crop; +pub(crate) mod crop; -mod navigate; +pub(crate) mod navigate; -mod navigator; +pub(crate) mod navigator; -mod opacity_keys; +pub(crate) mod opacity_keys; -mod press_focus; +pub(crate) mod press_focus; -mod pasteboard; +pub(crate) mod pasteboard; -mod raster; +pub(crate) mod raster; -mod rulers; +pub(crate) mod rulers; -mod scrollbars; +pub(crate) mod scrollbars; -mod snap; +pub(crate) mod snap; -mod split; +pub(crate) mod split; -mod story_canvas; +pub(crate) mod story_canvas; -mod tool; +pub(crate) mod tool; -mod tool_keys; +pub(crate) mod tool_keys; -mod tool_story; +pub(crate) mod tool_story; -mod tools; +pub(crate) mod tools; diff --git a/crates/ui-canvas/tests/it/canvas_controls/mod.rs b/crates/ui-canvas/tests/it/canvas_controls/mod.rs index 37938ec64..411a1115e 100644 --- a/crates/ui-canvas/tests/it/canvas_controls/mod.rs +++ b/crates/ui-canvas/tests/it/canvas_controls/mod.rs @@ -1,13 +1,13 @@ //! The canvas controls: `Guides`, `SmartGuides`, selection outlines, grids and brush overlays on a `Canvas`. -mod brush; +pub(crate) mod brush; -mod grid; +pub(crate) mod grid; -mod guides; +pub(crate) mod guides; -mod marquee; +pub(crate) mod marquee; -mod outline; +pub(crate) mod outline; -mod task_bar; +pub(crate) mod task_bar; diff --git a/crates/ui-canvas/tests/it/contract/derives.rs b/crates/ui-canvas/tests/it/contract/derives.rs index 4c6f41ab2..acdb5fb42 100644 --- a/crates/ui-canvas/tests/it/contract/derives.rs +++ b/crates/ui-canvas/tests/it/contract/derives.rs @@ -166,7 +166,11 @@ impl CanvasTool for IdleTool { /// Every probe linked into this binary, the integration binary's own fixtures included. fn probes() -> Vec { - craft_ui::contract::registrations().into_iter().filter_map(|registration| registration.probe().copied()).collect() + craft_ui::testing::Registry::of(&[crate::register, craft_ui::testing::register]) + .registrations() + .iter() + .filter_map(|registration| registration.probe().copied()) + .collect() } fn named(name: &str) -> Vec { diff --git a/crates/ui-canvas/tests/it/contract/mod.rs b/crates/ui-canvas/tests/it/contract/mod.rs index f5437025d..6067f7da1 100644 --- a/crates/ui-canvas/tests/it/contract/mod.rs +++ b/crates/ui-canvas/tests/it/contract/mod.rs @@ -1,3 +1,3 @@ //! The component contract and the show pipeline: the steps each shape runs, and the rules the steps keep. -mod derives; +pub(crate) mod derives; diff --git a/crates/ui-canvas/tests/it/full_window_parts.rs b/crates/ui-canvas/tests/it/full_window_parts.rs index a803f723d..2de2dc5ee 100644 --- a/crates/ui-canvas/tests/it/full_window_parts.rs +++ b/crates/ui-canvas/tests/it/full_window_parts.rs @@ -39,7 +39,7 @@ fn a_zoom_command_ends_the_fit_and_fit_returns_to_it() { } /// The canvas's navigation: the wheel, the middle button and the Hand tool it falls back to. -mod canvas_navigation { +pub(crate) mod canvas_navigation { use craft_behavior::PixelSize; use craft_behavior::kurbo::Point; use craft_ui::canvas::{NavigationOptions, PixelRect, RasterSource}; @@ -130,7 +130,7 @@ mod canvas_navigation { } /// The momentary tools every full-window canvas runs. -mod momentary { +pub(crate) mod momentary { use craft_behavior::{CancelReason, PixelSize}; use craft_ui::canvas::{CanvasTool, PixelRect, RasterSource, ToolAction, ToolContext, ToolPath, ToolPointer}; use craft_ui::contract::{Bind, ShowContainer as _}; @@ -221,7 +221,7 @@ mod momentary { } /// Escape on a focused canvas inside a full-window dialog. -mod escape { +pub(crate) mod escape { use craft_behavior::{CancelReason, Intent, PixelSize}; use craft_ui::canvas::{CanvasTool, PixelRect, RasterSource, ToolAction, ToolContext, ToolKey, ToolPath, ToolPointer}; use craft_ui::contract::{Bind, ShowContainer as _}; @@ -319,7 +319,7 @@ mod escape { } /// A full-window dialog in a window of its own. -mod own_window { +pub(crate) mod own_window { use craft_ui::contract::{Bind, ShowContainer as _}; use craft_ui::dialog::{DialogResult, FullWindowDialog}; use craft_ui::runtime::overlay::CloseReason; @@ -365,7 +365,7 @@ mod own_window { } /// An overlay drawn through a frame. -mod mapped_overlay { +pub(crate) mod mapped_overlay { use craft_behavior::PixelSize; use craft_behavior::geometry::quad::Homography; use craft_behavior::kurbo::{Point, Rect}; diff --git a/crates/ui-canvas/tests/it/main.rs b/crates/ui-canvas/tests/it/main.rs index a94a0c3c1..1893ba675 100644 --- a/crates/ui-canvas/tests/it/main.rs +++ b/crates/ui-canvas/tests/it/main.rs @@ -3,15 +3,19 @@ // The test files name the library as `craft_ui`, as the crates that use it do. extern crate craft_ui_canvas as craft_ui; -mod canvas; -mod canvas_controls; -mod contract; +pub(crate) mod canvas; +pub(crate) mod canvas_controls; +pub(crate) mod contract; // full-window parts -mod full_window_parts; +pub(crate) mod full_window_parts; // end of full-window parts -use craft_ui::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run( + module_path!(), + env!("CARGO_PKG_NAME"), + &craft_ui::testing::Registry::of(&[register, craft_ui::testing::register, craft_ui_test_kit::testing::register]), + ); } diff --git a/crates/ui-contract/Cargo.toml b/crates/ui-contract/Cargo.toml index 4e364cf52..06abb8f3d 100644 --- a/crates/ui-contract/Cargo.toml +++ b/crates/ui-contract/Cargo.toml @@ -96,7 +96,7 @@ craft-host = { workspace = true } craft-i18n = { workspace = true } craft-keymap = { workspace = true, features = ["egui"] } craft-theme = { workspace = true } -craft-ui-test-kit = { workspace = true } +craft-ui-test-kit = { workspace = true, features = ["suite"] } craft-window = { workspace = true } egui = { workspace = true } # The oracle for the deflated default faces (`tests/it/fonts/on_demand.rs`). diff --git a/crates/ui-contract/src/contract/items.rs b/crates/ui-contract/src/contract/items.rs index d2ce1b11e..520bbff4c 100644 --- a/crates/ui-contract/src/contract/items.rs +++ b/crates/ui-contract/src/contract/items.rs @@ -13,7 +13,7 @@ use std::sync::Arc; mod drag; mod edge; pub(super) mod empty_text; -mod header; +pub(crate) mod header; mod marquee; mod request; diff --git a/crates/ui-contract/src/contract/label.rs b/crates/ui-contract/src/contract/label.rs index 8c583a794..b5f065803 100644 --- a/crates/ui-contract/src/contract/label.rs +++ b/crates/ui-contract/src/contract/label.rs @@ -4,7 +4,7 @@ pub use crate::runtime::access::scope::FieldLabelRole; -mod leaf; +pub(crate) mod leaf; mod place; mod props; mod step; diff --git a/crates/ui-contract/src/contract/level.rs b/crates/ui-contract/src/contract/level.rs index a16df9f30..340f0165e 100644 --- a/crates/ui-contract/src/contract/level.rs +++ b/crates/ui-contract/src/contract/level.rs @@ -213,7 +213,7 @@ fn pascal(segment: &str) -> String { #[non_exhaustive] pub struct CatalogEntry { /// The registration (the first of a generic type's instantiations). - pub registration: &'static Registration, + pub registration: Registration, /// The type's level. pub level: Level, /// The surface its stories sit on. @@ -228,7 +228,7 @@ impl CatalogEntry { /// How a viewer lays out the type's story group named `group` (`Story::group_name`): the layout `STORY_LAYOUTS` /// declares for it, else stacked. pub fn story_layout(&self, group: &str) -> StoryLayout { - let (target, short) = table_key(self.registration); + let (target, short) = table_key(&self.registration); STORY_LAYOUTS.iter().find(|row| row.0 == target && row.1 == short && row.2 == group).map_or(StoryLayout::Stacked, |row| row.3) } } @@ -265,10 +265,10 @@ fn kit_module(module: &str) -> bool { /// The display name is the type's name without module path or type arguments. Two registered types that share it /// each take the last module segments of their paths in front of it (`DockButton`, then `DockGroupButton`) /// until the names differ. -pub fn catalog(registrations: &[&'static Registration]) -> Catalog { - let mut types: BTreeMap<&'static str, &'static Registration> = BTreeMap::new(); +pub fn catalog(registrations: &[&Registration]) -> Catalog { + let mut types: BTreeMap<&'static str, Registration> = BTreeMap::new(); for ®istration in registrations.iter().filter(|registration| !kit_module(parts(registration).0)) { - types.entry(base_path(parts(registration).1)).or_insert(registration); + types.entry(base_path(parts(registration).1)).or_insert(*registration); } let mut by_short: BTreeMap<&str, Vec<&'static str>> = BTreeMap::new(); for &path in types.keys() { @@ -279,13 +279,13 @@ pub fn catalog(registrations: &[&'static Registration]) -> Catalog { for &path in &paths { let registration = types[path]; let name = qualified(path, short, &paths); - match level_of(registration) { + match level_of(®istration) { Some(level) => { - let surface = surface_of(registration); - let type_name = parts(registration).1; + let surface = surface_of(®istration); + let type_name = parts(®istration).1; out.entries.push(CatalogEntry { registration, level, surface, type_name, name }); } - None => out.unleveled.push(parts(registration).1), + None => out.unleveled.push(parts(®istration).1), } } } @@ -349,18 +349,13 @@ pub fn story_title(type_name: &str, story: &str) -> String { text[..1].to_uppercase() + &text[1..] } -/// Every library registration linked into the running binary: the types of the library crates, not the fixtures of -/// an integration binary. -fn linked() -> Vec<&'static Registration> { - super::registrations().into_iter().filter(|registration| registration.crate_target() == registration.crate_name().replace('-', "_")).collect() -} - /// The rows of the surface and story layout tables whose type is not among `linked`, in every crate that has a type /// there, and the layout rows whose story group none of the type's linked stories has. The library's crates are /// linked together only above them, so the craft-ui facade's trials run it with every registration of the library. #[cfg(feature = "testing")] #[doc(hidden)] -pub fn stale_table_rows(linked: &[&'static Registration]) -> Vec { +pub fn stale_table_rows(registry: &crate::testing::Registry) -> Vec { + let linked: Vec<_> = registry.registrations().iter().collect(); let named: std::collections::HashSet<(&str, &str)> = linked.iter().map(|registration| table_key(registration)).collect(); let mut crates: std::collections::HashSet<&str> = named.iter().map(|(target, _)| *target).collect(); // The library's rows are checked whenever one of its crates is linked, whatever key its types get. @@ -374,7 +369,7 @@ pub fn stale_table_rows(linked: &[&'static Registration]) -> Vec { let keys: std::collections::HashMap<&str, (&str, &str)> = linked.iter().map(|registration| (parts(registration).1, table_key(registration))).collect(); let mut groups: std::collections::HashMap<(&str, &str), Vec> = std::collections::HashMap::new(); - for entry in crate::testing::stories() { + for entry in registry.stories() { if let Some(&key) = keys.get((entry.type_name)()) { groups.entry(key).or_default().push(entry.story.group_name(key.1)); } @@ -388,25 +383,6 @@ pub fn stale_table_rows(linked: &[&'static Registration]) -> Vec { stale } -/// Guards against a registered type that no row places (it would list under no level) and against names a -/// viewer cannot show as one identifier or that two types share (the tree would list two rows alike). -#[crate::testing::trial] -fn catalog_names_are_unique_pascal_case_and_every_type_has_a_level() { - let catalog = catalog(&linked()); - assert!(catalog.unleveled.is_empty(), "types with no level: {:?}", catalog.unleveled); - let mut seen = std::collections::HashSet::new(); - for entry in &catalog.entries { - let mut chars = entry.name.chars(); - assert!( - chars.next().is_some_and(|first| first.is_ascii_uppercase()) && chars.all(|c| c.is_ascii_alphanumeric()), - "`{}` ({}) is not a PascalCase identifier", - entry.name, - entry.type_name - ); - assert!(seen.insert((entry.level, entry.name.to_lowercase())), "`{}` is listed twice in {:?}", entry.name, entry.level); - } -} - /// Guards the story title rule: the type's words come off the front, the rest reads as a sentence. #[crate::testing::trial] fn story_titles_drop_the_type_prefix_and_use_sentence_case() { diff --git a/crates/ui-contract/src/contract/mod.rs b/crates/ui-contract/src/contract/mod.rs index 28b5bc634..86a22aca3 100644 --- a/crates/ui-contract/src/contract/mod.rs +++ b/crates/ui-contract/src/contract/mod.rs @@ -12,11 +12,11 @@ pub mod ghost; mod group; mod held; mod hosted; -mod items; -mod label; +pub(crate) mod items; +pub(crate) mod label; mod lazy; #[cfg(feature = "suite")] -mod level; +pub(crate) mod level; #[cfg(feature = "suite")] mod level_table; mod looks; @@ -95,9 +95,6 @@ pub use pages::Pages; pub use paint_ui::PaintUi; pub use props::{Common, Props, Resolved, Tooltip, TooltipAt, TooltipSpec, TooltipWhen}; #[doc(hidden)] -#[cfg(feature = "suite")] -pub use registry::registrations; -#[doc(hidden)] pub use registry::{CollectionEntry, ContainerEntry, Exemption, LeafEntry, PatternKind, PatternProbe, Probe, Registration, ShowEntry}; pub use sampler::{CanvasGesture, Sampler}; pub use settle::SettleCx; diff --git a/crates/ui-contract/src/contract/registry.rs b/crates/ui-contract/src/contract/registry.rs index 272fc37be..7d4c43ffc 100644 --- a/crates/ui-contract/src/contract/registry.rs +++ b/crates/ui-contract/src/contract/registry.rs @@ -370,21 +370,6 @@ impl Registration { } } -#[cfg(feature = "suite")] -inventory::collect!(Registration); - -/// Every registration in the running binary, by crate, module and type name. -#[doc(hidden)] -#[cfg(feature = "suite")] -pub fn registrations() -> Vec<&'static Registration> { - let mut all: Vec<_> = inventory::iter::().collect(); - all.sort_by_key(|registration| match registration { - Registration::Component(probe) => (probe.crate_name, probe.crate_target, probe.module, probe.type_name()), - Registration::Pattern(probe) => (probe.crate_name, probe.crate_target, probe.module, probe.type_name()), - }); - all -} - /// Registers the component type `$ty` of shape `$shape` (`leaf`, `container` or `collection`) with its declarations: /// `$overlay`, the `($case, $reason)` exemptions, the optional `$sample` constructor (`fn() -> $ty`, leaves only) /// and the `$purpose` line of its doc comment. @@ -420,12 +405,14 @@ macro_rules! __register_contract { macro_rules! __register_probe { ($ty:ty, $shape:ident, $overlay:expr, [$(($case:expr, $reason:expr)),*], $purpose:expr, $($with:tt)*) => { const EXEMPT: &[$crate::contract::Exemption] = &[$($crate::contract::Exemption::new($case, $reason)),*]; - $crate::__private::inventory::submit! { - $crate::contract::Registration::component( - $crate::contract::Probe::$shape::<$ty>(env!("CARGO_PKG_NAME"), env!("CARGO_CRATE_NAME"), module_path!(), $overlay, EXEMPT) - .with_purpose($purpose) - $($with)*, - ) + impl $crate::testing::Registered for $ty { + fn registration() -> $crate::contract::Registration { + $crate::contract::Registration::component( + $crate::contract::Probe::$shape::<$ty>(env!("CARGO_PKG_NAME"), env!("CARGO_CRATE_NAME"), module_path!(), $overlay, EXEMPT) + .with_purpose($purpose) + $($with)*, + ) + } } }; } @@ -440,10 +427,12 @@ macro_rules! __register_pattern { $crate::__register_pattern!($ty, $purpose, $crate::contract::PatternProbe::of); }; ($ty:ty, $purpose:expr, $($probe:tt)+) => { - $crate::__private::inventory::submit! { - $crate::contract::Registration::pattern( - $($probe)+::<$ty>(env!("CARGO_PKG_NAME"), env!("CARGO_CRATE_NAME"), module_path!(), $purpose), - ) + impl $crate::testing::Registered for $ty { + fn registration() -> $crate::contract::Registration { + $crate::contract::Registration::pattern( + $($probe)+::<$ty>(env!("CARGO_PKG_NAME"), env!("CARGO_CRATE_NAME"), module_path!(), $purpose), + ) + } } }; } diff --git a/crates/ui-contract/src/lib.rs b/crates/ui-contract/src/lib.rs index 9a6007b49..418ddd0ee 100644 --- a/crates/ui-contract/src/lib.rs +++ b/crates/ui-contract/src/lib.rs @@ -10,7 +10,7 @@ // The derives' output names the crate as `craft_ui`, here as in every other crate. extern crate self as craft_ui; -pub use craft_ui_macros::words; +pub use craft_ui_macros::{registry, words}; pub mod contract; pub mod fonts; diff --git a/crates/ui-contract/src/runtime/commands/mod.rs b/crates/ui-contract/src/runtime/commands/mod.rs index 1570c4ae1..13d4865bc 100644 --- a/crates/ui-contract/src/runtime/commands/mod.rs +++ b/crates/ui-contract/src/runtime/commands/mod.rs @@ -12,6 +12,8 @@ pub use library::ChromeCommand; pub(crate) use library::WindowShortcut; pub use library::{EditCommands, NavCommand, WindowCommand}; pub use registry::CommandDefError; +#[cfg(feature = "suite")] +pub(crate) use registry::configure_story_sets; #[doc(hidden)] pub use registry::{SetEntry, sets}; diff --git a/crates/ui-contract/src/runtime/commands/registry.rs b/crates/ui-contract/src/runtime/commands/registry.rs index 115552e22..807f661fe 100644 --- a/crates/ui-contract/src/runtime/commands/registry.rs +++ b/crates/ui-contract/src/runtime/commands/registry.rs @@ -27,8 +27,6 @@ pub struct SetEntry { pub typing: Option, /// The defaults of one platform, which replace the command's other defaults there. pub platform_defaults: fn() -> Result, CommandDefError>, - /// A story's set (`#[command(story)]`): loaded only by an install that shows stories. - pub story: bool, } impl SetEntry { @@ -42,13 +40,7 @@ impl SetEntry { typing: Option, platform_defaults: fn() -> Result, CommandDefError>, ) -> Self { - SetEntry { name, defs, no_default_on, edits, holds, typing, platform_defaults, story: false } - } - - /// The entry as a story's set. - pub const fn story(mut self) -> Self { - self.story = true; - self + SetEntry { name, defs, no_default_on, edits, holds, typing, platform_defaults } } } @@ -70,9 +62,6 @@ macro_rules! __register_command_set { ($ty:ty) => { $crate::__register_command_set!(@entry $ty, ::core::convert::identity); }; - ($ty:ty, story) => { - $crate::__register_command_set!(@entry $ty, $crate::runtime::commands::SetEntry::story); - }; (@entry $ty:ty, $mark:expr) => { const _: () = { $crate::__private::inventory::submit! { @@ -153,6 +142,30 @@ impl std::error::Error for CommandDefError {} /// The shared registries: the app's sets, and the app's sets with the stories' (`[apps, with stories]`). static LOADED: [OnceLock>; 2] = [OnceLock::new(), OnceLock::new()]; +#[cfg(feature = "suite")] +static STORY_SETS: OnceLock> = OnceLock::new(); +#[cfg(feature = "suite")] +static STORY_SETS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); + +/// Selects the story command sets before the first story context is installed. +#[cfg(feature = "suite")] +pub(crate) fn configure_story_sets(sets: &[SetEntry]) -> bool { + let _guard = STORY_SETS_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + if STORY_SETS.get().is_none() && LOADED[1].get().is_some() { + return sets.is_empty(); + } + let selected = STORY_SETS.get_or_init(|| sets.to_vec()); + selected.len() == sets.len() + && selected.iter().zip(sets).all(|(a, b)| { + (a.name)() == (b.name)() + && std::ptr::fn_addr_eq(a.defs, b.defs) + && std::ptr::fn_addr_eq(a.no_default_on, b.no_default_on) + && std::ptr::fn_addr_eq(a.edits, b.edits) + && std::ptr::fn_addr_eq(a.holds, b.holds) + && std::ptr::fn_addr_eq(a.platform_defaults, b.platform_defaults) + && a.typing.map(CommandScope::name) == b.typing.map(CommandScope::name) + }) +} /// Indexes the definition at `at` under its id `id`; an id already in `index` is refused (`Duplicate`). The registry /// and an app's catalog index their definitions through it. @@ -186,7 +199,19 @@ impl Registry { /// Loads every linked set; the stories' sets only with `stories`. pub(crate) fn load(stories: bool) -> Result { let mut registry = Registry { stories, ..Registry::default() }; - for entry in sets().into_iter().filter(|entry| stories || !entry.story) { + let entries = sets(); + #[cfg(feature = "suite")] + let entries = { + let mut entries = entries; + if stories { + if let Some(story_sets) = STORY_SETS.get() { + entries.extend(story_sets.iter()); + entries.sort_by_key(|entry| (entry.name)()); + } + } + entries + }; + for entry in entries { for def in (entry.defs)()? { registry.add(def)?; } @@ -204,6 +229,8 @@ impl Registry { /// The registry of every linked set (the stories' sets only with `stories`), loaded once per process: the sets are /// static, so every context shares one. A load that fails is not kept, so each install reports its error. pub(crate) fn shared(stories: bool) -> Result, CommandDefError> { + #[cfg(feature = "suite")] + let _guard = stories.then(|| STORY_SETS_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner)); let slot = &LOADED[usize::from(stories)]; if let Some(loaded) = slot.get() { return Ok(loaded.clone()); diff --git a/crates/ui-contract/src/testing/index.rs b/crates/ui-contract/src/testing/index.rs index 846377d92..89b9e50ee 100644 --- a/crates/ui-contract/src/testing/index.rs +++ b/crates/ui-contract/src/testing/index.rs @@ -49,7 +49,7 @@ fn shape_rank(shape: &str) -> usize { } /// The components and patterns of `registered`, ordered by level (the gallery's order), shape, then name. -fn registered_rows(registered: &[&'static Registration]) -> Vec { +fn registered_rows(registered: &[&Registration]) -> Vec { let mut rows = Vec::new(); for entry in catalog(registered).entries { let level = entry.level; @@ -77,12 +77,12 @@ fn registered_rows(registered: &[&'static Registration]) -> Vec { } /// The types of `registered` that have no purpose: their types lack a doc comment. -pub fn types_without_purpose(registered: &[&'static Registration]) -> Vec { +pub fn types_without_purpose(registered: &[&Registration]) -> Vec { registered_rows(registered).into_iter().filter(|row| row.purpose.is_empty()).map(|row| format!("{}::{}", row.module, row.name)).collect() } /// The text of `docs/components-index.md` for the workspace at `root` and the types of `registered`. -pub fn components_index(root: &Path, registered: &[&'static Registration]) -> String { +pub fn components_index(root: &Path, registered: &[&Registration]) -> String { let mut out = String::from("# Built components\n\n"); out.push_str("Generated by `cargo run -p craft-ui-gallery --bin components-index`; edit the doc comments, not this file.\n\n"); diff --git a/crates/ui-contract/src/testing/mod.rs b/crates/ui-contract/src/testing/mod.rs index 75b5ebb8f..d4fcf46c1 100644 --- a/crates/ui-contract/src/testing/mod.rs +++ b/crates/ui-contract/src/testing/mod.rs @@ -14,27 +14,29 @@ pub mod fixture; pub mod focus; pub mod frames; #[cfg(feature = "suite")] -mod host_key_trials; +pub(crate) mod host_key_trials; #[cfg(feature = "suite")] -mod icon_trials; +pub(crate) mod icon_trials; #[cfg(feature = "suite")] pub mod index; pub mod input; #[cfg(feature = "suite")] -mod key_trials; +pub(crate) mod key_trials; pub mod layout; pub mod memory; pub mod pictures; pub mod pointer; +#[cfg(feature = "suite")] +mod registry; pub mod relations; #[cfg(feature = "suite")] -mod replay_trials; +pub(crate) mod replay_trials; pub mod sensing; #[cfg(all(feature = "snapshot", not(target_arch = "wasm32")))] pub mod snapshot; mod stage; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub mod story; pub mod style; #[cfg(feature = "suite")] @@ -54,9 +56,9 @@ pub use crate::runtime::measure::{ pub use craft_ui_macros::{story, trial}; pub use fixture::{Fixture, Impure, Room, Target}; pub use frames::Frames; -pub use stage::{room_height, stage, stage_fitting, stage_width}; #[cfg(feature = "suite")] -pub use story::stories; +pub use registry::{Registered, Registry}; +pub use stage::{room_height, stage, stage_fitting, stage_width}; #[doc(hidden)] pub use story::{ CollectionKind, Drive, EditKind, Grip, Required, Story, StoryData, StoryOutput, StoryRegistration, StorySnapshot, show_as_only_item, @@ -97,28 +99,22 @@ impl Trial { } } -#[cfg(feature = "suite")] -inventory::collect!(Trial); - -/// Every `#[trial]` linked into the running binary, by full name. -#[cfg(feature = "suite")] -pub fn trials() -> Vec<&'static Trial> { - let mut all: Vec<_> = inventory::iter::().collect(); - all.sort_by_key(|trial| trial.full_name()); - all -} - /// Runs a test executable and exits: the `#[trial]`s declared in the crate whose root module is `crate_root` or in /// `package`'s library crate, and the suite's trials over `registered`. Every test executable's `main` calls it, with /// its own `module_path!()`. #[cfg(feature = "suite")] -pub fn run(crate_root: &str, package: &'static str, registered: &[&'static Registration]) -> ! { +pub fn run(crate_root: &str, package: &'static str, registry: &Registry) -> ! { + if !registry.install_story_sets() { + eprintln!("a different set of story commands was already installed"); + std::process::exit(1); + } let library = package.replace('-', "_"); let own = |module: &str| { [crate_root, library.as_str()].into_iter().any(|root| module.strip_prefix(root).is_some_and(|rest| rest.is_empty() || rest.starts_with("::"))) }; - let mut tests: Vec = trials() - .into_iter() + let mut tests: Vec = registry + .trials() + .iter() .filter(|trial| own(trial.module)) .map(|trial| { let run = trial.run; @@ -129,42 +125,12 @@ pub fn run(crate_root: &str, package: &'static str, registered: &[&'static Regis .with_ignored_flag(trial.ignored) }) .collect(); - tests.extend(suite::trials(package, registered)); + tests.extend(suite::trials(package, registry)); // A trial that re-runs its executable as a stand-in for another program passes that program's arguments after // `--`; they are the stand-in's, not the runner's. let args = libtest_mimic::Arguments::from_iter(std::env::args().take_while(|arg| arg != "--")); libtest_mimic::run(&args, tests).exit() } -/// Every registration declared in the library crate of the package `crate_name` and linked into the running -/// binary, by module and type name. Types declared in the package's integration binaries are fixtures, not the package's. #[cfg(feature = "suite")] -pub fn registered_in(crate_name: &str) -> Vec<&'static Registration> { - let library = crate_name.replace('-', "_"); - crate::contract::registrations() - .into_iter() - .filter(|registration| registration.crate_name() == crate_name && registration.crate_target() == library) - .collect() -} - -/// Writes `pub fn registered()` for the invoking package: its library crate's registrations in the running binary. -/// A crate invokes it once, in its `testing` module, and its integration binary calls the function by name. The -/// call references the library, so the linker includes it; the registrations are constructors in the library's -/// object files, which run as long as those files are linked. -#[macro_export] -macro_rules! testing_registered { - () => { - /// Every registration of this package linked into the running binary. - pub fn registered() -> ::std::vec::Vec<&'static $crate::testing::Registration> { - $crate::testing::registered_in(env!("CARGO_PKG_NAME")) - } - }; -} - -#[cfg(feature = "suite")] -testing_registered!(); - -#[doc(hidden)] -pub mod __private { - pub use inventory; -} +craft_ui_macros::registry!(); diff --git a/crates/ui-contract/src/testing/registry.rs b/crates/ui-contract/src/testing/registry.rs new file mode 100644 index 000000000..e3ad20aee --- /dev/null +++ b/crates/ui-contract/src/testing/registry.rs @@ -0,0 +1,84 @@ +//! Explicit registrations selected by a test executable or the gallery. + +use super::{StoryRegistration, Trial}; +use crate::contract::Registration; +use crate::runtime::commands::SetEntry; + +/// A component or pattern whose derive supplies its suite registration. +pub trait Registered { + /// The registration for this concrete type. + fn registration() -> Registration; +} + +/// The suite items selected by a caller. +#[derive(Default)] +pub struct Registry { + registrations: Vec, + stories: Vec, + trials: Vec, + story_sets: Vec, +} + +impl Registry { + /// Collects the items contributed by each selected crate. + pub fn of(crates: &[fn(&mut Registry)]) -> Self { + let mut registry = Self::default(); + for register in crates { + register(&mut registry); + } + registry.registrations.sort_by_key(|entry| match entry { + Registration::Component(probe) => (probe.crate_name, probe.crate_target, probe.module, probe.type_name()), + Registration::Pattern(probe) => (probe.crate_name, probe.crate_target, probe.module, probe.type_name()), + }); + registry.stories.sort_by_key(|story| ((story.type_name)(), (story.registration)().crate_name() != story.crate_name, story.file, story.line)); + registry.trials.sort_by_key(Trial::full_name); + registry.story_sets.sort_by_key(|entry| (entry.name)()); + registry + } + + /// Adds a component or pattern registration. + pub fn add_registration(&mut self, registration: Registration) { + self.registrations.push(registration); + } + + /// Adds a story. + pub fn add_story(&mut self, story: StoryRegistration) { + self.stories.push(story); + } + + /// Adds a trial. + pub fn add_trial(&mut self, trial: Trial) { + self.trials.push(trial); + } + + /// Adds a command set used by stories. + pub fn add_story_set(&mut self, set: SetEntry) { + self.story_sets.push(set); + } + + /// The selected components and patterns. + pub fn registrations(&self) -> &[Registration] { + &self.registrations + } + + /// The selected stories. + pub fn stories(&self) -> &[StoryRegistration] { + &self.stories + } + + /// The selected trials. + pub fn trials(&self) -> &[Trial] { + &self.trials + } + + /// Installs the selected story command sets before a story context is created. + /// Returns false if this process already selected a different set. + pub fn install_story_sets(&self) -> bool { + crate::runtime::commands::configure_story_sets(&self.story_sets) + } + + /// The selected story command sets. + pub fn story_sets(&self) -> &[SetEntry] { + &self.story_sets + } +} diff --git a/crates/ui-contract/src/testing/story.rs b/crates/ui-contract/src/testing/story.rs index 70d1639a6..eea92afa7 100644 --- a/crates/ui-contract/src/testing/story.rs +++ b/crates/ui-contract/src/testing/story.rs @@ -186,6 +186,8 @@ pub struct StoryRegistration { pub crate_target: &'static str, /// The registered name of the type the story shows. pub type_name: fn() -> &'static str, + /// The registration of the type shown by this story. + pub registration: fn() -> crate::contract::Registration, /// The story. pub story: Story, /// The source file of the declaration. @@ -196,8 +198,14 @@ pub struct StoryRegistration { impl StoryRegistration { /// The registration `#[story]` writes. - pub const fn new(crate_name: &'static str, crate_target: &'static str, type_name: fn() -> &'static str, story: Story) -> Self { - StoryRegistration { crate_name, crate_target, type_name, story, file: "", line: 0 } + pub const fn new( + crate_name: &'static str, + crate_target: &'static str, + type_name: fn() -> &'static str, + registration: fn() -> crate::contract::Registration, + story: Story, + ) -> Self { + StoryRegistration { crate_name, crate_target, type_name, registration, story, file: "", line: 0 } } /// The registration declared at `line` of `file`. @@ -208,29 +216,6 @@ impl StoryRegistration { } } -#[cfg(feature = "suite")] -inventory::collect!(StoryRegistration); - -/// Every story linked into the running binary, by type name; of each type, the stories of the package that registers -/// it first, then those other packages declare; each in the order they are declared in. -#[doc(hidden)] -#[cfg(feature = "suite")] -pub fn stories() -> Vec<&'static StoryRegistration> { - let homes: HashMap<&str, &str> = crate::contract::registrations() - .into_iter() - .filter_map(|registration| { - let name = registration.probe().map(|probe| probe.type_name()).or_else(|| registration.pattern_probe().map(|probe| probe.type_name()))?; - Some((name, registration.crate_name())) - }) - .collect(); - let mut all: Vec<_> = inventory::iter::().collect(); - all.sort_by_key(|entry| { - let name = (entry.type_name)(); - (name, homes.get(name) != Some(&entry.crate_name), entry.file, entry.line) - }); - all -} - /// The values a story shows, by name. Each is a `Value`, so the runner compares them before and after a drive. #[derive(Default)] pub struct StoryData { diff --git a/crates/ui-contract/src/testing/suite.rs b/crates/ui-contract/src/testing/suite.rs index b025b4904..d8aed2bbc 100644 --- a/crates/ui-contract/src/testing/suite.rs +++ b/crates/ui-contract/src/testing/suite.rs @@ -31,16 +31,17 @@ pub use size::{reflowed, text_size_case}; pub use states::required_states; pub use variants::rtl_case; +use super::Registry; use super::fixture::Fixture; -use super::story::{Story, stories}; +use super::story::Story; use crate::contract::{PatternProbe, Probe, Registration, ShapeKind}; use libtest_mimic::{Failed, Trial}; use std::cell::OnceCell; use std::panic::{AssertUnwindSafe, catch_unwind}; /// What a case reads: the registered type, the stories written for it, and what the cases share of them. -struct Subject { - probe: &'static Probe, +struct Subject<'a> { + probe: &'a Probe, stories: Vec, /// The stories are the home package's, the one that registers the type. Stories another package declares for the /// type run only the per-story cases there; the cases about the type as a whole (its required states, its @@ -62,8 +63,8 @@ struct Base { plan: drive::Plan, } -impl Subject { - fn new(probe: &'static Probe, stories: Vec, home: bool) -> Self { +impl<'a> Subject<'a> { + fn new(probe: &'a Probe, stories: Vec, home: bool) -> Self { let bases = stories.iter().map(|_| OnceCell::new()).collect(); Subject { probe, stories, home, bases, style_sources: OnceCell::new(), style_ctx: OnceCell::new() } } @@ -171,8 +172,8 @@ fn panic_text(payload: Box) -> String { /// The cases of `group` over the stories of the type `probe` describes, and with `check_exemptions` the check that /// each exemption names a known case. `home`: the stories are the package's that registers the type ([`Subject::home`]). -fn run_group(probe: &'static Probe, group: &'static Group, check_exemptions: bool, home: bool, stories: Vec) -> Result<(), Failed> { - let subject = Subject::new(probe, stories, home); +fn run_group(probe: Probe, group: &'static Group, check_exemptions: bool, home: bool, stories: Vec) -> Result<(), Failed> { + let subject = Subject::new(&probe, stories, home); let mut failures = Vec::new(); if check_exemptions && home { for exemption in probe.exempt { @@ -182,7 +183,7 @@ fn run_group(probe: &'static Probe, group: &'static Group, check_exemptions: boo } } for case in group.cases() { - if !runs_for(case, probe) { + if !runs_for(case, &probe) { continue; } match catch_unwind(AssertUnwindSafe(|| (case.run)(&subject))) { @@ -197,10 +198,11 @@ fn run_group(probe: &'static Probe, group: &'static Group, check_exemptions: boo /// The trials of one package: a trial per registered type and group of cases, `suite::::`; the same for /// each type another linked package registers and this package has stories of, over those stories and without the /// cases about the type as a whole (`Subject::home`); and one per story naming a type that is not linked. -pub fn trials(package: &'static str, registered: &[&'static Registration]) -> Vec { +pub fn trials(package: &'static str, registry: &Registry) -> Vec { let library = package.replace('-', "_"); - let own: Vec<_> = stories().into_iter().filter(|entry| entry.crate_name == package && entry.crate_target == library).collect(); - let probes: Vec<&'static Probe> = registered.iter().copied().filter_map(Registration::probe).collect(); + let own: Vec<_> = registry.stories().iter().filter(|entry| entry.crate_name == package && entry.crate_target == library).collect(); + let own_registrations = registry.registrations().iter().filter(|entry| entry.crate_name() == package && entry.crate_target() == library); + let probes: Vec = own_registrations.clone().filter_map(Registration::probe).copied().collect(); let mut trials = Vec::new(); for probe in probes.iter().copied() { let mut stories: Vec = own.iter().filter(|entry| (entry.type_name)() == probe.type_name()).map(|entry| entry.story).collect(); @@ -213,14 +215,13 @@ pub fn trials(package: &'static str, registered: &[&'static Registration]) -> Ve trials.push(Trial::test(name, move || run_group(probe, group, index == 0, true, stories))); } } - let patterns: Vec<&'static PatternProbe> = registered.iter().copied().filter_map(Registration::pattern_probe).collect(); + let patterns: Vec = own_registrations.filter_map(Registration::pattern_probe).copied().collect(); for pattern in &patterns { let stories: Vec = own.iter().filter(|entry| (entry.type_name)() == pattern.type_name()).map(|entry| entry.story).collect(); let name = pattern.type_name(); trials.push(Trial::test(format!("suite::{name}"), move || pattern::run(name, &stories).map_err(Failed::from))); } // Stories of a type another linked package registers run that type's cases here, as its visitors. - let linked = crate::contract::registrations(); let mut visited: Vec<&'static str> = Vec::new(); for entry in &own { let name = (entry.type_name)(); @@ -231,13 +232,14 @@ pub fn trials(package: &'static str, registered: &[&'static Registration]) -> Ve continue; } let stories: Vec = own.iter().filter(|entry| (entry.type_name)() == name).map(|entry| entry.story).collect(); - if let Some(probe) = linked.iter().copied().find_map(|registration| registration.probe().filter(|probe| probe.type_name() == name)) { + let registration = (entry.registration)(); + if let Some(probe) = registration.probe().copied() { visited.push(name); for group in GROUPS { let stories = stories.clone(); trials.push(Trial::test(format!("suite::{name}::{}", group.name), move || run_group(probe, group, false, false, stories))); } - } else if linked.iter().any(|registration| registration.pattern_probe().is_some_and(|pattern| pattern.type_name() == name)) { + } else if registration.pattern_probe().is_some() { visited.push(name); trials.push(Trial::test(format!("suite::{name}"), move || pattern::run(name, &stories).map_err(Failed::from))); } else { @@ -245,7 +247,7 @@ pub fn trials(package: &'static str, registered: &[&'static Registration]) -> Ve trials.push(Trial::test(format!("suite::stories::{}", entry.story.name), move || Err(Failed::from(message)))); } } - for entry in stories().into_iter().filter(|entry| entry.crate_name == package && entry.crate_target != library) { + for entry in registry.stories().iter().filter(|entry| entry.crate_name == package && entry.crate_target != library) { let message = format!( "the story `{}` is declared in the target `{}`; stories live in the library crate's `stories` module", entry.story.name, entry.crate_target diff --git a/crates/ui-contract/src/testing/suite/style.rs b/crates/ui-contract/src/testing/suite/style.rs index efbbb545d..311eab4fb 100644 --- a/crates/ui-contract/src/testing/suite/style.rs +++ b/crates/ui-contract/src/testing/suite/style.rs @@ -32,7 +32,7 @@ pub(super) enum Source { /// The styles of `subject` the stories resolve, read once for the style cases: each story settled, then each of its /// drives run once. One entry per style key, variant and size; the cases resolve each again under the themes they /// measure. -fn sources(subject: &Subject) -> Result<&[Source], String> { +fn sources<'a>(subject: &'a Subject<'_>) -> Result<&'a [Source], String> { subject.style_sources.get_or_init(|| read_sources(subject)).as_deref().map_err(Clone::clone) } @@ -68,7 +68,7 @@ fn read_sources(subject: &Subject) -> Result, String> { /// The context the style cases resolve looks in, one per type. A style hook that measures text needs the fonts, which /// egui installs in its first frame; the style cache keys each look by its key, env, variant and size, so the looks /// resolved before stand in for nothing else. -fn measuring_ctx(subject: &Subject) -> &egui::Context { +fn measuring_ctx<'a>(subject: &'a Subject<'_>) -> &'a egui::Context { subject.style_ctx.get_or_init(|| { let ctx = egui::Context::default(); drop(crate::runtime::egui::fixture::run_frame_shapes(&ctx, 0.0, egui::vec2(800.0, 600.0), |_| {})); diff --git a/crates/ui-contract/tests/it/access/mod.rs b/crates/ui-contract/tests/it/access/mod.rs index 67a826aac..b72d1c87f 100644 --- a/crates/ui-contract/tests/it/access/mod.rs +++ b/crates/ui-contract/tests/it/access/mod.rs @@ -1,10 +1,10 @@ //! The accessibility emitter: the label scope and merge rule, announcements, modal inertness, viewports. -mod bounds; -mod face_record; -mod face_state; -mod nodes; -mod scope; -mod static_text; -mod sub_node_keys; -mod viewports; +pub(crate) mod bounds; +pub(crate) mod face_record; +pub(crate) mod face_state; +pub(crate) mod nodes; +pub(crate) mod scope; +pub(crate) mod static_text; +pub(crate) mod sub_node_keys; +pub(crate) mod viewports; diff --git a/crates/ui-contract/tests/it/body/mod.rs b/crates/ui-contract/tests/it/body/mod.rs index ef7344a76..75236c9a4 100644 --- a/crates/ui-contract/tests/it/body/mod.rs +++ b/crates/ui-contract/tests/it/body/mod.rs @@ -1,5 +1,5 @@ //! The body step and the mount host: regions, scrolling, move and resize, and viewport mounts. -mod mounts; -mod nesting; -mod placement; +pub(crate) mod mounts; +pub(crate) mod nesting; +pub(crate) mod placement; diff --git a/crates/ui-contract/tests/it/canvas/mod.rs b/crates/ui-contract/tests/it/canvas/mod.rs index 7c25209c0..44064d75b 100644 --- a/crates/ui-contract/tests/it/canvas/mod.rs +++ b/crates/ui-contract/tests/it/canvas/mod.rs @@ -1,4 +1,4 @@ //! `Canvas` (20.6): a press away from every canvas control's parts reaches the tool. -mod outside_polygon; -mod past_the_clip; +pub(crate) mod outside_polygon; +pub(crate) mod past_the_clip; diff --git a/crates/ui-contract/tests/it/collection/mod.rs b/crates/ui-contract/tests/it/collection/mod.rs index 93a6b4998..880d56a3d 100644 --- a/crates/ui-contract/tests/it/collection/mod.rs +++ b/crates/ui-contract/tests/it/collection/mod.rs @@ -1,14 +1,14 @@ //! The item step: scrolling, the lead and selection, rename, the empty state, trees and large sources, over //! collections written on the contract only. -mod drag; -mod drops; -mod keys; +pub(crate) mod drag; +pub(crate) mod drops; +pub(crate) mod keys; pub(crate) mod kit; -mod list; -mod reorder_groups; -mod review; -mod rows; -mod sweep_apply; +pub(crate) mod list; +pub(crate) mod reorder_groups; +pub(crate) mod review; +pub(crate) mod rows; +pub(crate) mod sweep_apply; pub(crate) mod table; -mod table_trials; +pub(crate) mod table_trials; diff --git a/crates/ui-contract/tests/it/contract/level.rs b/crates/ui-contract/tests/it/contract/level.rs new file mode 100644 index 000000000..10565db96 --- /dev/null +++ b/crates/ui-contract/tests/it/contract/level.rs @@ -0,0 +1,23 @@ +//! Catalog names across the linked library crates. + +/// Guards against a registered type that no row places (it would list under no level) and against names a +/// viewer cannot show as one identifier or that two types share (the tree would list two rows alike). +#[craft_ui::testing::trial] +fn catalog_names_are_unique_pascal_case_and_every_type_has_a_level() { + let registry = craft_ui::testing::Registry::of(&[craft_ui::testing::register, craft_ui_test_kit::testing::register]); + let linked: Vec<_> = + registry.registrations().iter().filter(|registration| registration.crate_target() == registration.crate_name().replace('-', "_")).collect(); + let catalog = craft_ui::contract::catalog(&linked); + assert!(catalog.unleveled.is_empty(), "types with no level: {:?}", catalog.unleveled); + let mut seen = std::collections::HashSet::new(); + for entry in &catalog.entries { + let mut chars = entry.name.chars(); + assert!( + chars.next().is_some_and(|first| first.is_ascii_uppercase()) && chars.all(|c| c.is_ascii_alphanumeric()), + "`{}` ({}) is not a PascalCase identifier", + entry.name, + entry.type_name + ); + assert!(seen.insert((entry.level, entry.name.to_lowercase())), "`{}` is listed twice in {:?}", entry.name, entry.level); + } +} diff --git a/crates/ui-contract/tests/it/contract/mod.rs b/crates/ui-contract/tests/it/contract/mod.rs index b37aa95dc..c58d91a03 100644 --- a/crates/ui-contract/tests/it/contract/mod.rs +++ b/crates/ui-contract/tests/it/contract/mod.rs @@ -1,9 +1,10 @@ //! The component contract and the show pipeline: the steps each shape runs, and the rules the steps keep. -mod fixes; -mod gesture; -mod hit_order; -mod pages; -mod pointer; -mod style; -mod visited_type; +pub(crate) mod fixes; +pub(crate) mod gesture; +pub(crate) mod hit_order; +pub(crate) mod level; +pub(crate) mod pages; +pub(crate) mod pointer; +pub(crate) mod style; +pub(crate) mod visited_type; diff --git a/crates/ui-contract/tests/it/contract/visited_type.rs b/crates/ui-contract/tests/it/contract/visited_type.rs index c29953156..dee591092 100644 --- a/crates/ui-contract/tests/it/contract/visited_type.rs +++ b/crates/ui-contract/tests/it/contract/visited_type.rs @@ -42,31 +42,48 @@ fn plain_box(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { // The visitor's story covers no state: a Default story is the registering package's to have. Its file sorts before // the home story's. -craft_ui::testing::__private::inventory::submit! { - StoryRegistration::new(VISITOR, "craft_ui_visitor", std::any::type_name::, Story::new("plain_box", plain_box)).at("a.rs", 1) +fn visitor_story() -> StoryRegistration { + StoryRegistration::new( + VISITOR, + "craft_ui_visitor", + std::any::type_name::, + ::registration, + Story::new("plain_box", plain_box), + ) + .at("a.rs", 1) } -craft_ui::testing::__private::inventory::submit! { +fn home_story() -> StoryRegistration { StoryRegistration::new( env!("CARGO_PKG_NAME"), "craft_ui_contract", std::any::type_name::, + ::registration, Story::new("home_box", plain_box).covers(&[Required::Default]), ) .at("z.rs", 1) } +pub(crate) fn register_fixture(registry: &mut craft_ui::testing::Registry) { + registry.add_story(visitor_story()); + registry.add_story(home_story()); +} + +fn fixture_registry() -> craft_ui::testing::Registry { + craft_ui::testing::Registry::of(&[register_fixture]) +} + #[trial] fn a_types_own_stories_list_before_another_packages() { let visited = std::any::type_name::(); - let names: Vec<&str> = - craft_ui::testing::stories().into_iter().filter(|entry| (entry.type_name)() == visited).map(|entry| entry.story.name).collect(); + let registry = fixture_registry(); + let names: Vec<&str> = registry.stories().iter().filter(|entry| (entry.type_name)() == visited).map(|entry| entry.story.name).collect(); assert_eq!(names, ["home_box", "plain_box"], "the registering package's story comes first"); } #[trial] fn stories_of_another_packages_type_run_its_cases_in_the_declaring_package() { - let trials = craft_ui::testing::suite::trials(VISITOR, &[]); + let trials = craft_ui::testing::suite::trials(VISITOR, &fixture_registry()); let names: Vec = trials.iter().map(|trial| trial.name().to_owned()).collect(); let visited = std::any::type_name::(); assert!(names.contains(&format!("suite::{visited}::reads")), "the visitor runs the visited type's cases: {names:?}"); diff --git a/crates/ui-contract/tests/it/fonts/mod.rs b/crates/ui-contract/tests/it/fonts/mod.rs index c0804f8d6..96465b886 100644 --- a/crates/ui-contract/tests/it/fonts/mod.rs +++ b/crates/ui-contract/tests/it/fonts/mod.rs @@ -1,6 +1,6 @@ //! Interface fonts. -mod document; -mod on_demand; -mod served; -mod stack; +pub(crate) mod document; +pub(crate) mod on_demand; +pub(crate) mod served; +pub(crate) mod stack; diff --git a/crates/ui-contract/tests/it/layout/mod.rs b/crates/ui-contract/tests/it/layout/mod.rs index 0491eb06f..5d04599e3 100644 --- a/crates/ui-contract/tests/it/layout/mod.rs +++ b/crates/ui-contract/tests/it/layout/mod.rs @@ -1,4 +1,4 @@ -mod body; -mod fill; -mod memory; -mod overlay_bar; +pub(crate) mod body; +pub(crate) mod fill; +pub(crate) mod memory; +pub(crate) mod overlay_bar; diff --git a/crates/ui-contract/tests/it/main.rs b/crates/ui-contract/tests/it/main.rs index c62277815..7d0cf6b56 100644 --- a/crates/ui-contract/tests/it/main.rs +++ b/crates/ui-contract/tests/it/main.rs @@ -3,27 +3,36 @@ // The test files name the library as `craft_ui`, as the crates that use it do. extern crate craft_ui_contract as craft_ui; -mod access; +pub(crate) mod access; pub(crate) mod body; -mod canvas; -mod collection; -mod contract; -mod drag; -mod egui_surface; -mod fonts; -mod icon_ids; -mod keys_consumed; -mod layout; -mod motion; -mod paint; +pub(crate) mod canvas; +pub(crate) mod collection; +pub(crate) mod contract; +pub(crate) mod drag; +pub(crate) mod egui_surface; +pub(crate) mod fonts; +pub(crate) mod icon_ids; +pub(crate) mod keys_consumed; +pub(crate) mod layout; +pub(crate) mod motion; +pub(crate) mod paint; -mod runtime; +pub(crate) mod runtime; -mod style; -mod text; +pub(crate) mod style; +pub(crate) mod text; -use craft_ui::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run( + module_path!(), + env!("CARGO_PKG_NAME"), + &craft_ui::testing::Registry::of(&[ + register, + craft_ui::testing::register, + craft_ui_test_kit::testing::register, + contract::visited_type::register_fixture, + ]), + ); } diff --git a/crates/ui-contract/tests/it/motion/mod.rs b/crates/ui-contract/tests/it/motion/mod.rs index 8a4c649d4..31c8001a0 100644 --- a/crates/ui-contract/tests/it/motion/mod.rs +++ b/crates/ui-contract/tests/it/motion/mod.rs @@ -1,5 +1,5 @@ //! The motion service (13) and background results (14). -mod pending; -mod state; -mod timers; +pub(crate) mod pending; +pub(crate) mod state; +pub(crate) mod timers; diff --git a/crates/ui-contract/tests/it/paint/mod.rs b/crates/ui-contract/tests/it/paint/mod.rs index 2f42bfe96..ec94d91e2 100644 --- a/crates/ui-contract/tests/it/paint/mod.rs +++ b/crates/ui-contract/tests/it/paint/mod.rs @@ -1,9 +1,9 @@ -mod backdrop; +pub(crate) mod backdrop; -mod painters; +pub(crate) mod painters; -mod surround; +pub(crate) mod surround; -mod text_place; +pub(crate) mod text_place; -mod texture_store; +pub(crate) mod texture_store; diff --git a/crates/ui-contract/tests/it/runtime/mod.rs b/crates/ui-contract/tests/it/runtime/mod.rs index d7e5d979b..ea28e139e 100644 --- a/crates/ui-contract/tests/it/runtime/mod.rs +++ b/crates/ui-contract/tests/it/runtime/mod.rs @@ -1,15 +1,15 @@ -mod control_click; -mod cursor; -mod elapsed; -mod env; -mod frame; -mod latch; -mod memory; -mod pen; -mod pointer; -mod wheel; -mod window_move; -mod windows; -mod words; +pub(crate) mod control_click; +pub(crate) mod cursor; +pub(crate) mod elapsed; +pub(crate) mod env; +pub(crate) mod frame; +pub(crate) mod latch; +pub(crate) mod memory; +pub(crate) mod pen; +pub(crate) mod pointer; +pub(crate) mod wheel; +pub(crate) mod window_move; +pub(crate) mod windows; +pub(crate) mod words; -mod screenshot; +pub(crate) mod screenshot; diff --git a/crates/ui-contract/tests/it/style/mod.rs b/crates/ui-contract/tests/it/style/mod.rs index 890d3ceac..02daabf49 100644 --- a/crates/ui-contract/tests/it/style/mod.rs +++ b/crates/ui-contract/tests/it/style/mod.rs @@ -1,4 +1,4 @@ -mod cache; -mod library_theme; -mod surface_look; -mod theme_scope; +pub(crate) mod cache; +pub(crate) mod library_theme; +pub(crate) mod surface_look; +pub(crate) mod theme_scope; diff --git a/crates/ui-contract/tests/it/text/mod.rs b/crates/ui-contract/tests/it/text/mod.rs index de84ade0c..35907c463 100644 --- a/crates/ui-contract/tests/it/text/mod.rs +++ b/crates/ui-contract/tests/it/text/mod.rs @@ -1,2 +1,2 @@ -mod editor; -mod input_cap; +pub(crate) mod editor; +pub(crate) mod input_cap; diff --git a/crates/ui-gallery/Cargo.toml b/crates/ui-gallery/Cargo.toml index 67727bdd6..4e59501e5 100644 --- a/crates/ui-gallery/Cargo.toml +++ b/crates/ui-gallery/Cargo.toml @@ -108,3 +108,4 @@ craft-update = { workspace = true, features = ["suite"], optional = true } wasm-bindgen-futures = "0.4" [dev-dependencies] +toml = { version = "1.1", default-features = false, features = ["std", "parse", "serde"] } diff --git a/crates/ui-gallery/src/bin/components-index.rs b/crates/ui-gallery/src/bin/components-index.rs index 184daefac..5b8a83c2e 100644 --- a/crates/ui-gallery/src/bin/components-index.rs +++ b/crates/ui-gallery/src/bin/components-index.rs @@ -20,7 +20,9 @@ fn workspace_root() -> PathBuf { fn main() -> ExitCode { let root = workspace_root(); - let text = components_index(&root, &library_registrations()); + let registry = library_registrations(); + let registrations: Vec<_> = registry.registrations().iter().collect(); + let text = components_index(&root, ®istrations); let target = root.join(OUTPUT); if std::env::args().any(|argument| argument == "--check") { let current = fs::read_to_string(&target).unwrap_or_default(); diff --git a/crates/ui-gallery/src/foundations/mod.rs b/crates/ui-gallery/src/foundations/mod.rs index 3440a9b59..c61a7b391 100644 --- a/crates/ui-gallery/src/foundations/mod.rs +++ b/crates/ui-gallery/src/foundations/mod.rs @@ -1,8 +1,8 @@ //! The Foundations level: demos of the theme's tokens and of the edit lifecycle, which every component builds on. -mod colours; -mod edit_policy; -mod stories; +pub(crate) mod colours; +pub(crate) mod edit_policy; +pub(crate) mod stories; pub use colours::Colours; pub use edit_policy::EditPolicy; diff --git a/crates/ui-gallery/src/lib.rs b/crates/ui-gallery/src/lib.rs index 85e9b8240..ac528766e 100644 --- a/crates/ui-gallery/src/lib.rs +++ b/crates/ui-gallery/src/lib.rs @@ -17,59 +17,76 @@ pub const WINDOW: [f32; 2] = [1280.0, 800.0]; /// /// Each entry is a function of its crate that is passed by pointer, so the linker keeps that crate's object files and /// the story registrations in them, which a release build for the web would otherwise drop. -type Registered = fn() -> Vec<&'static craft_ui::testing::Registration>; +type Registered = fn(&mut craft_ui::testing::Registry); #[allow(unused_mut, clippy::vec_init_then_push)] fn crates() -> Vec<(&'static str, Registered)> { let mut crates: Vec<(&'static str, Registered)> = Vec::new(); #[cfg(feature = "automation")] - crates.push(("craft-automation", craft_automation::testing::registered)); + crates.push(("craft-automation", craft_automation::testing::register)); #[cfg(feature = "browse")] - crates.push(("craft-browse", craft_browse::ui::testing::registered)); + crates.push(("craft-browse", craft_browse::ui::testing::register)); #[cfg(feature = "color-ui")] - crates.push(("craft-color-ui", craft_color_ui::ui::testing::registered)); + crates.push(("craft-color-ui", craft_color_ui::ui::testing::register)); #[cfg(feature = "draw")] - crates.push(("craft-draw", craft_draw::testing::registered)); + crates.push(("craft-draw", craft_draw::testing::register)); #[cfg(feature = "imaging")] - crates.push(("craft-imaging", craft_imaging::testing::registered)); + crates.push(("craft-imaging", craft_imaging::testing::register)); #[cfg(feature = "layers")] - crates.push(("craft-layers", craft_layers::testing::registered)); + crates.push(("craft-layers", craft_layers::testing::register)); #[cfg(feature = "menu")] - crates.push(("craft-menu", craft_menu::testing::registered)); + crates.push(("craft-menu", craft_menu::testing::register)); #[cfg(feature = "pages")] - crates.push(("craft-pages", craft_pages::testing::registered)); + crates.push(("craft-pages", craft_pages::testing::register)); #[cfg(feature = "print")] - crates.push(("craft-print", craft_print::testing::registered)); + crates.push(("craft-print", craft_print::testing::register)); #[cfg(feature = "review")] - crates.push(("craft-review", craft_review::testing::registered)); + crates.push(("craft-review", craft_review::testing::register)); #[cfg(feature = "table")] - crates.push(("craft-table", craft_table::ui::testing::registered)); + crates.push(("craft-table", craft_table::ui::testing::register)); #[cfg(feature = "text")] - crates.push(("craft-text", craft_text::testing::registered)); + crates.push(("craft-text", craft_text::testing::register)); #[cfg(feature = "theme-editor")] - crates.push(("craft-theme-editor", craft_theme_editor::testing::registered)); + crates.push(("craft-theme-editor", craft_theme_editor::testing::register)); #[cfg(feature = "theme-store")] - crates.push(("craft-theme-store", craft_theme_store::ui::registered)); + crates.push(("craft-theme-store", craft_theme_store::ui::register)); #[cfg(feature = "timeline")] - crates.push(("craft-timeline", craft_timeline::testing::registered)); + crates.push(("craft-timeline", craft_timeline::testing::register)); // These do not build for the web, so their stories are in the native gallery only. #[cfg(all(feature = "dialogs", not(target_arch = "wasm32")))] - crates.push(("craft-dialogs", craft_dialogs::testing::registered)); + crates.push(("craft-dialogs", craft_dialogs::testing::register)); #[cfg(all(feature = "font-manager", not(target_arch = "wasm32")))] - crates.push(("craft-font-manager", craft_font_manager::testing::registered)); + crates.push(("craft-font-manager", craft_font_manager::testing::register)); #[cfg(all(feature = "update", not(target_arch = "wasm32")))] - crates.push(("craft-update", craft_update::testing::registered)); - std::hint::black_box(crates) + crates.push(("craft-update", craft_update::testing::register)); + crates } -/// How many registrations each linked crate contributes, with the viewer's own, and how many stories there are in all. +/// Adds the viewer and each selected dependency to a registry. +pub fn register_all(registry: &mut craft_ui::testing::Registry) { + craft_ui::testing::register_library(registry); + testing::register(registry); + for (_, register) in crates() { + register(registry); + } +} + +/// The registry of the viewer and the crates whose stories it shows. +pub fn registry() -> &'static craft_ui::testing::Registry { + static REGISTRY: std::sync::OnceLock = std::sync::OnceLock::new(); + REGISTRY.get_or_init(|| craft_ui::testing::Registry::of(&[register_all])) +} + +/// How many registrations each selected crate contributes, and how many stories there are in all. pub fn linked_counts() -> (Vec<(&'static str, usize)>, usize) { - let mut counts: Vec<(&'static str, usize)> = crates().into_iter().map(|(name, registered)| (name, registered().len())).collect(); - counts.push((env!("CARGO_PKG_NAME"), testing::registered().len())); - (counts, craft_ui::testing::stories().len()) + let registry = registry(); + let mut counts: Vec<_> = + crates().into_iter().map(|(name, _)| (name, registry.registrations().iter().filter(|entry| entry.crate_name() == name).count())).collect(); + counts.push((env!("CARGO_PKG_NAME"), registry.registrations().iter().filter(|entry| entry.crate_name() == env!("CARGO_PKG_NAME")).count())); + (counts, registry.stories().len()) } /// The test registry of this package's stories. pub mod testing { - craft_ui::testing_registered!(); + craft_ui::registry!(); } diff --git a/crates/ui-gallery/src/main.rs b/crates/ui-gallery/src/main.rs index e7343b4d8..e946e3da0 100644 --- a/crates/ui-gallery/src/main.rs +++ b/crates/ui-gallery/src/main.rs @@ -13,8 +13,15 @@ fn spec() -> AppSpec { } #[cfg(not(target_arch = "wasm32"))] -fn main() -> eframe::Result { - craft_ui::shell::app::run(spec(), |_| Gallery::open()) +fn main() { + if !craft_ui_gallery::registry().install_story_sets() { + eprintln!("a different set of story commands was already installed"); + std::process::exit(1); + } + if let Err(error) = craft_ui::shell::app::run(spec(), |_| Gallery::open()) { + eprintln!("{error}"); + std::process::exit(1); + } } /// The web build: the gallery on the page's `gallery_canvas`, started by trunk's bundle. The number of stories goes @@ -25,6 +32,10 @@ fn main() { use eframe::web_sys::{HtmlCanvasElement, console, window}; wasm_bindgen_futures::spawn_local(async { + if !craft_ui_gallery::registry().install_story_sets() { + console::error_1(&JsValue::from_str("a different set of story commands was already installed")); + return; + } let (counts, stories) = craft_ui_gallery::linked_counts(); let per_crate: Vec = counts.iter().map(|(name, count)| format!("{name}={count}")).collect(); console::log_1(&JsValue::from_str(&format!("craft-ui-gallery: {stories} stories; registrations by crate: {}", per_crate.join(" ")))); diff --git a/crates/ui-gallery/src/mock/mod.rs b/crates/ui-gallery/src/mock/mod.rs index 76030611a..3592485a6 100644 --- a/crates/ui-gallery/src/mock/mod.rs +++ b/crates/ui-gallery/src/mock/mod.rs @@ -2,11 +2,11 @@ //! composed from library components only. mod commands; -mod editor; +pub(crate) mod editor; mod model; mod panels; -mod stories; -mod tools; +pub(crate) mod stories; +pub(crate) mod tools; mod words; pub use commands::AppCommand; diff --git a/crates/ui-gallery/src/viewer/catalog.rs b/crates/ui-gallery/src/viewer/catalog.rs index 49122a87f..df7280146 100644 --- a/crates/ui-gallery/src/viewer/catalog.rs +++ b/crates/ui-gallery/src/viewer/catalog.rs @@ -1,7 +1,7 @@ //! What the viewer lists: every registered story, grouped by the component it shows. use craft_ui::contract::{self, Level, Probe, Registration}; -use craft_ui::testing::{StoryRegistration, stories}; +use craft_ui::testing::StoryRegistration; use std::collections::HashMap; use std::sync::OnceLock; @@ -108,7 +108,10 @@ pub fn fold_filter(filter: &str) -> String { /// The registry's catalog of the types linked into the running binary: each one's level and plain name. pub(crate) fn linked_catalog() -> &'static contract::Catalog { static CATALOG: OnceLock = OnceLock::new(); - CATALOG.get_or_init(|| contract::catalog(&contract::registrations())) + CATALOG.get_or_init(|| { + let registrations: Vec<_> = crate::registry().registrations().iter().collect(); + contract::catalog(®istrations) + }) } /// The plain name of the component registered as `type_name`; the registered name when the registry lists no such type. @@ -118,7 +121,7 @@ pub fn display_name(type_name: &str) -> String { /// Every story linked into the viewer, ordered by type then story name. pub fn entries() -> Vec { - stories().into_iter().map(|registration| Entry { registration, type_name: (registration.type_name)() }).collect() + crate::registry().stories().iter().map(|registration| Entry { registration, type_name: (registration.type_name)() }).collect() } /// What a registration says about a type: where it is declared and what it is for. @@ -136,7 +139,7 @@ pub struct Declared { /// The registration of each registered component and pattern type, by the type's registered name. pub fn declared() -> HashMap<&'static str, Declared> { let mut out = HashMap::new(); - for registration in contract::registrations() { + for registration in crate::registry().registrations() { match registration { Registration::Component(probe) => { out.insert(probe.type_name(), Declared { module: probe.module, purpose: probe.purpose, probe: Some(probe) }); diff --git a/crates/ui-gallery/tests/it/main.rs b/crates/ui-gallery/tests/it/main.rs index 48506bd19..866bfbfa3 100644 --- a/crates/ui-gallery/tests/it/main.rs +++ b/crates/ui-gallery/tests/it/main.rs @@ -1,11 +1,12 @@ //! The viewer's integration tests: one binary, run by `libtest-mimic` over the registered trials. -mod mock; -mod overview; -mod viewer; +pub(crate) mod mock; +pub(crate) mod overview; +pub(crate) mod registry; +pub(crate) mod viewer; -use craft_ui_gallery::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register, craft_ui_gallery::register_all])); } diff --git a/crates/ui-gallery/tests/it/registry.rs b/crates/ui-gallery/tests/it/registry.rs new file mode 100644 index 000000000..40b1a6dea --- /dev/null +++ b/crates/ui-gallery/tests/it/registry.rs @@ -0,0 +1,49 @@ +//! The gallery registry must follow its manifest's suite dependencies. + +use craft_ui::testing::trial; +use std::collections::BTreeSet; + +fn suite_dependencies(table: &toml::Table, found: &mut BTreeSet) { + for (name, value) in table { + let Some(dependency) = value.as_table() else { continue }; + if name != "craft-ui" + && dependency + .get("features") + .and_then(toml::Value::as_array) + .is_some_and(|features| features.iter().any(|feature| feature.as_str() == Some("suite"))) + { + found.insert(name.clone()); + } + } +} + +#[trial] +fn gallery_registers_each_suite_dependency() { + let manifest: toml::Value = toml::from_str(include_str!("../../Cargo.toml")).expect("gallery manifest parses"); + let mut dependencies = BTreeSet::new(); + if let Some(table) = manifest.get("dependencies").and_then(toml::Value::as_table) { + suite_dependencies(table, &mut dependencies); + } + if let Some(targets) = manifest.get("target").and_then(toml::Value::as_table) { + for target in targets.values() { + if let Some(table) = target.get("dependencies").and_then(toml::Value::as_table) { + suite_dependencies(table, &mut dependencies); + } + } + } + if let Some(features) = manifest.get("features").and_then(toml::Value::as_table) { + for value in features.values().filter_map(toml::Value::as_array).flatten().filter_map(toml::Value::as_str) { + if let Some(name) = value.strip_suffix("/suite") { + if name.starts_with("craft-") && name != "craft-ui" { + dependencies.insert(name.to_owned()); + } + } + } + } + let listed: BTreeSet<_> = include_str!("../../src/lib.rs") + .lines() + .filter_map(|line| line.trim().strip_prefix("crates.push((\"")) + .filter_map(|line| line.split_once('"').map(|(name, _)| name.to_owned())) + .collect(); + assert_eq!(listed, dependencies, "gallery registry and suite dependencies differ"); +} diff --git a/crates/ui-macros/src/command_set.rs b/crates/ui-macros/src/command_set.rs index 9beb0a132..c18fc83b4 100644 --- a/crates/ui-macros/src/command_set.rs +++ b/crates/ui-macros/src/command_set.rs @@ -42,7 +42,7 @@ fn command_attrs(attrs: &[Attribute], mut read: impl FnMut(&syn::meta::ParseNest Ok(()) } -fn snake(name: &str) -> String { +pub(crate) fn snake(name: &str) -> String { let mut out = String::new(); for (i, c) in name.chars().enumerate() { if c.is_ascii_uppercase() { @@ -227,7 +227,26 @@ pub(crate) fn derive(input: TokenStream) -> syn::Result { } Ok(true) })?; - let register = if set.story { quote!(#k::__register_command_set!(#ident, story);) } else { quote!(#k::__register_command_set!(#ident);) }; + let register = if set.story { + let helper = quote::format_ident!("__registry_command_{}", snake(&ident.to_string())); + quote! { + pub(crate) fn #helper() -> #k::runtime::commands::SetEntry { + #k::runtime::commands::SetEntry::new( + ::std::any::type_name::<#ident>, + <#ident as #k::runtime::commands::CommandSet>::defs, + <#ident as #k::runtime::commands::CommandSet>::no_default_on, + <#ident as #k::runtime::commands::CommandSet>::edits, + <#ident as #k::runtime::commands::CommandSet>::holds, + if <#ident as #k::runtime::commands::CommandSet>::TYPING { + Some(<#ident as #k::runtime::commands::CommandSet>::SCOPE) + } else { None }, + <#ident as #k::runtime::commands::CommandSet>::platform_defaults, + ) + } + } + } else { + quote!(#k::__register_command_set!(#ident);) + }; let prefix = set.prefix.ok_or_else(|| syn::Error::new_spanned(ident, "a command set names its id prefix: `#[command(prefix = \"..\")]`"))?; check_prefix(&prefix)?; if let Some(scope) = &set.scope { @@ -346,8 +365,6 @@ pub(crate) fn derive(input: TokenStream) -> syn::Result { } } - const _: () = { - #register - }; + #register }) } diff --git a/crates/ui-macros/src/component.rs b/crates/ui-macros/src/component.rs index aa7f82897..ebf5d48a6 100644 --- a/crates/ui-macros/src/component.rs +++ b/crates/ui-macros/src/component.rs @@ -22,7 +22,7 @@ struct Declared { exempt: Vec<(LitStr, LitStr)>, /// The function that makes an instance of a leaf for the suite: `sample = path`. sample: Option, - /// The first sentence of the type's doc comment; empty for `register_contract!`. + /// The first sentence of the type's doc comment, or an explicit manual registration purpose. purpose: String, } @@ -61,6 +61,8 @@ impl Declared { (Some(case), Some(reason)) => self.exempt.push((case, reason)), _ => return Err(meta.error("`exempt` needs both `case = \"..\"` and `reason = \"..\"`")), } + } else if path.is_ident("purpose") { + self.purpose = meta.value()?.parse::()?.value(); } else if path.is_ident("sample") { if self.sample.is_some() { return Err(meta.error("`sample` is declared once")); @@ -198,6 +200,16 @@ pub(crate) fn gate_for(manifest: &str) -> TokenStream { if declares { quote!(#[cfg(feature = "suite")]) } else { quote!() } } +fn registry_helper(types: &[Type]) -> syn::Result { + let Some(Type::Path(path)) = types.first() else { + return Err(syn::Error::new(proc_macro2::Span::call_site(), "a registration needs a named type")); + }; + let Some(name) = path.path.segments.last() else { + return Err(syn::Error::new_spanned(path, "a registration needs a named type")); + }; + Ok(format_ident!("__registry_component_{}", crate::command_set::snake(&name.ident.to_string()))) +} + fn registrations(k: &TokenStream, types: &[Type], declared: &Declared, shape: Shape) -> syn::Result { if let Some(sample) = &declared.sample { if shape != Shape::Leaf { @@ -218,7 +230,13 @@ fn registrations(k: &TokenStream, types: &[Type], declared: &Declared, shape: Sh let purpose = &declared.purpose; let each = types.iter().map(|ty| quote!(#k::__register_contract!(#ty, #shape, #overlay, [#(#exempt),*], [#(#sample)*], #purpose);)); let gate = registration_gate(); + let helper = registry_helper(types)?; Ok(quote! { + #gate + pub(crate) fn #helper(registry: &mut #k::testing::Registry) { + #(registry.add_registration(<#types as #k::testing::Registered>::registration());)* + } + // Outside the gate: the sample exists in every build, so it is never dead code where the registration is absent. #(const _: () = { let _ = #sample; };)* #gate @@ -234,7 +252,15 @@ fn registrations(k: &TokenStream, types: &[Type], declared: &Declared, shape: Sh pub(crate) fn pattern_registrations(k: &TokenStream, types: &[Type], purpose: &str, probe: &TokenStream) -> TokenStream { let each = types.iter().map(|ty| quote!(#k::__register_pattern!(#ty, #purpose, #probe);)); let gate = registration_gate(); + let helper = match registry_helper(types) { + Ok(helper) => helper, + Err(error) => return error.to_compile_error(), + }; quote! { + #gate + pub(crate) fn #helper(registry: &mut #k::testing::Registry) { + #(registry.add_registration(<#types as #k::testing::Registered>::registration());)* + } #gate const _: () = { #(#each)* diff --git a/crates/ui-macros/src/lib.rs b/crates/ui-macros/src/lib.rs index c0c4ada83..6d666df3a 100644 --- a/crates/ui-macros/src/lib.rs +++ b/crates/ui-macros/src/lib.rs @@ -7,6 +7,7 @@ mod component; mod env; mod pattern; mod props; +mod registry; mod style; mod token_group; mod util; @@ -114,8 +115,7 @@ pub fn words(input: TokenStream) -> TokenStream { /// Registers a function as a trial of its crate's test executable. /// -/// The function takes no arguments and returns `()`; it fails by panicking. The registration lists it in -/// `craft_ui::testing::trials()`, so the runner finds it without a hand-kept list. An `#[ignore]` on the function +/// The function takes no arguments and returns `()`; it fails by panicking. The crate registry includes it in the runner. An `#[ignore]` on the function /// makes it run only under `--ignored`. #[proc_macro_attribute] pub fn trial(attr: TokenStream, item: TokenStream) -> TokenStream { @@ -136,14 +136,16 @@ pub fn trial(attr: TokenStream, item: TokenStream) -> TokenStream { let ident = &sig.ident; let name = ident.to_string(); let gate = component::registration_gate(); + let helper = quote::format_ident!("__registry_trial_{}", ident); quote! { #gate #func #gate - #k::testing::__private::inventory::submit! { + pub(crate) fn #helper() -> #k::testing::Trial { #k::testing::Trial::#register(module_path!(), #name, #ident) } + } .into() } @@ -206,7 +208,8 @@ impl Parse for StoryArgs { pub fn story(attr: TokenStream, item: TokenStream) -> TokenStream { let k = util::ui_crate(); let args = parse_macro_input!(attr as StoryArgs); - let func = parse_macro_input!(item as ItemFn); + let mut func = parse_macro_input!(item as ItemFn); + func.vis = syn::parse_quote!(pub(crate)); let ident = &func.sig.ident; let name = ident.to_string(); let ty = &args.ty; @@ -217,20 +220,32 @@ pub fn story(attr: TokenStream, item: TokenStream) -> TokenStream { let group = args.group.as_ref().map(|group| quote!(.group(#group))); let commands = args.commands.as_ref().map(|commands| quote!(.commands(#commands))); let gate = component::registration_gate(); + let helper = quote::format_ident!("__registry_story_{}", ident); + let registration = quote! { + #k::testing::StoryRegistration::new( + env!("CARGO_PKG_NAME"), + env!("CARGO_CRATE_NAME"), + ::std::any::type_name::<#ty>, + <#ty as #k::testing::Registered>::registration, + #k::testing::Story::new(#name, #ident).covers(&[#(#k::testing::Required::#covers),*]) #drive #disabled_text #title #group #commands, + ).at(file!(), line!()) + }; quote! { #gate #func #gate - #k::testing::__private::inventory::submit! { - #k::testing::StoryRegistration::new( - env!("CARGO_PKG_NAME"), - env!("CARGO_CRATE_NAME"), - ::std::any::type_name::<#ty>, - #k::testing::Story::new(#name, #ident).covers(&[#(#k::testing::Required::#covers),*]) #drive #disabled_text #title #group #commands, - ) - .at(file!(), line!()) - } + pub(crate) fn #helper() -> #k::testing::StoryRegistration { #registration } + } .into() } + +/// Generates a crate registration function by reading its source modules. +#[proc_macro] +pub fn registry(input: TokenStream) -> TokenStream { + if !input.is_empty() { + return syn::Error::new(proc_macro2::Span::call_site(), "registry! takes no arguments").to_compile_error().into(); + } + expanded(registry::expand()) +} diff --git a/crates/ui-macros/src/registry.rs b/crates/ui-macros/src/registry.rs new file mode 100644 index 000000000..68e5a5781 --- /dev/null +++ b/crates/ui-macros/src/registry.rs @@ -0,0 +1,243 @@ +//! Discovers suite items in a crate's source modules for `registry!()`. + +use proc_macro2::{Ident, Span, TokenStream}; +use quote::{format_ident, quote}; +use std::path::{Path, PathBuf}; +use syn::parse::{Parse, ParseStream}; +use syn::punctuated::Punctuated; +use syn::{Attribute, Item, ItemMod, Meta, Token, Type}; + +struct FirstType(Type); +impl Parse for FirstType { + fn parse(input: ParseStream<'_>) -> syn::Result { + let first = input.parse()?; + let _: TokenStream = input.parse()?; + Ok(Self(first)) + } +} + +fn attrs_cfg(attrs: &[Attribute]) -> Vec { + attrs.iter().filter(|a| a.path().is_ident("cfg") || a.path().is_ident("cfg_attr")).cloned().collect() +} + +fn derives(attrs: &[Attribute], wanted: &str) -> bool { + attrs.iter().filter(|a| a.path().is_ident("derive")).any(|a| { + a.parse_args_with(Punctuated::::parse_terminated) + .is_ok_and(|paths| paths.iter().any(|p| p.segments.last().is_some_and(|s| s.ident == wanted))) + }) +} + +fn marker(attrs: &[Attribute], name: &str) -> bool { + attrs.iter().any(|a| a.path().segments.last().is_some_and(|s| s.ident == name)) +} + +fn opt(attrs: &[Attribute], attr: &str, value: &str) -> bool { + attrs.iter().filter(|a| a.path().is_ident(attr)).any(|a| match &a.meta { + Meta::List(list) => list.tokens.to_string().split(|c: char| !c.is_alphanumeric() && c != '_').any(|word| word == value), + _ => false, + }) +} + +fn include_value(expr: &syn::Expr) -> Option { + match expr { + syn::Expr::Lit(expr) => match &expr.lit { + syn::Lit::Str(value) => Some(value.value()), + _ => None, + }, + syn::Expr::Macro(expr) if expr.mac.path.is_ident("env") => { + let name = syn::parse2::(expr.mac.tokens.clone()).ok()?; + (name.value() == "OUT_DIR").then(|| std::env::var("OUT_DIR").ok()).flatten() + } + syn::Expr::Macro(expr) if expr.mac.path.is_ident("concat") => { + let args = expr.mac.parse_body_with(Punctuated::::parse_terminated).ok()?; + args.iter().map(include_value).collect::>>().map(|parts| parts.concat()) + } + _ => None, + } +} + +fn contains_suite_item(items: &[Item]) -> bool { + items.iter().any(|item| match item { + Item::Struct(item) => { + (derives(&item.attrs, "Component") && !opt(&item.attrs, "component", "unregistered")) || derives(&item.attrs, "Pattern") + } + Item::Enum(item) => derives(&item.attrs, "CommandSet") && opt(&item.attrs, "command", "story"), + Item::Fn(item) => marker(&item.attrs, "story") || marker(&item.attrs, "trial"), + Item::Mod(item) => item.content.as_ref().is_some_and(|(_, items)| contains_suite_item(items)), + Item::Macro(item) => { + let name = item.mac.path.segments.last().map(|segment| segment.ident.to_string()).unwrap_or_default(); + let body = item.mac.tokens.to_string(); + name == "register_contract" + || name == "include" + || (name == "macro_rules" + && (body.contains("register_contract") + || body.contains("# [story") + || body.contains("# [trial") + || (body.contains("derive") && (body.contains("Component") || body.contains("Pattern")) && !body.contains("unregistered")) + || (body.contains("CommandSet") && body.contains("story")))) + } + _ => false, + }) +} + +fn module_file(dir: &Path, path_dir: &Path, module: &ItemMod) -> Option { + for attr in &module.attrs { + if attr.path().is_ident("path") { + if let Meta::NameValue(value) = &attr.meta { + if let syn::Expr::Lit(expr) = &value.value { + if let syn::Lit::Str(path) = &expr.lit { + return Some(path_dir.join(path.value())); + } + } + } + } + } + let plain = dir.join(format!("{}.rs", module.ident)); + if plain.is_file() { + Some(plain) + } else { + let nested = dir.join(module.ident.to_string()).join("mod.rs"); + nested.is_file().then_some(nested) + } +} + +fn walk( + items: &[Item], + file: &Path, + dir: &Path, + path_dir: &Path, + path: &[Ident], + inherited: &[Attribute], + calls: &mut Vec, +) -> syn::Result<()> { + for item in items { + match item { + Item::Mod(module) => { + let mut cfg = inherited.to_vec(); + cfg.extend(attrs_cfg(&module.attrs)); + let mut child_path = path.to_vec(); + child_path.push(module.ident.clone()); + if let Some((_, content)) = &module.content { + let inline_dir = dir.join(module.ident.to_string()); + walk(content, file, &inline_dir, &inline_dir, &child_path, &cfg, calls)?; + } else if let Some(file) = module_file(dir, path_dir, module) { + let text = std::fs::read_to_string(&file) + .map_err(|e| syn::Error::new_spanned(module, format!("cannot read {}: {e}", file.display())))?; + let parsed = + syn::parse_file(&text).map_err(|e| syn::Error::new_spanned(module, format!("cannot parse {}: {e}", file.display())))?; + let child_dir = if file.file_name().is_some_and(|n| n == "mod.rs" || n == "main.rs" || n == "lib.rs") { + file.parent().unwrap_or(dir).to_path_buf() + } else { + file.parent().unwrap_or(dir).join(file.file_stem().unwrap_or_default()) + }; + walk(&parsed.items, &file, &child_dir, file.parent().unwrap_or(dir), &child_path, &cfg, calls)?; + } + } + Item::Struct(item) + if (derives(&item.attrs, "Component") && !opt(&item.attrs, "component", "unregistered")) || derives(&item.attrs, "Pattern") => + { + let helper = format_ident!("__registry_component_{}", crate::command_set::snake(&item.ident.to_string())); + let mut cfg = inherited.to_vec(); + cfg.extend(attrs_cfg(&item.attrs)); + calls.push(quote! { #(#cfg)* crate::#(#path::)*#helper(registry); }); + } + Item::Fn(item) if marker(&item.attrs, "story") || marker(&item.attrs, "trial") => { + let (prefix, method) = + if marker(&item.attrs, "story") { ("story", format_ident!("add_story")) } else { ("trial", format_ident!("add_trial")) }; + let helper = format_ident!("__registry_{}_{}", prefix, item.sig.ident); + let mut cfg = inherited.to_vec(); + cfg.extend(attrs_cfg(&item.attrs)); + calls.push(quote! { #(#cfg)* registry.#method(crate::#(#path::)*#helper()); }); + } + Item::Enum(item) if derives(&item.attrs, "CommandSet") && opt(&item.attrs, "command", "story") => { + let helper = format_ident!("__registry_command_{}", crate::command_set::snake(&item.ident.to_string())); + let mut cfg = inherited.to_vec(); + cfg.extend(attrs_cfg(&item.attrs)); + calls.push(quote! { #(#cfg)* registry.add_story_set(crate::#(#path::)*#helper()); }); + } + Item::Macro(item) if item.mac.path.is_ident("include") => { + let expression: syn::Expr = syn::parse2(item.mac.tokens.clone())?; + let included = + include_value(&expression).ok_or_else(|| syn::Error::new_spanned(item, "registry! cannot inspect this include! path"))?; + let included = file.parent().unwrap_or(dir).join(included); + let text = std::fs::read_to_string(&included) + .map_err(|e| syn::Error::new_spanned(item, format!("cannot inspect {}: {e}", included.display())))?; + let parsed = + syn::parse_file(&text).map_err(|e| syn::Error::new_spanned(item, format!("cannot inspect {}: {e}", included.display())))?; + if contains_suite_item(&parsed.items) { + return Err(syn::Error::new_spanned(item, "suite registration inside include! is invisible to registry!")); + } + } + Item::Macro(item) if item.mac.path.segments.last().is_some_and(|s| s.ident == "register_contract") => { + let FirstType(ty) = syn::parse2(item.mac.tokens.clone())?; + if let Type::Path(ty) = ty { + if let Some(name) = ty.path.segments.last() { + let helper = format_ident!("__registry_component_{}", crate::command_set::snake(&name.ident.to_string())); + let mut cfg = inherited.to_vec(); + cfg.extend(attrs_cfg(&item.attrs)); + calls.push(quote! { #(#cfg)* crate::#(#path::)*#helper(registry); }); + } + } + } + _ => {} + } + } + Ok(()) +} + +pub fn expand() -> syn::Result { + let invocation = + proc_macro::Span::call_site().local_file().ok_or_else(|| syn::Error::new(Span::call_site(), "registry! needs a local source file"))?; + let manifest = + std::env::var_os("CARGO_MANIFEST_DIR").map(PathBuf::from).ok_or_else(|| syn::Error::new(Span::call_site(), "missing CARGO_MANIFEST_DIR"))?; + let invocation = std::fs::canonicalize(&invocation).unwrap_or(invocation); + let src = std::fs::canonicalize(manifest.join("src")).unwrap_or_else(|_| manifest.join("src")); + let source = if invocation.starts_with(&src) { src.join("lib.rs") } else { invocation }; + let text = std::fs::read_to_string(&source).map_err(|e| syn::Error::new(Span::call_site(), format!("cannot read {}: {e}", source.display())))?; + let parsed = syn::parse_file(&text)?; + let mut calls = Vec::new(); + walk(&parsed.items, &source, source.parent().unwrap_or(&manifest), source.parent().unwrap_or(&manifest), &[], &[], &mut calls)?; + let k = crate::util::ui_crate(); + Ok(quote! { + /// Adds this crate's suite items to the caller's registry. + pub fn register(registry: &mut #k::testing::Registry) { + #(#calls)* + } + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn rejects_a_registration_inside_an_include() { + let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/registry/root.rs"); + let parsed = syn::parse_file("include!(\"included.rs\");"); + assert!(parsed.is_ok()); + if let Ok(parsed) = parsed { + let mut calls = Vec::new(); + let dir = root.parent().unwrap_or(Path::new("")); + assert!(walk(&parsed.items, &root, dir, dir, &[], &[], &mut calls).is_err()); + } + } + + #[test] + fn follows_modules_and_keeps_their_conditions() { + let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/registry/root.rs"); + let source = std::fs::read_to_string(&root).unwrap_or_default(); + let parsed = syn::parse_file(&source); + assert!(parsed.is_ok()); + if let Ok(parsed) = parsed { + let mut calls = Vec::new(); + let result = + walk(&parsed.items, &root, root.parent().unwrap_or(Path::new("")), root.parent().unwrap_or(Path::new("")), &[], &[], &mut calls); + assert!(result.is_ok()); + let generated = quote! { #(#calls)* }.to_string(); + assert!(generated.contains("feature = \"sample\"")); + assert!(generated.contains("__registry_story_view")); + assert!(generated.contains("__registry_trial_changes")); + assert!(generated.contains("__registry_trial_path_trial")); + } + } +} diff --git a/crates/ui-macros/tests/fixtures/registry/child.rs b/crates/ui-macros/tests/fixtures/registry/child.rs new file mode 100644 index 000000000..58ec79e0f --- /dev/null +++ b/crates/ui-macros/tests/fixtures/registry/child.rs @@ -0,0 +1,7 @@ +#[story(Widget)] +fn view() {} + +#[trial] +fn changes() {} +#[path = "other.rs"] +mod other; diff --git a/crates/ui-macros/tests/fixtures/registry/included.rs b/crates/ui-macros/tests/fixtures/registry/included.rs new file mode 100644 index 000000000..d99724797 --- /dev/null +++ b/crates/ui-macros/tests/fixtures/registry/included.rs @@ -0,0 +1,2 @@ +#[trial] +fn hidden() {} diff --git a/crates/ui-macros/tests/fixtures/registry/other.rs b/crates/ui-macros/tests/fixtures/registry/other.rs new file mode 100644 index 000000000..1887f4901 --- /dev/null +++ b/crates/ui-macros/tests/fixtures/registry/other.rs @@ -0,0 +1,2 @@ +#[trial] +fn path_trial() {} diff --git a/crates/ui-macros/tests/fixtures/registry/root.rs b/crates/ui-macros/tests/fixtures/registry/root.rs new file mode 100644 index 000000000..9a84b5118 --- /dev/null +++ b/crates/ui-macros/tests/fixtures/registry/root.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "sample")] +mod child; diff --git a/crates/ui-panels/src/dialog/mod.rs b/crates/ui-panels/src/dialog/mod.rs index ca828462c..13b220910 100644 --- a/crates/ui-panels/src/dialog/mod.rs +++ b/crates/ui-panels/src/dialog/mod.rs @@ -2,24 +2,24 @@ //! configurations (`Alert`, `StandardPrompt`, `UnsavedChangesDialog`, `RecoveryDialog`) and the values an app routes //! its dialogs by (`DialogStack`, `DialogHost`). Form dialogs build on the shells. -mod alert; -mod blocking; +pub(crate) mod alert; +pub(crate) mod blocking; #[doc(hidden)] pub mod frame; mod held; mod host; -mod modal; -mod prompt; -mod prompts; -mod recovery; +pub(crate) mod modal; +pub(crate) mod prompt; +pub(crate) mod prompts; +pub(crate) mod recovery; mod serde_fields; mod stack; #[cfg(feature = "suite")] #[doc(hidden)] pub mod stories; #[cfg(feature = "suite")] -mod trials; -mod unsaved; +pub(crate) mod trials; +pub(crate) mod unsaved; mod words; pub use alert::{Alert, AlertOutput, HostedAlert}; diff --git a/crates/ui-panels/src/dialog/prompt.rs b/crates/ui-panels/src/dialog/prompt.rs index 1a793086e..d9e890628 100644 --- a/crates/ui-panels/src/dialog/prompt.rs +++ b/crates/ui-panels/src/dialog/prompt.rs @@ -15,7 +15,7 @@ use craft_theme::variant::Tone; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// One answer of a prompt before its button exists: the label, what the button means, whether it has a letter and /// whether it is available. diff --git a/crates/ui-panels/src/docking/dock_column.rs b/crates/ui-panels/src/docking/dock_column.rs index 75b3e6197..79c290a81 100644 --- a/crates/ui-panels/src/docking/dock_column.rs +++ b/crates/ui-panels/src/docking/dock_column.rs @@ -23,7 +23,7 @@ use egui::{Context, Id, Pos2, Rect, Response, Ui}; use std::hash::Hash; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod bar; mod sizing; diff --git a/crates/ui-panels/src/docking/floating.rs b/crates/ui-panels/src/docking/floating.rs index a78f1511c..8794d48b8 100644 --- a/crates/ui-panels/src/docking/floating.rs +++ b/crates/ui-panels/src/docking/floating.rs @@ -32,7 +32,7 @@ use std::cell::RefCell; use std::hash::Hash; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The height of a floating group's title row: a strong `TitleRow`, which is as tall as a panel header. pub(crate) fn title_row(tokens: &UiTokens) -> f32 { diff --git a/crates/ui-panels/src/docking/iconic.rs b/crates/ui-panels/src/docking/iconic.rs index d70fbec11..eead14a11 100644 --- a/crates/ui-panels/src/docking/iconic.rs +++ b/crates/ui-panels/src/docking/iconic.rs @@ -27,9 +27,9 @@ use egui::{Id, Pos2, Rect, Response, Ui, Vec2}; use std::hash::Hash; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; #[cfg(feature = "suite")] -mod trials; +pub(crate) mod trials; const CELL: PartKey = PartKey::new("cell"); const NAME: PartKey = PartKey::new("name"); diff --git a/crates/ui-panels/src/docking/mod.rs b/crates/ui-panels/src/docking/mod.rs index d7c7b098a..1b8db176a 100644 --- a/crates/ui-panels/src/docking/mod.rs +++ b/crates/ui-panels/src/docking/mod.rs @@ -9,20 +9,20 @@ pub mod divider; mod drop; mod event; pub mod frame; -mod group; +pub(crate) mod group; -mod floating; +pub(crate) mod floating; mod panels; mod placed; -mod root; +pub(crate) mod root; mod spec; -mod splitter; +pub(crate) mod splitter; pub mod stack; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub mod targets; pub mod tree; -mod window_menu; +pub(crate) mod window_menu; mod words; mod commands; @@ -53,9 +53,9 @@ pub use commands::{ dock_states, move_actions, run_workspace, workspace_states, }; -mod dock_column; +pub(crate) mod dock_column; mod flyout; -mod iconic; +pub(crate) mod iconic; pub use dock_column::{ ColumnArrow, ColumnBar, DockColumn, DockColumnOutput, DockColumnStyle, GroupSize, GroupView, column_cells, fit_widths, group_heights, diff --git a/crates/ui-panels/src/docking/root.rs b/crates/ui-panels/src/docking/root.rs index 0a3b07b56..649ca0ce7 100644 --- a/crates/ui-panels/src/docking/root.rs +++ b/crates/ui-panels/src/docking/root.rs @@ -14,7 +14,7 @@ use craft_behavior::{Metrics, Sense}; use egui::Response; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a dock root: the docking sizes of its drop bands, columns, groups and floating windows. Colours, /// surfaces and shapes belong to the parts the pattern assembles. diff --git a/crates/ui-panels/src/lib.rs b/crates/ui-panels/src/lib.rs index 57873fae1..bcfd0e8df 100644 --- a/crates/ui-panels/src/lib.rs +++ b/crates/ui-panels/src/lib.rs @@ -9,11 +9,11 @@ // The derives' output names the crate as `craft_ui`, here as in every other crate. extern crate self as craft_ui; +#[cfg(feature = "testing")] +pub use craft_ui_widgets::registry; #[cfg(feature = "suite")] #[doc(hidden)] pub use craft_ui_widgets::story_kit; -#[cfg(feature = "testing")] -pub use craft_ui_widgets::testing_registered; #[doc(hidden)] pub use craft_ui_widgets::{__private, __register_command_set, __register_contract, __register_pattern}; pub use craft_ui_widgets::{InstallError, InstallSpec, contract, fonts, install, layout, primitives, runtime, style, words}; @@ -44,5 +44,5 @@ pub mod testing { } #[cfg(feature = "suite")] - crate::testing_registered!(); + crate::registry!(); } diff --git a/crates/ui-panels/src/rails/drawer.rs b/crates/ui-panels/src/rails/drawer.rs index 1fcba24ff..24cec62d9 100644 --- a/crates/ui-panels/src/rails/drawer.rs +++ b/crates/ui-panels/src/rails/drawer.rs @@ -25,7 +25,7 @@ use egui::{Rect, Response, Ui}; use std::borrow::Cow; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// A group of the drawer: a heading over the tools that belong under it. #[derive(Clone, Debug)] diff --git a/crates/ui-panels/src/rails/flyout.rs b/crates/ui-panels/src/rails/flyout.rs index 64577d9d1..bbe4c86c6 100644 --- a/crates/ui-panels/src/rails/flyout.rs +++ b/crates/ui-panels/src/rails/flyout.rs @@ -16,7 +16,7 @@ use craft_behavior::{HitLevel, HitPriority, IconId, Metrics, PartKey, PointerBut use egui::{Rect, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The face over the whole button. const FACE: PartKey = PartKey::new("face"); diff --git a/crates/ui-panels/src/rails/mod.rs b/crates/ui-panels/src/rails/mod.rs index ec22c322f..200b991b8 100644 --- a/crates/ui-panels/src/rails/mod.rs +++ b/crates/ui-panels/src/rails/mod.rs @@ -3,11 +3,11 @@ mod words; // The Edit Toolbar drawer. -mod drawer; +pub(crate) mod drawer; // The tool rail and its flyout button. -mod flyout; -mod tool; +pub(crate) mod flyout; +pub(crate) mod tool; pub use drawer::{DrawerGroup, ToolbarDrawer, ToolbarDrawerOutput, ToolbarEdit, apply_toolbar_edit, drop_edit}; pub use flyout::{FlyoutButton, FlyoutButtonStyle, FlyoutOutput, SlotEdit}; diff --git a/crates/ui-panels/src/rails/tool.rs b/crates/ui-panels/src/rails/tool.rs index 94db961fa..5a3adb324 100644 --- a/crates/ui-panels/src/rails/tool.rs +++ b/crates/ui-panels/src/rails/tool.rs @@ -24,9 +24,9 @@ use egui::{Response, Ui, Vec2}; mod data; mod drag; #[cfg(feature = "suite")] -pub(super) mod stories; +pub(crate) mod stories; #[cfg(feature = "suite")] -mod trials; +pub(crate) mod trials; use data::row_groups; pub use data::{LastUsed, RailTool, SlotId, ToolSlot, remembered, shown_tool, visible_slots}; diff --git a/crates/ui-panels/src/sections/footer.rs b/crates/ui-panels/src/sections/footer.rs index 8b579722a..7b807caf6 100644 --- a/crates/ui-panels/src/sections/footer.rs +++ b/crates/ui-panels/src/sections/footer.rs @@ -26,7 +26,7 @@ use std::fmt; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a footer bar. A bar of panel actions sits under a divider rule along its top edge, with the control /// padding above and under its buttons; other bars have no look of their own. diff --git a/crates/ui-panels/src/sections/group_box.rs b/crates/ui-panels/src/sections/group_box.rs index fcb41e24b..16889d707 100644 --- a/crates/ui-panels/src/sections/group_box.rs +++ b/crates/ui-panels/src/sections/group_box.rs @@ -11,7 +11,7 @@ use craft_behavior::{Metrics, Sense}; use egui::Ui; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The heading level AccessKit reports for a section header. pub(super) const SECTION_LEVEL: usize = 3; diff --git a/crates/ui-panels/src/sections/mod.rs b/crates/ui-panels/src/sections/mod.rs index fc85268b7..f133bfb13 100644 --- a/crates/ui-panels/src/sections/mod.rs +++ b/crates/ui-panels/src/sections/mod.rs @@ -1,16 +1,16 @@ //! Sections and title rows: `TitleRow`, `FooterBar`, `Section`, `GroupBox` and `Panel`. pub(crate) mod footer; -mod group_box; +pub(crate) mod group_box; #[cfg(feature = "suite")] mod sample; -mod section; -mod stack; -mod title_row; +pub(crate) mod section; +pub(crate) mod stack; +pub(crate) mod title_row; mod words; // Panel. -mod panel; +pub(crate) mod panel; pub use footer::{DialogRole, DropAction, DropActionOutput, DropActionStyle, FooterAction, FooterBar, FooterButton, FooterDrop, FooterOutput}; pub use group_box::{GroupBox, GroupBoxStyle}; @@ -25,7 +25,7 @@ pub use panel::{Panel, PanelOutput, PanelStyle}; // Reorderable sections. mod layout; -mod reorderable; +pub(crate) mod reorderable; pub use layout::{SectionEvent, SectionKey, SectionLayout, SectionState}; pub use reorderable::{ReorderableSections, ReorderableSectionsOutput, SectionButton, SectionCommands, SectionSpec}; diff --git a/crates/ui-panels/src/sections/panel.rs b/crates/ui-panels/src/sections/panel.rs index ec1dd4cbb..5998fd123 100644 --- a/crates/ui-panels/src/sections/panel.rs +++ b/crates/ui-panels/src/sections/panel.rs @@ -19,7 +19,7 @@ use craft_behavior::{Metrics, Sense}; use egui::{CornerRadius, Id, Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a panel: the surface and padding come from the container. #[derive(Clone, Debug, PartialEq, ComponentStyle)] diff --git a/crates/ui-panels/src/sections/reorderable.rs b/crates/ui-panels/src/sections/reorderable.rs index 2de08e6fe..f2690e3ef 100644 --- a/crates/ui-panels/src/sections/reorderable.rs +++ b/crates/ui-panels/src/sections/reorderable.rs @@ -17,7 +17,7 @@ use std::cell::RefCell; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The commands of a section, run on the section that holds the focus: its header menu rows and any chord the keymap /// binds. Showing a hidden section is a row of the menu, one per section, because a hidden section cannot hold focus. diff --git a/crates/ui-panels/src/sections/section.rs b/crates/ui-panels/src/sections/section.rs index d9ac2829a..9bb18b6f1 100644 --- a/crates/ui-panels/src/sections/section.rs +++ b/crates/ui-panels/src/sections/section.rs @@ -16,7 +16,7 @@ use craft_behavior::{Metrics, PointerButton, PressPhase, Sense}; use egui::{Id, Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a section: no surface or padding of its own; the header and body carry the look. #[derive(Clone, Debug, Default, PartialEq, ComponentStyle)] diff --git a/crates/ui-panels/src/sections/stack.rs b/crates/ui-panels/src/sections/stack.rs index 6b70b0bf7..1fbe44a87 100644 --- a/crates/ui-panels/src/sections/stack.rs +++ b/crates/ui-panels/src/sections/stack.rs @@ -16,7 +16,7 @@ use egui::{Pos2, Rect, Response, Ui}; use std::sync::{Arc, Mutex, PoisonError}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// What a section of a stack is told about its place: `Section::in_stack` reads it. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/ui-panels/src/sections/title_row.rs b/crates/ui-panels/src/sections/title_row.rs index a6b17e9ea..dfbfd4a5a 100644 --- a/crates/ui-panels/src/sections/title_row.rs +++ b/crates/ui-panels/src/sections/title_row.rs @@ -21,7 +21,7 @@ use craft_theme::{ControlSize, Stateful, States}; use egui::{Id, Rect, Response, Ui, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// How much weight a header carries. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] diff --git a/crates/ui-panels/tests/it/access/mod.rs b/crates/ui-panels/tests/it/access/mod.rs index 265795b2d..ff516ed39 100644 --- a/crates/ui-panels/tests/it/access/mod.rs +++ b/crates/ui-panels/tests/it/access/mod.rs @@ -1,3 +1,3 @@ //! The accessibility emitter: the label scope and merge rule, announcements, modal inertness, viewports. -mod modal_inert; +pub(crate) mod modal_inert; diff --git a/crates/ui-panels/tests/it/body/mod.rs b/crates/ui-panels/tests/it/body/mod.rs index b8af0f714..bf7e06cbe 100644 --- a/crates/ui-panels/tests/it/body/mod.rs +++ b/crates/ui-panels/tests/it/body/mod.rs @@ -1,4 +1,4 @@ //! The body step and the mount host: regions, scrolling, move and resize, and viewport mounts. -mod after_label; -mod footer_reserve; +pub(crate) mod after_label; +pub(crate) mod footer_reserve; diff --git a/crates/ui-panels/tests/it/edit/mod.rs b/crates/ui-panels/tests/it/edit/mod.rs index 15c21ab99..fa219de8b 100644 --- a/crates/ui-panels/tests/it/edit/mod.rs +++ b/crates/ui-panels/tests/it/edit/mod.rs @@ -1,3 +1,3 @@ //! The edit mechanism across components: a dialog's outer gesture over its fields. -mod outer; +pub(crate) mod outer; diff --git a/crates/ui-panels/tests/it/focus/mod.rs b/crates/ui-panels/tests/it/focus/mod.rs index 280fca926..fd2552ac9 100644 --- a/crates/ui-panels/tests/it/focus/mod.rs +++ b/crates/ui-panels/tests/it/focus/mod.rs @@ -1,10 +1,10 @@ //! The focus service and the key stage, driven through registered stops over real egui widgets. -mod dialog_tab; -mod keys; -mod press; -mod roving; -mod scopes; +pub(crate) mod dialog_tab; +pub(crate) mod keys; +pub(crate) mod press; +pub(crate) mod roving; +pub(crate) mod scopes; use craft_behavior::Input; use craft_ui::runtime::focus::{FocusTarget, KeyUse, request}; diff --git a/crates/ui-panels/tests/it/list/mod.rs b/crates/ui-panels/tests/it/list/mod.rs index f79e25f25..91f44c194 100644 --- a/crates/ui-panels/tests/it/list/mod.rs +++ b/crates/ui-panels/tests/it/list/mod.rs @@ -1,3 +1,3 @@ //! The `List` component's own settings, over the item step. -mod row_trailing; +pub(crate) mod row_trailing; diff --git a/crates/ui-panels/tests/it/main.rs b/crates/ui-panels/tests/it/main.rs index 1a8ff8e60..70872c8f4 100644 --- a/crates/ui-panels/tests/it/main.rs +++ b/crates/ui-panels/tests/it/main.rs @@ -3,23 +3,23 @@ // The test files name the library as `craft_ui`, as the crates that use it do. extern crate craft_ui_panels as craft_ui; -mod access; +pub(crate) mod access; pub(crate) mod body; -mod dialogs; -mod dock_group; +pub(crate) mod dialogs; +pub(crate) mod dock_group; // outer edit -mod edit; +pub(crate) mod edit; // end of outer edit -mod focus; -mod internals; -mod list; -mod popup_surface; +pub(crate) mod focus; +pub(crate) mod internals; +pub(crate) mod list; +pub(crate) mod popup_surface; -mod rails; -mod sections; +pub(crate) mod rails; +pub(crate) mod sections; -use craft_ui::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register, craft_ui::testing::register])); } diff --git a/crates/ui-panels/tests/it/popup_surface.rs b/crates/ui-panels/tests/it/popup_surface.rs index 74e00aa8e..2e136e6a0 100644 --- a/crates/ui-panels/tests/it/popup_surface.rs +++ b/crates/ui-panels/tests/it/popup_surface.rs @@ -2,7 +2,7 @@ //! a layer or a component shows it from its `overlay` hook, and whatever its body paints itself. Its content sits //! inside the popup padding, and a popup beside its owner does not cover it. -use craft_ui::testing::{Drive, Fixture, stories, trial}; +use craft_ui::testing::{Drive, Fixture, Registry, trial}; use egui::{Rect, Shape}; /// Each story, opened by its drive, with a text only its popup shows. @@ -19,7 +19,8 @@ const OPEN: [(&str, &str); 4] = [ /// The story `name`, opened by its drive, and the shapes of the frame after it settled. fn open(name: &str) -> (Fixture, Vec) { - let entry = stories().into_iter().find(|entry| entry.story.name == name).unwrap_or_else(|| panic!("story {name}")); + let registry = Registry::of(&[craft_ui::testing::register, craft_ui_widgets::testing::register]); + let entry = registry.stories().iter().find(|entry| entry.story.name == name).unwrap_or_else(|| panic!("story {name}")); let mut fixture = Fixture::story(&entry.story); fixture.settle(); if let Drive::Custom(open) = entry.story.drive { diff --git a/crates/ui-panels/tests/it/rails/drawer.rs b/crates/ui-panels/tests/it/rails/drawer.rs index b99eb3629..c5b1a7e5a 100644 --- a/crates/ui-panels/tests/it/rails/drawer.rs +++ b/crates/ui-panels/tests/it/rails/drawer.rs @@ -4,7 +4,7 @@ use craft_ui::rails::{DropAt, RailTool, ToolSlot, ToolbarEdit, apply_toolbar_edit}; use craft_ui::runtime::commands::EditCommands; use craft_ui::runtime::drag; -use craft_ui::testing::{Fixture, stories, trial}; +use craft_ui::testing::{Fixture, Registry, trial}; use egui::Vec2; const UNDO: u8 = 1; @@ -74,7 +74,8 @@ fn closing_the_drawer_returns_the_focus_to_the_rails_edit_toolbar_button() { /// A tool already on the toolbar is dimmed and does not drag; a tool that is not on it drags to the rail. #[trial] fn only_a_tool_off_the_toolbar_drags() { - let entry = stories().into_iter().find(|entry| entry.story.name == "toolbar_drawer").expect("the drawer story"); + let registry = Registry::of(&[craft_ui::testing::register]); + let entry = registry.stories().iter().find(|entry| entry.story.name == "toolbar_drawer").expect("the drawer story"); let mut fixture = Fixture::story(&entry.story); fixture.settle(); let opener = fixture.by_label("Edit Toolbar").expect("the rail's Edit Toolbar button"); diff --git a/crates/ui-panels/tests/it/rails/mod.rs b/crates/ui-panels/tests/it/rails/mod.rs index 0ac0f8473..4c9ba1d0d 100644 --- a/crates/ui-panels/tests/it/rails/mod.rs +++ b/crates/ui-panels/tests/it/rails/mod.rs @@ -1,7 +1,7 @@ //! The rail's own logic: which tool a slot shows, what the rail remembers, where a drop goes, and the flyout's hold //! and click, and a press dragged away. -mod drawer; +pub(crate) mod drawer; use craft_ui::contract::{Role, Show as _}; use craft_ui::rails::{FlyoutButton, RailTool}; diff --git a/crates/ui-panels/tests/it/sections/mod.rs b/crates/ui-panels/tests/it/sections/mod.rs index 60c7053e2..25895f61f 100644 --- a/crates/ui-panels/tests/it/sections/mod.rs +++ b/crates/ui-panels/tests/it/sections/mod.rs @@ -1,8 +1,8 @@ //! Sections: captions, footers, panel headers and reorderable sections. -mod caption; -mod footer_keys; -mod footer_row; -mod layout; -mod panel_header; -mod reorderable; +pub(crate) mod caption; +pub(crate) mod footer_keys; +pub(crate) mod footer_row; +pub(crate) mod layout; +pub(crate) mod panel_header; +pub(crate) mod reorderable; diff --git a/crates/ui-patterns/Cargo.toml b/crates/ui-patterns/Cargo.toml index a7e70a5b6..f55ef4892 100644 --- a/crates/ui-patterns/Cargo.toml +++ b/crates/ui-patterns/Cargo.toml @@ -44,7 +44,7 @@ zeroize = "1.9" craft-ui-patterns = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-theme = { workspace = true } -craft-ui-test-kit = { workspace = true } +craft-ui-test-kit = { workspace = true, features = ["suite"] } egui = { workspace = true } serde = { workspace = true } diff --git a/crates/ui-patterns/src/lib.rs b/crates/ui-patterns/src/lib.rs index cd7982b15..ca8b46907 100644 --- a/crates/ui-patterns/src/lib.rs +++ b/crates/ui-patterns/src/lib.rs @@ -10,11 +10,11 @@ extern crate self as craft_ui; #[doc(hidden)] pub use craft_ui_panels::canvas_data; +#[cfg(feature = "testing")] +pub use craft_ui_panels::registry; #[cfg(feature = "suite")] #[doc(hidden)] pub use craft_ui_panels::story_kit; -#[cfg(feature = "testing")] -pub use craft_ui_panels::testing_registered; #[doc(hidden)] pub use craft_ui_panels::{__private, __register_command_set, __register_contract, __register_pattern}; pub use craft_ui_panels::{InstallError, InstallSpec, contract, fonts, install, layout, primitives, runtime, style, words}; @@ -32,5 +32,5 @@ pub mod testing { pub use craft_ui_panels::testing::*; #[cfg(feature = "suite")] - crate::testing_registered!(); + crate::registry!(); } diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index 7a7e50121..72ccb3ce0 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -36,7 +36,7 @@ use std::hash::Hash; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// A layout the dock cannot show: the workspace failed `Workspace::validate`. The area draws nothing for it. #[derive(Clone, Debug, PartialEq)] diff --git a/crates/ui-patterns/src/patterns/dock/mod.rs b/crates/ui-patterns/src/patterns/dock/mod.rs index ab247d2d6..840e578d9 100644 --- a/crates/ui-patterns/src/patterns/dock/mod.rs +++ b/crates/ui-patterns/src/patterns/dock/mod.rs @@ -2,12 +2,12 @@ mod words; -mod area; +pub(crate) mod area; mod hide; -mod switcher; -mod workspace_dialogs; +pub(crate) mod switcher; +pub(crate) mod workspace_dialogs; // Task panes: docked panes as shell panes, floating panes as floating frames. -mod panes; +pub(crate) mod panes; pub use area::{DockArea, DockAreaOutput, InvalidGeometry}; pub use panes::{ diff --git a/crates/ui-patterns/src/patterns/dock/panes.rs b/crates/ui-patterns/src/patterns/dock/panes.rs index ed31d02a5..b504ce68f 100644 --- a/crates/ui-patterns/src/patterns/dock/panes.rs +++ b/crates/ui-patterns/src/patterns/dock/panes.rs @@ -30,7 +30,7 @@ use std::fmt::Debug; use std::hash::Hash; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Where a pane is shown. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/ui-patterns/src/patterns/dock/switcher.rs b/crates/ui-patterns/src/patterns/dock/switcher.rs index a3bb100ff..f6e067c7d 100644 --- a/crates/ui-patterns/src/patterns/dock/switcher.rs +++ b/crates/ui-patterns/src/patterns/dock/switcher.rs @@ -1,7 +1,7 @@ //! `WorkspaceSwitcher`: a select over the workspace set's names with the workspace commands in its list. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use crate::contract::{Bind, Entry, NoValue, Outcome, Props as _, Show as _, Sizing}; use crate::display::Divider; diff --git a/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs b/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs index 8d744fd80..fdfa8862b 100644 --- a/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs +++ b/crates/ui-patterns/src/patterns/dock/workspace_dialogs.rs @@ -2,7 +2,7 @@ //! and `WorkspaceAsk::Which`. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::words::WorkspaceDialogWords; use crate::choice::Checkbox; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/about.rs b/crates/ui-patterns/src/patterns/form_dialogs/about.rs index 4a695dbe0..1e150d1ec 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/about.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/about.rs @@ -4,7 +4,7 @@ mod contributors; mod credits; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use contributors::{CommitShare, ContributorSort, NameMode}; pub use credits::{AboutInfo, AboutLink, Contributor, Credits, ModelCredit}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs index e9faf5ab0..7e115e971 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/dialog.rs @@ -41,7 +41,7 @@ use serde_json::Value; use std::borrow::Cow; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The words of the parameter dialog beside the common OK and Cancel. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/export.rs b/crates/ui-patterns/src/patterns/form_dialogs/export.rs index 1d18124f0..8cb0d5fbd 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/export.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/export.rs @@ -4,12 +4,12 @@ //! //! [`export_file_name`] is the pure file-name rule the export dialogs share. -mod as_dialog; -mod options; -mod path_row; +pub(crate) mod as_dialog; +pub(crate) mod options; +pub(crate) mod path_row; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::PreviewRequest; use crate::contract::SaveKey; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/file_list.rs b/crates/ui-patterns/src/patterns/form_dialogs/file_list.rs index eb0e09586..65b8a0221 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/file_list.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/file_list.rs @@ -21,7 +21,7 @@ use std::cell::RefCell; use std::path::{Path, PathBuf}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The list shows this many rows, then scrolls. const LIST_ROWS: u16 = 6; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/form.rs b/crates/ui-patterns/src/patterns/form_dialogs/form.rs index ebaa05092..000f4dc3a 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/form.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/form.rs @@ -31,7 +31,7 @@ use std::rc::Rc; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The words a form dialog adds beside the common OK and Cancel. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/guides.rs b/crates/ui-patterns/src/patterns/form_dialogs/guides.rs index 70e260d73..75712a5fa 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/guides.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/guides.rs @@ -8,12 +8,12 @@ //! the same `canvas::Guide`s. mod layout; -mod new_guide; +pub(crate) mod new_guide; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; #[cfg(feature = "suite")] -mod trials; +pub(crate) mod trials; pub use layout::{GuideGroup, GuideLayoutError, GuideLayoutOptions, GuideLayoutPreset, GuideLength, GuideRect, GuideTarget, GuideUnits, MAX_COUNT}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs b/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs index 5a68a116a..3dfaf144e 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/list_manager.rs @@ -21,7 +21,7 @@ use std::borrow::Cow; use std::cell::{Cell, RefCell}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The standard words of the list manager; the app's own actions bring their labels. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/mod.rs b/crates/ui-patterns/src/patterns/form_dialogs/mod.rs index 01076d86e..29947cbbf 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/mod.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/mod.rs @@ -4,18 +4,18 @@ mod words; mod fields; mod param; -mod rows; +pub(crate) mod rows; pub use fields::{DialogFields, FieldValue}; pub use param::{CustomContext, CustomRow, NumberUnit, Param, ParamKind, encode, open_fields, set_color_field}; pub use rows::{ParamRows, ParamRowsOutput}; pub use words::ParamWords; -mod dialog; -mod form; +pub(crate) mod dialog; +pub(crate) mod form; mod host_requests; -mod path_row; -mod preview; +pub(crate) mod path_row; +pub(crate) mod preview; pub use dialog::{ BelowRows, HostedParamDialog, ParamDialog, ParamDialogOutput, ParamDialogWords, ParamLayout, ParamResult, ResetFooter, ResetPick, set_param_field, @@ -31,26 +31,26 @@ mod size_model; pub use size_model::{LinkedSize, MAX_DOCUMENT_SIDE, SizeError, resize_from_scale, resize_from_side}; -mod list_manager; -mod password; -mod report; +pub(crate) mod list_manager; +pub(crate) mod password; +pub(crate) mod report; pub use list_manager::{ActionEnabled, ListManager, ListManagerAction, ListManagerChoice, ListManagerEntry, ListManagerOutput, ListManagerWords}; pub use password::{PasswordAnswer, PasswordDialog, PasswordOutput, PasswordPurpose, PasswordStrength, PasswordWords, Secret}; pub use report::{HostedReport, ReportDialog, ReportNote, ReportOutput, ReportWords}; -mod file_list; +pub(crate) mod file_list; pub use file_list::{FileList, FileListMode, FileListPicker, FileListPickerOutput, FileListWords}; -mod sizing; +pub(crate) mod sizing; pub use sizing::{ CanvasExtension, CanvasSize, CanvasSizeOutput, CanvasSizeResult, CanvasSizeValues, HostedCanvasSize, HostedImageSize, ImageSize, ImageSizeOutput, ImageSizeResult, ImageSizeValues, Resample, SizingOutput, SizingWords, }; -mod new_document; +pub(crate) mod new_document; pub use new_document::{ BACKGROUND_COLOR_KEY, BackgroundContents, BitDepth, ColorMode, ColorProfiles, DocumentOptions, DocumentPreset, HostedNewDocument, @@ -58,7 +58,7 @@ pub use new_document::{ SQUARE_PIXELS, }; -mod about; +pub(crate) mod about; pub use about::{ AboutDialog, AboutInfo, AboutLink, AboutOutput, AboutTab, AboutWords, CommitShare, Contributor, ContributorSort, Credits, HostedAbout, @@ -66,8 +66,8 @@ pub use about::{ }; mod color_choice; -mod guides; -mod properties; +pub(crate) mod guides; +pub(crate) mod properties; pub use guides::{ GUIDE_LAYOUT_COLOR_KEY, GuideDialogWords, GuideGroup, GuideLayoutDialog, GuideLayoutError, GuideLayoutOptions, GuideLayoutOutput, @@ -77,12 +77,12 @@ pub use guides::{ pub use properties::{HostedPropertiesDialog, PropertiesDialog, PropertiesOutput, PropertiesTab, PropertyRow}; // canvas-navigator-a -mod navigator_options; +pub(crate) mod navigator_options; pub use navigator_options::{NAVIGATOR_PROXY_COLOR_KEY, NavigatorOptionsDialog, NavigatorOptionsDialogOutput, NavigatorOptionsWords}; // End of canvas-navigator-a. -mod export; +pub(crate) mod export; pub use export::{ DdsCompression, DdsOptions, ExportAsDialog, ExportAsOutput, ExportAsResult, ExportFormat, ExportFormatDefaults, ExportMetadata, ExportOptions, @@ -92,12 +92,12 @@ pub use export::{ }; // Save PDF. -mod pdf_export; +pub(crate) mod pdf_export; pub use pdf_export::{PdfArtboards, PdfExportDialog, PdfExportOutput, PdfExportResult, PdfExportWords, PdfPresetEvent, PdfSection, RangeError}; -mod save_for_web; -mod watermark; +pub(crate) mod save_for_web; +pub(crate) mod watermark; pub use save_for_web::{ Animation, ColorTable, Dither, HostedSaveForWeb, MATTE_COLOR_KEY, PALETTE_COLOR_KEY, SAVE_PATH_KEY, SaveForWebDialog, SaveForWebOptions, diff --git a/crates/ui-patterns/src/patterns/form_dialogs/navigator_options.rs b/crates/ui-patterns/src/patterns/form_dialogs/navigator_options.rs index 29792fa9d..0b3ed9294 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/navigator_options.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/navigator_options.rs @@ -15,7 +15,7 @@ use crate::runtime::overlay::CloseReason; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The [`ColorRequest::key`](crate::runtime::requests::ColorRequest::key) of Panel Options' Custom… colour. pub const NAVIGATOR_PROXY_COLOR_KEY: &str = "navigatorOptionsDialog.proxyColor"; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs b/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs index 00f53921e..80898c530 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/new_document.rs @@ -5,7 +5,7 @@ mod cards; mod details; mod presets; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::form::{read_bind, write_bind}; use super::{FormCx, FormDialog, HostRequests, LinkedSize}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/password.rs b/crates/ui-patterns/src/patterns/form_dialogs/password.rs index 14f07a8dd..892338c1c 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/password.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/password.rs @@ -22,7 +22,7 @@ use std::cell::{Cell, RefCell}; use std::fmt; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The words of the password dialog beside the common Cancel. `{name}` is the file's name, `{strength}` one of diff --git a/crates/ui-patterns/src/patterns/form_dialogs/path_row.rs b/crates/ui-patterns/src/patterns/form_dialogs/path_row.rs index 8748183a4..79455ccc0 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/path_row.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/path_row.rs @@ -1,7 +1,7 @@ //! `PathRow`: a path typed in a text field, with a Browse button that asks the host to pick one. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use crate::buttons::Button; use crate::contract::{Bind, NoValue, Outcome, Props as _, Remember as _, Show as _, ShowContainer as _, Sizing, clicked}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/pdf_export.rs b/crates/ui-patterns/src/patterns/form_dialogs/pdf_export.rs index a3992f27f..aa61d5668 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/pdf_export.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/pdf_export.rs @@ -5,7 +5,7 @@ mod summary; mod words; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use self::sections::{ArtboardChoice, PasswordSwitches, Sections}; pub use self::summary::RangeError; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/preview.rs b/crates/ui-patterns/src/patterns/form_dialogs/preview.rs index da68bc79b..aa9960727 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/preview.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/preview.rs @@ -22,7 +22,7 @@ use egui::{Pos2, Rect, Response, Ui, Vec2, pos2}; use std::ops::RangeInclusive; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The well: a drag on it pans the picture and a click centres the view on the point clicked. const WELL: PartKey = PartKey::new("well"); diff --git a/crates/ui-patterns/src/patterns/form_dialogs/properties.rs b/crates/ui-patterns/src/patterns/form_dialogs/properties.rs index 69e596225..d3471211f 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/properties.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/properties.rs @@ -16,7 +16,7 @@ use std::borrow::Cow; use std::cell::RefCell; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// One row of a properties tab. #[derive(Clone, Debug, PartialEq)] diff --git a/crates/ui-patterns/src/patterns/form_dialogs/report.rs b/crates/ui-patterns/src/patterns/form_dialogs/report.rs index db3ed6040..f4ca45929 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/report.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/report.rs @@ -17,7 +17,7 @@ use egui::{Response, Ui}; use serde_json::{Value, json}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; craft_ui::words! { /// The words of the report dialog beside the common OK. diff --git a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs index b1995c608..88f4b8047 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs @@ -39,7 +39,7 @@ use std::path::PathBuf; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Where a grid or point row's numbers go: whole numbers have no decimals. const WHOLE: u32 = 0; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/save_for_web.rs b/crates/ui-patterns/src/patterns/form_dialogs/save_for_web.rs index 1732c1728..4d3dacc32 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/save_for_web.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/save_for_web.rs @@ -35,7 +35,7 @@ mod options; mod panes; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use panes::WebPane; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/sizing.rs b/crates/ui-patterns/src/patterns/form_dialogs/sizing.rs index 63ea9a59e..2789dde56 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/sizing.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/sizing.rs @@ -20,10 +20,10 @@ use egui::{Response, Ui}; use serde::{Deserialize, Serialize}; use std::sync::Arc; -mod canvas; -mod image; +pub(crate) mod canvas; +pub(crate) mod image; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use canvas::{CanvasSize, CanvasSizeOutput, CanvasSizeResult, CanvasSizeValues, HostedCanvasSize}; pub use image::{HostedImageSize, ImageSize, ImageSizeOutput, ImageSizeResult, ImageSizeValues}; diff --git a/crates/ui-patterns/src/patterns/form_dialogs/watermark.rs b/crates/ui-patterns/src/patterns/form_dialogs/watermark.rs index ee87b3599..43715cef4 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/watermark.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/watermark.rs @@ -26,7 +26,7 @@ use std::ops::RangeInclusive; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The key of the image request the Choose button files. pub const WATERMARK_IMAGE_KEY: &str = "watermark"; diff --git a/crates/ui-patterns/src/patterns/panels/history.rs b/crates/ui-patterns/src/patterns/panels/history.rs index 026ff0523..2fa88b508 100644 --- a/crates/ui-patterns/src/patterns/panels/history.rs +++ b/crates/ui-patterns/src/patterns/panels/history.rs @@ -21,7 +21,7 @@ use std::collections::HashSet; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The column of the source marks. const SOURCE: ColumnKey = ColumnKey::new("historySource"); diff --git a/crates/ui-patterns/src/patterns/panels/inspector.rs b/crates/ui-patterns/src/patterns/panels/inspector.rs index 1bfcf73f0..d4ede9326 100644 --- a/crates/ui-patterns/src/patterns/panels/inspector.rs +++ b/crates/ui-patterns/src/patterns/panels/inspector.rs @@ -10,7 +10,7 @@ use craft_theme::variant::Tone; use egui::{AsIdSalt, IdSalt, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// A properties panel: a `Panel` whose header names the target (icon and name, and the kind at the end), and whose body /// the caller fills with the target's controls, labelled as inspector rows (`LabelScheme::Inspector`). diff --git a/crates/ui-patterns/src/patterns/panels/mod.rs b/crates/ui-patterns/src/patterns/panels/mod.rs index 4e27681da..d64164112 100644 --- a/crates/ui-patterns/src/patterns/panels/mod.rs +++ b/crates/ui-patterns/src/patterns/panels/mod.rs @@ -3,20 +3,20 @@ mod words; // Inspector. -mod inspector; +pub(crate) mod inspector; pub use inspector::Inspector; // History and modifier keys. -mod history; -mod modifier_keys; +pub(crate) mod history; +pub(crate) mod modifier_keys; pub use history::{HistoryEvent, HistoryFooter, HistoryKey, HistoryPanel, HistoryPanelOutput, HistoryRow}; pub use modifier_keys::ModifierKeysPanel; // CommandPalette and Tour. -mod palette; -mod tour; +pub(crate) mod palette; +pub(crate) mod tour; pub use palette::{CommandPalette, PaletteOutput}; pub use tour::{Tour, TourEvent, TourOutput, TourStep}; diff --git a/crates/ui-patterns/src/patterns/panels/modifier_keys.rs b/crates/ui-patterns/src/patterns/panels/modifier_keys.rs index cfdf1c14b..723fc25e3 100644 --- a/crates/ui-patterns/src/patterns/panels/modifier_keys.rs +++ b/crates/ui-patterns/src/patterns/panels/modifier_keys.rs @@ -10,7 +10,7 @@ use egui::{Response, Ui}; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The panel's buttons in their fixed order, each with the one modifier it latches: Shift, the command key (⌘ on /// macOS, Ctrl elsewhere) and Alt (⌥ on macOS). diff --git a/crates/ui-patterns/src/patterns/panels/palette.rs b/crates/ui-patterns/src/patterns/panels/palette.rs index 494bb6f68..b9cd483c3 100644 --- a/crates/ui-patterns/src/patterns/panels/palette.rs +++ b/crates/ui-patterns/src/patterns/panels/palette.rs @@ -23,7 +23,7 @@ use std::hash::{Hash, Hasher}; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The most commands the empty query lists when the app has run none. const FIRST_ROWS: usize = 12; diff --git a/crates/ui-patterns/src/patterns/panels/tour.rs b/crates/ui-patterns/src/patterns/panels/tour.rs index 81c253cc3..a1e0c608a 100644 --- a/crates/ui-patterns/src/patterns/panels/tour.rs +++ b/crates/ui-patterns/src/patterns/panels/tour.rs @@ -20,7 +20,7 @@ use egui::{Rect, Ui}; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The keys of a tour: Right goes to the next step and Left back (the keymap mirrors them in a right-to-left /// interface). They belong to the tour that holds the focus. diff --git a/crates/ui-patterns/src/patterns/preferences/mod.rs b/crates/ui-patterns/src/patterns/preferences/mod.rs index b1875f352..425fea23f 100644 --- a/crates/ui-patterns/src/patterns/preferences/mod.rs +++ b/crates/ui-patterns/src/patterns/preferences/mod.rs @@ -25,9 +25,9 @@ pub use words::{PreferencesWords, SettingsDocumentWords}; // The window, its body and its rows. mod body; -mod path_setting; +pub(crate) mod path_setting; mod rows; -mod window; +pub(crate) mod window; pub use path_setting::{PathSetting, PathSettingOutput}; diff --git a/crates/ui-patterns/src/patterns/preferences/path_setting.rs b/crates/ui-patterns/src/patterns/preferences/path_setting.rs index 90ab8972a..4e961a1eb 100644 --- a/crates/ui-patterns/src/patterns/preferences/path_setting.rs +++ b/crates/ui-patterns/src/patterns/preferences/path_setting.rs @@ -1,7 +1,7 @@ //! `PathSetting`: a path setting of Preferences, typed or picked through the host's file service, kept in the draft. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::SettingsDraft; use crate::contract::{Bind, NoValue, Outcome, Props as _, ShowContainer as _}; diff --git a/crates/ui-patterns/src/patterns/preferences/window.rs b/crates/ui-patterns/src/patterns/preferences/window.rs index 5c880039f..533d7ac04 100644 --- a/crates/ui-patterns/src/patterns/preferences/window.rs +++ b/crates/ui-patterns/src/patterns/preferences/window.rs @@ -2,7 +2,7 @@ //! exist. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::body::{self, BodyOut}; use super::model::{Closed, PreferencesModel, PreferencesOutput}; diff --git a/crates/ui-patterns/src/patterns/presets/browser.rs b/crates/ui-patterns/src/patterns/presets/browser.rs index ead741bf4..c01396567 100644 --- a/crates/ui-patterns/src/patterns/presets/browser.rs +++ b/crates/ui-patterns/src/patterns/presets/browser.rs @@ -8,7 +8,7 @@ mod reorder; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use reorder::PresetReorder; diff --git a/crates/ui-patterns/src/patterns/presets/footer.rs b/crates/ui-patterns/src/patterns/presets/footer.rs index 61e35f26e..d5c4c946f 100644 --- a/crates/ui-patterns/src/patterns/presets/footer.rs +++ b/crates/ui-patterns/src/patterns/presets/footer.rs @@ -12,7 +12,7 @@ use std::marker::PhantomData; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// What a [`PresetFooter`] reports. A browser's footer reports these as `PresetEvent::Footer`, in order with its /// other events. diff --git a/crates/ui-patterns/src/patterns/presets/manager.rs b/crates/ui-patterns/src/patterns/presets/manager.rs index 12f7f2053..002936293 100644 --- a/crates/ui-patterns/src/patterns/presets/manager.rs +++ b/crates/ui-patterns/src/patterns/presets/manager.rs @@ -2,7 +2,7 @@ //! kind, with rename and delete, and the host's own action buttons. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::browser::PresetBrowser; use super::event::PresetEvent; diff --git a/crates/ui-patterns/src/patterns/presets/mod.rs b/crates/ui-patterns/src/patterns/presets/mod.rs index ccb51c5cf..e2ceac926 100644 --- a/crates/ui-patterns/src/patterns/presets/mod.rs +++ b/crates/ui-patterns/src/patterns/presets/mod.rs @@ -4,20 +4,20 @@ mod words; // The browser. -mod browser; +pub(crate) mod browser; // Preset data, footer, files and panel menu. mod event; mod files; -mod footer; +pub(crate) mod footer; mod model; mod panel_menu; mod state; // The picker and the named row. -mod manager; -mod named; -mod picker; +pub(crate) mod manager; +pub(crate) mod named; +pub(crate) mod picker; pub use browser::{BrowserTools, PresetBrowser, PresetItemCommands, PresetReorder, ThumbPainter}; pub use event::{PresetEvent, PresetOutput}; diff --git a/crates/ui-patterns/src/patterns/presets/named.rs b/crates/ui-patterns/src/patterns/presets/named.rs index e57be9646..31a90a641 100644 --- a/crates/ui-patterns/src/patterns/presets/named.rs +++ b/crates/ui-patterns/src/patterns/presets/named.rs @@ -6,7 +6,7 @@ //! keeps the prompt open. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::event::PresetEvent; use super::files::{PresetFileRequest, PresetFiles}; diff --git a/crates/ui-patterns/src/patterns/presets/picker.rs b/crates/ui-patterns/src/patterns/presets/picker.rs index 08a4e44e3..50891a12d 100644 --- a/crates/ui-patterns/src/patterns/presets/picker.rs +++ b/crates/ui-patterns/src/patterns/presets/picker.rs @@ -6,7 +6,7 @@ //! field (`open_at`) and let the user resize it (`resizable`). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use std::sync::Arc; diff --git a/crates/ui-patterns/tests/it/docking/mod.rs b/crates/ui-patterns/tests/it/docking/mod.rs index 2243f997e..fc021757c 100644 --- a/crates/ui-patterns/tests/it/docking/mod.rs +++ b/crates/ui-patterns/tests/it/docking/mod.rs @@ -4,27 +4,27 @@ use craft_theme::{Contrast, ControlSize, Mode, Variant}; use craft_ui::docking::DockSizes; use craft_ui::testing::style::{tokens, with_cx}; -mod render; +pub(crate) mod render; -mod panel_menu; -mod runs; +pub(crate) mod panel_menu; +pub(crate) mod runs; -mod split; +pub(crate) mod split; -mod drop; -mod drop_preview; -mod drop_session; +pub(crate) mod drop; +pub(crate) mod drop_preview; +pub(crate) mod drop_session; -mod floating; -mod floating_area; -mod hidden; +pub(crate) mod floating; +pub(crate) mod floating_area; +pub(crate) mod hidden; -mod columns; -mod dock_back; -mod group_view; -mod workspace_dialogs; +pub(crate) mod columns; +pub(crate) mod dock_back; +pub(crate) mod group_view; +pub(crate) mod workspace_dialogs; -mod native; +pub(crate) mod native; /// The docking sizes of the default theme with the given divider gap, least pane and strip height. fn sizes(gap: f32, least_pane: f32, strip: f32) -> DockSizes { diff --git a/crates/ui-patterns/tests/it/form_dialogs/mod.rs b/crates/ui-patterns/tests/it/form_dialogs/mod.rs index 44159cf68..336fb8a3e 100644 --- a/crates/ui-patterns/tests/it/form_dialogs/mod.rs +++ b/crates/ui-patterns/tests/it/form_dialogs/mod.rs @@ -1,15 +1,15 @@ //! The form dialogs' own logic: the parameter model, its spec-string parser, the value store, the size model, //! guide layout and the export file name. -mod about; -mod dialog; -mod export; -mod files; -mod hosted; -mod new_document; -mod params; -mod password; -mod preview; -mod preview_width; -mod save_for_web; -mod size_model; +pub(crate) mod about; +pub(crate) mod dialog; +pub(crate) mod export; +pub(crate) mod files; +pub(crate) mod hosted; +pub(crate) mod new_document; +pub(crate) mod params; +pub(crate) mod password; +pub(crate) mod preview; +pub(crate) mod preview_width; +pub(crate) mod save_for_web; +pub(crate) mod size_model; diff --git a/crates/ui-patterns/tests/it/main.rs b/crates/ui-patterns/tests/it/main.rs index 49919e6b6..a908cb179 100644 --- a/crates/ui-patterns/tests/it/main.rs +++ b/crates/ui-patterns/tests/it/main.rs @@ -3,18 +3,22 @@ // The test files name the library as `craft_ui`, as the crates that use it do. extern crate craft_ui_patterns as craft_ui; -mod blend_keys; -mod docking; -mod form_dialogs; +pub(crate) mod blend_keys; +pub(crate) mod docking; +pub(crate) mod form_dialogs; // Panels family. -mod panels; +pub(crate) mod panels; -mod preferences; -mod presets; +pub(crate) mod preferences; +pub(crate) mod presets; -use craft_ui::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run( + module_path!(), + env!("CARGO_PKG_NAME"), + &craft_ui::testing::Registry::of(&[register, craft_ui::testing::register, craft_ui_test_kit::testing::register]), + ); } diff --git a/crates/ui-patterns/tests/it/panels/mod.rs b/crates/ui-patterns/tests/it/panels/mod.rs index cad91f130..a02a16147 100644 --- a/crates/ui-patterns/tests/it/panels/mod.rs +++ b/crates/ui-patterns/tests/it/panels/mod.rs @@ -1,9 +1,9 @@ //! The rules of the panels family: an inspector keys its controls by the target and shows the empty notice for no //! target. -mod history; -mod palette; -mod tour; +pub(crate) mod history; +pub(crate) mod palette; +pub(crate) mod tour; use craft_ui::choice::Checkbox; use craft_ui::contract::{Bind, Props as _, Show as _}; diff --git a/crates/ui-patterns/tests/it/panels/palette.rs b/crates/ui-patterns/tests/it/panels/palette.rs index 9e233ad12..a1b8ab6bf 100644 --- a/crates/ui-patterns/tests/it/panels/palette.rs +++ b/crates/ui-patterns/tests/it/panels/palette.rs @@ -8,7 +8,7 @@ use craft_ui::patterns::panels::CommandPalette; use craft_ui::popover::Popover; use craft_ui::runtime::commands::{CommandRef, CommandState, EditCommands, FireSource}; use craft_ui::runtime::frame::take_output; -use craft_ui::testing::{Fixture, stories, trial}; +use craft_ui::testing::{Fixture, Registry, trial}; use egui::{Key, Modifiers, Ui}; use std::cell::{Cell, RefCell}; use std::rc::Rc; @@ -99,7 +99,8 @@ fn a_picked_command_runs_from_the_palette_and_comes_first_when_it_opens_again() /// lists enabled. #[trial] fn the_palette_story_runs_under_its_command_states() { - let entry = stories().into_iter().find(|entry| entry.story.name == "command_palette").expect("the palette story"); + let registry = Registry::of(&[craft_ui::testing::register]); + let entry = registry.stories().iter().find(|entry| entry.story.name == "command_palette").expect("the palette story"); let mut fixture = Fixture::story(&entry.story); fixture.settle(); assert!(disabled(&fixture, "Redo"), "the story's Redo lists disabled"); diff --git a/crates/ui-patterns/tests/it/preferences/mod.rs b/crates/ui-patterns/tests/it/preferences/mod.rs index d2b72df8f..b1a0e898b 100644 --- a/crates/ui-patterns/tests/it/preferences/mod.rs +++ b/crates/ui-patterns/tests/it/preferences/mod.rs @@ -1,5 +1,5 @@ //! The data and rules of the preferences family: the search over the row model and the settings document, the //! window's answers and the hex codec. -mod model; -mod path_setting; +pub(crate) mod model; +pub(crate) mod path_setting; diff --git a/crates/ui-patterns/tests/it/presets/mod.rs b/crates/ui-patterns/tests/it/presets/mod.rs index 25a1c8158..33bf20d0d 100644 --- a/crates/ui-patterns/tests/it/presets/mod.rs +++ b/crates/ui-patterns/tests/it/presets/mod.rs @@ -1,6 +1,6 @@ //! The data and rules of the presets family. -mod browser; -mod model; -mod named; -mod picker; +pub(crate) mod browser; +pub(crate) mod model; +pub(crate) mod named; +pub(crate) mod picker; diff --git a/crates/ui-shell/Cargo.toml b/crates/ui-shell/Cargo.toml index 828982e81..cef43c27e 100644 --- a/crates/ui-shell/Cargo.toml +++ b/crates/ui-shell/Cargo.toml @@ -50,7 +50,7 @@ craft-ui-shell = { path = ".", features = ["suite"] } craft-behavior = { workspace = true } craft-host = { workspace = true } craft-theme = { workspace = true } -craft-ui-test-kit = { workspace = true } +craft-ui-test-kit = { workspace = true, features = ["suite"] } craft-window = { workspace = true } egui = { workspace = true } diff --git a/crates/ui-shell/src/lib.rs b/crates/ui-shell/src/lib.rs index 267f8e077..dc3c89f5e 100644 --- a/crates/ui-shell/src/lib.rs +++ b/crates/ui-shell/src/lib.rs @@ -10,11 +10,11 @@ extern crate self as craft_ui; #[doc(hidden)] pub use craft_ui_panels::canvas_data; +#[cfg(feature = "testing")] +pub use craft_ui_panels::registry; #[cfg(feature = "suite")] #[doc(hidden)] pub use craft_ui_panels::story_kit; -#[cfg(feature = "testing")] -pub use craft_ui_panels::testing_registered; #[doc(hidden)] pub use craft_ui_panels::{__private, __register_command_set, __register_contract, __register_pattern}; pub use craft_ui_panels::{InstallError, InstallSpec, contract, fonts, install, layout, primitives, runtime, style, words}; @@ -32,5 +32,5 @@ pub mod testing { pub use craft_ui_panels::testing::*; #[cfg(feature = "suite")] - crate::testing_registered!(); + crate::registry!(); } diff --git a/crates/ui-shell/src/shell/app_shell.rs b/crates/ui-shell/src/shell/app_shell.rs index 345f37f6e..573498be8 100644 --- a/crates/ui-shell/src/shell/app_shell.rs +++ b/crates/ui-shell/src/shell/app_shell.rs @@ -4,7 +4,7 @@ mod dialogs; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use self::dialogs::{ShellDialogsCx, WindowDialogs}; use super::canvas_shell::slots as keys; diff --git a/crates/ui-shell/src/shell/canvas_shell.rs b/crates/ui-shell/src/shell/canvas_shell.rs index ebb3ade00..b8427a4f9 100644 --- a/crates/ui-shell/src/shell/canvas_shell.rs +++ b/crates/ui-shell/src/shell/canvas_shell.rs @@ -19,7 +19,7 @@ //! ``` #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::app_shell::{RegionBody, ShellRegion}; use super::words::ShellWords; diff --git a/crates/ui-shell/src/shell/caption_button.rs b/crates/ui-shell/src/shell/caption_button.rs index 8ceafc2db..151f60179 100644 --- a/crates/ui-shell/src/shell/caption_button.rs +++ b/crates/ui-shell/src/shell/caption_button.rs @@ -16,7 +16,7 @@ use egui::emath::GuiRounding as _; use egui::{Color32, ColorImage, CornerRadius, Painter, Pos2, Rect, Response, Stroke, StrokeKind, Vec2, pos2, vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The button's one part: the whole slot. const BUTTON: PartKey = PartKey::new("button"); diff --git a/crates/ui-shell/src/shell/document_window.rs b/crates/ui-shell/src/shell/document_window.rs index 6aef5f494..1bc55a73d 100644 --- a/crates/ui-shell/src/shell/document_window.rs +++ b/crates/ui-shell/src/shell/document_window.rs @@ -1,7 +1,7 @@ //! `DocumentWindow`: a document's window, a container in its own OS viewport. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use crate::contract::overlay::OverlayFit; use crate::contract::{ diff --git a/crates/ui-shell/src/shell/mod.rs b/crates/ui-shell/src/shell/mod.rs index c5d93ebbf..5d938a61d 100644 --- a/crates/ui-shell/src/shell/mod.rs +++ b/crates/ui-shell/src/shell/mod.rs @@ -17,12 +17,12 @@ mod regions; pub use regions::{Slot, SlotSize}; // App shell, canvas panel, screen modes and reveal. -mod app_shell; -mod canvas_shell; -mod opening; +pub(crate) mod app_shell; +pub(crate) mod canvas_shell; +pub(crate) mod opening; mod reveal; mod screen_mode; -mod screen_mode_button; +pub(crate) mod screen_mode_button; pub use app_shell::{AppShell, AppShellOutput, ShellDialogsCx, ShellRegion, ShellRegionOutput, WindowDialogs}; pub use canvas_shell::{CanvasPanel, CanvasPanelOutput, slots}; @@ -33,15 +33,15 @@ pub use words::ShellWords; // Start screen and app windows. mod recent; -mod start; -mod viewport_window; +pub(crate) mod start; +pub(crate) mod viewport_window; pub use recent::{RecentFile, RecentSort, RecentView, Template, ThumbKey, sort_recent}; pub use start::{StartAction, StartLink, StartLinkTarget, StartOutput, StartPinnedCommands, StartRecentCommands, StartScreen}; pub use viewport_window::{ViewportWindow, ViewportWindowOutput}; // Caption buttons: the four families' button, its slot layout and the icon-theme glyphs. -mod caption_button; +pub(crate) mod caption_button; mod caption_icons; pub use caption_button::{CaptionButton, CaptionEnd, CaptionPlan, CaptionSlot}; @@ -49,7 +49,7 @@ pub use caption_icons::{CaptionIcon, CaptionIcons, CaptionMask, RenderIconFn}; pub use craft_window::policy::{CaptionFamily, Captions, Frame, MacInset}; // A document's window: a container in its own OS viewport. -mod document_window; +pub(crate) mod document_window; pub use document_window::{DocumentWindow, DocumentWindowOutput, DocumentWindowStyle, Wrapped}; diff --git a/crates/ui-shell/src/shell/opening.rs b/crates/ui-shell/src/shell/opening.rs index 2f322695d..9764e90e0 100644 --- a/crates/ui-shell/src/shell/opening.rs +++ b/crates/ui-shell/src/shell/opening.rs @@ -11,7 +11,7 @@ use crate::style::{SurfaceKind, TypeRole}; use egui::{Layout, Response, Ui, UiBuilder}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// A centred card: "Opening {name}…" elided on one line with the full text on hover, the muted message, a progress bar /// (indeterminate without a fraction), the percentage at the start and Cancel at the end of the last row. Job UI diff --git a/crates/ui-shell/src/shell/screen_mode_button.rs b/crates/ui-shell/src/shell/screen_mode_button.rs index 0e2566b71..ab02b361f 100644 --- a/crates/ui-shell/src/shell/screen_mode_button.rs +++ b/crates/ui-shell/src/shell/screen_mode_button.rs @@ -8,7 +8,7 @@ use crate::runtime::env::Env; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// A flyout button over the three screen modes, with `mode` marked: a click, Enter or Space cycles; a hold, a drag away /// or a right click lists the three modes without cycling. The face is the Cycle command's icon and tooltip; disabled diff --git a/crates/ui-shell/src/shell/start.rs b/crates/ui-shell/src/shell/start.rs index 35d13a288..d39e1c169 100644 --- a/crates/ui-shell/src/shell/start.rs +++ b/crates/ui-shell/src/shell/start.rs @@ -2,7 +2,7 @@ //! pinned folders and templates. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::recent::{RecentFile, RecentSort, RecentView, Template, ThumbKey, sort_recent}; use super::words::ShellWords; diff --git a/crates/ui-shell/src/shell/title_bar.rs b/crates/ui-shell/src/shell/title_bar.rs index 0863c7b57..09308c534 100644 --- a/crates/ui-shell/src/shell/title_bar.rs +++ b/crates/ui-shell/src/shell/title_bar.rs @@ -21,7 +21,7 @@ pub fn set_window_movable(ctx: &Context, movable: bool) { } // The bar, its title and its two ends. -mod bar; +pub(crate) mod bar; mod measure; mod style; mod title; diff --git a/crates/ui-shell/src/shell/title_bar/bar.rs b/crates/ui-shell/src/shell/title_bar/bar.rs index 454a579c9..137988cec 100644 --- a/crates/ui-shell/src/shell/title_bar/bar.rs +++ b/crates/ui-shell/src/shell/title_bar/bar.rs @@ -1,7 +1,7 @@ //! `TitleBar`: the app-drawn bar of a window, in the title slot of an `AppShell`. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::measure::{End, Ends, Strip}; use super::style::TitleBarStyle; diff --git a/crates/ui-shell/src/shell/viewport_window.rs b/crates/ui-shell/src/shell/viewport_window.rs index a6fbf287c..c465c40fe 100644 --- a/crates/ui-shell/src/shell/viewport_window.rs +++ b/crates/ui-shell/src/shell/viewport_window.rs @@ -1,7 +1,7 @@ //! `ViewportWindow`: an app window in its own OS window where windows exist, else a dialog layer over the parent. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use crate::contract::{Bind, BodyCx, NoValue, Outcome, Overlay, Pattern, Props, SaveKey, ShowContainer as _}; use crate::dialog::Dialog; diff --git a/crates/ui-shell/tests/it/body/mod.rs b/crates/ui-shell/tests/it/body/mod.rs index 3f74b2b38..1a957836f 100644 --- a/crates/ui-shell/tests/it/body/mod.rs +++ b/crates/ui-shell/tests/it/body/mod.rs @@ -1,3 +1,3 @@ //! The body step and the mount host: regions, scrolling, move and resize, and viewport mounts. -mod regions; +pub(crate) mod regions; diff --git a/crates/ui-shell/tests/it/commands/mod.rs b/crates/ui-shell/tests/it/commands/mod.rs index 3c8a37d28..6b817c16a 100644 --- a/crates/ui-shell/tests/it/commands/mod.rs +++ b/crates/ui-shell/tests/it/commands/mod.rs @@ -1,6 +1,6 @@ //! The command board: registry, state, the gate, firing and scoped delivery. -mod app_catalog; -mod app_scope; -mod board; -mod kit; +pub(crate) mod app_catalog; +pub(crate) mod app_scope; +pub(crate) mod board; +pub(crate) mod kit; diff --git a/crates/ui-shell/tests/it/contract/mod.rs b/crates/ui-shell/tests/it/contract/mod.rs index d40a6a201..a398c82b2 100644 --- a/crates/ui-shell/tests/it/contract/mod.rs +++ b/crates/ui-shell/tests/it/contract/mod.rs @@ -1,3 +1,3 @@ //! The component contract and the show pipeline: the steps each shape runs, and the rules the steps keep. -mod os_window; +pub(crate) mod os_window; diff --git a/crates/ui-shell/tests/it/dialog/mod.rs b/crates/ui-shell/tests/it/dialog/mod.rs index 7f4659df3..df5eeb736 100644 --- a/crates/ui-shell/tests/it/dialog/mod.rs +++ b/crates/ui-shell/tests/it/dialog/mod.rs @@ -1,4 +1,4 @@ //! Dialogs embedded in a region. -mod contained; -mod window; +pub(crate) mod contained; +pub(crate) mod window; diff --git a/crates/ui-shell/tests/it/main.rs b/crates/ui-shell/tests/it/main.rs index 580eb26e0..041a34efe 100644 --- a/crates/ui-shell/tests/it/main.rs +++ b/crates/ui-shell/tests/it/main.rs @@ -4,16 +4,20 @@ extern crate craft_ui_shell as craft_ui; pub(crate) mod body; -mod commands; -mod contract; -mod dialog; -mod measure; -mod notices; +pub(crate) mod commands; +pub(crate) mod contract; +pub(crate) mod dialog; +pub(crate) mod measure; +pub(crate) mod notices; -mod shell; +pub(crate) mod shell; -use craft_ui::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run( + module_path!(), + env!("CARGO_PKG_NAME"), + &craft_ui::testing::Registry::of(&[register, craft_ui::testing::register, craft_ui_test_kit::testing::register]), + ); } diff --git a/crates/ui-shell/tests/it/measure/mod.rs b/crates/ui-shell/tests/it/measure/mod.rs index 5817c5814..259a6a210 100644 --- a/crates/ui-shell/tests/it/measure/mod.rs +++ b/crates/ui-shell/tests/it/measure/mod.rs @@ -1,6 +1,6 @@ //! A measuring run delivers nothing and consumes nothing: what the real run after it needs is still there. -mod record; +pub(crate) mod record; use craft_ui::contract::{Bind, Politeness, Show as _}; use craft_ui::runtime::commands::{FireSource, fire}; diff --git a/crates/ui-shell/tests/it/shell/mod.rs b/crates/ui-shell/tests/it/shell/mod.rs index 17c40b5bd..662fc8e2e 100644 --- a/crates/ui-shell/tests/it/shell/mod.rs +++ b/crates/ui-shell/tests/it/shell/mod.rs @@ -1,13 +1,13 @@ //! The window skeleton's interface: what `ShellCx` answers by mode and reveal, and how a body reads it. -mod app_shell; -mod canvas_panel; -mod caption_button; -mod document_window; -mod embed; -mod opening; -mod reveal; -mod screen_mode; -mod start; -mod title_bar; -mod window_parts; +pub(crate) mod app_shell; +pub(crate) mod canvas_panel; +pub(crate) mod caption_button; +pub(crate) mod document_window; +pub(crate) mod embed; +pub(crate) mod opening; +pub(crate) mod reveal; +pub(crate) mod screen_mode; +pub(crate) mod start; +pub(crate) mod title_bar; +pub(crate) mod window_parts; diff --git a/crates/ui-test-kit/Cargo.toml b/crates/ui-test-kit/Cargo.toml index 7b3673484..1e003a89b 100644 --- a/crates/ui-test-kit/Cargo.toml +++ b/crates/ui-test-kit/Cargo.toml @@ -15,6 +15,9 @@ workspace = true test = false doctest = false +[features] +suite = ["craft-ui-contract/suite"] + [dependencies] craft-ui-contract = { workspace = true, features = ["testing"] } egui = { workspace = true } diff --git a/crates/ui-test-kit/src/lib.rs b/crates/ui-test-kit/src/lib.rs index bde456318..12006a6f3 100644 --- a/crates/ui-test-kit/src/lib.rs +++ b/crates/ui-test-kit/src/lib.rs @@ -8,3 +8,9 @@ extern crate craft_ui_contract as craft_ui; pub mod body; pub mod contract; pub mod windows; + +/// Registrations of the shared test components. +#[cfg(feature = "suite")] +pub mod testing { + craft_ui::registry!(); +} diff --git a/crates/ui-widgets/Cargo.toml b/crates/ui-widgets/Cargo.toml index 3e5521ab0..9afe30081 100644 --- a/crates/ui-widgets/Cargo.toml +++ b/crates/ui-widgets/Cargo.toml @@ -39,7 +39,7 @@ craft-host = { workspace = true } craft-i18n = { workspace = true, features = ["collate"] } craft-keymap = { workspace = true, features = ["egui"] } craft-theme = { workspace = true } -craft-ui-test-kit = { workspace = true } +craft-ui-test-kit = { workspace = true, features = ["suite"] } egui = { workspace = true } [[test]] diff --git a/crates/ui-widgets/src/bars/align.rs b/crates/ui-widgets/src/bars/align.rs index c0b9f0d43..d2f4b4ba9 100644 --- a/crates/ui-widgets/src/bars/align.rs +++ b/crates/ui-widgets/src/bars/align.rs @@ -11,7 +11,7 @@ use craft_behavior::fit::FitKeep; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// One align or distribute command. The commands are app commands: the app gates them with command state and takes /// them when they run, from a button, the menu or a chord. diff --git a/crates/ui-widgets/src/bars/breadcrumb.rs b/crates/ui-widgets/src/bars/breadcrumb.rs index 90ae6e3d2..cdc6323c1 100644 --- a/crates/ui-widgets/src/bars/breadcrumb.rs +++ b/crates/ui-widgets/src/bars/breadcrumb.rs @@ -18,7 +18,7 @@ use craft_behavior::{Axis, CursorIcon, Flow, IconId, Metrics, NavShape, PartKey, use egui::{Rect, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; const HIDDEN: PartKey = PartKey::new("hidden"); const CRUMB: PartKey = PartKey::new("crumb"); diff --git a/crates/ui-widgets/src/bars/constraint_fields.rs b/crates/ui-widgets/src/bars/constraint_fields.rs index 188f438b5..ce3bbd166 100644 --- a/crates/ui-widgets/src/bars/constraint_fields.rs +++ b/crates/ui-widgets/src/bars/constraint_fields.rs @@ -17,7 +17,7 @@ use std::ops::RangeInclusive; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The three kinds of [`Constraint`], as the Style select lists them. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] diff --git a/crates/ui-widgets/src/bars/mod.rs b/crates/ui-widgets/src/bars/mod.rs index 0b4e4c236..f7ab811e6 100644 --- a/crates/ui-widgets/src/bars/mod.rs +++ b/crates/ui-widgets/src/bars/mod.rs @@ -1,15 +1,15 @@ //! `Bar` and `BarItems`: the bar container and its strip of command items, and the members of a status bar. -mod align; -mod bar; -mod breadcrumb; -mod constraint_fields; -mod items; -mod lead; -mod status; -mod status_readout; +pub(crate) mod align; +pub(crate) mod bar; +pub(crate) mod breadcrumb; +pub(crate) mod constraint_fields; +pub(crate) mod items; +pub(crate) mod lead; +pub(crate) mod status; +pub(crate) mod status_readout; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; pub use align::{AlignAction, AlignBar, AlignBarOutput}; diff --git a/crates/ui-widgets/src/bars/status_readout.rs b/crates/ui-widgets/src/bars/status_readout.rs index 2e0f2683e..7cedb45c9 100644 --- a/crates/ui-widgets/src/bars/status_readout.rs +++ b/crates/ui-widgets/src/bars/status_readout.rs @@ -16,7 +16,7 @@ use egui::{Response, Ui}; use std::time::Duration; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Shown for an item whose value the host does not know. const MISSING: &str = "\u{2014}"; diff --git a/crates/ui-widgets/src/buttons/mod.rs b/crates/ui-widgets/src/buttons/mod.rs index 0b3e133fc..579103b58 100644 --- a/crates/ui-widgets/src/buttons/mod.rs +++ b/crates/ui-widgets/src/buttons/mod.rs @@ -6,7 +6,7 @@ pub mod icon_button; pub mod link; pub mod split_button; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub mod toggle_button; mod words; diff --git a/crates/ui-widgets/src/choice/check.rs b/crates/ui-widgets/src/choice/check.rs index 5aac81ec6..41dae36cf 100644 --- a/crates/ui-widgets/src/choice/check.rs +++ b/crates/ui-widgets/src/choice/check.rs @@ -93,4 +93,4 @@ impl Component for Checkbox<'_> { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/ui-widgets/src/choice/mod.rs b/crates/ui-widgets/src/choice/mod.rs index a4c0dc47b..d0aba36ee 100644 --- a/crates/ui-widgets/src/choice/mod.rs +++ b/crates/ui-widgets/src/choice/mod.rs @@ -2,13 +2,13 @@ pub mod check; pub mod radio; -mod rating; -mod segmented; -mod switch; +pub(crate) mod rating; +pub(crate) mod segmented; +pub(crate) mod switch; mod words; -mod swatch; -mod swatch_table; +pub(crate) mod swatch; +pub(crate) mod swatch_table; pub use check::{Checkbox, CheckboxStyle}; pub use radio::{GroupStyle, Radio, RadioGroup, RadioKind, RadioStyle}; diff --git a/crates/ui-widgets/src/choice/radio.rs b/crates/ui-widgets/src/choice/radio.rs index 8e2b846b0..eb5c0f40c 100644 --- a/crates/ui-widgets/src/choice/radio.rs +++ b/crates/ui-widgets/src/choice/radio.rs @@ -224,4 +224,4 @@ impl Component for Radio { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/ui-widgets/src/choice/rating.rs b/crates/ui-widgets/src/choice/rating.rs index 0db4d1c26..8c07612a1 100644 --- a/crates/ui-widgets/src/choice/rating.rs +++ b/crates/ui-widgets/src/choice/rating.rs @@ -204,4 +204,4 @@ impl Component for Rating<'_> { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/ui-widgets/src/choice/segmented.rs b/crates/ui-widgets/src/choice/segmented.rs index 0ea652ad0..0ac76a16b 100644 --- a/crates/ui-widgets/src/choice/segmented.rs +++ b/crates/ui-widgets/src/choice/segmented.rs @@ -251,4 +251,4 @@ impl Component for Segment { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/ui-widgets/src/choice/swatch.rs b/crates/ui-widgets/src/choice/swatch.rs index 008cf2be5..ed541639c 100644 --- a/crates/ui-widgets/src/choice/swatch.rs +++ b/crates/ui-widgets/src/choice/swatch.rs @@ -15,7 +15,7 @@ use craft_theme::{Rgba, Srgba, Stateful, States, over}; use egui::{Color32, CornerRadius, Rect, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Opacity of the black or white ring that stands out from a well's colour. const INNER_EDGE_ALPHA: u8 = 0x80; diff --git a/crates/ui-widgets/src/choice/swatch_table.rs b/crates/ui-widgets/src/choice/swatch_table.rs index adf28392e..66ad1b688 100644 --- a/crates/ui-widgets/src/choice/swatch_table.rs +++ b/crates/ui-widgets/src/choice/swatch_table.rs @@ -13,7 +13,7 @@ use craft_theme::Srgba; use egui::{Response, Ui, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The entries of a colour table as an item source: keyed by index, named for type-ahead. #[derive(Clone, Copy, Debug)] diff --git a/crates/ui-widgets/src/choice/switch.rs b/crates/ui-widgets/src/choice/switch.rs index d00031722..98464a6f5 100644 --- a/crates/ui-widgets/src/choice/switch.rs +++ b/crates/ui-widgets/src/choice/switch.rs @@ -114,4 +114,4 @@ impl Component for Switch<'_> { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/ui-widgets/src/controls/mod.rs b/crates/ui-widgets/src/controls/mod.rs index c25e18cbc..8bc1dfc59 100644 --- a/crates/ui-widgets/src/controls/mod.rs +++ b/crates/ui-widgets/src/controls/mod.rs @@ -2,4 +2,4 @@ pub mod disclosure; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/ui-widgets/src/display/badge.rs b/crates/ui-widgets/src/display/badge.rs index ee54e5926..5ab3719ed 100644 --- a/crates/ui-widgets/src/display/badge.rs +++ b/crates/ui-widgets/src/display/badge.rs @@ -13,7 +13,7 @@ use egui::{Response, Vec2}; use std::borrow::Cow; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The largest count a count badge shows; more reads `99+`. pub const MAX_COUNT: u32 = 99; diff --git a/crates/ui-widgets/src/display/divider.rs b/crates/ui-widgets/src/display/divider.rs index 44efb3b5b..01e0749e8 100644 --- a/crates/ui-widgets/src/display/divider.rs +++ b/crates/ui-widgets/src/display/divider.rs @@ -6,7 +6,7 @@ use craft_behavior::{Metrics, Sense}; use egui::{Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a divider. #[derive(Clone, Debug, PartialEq, ComponentStyle)] diff --git a/crates/ui-widgets/src/display/icon.rs b/crates/ui-widgets/src/display/icon.rs index 3a217dcdf..ca8d531de 100644 --- a/crates/ui-widgets/src/display/icon.rs +++ b/crates/ui-widgets/src/display/icon.rs @@ -9,7 +9,7 @@ use craft_theme::{Stateful, States}; use egui::{Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of an icon. #[derive(Clone, Debug, PartialEq, ComponentStyle)] diff --git a/crates/ui-widgets/src/display/inspect_overlay.rs b/crates/ui-widgets/src/display/inspect_overlay.rs index 96cde9cb1..1b939635c 100644 --- a/crates/ui-widgets/src/display/inspect_overlay.rs +++ b/crates/ui-widgets/src/display/inspect_overlay.rs @@ -11,7 +11,7 @@ use egui::{CornerRadius, Pos2, Rect, Response, Vec2}; use std::sync::Arc; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Which drawings an [`InspectOverlay`] shows. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/ui-widgets/src/display/kbd.rs b/crates/ui-widgets/src/display/kbd.rs index b2e3ef5e3..dc3f36dce 100644 --- a/crates/ui-widgets/src/display/kbd.rs +++ b/crates/ui-widgets/src/display/kbd.rs @@ -13,7 +13,7 @@ use craft_theme::Stateful; use egui::{Rect, Response, Vec2, pos2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a chord. #[derive(Clone, Debug, PartialEq, ComponentStyle)] diff --git a/crates/ui-widgets/src/display/mod.rs b/crates/ui-widgets/src/display/mod.rs index 860385fdd..5b1e0e582 100644 --- a/crates/ui-widgets/src/display/mod.rs +++ b/crates/ui-widgets/src/display/mod.rs @@ -3,16 +3,16 @@ //! None of them takes input or a Tab stop. A tooltip, or a label no text paints, gives the root a hover sense so the //! tooltip can show. -mod badge; -mod divider; -mod icon; -mod inspect_overlay; -mod kbd; -mod picture; -mod progress; -mod spinner; -mod target_mark; -mod text; +pub(crate) mod badge; +pub(crate) mod divider; +pub(crate) mod icon; +pub(crate) mod inspect_overlay; +pub(crate) mod kbd; +pub(crate) mod picture; +pub(crate) mod progress; +pub(crate) mod spinner; +pub(crate) mod target_mark; +pub(crate) mod text; mod words; pub use badge::{Badge, BadgeStyle}; diff --git a/crates/ui-widgets/src/display/picture.rs b/crates/ui-widgets/src/display/picture.rs index d47be3ec9..60b1c1ce7 100644 --- a/crates/ui-widgets/src/display/picture.rs +++ b/crates/ui-widgets/src/display/picture.rs @@ -10,7 +10,7 @@ use craft_behavior::{Metrics, Sense}; use egui::{ColorImage, Id, Pos2, Rect, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// How large a picture is: its height, from a token. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] diff --git a/crates/ui-widgets/src/display/progress.rs b/crates/ui-widgets/src/display/progress.rs index 0e4061ed7..ac6adb1c0 100644 --- a/crates/ui-widgets/src/display/progress.rs +++ b/crates/ui-widgets/src/display/progress.rs @@ -9,7 +9,7 @@ use craft_theme::{Stateful, Variant}; use egui::{CornerRadius, Rect, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Seconds for the unknown-extent segment to cross the track. const SWEEP: f64 = 1.25; diff --git a/crates/ui-widgets/src/display/spinner.rs b/crates/ui-widgets/src/display/spinner.rs index f9f28ccdd..53949bdbb 100644 --- a/crates/ui-widgets/src/display/spinner.rs +++ b/crates/ui-widgets/src/display/spinner.rs @@ -11,7 +11,7 @@ use egui::{Pos2, Response, Vec2, vec2}; use std::f32::consts::{PI, TAU}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// How long the spinner takes for a turn, in seconds. const PERIOD: f64 = 1.0; diff --git a/crates/ui-widgets/src/display/target_mark.rs b/crates/ui-widgets/src/display/target_mark.rs index 20753fb94..40b200b4e 100644 --- a/crates/ui-widgets/src/display/target_mark.rs +++ b/crates/ui-widgets/src/display/target_mark.rs @@ -14,7 +14,7 @@ use egui::{CornerRadius, Rect, Response, Ui}; use std::f32::consts::TAU; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The period of the pulse in seconds: a sine of four radians per second. const PULSE_PERIOD: f64 = std::f64::consts::FRAC_PI_2; diff --git a/crates/ui-widgets/src/display/text.rs b/crates/ui-widgets/src/display/text.rs index cc84c50b9..c4d82dd00 100644 --- a/crates/ui-widgets/src/display/text.rs +++ b/crates/ui-widgets/src/display/text.rs @@ -9,7 +9,7 @@ use craft_theme::{Stateful, States, variant::Tone}; use egui::{Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// How strongly the text reads against its surface. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default)] diff --git a/crates/ui-widgets/src/form/mod.rs b/crates/ui-widgets/src/form/mod.rs index efa196c15..71a31be6f 100644 --- a/crates/ui-widgets/src/form/mod.rs +++ b/crates/ui-widgets/src/form/mod.rs @@ -1,10 +1,10 @@ //! Form rows: `Field`, `FieldGroup` and `SliderField`. -mod field; -mod group; -mod slider_field; +pub(crate) mod field; +pub(crate) mod group; +pub(crate) mod slider_field; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; pub use field::{Field, FieldRowStyle, Help}; diff --git a/crates/ui-widgets/src/form/slider_field.rs b/crates/ui-widgets/src/form/slider_field.rs index 015429972..68066a570 100644 --- a/crates/ui-widgets/src/form/slider_field.rs +++ b/crates/ui-widgets/src/form/slider_field.rs @@ -1,7 +1,7 @@ //! `SliderField`: a slider and a number field over one value. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use crate::contract::{ Bind, BindMut, Common, Component, Cx, Edit as _, EditResponse, FieldLayout, MeasureCx, Outcome, PaintUi, Props as _, Role, SideLabel, Sizing, diff --git a/crates/ui-widgets/src/graph/mod.rs b/crates/ui-widgets/src/graph/mod.rs index 0d0793784..e11d633d5 100644 --- a/crates/ui-widgets/src/graph/mod.rs +++ b/crates/ui-widgets/src/graph/mod.rs @@ -5,9 +5,9 @@ //! `NodeKind`. mod kind; -mod node; +pub(crate) mod node; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use kind::{NodeEvent, NodeId, NodeKind, PortRef, Wire, WireDrag}; pub use node::{Node, NodeOutput, NodeStyle}; diff --git a/crates/ui-widgets/src/layout_components/mod.rs b/crates/ui-widgets/src/layout_components/mod.rs index 78e0f94f3..03c9288ef 100644 --- a/crates/ui-widgets/src/layout_components/mod.rs +++ b/crates/ui-widgets/src/layout_components/mod.rs @@ -11,7 +11,7 @@ use craft_behavior::{ColumnWidth, Insets, Metrics, Sense}; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of the layout components: no minimum size, and padding only at the start edge, one /// `space.pad.regular` per level of indent. @@ -59,7 +59,7 @@ macro_rules! layout_component { ($(#[$doc:meta])* $name:ident, $key:ident, [$($fwd:ident),*] $(, <$life:lifetime> { $($field:ident: $ty:ty),* })?) => { $(#[$doc])* #[derive(crate::contract::Component, crate::contract::Props)] - #[component(container)] + #[component(container, unregistered)] pub struct $name $(<$life>)? { #[common] common: Common, @@ -189,6 +189,13 @@ macro_rules! layout_component { }; } +#[cfg(feature = "suite")] +crate::contract::register_contract!(Stack<'static>; container, purpose = "Children one under another"); +#[cfg(feature = "suite")] +crate::contract::register_contract!(Row; container, purpose = "Children side by side"); +#[cfg(feature = "suite")] +crate::contract::register_contract!(Grid; container, purpose = "Children row-major over a column list: a child in flow takes the next cell"); + layout_component!( /// Children one under another. A header and a footer sit outside the body: the footer stays in the room under /// a collection that fills it. diff --git a/crates/ui-widgets/src/lib.rs b/crates/ui-widgets/src/lib.rs index 446d09a5e..fbb6cf38c 100644 --- a/crates/ui-widgets/src/lib.rs +++ b/crates/ui-widgets/src/lib.rs @@ -11,7 +11,7 @@ extern crate self as craft_ui; #[cfg(feature = "testing")] -pub use craft_ui_contract::testing_registered; +pub use craft_ui_contract::registry; #[doc(hidden)] pub use craft_ui_contract::{__private, __register_command_set, __register_contract, __register_pattern}; pub use craft_ui_contract::{InstallError, InstallSpec, contract, fonts, install, layout, primitives, runtime, style, words}; @@ -48,5 +48,5 @@ pub mod testing { pub use craft_ui_contract::testing::*; #[cfg(feature = "suite")] - crate::testing_registered!(); + crate::registry!(); } diff --git a/crates/ui-widgets/src/list/mod.rs b/crates/ui-widgets/src/list/mod.rs index b5d9824e5..4176bcba8 100644 --- a/crates/ui-widgets/src/list/mod.rs +++ b/crates/ui-widgets/src/list/mod.rs @@ -1,18 +1,18 @@ //! `List` and its rows: `ListRow`, `FindingsList`, `EventList` and `UndoList`. -mod events; -mod findings; +pub(crate) mod events; +pub(crate) mod findings; mod predicate; #[doc(hidden)] pub mod row; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod toggle; mod tree; -mod undo; -mod view; +pub(crate) mod undo; +pub(crate) mod view; #[cfg(feature = "suite")] -mod view_stories; +pub(crate) mod view_stories; mod view_words; mod words; diff --git a/crates/ui-widgets/src/list/row.rs b/crates/ui-widgets/src/list/row.rs index 8b41fd357..1b6004cf0 100644 --- a/crates/ui-widgets/src/list/row.rs +++ b/crates/ui-widgets/src/list/row.rs @@ -23,7 +23,7 @@ mod paint; mod placement; mod show; mod style; -mod thumb; +pub(crate) mod thumb; mod trailing; use crate::contract::Hosting; diff --git a/crates/ui-widgets/src/menu/bar.rs b/crates/ui-widgets/src/menu/bar.rs index 87fee1fc6..d4b132a8e 100644 --- a/crates/ui-widgets/src/menu/bar.rs +++ b/crates/ui-widgets/src/menu/bar.rs @@ -16,7 +16,7 @@ //! matches by label, English label or menu path, each as a command row with its path as detail. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::search::{HelpEntry, search_order}; use super::words::MenuWords; diff --git a/crates/ui-widgets/src/menu/mod.rs b/crates/ui-widgets/src/menu/mod.rs index 7271572a5..2c400aced 100644 --- a/crates/ui-widgets/src/menu/mod.rs +++ b/crates/ui-widgets/src/menu/mod.rs @@ -1,15 +1,15 @@ //! Menu presets with `MenuItem` rows, menu-bar keys and mnemonics. pub mod bar; -mod edit; +pub(crate) mod edit; pub(crate) mod item; #[doc(hidden)] pub mod level; -mod panel; -mod popup; +pub(crate) mod panel; +pub(crate) mod popup; pub mod search; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; mod words; pub use bar::{MenuBar, MenuBarOutput, MenuBarStyle, MenuHelp, MenuTitle}; diff --git a/crates/ui-widgets/src/notices/mod.rs b/crates/ui-widgets/src/notices/mod.rs index 386586e52..6c430edec 100644 --- a/crates/ui-widgets/src/notices/mod.rs +++ b/crates/ui-widgets/src/notices/mod.rs @@ -1,14 +1,14 @@ //! `Notice` (inline, card and centred layouts), the settings notices and the notice center. The toast queue is //! `runtime::toast`, drawn by `ToastStack` through the contract's `ToastHost`. -mod center; -mod notice; -mod settings; -mod toasts; +pub(crate) mod center; +pub(crate) mod notice; +pub(crate) mod settings; +pub(crate) mod toasts; mod words; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use center::{NoticeCenter, NoticeCenterOutput, NoticeEnd, PostedNotice}; pub use notice::{Notice, NoticeAction, NoticeIcon, NoticeLayout, NoticeOutput, NoticeStyle}; diff --git a/crates/ui-widgets/src/pickers/combo_box.rs b/crates/ui-widgets/src/pickers/combo_box.rs index 52dcd9f6f..4b1c06b1d 100644 --- a/crates/ui-widgets/src/pickers/combo_box.rs +++ b/crates/ui-widgets/src/pickers/combo_box.rs @@ -5,7 +5,7 @@ //! the list. The option the keys make active puts its text in the field; the list's Escape puts back what was typed. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::dress::RowDress; use super::rows::EntryRows; diff --git a/crates/ui-widgets/src/pickers/date.rs b/crates/ui-widgets/src/pickers/date.rs index 46327edbf..d8819c941 100644 --- a/crates/ui-widgets/src/pickers/date.rs +++ b/crates/ui-widgets/src/pickers/date.rs @@ -5,10 +5,10 @@ //! button opens the calendar; the day under the pointer is proposed while it is open and a pick commits it. Escape //! or a press outside closes it and restores the value. -mod calendar; +pub(crate) mod calendar; mod codec; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; pub use calendar::{Calendar, CalendarOutput, CalendarStyle, CalendarView, local_month_grid, month_grid}; pub use codec::DateCodec; diff --git a/crates/ui-widgets/src/pickers/face.rs b/crates/ui-widgets/src/pickers/face.rs index fff9d93f5..5093e8d52 100644 --- a/crates/ui-widgets/src/pickers/face.rs +++ b/crates/ui-widgets/src/pickers/face.rs @@ -250,7 +250,7 @@ impl Component for SelectFace<'_> { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// Opens the popup of a picker whose face part toggles it, from the keyboard: Enter and Space (an activation by key) /// toggle it. A click on the face reaches the popup through the part's `toggles`, so the pointer is not read here. diff --git a/crates/ui-widgets/src/pickers/icon_picker.rs b/crates/ui-widgets/src/pickers/icon_picker.rs index 0b556a4ca..007da755b 100644 --- a/crates/ui-widgets/src/pickers/icon_picker.rs +++ b/crates/ui-widgets/src/pickers/icon_picker.rs @@ -4,7 +4,7 @@ //! tiles, Enter picks the active tile, and focus stays in the field. A click on a tile picks it. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::words::PickerWords; use crate::contract::{ diff --git a/crates/ui-widgets/src/pickers/mod.rs b/crates/ui-widgets/src/pickers/mod.rs index d2fea5eb9..37f05be27 100644 --- a/crates/ui-widgets/src/pickers/mod.rs +++ b/crates/ui-widgets/src/pickers/mod.rs @@ -1,18 +1,18 @@ //! Dropdown pickers: `Select`, `ComboBox`, `TreePicker`, `Autocomplete`, `DatePicker` and `IconPicker`. -mod combo_box; -mod date; +pub(crate) mod combo_box; +pub(crate) mod date; mod dress; -mod face; -mod icon_picker; +pub(crate) mod face; +pub(crate) mod icon_picker; mod rows; mod search; -mod select; -mod tree_picker; -mod unit_select; +pub(crate) mod select; +pub(crate) mod tree_picker; +pub(crate) mod unit_select; mod words; -mod reference_point; +pub(crate) mod reference_point; pub use combo_box::ComboBox; pub use date::{ diff --git a/crates/ui-widgets/src/pickers/reference_point.rs b/crates/ui-widgets/src/pickers/reference_point.rs index 5e8162485..71ecc7e31 100644 --- a/crates/ui-widgets/src/pickers/reference_point.rs +++ b/crates/ui-widgets/src/pickers/reference_point.rs @@ -15,7 +15,7 @@ use craft_behavior::{Anchor9, Metrics, NavShape, PartKey, PartRef, Roving, Sense use egui::{Pos2, Rect, Vec2, vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; const CELL: PartKey = PartKey::new("cell"); diff --git a/crates/ui-widgets/src/pickers/select.rs b/crates/ui-widgets/src/pickers/select.rs index 7a0f2fee3..8aec2a378 100644 --- a/crates/ui-widgets/src/pickers/select.rs +++ b/crates/ui-widgets/src/pickers/select.rs @@ -32,7 +32,7 @@ use egui::{Rect, Ui, Vec2}; use std::borrow::Cow; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The part that shows the face over the whole field and opens the list on a click. const FACE: PartKey = PartKey::new("face"); diff --git a/crates/ui-widgets/src/pickers/tree_picker.rs b/crates/ui-widgets/src/pickers/tree_picker.rs index 2f41e422e..3d6d0fb97 100644 --- a/crates/ui-widgets/src/pickers/tree_picker.rs +++ b/crates/ui-widgets/src/pickers/tree_picker.rs @@ -5,7 +5,7 @@ //! Typing lists the items whose path holds every typed word instead of the tree. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::SelectFace; use super::face::toggle_on_key; diff --git a/crates/ui-widgets/src/pickers/unit_select.rs b/crates/ui-widgets/src/pickers/unit_select.rs index e0b7accc3..7afe8fd2e 100644 --- a/crates/ui-widgets/src/pickers/unit_select.rs +++ b/crates/ui-widgets/src/pickers/unit_select.rs @@ -12,7 +12,7 @@ use egui::{Rect, Response, Vec2, pos2}; use std::ops::{Deref, RangeInclusive}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a unit select: the gap between the field and the select, and the number field's width. #[derive(Clone, Debug, PartialEq, ComponentStyle)] diff --git a/crates/ui-widgets/src/popover/anchored.rs b/crates/ui-widgets/src/popover/anchored.rs index d3d158a84..d9e3fc4b8 100644 --- a/crates/ui-widgets/src/popover/anchored.rs +++ b/crates/ui-widgets/src/popover/anchored.rs @@ -207,4 +207,4 @@ impl Container for Popover<'_> { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; diff --git a/crates/ui-widgets/src/popover/drop_veil.rs b/crates/ui-widgets/src/popover/drop_veil.rs index 26a248183..1e003857e 100644 --- a/crates/ui-widgets/src/popover/drop_veil.rs +++ b/crates/ui-widgets/src/popover/drop_veil.rs @@ -13,7 +13,7 @@ use craft_behavior::{Metrics, Proposal, Sense}; use egui::{Rect, Response}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a drop veil: the scrim comes from the surface kind; the card is a child. #[derive(Clone, Debug, PartialEq, ComponentStyle)] diff --git a/crates/ui-widgets/src/popover/mod.rs b/crates/ui-widgets/src/popover/mod.rs index aefa94fb9..66d19ea72 100644 --- a/crates/ui-widgets/src/popover/mod.rs +++ b/crates/ui-widgets/src/popover/mod.rs @@ -1,8 +1,8 @@ //! Overlay components: `Popover`, `PopupList`, `Tooltip` and `DropVeil`. -mod anchored; -mod drop_veil; -mod popup_list; +pub(crate) mod anchored; +pub(crate) mod drop_veil; +pub(crate) mod popup_list; mod words; pub use anchored::{Popover, PopoverOutput, PopoverStyle}; diff --git a/crates/ui-widgets/src/popover/popup_list.rs b/crates/ui-widgets/src/popover/popup_list.rs index 85533caca..4fcf84c16 100644 --- a/crates/ui-widgets/src/popover/popup_list.rs +++ b/crates/ui-widgets/src/popover/popup_list.rs @@ -9,7 +9,7 @@ use craft_behavior::{Metrics, Sense}; use egui::Response; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The style of a popup list: the surface comes from the container. #[derive(Clone, Debug, Default, PartialEq, ComponentStyle)] diff --git a/crates/ui-widgets/src/table/metadata.rs b/crates/ui-widgets/src/table/metadata.rs index 36183c8c4..659855d13 100644 --- a/crates/ui-widgets/src/table/metadata.rs +++ b/crates/ui-widgets/src/table/metadata.rs @@ -326,7 +326,7 @@ impl<'a> MetadataTable<'a> { } #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The rows stamp of a filter query: the same query keeps the layout, another one rebuilds it. fn query_stamp(query: &str) -> u64 { diff --git a/crates/ui-widgets/src/table/mod.rs b/crates/ui-widgets/src/table/mod.rs index be0a212ac..a0e7b77e1 100644 --- a/crates/ui-widgets/src/table/mod.rs +++ b/crates/ui-widgets/src/table/mod.rs @@ -1,10 +1,10 @@ //! `Table` and `MetadataTable`, as `List` with columns. -mod metadata; +pub(crate) mod metadata; mod sort; #[cfg(feature = "suite")] -mod stories; -mod view; +pub(crate) mod stories; +pub(crate) mod view; mod words; pub use metadata::{Checked, FieldKey, MetadataGroup, MetadataRow, MetadataTable, MetadataTableOutput}; diff --git a/crates/ui-widgets/src/tabs/document.rs b/crates/ui-widgets/src/tabs/document.rs index 8bb6147a3..c8f0da436 100644 --- a/crates/ui-widgets/src/tabs/document.rs +++ b/crates/ui-widgets/src/tabs/document.rs @@ -3,7 +3,7 @@ //! are the caller's closures. Files from the OS drop between the tabs when the host takes them. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::{Tab, TabStrip}; use crate::contract::{ diff --git a/crates/ui-widgets/src/tabs/mod.rs b/crates/ui-widgets/src/tabs/mod.rs index 953a2f362..ffc8853aa 100644 --- a/crates/ui-widgets/src/tabs/mod.rs +++ b/crates/ui-widgets/src/tabs/mod.rs @@ -4,15 +4,15 @@ mod words; // Tab and the strip rules. mod rules; -mod tab; +pub(crate) mod tab; pub use rules::{CloseSide, FitMode, OverflowMenu, OverflowPlace, TabKind, close_side}; pub use tab::{Tab, TabOutput, TabPartEvent, TabStyle}; pub use words::TabWords; // The strip and the document tabs. -mod document; -mod strip; +pub(crate) mod document; +pub(crate) mod strip; pub use document::{DocumentTab, DocumentTabs, DocumentTabsEvent, DocumentTabsOutput}; pub use strip::{StripLayout, TabStrip, TabStripOutput, TabStripStyle, TornOff}; diff --git a/crates/ui-widgets/src/tabs/strip.rs b/crates/ui-widgets/src/tabs/strip.rs index c1be1b4b3..ea88e13ab 100644 --- a/crates/ui-widgets/src/tabs/strip.rs +++ b/crates/ui-widgets/src/tabs/strip.rs @@ -7,7 +7,7 @@ //! carries panels reads the same payload with the panel key as `K`. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::rules::{FitMode, OverflowMenu, OverflowPlace, TabKind}; use super::words::StripWords; diff --git a/crates/ui-widgets/src/tabs/tab.rs b/crates/ui-widgets/src/tabs/tab.rs index e54c3c658..7a53efbaf 100644 --- a/crates/ui-widgets/src/tabs/tab.rs +++ b/crates/ui-widgets/src/tabs/tab.rs @@ -21,7 +21,7 @@ use craft_theme::{Contrast, Rgba, Stateful, States, TypeRole}; use egui::{Pos2, Rect, Response, Vec2}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// What a tab's own parts report, besides what the collection reads from the pointer. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/ui-widgets/src/text/alt_text.rs b/crates/ui-widgets/src/text/alt_text.rs index 1d4a3f4cf..644e2ce1c 100644 --- a/crates/ui-widgets/src/text/alt_text.rs +++ b/crates/ui-widgets/src/text/alt_text.rs @@ -1,7 +1,7 @@ //! `AltTextField`: an object's description for people who cannot see it, with a Mark as decorative check. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::{FieldStyle, text_part}; use crate::choice::Checkbox; diff --git a/crates/ui-widgets/src/text/chips.rs b/crates/ui-widgets/src/text/chips.rs index d48f4e7f6..15cb0beb8 100644 --- a/crates/ui-widgets/src/text/chips.rs +++ b/crates/ui-widgets/src/text/chips.rs @@ -2,7 +2,7 @@ //! where a line limit stops the list, and Clear All. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::{FieldStyle, text_part}; use crate::buttons::IconButton; diff --git a/crates/ui-widgets/src/text/hex.rs b/crates/ui-widgets/src/text/hex.rs index 9ea16d0b8..7d8974b8b 100644 --- a/crates/ui-widgets/src/text/hex.rs +++ b/crates/ui-widgets/src/text/hex.rs @@ -2,7 +2,7 @@ //! the codec behind it. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::TextField; use crate::contract::{Bind, GlyphLabel, LabelKind, SideLabel}; diff --git a/crates/ui-widgets/src/text/linked.rs b/crates/ui-widgets/src/text/linked.rs index 87bc66acd..6964e0b82 100644 --- a/crates/ui-widgets/src/text/linked.rs +++ b/crates/ui-widgets/src/text/linked.rs @@ -2,7 +2,7 @@ //! equal (four sides). #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::NumberField; use crate::buttons::ToggleButton; diff --git a/crates/ui-widgets/src/text/mod.rs b/crates/ui-widgets/src/text/mod.rs index 245e2d1ca..bae92ad6e 100644 --- a/crates/ui-widgets/src/text/mod.rs +++ b/crates/ui-widgets/src/text/mod.rs @@ -1,16 +1,16 @@ //! Text and number fields: `TextField` and `NumberField` on the text part (18.3). mod adorn; -mod alt_text; -mod chips; +pub(crate) mod alt_text; +pub(crate) mod chips; mod completions; -mod hex; -mod linked; -mod number; -mod selectable_text; -mod text_field; +pub(crate) mod hex; +pub(crate) mod linked; +pub(crate) mod number; +pub(crate) mod selectable_text; +pub(crate) mod text_field; mod words; -mod zoom_field; +pub(crate) mod zoom_field; pub use adorn::{Adornment, Placed, place, reserve}; pub use alt_text::{AltText, AltTextField, AltTextFieldStyle, AltTextWords}; diff --git a/crates/ui-widgets/src/text/number.rs b/crates/ui-widgets/src/text/number.rs index ef033a6ab..ecdc0483a 100644 --- a/crates/ui-widgets/src/text/number.rs +++ b/crates/ui-widgets/src/text/number.rs @@ -5,7 +5,7 @@ //! is not in edit scrubs it; a click enters edit, where a drag selects text. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::adorn::{Adornment, Placed, place, reserve}; use super::words::TextWords; diff --git a/crates/ui-widgets/src/text/selectable_text.rs b/crates/ui-widgets/src/text/selectable_text.rs index c04393052..41e64a745 100644 --- a/crates/ui-widgets/src/text/selectable_text.rs +++ b/crates/ui-widgets/src/text/selectable_text.rs @@ -1,7 +1,7 @@ //! `SelectableText`: read-only text the user can focus, select and copy. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use crate::contract::{Access, Common, Component, Cx, MeasureCx, PaintUi, PartsCx, Props as _, Role, Styled as _}; use crate::primitives::{Span, TextRun, Wrap}; diff --git a/crates/ui-widgets/src/text/text_field.rs b/crates/ui-widgets/src/text/text_field.rs index a58112cf3..ef587060a 100644 --- a/crates/ui-widgets/src/text/text_field.rs +++ b/crates/ui-widgets/src/text/text_field.rs @@ -1,7 +1,7 @@ //! `TextField`: a text field over a codec, with the search form and the adornment layout. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::adorn::{self, Adornment}; use super::{FieldStyle, completions, text_part, words}; diff --git a/crates/ui-widgets/src/text/zoom_field.rs b/crates/ui-widgets/src/text/zoom_field.rs index cf859db1e..bb80bd942 100644 --- a/crates/ui-widgets/src/text/zoom_field.rs +++ b/crates/ui-widgets/src/text/zoom_field.rs @@ -10,7 +10,7 @@ use craft_behavior::{CanvasView, EditEvents, ZoomLadder}; use egui::{Response, Ui}; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The decimals the zoom range's ends are written with in the message, as the field shows a zoom. const MESSAGE_DECIMALS: usize = 2; diff --git a/crates/ui-widgets/src/tile_grid/grid.rs b/crates/ui-widgets/src/tile_grid/grid.rs index 06348f3b8..9af0dee75 100644 --- a/crates/ui-widgets/src/tile_grid/grid.rs +++ b/crates/ui-widgets/src/tile_grid/grid.rs @@ -6,7 +6,7 @@ //! caption goes, whether a detail line is reserved, and the zoom. #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; use super::headers::Outline; use super::layout::{Around, ArrangeSpacing, GridLayout, Recipe, Slot, TailRow, TileGroup, Tiling, arrange, aspects_of, slot_at}; diff --git a/crates/ui-widgets/src/tile_grid/mod.rs b/crates/ui-widgets/src/tile_grid/mod.rs index f3705281e..8eba110b6 100644 --- a/crates/ui-widgets/src/tile_grid/mod.rs +++ b/crates/ui-widgets/src/tile_grid/mod.rs @@ -3,13 +3,13 @@ //! The data types of a tile (badges, status, marks, the caption's place) live here; `TileGrid` shows tiles in //! rows and columns and reads the tile size from the value a `ThumbnailSlider` edits. -mod grid; +pub(crate) mod grid; mod headers; mod layout; -mod slider; +pub(crate) mod slider; #[cfg(feature = "suite")] -mod stories; -mod tile; +pub(crate) mod stories; +pub(crate) mod tile; mod words; use crate::runtime::env::Label; diff --git a/crates/ui-widgets/src/value_drag/angle_dial.rs b/crates/ui-widgets/src/value_drag/angle_dial.rs index ce5b9060a..db02d76f5 100644 --- a/crates/ui-widgets/src/value_drag/angle_dial.rs +++ b/crates/ui-widgets/src/value_drag/angle_dial.rs @@ -18,7 +18,7 @@ use egui::{CornerRadius, Pos2, Rect, Vec2}; use std::ops::RangeInclusive; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The face: the circle the pointer points at. const FACE: PartKey = PartKey::new("face"); diff --git a/crates/ui-widgets/src/value_drag/mod.rs b/crates/ui-widgets/src/value_drag/mod.rs index fec2aba73..12d65961e 100644 --- a/crates/ui-widgets/src/value_drag/mod.rs +++ b/crates/ui-widgets/src/value_drag/mod.rs @@ -1,10 +1,10 @@ //! `Slider`, `RangeSlider`, `AngleDial`, `PointPicker` and `ThumbRow`, built on `ValueDrag`. -mod angle_dial; -mod point_picker; -mod range_slider; -mod slider; -mod thumb_row; +pub(crate) mod angle_dial; +pub(crate) mod point_picker; +pub(crate) mod range_slider; +pub(crate) mod slider; +pub(crate) mod thumb_row; pub(crate) mod track; mod words; diff --git a/crates/ui-widgets/src/value_drag/point_picker.rs b/crates/ui-widgets/src/value_drag/point_picker.rs index 89f5df8b3..8417bdd3a 100644 --- a/crates/ui-widgets/src/value_drag/point_picker.rs +++ b/crates/ui-widgets/src/value_drag/point_picker.rs @@ -20,7 +20,7 @@ use egui::{Pos2, Rect, Vec2, pos2}; use std::ops::RangeInclusive; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The point: a drag on it follows the pointer. const THUMB: PartKey = PartKey::new("thumb"); diff --git a/crates/ui-widgets/src/value_drag/range_slider.rs b/crates/ui-widgets/src/value_drag/range_slider.rs index c97893c7a..00fd5547a 100644 --- a/crates/ui-widgets/src/value_drag/range_slider.rs +++ b/crates/ui-widgets/src/value_drag/range_slider.rs @@ -17,7 +17,7 @@ use egui::{Pos2, Rect, Vec2}; use std::ops::RangeInclusive; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The track both thumbs ride on. pub(crate) const TRACK: PartKey = PartKey::new("track"); diff --git a/crates/ui-widgets/src/value_drag/slider.rs b/crates/ui-widgets/src/value_drag/slider.rs index 54bbf032d..88a3b8f7f 100644 --- a/crates/ui-widgets/src/value_drag/slider.rs +++ b/crates/ui-widgets/src/value_drag/slider.rs @@ -18,7 +18,7 @@ use egui::{Pos2, Rect, Vec2}; use std::ops::RangeInclusive; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The track the thumb rides on. pub(crate) const TRACK: PartKey = PartKey::new("track"); diff --git a/crates/ui-widgets/src/value_drag/thumb_row.rs b/crates/ui-widgets/src/value_drag/thumb_row.rs index d96044e60..bf2ba60e8 100644 --- a/crates/ui-widgets/src/value_drag/thumb_row.rs +++ b/crates/ui-widgets/src/value_drag/thumb_row.rs @@ -33,7 +33,7 @@ use std::ops::RangeInclusive; const THUMB_WIDTH_IN_SMALL_HANDLES: f32 = 0.5; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; /// The row-wide part: a press off the thumbs lands here. pub(crate) const ROW: PartKey = PartKey::new("row"); diff --git a/crates/ui-widgets/tests/it/access/mod.rs b/crates/ui-widgets/tests/it/access/mod.rs index 1f8f33f8b..48bc3bb72 100644 --- a/crates/ui-widgets/tests/it/access/mod.rs +++ b/crates/ui-widgets/tests/it/access/mod.rs @@ -1,4 +1,4 @@ //! The accessibility emitter: the label scope and merge rule, announcements, modal inertness, viewports. -mod scroll_into_view; -mod step_ends; +pub(crate) mod scroll_into_view; +pub(crate) mod step_ends; diff --git a/crates/ui-widgets/tests/it/bars/mod.rs b/crates/ui-widgets/tests/it/bars/mod.rs index 39ac29b41..afb93e134 100644 --- a/crates/ui-widgets/tests/it/bars/mod.rs +++ b/crates/ui-widgets/tests/it/bars/mod.rs @@ -1,7 +1,7 @@ //! `Bar` and `BarItems`. -mod bar; -mod breadcrumb; -mod constraint_fields; -mod items; -mod overflow; +pub(crate) mod bar; +pub(crate) mod breadcrumb; +pub(crate) mod constraint_fields; +pub(crate) mod items; +pub(crate) mod overflow; diff --git a/crates/ui-widgets/tests/it/body/mod.rs b/crates/ui-widgets/tests/it/body/mod.rs index 823404bfe..24bc60467 100644 --- a/crates/ui-widgets/tests/it/body/mod.rs +++ b/crates/ui-widgets/tests/it/body/mod.rs @@ -1,4 +1,4 @@ //! The body step and the mount host: regions, scrolling, move and resize, and viewport mounts. -mod scroll; -mod settle; +pub(crate) mod scroll; +pub(crate) mod settle; diff --git a/crates/ui-widgets/tests/it/commands/mod.rs b/crates/ui-widgets/tests/it/commands/mod.rs index c3bed565b..701124194 100644 --- a/crates/ui-widgets/tests/it/commands/mod.rs +++ b/crates/ui-widgets/tests/it/commands/mod.rs @@ -1,3 +1,3 @@ //! The command board: registry, state, the gate, firing and scoped delivery. -mod panel_scope; +pub(crate) mod panel_scope; diff --git a/crates/ui-widgets/tests/it/contract/mod.rs b/crates/ui-widgets/tests/it/contract/mod.rs index 3e028ac93..f50d32ba8 100644 --- a/crates/ui-widgets/tests/it/contract/mod.rs +++ b/crates/ui-widgets/tests/it/contract/mod.rs @@ -1,6 +1,6 @@ //! The component contract and the show pipeline: the steps each shape runs, and the rules the steps keep. -mod elide; -mod faces; -mod measure; -mod state_looks; +pub(crate) mod elide; +pub(crate) mod faces; +pub(crate) mod measure; +pub(crate) mod state_looks; diff --git a/crates/ui-widgets/tests/it/label/mod.rs b/crates/ui-widgets/tests/it/label/mod.rs index 1c36ecfdf..6facfa093 100644 --- a/crates/ui-widgets/tests/it/label/mod.rs +++ b/crates/ui-widgets/tests/it/label/mod.rs @@ -1,17 +1,17 @@ //! The label step: scrub across a pointer warp and the label beside or above a fill-width control. -mod align; -mod baseline; -mod caption; +pub(crate) mod align; +pub(crate) mod baseline; +pub(crate) mod caption; pub mod group; -mod hit; -mod inside; +pub(crate) mod hit; +pub(crate) mod inside; pub mod kit; -mod reach; -mod reset; -mod scheme; -mod short; -mod tooltip; +pub(crate) mod reach; +pub(crate) mod reset; +pub(crate) mod scheme; +pub(crate) mod short; +pub(crate) mod tooltip; use self::kit::{Dial, Field, Seen, Wide}; use craft_host::target::ShellInfo; diff --git a/crates/ui-widgets/tests/it/layer/mod.rs b/crates/ui-widgets/tests/it/layer/mod.rs index f840ad829..29e4970b8 100644 --- a/crates/ui-widgets/tests/it/layer/mod.rs +++ b/crates/ui-widgets/tests/it/layer/mod.rs @@ -1,3 +1,3 @@ //! Layers: what a layer starts with when it opens again. -mod reopen; +pub(crate) mod reopen; diff --git a/crates/ui-widgets/tests/it/layout/mod.rs b/crates/ui-widgets/tests/it/layout/mod.rs index ff427c664..0432e2c4e 100644 --- a/crates/ui-widgets/tests/it/layout/mod.rs +++ b/crates/ui-widgets/tests/it/layout/mod.rs @@ -1,15 +1,15 @@ -mod cross_fill; -mod fill_column; -mod fill_share; -mod fonts; -mod grid_labels; -mod grid_least; -mod nested; -mod room_height; -mod row_line; -mod row_room; -mod rtl_scroll; -mod scroll_region; -mod shrink_order; -mod stack_header; -mod zero_width; +pub(crate) mod cross_fill; +pub(crate) mod fill_column; +pub(crate) mod fill_share; +pub(crate) mod fonts; +pub(crate) mod grid_labels; +pub(crate) mod grid_least; +pub(crate) mod nested; +pub(crate) mod room_height; +pub(crate) mod row_line; +pub(crate) mod row_room; +pub(crate) mod rtl_scroll; +pub(crate) mod scroll_region; +pub(crate) mod shrink_order; +pub(crate) mod stack_header; +pub(crate) mod zero_width; diff --git a/crates/ui-widgets/tests/it/main.rs b/crates/ui-widgets/tests/it/main.rs index dcd439b30..44f614b4d 100644 --- a/crates/ui-widgets/tests/it/main.rs +++ b/crates/ui-widgets/tests/it/main.rs @@ -3,39 +3,43 @@ // The test files name the library as `craft_ui`, as the crates that use it do. extern crate craft_ui_widgets as craft_ui; -mod access; -mod bars; +pub(crate) mod access; +pub(crate) mod bars; pub(crate) mod body; -mod commands; -mod contract; -mod disabled_fade; -mod field_text_centred; -mod keys; -mod label; -mod layer; -mod layout; -mod link; -mod list; -mod menu; -mod notices; -mod overlay; +pub(crate) mod commands; +pub(crate) mod contract; +pub(crate) mod disabled_fade; +pub(crate) mod field_text_centred; +pub(crate) mod keys; +pub(crate) mod label; +pub(crate) mod layer; +pub(crate) mod layout; +pub(crate) mod link; +pub(crate) mod list; +pub(crate) mod menu; +pub(crate) mod notices; +pub(crate) mod overlay; -mod pickers; -mod popover; -mod runtime; +pub(crate) mod pickers; +pub(crate) mod popover; +pub(crate) mod runtime; -mod suite_rtl; -mod suite_rules; -mod suite_title; -mod table; -mod tabs; -mod text; -mod tile_grid; -mod value_drag; -mod values; +pub(crate) mod suite_rtl; +pub(crate) mod suite_rules; +pub(crate) mod suite_title; +pub(crate) mod table; +pub(crate) mod tabs; +pub(crate) mod text; +pub(crate) mod tile_grid; +pub(crate) mod value_drag; +pub(crate) mod values; -use craft_ui::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run( + module_path!(), + env!("CARGO_PKG_NAME"), + &craft_ui::testing::Registry::of(&[register, craft_ui::testing::register, craft_ui_test_kit::testing::register]), + ); } diff --git a/crates/ui-widgets/tests/it/menu/mod.rs b/crates/ui-widgets/tests/it/menu/mod.rs index 1f760725f..161a5364a 100644 --- a/crates/ui-widgets/tests/it/menu/mod.rs +++ b/crates/ui-widgets/tests/it/menu/mod.rs @@ -1,20 +1,20 @@ //! `Menu` and `MenuItem`: the columns of an inline menu's rows. -mod bar; +pub(crate) mod bar; -mod closed; +pub(crate) mod closed; -mod native; +pub(crate) mod native; -mod openers; +pub(crate) mod openers; -mod overflow; +pub(crate) mod overflow; -mod pick_focus; +pub(crate) mod pick_focus; -mod rows; +pub(crate) mod rows; -mod submenus; +pub(crate) mod submenus; use craft_behavior::IconId; use craft_ui::contract::{Show as _, ShowContainer as _}; diff --git a/crates/ui-widgets/tests/it/overlay/mod.rs b/crates/ui-widgets/tests/it/overlay/mod.rs index f2ad8e89c..582d9da48 100644 --- a/crates/ui-widgets/tests/it/overlay/mod.rs +++ b/crates/ui-widgets/tests/it/overlay/mod.rs @@ -1,7 +1,7 @@ //! The overlay host (15): popups, modals and menu picking. -mod hosting; +pub(crate) mod hosting; pub(crate) mod kit; -mod modal; -mod pages; -mod sampler; +pub(crate) mod modal; +pub(crate) mod pages; +pub(crate) mod sampler; diff --git a/crates/ui-widgets/tests/it/pickers/mod.rs b/crates/ui-widgets/tests/it/pickers/mod.rs index 8b2fd8a6b..db94ed692 100644 --- a/crates/ui-widgets/tests/it/pickers/mod.rs +++ b/crates/ui-widgets/tests/it/pickers/mod.rs @@ -1,8 +1,8 @@ //! Dropdown pickers. -mod combo_list; -mod date; -mod select_list; -mod select_steps; -mod select_width; -mod tree_list; +pub(crate) mod combo_list; +pub(crate) mod date; +pub(crate) mod select_list; +pub(crate) mod select_steps; +pub(crate) mod select_width; +pub(crate) mod tree_list; diff --git a/crates/ui-widgets/tests/it/popover/mod.rs b/crates/ui-widgets/tests/it/popover/mod.rs index d25856671..5e0ea49ba 100644 --- a/crates/ui-widgets/tests/it/popover/mod.rs +++ b/crates/ui-widgets/tests/it/popover/mod.rs @@ -1,5 +1,5 @@ //! The popover family (15.5): popup lists and their dismissal. -mod commands; -mod one_at_a_time; -mod popup; +pub(crate) mod commands; +pub(crate) mod one_at_a_time; +pub(crate) mod popup; diff --git a/crates/ui-widgets/tests/it/runtime/mod.rs b/crates/ui-widgets/tests/it/runtime/mod.rs index 66faeeb6a..3063263e7 100644 --- a/crates/ui-widgets/tests/it/runtime/mod.rs +++ b/crates/ui-widgets/tests/it/runtime/mod.rs @@ -1,2 +1,2 @@ -mod bypass; -mod inspect; +pub(crate) mod bypass; +pub(crate) mod inspect; diff --git a/crates/ui-widgets/tests/it/suite_rules.rs b/crates/ui-widgets/tests/it/suite_rules.rs index 72a368d3c..b342fdd06 100644 --- a/crates/ui-widgets/tests/it/suite_rules.rs +++ b/crates/ui-widgets/tests/it/suite_rules.rs @@ -11,8 +11,11 @@ use egui::{Ui, vec2}; fn probe_of() -> &'static Probe { let name = std::any::type_name::(); - craft_ui::contract::registrations() - .into_iter() + static REGISTRY: std::sync::OnceLock = std::sync::OnceLock::new(); + REGISTRY + .get_or_init(|| craft_ui::testing::Registry::of(&[crate::register, craft_ui::testing::register])) + .registrations() + .iter() .filter_map(Registration::probe) .find(|probe| probe.type_name() == name) .expect("the type is registered") diff --git a/crates/ui-widgets/tests/it/text/chips.rs b/crates/ui-widgets/tests/it/text/chips.rs index ab8459894..1b854714e 100644 --- a/crates/ui-widgets/tests/it/text/chips.rs +++ b/crates/ui-widgets/tests/it/text/chips.rs @@ -20,7 +20,7 @@ fn a_draft_adds_its_pieces_after_the_existing_chips() { assert_eq!(codec.parse("two words", &Vec::new()), Ok(chips(&["two words"])), "a space does not end a chip"); } -mod field { +pub(crate) mod field { use craft_ui::contract::{Bind, Role, Show as _}; use craft_ui::testing::access::name; use craft_ui::testing::{Fixture, Story, StoryData, StoryOutput, pointer, trial}; diff --git a/crates/ui-widgets/tests/it/text/mod.rs b/crates/ui-widgets/tests/it/text/mod.rs index d6e55d6f6..0dcca20b7 100644 --- a/crates/ui-widgets/tests/it/text/mod.rs +++ b/crates/ui-widgets/tests/it/text/mod.rs @@ -1,14 +1,14 @@ -mod access; -mod chips; -mod edit_menu; -mod fields; -mod hex; +pub(crate) mod access; +pub(crate) mod chips; +pub(crate) mod edit_menu; +pub(crate) mod fields; +pub(crate) mod hex; mod kit; -mod linked; -mod mixed_blank; -mod number; -mod number_length; -mod selectable; -mod text_field; -mod widths; -mod zoom_field; +pub(crate) mod linked; +pub(crate) mod mixed_blank; +pub(crate) mod number; +pub(crate) mod number_length; +pub(crate) mod selectable; +pub(crate) mod text_field; +pub(crate) mod widths; +pub(crate) mod zoom_field; diff --git a/crates/ui-widgets/tests/it/tile_grid/mod.rs b/crates/ui-widgets/tests/it/tile_grid/mod.rs index be6ff4d7f..e3c99a8a8 100644 --- a/crates/ui-widgets/tests/it/tile_grid/mod.rs +++ b/crates/ui-widgets/tests/it/tile_grid/mod.rs @@ -1,6 +1,6 @@ //! The tile grid family's own logic. -mod cells; -mod grid; -mod keys; -mod tile; +pub(crate) mod cells; +pub(crate) mod grid; +pub(crate) mod keys; +pub(crate) mod tile; diff --git a/crates/ui-widgets/tests/it/value_drag.rs b/crates/ui-widgets/tests/it/value_drag.rs index 862ed342a..507caf2eb 100644 --- a/crates/ui-widgets/tests/it/value_drag.rs +++ b/crates/ui-widgets/tests/it/value_drag.rs @@ -1,9 +1,9 @@ //! `Slider` and `RangeSlider`: the value maths that is the family's own: stepping in the reading direction, the scales //! that spread a range over a track, and thumbs that never cross. -mod dials; +pub(crate) mod dials; -mod thumb_row; +pub(crate) mod thumb_row; use craft_behavior::{EditEvent, MotionMode}; use craft_ui::contract::{Bind, Props as _, Show as _}; diff --git a/crates/ui-widgets/tests/it/values/mod.rs b/crates/ui-widgets/tests/it/values/mod.rs index f121dc92d..8dd255105 100644 --- a/crates/ui-widgets/tests/it/values/mod.rs +++ b/crates/ui-widgets/tests/it/values/mod.rs @@ -1,13 +1,13 @@ //! Values and edits: the binding sources, gestures, cancels, mixed values, checks and the undo adapter. -mod bindings; +pub(crate) mod bindings; -mod gestures; +pub(crate) mod gestures; -mod history; +pub(crate) mod history; pub(crate) mod kit; -mod reads; +pub(crate) mod reads; -mod write_back; +pub(crate) mod write_back; diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index 0188f2d49..b66112c99 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -10,6 +10,8 @@ //! `presence`) from craft-cloud-ui, which is still raw egui. #![warn(missing_docs)] +extern crate self as craft_ui; + #[cfg(feature = "cloud")] pub use craft_cloud_ui::cloud; #[cfg(feature = "esign")] @@ -19,7 +21,7 @@ pub use craft_cloud_ui::presence; pub use craft_cloud_ui::{account, share}; pub use craft_ui_canvas::{canvas, canvas_controls, dialog}; #[cfg(feature = "testing")] -pub use craft_ui_contract::testing_registered; +pub use craft_ui_contract::registry; #[doc(hidden)] pub use craft_ui_contract::{__private, __register_command_set, __register_contract, __register_pattern}; pub use craft_ui_contract::{InstallError, InstallSpec, contract, fonts, install, layout, primitives, runtime, style, words}; @@ -47,37 +49,31 @@ pub mod testing { pub use craft_ui_canvas::testing::*; #[cfg(feature = "suite")] - crate::testing_registered!(); + crate::registry!(); - /// A crate's `registered`. + /// The framework crates whose suite items form the library. #[cfg(feature = "suite")] - type Registered = fn() -> Vec<&'static Registration>; - - /// The crates of the library, each with its `registered`. - #[cfg(feature = "suite")] - const LIBRARY: [(&str, Registered); 7] = [ - ("craft-ui", registered), - ("craft-ui-contract", craft_ui_contract::testing::registered), - ("craft-ui-widgets", craft_ui_widgets::testing::registered), - ("craft-ui-panels", craft_ui_panels::testing::registered), - ("craft-ui-canvas", craft_ui_canvas::testing::registered), - ("craft-ui-patterns", craft_ui_patterns::testing::registered), - ("craft-ui-shell", craft_ui_shell::testing::registered), + const LIBRARY: [fn(&mut Registry); 7] = [ + register, + craft_ui_contract::testing::register, + craft_ui_widgets::testing::register, + craft_ui_panels::testing::register, + craft_ui_canvas::testing::register, + craft_ui_patterns::testing::register, + craft_ui_shell::testing::register, ]; - /// Every registration declared in the library crates of the library: this crate and the six it re-exports. - /// Types declared in integration binaries are fixtures and are left out. + /// Adds the framework library crates to a registry. #[cfg(feature = "suite")] - pub fn library_registrations() -> Vec<&'static Registration> { - // A crate's registrations run only in a binary that links the crate; naming each crate's `registered` - // links them all. - let library = std::hint::black_box(LIBRARY); - crate::contract::registrations() - .into_iter() - .filter(|registration| { - library.iter().any(|(name, _)| *name == registration.crate_name()) - && registration.crate_target() == registration.crate_name().replace('-', "_") - }) - .collect() + pub fn register_library(registry: &mut Registry) { + for register in LIBRARY { + register(registry); + } + } + + /// The suite items declared by the framework library crates. + #[cfg(feature = "suite")] + pub fn library_registrations() -> Registry { + Registry::of(&LIBRARY) } } diff --git a/crates/ui/tests/it/canvas/mod.rs b/crates/ui/tests/it/canvas/mod.rs index af1480537..6a3f1c9d2 100644 --- a/crates/ui/tests/it/canvas/mod.rs +++ b/crates/ui/tests/it/canvas/mod.rs @@ -1,3 +1,3 @@ //! `Canvas` (20.6): a press away from every canvas control's parts reaches the tool. -mod document_canvas; +pub(crate) mod document_canvas; diff --git a/crates/ui/tests/it/components_index.rs b/crates/ui/tests/it/components_index.rs index e932828e1..637a71dd0 100644 --- a/crates/ui/tests/it/components_index.rs +++ b/crates/ui/tests/it/components_index.rs @@ -11,8 +11,10 @@ use std::path::Path; fn the_committed_components_index_is_what_the_registrations_give() { let root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."); let committed = std::fs::read_to_string(root.join("docs/components-index.md")).unwrap_or_default(); + let registry = library_registrations(); + let registrations: Vec<_> = registry.registrations().iter().collect(); assert!( - committed == components_index(&root, &library_registrations()), + committed == components_index(&root, ®istrations), "docs/components-index.md is stale; run `cargo run -p craft-ui-gallery --bin components-index`" ); } @@ -21,6 +23,7 @@ fn the_committed_components_index_is_what_the_registrations_give() { /// together only here. #[trial] fn the_level_tables_name_only_registered_types_and_story_groups() { - let stale = stale_table_rows(&library_registrations()); + let registry = library_registrations(); + let stale = stale_table_rows(®istry); assert!(stale.is_empty(), "stale level table rows: {stale:#?}"); } diff --git a/crates/ui/tests/it/form_dialogs/mod.rs b/crates/ui/tests/it/form_dialogs/mod.rs index d0f4f035a..a07f22d6d 100644 --- a/crates/ui/tests/it/form_dialogs/mod.rs +++ b/crates/ui/tests/it/form_dialogs/mod.rs @@ -1,4 +1,4 @@ //! The form dialogs' own logic: the parameter model, its spec-string parser, the value store, the size model, //! guide layout and the export file name. -mod guides; +pub(crate) mod guides; diff --git a/crates/ui/tests/it/main.rs b/crates/ui/tests/it/main.rs index 5e341b9a8..afe462985 100644 --- a/crates/ui/tests/it/main.rs +++ b/crates/ui/tests/it/main.rs @@ -1,14 +1,18 @@ //! The integration binary of craft-ui: every test is a registered trial. -mod api_map; -mod canvas; -mod components_index; -mod form_dialogs; +pub(crate) mod api_map; +pub(crate) mod canvas; +pub(crate) mod components_index; +pub(crate) mod form_dialogs; -mod shell; +pub(crate) mod shell; -use craft_ui::testing::registered; +craft_ui::registry!(); fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), ®istered()); + craft_ui::testing::run( + module_path!(), + env!("CARGO_PKG_NAME"), + &craft_ui::testing::Registry::of(&[register, craft_ui::testing::register_library]), + ); } diff --git a/crates/ui/tests/it/shell/mod.rs b/crates/ui/tests/it/shell/mod.rs index 2b08cbe45..696f10ab6 100644 --- a/crates/ui/tests/it/shell/mod.rs +++ b/crates/ui/tests/it/shell/mod.rs @@ -1,3 +1,3 @@ //! The window skeleton's interface: what `ShellCx` answers by mode and reveal, and how a body reads it. -mod app_shell; +pub(crate) mod app_shell; diff --git a/crates/update/src/app.rs b/crates/update/src/app.rs index 3d47f8d6d..c4d0d34f7 100644 --- a/crates/update/src/app.rs +++ b/crates/update/src/app.rs @@ -84,7 +84,7 @@ impl App { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/desktop_entry.rs b/crates/update/src/desktop_entry.rs index 95e327425..fa13e5ebf 100644 --- a/crates/update/src/desktop_entry.rs +++ b/crates/update/src/desktop_entry.rs @@ -132,7 +132,7 @@ pub fn exec_program(text: &str) -> Option { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use craft_ui::testing::trial; use super::*; diff --git a/crates/update/src/detect.rs b/crates/update/src/detect.rs index 21fcc1317..4011fbef7 100644 --- a/crates/update/src/detect.rs +++ b/crates/update/src/detect.rs @@ -155,4 +155,4 @@ pub mod linux; pub mod freebsd; #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/update/src/install.rs b/crates/update/src/install.rs index 3a2e883e1..2b1235a09 100644 --- a/crates/update/src/install.rs +++ b/crates/update/src/install.rs @@ -916,4 +916,4 @@ pub(crate) fn msi_path(msi: &Path) -> Result { pub mod windows; #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/update/src/install/tests.rs b/crates/update/src/install/tests.rs index 528cca611..3f3f43781 100644 --- a/crates/update/src/install/tests.rs +++ b/crates/update/src/install/tests.rs @@ -689,7 +689,7 @@ fn install_refuses_while_the_installed_copy_is_running() { } #[cfg(target_os = "macos")] -mod macos_checks { +pub(crate) mod macos_checks { use craft_ui::testing::trial; use super::macos::{CheckTurn, Expect, Signature, TEAM_ID, signed_by}; diff --git a/crates/update/src/lib.rs b/crates/update/src/lib.rs index ebe40129b..7ae50b3a7 100644 --- a/crates/update/src/lib.rs +++ b/crates/update/src/lib.rs @@ -11,8 +11,8 @@ pub mod http; pub mod install; pub mod manifest; pub mod msi_context; -mod msi_copy; -mod msi_migrate; +pub(crate) mod msi_copy; +pub(crate) mod msi_migrate; pub mod packages; pub mod paths; pub mod pins; @@ -51,8 +51,9 @@ pub use version::{Version, is_newer, parse as parse_version}; #[cfg(feature = "screen-testing")] /// The registrations of this package for the integration binary. pub mod testing { + #[cfg(feature = "suite")] - craft_ui::testing_registered!(); + craft_ui::registry!(); } /// Checks for an update against GitHub releases for the given app. @@ -89,12 +90,12 @@ pub(crate) const TEST_AGENT: &str = "ArtCraft-Launcher-Test/0.0"; extern crate self as craft_update; #[cfg(test)] #[path = "../tests/https_only.rs"] -mod https_only; +pub(crate) mod https_only; #[cfg(all(test, feature = "screen-testing"))] #[path = "../tests/it/main.rs"] -mod integration; +pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME"))); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); } diff --git a/crates/update/src/manifest.rs b/crates/update/src/manifest.rs index 8aa02bf10..87e40b337 100644 --- a/crates/update/src/manifest.rs +++ b/crates/update/src/manifest.rs @@ -46,7 +46,7 @@ impl Manifest { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/msi_context.rs b/crates/update/src/msi_context.rs index 414ac4aa8..c1813ea56 100644 --- a/crates/update/src/msi_context.rs +++ b/crates/update/src/msi_context.rs @@ -174,7 +174,7 @@ fn current_user_sid() -> Result { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/msi_copy.rs b/crates/update/src/msi_copy.rs index ea846c704..a29e9776a 100644 --- a/crates/update/src/msi_copy.rs +++ b/crates/update/src/msi_copy.rs @@ -218,7 +218,7 @@ pub(crate) mod windows { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/msi_migrate.rs b/crates/update/src/msi_migrate.rs index 7d8a86226..a80068484 100644 --- a/crates/update/src/msi_migrate.rs +++ b/crates/update/src/msi_migrate.rs @@ -169,7 +169,7 @@ pub(crate) mod windows { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/packages.rs b/crates/update/src/packages.rs index b76cca4b2..9eb80884b 100644 --- a/crates/update/src/packages.rs +++ b/crates/update/src/packages.rs @@ -119,7 +119,7 @@ pub fn version_of(p: &Package) -> Option { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; @@ -183,7 +183,7 @@ pub fn is_artcraft_remote(origin: &str, remotes: &str) -> bool { } #[cfg(test)] -mod remote_url_tests { +pub(crate) mod remote_url_tests { use super::*; use craft_ui::testing::trial; @@ -224,7 +224,7 @@ pub(crate) fn oci_ref_available(reference: &str, expected: &version::Version, li #[cfg(test)] #[cfg(all(target_os = "linux", feature = "oci_migration"))] -mod migration_tests { +pub(crate) mod migration_tests { use super::{oci_ref_available, version}; use craft_ui::testing::trial; @@ -256,7 +256,7 @@ pub fn remote_manages_flatpak(origin: &str, remotes: &str) -> bool { } #[cfg(test)] -mod remote_ownership_tests { +pub(crate) mod remote_ownership_tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/paths.rs b/crates/update/src/paths.rs index 3238610d1..e1d6ad8ef 100644 --- a/crates/update/src/paths.rs +++ b/crates/update/src/paths.rs @@ -87,7 +87,7 @@ pub fn write_atomic(path: &std::path::Path, bytes: &[u8]) -> Result<(), String> #[cfg(test)] #[cfg(unix)] -mod tests { +pub(crate) mod tests { use super::*; #[craft_ui::testing::trial] diff --git a/crates/update/src/pins.rs b/crates/update/src/pins.rs index 1dc1c3a3a..e82fb5702 100644 --- a/crates/update/src/pins.rs +++ b/crates/update/src/pins.rs @@ -151,7 +151,7 @@ impl Pins { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/platform.rs b/crates/update/src/platform.rs index addb21902..07beed1bd 100644 --- a/crates/update/src/platform.rs +++ b/crates/update/src/platform.rs @@ -299,7 +299,7 @@ pub fn pick_asset<'a>(release: &'a Release, stems: &[&str], platform: Platform, } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/portable.rs b/crates/update/src/portable.rs index e6f951f12..8f057e42f 100644 --- a/crates/update/src/portable.rs +++ b/crates/update/src/portable.rs @@ -472,4 +472,4 @@ fn single_top_folder(files: &[PathBuf]) -> Option { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/update/src/process.rs b/crates/update/src/process.rs index cd34af85c..29e584187 100644 --- a/crates/update/src/process.rs +++ b/crates/update/src/process.rs @@ -560,7 +560,7 @@ pub(crate) mod tests { } #[cfg(test)] -mod run_tests { +pub(crate) mod run_tests { use super::*; #[cfg(unix)] @@ -630,7 +630,7 @@ mod run_tests { } #[cfg(test)] -mod inherited_pipe_tests { +pub(crate) mod inherited_pipe_tests { use super::*; use craft_ui::testing::trial; use std::io::{BufRead, BufReader, Read, Write}; @@ -768,7 +768,7 @@ pub(crate) fn cancellable_output(mut cmd: Command, check: impl Fn() -> Result<() #[cfg(test)] #[cfg(target_os = "linux")] -mod update_cancel_tests { +pub(crate) mod update_cancel_tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/proxy.rs b/crates/update/src/proxy.rs index b4e039f61..aee2cc09e 100644 --- a/crates/update/src/proxy.rs +++ b/crates/update/src/proxy.rs @@ -191,7 +191,7 @@ pub fn parse_scutil(out: &str) -> Option { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/queue.rs b/crates/update/src/queue.rs index 59292f01a..2bf756c87 100644 --- a/crates/update/src/queue.rs +++ b/crates/update/src/queue.rs @@ -168,4 +168,4 @@ impl Queue { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/update/src/release.rs b/crates/update/src/release.rs index 370d4d92b..eb4ccc41c 100644 --- a/crates/update/src/release.rs +++ b/crates/update/src/release.rs @@ -365,7 +365,7 @@ pub(crate) fn truncate(s: &str, max: usize) -> String { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/self_update.rs b/crates/update/src/self_update.rs index e71c93e52..9f4ac9d95 100644 --- a/crates/update/src/self_update.rs +++ b/crates/update/src/self_update.rs @@ -321,4 +321,4 @@ pub fn prepare_update_with_options( } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/update/src/source.rs b/crates/update/src/source.rs index 9d24788ca..715624f2a 100644 --- a/crates/update/src/source.rs +++ b/crates/update/src/source.rs @@ -214,7 +214,7 @@ impl ReleaseSource for GitHubSource { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/src/stack_dialogs.rs b/crates/update/src/stack_dialogs.rs index fa3c405eb..7d2f37c31 100644 --- a/crates/update/src/stack_dialogs.rs +++ b/crates/update/src/stack_dialogs.rs @@ -24,7 +24,7 @@ use crate::self_update; use crate::updater::Status; #[cfg(feature = "suite")] -mod stories; +pub(crate) mod stories; const PROMPT_KEY: &str = "updateDialog.prompt"; const CHECK_KEY: &str = "updateDialog.check"; diff --git a/crates/update/src/updater.rs b/crates/update/src/updater.rs index 21ec360aa..8f43e73d8 100644 --- a/crates/update/src/updater.rs +++ b/crates/update/src/updater.rs @@ -1139,4 +1139,4 @@ pub fn download_action(app: &App, release: &Release) -> Action { } #[cfg(test)] -mod tests; +pub(crate) mod tests; diff --git a/crates/update/src/version.rs b/crates/update/src/version.rs index 502afc4ad..d8b68069e 100644 --- a/crates/update/src/version.rs +++ b/crates/update/src/version.rs @@ -148,7 +148,7 @@ pub fn is_update(latest: &Version, installed: &Version) -> bool { } #[cfg(test)] -mod tests { +pub(crate) mod tests { use super::*; use craft_ui::testing::trial; diff --git a/crates/update/tests/it/main.rs b/crates/update/tests/it/main.rs index 1cd188529..71718ba34 100644 --- a/crates/update/tests/it/main.rs +++ b/crates/update/tests/it/main.rs @@ -2,4 +2,4 @@ // Unwrapping, expecting and panicking on failure is fine in tests, unlike in shipped code. #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] -mod update; +pub(crate) mod update; From baffd665e0df437ec79fb22919a9b4c1908658bf Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 13:06:25 +0100 Subject: [PATCH 03/22] Simplify registry scanner path matching --- crates/ui-macros/src/registry.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/crates/ui-macros/src/registry.rs b/crates/ui-macros/src/registry.rs index 68e5a5781..15c068c46 100644 --- a/crates/ui-macros/src/registry.rs +++ b/crates/ui-macros/src/registry.rs @@ -82,14 +82,12 @@ fn contains_suite_item(items: &[Item]) -> bool { fn module_file(dir: &Path, path_dir: &Path, module: &ItemMod) -> Option { for attr in &module.attrs { - if attr.path().is_ident("path") { - if let Meta::NameValue(value) = &attr.meta { - if let syn::Expr::Lit(expr) = &value.value { - if let syn::Lit::Str(path) = &expr.lit { - return Some(path_dir.join(path.value())); - } - } - } + if attr.path().is_ident("path") + && let Meta::NameValue(value) = &attr.meta + && let syn::Expr::Lit(expr) = &value.value + && let syn::Lit::Str(path) = &expr.lit + { + return Some(path_dir.join(path.value())); } } let plain = dir.join(format!("{}.rs", module.ident)); @@ -170,13 +168,13 @@ fn walk( } Item::Macro(item) if item.mac.path.segments.last().is_some_and(|s| s.ident == "register_contract") => { let FirstType(ty) = syn::parse2(item.mac.tokens.clone())?; - if let Type::Path(ty) = ty { - if let Some(name) = ty.path.segments.last() { - let helper = format_ident!("__registry_component_{}", crate::command_set::snake(&name.ident.to_string())); - let mut cfg = inherited.to_vec(); - cfg.extend(attrs_cfg(&item.attrs)); - calls.push(quote! { #(#cfg)* crate::#(#path::)*#helper(registry); }); - } + if let Type::Path(ty) = ty + && let Some(name) = ty.path.segments.last() + { + let helper = format_ident!("__registry_component_{}", crate::command_set::snake(&name.ident.to_string())); + let mut cfg = inherited.to_vec(); + cfg.extend(attrs_cfg(&item.attrs)); + calls.push(quote! { #(#cfg)* crate::#(#path::)*#helper(registry); }); } } _ => {} From f8cf3d5e74ed58a7f35089e7620657e73ac4c4a8 Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 13:37:26 +0100 Subject: [PATCH 04/22] Scope story commands to each registry --- .../ui-contract/src/runtime/commands/board.rs | 18 +-- .../ui-contract/src/runtime/commands/mod.rs | 4 +- .../src/runtime/commands/registry.rs | 108 ++++++++++-------- crates/ui-contract/src/testing/mod.rs | 9 +- crates/ui-contract/src/testing/registry.rs | 12 +- crates/ui-contract/src/testing/suite.rs | 20 +++- crates/ui-contract/tests/it/main.rs | 1 + .../tests/it/story_command_subsets.rs | 68 +++++++++++ crates/ui-gallery/src/main.rs | 4 +- 9 files changed, 173 insertions(+), 71 deletions(-) create mode 100644 crates/ui-contract/tests/it/story_command_subsets.rs diff --git a/crates/ui-contract/src/runtime/commands/board.rs b/crates/ui-contract/src/runtime/commands/board.rs index 0c3d7f8a7..a3879ffbc 100644 --- a/crates/ui-contract/src/runtime/commands/board.rs +++ b/crates/ui-contract/src/runtime/commands/board.rs @@ -460,7 +460,7 @@ pub(crate) fn install(ctx: &Context, stories: bool) -> Result<(), registry::Comm /// A keymap with the chords it binds to the edit commands and to the window's keys. #[derive(Clone)] -struct BuiltKeymap { +pub(crate) struct BuiltKeymap { keymap: Arc, edit_chords: Arc<[(EditCommand, Chord)]>, window_shortcuts: Arc<[(WindowShortcut, Chord)]>, @@ -561,23 +561,17 @@ fn build_keymap(registry: ®istry::Registry, app: Option<&AppCatalog>, platfor BuiltKeymap { keymap: Arc::new(keymap), edit_chords, window_shortcuts } } -/// The keymap of each shared registry (with or without the stories' sets) on each platform with no overrides. It -/// depends on nothing else, so every context of the process shares it. -static DEFAULT_KEYMAPS: std::sync::Mutex> = std::sync::Mutex::new(Vec::new()); - -/// The keymap of `registry` and `app` on `platform` under `overrides`: built once per platform for the shared -/// registry with no overrides and no catalog, else built here. +/// Builds or reuses a keymap owned by this exact command registry. fn keymap_for(registry: &Arc, app: Option<&AppCatalog>, platform: Platform, overrides: Option<&Arc>) -> BuiltKeymap { - if app.is_some() || overrides.is_some() || !registry::Registry::is_shared(registry) { + if app.is_some() || overrides.is_some() { return build_keymap(registry, app, platform, overrides); } - let mut kept = DEFAULT_KEYMAPS.lock().unwrap_or_else(std::sync::PoisonError::into_inner); - let stories = registry.has_stories(); - if let Some((.., built)) = kept.iter().find(|(on, with, _)| *on == platform && *with == stories) { + let mut kept = registry.keymaps.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + if let Some((_, built)) = kept.iter().find(|(on, _)| *on == platform) { return built.clone(); } let built = build_keymap(registry, None, platform, None); - kept.push((platform, stories, built.clone())); + kept.push((platform, built.clone())); built } diff --git a/crates/ui-contract/src/runtime/commands/mod.rs b/crates/ui-contract/src/runtime/commands/mod.rs index 13d4865bc..761614264 100644 --- a/crates/ui-contract/src/runtime/commands/mod.rs +++ b/crates/ui-contract/src/runtime/commands/mod.rs @@ -12,10 +12,10 @@ pub use library::ChromeCommand; pub(crate) use library::WindowShortcut; pub use library::{EditCommands, NavCommand, WindowCommand}; pub use registry::CommandDefError; -#[cfg(feature = "suite")] -pub(crate) use registry::configure_story_sets; #[doc(hidden)] pub use registry::{SetEntry, sets}; +#[cfg(feature = "suite")] +pub(crate) use registry::{StorySelection, configure_story_sets, with_story_sets}; #[doc(hidden)] pub use board::declare_child; diff --git a/crates/ui-contract/src/runtime/commands/registry.rs b/crates/ui-contract/src/runtime/commands/registry.rs index 807f661fe..040290132 100644 --- a/crates/ui-contract/src/runtime/commands/registry.rs +++ b/crates/ui-contract/src/runtime/commands/registry.rs @@ -142,29 +142,55 @@ impl std::error::Error for CommandDefError {} /// The shared registries: the app's sets, and the app's sets with the stories' (`[apps, with stories]`). static LOADED: [OnceLock>; 2] = [OnceLock::new(), OnceLock::new()]; +/// One selected set of story commands and its lazily loaded definitions. #[cfg(feature = "suite")] -static STORY_SETS: OnceLock> = OnceLock::new(); -#[cfg(feature = "suite")] -static STORY_SETS_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(()); +pub(crate) struct StorySelection { + sets: Vec, + loaded: OnceLock>, +} -/// Selects the story command sets before the first story context is installed. #[cfg(feature = "suite")] -pub(crate) fn configure_story_sets(sets: &[SetEntry]) -> bool { - let _guard = STORY_SETS_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner); - if STORY_SETS.get().is_none() && LOADED[1].get().is_some() { - return sets.is_empty(); +impl StorySelection { + pub(crate) fn new(sets: Vec) -> Self { + Self { sets, loaded: OnceLock::new() } } - let selected = STORY_SETS.get_or_init(|| sets.to_vec()); - selected.len() == sets.len() - && selected.iter().zip(sets).all(|(a, b)| { - (a.name)() == (b.name)() - && std::ptr::fn_addr_eq(a.defs, b.defs) - && std::ptr::fn_addr_eq(a.no_default_on, b.no_default_on) - && std::ptr::fn_addr_eq(a.edits, b.edits) - && std::ptr::fn_addr_eq(a.holds, b.holds) - && std::ptr::fn_addr_eq(a.platform_defaults, b.platform_defaults) - && a.typing.map(CommandScope::name) == b.typing.map(CommandScope::name) - }) + + fn shared(&self) -> Result, CommandDefError> { + if let Some(loaded) = self.loaded.get() { + return Ok(loaded.clone()); + } + let loaded = Arc::new(Registry::load_selected(true, &self.sets)?); + Ok(self.loaded.get_or_init(|| loaded).clone()) + } +} + +#[cfg(feature = "suite")] +thread_local! { + static STORY_SETS: std::cell::RefCell>> = const { std::cell::RefCell::new(None) }; +} + +/// Selects story commands for contexts created on this thread. +#[cfg(feature = "suite")] +pub(crate) fn configure_story_sets(selection: Arc) -> bool { + if selection.shared().is_err() { + return false; + } + STORY_SETS.with(|current| *current.borrow_mut() = Some(selection)); + true +} + +/// Runs one trial with its selection and restores the caller's selection. +#[cfg(feature = "suite")] +pub(crate) fn with_story_sets(selection: &Arc, f: impl FnOnce() -> R) -> R { + struct Restore(Option>); + impl Drop for Restore { + fn drop(&mut self) { + STORY_SETS.with(|current| *current.borrow_mut() = self.0.take()); + } + } + let previous = STORY_SETS.with(|current| current.borrow_mut().replace(selection.clone())); + let _restore = Restore(previous); + f() } /// Indexes the definition at `at` under its id `id`; an id already in `index` is refused (`Duplicate`). The registry @@ -191,26 +217,23 @@ pub(crate) struct Registry { holds: HashMap, /// The scopes whose keys are meant for typing (`CommandSet::TYPING`). typing: HashSet<&'static str>, - /// Whether the stories' sets are loaded. - stories: bool, + /// Default keymaps are shared by contexts using this exact registry. + pub(crate) keymaps: std::sync::Mutex>, } impl Registry { /// Loads every linked set; the stories' sets only with `stories`. pub(crate) fn load(stories: bool) -> Result { - let mut registry = Registry { stories, ..Registry::default() }; - let entries = sets(); - #[cfg(feature = "suite")] - let entries = { - let mut entries = entries; - if stories { - if let Some(story_sets) = STORY_SETS.get() { - entries.extend(story_sets.iter()); - entries.sort_by_key(|entry| (entry.name)()); - } - } - entries - }; + Self::load_selected(stories, &[]) + } + + fn load_selected(stories: bool, story_sets: &[SetEntry]) -> Result { + let mut registry = Registry::default(); + let mut entries = sets(); + if stories { + entries.extend(story_sets.iter()); + entries.sort_by_key(|entry| (entry.name)()); + } for entry in entries { for def in (entry.defs)()? { registry.add(def)?; @@ -230,7 +253,12 @@ impl Registry { /// static, so every context shares one. A load that fails is not kept, so each install reports its error. pub(crate) fn shared(stories: bool) -> Result, CommandDefError> { #[cfg(feature = "suite")] - let _guard = stories.then(|| STORY_SETS_LOCK.lock().unwrap_or_else(std::sync::PoisonError::into_inner)); + if stories { + let selection = STORY_SETS.with(|current| current.borrow().clone()); + if let Some(selection) = selection { + return selection.shared(); + } + } let slot = &LOADED[usize::from(stories)]; if let Some(loaded) = slot.get() { return Ok(loaded.clone()); @@ -239,16 +267,6 @@ impl Registry { Ok(slot.get_or_init(|| registry).clone()) } - /// Whether `registry` is one [`Registry::shared`] loaded. - pub(crate) fn is_shared(registry: &Arc) -> bool { - LOADED[usize::from(registry.stories)].get().is_some_and(|loaded| Arc::ptr_eq(loaded, registry)) - } - - /// Whether the stories' sets are loaded. - pub(crate) fn has_stories(&self) -> bool { - self.stories - } - fn add(&mut self, def: CommandDef) -> Result<(), CommandDefError> { index_id(&mut self.index, &def.command.id, self.defs.len())?; self.defs.push(def); diff --git a/crates/ui-contract/src/testing/mod.rs b/crates/ui-contract/src/testing/mod.rs index d4fcf46c1..cd03d3e9c 100644 --- a/crates/ui-contract/src/testing/mod.rs +++ b/crates/ui-contract/src/testing/mod.rs @@ -105,7 +105,7 @@ impl Trial { #[cfg(feature = "suite")] pub fn run(crate_root: &str, package: &'static str, registry: &Registry) -> ! { if !registry.install_story_sets() { - eprintln!("a different set of story commands was already installed"); + eprintln!("the selected story commands are invalid"); std::process::exit(1); } let library = package.replace('-', "_"); @@ -118,9 +118,12 @@ pub fn run(crate_root: &str, package: &'static str, registry: &Registry) -> ! { .filter(|trial| own(trial.module)) .map(|trial| { let run = trial.run; + let story_sets = registry.story_selection(); libtest_mimic::Trial::test(trial.full_name(), move || { - run(); - Ok(()) + crate::runtime::commands::with_story_sets(&story_sets, || { + run(); + Ok(()) + }) }) .with_ignored_flag(trial.ignored) }) diff --git a/crates/ui-contract/src/testing/registry.rs b/crates/ui-contract/src/testing/registry.rs index e3ad20aee..6568fcc12 100644 --- a/crates/ui-contract/src/testing/registry.rs +++ b/crates/ui-contract/src/testing/registry.rs @@ -17,6 +17,7 @@ pub struct Registry { stories: Vec, trials: Vec, story_sets: Vec, + selection: std::sync::OnceLock>, } impl Registry { @@ -53,6 +54,7 @@ impl Registry { /// Adds a command set used by stories. pub fn add_story_set(&mut self, set: SetEntry) { + let _ = self.selection.take(); self.story_sets.push(set); } @@ -71,10 +73,14 @@ impl Registry { &self.trials } - /// Installs the selected story command sets before a story context is created. - /// Returns false if this process already selected a different set. + /// Selects story command sets for contexts created on the current thread. + /// Returns false if the selected definitions are invalid. pub fn install_story_sets(&self) -> bool { - crate::runtime::commands::configure_story_sets(&self.story_sets) + crate::runtime::commands::configure_story_sets(self.story_selection()) + } + + pub(crate) fn story_selection(&self) -> std::sync::Arc { + self.selection.get_or_init(|| std::sync::Arc::new(crate::runtime::commands::StorySelection::new(self.story_sets.clone()))).clone() } /// The selected story command sets. diff --git a/crates/ui-contract/src/testing/suite.rs b/crates/ui-contract/src/testing/suite.rs index d8aed2bbc..037d70f80 100644 --- a/crates/ui-contract/src/testing/suite.rs +++ b/crates/ui-contract/src/testing/suite.rs @@ -211,15 +211,21 @@ pub fn trials(package: &'static str, registry: &Registry) -> Vec { } for (index, group) in GROUPS.iter().enumerate() { let stories = stories.clone(); + let story_sets = registry.story_selection(); let name = format!("suite::{}::{}", probe.type_name(), group.name); - trials.push(Trial::test(name, move || run_group(probe, group, index == 0, true, stories))); + trials.push(Trial::test(name, move || { + crate::runtime::commands::with_story_sets(&story_sets, || run_group(probe, group, index == 0, true, stories)) + })); } } let patterns: Vec = own_registrations.filter_map(Registration::pattern_probe).copied().collect(); for pattern in &patterns { let stories: Vec = own.iter().filter(|entry| (entry.type_name)() == pattern.type_name()).map(|entry| entry.story).collect(); let name = pattern.type_name(); - trials.push(Trial::test(format!("suite::{name}"), move || pattern::run(name, &stories).map_err(Failed::from))); + let story_sets = registry.story_selection(); + trials.push(Trial::test(format!("suite::{name}"), move || { + crate::runtime::commands::with_story_sets(&story_sets, || pattern::run(name, &stories).map_err(Failed::from)) + })); } // Stories of a type another linked package registers run that type's cases here, as its visitors. let mut visited: Vec<&'static str> = Vec::new(); @@ -237,11 +243,17 @@ pub fn trials(package: &'static str, registry: &Registry) -> Vec { visited.push(name); for group in GROUPS { let stories = stories.clone(); - trials.push(Trial::test(format!("suite::{name}::{}", group.name), move || run_group(probe, group, false, false, stories))); + let story_sets = registry.story_selection(); + trials.push(Trial::test(format!("suite::{name}::{}", group.name), move || { + crate::runtime::commands::with_story_sets(&story_sets, || run_group(probe, group, false, false, stories)) + })); } } else if registration.pattern_probe().is_some() { visited.push(name); - trials.push(Trial::test(format!("suite::{name}"), move || pattern::run(name, &stories).map_err(Failed::from))); + let story_sets = registry.story_selection(); + trials.push(Trial::test(format!("suite::{name}"), move || { + crate::runtime::commands::with_story_sets(&story_sets, || pattern::run(name, &stories).map_err(Failed::from)) + })); } else { let message = format!("the story `{}` shows `{name}`, which is not in the linked registrations", entry.story.name); trials.push(Trial::test(format!("suite::stories::{}", entry.story.name), move || Err(Failed::from(message)))); diff --git a/crates/ui-contract/tests/it/main.rs b/crates/ui-contract/tests/it/main.rs index 7d0cf6b56..bbc639e4e 100644 --- a/crates/ui-contract/tests/it/main.rs +++ b/crates/ui-contract/tests/it/main.rs @@ -19,6 +19,7 @@ pub(crate) mod paint; pub(crate) mod runtime; +pub(crate) mod story_command_subsets; pub(crate) mod style; pub(crate) mod text; diff --git a/crates/ui-contract/tests/it/story_command_subsets.rs b/crates/ui-contract/tests/it/story_command_subsets.rs new file mode 100644 index 000000000..0e3678d89 --- /dev/null +++ b/crates/ui-contract/tests/it/story_command_subsets.rs @@ -0,0 +1,68 @@ +//! Story command selections stay with each context. + +use craft_ui::contract::CommandSet; +use craft_ui::runtime::commands::resolve; +use craft_ui::testing::{Fixture, Registry, trial}; +use std::sync::{Arc, Barrier}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, CommandSet)] +#[command(prefix = "subsetAlpha", story)] +enum Alpha { + #[command(label = "Subset Alpha")] + Run, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, CommandSet)] +#[command(prefix = "subsetBeta", story)] +enum Beta { + #[command(label = "Subset Beta")] + Run, +} + +fn alpha(registry: &mut Registry) { + registry.add_story_set(__registry_command_alpha()); +} +fn beta(registry: &mut Registry) { + registry.add_story_set(__registry_command_beta()); +} + +fn selected(alpha_selected: bool, barrier: Arc) { + let registry = if alpha_selected { Registry::of(&[alpha]) } else { Registry::of(&[beta]) }; + barrier.wait(); + assert!(registry.install_story_sets()); + let mut fixture = Fixture::new(|_| {}); + fixture.settle(); + let alpha_label = resolve(fixture.ctx(), Alpha::Run).label; + let beta_label = resolve(fixture.ctx(), Beta::Run).label; + assert_eq!(alpha_label.as_ref() == "Subset Alpha", alpha_selected); + assert_eq!(beta_label.as_ref() == "Subset Beta", !alpha_selected); +} + +#[trial] +fn separate_story_command_subsets_can_run_concurrently() { + let alpha_registry = Registry::of(&[alpha]); + let beta_registry = Registry::of(&[beta]); + assert!(alpha_registry.install_story_sets()); + let mut first = Fixture::new(|_| {}); + first.settle(); + assert!(beta_registry.install_story_sets()); + let mut second = Fixture::new(|_| {}); + second.settle(); + assert_eq!(resolve(first.ctx(), Alpha::Run).label.as_ref(), "Subset Alpha"); + assert_ne!(resolve(first.ctx(), Beta::Run).label.as_ref(), "Subset Beta"); + assert_eq!(resolve(second.ctx(), Beta::Run).label.as_ref(), "Subset Beta"); + assert_ne!(resolve(second.ctx(), Alpha::Run).label.as_ref(), "Subset Alpha"); + let builds = craft_ui::runtime::commands::keymap_builds(); + let mut another = Fixture::new(|_| {}); + another.settle(); + assert_eq!(craft_ui::runtime::commands::keymap_builds(), builds, "a second context reuses its registry's keymap"); + + let barrier = Arc::new(Barrier::new(2)); + let first = { + let barrier = barrier.clone(); + std::thread::spawn(move || selected(true, barrier)) + }; + let second = std::thread::spawn(move || selected(false, barrier)); + assert!(first.join().is_ok()); + assert!(second.join().is_ok()); +} diff --git a/crates/ui-gallery/src/main.rs b/crates/ui-gallery/src/main.rs index e946e3da0..035cd405b 100644 --- a/crates/ui-gallery/src/main.rs +++ b/crates/ui-gallery/src/main.rs @@ -15,7 +15,7 @@ fn spec() -> AppSpec { #[cfg(not(target_arch = "wasm32"))] fn main() { if !craft_ui_gallery::registry().install_story_sets() { - eprintln!("a different set of story commands was already installed"); + eprintln!("the selected story commands are invalid"); std::process::exit(1); } if let Err(error) = craft_ui::shell::app::run(spec(), |_| Gallery::open()) { @@ -33,7 +33,7 @@ fn main() { wasm_bindgen_futures::spawn_local(async { if !craft_ui_gallery::registry().install_story_sets() { - console::error_1(&JsValue::from_str("a different set of story commands was already installed")); + console::error_1(&JsValue::from_str("the selected story commands are invalid")); return; } let (counts, stories) = craft_ui_gallery::linked_counts(); From 41b2c32801c773bd494725cd18f24079ebd199a1 Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 13:58:10 +0100 Subject: [PATCH 05/22] Restore generated imaging stories to registry --- .../src/contract/registry_expansion.rs | 8 ++ crates/imaging/src/ui/layer_style/stories.rs | 78 +++++++++++++------ crates/imaging/src/ui/select_mask/stories.rs | 40 ++++++---- 3 files changed, 88 insertions(+), 38 deletions(-) diff --git a/crates/design-lint/src/contract/registry_expansion.rs b/crates/design-lint/src/contract/registry_expansion.rs index 3a85f01a5..22a125eb5 100644 --- a/crates/design-lint/src/contract/registry_expansion.rs +++ b/crates/design-lint/src/contract/registry_expansion.rs @@ -111,6 +111,14 @@ pub(super) fn check(cx: &Cx<'_>, out: &mut Vec) { mod tests { use super::*; + #[test] + fn detects_story_attributes_inside_repeated_macro_expansions() { + let source = r#"macro_rules! stories { ($($name:ident),*) => { $( #[story(Widget, covers = [])] fn $name() {} )* }; }"#; + let file = syn::parse_file(source).expect("valid macro definition"); + let syn::Item::Macro(item) = &file.items[0] else { panic!("expected macro definition") }; + assert!(has_registration(item.mac.tokens.clone())); + } + #[test] fn detects_hidden_registrations_and_allows_unregistered_derive() { let hidden = TokenStream::from_str("#[derive(Component)] struct A; #[trial] fn t() {} ").unwrap_or_default(); diff --git a/crates/imaging/src/ui/layer_style/stories.rs b/crates/imaging/src/ui/layer_style/stories.rs index 522739f13..9a8fbf0c9 100644 --- a/crates/imaging/src/ui/layer_style/stories.rs +++ b/crates/imaging/src/ui/layer_style/stories.rs @@ -157,28 +157,62 @@ fn layer_style_styles(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { host(ui, data, || page_of(&[EffectKind::DropShadow], Some(LayerStylePage::Styles)), &rgb(&words)) } -/// One story per effect kind: the dialog on that effect's page. -macro_rules! effect_stories { - ($($name:ident => $kind:ident),* $(,)?) => { - $( - #[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] - fn $name(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { - let words = Env::of(ui).words::(); - host(ui, data, || page_of(&[EffectKind::$kind], None), &rgb(&words)) - } - )* - }; +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_bevel_emboss(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::BevelEmboss], None), &rgb(&words)) } -effect_stories! { - layer_style_bevel_emboss => BevelEmboss, - layer_style_stroke => Stroke, - layer_style_inner_shadow => InnerShadow, - layer_style_inner_glow => InnerGlow, - layer_style_satin => Satin, - layer_style_color_overlay => ColorOverlay, - layer_style_gradient_overlay => GradientOverlay, - layer_style_pattern_overlay => PatternOverlay, - layer_style_outer_glow => OuterGlow, - layer_style_drop_shadow => DropShadow, +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_stroke(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::Stroke], None), &rgb(&words)) +} + +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_inner_shadow(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::InnerShadow], None), &rgb(&words)) +} + +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_inner_glow(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::InnerGlow], None), &rgb(&words)) +} + +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_satin(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::Satin], None), &rgb(&words)) +} + +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_color_overlay(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::ColorOverlay], None), &rgb(&words)) +} + +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_gradient_overlay(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::GradientOverlay], None), &rgb(&words)) +} + +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_pattern_overlay(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::PatternOverlay], None), &rgb(&words)) +} + +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_outer_glow(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::OuterGlow], None), &rgb(&words)) +} + +#[story(LayerStyleDialog<'static>, covers = [], drive = Drive::Never)] +fn layer_style_drop_shadow(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let words = Env::of(ui).words::(); + host(ui, data, || page_of(&[EffectKind::DropShadow], None), &rgb(&words)) } diff --git a/crates/imaging/src/ui/select_mask/stories.rs b/crates/imaging/src/ui/select_mask/stories.rs index 40a341d2b..2bfd781a7 100644 --- a/crates/imaging/src/ui/select_mask/stories.rs +++ b/crates/imaging/src/ui/select_mask/stories.rs @@ -81,27 +81,35 @@ fn viewing(view: MaskViewMode) -> SelectMaskSettings { SelectMaskSettings { view, ..SelectMaskSettings::default() } } -/// One story per view: the workspace with that view chosen. -macro_rules! view_story { - ($name:ident, $view:expr) => { - #[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)] - fn $name(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { - show_workspace(ui, data, viewing($view), false) - } - }; -} - #[story(SelectMaskWorkspace, covers = [Default], drive = Drive::Never)] fn workspace(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { show_workspace(ui, data, SelectMaskSettings::default(), false) } -view_story!(view_marching_ants, MaskViewMode::MarchingAnts); -view_story!(view_overlay, MaskViewMode::Overlay); -view_story!(view_on_black, MaskViewMode::OnBlack); -view_story!(view_on_white, MaskViewMode::OnWhite); -view_story!(view_black_and_white, MaskViewMode::BlackAndWhite); -view_story!(view_on_layers, MaskViewMode::OnLayers); +#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)] +fn view_marching_ants(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + show_workspace(ui, data, viewing(MaskViewMode::MarchingAnts), false) +} +#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)] +fn view_overlay(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + show_workspace(ui, data, viewing(MaskViewMode::Overlay), false) +} +#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)] +fn view_on_black(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + show_workspace(ui, data, viewing(MaskViewMode::OnBlack), false) +} +#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)] +fn view_on_white(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + show_workspace(ui, data, viewing(MaskViewMode::OnWhite), false) +} +#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)] +fn view_black_and_white(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + show_workspace(ui, data, viewing(MaskViewMode::BlackAndWhite), false) +} +#[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)] +fn view_on_layers(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + show_workspace(ui, data, viewing(MaskViewMode::OnLayers), false) +} #[story(SelectMaskWorkspace, covers = [], drive = Drive::Never)] fn workspace_with_refinements(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { From 938d170b87a402851154c39e2d0ed201e08f92db Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 14:11:23 +0100 Subject: [PATCH 06/22] Keep library trials available without a UI suite and preserve the generator API --- crates/automation/src/lib.rs | 3 ++- crates/browse/src/lib.rs | 3 ++- crates/color-ui/src/lib.rs | 3 ++- crates/dialogs/src/lib.rs | 3 ++- crates/draw/src/lib.rs | 3 ++- crates/imaging/src/lib.rs | 3 ++- crates/pages/src/lib.rs | 3 ++- crates/print/src/lib.rs | 3 ++- crates/review/src/lib.rs | 3 ++- crates/text/src/hyphen/mod.rs | 2 +- crates/text/src/lib.rs | 3 ++- crates/theme-editor/src/lib.rs | 3 ++- crates/theme-store/src/lib.rs | 3 ++- crates/timeline/src/lib.rs | 3 ++- crates/ui-macros/src/component.rs | 17 +++++++++------- crates/ui-macros/src/lib.rs | 2 +- crates/ui-macros/src/registry.rs | 32 +++++++++++++++++++++---------- crates/ui-macros/src/tests.rs | 9 +++------ crates/update/src/lib.rs | 3 ++- 19 files changed, 65 insertions(+), 39 deletions(-) diff --git a/crates/automation/src/lib.rs b/crates/automation/src/lib.rs index 339015183..2e66c6d6f 100644 --- a/crates/automation/src/lib.rs +++ b/crates/automation/src/lib.rs @@ -70,5 +70,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/browse/src/lib.rs b/crates/browse/src/lib.rs index 2ca6cba0a..029c8c2bc 100644 --- a/crates/browse/src/lib.rs +++ b/crates/browse/src/lib.rs @@ -24,5 +24,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::ui::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/color-ui/src/lib.rs b/crates/color-ui/src/lib.rs index fba4f89c7..49a93c7ea 100644 --- a/crates/color-ui/src/lib.rs +++ b/crates/color-ui/src/lib.rs @@ -31,5 +31,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::ui::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/dialogs/src/lib.rs b/crates/dialogs/src/lib.rs index 763876054..be0cde168 100644 --- a/crates/dialogs/src/lib.rs +++ b/crates/dialogs/src/lib.rs @@ -400,5 +400,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/draw/src/lib.rs b/crates/draw/src/lib.rs index 2e7e1ea2a..9c3772468 100644 --- a/crates/draw/src/lib.rs +++ b/crates/draw/src/lib.rs @@ -22,5 +22,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/imaging/src/lib.rs b/crates/imaging/src/lib.rs index 77b7dac13..631f47adf 100644 --- a/crates/imaging/src/lib.rs +++ b/crates/imaging/src/lib.rs @@ -29,5 +29,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/pages/src/lib.rs b/crates/pages/src/lib.rs index 3a58fdb6d..d6abe6938 100644 --- a/crates/pages/src/lib.rs +++ b/crates/pages/src/lib.rs @@ -55,5 +55,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/print/src/lib.rs b/crates/print/src/lib.rs index 86922604e..ea3b45778 100644 --- a/crates/print/src/lib.rs +++ b/crates/print/src/lib.rs @@ -1090,5 +1090,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/review/src/lib.rs b/crates/review/src/lib.rs index 5beb64ebb..931b7f571 100644 --- a/crates/review/src/lib.rs +++ b/crates/review/src/lib.rs @@ -46,5 +46,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/text/src/hyphen/mod.rs b/crates/text/src/hyphen/mod.rs index d664811ec..9eed829f2 100644 --- a/crates/text/src/hyphen/mod.rs +++ b/crates/text/src/hyphen/mod.rs @@ -14,7 +14,7 @@ //! Then the paragraph's limits ([`Limits`]) are applied. #[cfg(feature = "generator")] -pub(crate) mod dict; +pub mod dict; #[cfg(not(feature = "generator"))] pub(crate) mod dict; #[cfg(feature = "generator")] diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index 4c724fbe7..b13506f45 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -71,7 +71,8 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } /// Paragraph-wide line composition with stateful line measurement. diff --git a/crates/theme-editor/src/lib.rs b/crates/theme-editor/src/lib.rs index 2c33c17c9..2730241e4 100644 --- a/crates/theme-editor/src/lib.rs +++ b/crates/theme-editor/src/lib.rs @@ -33,5 +33,6 @@ pub mod testing { #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/theme-store/src/lib.rs b/crates/theme-store/src/lib.rs index 33f491219..b20d4708c 100644 --- a/crates/theme-store/src/lib.rs +++ b/crates/theme-store/src/lib.rs @@ -74,5 +74,6 @@ pub(crate) mod two_processes; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::ui::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/timeline/src/lib.rs b/crates/timeline/src/lib.rs index 679c94ea0..1c6b85a19 100644 --- a/crates/timeline/src/lib.rs +++ b/crates/timeline/src/lib.rs @@ -99,5 +99,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } diff --git a/crates/ui-macros/src/component.rs b/crates/ui-macros/src/component.rs index ebf5d48a6..65c236eed 100644 --- a/crates/ui-macros/src/component.rs +++ b/crates/ui-macros/src/component.rs @@ -179,25 +179,28 @@ pub(crate) fn purpose_of(attrs: &[Attribute]) -> String { sentence.trim_end_matches('.').to_owned() } -/// The attributes on a registration block, from the crate being compiled. See `gate_for`. -pub(crate) fn registration_gate() -> TokenStream { +/// Whether the crate being compiled declares its own suite feature. +pub(crate) fn declares_suite() -> bool { let manifest = std::env::var_os("CARGO_MANIFEST_DIR").and_then(|dir| std::fs::read_to_string(std::path::Path::new(&dir).join("Cargo.toml")).ok()); - gate_for(manifest.as_deref().unwrap_or_default()) + declares_suite_in(manifest.as_deref().unwrap_or_default()) } /// The attributes on a registration block. The registration's types can exist only under the defining package's /// `suite` feature, which may be off while craft-ui's `testing` is on, so the block is gated on it (the cfg /// is evaluated in the defining crate) when the package's `manifest` declares that feature, and is not gated otherwise. -pub(crate) fn gate_for(manifest: &str) -> TokenStream { +pub(crate) fn declares_suite_in(manifest: &str) -> bool { let mut in_features = false; - let declares = manifest.lines().map(str::trim).any(|line| { + manifest.lines().map(str::trim).any(|line| { if line.starts_with('[') { in_features = line.trim_end_matches(|c: char| c.is_whitespace()) == "[features]"; return false; } in_features && line.strip_prefix("suite").is_some_and(|rest| rest.trim_start().starts_with('=')) - }); - if declares { quote!(#[cfg(feature = "suite")]) } else { quote!() } + }) +} + +pub(crate) fn registration_gate() -> TokenStream { + if declares_suite() { quote!(#[cfg(feature = "suite")]) } else { quote!() } } fn registry_helper(types: &[Type]) -> syn::Result { diff --git a/crates/ui-macros/src/lib.rs b/crates/ui-macros/src/lib.rs index 6d666df3a..31633ee43 100644 --- a/crates/ui-macros/src/lib.rs +++ b/crates/ui-macros/src/lib.rs @@ -135,7 +135,7 @@ pub fn trial(attr: TokenStream, item: TokenStream) -> TokenStream { } let ident = &sig.ident; let name = ident.to_string(); - let gate = component::registration_gate(); + let gate = component::declares_suite().then(|| quote!(#[cfg(any(test, feature = "suite"))])); let helper = quote::format_ident!("__registry_trial_{}", ident); quote! { #gate diff --git a/crates/ui-macros/src/registry.rs b/crates/ui-macros/src/registry.rs index 15c068c46..53bf34e0c 100644 --- a/crates/ui-macros/src/registry.rs +++ b/crates/ui-macros/src/registry.rs @@ -99,6 +99,12 @@ fn module_file(dir: &Path, path_dir: &Path, module: &ItemMod) -> Option } } +#[derive(Default)] +struct Registrations { + trials: Vec, + suite: Vec, +} + fn walk( items: &[Item], file: &Path, @@ -106,7 +112,7 @@ fn walk( path_dir: &Path, path: &[Ident], inherited: &[Attribute], - calls: &mut Vec, + calls: &mut Registrations, ) -> syn::Result<()> { for item in items { match item { @@ -137,7 +143,7 @@ fn walk( let helper = format_ident!("__registry_component_{}", crate::command_set::snake(&item.ident.to_string())); let mut cfg = inherited.to_vec(); cfg.extend(attrs_cfg(&item.attrs)); - calls.push(quote! { #(#cfg)* crate::#(#path::)*#helper(registry); }); + calls.suite.push(quote! { #(#cfg)* crate::#(#path::)*#helper(registry); }); } Item::Fn(item) if marker(&item.attrs, "story") || marker(&item.attrs, "trial") => { let (prefix, method) = @@ -145,13 +151,14 @@ fn walk( let helper = format_ident!("__registry_{}_{}", prefix, item.sig.ident); let mut cfg = inherited.to_vec(); cfg.extend(attrs_cfg(&item.attrs)); - calls.push(quote! { #(#cfg)* registry.#method(crate::#(#path::)*#helper()); }); + let entries = if marker(&item.attrs, "trial") { &mut calls.trials } else { &mut calls.suite }; + entries.push(quote! { #(#cfg)* registry.#method(crate::#(#path::)*#helper()); }); } Item::Enum(item) if derives(&item.attrs, "CommandSet") && opt(&item.attrs, "command", "story") => { let helper = format_ident!("__registry_command_{}", crate::command_set::snake(&item.ident.to_string())); let mut cfg = inherited.to_vec(); cfg.extend(attrs_cfg(&item.attrs)); - calls.push(quote! { #(#cfg)* registry.add_story_set(crate::#(#path::)*#helper()); }); + calls.suite.push(quote! { #(#cfg)* registry.add_story_set(crate::#(#path::)*#helper()); }); } Item::Macro(item) if item.mac.path.is_ident("include") => { let expression: syn::Expr = syn::parse2(item.mac.tokens.clone())?; @@ -174,7 +181,7 @@ fn walk( let helper = format_ident!("__registry_component_{}", crate::command_set::snake(&name.ident.to_string())); let mut cfg = inherited.to_vec(); cfg.extend(attrs_cfg(&item.attrs)); - calls.push(quote! { #(#cfg)* crate::#(#path::)*#helper(registry); }); + calls.suite.push(quote! { #(#cfg)* crate::#(#path::)*#helper(registry); }); } } _ => {} @@ -193,13 +200,17 @@ pub fn expand() -> syn::Result { let source = if invocation.starts_with(&src) { src.join("lib.rs") } else { invocation }; let text = std::fs::read_to_string(&source).map_err(|e| syn::Error::new(Span::call_site(), format!("cannot read {}: {e}", source.display())))?; let parsed = syn::parse_file(&text)?; - let mut calls = Vec::new(); + let mut calls = Registrations::default(); walk(&parsed.items, &source, source.parent().unwrap_or(&manifest), source.parent().unwrap_or(&manifest), &[], &[], &mut calls)?; let k = crate::util::ui_crate(); + let Registrations { trials, suite } = calls; + let gate = crate::component::registration_gate(); Ok(quote! { /// Adds this crate's suite items to the caller's registry. pub fn register(registry: &mut #k::testing::Registry) { - #(#calls)* + #(#trials)* + #gate + { #(#suite)* } } }) } @@ -214,7 +225,7 @@ mod tests { let parsed = syn::parse_file("include!(\"included.rs\");"); assert!(parsed.is_ok()); if let Ok(parsed) = parsed { - let mut calls = Vec::new(); + let mut calls = Registrations::default(); let dir = root.parent().unwrap_or(Path::new("")); assert!(walk(&parsed.items, &root, dir, dir, &[], &[], &mut calls).is_err()); } @@ -227,11 +238,12 @@ mod tests { let parsed = syn::parse_file(&source); assert!(parsed.is_ok()); if let Ok(parsed) = parsed { - let mut calls = Vec::new(); + let mut calls = Registrations::default(); let result = walk(&parsed.items, &root, root.parent().unwrap_or(Path::new("")), root.parent().unwrap_or(Path::new("")), &[], &[], &mut calls); assert!(result.is_ok()); - let generated = quote! { #(#calls)* }.to_string(); + let Registrations { trials, suite } = calls; + let generated = quote! { #(#trials)* #(#suite)* }.to_string(); assert!(generated.contains("feature = \"sample\"")); assert!(generated.contains("__registry_story_view")); assert!(generated.contains("__registry_trial_changes")); diff --git a/crates/ui-macros/src/tests.rs b/crates/ui-macros/src/tests.rs index b6ae5d5d6..ed0ed2c36 100644 --- a/crates/ui-macros/src/tests.rs +++ b/crates/ui-macros/src/tests.rs @@ -1,13 +1,10 @@ //! The registration gate the component derive reads from the package manifest. -use proc_macro2::TokenStream; - #[test] fn registration_is_gated_only_when_the_package_declares_suite() { - let compact = |tokens: TokenStream| tokens.to_string().split_whitespace().collect::(); let declared = "[package]\nname = \"app\"\n\n[features]\nsuite = [\"craft-ui/testing\"]\n"; - assert_eq!(compact(crate::component::gate_for(declared)), "#[cfg(feature=\"suite\")]"); + assert!(crate::component::declares_suite_in(declared)); let undeclared = "[package]\nname = \"gallery\"\nsuite = 1\n\n[dependencies]\nsuite = \"1\"\n"; - assert_eq!(compact(crate::component::gate_for(undeclared)), ""); - assert_eq!(compact(crate::component::gate_for("")), ""); + assert!(!crate::component::declares_suite_in(undeclared)); + assert!(!crate::component::declares_suite_in("")); } diff --git a/crates/update/src/lib.rs b/crates/update/src/lib.rs index 7ae50b3a7..06897fd1d 100644 --- a/crates/update/src/lib.rs +++ b/crates/update/src/lib.rs @@ -97,5 +97,6 @@ pub(crate) mod integration; #[cfg(test)] fn main() { - craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register])); + craft_ui::registry!(); + craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[register])); } From 6aff4cb1dde37c675619c5037dae478e92d1103d Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 14:37:53 +0100 Subject: [PATCH 07/22] Honor inner module conditions in registry discovery --- crates/ui-macros/src/registry.rs | 13 ++++++++++++- crates/ui-macros/tests/fixtures/registry/child.rs | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/ui-macros/src/registry.rs b/crates/ui-macros/src/registry.rs index 53bf34e0c..5dc543577 100644 --- a/crates/ui-macros/src/registry.rs +++ b/crates/ui-macros/src/registry.rs @@ -17,7 +17,15 @@ impl Parse for FirstType { } fn attrs_cfg(attrs: &[Attribute]) -> Vec { - attrs.iter().filter(|a| a.path().is_ident("cfg") || a.path().is_ident("cfg_attr")).cloned().collect() + attrs + .iter() + .filter(|a| a.path().is_ident("cfg") || a.path().is_ident("cfg_attr")) + .cloned() + .map(|mut attr| { + attr.style = syn::AttrStyle::Outer; + attr + }) + .collect() } fn derives(attrs: &[Attribute], wanted: &str) -> bool { @@ -129,6 +137,7 @@ fn walk( .map_err(|e| syn::Error::new_spanned(module, format!("cannot read {}: {e}", file.display())))?; let parsed = syn::parse_file(&text).map_err(|e| syn::Error::new_spanned(module, format!("cannot parse {}: {e}", file.display())))?; + cfg.extend(attrs_cfg(&parsed.attrs)); let child_dir = if file.file_name().is_some_and(|n| n == "mod.rs" || n == "main.rs" || n == "lib.rs") { file.parent().unwrap_or(dir).to_path_buf() } else { @@ -248,6 +257,8 @@ mod tests { assert!(generated.contains("__registry_story_view")); assert!(generated.contains("__registry_trial_changes")); assert!(generated.contains("__registry_trial_path_trial")); + assert!(generated.contains("cfg (not (target_arch = \"wasm32\"))")); + assert!(!generated.contains("# !")); } } } diff --git a/crates/ui-macros/tests/fixtures/registry/child.rs b/crates/ui-macros/tests/fixtures/registry/child.rs index 58ec79e0f..832cf8638 100644 --- a/crates/ui-macros/tests/fixtures/registry/child.rs +++ b/crates/ui-macros/tests/fixtures/registry/child.rs @@ -1,3 +1,5 @@ +#![cfg(not(target_arch = "wasm32"))] + #[story(Widget)] fn view() {} From 6ac9069b9d37257ed75b8468f3ee022317ab3511 Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 14:49:38 +0100 Subject: [PATCH 08/22] Fix registry expansion lint warnings --- .../src/contract/registry_expansion.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/design-lint/src/contract/registry_expansion.rs b/crates/design-lint/src/contract/registry_expansion.rs index 22a125eb5..16c40b7f9 100644 --- a/crates/design-lint/src/contract/registry_expansion.rs +++ b/crates/design-lint/src/contract/registry_expansion.rs @@ -62,15 +62,16 @@ fn has_registration(tokens: TokenStream) -> bool { } continue; } - if let TokenTree::Ident(ident) = &trees[i] { - if ident == "register_contract" && trees.get(i + 1).is_some_and(|t| matches!(t, TokenTree::Punct(p) if p.as_char() == '!')) { - return true; - } + if let TokenTree::Ident(ident) = &trees[i] + && ident == "register_contract" + && trees.get(i + 1).is_some_and(|t| matches!(t, TokenTree::Punct(p) if p.as_char() == '!')) + { + return true; } - if let TokenTree::Group(group) = &trees[i] { - if has_registration(group.stream()) { - return true; - } + if let TokenTree::Group(group) = &trees[i] + && has_registration(group.stream()) + { + return true; } i += 1; } From d9a3c6d7cef9445f65a02ed07e6aeb7560fd7aac Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 15:05:49 +0100 Subject: [PATCH 09/22] Fix gallery registry test lint --- crates/ui-gallery/tests/it/registry.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ui-gallery/tests/it/registry.rs b/crates/ui-gallery/tests/it/registry.rs index 40b1a6dea..eeb7e4f99 100644 --- a/crates/ui-gallery/tests/it/registry.rs +++ b/crates/ui-gallery/tests/it/registry.rs @@ -33,10 +33,11 @@ fn gallery_registers_each_suite_dependency() { } if let Some(features) = manifest.get("features").and_then(toml::Value::as_table) { for value in features.values().filter_map(toml::Value::as_array).flatten().filter_map(toml::Value::as_str) { - if let Some(name) = value.strip_suffix("/suite") { - if name.starts_with("craft-") && name != "craft-ui" { - dependencies.insert(name.to_owned()); - } + if let Some(name) = value.strip_suffix("/suite") + && name.starts_with("craft-") + && name != "craft-ui" + { + dependencies.insert(name.to_owned()); } } } From 6e36fda0864cae3b28e629b49f4dcb789b4b1a6d Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 16:50:33 +0100 Subject: [PATCH 10/22] Generate the facade suite feature --- crates/craft/Cargo.toml | 23 ++++++++++++++++++++++- crates/craft/tests/features.rs | 7 ++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/crates/craft/Cargo.toml b/crates/craft/Cargo.toml index 6fbd896bb..5a6b4bcd5 100644 --- a/crates/craft/Cargo.toml +++ b/crates/craft/Cargo.toml @@ -216,7 +216,6 @@ craft-suite-account = { workspace = true, optional = true } craft-xfa = { workspace = true, optional = true } [features] -suite = ["screen-testing", "craft-ui/suite", "craft-automation?/suite", "craft-browse?/suite", "craft-color-ui?/suite", "craft-dialogs?/suite", "craft-draw?/suite", "craft-font-manager?/suite", "craft-imaging?/suite", "craft-layers?/suite", "craft-menu?/suite", "craft-pages?/suite", "craft-print?/suite", "craft-review?/suite", "craft-table?/suite", "craft-text?/suite", "craft-theme-editor?/suite", "craft-theme-store?/suite", "craft-timeline?/suite", "craft-update?/suite"] ui = [ "dep:craft-ui", "dep:egui", @@ -261,6 +260,28 @@ screen-testing = [ "craft-timeline?/screen-testing", "craft-update?/screen-testing", ] +suite = [ + "screen-testing", + "craft-ui/suite", + "craft-automation?/suite", + "craft-browse?/suite", + "craft-color-ui?/suite", + "craft-dialogs?/suite", + "craft-draw?/suite", + "craft-font-manager?/suite", + "craft-imaging?/suite", + "craft-layers?/suite", + "craft-menu?/suite", + "craft-pages?/suite", + "craft-print?/suite", + "craft-review?/suite", + "craft-table?/suite", + "craft-text?/suite", + "craft-theme-editor?/suite", + "craft-theme-store?/suite", + "craft-timeline?/suite", + "craft-update?/suite", +] aaf = ["dep:craft-aaf"] aep = ["dep:craft-aep"] diff --git a/crates/craft/tests/features.rs b/crates/craft/tests/features.rs index a57212b1f..0f376068a 100644 --- a/crates/craft/tests/features.rs +++ b/crates/craft/tests/features.rs @@ -8,7 +8,7 @@ use common::{Member, members}; use std::collections::BTreeMap; /// Crate features forwarded by their own rule, not as `-`. -const SHARED: &[&str] = &["ui", "screen-testing"]; +const SHARED: &[&str] = &["ui", "screen-testing", "suite"]; /// Facade features that do not build for `wasm32-unknown-unknown`, noted on their line. const NATIVE_ONLY: &[(&str, &str)] = &[ @@ -66,6 +66,11 @@ fn expected(members: &[Member]) -> String { out += &line("screen-testing", &testing, None); out += "\n"; + let mut suite = vec!["screen-testing".to_owned(), "craft-ui/suite".to_owned()]; + suite.extend(forwarded_to_all(members, "suite").into_iter().filter(|entry| entry != "craft-ui?/suite")); + out += &line("suite", &suite, None); + out += "\n"; + let mut seen: BTreeMap = BTreeMap::new(); for m in members { let mut group = String::new(); From 2e307a79bca5754efc4d5049f10baa21d6b79ab0 Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 17:02:11 +0100 Subject: [PATCH 11/22] Keep gallery registrations in owned catalogs --- crates/design-lint/src/workspace.rs | 2 ++ crates/ui-contract/src/testing/story.rs | 1 + crates/ui-gallery/src/chrome/card.rs | 8 ++++---- crates/ui-gallery/src/chrome/overview.rs | 2 +- crates/ui-gallery/src/lib.rs | 5 ++--- crates/ui-gallery/src/viewer/catalog.rs | 11 ++++++----- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/design-lint/src/workspace.rs b/crates/design-lint/src/workspace.rs index 80d4f53f8..3c57cd1cd 100644 --- a/crates/design-lint/src/workspace.rs +++ b/crates/design-lint/src/workspace.rs @@ -135,6 +135,8 @@ const NO_GLOBAL_STATE_PREFIXES: &[&str] = &[ /// a `static` or `thread_local!` item or [`FS`] for `std::fs`. Each group names the settled fact or environment key that /// covers it, or the later task of craft-libs#2336 that removes the state. A new item in these files is flagged. const NO_GLOBAL_STATE: &[(&str, &str)] = &[ + // Compile-time registry discovery reads the defining crate's source, never a view input. + ("crates/ui-macros/src/registry.rs", FS), // The trait's home crate: it implements `MemoProps` by hand for std and framework value types. ("crates/ui-contract/src/contract/memo.rs", "MemoProps"), // Settled fact: constant font bytes, decompressed once from compile-time input and immutable after init. diff --git a/crates/ui-contract/src/testing/story.rs b/crates/ui-contract/src/testing/story.rs index eea92afa7..a60f60d16 100644 --- a/crates/ui-contract/src/testing/story.rs +++ b/crates/ui-contract/src/testing/story.rs @@ -178,6 +178,7 @@ impl Story { /// A story registered by `#[story]`, linked to its type by the type's registered name. #[doc(hidden)] +#[derive(Clone, Copy)] #[non_exhaustive] pub struct StoryRegistration { /// The package that declares the story. diff --git a/crates/ui-gallery/src/chrome/card.rs b/crates/ui-gallery/src/chrome/card.rs index 75754c601..66957596c 100644 --- a/crates/ui-gallery/src/chrome/card.rs +++ b/crates/ui-gallery/src/chrome/card.rs @@ -61,14 +61,14 @@ pub struct CardStory<'a> { /// The index of the story in the catalog: the key of its state. pub index: usize, /// The story. - pub story: &'static StoryRegistration, + pub story: StoryRegistration, /// The story's caption. pub caption: &'a str, } impl<'a> CardStory<'a> { /// The story at catalog index `index`, under `caption`. - pub fn new(index: usize, story: &'static StoryRegistration, caption: &'a str) -> Self { + pub fn new(index: usize, story: StoryRegistration, caption: &'a str) -> Self { CardStory { index, story, caption } } } @@ -241,7 +241,7 @@ pub struct StoryBody { /// The id scope of the story: unique among the stories of a pass. pub key: String, /// The story. - pub story: &'static StoryRegistration, + pub story: StoryRegistration, /// The surface the story sits on. pub surface: Surface, /// The most a story that fills takes. @@ -268,7 +268,7 @@ pub struct BodyShown { impl StoryBody { /// The body of `story` on `surface`, in the window's look, with ungated wheel takers. - pub fn new(key: impl Into, story: &'static StoryRegistration, surface: Surface, room: f32, panel_pad: Pad) -> Self { + pub fn new(key: impl Into, story: StoryRegistration, surface: Surface, room: f32, panel_pad: Pad) -> Self { StoryBody { key: key.into(), story, surface, room, look: Look::default(), gated: false, panel_pad, caption: None, inspect: None } } diff --git a/crates/ui-gallery/src/chrome/overview.rs b/crates/ui-gallery/src/chrome/overview.rs index f9892f4bd..6255b3aec 100644 --- a/crates/ui-gallery/src/chrome/overview.rs +++ b/crates/ui-gallery/src/chrome/overview.rs @@ -36,7 +36,7 @@ pub struct SpecStory { /// The index of the story in the catalog. pub index: usize, /// The story's registration. - pub story: &'static StoryRegistration, + pub story: StoryRegistration, /// The story's caption. pub caption: String, } diff --git a/crates/ui-gallery/src/lib.rs b/crates/ui-gallery/src/lib.rs index ac528766e..a83fd504d 100644 --- a/crates/ui-gallery/src/lib.rs +++ b/crates/ui-gallery/src/lib.rs @@ -72,9 +72,8 @@ pub fn register_all(registry: &mut craft_ui::testing::Registry) { } /// The registry of the viewer and the crates whose stories it shows. -pub fn registry() -> &'static craft_ui::testing::Registry { - static REGISTRY: std::sync::OnceLock = std::sync::OnceLock::new(); - REGISTRY.get_or_init(|| craft_ui::testing::Registry::of(&[register_all])) +pub fn registry() -> craft_ui::testing::Registry { + craft_ui::testing::Registry::of(&[register_all]) } /// How many registrations each selected crate contributes, and how many stories there are in all. diff --git a/crates/ui-gallery/src/viewer/catalog.rs b/crates/ui-gallery/src/viewer/catalog.rs index df7280146..9b3b47b20 100644 --- a/crates/ui-gallery/src/viewer/catalog.rs +++ b/crates/ui-gallery/src/viewer/catalog.rs @@ -10,7 +10,7 @@ use std::sync::OnceLock; #[non_exhaustive] pub struct Entry { /// The registration. - pub registration: &'static StoryRegistration, + pub registration: StoryRegistration, /// The registered name of the type the story shows. pub type_name: &'static str, } @@ -109,7 +109,8 @@ pub fn fold_filter(filter: &str) -> String { pub(crate) fn linked_catalog() -> &'static contract::Catalog { static CATALOG: OnceLock = OnceLock::new(); CATALOG.get_or_init(|| { - let registrations: Vec<_> = crate::registry().registrations().iter().collect(); + let registry = crate::registry(); + let registrations: Vec<_> = registry.registrations().iter().collect(); contract::catalog(®istrations) }) } @@ -121,7 +122,7 @@ pub fn display_name(type_name: &str) -> String { /// Every story linked into the viewer, ordered by type then story name. pub fn entries() -> Vec { - crate::registry().stories().iter().map(|registration| Entry { registration, type_name: (registration.type_name)() }).collect() + crate::registry().stories().iter().map(|registration| Entry { registration: *registration, type_name: (registration.type_name)() }).collect() } /// What a registration says about a type: where it is declared and what it is for. @@ -133,7 +134,7 @@ pub struct Declared { /// The first sentence of the type's doc comment. pub purpose: &'static str, /// The component probe; `None` for a pattern. - pub probe: Option<&'static Probe>, + pub probe: Option, } /// The registration of each registered component and pattern type, by the type's registered name. @@ -142,7 +143,7 @@ pub fn declared() -> HashMap<&'static str, Declared> { for registration in crate::registry().registrations() { match registration { Registration::Component(probe) => { - out.insert(probe.type_name(), Declared { module: probe.module, purpose: probe.purpose, probe: Some(probe) }); + out.insert(probe.type_name(), Declared { module: probe.module, purpose: probe.purpose, probe: Some(*probe) }); } Registration::Pattern(probe) => { out.insert(probe.type_name(), Declared { module: probe.module, purpose: probe.purpose, probe: None }); From 7e8b19c329dea1fd295086776ccad00b07d3b783 Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 17:11:55 +0100 Subject: [PATCH 12/22] Reuse selected registry when building gallery catalog --- crates/ui-gallery/src/viewer/catalog.rs | 29 +++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/crates/ui-gallery/src/viewer/catalog.rs b/crates/ui-gallery/src/viewer/catalog.rs index 9b3b47b20..d3a5d784c 100644 --- a/crates/ui-gallery/src/viewer/catalog.rs +++ b/crates/ui-gallery/src/viewer/catalog.rs @@ -107,9 +107,20 @@ pub fn fold_filter(filter: &str) -> String { /// The registry's catalog of the types linked into the running binary: each one's level and plain name. pub(crate) fn linked_catalog() -> &'static contract::Catalog { + linked_catalog_from(None) +} + +fn linked_catalog_from(registry: Option<&craft_ui::testing::Registry>) -> &'static contract::Catalog { static CATALOG: OnceLock = OnceLock::new(); CATALOG.get_or_init(|| { - let registry = crate::registry(); + let owned; + let registry = match registry { + Some(registry) => registry, + None => { + owned = crate::registry(); + &owned + } + }; let registrations: Vec<_> = registry.registrations().iter().collect(); contract::catalog(®istrations) }) @@ -120,9 +131,8 @@ pub fn display_name(type_name: &str) -> String { linked_catalog().entry(type_name).map_or_else(|| type_name.to_owned(), |entry| entry.name.clone()) } -/// Every story linked into the viewer, ordered by type then story name. -pub fn entries() -> Vec { - crate::registry().stories().iter().map(|registration| Entry { registration: *registration, type_name: (registration.type_name)() }).collect() +fn entries_from(registry: &craft_ui::testing::Registry) -> Vec { + registry.stories().iter().map(|registration| Entry { registration: *registration, type_name: (registration.type_name)() }).collect() } /// What a registration says about a type: where it is declared and what it is for. @@ -137,10 +147,9 @@ pub struct Declared { pub probe: Option, } -/// The registration of each registered component and pattern type, by the type's registered name. -pub fn declared() -> HashMap<&'static str, Declared> { +fn declared_from(registry: &craft_ui::testing::Registry) -> HashMap<&'static str, Declared> { let mut out = HashMap::new(); - for registration in crate::registry().registrations() { + for registration in registry.registrations() { match registration { Registration::Component(probe) => { out.insert(probe.type_name(), Declared { module: probe.module, purpose: probe.purpose, probe: Some(*probe) }); @@ -189,8 +198,10 @@ pub struct Catalog { impl Catalog { /// The catalog of the stories linked into the running binary. pub fn linked() -> Self { - let entries = entries(); - let declared = declared(); + let registry = crate::registry(); + linked_catalog_from(Some(®istry)); + let entries = entries_from(®istry); + let declared = declared_from(®istry); let components = components(&entries); Catalog::new(entries, components, declared) } From c6fe3ac04bcf0ec60887e333075272fbc5eae171 Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 17:13:36 +0100 Subject: [PATCH 13/22] Detect suite registrations in macro invocations --- .../src/contract/registry_expansion.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/design-lint/src/contract/registry_expansion.rs b/crates/design-lint/src/contract/registry_expansion.rs index 16c40b7f9..ee423f44d 100644 --- a/crates/design-lint/src/contract/registry_expansion.rs +++ b/crates/design-lint/src/contract/registry_expansion.rs @@ -33,6 +33,10 @@ fn has_registration(tokens: TokenStream) -> bool { attrs.push(attr); i += 2; } + if attrs.is_empty() { + i += 1; + continue; + } if attrs.iter().any(|attr| words(attr).first().is_some_and(|word| *word == "story" || *word == "trial")) { return true; } @@ -85,9 +89,7 @@ struct Walk<'a, 'b> { impl<'ast> Visit<'ast> for Walk<'_, '_> { fn visit_item_macro(&mut self, item: &'ast syn::ItemMacro) { - let hidden = if item.mac.path.is_ident("macro_rules") { - has_registration(item.mac.tokens.clone()) - } else if item.mac.path.is_ident("include") { + let hidden = if item.mac.path.is_ident("include") { syn::parse2::(item.mac.tokens.clone()) .ok() .and_then(|path| self.cx.path.parent().map(|parent| parent.join(path.value()))) @@ -95,7 +97,7 @@ impl<'ast> Visit<'ast> for Walk<'_, '_> { .and_then(|source| TokenStream::from_str(&source).ok()) .is_some_and(has_registration) } else { - false + has_registration(item.mac.tokens.clone()) }; if hidden { self.cx.flag_span(self.out, ID, ID, item.span(), "suite registration inside a macro or include is invisible to registry!".to_owned()); @@ -120,6 +122,14 @@ mod tests { assert!(has_registration(item.mac.tokens.clone())); } + #[test] + fn detects_trial_inside_a_proptest_invocation() { + let source = "proptest! { #![proptest_config(ProptestConfig::with_cases(48))] #[trial] fn roundtrip(value in 0u8..4) {} }"; + let file = syn::parse_file(source).expect("valid macro invocation"); + let syn::Item::Macro(item) = &file.items[0] else { panic!("expected macro invocation") }; + assert!(has_registration(item.mac.tokens.clone())); + } + #[test] fn detects_hidden_registrations_and_allows_unregistered_derive() { let hidden = TokenStream::from_str("#[derive(Component)] struct A; #[trial] fn t() {} ").unwrap_or_default(); From cf66b3ab6c1ca8fec042ec93c86195082522bbe2 Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 17:17:06 +0100 Subject: [PATCH 14/22] Register timeline property trials explicitly --- crates/timeline/tests/it/fcp7.rs | 125 ++++++++++++++--------- crates/timeline/tests/it/fcpxml.rs | 156 +++++++++++++++++------------ crates/timeline/tests/it/otio.rs | 137 +++++++++++++++---------- 3 files changed, 257 insertions(+), 161 deletions(-) diff --git a/crates/timeline/tests/it/fcp7.rs b/crates/timeline/tests/it/fcp7.rs index f26e952c8..5af8c63c3 100644 --- a/crates/timeline/tests/it/fcp7.rs +++ b/crates/timeline/tests/it/fcp7.rs @@ -447,54 +447,89 @@ fn gen_clip() -> impl Strategy { ) } -proptest! { - #![proptest_config(ProptestConfig::with_cases(48))] - #[trial] - fn xmeml_roundtrip(clips in prop::collection::vec(gen_clip(), 1..20), ri in 0usize..5) { - let rate = [FrameRate::FPS_23_976, FrameRate::FPS_25, FrameRate::FPS_29_97, FrameRate::FPS_59_94, FrameRate::FPS_24][ri]; - let mut p = Project::new("P"); - let ms = [media(&mut p, "/x/one.mov", true, true, rate), media(&mut p, "/x/two.mov", true, true, rate), media(&mut p, "/y/three four.mxf", true, true, rate)]; - let s = sequence(&mut p, "S", rate, false); - let mut ends = [0i64; 3]; - let mut prev: [Option; 3] = [None; 3]; - let mut aends = [0i64; 3]; - for g in &clips { - let t = ends[g.track] + g.gap; - let v = clip(&mut p, s, TrackKind::Video, g.track, ms[g.media], t..t + (g.dur), g.src); - { - let q = p.sequence_mut(s).unwrap(); - let (_, it) = q.find_item_mut(v).unwrap(); - it.enabled = g.enabled; - match g.speed { - 1 => it.speed = 2.0, - 2 => it.speed = 0.5, - 3 => it.reverse = true, +#[trial] +fn xmeml_roundtrip() { + let mut config = ProptestConfig::with_cases(48); + config.source_file = Some(file!()); + let mut runner = proptest::test_runner::TestRunner::new(config); + runner + .run(&(prop::collection::vec(gen_clip(), 1..20), 0usize..5), |(clips, ri)| { + let rate = [FrameRate::FPS_23_976, FrameRate::FPS_25, FrameRate::FPS_29_97, FrameRate::FPS_59_94, FrameRate::FPS_24][ri]; + let mut p = Project::new("P"); + let ms = [ + media(&mut p, "/x/one.mov", true, true, rate), + media(&mut p, "/x/two.mov", true, true, rate), + media(&mut p, "/y/three four.mxf", true, true, rate), + ]; + let s = sequence(&mut p, "S", rate, false); + let mut ends = [0i64; 3]; + let mut prev: [Option; 3] = [None; 3]; + let mut aends = [0i64; 3]; + for g in &clips { + let t = ends[g.track] + g.gap; + let v = clip(&mut p, s, TrackKind::Video, g.track, ms[g.media], t..t + (g.dur), g.src); + { + let q = p.sequence_mut(s).unwrap(); + let (_, it) = q.find_item_mut(v).unwrap(); + it.enabled = g.enabled; + match g.speed { + 1 => it.speed = 2.0, + 2 => it.speed = 0.5, + 3 => it.reverse = true, + _ => {} + } + } + let d = g.tr_len; + let adjacent = g.gap == 0 && prev[g.track].is_some(); + match g.tr { + 0 if adjacent => transition( + &mut p, + s, + (TrackKind::Video, g.track), + "cross_dissolve", + (prev[g.track], Some(v)), + t - d / 2..t - d / 2 + (d), + TransitionAlign::CenterAtCut, + ), + 1 if adjacent => transition( + &mut p, + s, + (TrackKind::Video, g.track), + "dip_to_white", + (prev[g.track], Some(v)), + t..t + (d), + TransitionAlign::StartAtCut, + ), + 2 if adjacent => transition( + &mut p, + s, + (TrackKind::Video, g.track), + "push", + (prev[g.track], Some(v)), + t - d..t - d + (d), + TransitionAlign::EndAtCut, + ), + 3 if !adjacent => { + transition(&mut p, s, (TrackKind::Video, g.track), "cross_dissolve", (None, Some(v)), t..t + (d), TransitionAlign::StartAtCut) + } _ => {} } + if g.audio && aends[g.track] <= t { + let a = clip(&mut p, s, TrackKind::Audio, g.track, ms[g.media], t..t + (g.dur), g.src); + link(&mut p, s, &[v, a]); + aends[g.track] = t + g.dur; + } + ends[g.track] = t + g.dur; + prev[g.track] = Some(v); } - let d = g.tr_len; - let adjacent = g.gap == 0 && prev[g.track].is_some(); - match g.tr { - 0 if adjacent => transition(&mut p, s, (TrackKind::Video, g.track), "cross_dissolve", (prev[g.track], Some(v)), t - d / 2..t - d / 2 + (d), TransitionAlign::CenterAtCut), - 1 if adjacent => transition(&mut p, s, (TrackKind::Video, g.track), "dip_to_white", (prev[g.track], Some(v)), t..t + (d), TransitionAlign::StartAtCut), - 2 if adjacent => transition(&mut p, s, (TrackKind::Video, g.track), "push", (prev[g.track], Some(v)), t - d..t - d + (d), TransitionAlign::EndAtCut), - 3 if !adjacent => transition(&mut p, s, (TrackKind::Video, g.track), "cross_dissolve", (None, Some(v)), t..t + (d), TransitionAlign::StartAtCut), - _ => {} - } - if g.audio && aends[g.track] <= t { - let a = clip(&mut p, s, TrackKind::Audio, g.track, ms[g.media], t..t + (g.dur), g.src); - link(&mut p, s, &[v, a]); - aends[g.track] = t + g.dur; - } - ends[g.track] = t + g.dur; - prev[g.track] = Some(v); - } - let (imp, text, _) = fcp7_roundtrip(&p, s, &xopts()); - let si = only_seq(&imp); - prop_assert_eq!(structure(&imp.project, si, TrackKind::Video), structure(&p, s, TrackKind::Video), "{}", text); - prop_assert_eq!(structure(&imp.project, si, TrackKind::Audio), structure(&p, s, TrackKind::Audio)); - prop_assert_eq!(links(&imp.project, si), links(&p, s)); - } + let (imp, text, _) = fcp7_roundtrip(&p, s, &xopts()); + let si = only_seq(&imp); + prop_assert_eq!(structure(&imp.project, si, TrackKind::Video), structure(&p, s, TrackKind::Video), "{}", text); + prop_assert_eq!(structure(&imp.project, si, TrackKind::Audio), structure(&p, s, TrackKind::Audio)); + prop_assert_eq!(links(&imp.project, si), links(&p, s)); + Ok(()) + }) + .unwrap(); } #[trial] diff --git a/crates/timeline/tests/it/fcpxml.rs b/crates/timeline/tests/it/fcpxml.rs index 2e68828b7..060439994 100644 --- a/crates/timeline/tests/it/fcpxml.rs +++ b/crates/timeline/tests/it/fcpxml.rs @@ -424,76 +424,102 @@ fn gen_clip() -> impl Strategy { ) } -proptest! { - #![proptest_config(ProptestConfig::with_cases(48))] - #[trial] - fn fcpxml_roundtrip(clips in prop::collection::vec(gen_clip(), 1..20), ri in 0usize..5) { - let rate = [FrameRate::FPS_23_976, FrameRate::FPS_25, FrameRate::FPS_29_97, FrameRate::FPS_59_94, FrameRate::FPS_24][ri]; - let mut p = Project::new("P"); - let ms = [media(&mut p, "/x/one.mov", true, true, rate), media(&mut p, "/x/two.mov", true, true, rate), media(&mut p, "/y/three four.mxf", true, true, rate)]; - let wav = media(&mut p, "/y/vo.wav", false, true, rate); - let s = sequence(&mut p, "S", rate, false); - let mut ends = [0i64; 3]; - let mut prev: [Option; 3] = [None; 3]; - let mut aends = [0i64; 3]; - for g in &clips { - let t = ends[g.track] + g.gap; - let v = clip(&mut p, s, TrackKind::Video, g.track, ms[g.media], t..t + (g.dur), g.src); - { - let q = p.sequence_mut(s).unwrap(); - let (_, it) = q.find_item_mut(v).unwrap(); - it.enabled = g.enabled; - match g.speed { - 1 => it.speed = 2.0, - 2 => it.speed = 0.5, - 3 => it.reverse = true, - _ => {} +#[trial] +fn fcpxml_roundtrip() { + let mut config = ProptestConfig::with_cases(48); + config.source_file = Some(file!()); + let mut runner = proptest::test_runner::TestRunner::new(config); + runner + .run(&(prop::collection::vec(gen_clip(), 1..20), 0usize..5), |(clips, ri)| { + let rate = [FrameRate::FPS_23_976, FrameRate::FPS_25, FrameRate::FPS_29_97, FrameRate::FPS_59_94, FrameRate::FPS_24][ri]; + let mut p = Project::new("P"); + let ms = [ + media(&mut p, "/x/one.mov", true, true, rate), + media(&mut p, "/x/two.mov", true, true, rate), + media(&mut p, "/y/three four.mxf", true, true, rate), + ]; + let wav = media(&mut p, "/y/vo.wav", false, true, rate); + let s = sequence(&mut p, "S", rate, false); + let mut ends = [0i64; 3]; + let mut prev: [Option; 3] = [None; 3]; + let mut aends = [0i64; 3]; + for g in &clips { + let t = ends[g.track] + g.gap; + let v = clip(&mut p, s, TrackKind::Video, g.track, ms[g.media], t..t + (g.dur), g.src); + { + let q = p.sequence_mut(s).unwrap(); + let (_, it) = q.find_item_mut(v).unwrap(); + it.enabled = g.enabled; + match g.speed { + 1 => it.speed = 2.0, + 2 => it.speed = 0.5, + 3 => it.reverse = true, + _ => {} + } } - } - let d = g.tr_len; - let adjacent = g.gap == 0 && prev[g.track].is_some(); - if g.track == 0 { - match g.tr { - 0 if adjacent && d >= 2 => transition(&mut p, s, (TrackKind::Video, 0), "cross_dissolve", (prev[0], Some(v)), t - d / 2..t - d / 2 + (d), TransitionAlign::CenterAtCut), - 1 if adjacent => transition(&mut p, s, (TrackKind::Video, 0), "dip_to_white", (prev[0], Some(v)), t..t + (d), TransitionAlign::StartAtCut), - 2 if adjacent => transition(&mut p, s, (TrackKind::Video, 0), "push", (prev[0], Some(v)), t - d..t - d + (d), TransitionAlign::EndAtCut), - 3 if !adjacent => transition(&mut p, s, (TrackKind::Video, 0), "cross_dissolve", (None, Some(v)), t..t + (d), TransitionAlign::StartAtCut), - _ => {} - } - } - if aends[g.track] <= t { - match g.audio { - // linked, same-numbered audio track, identical timing - 1 => { - let a = clip(&mut p, s, TrackKind::Audio, g.track, ms[g.media], t..t + (g.dur), g.src); - { - let q = p.sequence_mut(s).unwrap(); - let (sp, rv, en) = { let (_, it) = q.find_item(v).unwrap(); (it.speed, it.reverse, it.enabled) }; - let (_, ai) = q.find_item_mut(a).unwrap(); - ai.speed = sp; - ai.reverse = rv; - ai.enabled = en; + let d = g.tr_len; + let adjacent = g.gap == 0 && prev[g.track].is_some(); + if g.track == 0 { + match g.tr { + 0 if adjacent && d >= 2 => transition( + &mut p, + s, + (TrackKind::Video, 0), + "cross_dissolve", + (prev[0], Some(v)), + t - d / 2..t - d / 2 + (d), + TransitionAlign::CenterAtCut, + ), + 1 if adjacent => { + transition(&mut p, s, (TrackKind::Video, 0), "dip_to_white", (prev[0], Some(v)), t..t + (d), TransitionAlign::StartAtCut) } - link(&mut p, s, &[v, a]); - aends[g.track] = t + g.dur; + 2 if adjacent => { + transition(&mut p, s, (TrackKind::Video, 0), "push", (prev[0], Some(v)), t - d..t - d + (d), TransitionAlign::EndAtCut) + } + 3 if !adjacent => { + transition(&mut p, s, (TrackKind::Video, 0), "cross_dissolve", (None, Some(v)), t..t + (d), TransitionAlign::StartAtCut) + } + _ => {} } - // independent audio-only clip - 2 => { - clip(&mut p, s, TrackKind::Audio, g.track, wav, t..t + (g.dur), g.src); - aends[g.track] = t + g.dur; - } - _ => {} } + if aends[g.track] <= t { + match g.audio { + // linked, same-numbered audio track, identical timing + 1 => { + let a = clip(&mut p, s, TrackKind::Audio, g.track, ms[g.media], t..t + (g.dur), g.src); + { + let q = p.sequence_mut(s).unwrap(); + let (sp, rv, en) = { + let (_, it) = q.find_item(v).unwrap(); + (it.speed, it.reverse, it.enabled) + }; + let (_, ai) = q.find_item_mut(a).unwrap(); + ai.speed = sp; + ai.reverse = rv; + ai.enabled = en; + } + link(&mut p, s, &[v, a]); + aends[g.track] = t + g.dur; + } + // independent audio-only clip + 2 => { + clip(&mut p, s, TrackKind::Audio, g.track, wav, t..t + (g.dur), g.src); + aends[g.track] = t + g.dur; + } + _ => {} + } + } + ends[g.track] = t + g.dur; + prev[g.track] = Some(v); } - ends[g.track] = t + g.dur; - prev[g.track] = Some(v); - } - let (imp, text, _) = roundtrip(&p, s, Format::Fcpxml, &xopts()); - let si = only_seq(&imp); - prop_assert_eq!(structure(&imp.project, si, TrackKind::Video), structure(&p, s, TrackKind::Video), "{}", text); - prop_assert_eq!(structure(&imp.project, si, TrackKind::Audio), structure(&p, s, TrackKind::Audio), "{}", text); - prop_assert_eq!(links(&imp.project, si), links(&p, s)); - } + let (imp, text, _) = roundtrip(&p, s, Format::Fcpxml, &xopts()); + let si = only_seq(&imp); + prop_assert_eq!(structure(&imp.project, si, TrackKind::Video), structure(&p, s, TrackKind::Video), "{}", text); + prop_assert_eq!(structure(&imp.project, si, TrackKind::Audio), structure(&p, s, TrackKind::Audio), "{}", text); + prop_assert_eq!(links(&imp.project, si), links(&p, s)); + Ok(()) + }) + .unwrap(); } /// filmcraft#2195: a relative `src` is a URL like an absolute one: `boats%20b.mov` is the file `boats b.mov`. diff --git a/crates/timeline/tests/it/otio.rs b/crates/timeline/tests/it/otio.rs index 74d333c4e..df0d35d14 100644 --- a/crates/timeline/tests/it/otio.rs +++ b/crates/timeline/tests/it/otio.rs @@ -478,60 +478,95 @@ fn gen_clip() -> impl Strategy { ) } -proptest! { - #![proptest_config(ProptestConfig::with_cases(48))] - #[trial] - fn otio_roundtrip(clips in prop::collection::vec(gen_clip(), 1..20), ri in 0usize..5) { - let rate = [FrameRate::FPS_23_976, FrameRate::FPS_25, FrameRate::FPS_29_97, FrameRate::FPS_59_94, FrameRate::FPS_24][ri]; - let mut p = Project::new("P"); - let ms = [media(&mut p, "/x/one.mov", true, true, rate), media(&mut p, "/x/two.mov", true, true, rate), media(&mut p, "/y/three four.mxf", true, true, rate)]; - let s = sequence(&mut p, "S", rate, rate == FrameRate::FPS_29_97); - let mut ends = [0i64; 3]; - let mut prev: [Option; 3] = [None; 3]; - let mut aend = [Tick::ZERO; 3]; - for g in &clips { - let t = ends[g.track] + g.gap; - let v = clip(&mut p, s, TrackKind::Video, g.track, ms[g.media], t..t + (g.dur), g.src); - { - let q = p.sequence_mut(s).unwrap(); - let (_, it) = q.find_item_mut(v).unwrap(); - it.enabled = g.enabled; - match g.speed { - 1 => it.speed = 2.0, - 2 => it.speed = 0.5, - 3 => it.reverse = true, - 4 => it.frame_hold = Some(rate.tick_of(g.src + 3)), +#[trial] +fn otio_roundtrip() { + let mut config = ProptestConfig::with_cases(48); + config.source_file = Some(file!()); + let mut runner = proptest::test_runner::TestRunner::new(config); + runner + .run(&(prop::collection::vec(gen_clip(), 1..20), 0usize..5), |(clips, ri)| { + let rate = [FrameRate::FPS_23_976, FrameRate::FPS_25, FrameRate::FPS_29_97, FrameRate::FPS_59_94, FrameRate::FPS_24][ri]; + let mut p = Project::new("P"); + let ms = [ + media(&mut p, "/x/one.mov", true, true, rate), + media(&mut p, "/x/two.mov", true, true, rate), + media(&mut p, "/y/three four.mxf", true, true, rate), + ]; + let s = sequence(&mut p, "S", rate, rate == FrameRate::FPS_29_97); + let mut ends = [0i64; 3]; + let mut prev: [Option; 3] = [None; 3]; + let mut aend = [Tick::ZERO; 3]; + for g in &clips { + let t = ends[g.track] + g.gap; + let v = clip(&mut p, s, TrackKind::Video, g.track, ms[g.media], t..t + (g.dur), g.src); + { + let q = p.sequence_mut(s).unwrap(); + let (_, it) = q.find_item_mut(v).unwrap(); + it.enabled = g.enabled; + match g.speed { + 1 => it.speed = 2.0, + 2 => it.speed = 0.5, + 3 => it.reverse = true, + 4 => it.frame_hold = Some(rate.tick_of(g.src + 3)), + _ => {} + } + } + let d = g.tr_len; + let adjacent = g.gap == 0 && prev[g.track].is_some(); + match g.tr { + 0 if adjacent => transition( + &mut p, + s, + (TrackKind::Video, g.track), + "cross_dissolve", + (prev[g.track], Some(v)), + t - d / 2..t - d / 2 + (d), + TransitionAlign::CenterAtCut, + ), + 1 if adjacent => transition( + &mut p, + s, + (TrackKind::Video, g.track), + "dip_to_white", + (prev[g.track], Some(v)), + t..t + (d), + TransitionAlign::StartAtCut, + ), + 2 if adjacent => transition( + &mut p, + s, + (TrackKind::Video, g.track), + "push", + (prev[g.track], Some(v)), + t - d..t - d + (d), + TransitionAlign::EndAtCut, + ), + 3 if !adjacent => { + transition(&mut p, s, (TrackKind::Video, g.track), "cross_dissolve", (None, Some(v)), t..t + (d), TransitionAlign::StartAtCut) + } _ => {} } + // Audio at sample (not frame) positions, linked to the video. + let at = rate.tick_of(t) + Tick(TICKS_PER_SECOND / 48_000 * g.subframe % rate.frame_duration().0.max(1)); + if g.audio && aend[g.track] <= at { + let a = clip(&mut p, s, TrackKind::Audio, g.track, ms[g.media], t..t + (g.dur), g.src); + let q = p.sequence_mut(s).unwrap(); + let (_, ai) = q.find_item_mut(a).unwrap(); + ai.start = at; + aend[g.track] = ai.end(); + link(&mut p, s, &[v, a]); + } + ends[g.track] = t + g.dur; + prev[g.track] = Some(v); } - let d = g.tr_len; - let adjacent = g.gap == 0 && prev[g.track].is_some(); - match g.tr { - 0 if adjacent => transition(&mut p, s, (TrackKind::Video, g.track), "cross_dissolve", (prev[g.track], Some(v)), t - d / 2..t - d / 2 + (d), TransitionAlign::CenterAtCut), - 1 if adjacent => transition(&mut p, s, (TrackKind::Video, g.track), "dip_to_white", (prev[g.track], Some(v)), t..t + (d), TransitionAlign::StartAtCut), - 2 if adjacent => transition(&mut p, s, (TrackKind::Video, g.track), "push", (prev[g.track], Some(v)), t - d..t - d + (d), TransitionAlign::EndAtCut), - 3 if !adjacent => transition(&mut p, s, (TrackKind::Video, g.track), "cross_dissolve", (None, Some(v)), t..t + (d), TransitionAlign::StartAtCut), - _ => {} - } - // Audio at sample (not frame) positions, linked to the video. - let at = rate.tick_of(t) + Tick(TICKS_PER_SECOND / 48_000 * g.subframe % rate.frame_duration().0.max(1)); - if g.audio && aend[g.track] <= at { - let a = clip(&mut p, s, TrackKind::Audio, g.track, ms[g.media], t..t + (g.dur), g.src); - let q = p.sequence_mut(s).unwrap(); - let (_, ai) = q.find_item_mut(a).unwrap(); - ai.start = at; - aend[g.track] = ai.end(); - link(&mut p, s, &[v, a]); - } - ends[g.track] = t + g.dur; - prev[g.track] = Some(v); - } - let (imp, text, _) = roundtrip(&p, s, Format::Otio, &xopts()); - let si = only_seq(&imp); - prop_assert_eq!(structure(&imp.project, si, TrackKind::Video), structure(&p, s, TrackKind::Video), "{}", text); - prop_assert_eq!(structure(&imp.project, si, TrackKind::Audio), structure(&p, s, TrackKind::Audio)); - prop_assert_eq!(links(&imp.project, si), links(&p, s)); - } + let (imp, text, _) = roundtrip(&p, s, Format::Otio, &xopts()); + let si = only_seq(&imp); + prop_assert_eq!(structure(&imp.project, si, TrackKind::Video), structure(&p, s, TrackKind::Video), "{}", text); + prop_assert_eq!(structure(&imp.project, si, TrackKind::Audio), structure(&p, s, TrackKind::Audio)); + prop_assert_eq!(links(&imp.project, si), links(&p, s)); + Ok(()) + }) + .unwrap(); } #[trial] From 797da4cfab6b4c29396f90af0608a2723396ed37 Mon Sep 17 00:00:00 2001 From: FredApps Date: Thu, 19 Nov 2026 17:52:01 +0100 Subject: [PATCH 15/22] Keep story render jobs independent of gallery registry --- crates/story-render/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/story-render/src/main.rs b/crates/story-render/src/main.rs index f3214431f..009a506aa 100644 --- a/crates/story-render/src/main.rs +++ b/crates/story-render/src/main.rs @@ -135,7 +135,7 @@ fn options() -> Result { /// What a job renders. enum Shown { /// One story in a card's story body. - Story(&'static StoryRegistration), + Story(StoryRegistration), /// The Overview card of one story group. Card(Spec), } @@ -254,8 +254,8 @@ fn settle(frames: &mut Frames, width: f32, show: &mut dyn FnMut(&mut Ui)) { } /// The story in a card's body, with its dialog open when the card holds one behind its button: the rect it showed in. -fn story(frames: &mut Frames, story: &'static StoryRegistration, job: &Job, options: &Options) -> Option { - let body = StoryBody::new("sheet", story, job.surface, options.room, Pad::Regular); +fn story(frames: &mut Frames, story: &StoryRegistration, job: &Job, options: &Options) -> Option { + let body = StoryBody::new("sheet", *story, job.surface, options.room, Pad::Regular); let mut state = CardState::default(); let mut flow = None; settle(frames, options.width, &mut |ui| flow = body.show(ui, &mut state).flow); From efa69b8bb8c8cee2b088da1f7ff49f6df37894a6 Mon Sep 17 00:00:00 2001 From: FredApps Date: Fri, 20 Nov 2026 00:52:06 +0100 Subject: [PATCH 16/22] Keep shared resolved labels in registry trial --- crates/ui-contract/tests/it/story_command_subsets.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-contract/tests/it/story_command_subsets.rs b/crates/ui-contract/tests/it/story_command_subsets.rs index 0e3678d89..4ade27046 100644 --- a/crates/ui-contract/tests/it/story_command_subsets.rs +++ b/crates/ui-contract/tests/it/story_command_subsets.rs @@ -32,8 +32,8 @@ fn selected(alpha_selected: bool, barrier: Arc) { assert!(registry.install_story_sets()); let mut fixture = Fixture::new(|_| {}); fixture.settle(); - let alpha_label = resolve(fixture.ctx(), Alpha::Run).label; - let beta_label = resolve(fixture.ctx(), Beta::Run).label; + let alpha_label = resolve(fixture.ctx(), Alpha::Run).label.clone(); + let beta_label = resolve(fixture.ctx(), Beta::Run).label.clone(); assert_eq!(alpha_label.as_ref() == "Subset Alpha", alpha_selected); assert_eq!(beta_label.as_ref() == "Subset Beta", !alpha_selected); } From d6b7a5bee8cc76aec22aadd6bef840b12493d0bd Mon Sep 17 00:00:00 2001 From: FredApps Date: Fri, 20 Nov 2026 03:34:46 +0100 Subject: [PATCH 17/22] Follow nested modules beside explicit registry paths --- crates/ui-macros/src/registry.rs | 30 +++++++++++-------- .../tests/fixtures/registry/child.rs | 5 ++++ .../tests/fixtures/registry/nested.rs | 2 ++ .../tests/fixtures/registry/other.rs | 2 ++ 4 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 crates/ui-macros/tests/fixtures/registry/nested.rs diff --git a/crates/ui-macros/src/registry.rs b/crates/ui-macros/src/registry.rs index 5dc543577..a265949e2 100644 --- a/crates/ui-macros/src/registry.rs +++ b/crates/ui-macros/src/registry.rs @@ -88,7 +88,7 @@ fn contains_suite_item(items: &[Item]) -> bool { }) } -fn module_file(dir: &Path, path_dir: &Path, module: &ItemMod) -> Option { +fn explicit_path(path_dir: &Path, module: &ItemMod) -> Option { for attr in &module.attrs { if attr.path().is_ident("path") && let Meta::NameValue(value) = &attr.meta @@ -98,11 +98,15 @@ fn module_file(dir: &Path, path_dir: &Path, module: &ItemMod) -> Option return Some(path_dir.join(path.value())); } } - let plain = dir.join(format!("{}.rs", module.ident)); + None +} + +fn module_file(module_dir: &Path) -> Option { + let plain = module_dir.with_extension("rs"); if plain.is_file() { Some(plain) } else { - let nested = dir.join(module.ident.to_string()).join("mod.rs"); + let nested = module_dir.join("mod.rs"); nested.is_file().then_some(nested) } } @@ -129,21 +133,21 @@ fn walk( cfg.extend(attrs_cfg(&module.attrs)); let mut child_path = path.to_vec(); child_path.push(module.ident.clone()); + let module_dir = dir.join(module.ident.to_string()); + let explicit = explicit_path(path_dir, module); if let Some((_, content)) = &module.content { - let inline_dir = dir.join(module.ident.to_string()); - walk(content, file, &inline_dir, &inline_dir, &child_path, &cfg, calls)?; - } else if let Some(file) = module_file(dir, path_dir, module) { + let inline_dir = explicit.as_deref().unwrap_or(&module_dir); + walk(content, file, inline_dir, inline_dir, &child_path, &cfg, calls)?; + } else if let Some(file) = explicit.clone().or_else(|| module_file(&module_dir)) { let text = std::fs::read_to_string(&file) .map_err(|e| syn::Error::new_spanned(module, format!("cannot read {}: {e}", file.display())))?; let parsed = syn::parse_file(&text).map_err(|e| syn::Error::new_spanned(module, format!("cannot parse {}: {e}", file.display())))?; cfg.extend(attrs_cfg(&parsed.attrs)); - let child_dir = if file.file_name().is_some_and(|n| n == "mod.rs" || n == "main.rs" || n == "lib.rs") { - file.parent().unwrap_or(dir).to_path_buf() - } else { - file.parent().unwrap_or(dir).join(file.file_stem().unwrap_or_default()) - }; - walk(&parsed.items, &file, &child_dir, file.parent().unwrap_or(dir), &child_path, &cfg, calls)?; + let file_dir = file.parent().unwrap_or(dir); + // Rust looks beside a file selected by #[path] for that file's own modules. + let child_dir = if explicit.is_some() { file_dir } else { &module_dir }; + walk(&parsed.items, &file, child_dir, file_dir, &child_path, &cfg, calls)?; } } Item::Struct(item) @@ -257,6 +261,8 @@ mod tests { assert!(generated.contains("__registry_story_view")); assert!(generated.contains("__registry_trial_changes")); assert!(generated.contains("__registry_trial_path_trial")); + assert!(generated.contains("crate :: child :: other :: nested :: __registry_trial_nested_path_trial")); + assert!(generated.contains("crate :: child :: inline_alias :: nested :: __registry_trial_nested_path_trial")); assert!(generated.contains("cfg (not (target_arch = \"wasm32\"))")); assert!(!generated.contains("# !")); } diff --git a/crates/ui-macros/tests/fixtures/registry/child.rs b/crates/ui-macros/tests/fixtures/registry/child.rs index 832cf8638..2e2525059 100644 --- a/crates/ui-macros/tests/fixtures/registry/child.rs +++ b/crates/ui-macros/tests/fixtures/registry/child.rs @@ -7,3 +7,8 @@ fn view() {} fn changes() {} #[path = "other.rs"] mod other; + +#[path = "."] +mod inline_alias { + mod nested; +} diff --git a/crates/ui-macros/tests/fixtures/registry/nested.rs b/crates/ui-macros/tests/fixtures/registry/nested.rs new file mode 100644 index 000000000..5b4dd1385 --- /dev/null +++ b/crates/ui-macros/tests/fixtures/registry/nested.rs @@ -0,0 +1,2 @@ +#[trial] +fn nested_path_trial() {} diff --git a/crates/ui-macros/tests/fixtures/registry/other.rs b/crates/ui-macros/tests/fixtures/registry/other.rs index 1887f4901..5d05daba5 100644 --- a/crates/ui-macros/tests/fixtures/registry/other.rs +++ b/crates/ui-macros/tests/fixtures/registry/other.rs @@ -1,2 +1,4 @@ #[trial] fn path_trial() {} + +mod nested; From b87e5f1adebf5e38a828f8e72d2e90fac8c782d7 Mon Sep 17 00:00:00 2001 From: FredApps Date: Fri, 20 Nov 2026 15:15:52 +0100 Subject: [PATCH 18/22] Expose chooser trials to the registry --- crates/dialogs/src/ui/chooser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/dialogs/src/ui/chooser.rs b/crates/dialogs/src/ui/chooser.rs index aace9402a..2668b9ebb 100644 --- a/crates/dialogs/src/ui/chooser.rs +++ b/crates/dialogs/src/ui/chooser.rs @@ -6,7 +6,7 @@ mod accept; #[cfg(test)] -mod tests; +pub(crate) mod tests; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex, PoisonError}; From 2178dd2971671fe22a22a589f3c8611626471c87 Mon Sep 17 00:00:00 2001 From: FredApps Date: Fri, 20 Nov 2026 15:47:42 +0100 Subject: [PATCH 19/22] Repair registry access and story renderer --- crates/color-ui/src/ui/mod.rs | 2 +- crates/story-render/src/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/color-ui/src/ui/mod.rs b/crates/color-ui/src/ui/mod.rs index ef540646f..4f08f463d 100644 --- a/crates/color-ui/src/ui/mod.rs +++ b/crates/color-ui/src/ui/mod.rs @@ -29,7 +29,7 @@ pub(crate) mod pair; pub(crate) mod palette; pub(crate) mod panel; pub(crate) mod picker; -mod picker_dialog; +pub(crate) mod picker_dialog; pub(crate) mod popover; pub(crate) mod profile_prompts; pub(crate) mod ramp; diff --git a/crates/story-render/src/main.rs b/crates/story-render/src/main.rs index a7855b9dc..18031af8b 100644 --- a/crates/story-render/src/main.rs +++ b/crates/story-render/src/main.rs @@ -137,7 +137,7 @@ fn options() -> Result { /// What a job renders. enum Shown { /// One story in a card's story body. - Story(StoryRegistration), + Story(Box), /// The Overview card of one story group, which the card's frames show. Card(Arc), } @@ -202,7 +202,7 @@ fn jobs(options: &Options) -> Vec { name: component.name.clone(), level: entry.level.title(), crate_name: story.registration.crate_name, - shown: Shown::Story(story.registration), + shown: Shown::Story(Box::new(story.registration)), surface: entry.surface, story: story.registration.story.name.to_owned(), title: story.registration.story.caption(&component.name), @@ -332,7 +332,7 @@ fn card(spec: &Arc, env: &RootEnv, options: &Options) -> (Fixture, Option< fn render(job: &Job, renderer: &mut Renderer, env: &RootEnv, options: &Options) -> Result { let (mut fixture, shown, dialog) = match &job.shown { Shown::Story(registration) => { - let (fixture, shown) = story(*registration, job.surface, env, options); + let (fixture, shown) = story(**registration, job.surface, env, options); (fixture, shown, false) } Shown::Card(spec) => card(spec, env, options), From 2d212dadae338d5e2333c591d4b2e3cffe0a1193 Mon Sep 17 00:00:00 2001 From: FredApps Date: Fri, 20 Nov 2026 18:05:00 +0100 Subject: [PATCH 20/22] Isolate coverage for cancelled print helpers --- crates/print/src/spool_tests.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/crates/print/src/spool_tests.rs b/crates/print/src/spool_tests.rs index 1a0bdfc02..4627f3bc2 100644 --- a/crates/print/src/spool_tests.rs +++ b/crates/print/src/spool_tests.rs @@ -199,13 +199,18 @@ fn stand_in_print_helper() { } /// Launches [`stand_in_print_helper`] over `directory` in `mode`, marking its stages in `marks`. -fn helper_command(directory: &Path, marks: &Path, mode: &str) -> std::io::Result { +fn helper_command(directory: &Path, marks: &Path, mode: &str, may_be_killed: bool) -> std::io::Result { let mut command = Command::new(std::env::current_exe()?); command .args(["--exact", "spool_tests::stand_in_print_helper", "--nocapture", "--"]) .env(PRINT_DIR, directory) .env(PRINT_MARKS, marks) .env(PRINT_MODE, mode); + // A force-killed child can leave a partial LLVM profile; keep it in this trial's + // temporary directory while normally exiting children retain their coverage. + if may_be_killed && std::env::var_os("LLVM_PROFILE_FILE").is_some() { + command.env("LLVM_PROFILE_FILE", marks.join("killed-%p-%m.profraw")); + } Ok(command) } @@ -224,14 +229,19 @@ fn wait_for(path: &Path) { } /// Runs `submission` on a thread with the child in `mode`; the receiver gets its input folder. -fn submit_in(submission: &Submission, marks: &Path, mode: &'static str) -> (std::thread::JoinHandle>, Receiver) { +fn submit_in( + submission: &Submission, + marks: &Path, + mode: &'static str, + may_be_killed: bool, +) -> (std::thread::JoinHandle>, Receiver) { let worker = submission.clone(); let marks = marks.to_path_buf(); let (folder, folders) = channel(); let running = std::thread::spawn(move || { worker.submit_with(PDF, &job(), |directory| { folder.send(directory.to_path_buf()).unwrap(); - helper_command(directory, &marks, mode) + helper_command(directory, &marks, mode, may_be_killed) }) }); (running, folders) @@ -261,7 +271,7 @@ fn a_cancel_during_startup_never_starts_the_driver() { worker.submit_with(PDF, &job(), |directory| { started.send(directory.to_path_buf()).unwrap(); wait.recv().unwrap(); - helper_command(directory, &held, "held") + helper_command(directory, &held, "held", true) }) }); let directory = starting.recv_timeout(LIMIT).unwrap(); @@ -272,7 +282,7 @@ fn a_cancel_during_startup_never_starts_the_driver() { // Cancelled while the child is waking and has not acknowledged anything. let submission = Submission::new(); - let (running, folders) = submit_in(&submission, marks.path(), "waking"); + let (running, folders) = submit_in(&submission, marks.path(), "waking", true); let directory = folders.recv_timeout(LIMIT).unwrap(); wait_for(&marks.path().join("waking")); assert!(submission.cancel(), "a process without a start grant cannot send anything"); @@ -286,7 +296,7 @@ fn a_cancel_during_startup_never_starts_the_driver() { fn a_refusal_while_sending_keeps_the_job() { let marks = tempfile::tempdir().unwrap(); let submission = Submission::new(); - let (running, folders) = submit_in(&submission, marks.path(), "sending"); + let (running, folders) = submit_in(&submission, marks.path(), "sending", false); let directory = folders.recv_timeout(LIMIT).unwrap(); wait_for(&marks.path().join("sending")); assert!(!submission.cancel(), "a sending job refuses cancellation"); @@ -303,7 +313,7 @@ fn a_refusal_while_sending_keeps_the_job() { fn a_cancelled_driver_does_not_block_the_next_job() { let marks = tempfile::tempdir().unwrap(); let submission = Submission::new(); - let (running, folders) = submit_in(&submission, marks.path(), "held"); + let (running, folders) = submit_in(&submission, marks.path(), "held", true); let directory = folders.recv_timeout(LIMIT).unwrap(); wait_for(&marks.path().join("driver")); assert!(!directory.join("input.pdf").exists(), "the stalled driver retains no plaintext PDF"); @@ -311,7 +321,7 @@ fn a_cancelled_driver_does_not_block_the_next_job() { assert!(submission.cancel(), "a stalled driver still acknowledges cancellation"); let next_marks = tempfile::tempdir().unwrap(); let next = Submission::new(); - assert_eq!(next.submit_with(PDF, &job(), |dir| helper_command(dir, next_marks.path(), "ready")), Ok("spooled synthetic job".into())); + assert_eq!(next.submit_with(PDF, &job(), |dir| helper_command(dir, next_marks.path(), "ready", false)), Ok("spooled synthetic job".into())); assert_eq!(running.join().unwrap(), Err(CANCELLED.into())); assert!(!directory.exists(), "the reaped helper's PDF and settings were removed"); assert!(!next.cancel(), "a completed job keeps its receipt"); @@ -328,7 +338,7 @@ fn helper_crashes_are_errors_and_inputs_are_bounded() { Submission::new() .submit_with(PDF, &job(), |dir| { inputs = Some(dir.to_path_buf()); - helper_command(dir, marks.path(), "crash") + helper_command(dir, marks.path(), "crash", false) }) .is_err() ); @@ -353,7 +363,7 @@ fn helper_crashes_are_errors_and_inputs_are_bounded() { let folder = tempfile::tempdir().unwrap(); std::fs::write(folder.path().join("job.json"), serde_json::to_vec(&Request::from_job(&job())).unwrap()).unwrap(); std::fs::write(folder.path().join("input.pdf"), PDF).unwrap(); - let mut child = helper_command(folder.path(), marks.path(), "held") + let mut child = helper_command(folder.path(), marks.path(), "held", false) .unwrap() .stdin(Stdio::piped()) .stdout(Stdio::null()) From 752d2279ce931aaff1e8a8de2a78ac0e4b6d45d5 Mon Sep 17 00:00:00 2001 From: FredApps Date: Fri, 20 Nov 2026 19:26:44 +0100 Subject: [PATCH 21/22] Allow the owned gallery story memo key --- crates/design-lint/src/workspace.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/design-lint/src/workspace.rs b/crates/design-lint/src/workspace.rs index 5584a3d6b..3dab5fe16 100644 --- a/crates/design-lint/src/workspace.rs +++ b/crates/design-lint/src/workspace.rs @@ -152,6 +152,8 @@ const NO_GLOBAL_STATE: &[(&str, &str)] = &[ // Settled fact: a card's view of a story's state keys by the story value's revision, whether the start is taken, the // dialog's flags and the reset count; the view of every shown story's state is one fixed-size digest of those keys. // Both are props held as `&mut`, which the derive does not take. + // A card keys its owned story registration by the name and show function the card reads. + ("crates/ui-gallery/src/chrome/card.rs", "MemoProps"), ("crates/ui-gallery/src/viewer/picks.rs", "MemoProps"), // Settled fact: the names of a preset group key by a walk over the group and its folders (`dyn EachName`), which // the derive cannot see through. From bce3d25ea197668ad94f206dc72cfdbaf8c19c73 Mon Sep 17 00:00:00 2001 From: FredApps Date: Fri, 20 Nov 2026 19:32:44 +0100 Subject: [PATCH 22/22] Follow upstream settled test replacement --- crates/ui-widgets/tests/it/body/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/ui-widgets/tests/it/body/mod.rs b/crates/ui-widgets/tests/it/body/mod.rs index 268e42944..b95a6002f 100644 --- a/crates/ui-widgets/tests/it/body/mod.rs +++ b/crates/ui-widgets/tests/it/body/mod.rs @@ -5,4 +5,3 @@ pub(crate) mod memo_reads; pub(crate) mod memo_settled; pub(crate) mod memo_view; pub(crate) mod scroll; -pub(crate) mod settle;