pub fn seed(kind: &str, rect: Rect) -> StringExpand description
The smallest node of this kind that a form can actually hold, as file text.
What a designer writes when somebody drops a widget on the canvas. A rectangle
is the most of it — but “a rect and nothing else” is not true of every widget,
because three of them have a property the builder requires: an alert has
no colour to draw itself in without a role, a slider has no range without
min and max, and an image has nothing to draw without a src. A node
missing one of those parses and then will not build, so a designer that wrote
one would place a widget and break the form.
select and collapse were a fourth and fifth until #118, and they were the
awkward ones: what they lacked was not a number but a message, so the seed
had to invent a name nobody had asked for. Both have an inert constructor
now, so a dropped one carries no message at all.
This lives beside the code that raises those requirements, so the two cannot
drift; a test seeds every widget in all, builds
the result, and fails if a new one needs something this does not give it.
use denise::Rect;
assert_eq!(
seed("button", Rect::new(16, 24, 100, 32)),
r#"button "button" x=16 y=24 w=100 h=32"#,
);