Merge remote-tracking branch 'origin/next' into fix/photocraft-16905-own-window-moves

This commit is contained in:
David Mann
2026-11-25 14:24:32 +01:00
22 changed files with 212 additions and 47 deletions
+6
View File
@@ -29,3 +29,9 @@ opt-level = 1
[profile.dev.package.craft-cms]
opt-level = 1
# The runtime under every screen test: each frame of a fixture runs its pass, layout, focus and access tree. At
# opt-level 2 a suite trial runs about 40 percent fewer instructions than at 0 (Table activation 19.8 G to 11.9 G);
# opt-level 1 gives about 30 percent. Every UI crate waits for its compile, which grows by about a minute.
[profile.dev.package.craft-ui-contract]
opt-level = 2
+2 -2
View File
@@ -167,8 +167,8 @@ jobs:
cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
# A selection that reaches a replay-audit crate builds once in a `build` job, which writes
# three nextest archives and then runs the doctests; three shard legs run them in parallel:
# every selected test outside the replay audit's crates, those crates (run plainly, then with the
# audit), and craft-image-codecs with default features. Any other selection
# every selected test outside the replay audit's crates and craft-draw, those crates (run plainly,
# then the audit crates with the audit), and craft-image-codecs with default features. Any other selection
# (and every macOS and Windows leg) builds and runs in one leg. scripts/ci-workspace-tests.sh
# holds every step.
test-shards: ${{ needs.platforms.outputs.audit == 'true' && 3 || 0 }}
@@ -815,8 +815,9 @@ impl BodyHooks<'_> {
// areas cover its ends and top edge, and a cursor set over them fights the OS's.
let moved = os.or(moves_window.then(|| pass::current_viewport(&ctx)));
let os_bar = moved.is_some_and(|viewport| windows::shell_of(&ctx, viewport).window.chrome == WindowChrome::Inset);
let hand = pcx.env.get::<crate::contract::MoveBandCursor>() == crate::contract::MoveBandCursor::Hand;
let mut part = pcx.part(MOVE_BAND, band).sense(craft_behavior::Sense::DRAG).pointer_only(reason);
if !os_bar {
if !os_bar && hand {
part = part.cursor(CursorIcon::Grab).drag_cursor(CursorIcon::Grabbing);
}
if let Some(hit) = exclusive(WindowHit::Move).or(moves_window.then_some(WindowHit::Move)) {
@@ -337,6 +337,20 @@ pub enum QuietHeader {
Heads,
}
/// The cursor over a header's move band ([`DragBand::Move`]). An app sets it once at its root (`RootEnv::values`); the
/// default is `Hand`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)]
#[env(style)]
#[non_exhaustive]
pub enum MoveBandCursor {
/// The open hand, and the closed hand while the band is dragged.
#[default]
Hand,
/// The arrow, as an OS title bar shows, also over the click-only controls on the band (menu titles, buttons):
/// production VectorCraft's title bar and panel headers.
Arrow,
}
/// A header region, filled by `Container::header`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
+2 -2
View File
@@ -69,8 +69,8 @@ pub use container::InBar;
pub use container::InMenu;
pub use container::{
BandFill, Bracket, Collapse, ContainerProps, DragBand, EndRegion, FooterPlace, FooterRegion, Gap, HeaderEdge, HeaderParts, HeaderRegion,
LeastWidth, Mount, Notch, POPUP_PAD, Pad, PadEdges, PaneEdge, QuietHeader, Scroll, ScrollAnchor, ScrollAxes, ScrollIndicator, SectionRhythm,
ShellPane, Sizing, ThemeScope, WrapWidth,
LeastWidth, Mount, MoveBandCursor, Notch, POPUP_PAD, Pad, PadEdges, PaneEdge, QuietHeader, Scroll, ScrollAnchor, ScrollAxes, ScrollIndicator,
SectionRhythm, ShellPane, Sizing, ThemeScope, WrapWidth,
};
pub use craft_tracked::{PlainData, Revision, Tracked};
pub use craft_ui_macros::{CommandSet, Component, Pattern, PlainData, Props, register_contract};
@@ -717,7 +717,7 @@ fn icon_groups_apart_by_a_rule_show_one_level_rule_between_them() {
let band = |group: u64| fixture.part_rect(id, GRIP.at(group)).expect("each group keeps a grip band");
let (first, last, next) = (cell(0), cell(1), cell(2));
let (top, lower) = (band(0), band(1));
assert!(first.top() < gripped_first.top() - 0.5, "the first icon {first:?} stands higher than under a grip strip {gripped_first:?}");
assert!(first.top() < gripped_first.top(), "the first icon {first:?} stands higher than under a grip strip {gripped_first:?}");
for (group, band) in [top, lower].into_iter().enumerate() {
assert!(grip_ticks(&shapes, band).is_none(), "group {group}: the band shows no marks");
}
@@ -733,7 +733,7 @@ fn icon_groups_apart_by_a_rule_show_one_level_rule_between_them() {
let between: Vec<_> = level.iter().filter(|(a, _, _)| a.y > last.bottom() && a.y < next.top()).collect();
let [(a, b, ink)] = between.as_slice() else { panic!("one rule between the groups: {level:?}") };
let middle = (last.bottom() + next.top()) / 2.0;
assert!((a.y - middle).abs() <= 0.5, "the rule {a:?} lies in the middle of the room from {last:?} to {next:?}");
assert!(near(a.y, middle), "the rule {a:?} lies in the middle of the room from {last:?} to {next:?}");
let (left, right) = (a.x.min(b.x), a.x.max(b.x));
let span = right - left;
assert!(left > 0.0 && right < RAIL && span > RAIL - span, "the rule reaches across the column, short of its sides: {a:?} to {b:?}");
+1 -1
View File
@@ -878,7 +878,7 @@ impl StartScreen<'_> {
column_links(&page, ui, links_title.as_ref(), links);
});
});
ui.allocate_space(vec2(0.0, margin));
ui.add_space(env.tokens.size.page.margin);
});
return StartOutput { response: shown.output, actions: actions.into_inner() };
}
+2 -2
View File
@@ -211,9 +211,9 @@ fn page_templates() -> Vec<Template> {
/// The links of the Column stories: a call to action and two plain links.
fn column_links() -> [StartLink; 3] {
[
StartLink::url("Join the community", Some(IconId::new("message-circle")), "https://example.com/chat").primary(),
StartLink::url("Join the community", Some(IconId::new("note")), "https://example.com/chat").primary(),
StartLink::url("Website", Some(IconId::new("globe")), "https://example.com"),
StartLink::url("Source code", Some(IconId::new("git-branch")), "https://example.com/source"),
StartLink::url("Source code", Some(IconId::new("open")), "https://example.com/source"),
]
}
@@ -388,6 +388,42 @@ fn whole_bar(_: &mut WholeBar, ui: &mut Ui) {
);
}
/// The cursor over the File title and over the band of the whole bar in a window, with the band's cursor `look`.
fn cursors_over_the_bar(look: craft_ui::contract::MoveBandCursor) -> (Option<craft_behavior::Cursor>, Option<craft_behavior::Cursor>) {
let layout = craft_window::Layout { left: vec![], right: vec![Caption::Minimize, Caption::Maximize, Caption::Close] };
let frame = Frame::Integrated(Captions { family: CaptionFamily::Windows, layout });
let desktop = Desktop { kind: DesktopKind::Other, ssd: None, gtk_theme: None, icon_theme: None };
let windows = Windows::with(InstallSpec::new(ShellInfo::default(), Arc::new(NoWindows)).frame(Decision { frame, overridden: None, desktop }));
let mut root = craft_ui::runtime::env::RootEnv::default();
root.values.set(look);
windows.root_env(root);
let show = |ui: &mut Ui| whole_bar(&mut WholeBar { version: 0 }, ui);
windows.frame(vec![], vec![], show);
let settled = windows.frame(vec![], vec![], show);
let tree = &settled.trees.iter().rev().find(|(viewport, _)| *viewport == ViewportId::ROOT).expect("the root pass ran").1;
let title = |name: &str| {
tree.with_role(Role::MENU_ITEM).into_iter().find(|key| tree.name_of(*key) == Some(name)).and_then(|key| tree.bounds_of(key)).expect("a title")
};
let (file, help) = (title("File"), title("Help"));
let over = |at: Pos2| {
windows.frame(vec![moved(at)], vec![], show);
windows.frame(vec![], vec![], show);
craft_ui::runtime::cursor::current(&windows.ctx)
};
(over(file.center()), over(Pos2::new(help.right() + 40.0, help.center().y)))
}
/// A title bar's move band shows the open hand by default, also through the menu titles on it, which sense clicks
/// only; under `MoveBandCursor::Arrow` the band and the titles show the arrow, as an OS title bar does.
#[trial]
fn a_move_band_shows_the_arrow_when_the_app_asks() {
use craft_behavior::{Cursor, CursorIcon};
use craft_ui::contract::MoveBandCursor;
let grab = Some(Cursor::System(CursorIcon::Grab));
assert_eq!(cursors_over_the_bar(MoveBandCursor::Hand), (grab.clone(), grab), "the hand over the band and the titles on it");
assert_eq!(cursors_over_the_bar(MoveBandCursor::Arrow), (None, None), "the arrow over the band and the titles on it");
}
/// A whole title bar an app shows through a memoized view in the shell's title slot (1600 × 1000 px at 125 %) fills
/// the slot as the bar shown directly does: the captions end at the slot's end edge and the document title is drawn
/// whole after the last menu.
+35 -11
View File
@@ -37,7 +37,7 @@ use crate::runtime::env::{EnvView, Label};
use crate::runtime::focus::{self, FocusTarget};
use crate::runtime::memory::{Facts, Remember as _};
use crate::runtime::words::common::CommonWords;
use crate::style::{ComponentStyle, FocusLook, IconLook, StyleCx, SurfaceLook, TextLook, TypeRole};
use crate::style::{ComponentStyle, FocusLook, IconLook, StyleCx, SurfaceLook, TextLook, TypeRole, UiTokens};
use crate::text::TextField;
use craft_behavior::fit::{FitItem, FitKeep, fit_items};
use craft_behavior::{Arrows, Flow, Intent, Metrics, NavMove, NavShape, PartKey, PartRef, Proposal, Roving, Sense};
@@ -63,6 +63,19 @@ pub enum MenuTitlePad {
Control,
}
/// How a menu bar's titles stand. An app sets it once at its root (`RootEnv::values`); the default is a menu row's.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)]
#[env(style)]
#[non_exhaustive]
pub enum MenuTitleLook {
/// A menu row's: square corners, a control high, [`MenuTitlePad`] beside the text.
#[default]
Row,
/// A bare push button's, as egui's menu bar draws its titles: a push button high with the button's corners
/// (`radius.button`) and `space.gap.tight` beside the text, the titles `space.pad.control` apart.
Button,
}
/// The style of a title's face: a menu row's surface and ink (flat, square corners, no border), with the command
/// highlight (`CommandHighlight`) under the pointer and while its menu is open or the keyboard is on it.
#[derive(Clone, Debug, PartialEq, ComponentStyle)]
@@ -114,15 +127,14 @@ impl Component for TitleFace {
let surface = cx.command_row_look();
let ink = cx.command_row_ink(tokens.color.text.normal);
let control = cx.control();
let (surface, pad, height) = match (cx.env::<MenuTitleLook>(), cx.env::<MenuTitlePad>()) {
(MenuTitleLook::Button, _) => (surface.radius(UiTokens::corner(tokens.shape.radius.button)), tokens.space.gap.tight, cx.button_height()),
(MenuTitleLook::Row, MenuTitlePad::Regular) => (surface, tokens.space.pad.regular, control.height),
(MenuTitleLook::Row, MenuTitlePad::Control) => (surface, tokens.space.pad.control, control.height),
};
TitleFaceStyle {
surface,
metrics: Metrics::new()
.padding(craft_behavior::Insets::horizontal(match cx.env::<MenuTitlePad>() {
MenuTitlePad::Regular => tokens.space.pad.regular,
MenuTitlePad::Control => tokens.space.pad.control,
}))
.min_size(Vec2::new(0.0, control.height))
.gap(control.gap),
metrics: Metrics::new().padding(craft_behavior::Insets::horizontal(pad)).min_size(Vec2::new(0.0, height)).gap(control.gap),
focus: cx.focus_look(),
text: TextLook::new(TypeRole::Label, ink.clone()),
icon: IconLook::new(control.icon, ink),
@@ -387,13 +399,23 @@ impl<'a> MenuBar<'a> {
if shown == 0 { words.bar_all.as_str().to_owned() } else { words.bar_more.as_str().to_owned() }
}
/// Each title's width as its face measures, the face height, and the width of the "…" title.
/// Each title's width as its face measures, the face height, and the width of the "…" title, each with the gap
/// after it ([`Self::gap`]).
fn widths(&self, cx: &MeasureCx<'_, Self>) -> (Vec<f32>, f32, f32) {
let texts = self.texts(&cx.env);
let gap = Self::gap(cx);
let sizes: Vec<Vec2> = texts.iter().map(|(text, _)| cx.face(Self::face(text, false, None))).collect();
let more = cx.face(Self::face(&Self::more_text(&cx.env.words::<MenuWords>(), 1), false, None));
let height = sizes.iter().map(|size| size.y).fold(more.y, f32::max);
(sizes.iter().map(|size| size.x).collect(), height, more.x)
(sizes.iter().map(|size| size.x + gap).collect(), height, more.x + gap)
}
/// The room after each title: `space.pad.control` between titles that stand as buttons, none between rows.
fn gap(cx: &MeasureCx<'_, Self>) -> f32 {
match cx.env.get::<MenuTitleLook>() {
MenuTitleLook::Button => cx.tokens.space.pad.control,
MenuTitleLook::Row => 0.0,
}
}
fn slot_part(open: Open) -> PartRef {
@@ -500,14 +522,16 @@ impl Component for MenuBar<'_> {
}
let (widths, _, more) = self.widths(cx);
let fit = fit_titles(&widths, more, rect.width());
let gap = Self::gap(cx);
let mut flow = Flow::new(rect, cx.flow.is_rtl());
for (at, width) in widths.iter().take(fit.shown).enumerate() {
let (cell, rest) = flow.take_start(*width);
flow = rest;
let cell = Flow::new(cell, cx.flow.is_rtl()).take_start(width - gap).0;
cx.part(TITLE.at(at as u64), cell).sense(Sense::CLICK | Sense::FOCUS).focusable().toggles_at("menu", at);
}
if fit.overflow {
let (cell, _) = flow.take_start(more);
let cell = flow.take_start(more - gap).0;
cx.part(MORE, cell).sense(Sense::CLICK | Sense::FOCUS).focusable().toggles_at("menu", fit.shown);
}
cx.roving(Roving::new(NavShape::Flat).arrows(Arrows::Horizontal));
+16 -1
View File
@@ -1,6 +1,6 @@
//! Stories of the menu bar, the edit menu and the panel menu.
use super::{MenuBar, MenuHelp, MenuTitle, MenuTitlePad};
use super::{MenuBar, MenuHelp, MenuTitle, MenuTitleLook, MenuTitlePad};
use crate::buttons::{IconButton, PopupMark};
use crate::contract::{Entry, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger};
use crate::display::Divider;
@@ -103,6 +103,21 @@ fn menu_bar_close_titles(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
.into()
}
/// Titles that stand as bare push buttons (`MenuTitleLook::Button`), a push button high with its corners and the tight
/// gap beside the text, as egui's menu bar draws them; the open File menu's title shows the hover tint.
#[story(MenuBar<'static>, covers = [], drive = Drive::Custom(open_file))]
fn menu_bar_button_titles(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
with_env(
ui,
|overrides| {
overrides.values.set(MenuTitleLook::Button);
overrides.values.set(CommandHighlight::Hover);
},
|ui| MenuBar::new("Main menu", titles()).show(ui),
)
.into()
}
/// The open File menu under `CommandHighlight::Hover`: the open title and the active row show the hover tint with
/// their own ink, as an app sets it at its root for a quiet command highlight.
#[story(MenuBar<'static>, covers = [], drive = Drive::Custom(open_file))]
+1 -1
View File
@@ -15,7 +15,7 @@ pub(crate) mod stories;
mod words;
pub use alternate::Alternate;
pub use bar::{MenuBar, MenuBarOutput, MenuBarStyle, MenuHelp, MenuTitle, MenuTitlePad};
pub use bar::{MenuBar, MenuBarOutput, MenuBarStyle, MenuHelp, MenuTitle, MenuTitleLook, MenuTitlePad};
pub(crate) use edit::text_menu;
pub use edit::{EditMenu, EditMenuOutput};
pub use icon_row::{MenuIcon, MenuIconRow, MenuIconRowOutput};
@@ -96,3 +96,19 @@ fn semibold_document_tabs(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|ui| DocumentTabs::new("Documents", &tabs).selected(shown).reorderable(true).show(ui).response.into(),
)
}
/// VectorCraft's close buttons (`TabCloseLook::Glyph`): the × alone, a small muted glyph that turns to the text colour
/// under the pointer, with no fill.
#[story(DocumentTabs<'static, usize>, covers = [], drive = Drive::Never, title = "Close glyph")]
fn close_glyph_document_tabs(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
let tabs = [DocumentTab::new(0, "Untitled-1 @ 93.5 % (RGB/Preview)").modified(true).name_len(10), DocumentTab::new(1, "Poster.vectorcraft")];
let shown = *data.value("shown", 0_usize);
crate::runtime::env::with_env(
ui,
|overrides| {
overrides.values.set(crate::tabs::DocumentTabLook::Semibold);
overrides.values.set(crate::tabs::TabCloseLook::Glyph);
},
|ui| DocumentTabs::new("Documents", &tabs).selected(shown).show(ui).response.into(),
)
}
+1 -1
View File
@@ -6,7 +6,7 @@ mod words;
mod rules;
pub(crate) mod tab;
pub use rules::{CloseSide, DocumentTabLook, FitMode, OverflowMenu, OverflowPlace, PanelTabLook, TabKind, close_side};
pub use rules::{CloseSide, DocumentTabLook, FitMode, OverflowMenu, OverflowPlace, PanelTabLook, TabCloseLook, TabKind, close_side};
pub use tab::{Tab, TabOutput, TabPartEvent, TabRole, TabStyle};
pub use words::TabWords;
+14
View File
@@ -19,6 +19,20 @@ pub enum DocumentTabLook {
Semibold,
}
/// The look of a tab's close button app-wide. An app sets it once at its root (`RootEnv::values`); the default is
/// `Button`.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::runtime::env::EnvValue, crate::contract::MemoProps)]
#[env(style)]
#[non_exhaustive]
pub enum TabCloseLook {
/// An icon button as tall as the tab's content, which the pointer fills.
#[default]
Button,
/// The × alone, a small icon (`size.icon.sm`) in the muted ink that turns to the text colour under the pointer, with
/// no fill; it takes clicks in a square of the button's width. Production VectorCraft's.
Glyph,
}
/// The look of panel tabs ([`TabKind::Panel`]): a strip's choice ([`TabStrip::panel_look`](super::TabStrip)), which a
/// dock makes for its groups' tabs.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, crate::contract::MemoProps)]
+14 -5
View File
@@ -5,7 +5,7 @@
//! measure is its natural width (`Proposal::Min` the room for the first letters of its title beside its icon and close
//! button), and a narrower rect cuts the label first, then the detail, and shows the whole text as a tooltip.
use super::rules::{CloseSide, PanelTabLook, TabKind, close_side};
use super::rules::{CloseSide, PanelTabLook, TabCloseLook, TabKind, close_side};
use super::words::TabWords;
use std::borrow::Cow;
@@ -14,8 +14,8 @@ const MAX_NAME_DIGITS: usize = 22;
use crate::buttons::IconButton;
use crate::buttons::icon_button::{MarkerStyle, paint_marker};
use crate::contract::{
Access, Common, Component, Cx, ItemOutput, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Props as _, Role, SetPosition, Styled as _,
WordSetCx as _,
Access, Common, Component, Cx, ItemOutput, MeasureCx, Name, NoValue, Outcome, PaintUi, PartsCx, Pointer as _, Props as _, Role, SetPosition,
Styled as _, WordSetCx as _,
};
use crate::display::Progress;
use crate::primitives::{IconSpec, PaintShape, RectSide, StrokeWidth, TextRun, Wrap};
@@ -136,6 +136,9 @@ pub struct TabStyle {
/// The pill a panel tab in [`PanelTabLook::Pill`] shows under its label in place of the surface.
pill: Option<Pill>,
close_side: CloseSide,
/// The close glyph's side and its ink at rest and under the pointer under [`TabCloseLook::Glyph`]; none for the icon
/// button.
close_glyph: Option<(f32, StyleColor, StyleColor)>,
sizes: Sizes,
/// Document tabs in [`DocumentTabLook::Shrinking`](super::DocumentTabLook::Shrinking): a name capped at
/// `MAX_NAME_DIGITS` digits' width, a readable prefix at their least, and the marker dot for a modified tab.
@@ -317,7 +320,8 @@ impl<'a> Tab<'a> {
if self.shows_close() {
let at_start = style.close_side == if rtl { CloseSide::Right } else { CloseSide::Left };
let (slot, rest) = if at_start { flow.take_start(sizes.close_box) } else { flow.take_end(sizes.close_box) };
close = Some(slot);
// The glyph takes clicks in a square of the button's width, not the content's whole height.
close = Some(if style.close_glyph.is_some() { Rect::from_center_size(slot.center(), Vec2::splat(sizes.close_box)) } else { slot });
flow = if at_start { rest.take_start(sizes.gap).1 } else { rest.take_end(sizes.gap).1 };
}
flow = flow.take_end(sizes.tail).1;
@@ -476,6 +480,7 @@ impl Component for Tab<'_> {
divider: key.kind.trailing_divider(),
pill,
close_side: close_side(cx.os, cx.direction.is_rtl()),
close_glyph: (cx.env::<TabCloseLook>() == TabCloseLook::Glyph).then(|| (size.icon.sm, c(colors.text.muted), c(colors.text.normal))),
sizes,
shrinking: key.kind.shrinks_in(cx.env::<super::DocumentTabLook>()),
strong: key.kind == TabKind::Document && cx.env::<super::DocumentTabLook>() == super::DocumentTabLook::Semibold,
@@ -635,7 +640,11 @@ impl Component for Tab<'_> {
}
ui.draw().icon(at, icon);
}
if placed.close.is_some() {
if let (Some(at), Some((side, rest, hover))) = (placed.close, style.close_glyph) {
let mut glyph = IconSpec::from(IconId::new("close"));
glyph.color = Some(if cx.hover_pos(CLOSE).is_some() { hover } else { rest });
ui.draw().icon(Rect::from_center_size(at.center(), Vec2::splat(side)), &glyph);
} else if placed.close.is_some() {
let words = cx.words::<TabWords>();
let name = match &self.close_label {
Some(name) => name.as_str().to_owned(),
+2 -1
View File
@@ -305,7 +305,7 @@ pub struct TileStyle {
}
/// The paper of a page picture (`Tile::page`): a document's blank page, which is data, not a theme surface.
const PAPER: DataColor = DataColor::new(Color32::WHITE);
const PAPER: DataColor = DataColor::new(Color32::WHITE); // design: allow[raw-colour/const](a document's blank page is data, not a theme surface)
/// A `width` by `height` page centred in `picture` on the knob's shadow, the theme's short hard shadow of a part lifted
/// just off the surface under it. The page's longer side spans the largest square the picture holds with the shadow,
@@ -554,6 +554,7 @@ impl<'a> Tile<'a> {
/// that stands for a document size shows it this way (New Document's presets in `PresetCardLook::Page`, a start
/// page's page templates).
#[must_use]
// design: allow[props/point-size](only the page's shape counts: `width` and `height` are a proportion in any one unit)
pub fn page(self, width: f64, height: f64) -> Self {
self.flat_thumbnail().thumb(ThumbAspect::new(2, 1), move |cx: &ContentPainterCx<'_>, picture: Rect| paint_page(cx, picture, width, height))
}
@@ -1 +1,17 @@
config_version = 1
[[exception]]
name = "tile-page-paper-white"
kind = "marker"
rule = "raw-colour/const"
path = "crates/ui-widgets/src/tile_grid/tile.rs"
reason = "A page picture's paper is a document's blank page, which is data (`DataColor`), not a theme surface."
count = 1
[[exception]]
name = "tile-page-proportion"
kind = "marker"
rule = "props/point-size"
path = "crates/ui-widgets/src/tile_grid/tile.rs"
reason = "`Tile::page` takes a page's width and height in any one unit: only their proportion counts, never a size in points."
count = 1
+1 -1
View File
@@ -64,7 +64,7 @@ Grouped by gallery level, then shape, then name.
| `Disclosure` | Leaf | `craft_ui_widgets::controls::disclosure` | A button bound to an open state, with the expanded state |
| `IconButton` | Leaf | `craft_ui_widgets::buttons::icon_button` | A square button showing only an icon |
| `Kbd` | Leaf | `craft_ui_widgets::display::kbd` | A key chord |
| `Link` | Leaf | `craft_ui_widgets::buttons::link` | A link: drawn in the accent colour in a type role (body by default) and underlined, so colour is not its only cue |
| `Link` | Leaf | `craft_ui_widgets::buttons::link` | A link: drawn in the accent colour in a type role (body by default) and underlined, so colour is not its only cue (`LinkLook::Plain` drops the underline of a link standing alone) |
| `LinkedFields` | Leaf | `craft_ui_widgets::text::linked` | `N` number fields joined by a link toggle |
| `NumberField` | Leaf | `craft_ui_widgets::text::number` | A number field: a text part over [`NumberCodec`]; empty text is `None` |
| `PointPicker` | Leaf | `craft_ui_widgets::value_drag::point_picker` | A point `[x, y]` picked on a well: x grows to the right and y downwards, as image coordinates do, in either reading direction |
+15 -10
View File
@@ -4,10 +4,10 @@
# run one leg builds and runs every test: each macOS and Windows leg, and the Linux leg when
# the selection reaches no replay-audit crate
# archive the Linux build job (gate.yml `archive-command`) builds once and writes one nextest
# archive per shard: 1 every selected test outside the replay audit's crates, 2 those
# crates, 3 the default-feature crate
# shard a Linux shard leg runs its archive ($GATE_SHARD); shard 2 runs it plainly, then with
# the audit on
# archive per shard: 1 every selected test outside the replay audit's crates and the
# crates shard 2 also takes, 2 those crates, 3 the default-feature crate
# shard a Linux shard leg runs its archive ($GATE_SHARD); shard 2 runs it plainly, then the
# audit crates' tests again with the audit on
# doctest the doctests, in the build job after the archives (`after-archive-command`)
# audit prints whether the selection reaches a replay-audit crate (`true` or `false`)
# full the nightly run: every test, at the full sweep and proptest counts nightly.yml leaves set
@@ -34,10 +34,15 @@ default_features=(-p craft-image-codecs --locked --profile ci "${config[@]}")
audit_packages=(craft-ui-contract craft-ui-widgets craft-ui-panels craft-ui-patterns craft-ui-shell craft-ui-gallery craft-menu)
audit_crates=$(printf ' | package(%s)' "${audit_packages[@]}")
audit_crates=${audit_crates:3}
# Crates outside the audit whose tests shard 2 runs too (plainly only), so that shards 1 and 2 end
# together: shard 1 holds the other UI crates and every non-UI test.
shard_2_packages=(craft-draw)
shard_2_crates=$audit_crates$(printf ' | package(%s)' "${shard_2_packages[@]}")
filter=${CRAFT_TEST_FILTER:-all()}
# Shard 1 leaves the audit crates to shard 2, which runs them plainly and with the audit on.
plain_filter="($filter) & !($audit_crates)"
audit_filter="($filter) & ($audit_crates)"
# Shard 1 leaves the audit crates and shard 2's own to shard 2, which runs them plainly and then
# the audit crates with the audit on.
plain_filter="($filter) & !($shard_2_crates)"
shard_2_filter="($filter) & ($shard_2_crates)"
doctests() {
# Whole-workspace: `cargo test -p <selected>` would resolve features over the selected crates
@@ -65,9 +70,9 @@ case "${1:-}" in
# The examples' two packages join the one build here, so their tests are in shard 1's archive.
cargo nextest archive "${all_features[@]}" "${targets[@]}" --example stubicc --example h264_h264enc_bench \
-E "$plain_filter" --archive-file "$NEXTEST_ARCHIVE_DIR/1/$NEXTEST_ARCHIVE_NAME"
# The same build, so nothing compiles again; only the audit crates' binaries.
# The same build, so nothing compiles again; only shard 2's crates' binaries.
cargo nextest archive "${all_features[@]}" "${targets[@]}" --example stubicc --example h264_h264enc_bench \
-E "$audit_filter" --archive-file "$NEXTEST_ARCHIVE_DIR/2/$NEXTEST_ARCHIVE_NAME"
-E "$shard_2_filter" --archive-file "$NEXTEST_ARCHIVE_DIR/2/$NEXTEST_ARCHIVE_NAME"
cargo nextest archive "${default_features[@]}" "${targets[@]}" \
-E "$filter" --archive-file "$NEXTEST_ARCHIVE_DIR/3/$NEXTEST_ARCHIVE_NAME"
;;
@@ -75,7 +80,7 @@ case "${1:-}" in
run=(cargo nextest run --archive-file "$NEXTEST_ARCHIVE_FILE" --workspace-remap . --profile ci --no-tests=warn)
case "${GATE_SHARD:-}" in
1 | 3) "${run[@]}" ;;
2) "${run[@]}"; CRAFT_UI_AUDIT_REPLAY=1 "${run[@]}" ;;
2) "${run[@]}"; CRAFT_UI_AUDIT_REPLAY=1 "${run[@]}" -E "$audit_crates" ;;
*) echo "unknown shard: '${GATE_SHARD:-}'" >&2; exit 2 ;;
esac
;;
+6 -4
View File
@@ -114,6 +114,7 @@ EXAMPLES = "--example stubicc --example h264_h264enc_bench"
AUDIT_PACKAGES = ("craft-ui-contract", "craft-ui-widgets", "craft-ui-panels", "craft-ui-patterns",
"craft-ui-shell", "craft-ui-gallery", "craft-menu")
AUDIT = " | ".join(f"package({name})" for name in AUDIT_PACKAGES)
SHARD_2 = AUDIT + " | package(craft-draw)"
DOCTESTS = f"test --workspace --doc --all-features --locked {CONFIG}"
@@ -129,9 +130,9 @@ def run_commands(test_filter="all()"):
def archive_commands(directory, test_filter="all()"):
return [
f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & !({AUDIT}) "
f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & !({SHARD_2}) "
f"--archive-file {directory}/1/a.tar.zst",
f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & ({AUDIT}) "
f"nextest archive {ALL} {TARGETS} {EXAMPLES} -E ({test_filter}) & ({SHARD_2}) "
f"--archive-file {directory}/2/a.tar.zst",
f"nextest archive {DEFAULT} {TARGETS} -E {test_filter} --archive-file {directory}/3/a.tar.zst",
]
@@ -196,11 +197,12 @@ class WorkspaceTests(unittest.TestCase):
def test_each_shard_runs_its_archive_and_shard_2_also_audits(self):
expected = "nextest run --archive-file /a/b.tar.zst --workspace-remap . --profile ci --no-tests=warn"
for shard, prefixes in (("1", [""]), ("2", ["", "AUDIT "]), ("3", [""])):
# Shard 2 audits only the audit crates of its archive.
for shard, lines in (("1", [expected]), ("2", [expected, f"AUDIT {expected} -E {AUDIT}"]), ("3", [expected])):
with self.subTest(shard=shard):
result, _ = step("shard", GATE_SHARD=shard, NEXTEST_ARCHIVE_FILE="/a/b.tar.zst")
self.assertEqual(result.returncode, 0, result.stderr)
self.assertEqual(result.stdout.splitlines(), [prefix + expected for prefix in prefixes])
self.assertEqual(result.stdout.splitlines(), lines)
result, _ = step("shard", GATE_SHARD="4", NEXTEST_ARCHIVE_FILE="/a/b.tar.zst")
self.assertEqual(result.returncode, 2)
self.assertEqual(result.stdout, "")
+8 -2
View File
@@ -94,6 +94,8 @@ APP_KEYS = {
"test_threads": (int, None),
}
APP_BUILDING = {"test", "check", "build", "run", "bench", "clippy", "doc", "rustc"}
# cargo's own subcommands that resolve a profile; `cargo()` passes the dev settings after them.
CARGO_BUILDING = {"test", "check", "build", "run", "bench", "doc", "rustc", "metadata", "tree"}
APP_FEATURE_FLAGS = ("--features", "-F", "--no-default-features")
# Set by main() from the workspace's `[workspace.metadata.cl]` in an app workspace; None in craft-libs.
APP = None
@@ -379,9 +381,13 @@ def cargo(top, cargo_args, json_out=False, timings=True):
RECORD["target"] = target
if timings:
cargo_args = cargo_args[:1] + ["--timings"] + cargo_args[1:]
# An app workspace keeps its own profile settings.
# An app workspace keeps its own profile settings. For cargo's own build commands they go after the subcommand:
# cargo lets a `--config` given there replace every `--config` given before it, so a caller's own `--config`
# (.config/cargo-ci.toml) would otherwise drop the dev settings and build every crate, dependencies included, at
# opt-level 0. An external subcommand (fmt) would read them as its own options, so they stay before it.
config = [] if APP else [x for c in dev_profile_config() for x in ("--config", c)]
cmd = shlex.split(env.get("CL_LAUNCHER", "")) + ["cargo"] + config + cargo_args
split = 1 if cargo_args[:1] and cargo_args[0] in CARGO_BUILDING else 0
cmd = shlex.split(env.get("CL_LAUNCHER", "")) + ["cargo"] + cargo_args[:split] + config + cargo_args[split:]
print("cl: " + " ".join(cmd) + f" (target {target})", file=sys.stderr)
sys.stdout.flush()
if DRY_RUN: