From 1e2a432679d263c993975e01dc6b33ec4d850e73 Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 13 Nov 2026 14:31:18 +0000 Subject: [PATCH] SwatchPair: round wells take the pointer in their circle, trial for the well shape per theme; Color panel slider modes: the ramp takes the room the channel rows leave (least size.ramp.bar); SliderField keeps its field width from its measure; story-render --theme/--mode; Fixture::theme_id --- crates/color/src/ui/pair.rs | 16 ++++--- crates/color/src/ui/panel.rs | 28 +++++------ crates/color/src/ui/ramp.rs | 4 +- crates/color/tests/it/main.rs | 1 + crates/color/tests/it/pair.rs | 40 ++++++++++++++++ crates/color/tests/it/panels.rs | 51 +++++++++++---------- crates/story-render/src/main.rs | 24 +++++++--- crates/ui-contract/src/contract/paint_ui.rs | 6 --- crates/ui-contract/src/testing/fixture.rs | 7 ++- crates/ui-widgets/src/form/slider_field.rs | 11 +++-- docs/contract-api.md | 2 +- tools/cl | 4 +- 12 files changed, 126 insertions(+), 68 deletions(-) create mode 100644 crates/color/tests/it/pair.rs diff --git a/crates/color/src/ui/pair.rs b/crates/color/src/ui/pair.rs index 14b63756e..b6d963f0f 100644 --- a/crates/color/src/ui/pair.rs +++ b/crates/color/src/ui/pair.rs @@ -1,6 +1,6 @@ //! [`SwatchPair`]: two overlapping colour wells, foreground over background or fill over stroke. -use craft_behavior::{EditEvents, Flow, HitLevel, HitPriority, Metrics, Mixed, NavShape, PartKey, PressPhase, Roving, Sense}; +use craft_behavior::{EditEvents, Flow, HitLevel, HitPriority, HitShape, Metrics, Mixed, NavShape, PartKey, PressPhase, Roving, Sense}; use craft_theme::{Srgba, WellShape}; use craft_ui::buttons::IconButton; use craft_ui::choice::{ChoiceWords, Swatch, SwatchMetrics, SwatchStyle}; @@ -102,6 +102,8 @@ pub struct SwatchPairStyle { step: f32, /// The corners of a well: the swatch's, or half the side where the theme's wells are round (`shape.wells`). radius: CornerRadius, + /// Whether the wells are round (`shape.wells`): they take the pointer inside their circle only. + round: bool, /// The gap in the panel's colour round the front well: `space.gap.tight`. gap: f32, /// The side of a button: the icon slot of a control. @@ -280,12 +282,12 @@ impl<'a> SwatchPair<'a> { Vec2::splat(style.well + style.step + 2.0 * self.edge(style)) } - /// The wells' rects in logical coordinates from the pair's start edge, primary first, inside their outlines. /// The well drawn in front, which takes the pointer where the wells overlap. fn front(&self, active: Well) -> Well { if self.frame_active { Well::Primary } else { active } } + /// The wells' rects in logical coordinates from the pair's start edge, primary first, inside their outlines. fn well_rects(&self, style: &SwatchPairStyle, size: Vec2) -> [Rect; 2] { // The buttons' squares hold their glyphs with room round them, so the wells follow without a gap. let edge = self.edge(style); @@ -307,16 +309,15 @@ impl Component for SwatchPair<'_> { fn style(cx: &StyleCx<'_>, _: SwatchPairStyleKey) -> SwatchPairStyle { let colors = &cx.tokens.color; let well = cx.tokens.size.icon.lg; - let radius = match cx.tokens.shape.wells { - WellShape::Round => UiTokens::corner(well / 2.0), - _ => SwatchMetrics::of(cx).radius, - }; + let round = cx.tokens.shape.wells == WellShape::Round; + let radius = if round { UiTokens::corner(well / 2.0) } else { SwatchMetrics::of(cx).radius }; SwatchPairStyle { metrics: Metrics::new(), focus: cx.focus_look(), well, step: cx.tokens.size.icon.sm, radius, + round, gap: cx.tokens.space.gap.tight, buttons: cx.control().icon, edge: cx.color(colors.line.control_edge), @@ -353,8 +354,9 @@ impl Component for SwatchPair<'_> { let mut flags = Flags::empty(); flags.set(Flags::MIXED, self.wells[i].color.same().is_none()); flags.set(Flags::CHECKED, well == active); + let shape = if cx.style.round { HitShape::circle(at.center(), at.width() / 2.0) } else { HitShape::Rect(at) }; let part = cx - .part(WELL.at(i as u64), at) + .part(WELL.at(i as u64), shape) .sense(Sense::CLICK | Sense::FOCUS) .priority(HitPriority::new(HitLevel::Body, u8::from(front))) .flags(flags) diff --git a/crates/color/src/ui/panel.rs b/crates/color/src/ui/panel.rs index 35f2873a0..1b52851bd 100644 --- a/crates/color/src/ui/panel.rs +++ b/crates/color/src/ui/panel.rs @@ -2,7 +2,6 @@ //! (two cubes, a wheel, five slider sets), the out-of-gamut and web-colour warnings, and the colour ramp under the //! sliders; the panel menu chooses the view and the ramp and copies the colour. -use std::cell::RefCell; use std::hash::{DefaultHasher, Hash, Hasher}; use craft_behavior::{EditEvent, GesturePhase, IconId, Mixed}; @@ -541,23 +540,23 @@ impl Body<'_> { self.events.push((target, event)); } - /// The cubes take the height the readout leaves them, as Photoshop's field fills its dock group; the slider modes and - /// the wheel scroll where the group is shorter than they are. The slider modes' ramp is the body's footer, outside the - /// scroll: it stays whole under the rows, as Photoshop's ramp does. - fn show(self, ui: &mut Ui) -> Self { + /// The cubes take the height the readout leaves them, as Photoshop's field fills its dock group. In the slider modes + /// the channel rows come first and the ramp under them takes the room they leave, at least a colour band thick, as + /// Photoshop's does; in a group shorter than both the ramp is cut at the bottom. The wheel scrolls where the group + /// is shorter than it. + fn show(mut self, ui: &mut Ui) -> Self { let mode = self.now.mode; - let cube = mode.is_cube(); - // The body and the footer both draw into the panel's pass state. - let this = RefCell::new(self); let mut body = Stack::new().fill(); - if !cube { + if mode == ColorPanelMode::ColorWheel { body = body.scroll(Scroll::vertical()); } - if mode.is_sliders() { - body = body.footer(|ui, _| this.borrow_mut().ramp(ui)); - } - body.show(ui, |ui, _| this.borrow_mut().content(ui)); - this.into_inner() + body.show(ui, |ui, _| { + self.content(ui); + if mode.is_sliders() { + self.ramp(ui); + } + }); + self } /// The wells with their warnings beside the view of the mode; under the cubes their readout, under the wheel its @@ -799,6 +798,7 @@ impl Body<'_> { .gamut(gamut) .gamut_revision(hasher.finish()) .web_safe(self.now.web_safe_ramp) + .sizing(Sizing::Fill) .show(ui); // Alt is on every event of a gesture that has a value; the others go where it went. for event in ramp.edit.events { diff --git a/crates/color/src/ui/ramp.rs b/crates/color/src/ui/ramp.rs index 735926e10..63bb1a38d 100644 --- a/crates/color/src/ui/ramp.rs +++ b/crates/color/src/ui/ramp.rs @@ -354,8 +354,8 @@ impl Component for ColorRamp<'_> { fn style(cx: &StyleCx<'_>, _: ColorRampStyleKey) -> ColorRampStyle { let tokens = cx.tokens; ColorRampStyle { - // At least a control tall, as Photoshop's ramp under the channel rows of a short panel. - metrics: Metrics::new().min_size(Vec2::new(tokens.size.length.track, cx.control().height)), + // At least a colour band thick: under the Color panel's channel rows it takes the room they leave. + metrics: Metrics::new().min_size(Vec2::new(tokens.size.length.track, tokens.size.ramp.bar)), focus: cx.focus_look(), edge: cx.color(tokens.color.line.control_edge), boxes: tokens.size.icon.lg, diff --git a/crates/color/tests/it/main.rs b/crates/color/tests/it/main.rs index 4bdaa0f3d..018507205 100644 --- a/crates/color/tests/it/main.rs +++ b/crates/color/tests/it/main.rs @@ -1,6 +1,7 @@ //! The screen tests of craft-color, folded into the lib's test target. mod color_parts; +mod pair; mod paint_list; mod panels; mod picker; diff --git a/crates/color/tests/it/pair.rs b/crates/color/tests/it/pair.rs new file mode 100644 index 000000000..2c8363540 --- /dev/null +++ b/crates/color/tests/it/pair.rs @@ -0,0 +1,40 @@ +//! `SwatchPair` wells take the theme's well shape (`shape.wells`): a round well is round to the pointer too. + +use std::cell::Cell; +use std::rc::Rc; + +use craft_color::ui::{PairWell, SwatchPair, Well}; +use craft_theme::{Srgba, ThemeId}; +use craft_ui::contract::{Bind, Role, Show as _}; +use craft_ui::testing::{Fixture, trial}; +use egui::{Vec2, vec2}; + +/// Where a click lands on the primary well in theme `theme`: at the well's middle and just inside the corner of its +/// square. Each is the well the click reached, if any. +fn clicks(theme: &str) -> [Option; 2] { + let clicked = Rc::new(Cell::new(None)); + let seen = clicked.clone(); + let mut fixture = Fixture::new(move |ui| { + let wells = [PairWell::new("Foreground colour", Srgba::rgb(0.1, 0.3, 0.8)), PairWell::new("Background colour", Srgba::rgb(1.0, 1.0, 1.0))]; + let shown = SwatchPair::new("Colours", wells, Bind::given(Well::Primary)).popover(false).show(ui); + if shown.clicked.is_some() { + seen.set(shown.clicked); + } + }); + fixture.theme_id(ThemeId::parse(theme).expect("a theme id")).room(vec2(200.0, 200.0)); + fixture.settle(); + let well = fixture.by_role(Role::RADIO_BUTTON).first().expect("the primary well").rect; + [well.center(), well.min + Vec2::splat(1.5)].map(|at| { + clicked.set(None); + fixture.click_at(at); + fixture.settle(); + clicked.get() + }) +} + +/// Adwaita's wells are round: a click in the corner of a well's square misses it. Pro's are square: it hits. +#[trial] +fn the_well_corner_follows_the_theme_well_shape() { + assert_eq!(clicks("craft.adwaita"), [Some(Well::Primary), None], "round wells"); + assert_eq!(clicks("craft.pro"), [Some(Well::Primary), Some(Well::Primary)], "square wells"); +} diff --git a/crates/color/tests/it/panels.rs b/crates/color/tests/it/panels.rs index 6fd59029f..93be3c643 100644 --- a/crates/color/tests/it/panels.rs +++ b/crates/color/tests/it/panels.rs @@ -130,32 +130,35 @@ fn the_cubes_take_the_room_the_readout_and_the_strip_leave() { } /// The slider modes show each channel on one line: its slider and its number field side by side, every slider starting -/// at one x past the channels' letters. The ramp is the footer under the rows: whole and in view -/// in a short group too, where the rows scroll above it. +/// at one x past the channels' letters. The rows come first and stay in view in a short group; the ramp under them +/// takes the room they leave. #[trial] fn the_slider_modes_show_a_channel_on_one_line() { - for room in [COLOR_ROOM, Vec2::new(280.0, 96.0)] { - for (mode, channels) in [(ColorPanelMode::RgbSliders, 3), (ColorPanelMode::CmykSliders, 4), (ColorPanelMode::HsbSliders, 3)] { - let case = format!("{mode:?} in {room:?}"); - let rig = PanelRig::in_room(mode, room); - let sliders = rig.fixture.by_role(Role::SLIDER); - let fields = rig.fixture.by_role(Role::SPIN_BUTTON); - assert_eq!((sliders.len(), fields.len()), (channels, channels), "{case}"); - for (slider, field) in sliders.iter().zip(&fields) { - let line = slider.rect.y_range(); - assert!( - line.contains(field.rect.center().y) && slider.rect.right() <= field.rect.left(), - "{case}: {slider:?} then {field:?} on one line" - ); - assert!( - (slider.rect.left() - sliders[0].rect.left()).abs() < 0.5, - "{case}: the sliders start at one x ({slider:?}, {:?})", - sliders[0] - ); - } - let ramp = rig.fixture.by_label("Color Ramp").expect("the ramp"); - assert!(ramp.rect.top() >= -0.5 && ramp.rect.bottom() <= room.y + 0.5, "{case}: the ramp whole and in view ({:?})", ramp.rect); - assert!(sliders[0].rect.top() < ramp.rect.top(), "{case}: the ramp under the rows ({:?}, {:?})", sliders[0].rect, ramp.rect); + let (rgb, cmyk, hsb) = ((ColorPanelMode::RgbSliders, 3), (ColorPanelMode::CmykSliders, 4), (ColorPanelMode::HsbSliders, 3)); + // A Pro Color group's default height holds three rows and a band of the ramp. + let short = Vec2::new(280.0, 96.0); + for (room, (mode, channels)) in [(COLOR_ROOM, rgb), (COLOR_ROOM, cmyk), (COLOR_ROOM, hsb), (short, rgb), (short, hsb)] { + let case = format!("{mode:?} in {room:?}"); + let rig = PanelRig::in_room(mode, room); + let sliders = rig.fixture.by_role(Role::SLIDER); + let fields = rig.fixture.by_role(Role::SPIN_BUTTON); + assert_eq!((sliders.len(), fields.len()), (channels, channels), "{case}"); + for (slider, field) in sliders.iter().zip(&fields) { + let line = slider.rect.y_range(); + assert!(line.contains(field.rect.center().y) && slider.rect.right() <= field.rect.left(), "{case}: {slider:?} then {field:?} on one line"); + assert!( + (slider.rect.left() - sliders[0].rect.left()).abs() < 0.5, + "{case}: the sliders start at one x ({slider:?}, {:?})", + sliders[0] + ); + assert!(field.rect.bottom() <= room.y + 0.5, "{case}: every row in view ({field:?})"); + } + let last = fields.iter().map(|field| field.rect.bottom()).fold(0.0, f32::max); + let ramp = rig.fixture.by_label("Color Ramp").expect("the ramp").rect; + assert!(ramp.top() >= last && ramp.height() > 0.0, "{case}: the ramp under the rows ({last}, {ramp:?})"); + assert!(ramp.bottom() <= room.y + 0.5, "{case}: the ramp in view ({ramp:?})"); + if room == COLOR_ROOM { + assert!(ramp.bottom() > room.y - 40.0, "{case}: the ramp takes the room the rows leave ({ramp:?})"); } } } diff --git a/crates/story-render/src/main.rs b/crates/story-render/src/main.rs index bf57d532b..9e3b57a3e 100644 --- a/crates/story-render/src/main.rs +++ b/crates/story-render/src/main.rs @@ -3,7 +3,7 @@ //! `cargo run -p story-render --features -- --only --out ` writes, into ``: //! `new---.png` for every story of the component, `new-.png` for the story its Overview card //! shows (its first), `stories.tsv` and `components.tsv`. Each story runs in a card's story body (`StoryBody`) in a -//! fresh context, in ArtCraft Dark at 2 pixels per point (`--scale`) with the interface fonts, and its image is cropped to the +//! fresh context, in ArtCraft Dark (`--theme`, `--mode`) at 2 pixels per point (`--scale`) with the interface fonts, and its image is cropped to the //! story's surface and the layers it opened. A story runs in an embedded shell, over which its dialogs open, and a story //! whose dialog the card holds behind its button is shown with the dialog open. //! @@ -20,7 +20,8 @@ //! renders the story (with `--card`, the group) of that name only; `--threads N` (default: the cores, at most 8); //! `--width W` and `--room H` set the card's story width (with `--card`, the card's width) and the height a filling //! story gets, in points; `--scale S` the images' pixels per point (1 matches the old gallery's shots, so a canvas -//! document shows at the same size on both sides). `stories.tsv` lists the scale of every image. +//! document shows at the same size on both sides); `--theme ID` and `--mode light|dark` the theme and mode (ArtCraft +//! Dark without them). `stories.tsv` lists the scale of every image. use craft_behavior::ColumnWidth; use craft_ui::contract::{Pad, Scroll, ShowContainer as _, Surface}; @@ -65,13 +66,16 @@ struct Options { scale: f32, /// Whole Overview cards, one per story group, instead of story bodies. card: bool, + /// The theme id and the mode the stories are shown in. + theme: String, + mode: String, } fn options() -> Result { let mut args = std::env::args().skip(1); let threads = std::thread::available_parallelism().map_or(1, |n| n.get()).min(8); let mut options = - Options { out: PathBuf::new(), only: None, story: None, threads, width: WIDTH, room: ROOM, scale: PIXELS_PER_POINT, card: false }; + Options { out: PathBuf::new(), only: None, story: None, threads, width: WIDTH, room: ROOM, scale: PIXELS_PER_POINT, card: false, theme: String::new(), mode: "dark".to_owned() }; while let Some(arg) = args.next() { let mut value = || args.next().ok_or_else(|| format!("{arg} needs a value")); match arg.as_str() { @@ -83,6 +87,8 @@ fn options() -> Result { "--room" => options.room = value()?.parse().map_err(|_| "--room takes points".to_owned())?, "--scale" => options.scale = value()?.parse().map_err(|_| "--scale takes pixels per point".to_owned())?, "--card" => options.card = true, + "--theme" => options.theme = value()?, + "--mode" => options.mode = value()?, _ => return Err(format!("unknown argument {arg}")), } } @@ -171,11 +177,15 @@ fn jobs(options: &Options) -> Vec { jobs } -/// The root values the stories are shown under: the gallery's defaults in dark mode, which give ArtCraft. -fn root_env() -> RootEnv { +/// The root values the stories are shown under: the gallery's defaults with the theme and mode the options name (dark +/// mode and the default theme, ArtCraft, without them). +fn root_env(options: &Options) -> RootEnv { let mut env = RootEnv::default(); let mut settings = GallerySettings::default(); - settings.mode = "dark".to_owned(); + if !options.theme.is_empty() { + settings.theme.clone_from(&options.theme); + } + settings.mode.clone_from(&options.mode); settings.restore_env(&mut env); env } @@ -369,7 +379,7 @@ fn main() -> ExitCode { std::thread::scope(|scope| { for _ in 0..options.threads.max(1).min(jobs.len()) { scope.spawn(|| { - let env = root_env(); + let env = root_env(&options); let mut renderer = Renderer::new(); loop { let at = next.fetch_add(1, Ordering::Relaxed); diff --git a/crates/ui-contract/src/contract/paint_ui.rs b/crates/ui-contract/src/contract/paint_ui.rs index c34558af9..a5092f8b0 100644 --- a/crates/ui-contract/src/contract/paint_ui.rs +++ b/crates/ui-contract/src/contract/paint_ui.rs @@ -171,12 +171,6 @@ impl PaintUi<'_> { self.child_with(self.id.with(key), rect, child, None, None) } - /// Measures a child under the composite's resolved `enabled` and `size`, as [`child`](Self::child) with the same - /// key will show it: for a composite that places its children by their size. - pub fn measure(&self, key: impl Hash + Debug, child: &mut C, proposal: craft_behavior::Proposal) -> egui::Vec2 { - run::measure_under(child, &*self.ui, Some(self.id.with(key)), proposal, Some(&super::cx::Under::new(self.enabled, self.size))) - } - /// Shows `child` as the owner's own control, such as a picker the owner draws its field with. The child's node /// folds into the owner's: the owner's node stands for the child's focus stop, carries the child's value text when /// the owner's `access` sets none, and takes the actions and requests aimed at it, which reach the child. The diff --git a/crates/ui-contract/src/testing/fixture.rs b/crates/ui-contract/src/testing/fixture.rs index 2f2a71ca3..c8638fff8 100644 --- a/crates/ui-contract/src/testing/fixture.rs +++ b/crates/ui-contract/src/testing/fixture.rs @@ -11,7 +11,7 @@ use crate::runtime::egui::sizing::HELD_UPDATE_RERUN; use crate::runtime::env::{Direction, Overrides, RootEnv, Scale, with_env}; use craft_behavior::{MotionMode, PartRef}; use craft_host::target::Os; -use craft_theme::{Contrast, Mode, Size, TextSize}; +use craft_theme::{Contrast, Mode, Size, TextSize, ThemeId}; use egui::{Event, Id, Key, Modifiers, Pos2, Rect, Ui, Vec2}; use std::cell::{Cell, RefCell}; use std::collections::HashSet; @@ -257,6 +257,11 @@ impl Fixture { }) } + /// The theme: one of the built-ins (`craft.adwaita`) or one a test registered. + pub fn theme_id(&mut self, theme: ThemeId) -> &mut Self { + self.set_root(|root| root.set_theme(theme)) + } + /// The motion mode. pub fn motion(&mut self, motion: MotionMode) -> &mut Self { self.set_root(|root| *root = std::mem::take(root).motion(motion)) diff --git a/crates/ui-widgets/src/form/slider_field.rs b/crates/ui-widgets/src/form/slider_field.rs index 298de2378..1822039f4 100644 --- a/crates/ui-widgets/src/form/slider_field.rs +++ b/crates/ui-widgets/src/form/slider_field.rs @@ -92,6 +92,8 @@ pub struct SliderField<'a> { /// row, the Color panel's channels) instead of the number cell, and the slider takes the room it leaves. #[prop] field_sizing: Option, + /// The number field's width from this pass's measure (its `Proposal::Ideal` call, which runs before `paint`). + field_width: f32, } impl<'a> SliderField<'a> { @@ -111,6 +113,7 @@ impl<'a> SliderField<'a> { track_face: None, thumb: SliderThumb::Round, field_sizing: None, + field_width: 0.0, } .label(label) } @@ -263,6 +266,9 @@ impl Component for SliderField<'_> { let look = self.look(); let slider = cx.child("slider", &mut look.slider(&name, shown, None, None), Proposal::Ideal); let field = cx.child("field", &mut look.field(&name, shown, None), Proposal::Ideal); + if cx.proposal == Proposal::Ideal { + self.field_width = field.x; + } match self.layout { SliderFieldLayout::Inline => Vec2::new(slider.x + cx.style.inline_gap + field.x, slider.y.max(field.y)), SliderFieldLayout::Stacked => Vec2::new(slider.x.max(cx.style.width), cx.style.row.max(field.y) + cx.gap() + slider.y), @@ -280,10 +286,7 @@ impl Component for SliderField<'_> { let (track, field) = match self.layout { // The field takes the width its own measure gives (a number cell, or its widest value when content-sized), // so every row of a column with the same range ends its slider at one place. - SliderFieldLayout::Inline => { - let width = ui.measure("field", &mut look.field(&name, shown, None), Proposal::Ideal).x; - arrange(cx.rect.size(), cx.style.inline_gap, width) - } + SliderFieldLayout::Inline => arrange(cx.rect.size(), cx.style.inline_gap, self.field_width), SliderFieldLayout::Stacked => stack(cx.rect.size(), cx.style.metrics.gap, cx.style.row), }; let flow = Flow::new(cx.rect, cx.env.direction().is_rtl()); diff --git a/docs/contract-api.md b/docs/contract-api.md index 7e343d690..f6e9258ff 100644 --- a/docs/contract-api.md +++ b/docs/contract-api.md @@ -2217,7 +2217,6 @@ The component traits, context types, `PaintUi`, `Looks`, the pipeline and its st - `pub fn clipped(&mut self, rect: Rect, paint: impl FnOnce(&mut Self) -> R) -> R`. Runs `paint` with this `PaintUi` cut to `rect` (inside the clip already in force), as `Draw::clipped` does for a - `pub fn with_style(&self, variant: Variant, f: impl FnOnce(&StyleCx<'_>) -> R) -> R`. Runs `f` with the style context of this component's env, so app hooks called from `paint` pick colours and - `pub fn child(&mut self, key: impl Hash + Debug, rect: Rect, child: C) -> C::Output`. Shows a child component at a physical rect, with id `cx.key(key)`. The child `Ui` is pinned left to - - `pub fn measure(&self, key: impl Hash + Debug, child: &mut C, proposal: craft_behavior::Proposal) -> egui::Vec2`. Measures a child under the composite's resolved `enabled` and `size`, as [`child`](Self::child) with the same key will show it: for a composite that places its children by their size. - `pub fn inner(&mut self, key: impl Hash + Debug, rect: Rect, child: C) -> C::Output`. Shows `child` as the owner's own control, such as a picker the owner draws its field with. The child's node - `pub fn child_with_tip(&mut self, key: impl Hash + Debug, rect: Rect, child: C, tip: impl FnOnce(&mut Ui)) -> C::Output`. Shows a child with rich tooltip content. - `pub fn labelled(&mut self, key: impl Hash + Debug, rect: Rect, label: Label, side: SideLabel, child: C) -> C::Output`. Runs the label step (B2) for one leaf child at `rect`: the label's placement beside or above the child, the @@ -4124,6 +4123,7 @@ Text dumps for tests: ordered `key = value` lines compared exactly with a file, - `pub fn in_room(&mut self, room: Room) -> &mut Self`. The room of a host kind: the same as [`Fixture::room`] with that kind's size. - `pub fn direction(&mut self, direction: Direction) -> &mut Self`. The layout direction. - `pub fn theme(&mut self, mode: Mode, contrast: Contrast) -> &mut Self`. Light or dark, and standard or high contrast. + - `pub fn theme_id(&mut self, theme: ThemeId) -> &mut Self`. The theme: one of the built-ins (`craft.adwaita`) or one a test registered. - `pub fn motion(&mut self, motion: MotionMode) -> &mut Self`. The motion mode. - `pub fn text_size(&mut self, text_size: TextSize) -> &mut Self`. The text-size step. - `pub fn density(&mut self, density: Size) -> &mut Self`. The density preset. diff --git a/tools/cl b/tools/cl index 1ff0f4190..9abb502ec 100755 --- a/tools/cl +++ b/tools/cl @@ -5,7 +5,7 @@ cl test [cargo args] [-- test args] build the crate's tests (cargo test --no-run), then run each test binary cl build gallery [cargo args] the debug gallery binary (target/debug/craft-ui-gallery) cl build [cargo args] cargo build of the crate's lib and bins - cl render [--card] [--story ] [--out ] [--threads N] + cl render [--card] [--story ] [--out ] [--threads N] [--theme ] [--mode light|dark] the component's stories (--card: its Overview cards) as PNGs through the story-render bin cl features print the --features value cl adds for cl doctor check the manifests for drift from the one feature resolution @@ -382,7 +382,7 @@ def main(): run(top, with_features(["build"] + selected(pkg) + own_targets(packages[pkg]), features) + args) if command == "render": if len(rest) < 2: - fail("cl render [--card] [--story ] [--out ] [--threads N]") + fail("cl render [--card] [--story ] [--out ] [--threads N] [--theme ] [--mode light|dark]") crate, component, options = rest[0], rest[1], rest[2:] short = crate.removeprefix("craft-") features = []