thing-core: a Px length in Cells is cells at the 8x16 cell metric, one adapter

Ruling cells-px-metric. Device::length is the one adapter that turns a document's Px length
into device units: times the scale in Pixels, divided by the cell metric (8 across, 16 down)
in Cells, per axis, with Taffy's rounding landing it on a cell. A flex basis runs along its
parent's main axis. CELL_PX is the one constant: the Image extent in CellMeasure reads it
instead of its own 8 and 16. The thing-tui screen goldens run the shared fixtures unedited
(as_cells deleted), so f03, f08, f11 and every other Cells golden are re-blessed from them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-28 12:47:43 +01:00
commit a91cafce43
23 changed files with 642 additions and 1473 deletions

View file

@ -114,8 +114,21 @@ pub fn cells_inset(height: f32) -> (f32, f32) {
(1.0, if height >= 3.0 { 1.0 } else { 0.0 })
}
/// Device px per cell, `(across, down)`: the metric a terminal cell stands for. In Cells mode a Px
/// length converts at it (8 wide, 16 tall), and an Image's pixel extent is read in cells at it.
pub(crate) const CELL_PX: (f32, f32) = (8.0, 16.0);
/// The axis a Px length runs along: across (width, left and right, columns) or down (height, top
/// and bottom, rows). A cell is not square, so a Px length converts per axis in Cells.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(super) enum Axis {
X,
Y,
}
/// The one place logical units become device units and back: `k` device px per logical px
/// (1 in Cells). Everything past this adapter, the style map and the solver included, is device.
/// (1 in Cells, where `length` divides a Px length by the cell metric instead). Everything past
/// this adapter, the style map and the solver included, is device.
#[derive(Clone, Copy, Debug)]
pub(super) struct Device {
k: f32,
@ -143,10 +156,25 @@ impl Device {
if self.cells { (38.0, 10.0) } else { (self.px(300.0), self.px(150.0)) }
}
/// A viewport side or a measured size in device units: logical px times the scale, or cells
/// as they are (a Measure answers in cells in Cells).
pub(super) fn px(self, logical: f32) -> f32 {
logical * self.k
}
/// A Px length of the document in device units along `axis`: times the scale in Pixels, divided
/// by the cell metric in Cells. Taffy's rounding then lands it on a device pixel or a cell.
pub(super) fn length(self, px: f32, axis: Axis) -> f32 {
if self.cells {
px / match axis {
Axis::X => CELL_PX.0,
Axis::Y => CELL_PX.1,
}
} else {
px * self.k
}
}
fn logical(self, device: f32) -> f32 {
device / self.k
}

View file

@ -4,7 +4,7 @@
//!
//! Pixels mode runs the solver in device pixels (every Px length and every measured size is
//! multiplied by the scale factor at the one adapter) with Taffy's cumulative rounding, so every
//! edge lands on a device pixel and adjacent boxes share it. Cells mode ignores the scale. The
//! edge lands on a device pixel and adjacent boxes share it. Cells mode ignores the scale and converts a Px length at the cell metric (8x16 device px per cell). The
//! viewport is a block container the document root flows in, and is not itself in the output.
//! Overlays are out of flow: after the main pass each is laid out as its own root against its anchor
//! and appended after every main-tree node.
@ -19,7 +19,7 @@ use measure::Device;
use thing_contract::{NodeId, OverlayNode};
pub use measure::{Avail, CellStyle, cells_inset, Constraint, FontId, Glyph, Leaf, Measure, Run, TextLayout, TextLine, TextRequest};
pub(crate) use measure::MAX_DEVICE;
pub(crate) use measure::{CELL_PX, MAX_DEVICE};
use crate::bind::BoundTree;
use crate::diagnostic::{Code, Diagnostic};

View file

@ -13,7 +13,7 @@ use taffy::{
};
use thing_contract as c;
use super::measure::{Device, MAX_DEVICE};
use super::measure::{Axis, Device, MAX_DEVICE};
/// Field names of the slots that took their initial value.
pub(super) type Invalid = Vec<&'static str>;
@ -23,34 +23,34 @@ fn number(value: f64, negative: bool) -> Option<f32> {
fits.then_some(value as f32)
}
fn length(scalar: &c::Scalar, dev: Device, negative: bool) -> Option<f32> {
number(scalar.value, negative).map(|v| dev.px(v)).filter(|v| v.abs() <= MAX_DEVICE)
fn length(scalar: &c::Scalar, dev: Device, axis: Axis, negative: bool) -> Option<f32> {
number(scalar.value, negative).map(|v| dev.length(v, axis)).filter(|v| v.abs() <= MAX_DEVICE)
}
fn percent(scalar: &c::Scalar, negative: bool) -> Option<f32> {
number(scalar.value, negative).map(|v| v / 100.0)
}
fn lp(d: &c::Dimension, dev: Device) -> Option<LengthPercentage> {
fn lp(d: &c::Dimension, dev: Device, axis: Axis) -> Option<LengthPercentage> {
match d {
c::Dimension::Px(s) => length(s, dev, false).map(LengthPercentage::length),
c::Dimension::Px(s) => length(s, dev, axis, false).map(LengthPercentage::length),
c::Dimension::Percent(s) => percent(s, false).map(LengthPercentage::percent),
_ => None,
}
}
fn lpa(d: &c::Dimension, dev: Device, negative: bool) -> Option<LengthPercentageAuto> {
fn lpa(d: &c::Dimension, dev: Device, axis: Axis, negative: bool) -> Option<LengthPercentageAuto> {
match d {
c::Dimension::Px(s) => length(s, dev, negative).map(LengthPercentageAuto::length),
c::Dimension::Px(s) => length(s, dev, axis, negative).map(LengthPercentageAuto::length),
c::Dimension::Percent(s) => percent(s, negative).map(LengthPercentageAuto::percent),
c::Dimension::Auto => Some(LengthPercentageAuto::auto()),
_ => None,
}
}
fn size_dim(d: &c::Dimension, dev: Device) -> Option<Dimension> {
fn size_dim(d: &c::Dimension, dev: Device, axis: Axis) -> Option<Dimension> {
match d {
c::Dimension::Px(s) => length(s, dev, false).map(Dimension::length),
c::Dimension::Px(s) => length(s, dev, axis, false).map(Dimension::length),
c::Dimension::Percent(s) => percent(s, false).map(Dimension::percent),
c::Dimension::Auto => Some(Dimension::auto()),
c::Dimension::Content => Some(Dimension::fit_content()),
@ -58,20 +58,20 @@ fn size_dim(d: &c::Dimension, dev: Device) -> Option<Dimension> {
}
}
fn basis_dim(d: &c::Dimension, dev: Device) -> Option<Dimension> {
fn basis_dim(d: &c::Dimension, dev: Device, axis: Axis) -> Option<Dimension> {
match d {
c::Dimension::Content => Some(Dimension::content()),
c::Dimension::Fr(_) => None,
other => size_dim(other, dev),
other => size_dim(other, dev, axis),
}
}
fn track(d: &c::Dimension, dev: Device) -> Option<GridTemplateComponent<String>> {
fn track(d: &c::Dimension, dev: Device, axis: Axis) -> Option<GridTemplateComponent<String>> {
use MaxTrackSizingFunction as Max;
use MinTrackSizingFunction as Min;
let (min, max) = match d {
c::Dimension::Px(s) => {
let v = length(s, dev, false)?;
let v = length(s, dev, axis, false)?;
(Min::length(v), Max::length(v))
}
c::Dimension::Percent(s) => {
@ -103,16 +103,16 @@ impl Slots {
fn size2(&mut self, field: &'static str, s: &c::Size2) -> Size<Dimension> {
let dev = self.dev;
Size {
width: self.take(field, size_dim(&s.width, dev), Dimension::auto()),
height: self.take(field, size_dim(&s.height, dev), Dimension::auto()),
width: self.take(field, size_dim(&s.width, dev, Axis::X), Dimension::auto()),
height: self.take(field, size_dim(&s.height, dev, Axis::Y), Dimension::auto()),
}
}
fn size2_lpa(&mut self, field: &'static str, s: &c::Size2) -> Size<LengthPercentageAuto> {
let dev = self.dev;
Size {
width: self.take(field, lpa(&s.width, dev, false), LengthPercentageAuto::auto()),
height: self.take(field, lpa(&s.height, dev, false), LengthPercentageAuto::auto()),
width: self.take(field, lpa(&s.width, dev, Axis::X, false), LengthPercentageAuto::auto()),
height: self.take(field, lpa(&s.height, dev, Axis::Y, false), LengthPercentageAuto::auto()),
}
}
@ -125,10 +125,10 @@ impl Slots {
) -> Rect<LengthPercentageAuto> {
let dev = self.dev;
Rect {
left: self.take(field, lpa(&e.left, dev, negative), initial),
right: self.take(field, lpa(&e.right, dev, negative), initial),
top: self.take(field, lpa(&e.top, dev, negative), initial),
bottom: self.take(field, lpa(&e.bottom, dev, negative), initial),
left: self.take(field, lpa(&e.left, dev, Axis::X, negative), initial),
right: self.take(field, lpa(&e.right, dev, Axis::X, negative), initial),
top: self.take(field, lpa(&e.top, dev, Axis::Y, negative), initial),
bottom: self.take(field, lpa(&e.bottom, dev, Axis::Y, negative), initial),
}
}
@ -136,16 +136,16 @@ impl Slots {
let dev = self.dev;
let zero = LengthPercentage::ZERO;
Rect {
left: self.take(field, lp(&e.left, dev), zero),
right: self.take(field, lp(&e.right, dev), zero),
top: self.take(field, lp(&e.top, dev), zero),
bottom: self.take(field, lp(&e.bottom, dev), zero),
left: self.take(field, lp(&e.left, dev, Axis::X), zero),
right: self.take(field, lp(&e.right, dev, Axis::X), zero),
top: self.take(field, lp(&e.top, dev, Axis::Y), zero),
bottom: self.take(field, lp(&e.bottom, dev, Axis::Y), zero),
}
}
fn tracks(&mut self, field: &'static str, dims: &[c::Dimension]) -> Vec<GridTemplateComponent<String>> {
fn tracks(&mut self, field: &'static str, axis: Axis, dims: &[c::Dimension]) -> Vec<GridTemplateComponent<String>> {
let dev = self.dev;
let tracks: Option<Vec<_>> = dims.iter().map(|d| track(d, dev)).collect();
let tracks: Option<Vec<_>> = dims.iter().map(|d| track(d, dev, axis)).collect();
self.take(field, tracks, Vec::new())
}
@ -179,7 +179,9 @@ fn content(align: &c::ContentAlign, auto: AlignContent) -> AlignContent {
}
/// The Taffy style of a Box. `dev` converts Px lengths to the solver's device units; the slots that were not legal are named in the second value.
pub(super) fn box_style(s: &c::BoxStyle, paint: &c::Paint, dev: Device) -> (Style, Invalid) {
/// `main` is the main axis of the flex container this box is a child of: a flex basis runs along
/// its parent's main axis, not the box's own.
pub(super) fn box_style(s: &c::BoxStyle, paint: &c::Paint, dev: Device, main: Axis) -> (Style, Invalid) {
let c::BoxStyle {
display,
direction,
@ -204,11 +206,15 @@ pub(super) fn box_style(s: &c::BoxStyle, paint: &c::Paint, dev: Device) -> (Styl
grid_rows,
} = s;
let mut slots = Slots { dev, invalid: Vec::new() };
let border = match &paint.border {
None => LengthPercentage::ZERO,
// A border is one width on four sides: across (left, right) and down (top, bottom) it
// converts at its own axis.
let (border_x, border_y) = match &paint.border {
None => (LengthPercentage::ZERO, LengthPercentage::ZERO),
Some(b) => {
let width = slots.take("border", length(&c::Scalar { value: b.width }, dev, false), 0.0);
LengthPercentage::length(width)
let width = c::Scalar { value: b.width };
let across = slots.take("border", length(&width, dev, Axis::X, false), 0.0);
let down = length(&width, dev, Axis::Y, false).unwrap_or(0.0);
(LengthPercentage::length(across), LengthPercentage::length(down))
}
};
let overflow = match overflow {
@ -217,8 +223,8 @@ pub(super) fn box_style(s: &c::BoxStyle, paint: &c::Paint, dev: Device) -> (Styl
c::Overflow::Scroll => TOverflow::Scroll,
};
let gap = {
let width = slots.take("gap", lp(&gap.width, dev), LengthPercentage::ZERO);
let height = slots.take("gap", lp(&gap.height, dev), LengthPercentage::ZERO);
let width = slots.take("gap", lp(&gap.width, dev, Axis::X), LengthPercentage::ZERO);
let height = slots.take("gap", lp(&gap.height, dev, Axis::Y), LengthPercentage::ZERO);
Size { width, height }
};
let style = Style {
@ -240,7 +246,7 @@ pub(super) fn box_style(s: &c::BoxStyle, paint: &c::Paint, dev: Device) -> (Styl
},
gap,
padding: slots.edges_lp("padding", padding),
border: Rect { left: border, right: border, top: border, bottom: border },
border: Rect { left: border_x, right: border_x, top: border_y, bottom: border_y },
margin: slots.edges_lpa("margin", margin, true, LengthPercentageAuto::ZERO),
size: slots.size2("size", size),
min_size: slots.size2_lpa("min_size", min_size),
@ -259,11 +265,11 @@ pub(super) fn box_style(s: &c::BoxStyle, paint: &c::Paint, dev: Device) -> (Styl
flex_grow: slots.weight("grow", *grow, 0.0),
flex_shrink: slots.weight("shrink", *shrink, 1.0),
flex_basis: {
let basis = basis_dim(basis, dev);
let basis = basis_dim(basis, dev, main);
slots.take("basis", basis, Dimension::auto())
},
grid_template_columns: slots.tracks("grid_columns", grid_columns).into_iter().collect(),
grid_template_rows: slots.tracks("grid_rows", grid_rows).into_iter().collect(),
grid_template_columns: slots.tracks("grid_columns", Axis::X, grid_columns).into_iter().collect(),
grid_template_rows: slots.tracks("grid_rows", Axis::Y, grid_rows).into_iter().collect(),
..Style::default()
};
(style, slots.invalid)
@ -272,12 +278,12 @@ pub(super) fn box_style(s: &c::BoxStyle, paint: &c::Paint, dev: Device) -> (Styl
/// An Embed's style: exactly its declared size, never shrunk.
pub(super) fn embed_style(width: f64, height: f64, dev: Device) -> (Style, Invalid) {
let mut slots = Slots { dev, invalid: Vec::new() };
let side = |slots: &mut Slots, value: f64| {
let v = slots.take("size", length(&c::Scalar { value }, dev, false), 0.0);
let side = |slots: &mut Slots, value: f64, axis: Axis| {
let v = slots.take("size", length(&c::Scalar { value }, dev, axis, false), 0.0);
(Dimension::length(v), LengthPercentageAuto::length(v))
};
let (w, wa) = side(&mut slots, width);
let (h, ha) = side(&mut slots, height);
let (w, wa) = side(&mut slots, width, Axis::X);
let (h, ha) = side(&mut slots, height, Axis::Y);
let style = Style {
size: Size { width: w, height: h },
min_size: Size { width: wa, height: ha },

View file

@ -1,9 +1,9 @@
//! The walk: a `BoundTree` becomes a Taffy tree, one Taffy node per laid node, Repeats spliced.
use taffy::{Style, TaffyTree};
use thing_contract::{Node, NodeId, Overflow, OverlayNode};
use thing_contract::{Direction, Node, NodeId, Overflow, OverlayNode};
use super::measure::{Device, Leaf, MAX_DEVICE, cells_inset, intrinsic_ratio};
use super::measure::{Axis, Device, Leaf, MAX_DEVICE, cells_inset, intrinsic_ratio};
use super::style::{Invalid, box_style, embed_style};
use crate::bind::{Bound, BoundTree, Field};
use crate::diagnostic::{Code, Diagnostic};
@ -41,6 +41,9 @@ struct Builder<'a, 'm> {
leaves: Vec<Leaf<'a>>,
diagnostics: Vec<Diagnostic>,
overlays: Vec<&'a OverlayNode>,
/// The main axis of the container whose children are being visited: the axis a child's flex
/// basis runs along. The viewport is a block, whose children take no basis; across stands.
main: Axis,
}
/// What the Taffy tree is rooted at: the viewport holding the document root, or one Overlay.
@ -71,6 +74,7 @@ pub(super) fn build<'a>(
leaves: Vec::new(),
diagnostics: Vec::new(),
overlays: Vec::new(),
main: Axis::X,
};
let mut kids = Vec::new();
let mut style = Style {
@ -163,15 +167,18 @@ impl<'a> Builder<'a, '_> {
parent: Option<usize>,
(style, invalid): (Style, Invalid),
overflow: &Overflow,
main: Axis,
children: &'a [Node],
out: &mut Vec<taffy::NodeId>,
) {
self.report(id, invalid);
let index = self.entry(id, parent, overflow);
let mut kids = Vec::new();
let outer = std::mem::replace(&mut self.main, main);
for child in children {
self.visit(child, Some(index), &mut kids);
}
self.main = outer;
let node = self.taffy.new_with_children(style, &kids).expect("taffy: insert");
self.entries[index].node = node;
out.push(node);
@ -183,8 +190,12 @@ impl<'a> Builder<'a, '_> {
grow(|| match node {
Node::Box(b) => {
if !self.hidden(&b.common.id) {
let style = box_style(&b.style, &b.paint, self.dev);
self.container(&b.common.id, parent, style, &b.style.overflow, &b.children, out);
let style = box_style(&b.style, &b.paint, self.dev, self.main);
let main = match b.style.direction {
Direction::Row | Direction::RowReverse => Axis::X,
Direction::Column | Direction::ColumnReverse => Axis::Y,
};
self.container(&b.common.id, parent, style, &b.style.overflow, main, &b.children, out);
}
}
Node::Button(b) => {
@ -204,7 +215,7 @@ impl<'a> Builder<'a, '_> {
} else {
Style::default()
};
self.container(&b.common.id, parent, (style, Vec::new()), &Overflow::Visible, &b.content, out);
self.container(&b.common.id, parent, (style, Vec::new()), &Overflow::Visible, Axis::X, &b.content, out);
}
}
// A Repeat has no box: its instances are its parent's children, in instance order.

View file

@ -17,7 +17,7 @@ use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
use crate::bind::Bound;
use crate::layout::{Avail, CellStyle, Constraint, Leaf, Measure, Run, TextLayout, TextLine, TextRequest};
use crate::layout::{Avail, CELL_PX, CellStyle, Constraint, Leaf, Measure, Run, TextLayout, TextLine, TextRequest};
/// The tab stop, in columns (CSS `tab-size: 8`).
const TAB: u32 = 8;
@ -298,7 +298,7 @@ impl Measure for CellMeasure {
Leaf::Slider { .. } => (20.0, 1.0),
Leaf::Select { .. } => (20.0, 1.0),
Leaf::Image { asset, .. } => match asset {
Bound::Asset(entry) => ((entry.width.get() as f32 / 8.0).ceil(), (entry.height.get() as f32 / 16.0).ceil()),
Bound::Asset(entry) => ((entry.width.get() as f32 / CELL_PX.0).ceil(), (entry.height.get() as f32 / CELL_PX.1).ceil()),
_ => (0.0, 0.0),
},
}

View file

@ -1,8 +1,8 @@
surface thing:surface:provider.swarm.dashboard viewport 100x37 scale 1 cells
root 0 0 100 23
load 2 2 48 1
minds#6:mind-1/mind-name 54 2 48 1
minds#6:mind-2/mind-name 2 11 48 1
minds#6:mind-3/mind-name 54 11 48 1
restart 2 20 48 1
restart-label 3 20 46 1
root 0 0 100 4
load 0 0 50 1
minds#6:mind-1/mind-name 51 0 49 1
minds#6:mind-2/mind-name 0 2 50 1
minds#6:mind-3/mind-name 51 2 49 1
restart 0 3 50 1
restart-label 1 3 48 1

View file

@ -1,9 +1,9 @@
surface thing:surface:provider.swarm.dashboard viewport 100x37 scale 1 cells
fill 0 0 100 23 r8 #1e1e2eff
text 2 2 #ffffffff cells "42.0%" bold=false italic=false underline=false
text 54 2 #eeeef4ff cells "Eureka" bold=false italic=false underline=false
text 2 11 #eeeef4ff cells "Libby" bold=false italic=false underline=false
text 54 11 #eeeef4ff cells "Kiko" bold=false italic=false underline=false
fill 2 20 48 1 r0 #2c2c3eff
stroke 2 20 48 1 r0 w1 #4a4a60ff
text 3 20 #eeeef4ff cells "Restart" bold=false italic=false underline=false
fill 0 0 100 4 r8 #1e1e2eff
text 0 0 #ffffffff cells "42.0%" bold=false italic=false underline=false
text 51 0 #eeeef4ff cells "Eureka" bold=false italic=false underline=false
text 0 2 #eeeef4ff cells "Libby" bold=false italic=false underline=false
text 51 2 #eeeef4ff cells "Kiko" bold=false italic=false underline=false
fill 0 3 50 1 r0 #2c2c3eff
stroke 0 3 50 1 r0 w1 #4a4a60ff
text 1 3 #eeeef4ff cells "Restart" bold=false italic=false underline=false

View file

@ -1,31 +1,28 @@
surface thing:surface:provider.text.text-edge viewport 40x60 scale 1 cells
text 2 2 #eeeef4ff cells "Hello שלום עולם and مرحبا بالعالم" bold=false italic=false underline=false
text 2 3 #eeeef4ff cells "then 123 end." bold=false italic=false underline=false
text 2 12 #eeeef4ff cells "日本語テスト 你好世界 한국어 ABC" bold=false italic=false underline=false widths=2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,1,2,2,2
text 2 13 #eeeef4ff cells "123" bold=false italic=false underline=false widths=2,2,2
text 2 22 #eeeef4ff cells "e\u{301} a\u{308} n\u{303} o\u{302}\u{323} z\u{35b}\u{34f}\u{300}" bold=false italic=false underline=false
text 2 31 #eeeef4ff cells "👩\u{200d}👩\u{200d}👧\u{200d}👦 👨🏽\u{200d}💻 🏳\u{fe0f}\u{200d}🌈" bold=false italic=false underline=false widths=2,1,2,1,2
text 2 40 #eeeef4ff cells "The quick brown fox jumps over the" bold=false italic=false underline=false
text 2 41 #eeeef4ff cells "lazy dog while the evening light" bold=false italic=false underline=false
text 2 42 #eeeef4ff cells "slides across the valley, and the" bold=false italic=false underline=false
text 2 43 #eeeef4ff cells "long paragraph keeps going so that" bold=false italic=false underline=false
text 2 44 #eeeef4ff cells "any reasonable column must break it" bold=false italic=false underline=false
text 2 45 #eeeef4ff cells "across several lines. The quick" bold=false italic=false underline=false
text 2 46 #eeeef4ff cells "brown fox jumps over the lazy dog" bold=false italic=false underline=false
text 2 47 #eeeef4ff cells "while the evening light slides" bold=false italic=false underline=false
text 2 48 #eeeef4ff cells "across the valley, and the long" bold=false italic=false underline=false
text 2 49 #eeeef4ff cells "paragraph keeps going so that any" bold=false italic=false underline=false
text 2 50 #eeeef4ff cells "reasonable column must break it" bold=false italic=false underline=false
text 2 51 #eeeef4ff cells "across several lines. The quick" bold=false italic=false underline=false
text 2 52 #eeeef4ff cells "brown fox jumps over the lazy dog" bold=false italic=false underline=false
text 2 53 #eeeef4ff cells "while the evening light slides" bold=false italic=false underline=false
text 2 54 #eeeef4ff cells "across the valley, and the long" bold=false italic=false underline=false
text 2 55 #eeeef4ff cells "paragraph keeps going so that any" bold=false italic=false underline=false
text 2 56 #eeeef4ff cells "reasonable column must break it" bold=false italic=false underline=false
text 2 57 #eeeef4ff cells "across several lines. The quick" bold=false italic=false underline=false
text 2 58 #eeeef4ff cells "brown fox jumps over the lazy dog" bold=false italic=false underline=false
text 2 59 #eeeef4ff cells "while the evening light slides" bold=false italic=false underline=false
text 2 60 #eeeef4ff cells "across the valley, and the long" bold=false italic=false underline=false
text 2 61 #eeeef4ff cells "paragraph keeps going so that any" bold=false italic=false underline=false
text 2 62 #eeeef4ff cells "reasonable column must break it" bold=false italic=false underline=false
text 2 63 #eeeef4ff cells "across several lines. " bold=false italic=false underline=false
text 0 0 #eeeef4ff cells "Hello שלום עולם and مرحبا بالعالم then" bold=false italic=false underline=false
text 0 1 #eeeef4ff cells "123 end." bold=false italic=false underline=false
text 0 3 #eeeef4ff cells "日本語テスト 你好世界 한국어 ABC12" bold=false italic=false underline=false widths=2,2,2,2,2,2,1,2,2,2,2,1,2,2,2,1,2,2,2,2,2
text 0 4 #eeeef4ff cells "3" bold=false italic=false underline=false widths=2
text 0 5 #eeeef4ff cells "e\u{301} a\u{308} n\u{303} o\u{302}\u{323} z\u{35b}\u{34f}\u{300}" bold=false italic=false underline=false
text 0 7 #eeeef4ff cells "👩\u{200d}👩\u{200d}👧\u{200d}👦 👨🏽\u{200d}💻 🏳\u{fe0f}\u{200d}🌈" bold=false italic=false underline=false widths=2,1,2,1,2
text 0 8 #eeeef4ff cells "The quick brown fox jumps over the lazy" bold=false italic=false underline=false
text 0 9 #eeeef4ff cells "dog while the evening light slides" bold=false italic=false underline=false
text 0 10 #eeeef4ff cells "across the valley, and the long" bold=false italic=false underline=false
text 0 11 #eeeef4ff cells "paragraph keeps going so that any" bold=false italic=false underline=false
text 0 12 #eeeef4ff cells "reasonable column must break it across" bold=false italic=false underline=false
text 0 13 #eeeef4ff cells "several lines. The quick brown fox jumps" bold=false italic=false underline=false
text 0 14 #eeeef4ff cells "over the lazy dog while the evening" bold=false italic=false underline=false
text 0 15 #eeeef4ff cells "light slides across the valley, and the" bold=false italic=false underline=false
text 0 16 #eeeef4ff cells "long paragraph keeps going so that any" bold=false italic=false underline=false
text 0 17 #eeeef4ff cells "reasonable column must break it across" bold=false italic=false underline=false
text 0 18 #eeeef4ff cells "several lines. The quick brown fox jumps" bold=false italic=false underline=false
text 0 19 #eeeef4ff cells "over the lazy dog while the evening" bold=false italic=false underline=false
text 0 20 #eeeef4ff cells "light slides across the valley, and the" bold=false italic=false underline=false
text 0 21 #eeeef4ff cells "long paragraph keeps going so that any" bold=false italic=false underline=false
text 0 22 #eeeef4ff cells "reasonable column must break it across" bold=false italic=false underline=false
text 0 23 #eeeef4ff cells "several lines. The quick brown fox jumps" bold=false italic=false underline=false
text 0 24 #eeeef4ff cells "over the lazy dog while the evening" bold=false italic=false underline=false
text 0 25 #eeeef4ff cells "light slides across the valley, and the" bold=false italic=false underline=false
text 0 26 #eeeef4ff cells "long paragraph keeps going so that any" bold=false italic=false underline=false
text 0 27 #eeeef4ff cells "reasonable column must break it across" bold=false italic=false underline=false
text 0 28 #eeeef4ff cells "several lines. " bold=false italic=false underline=false

View file

@ -1227,3 +1227,41 @@ fn overlays_hold_the_bound() {
other => panic!("{other:?}"),
}
}
#[test]
fn a_px_length_in_cells_is_cells_at_the_cell_metric_per_axis() {
// 8 px across and 16 px down are one cell: a width, margin or border across divides by 8, a
// height or one down by 16, and an item's basis by the axis it runs along.
let mut style = sized(80.0, 32.0);
style.padding = Edges { left: px(8.0), top: px(16.0), right: px(8.0), bottom: px(16.0) };
let child = bx("child", sized(24.0, 16.0), vec![]);
let root = bx("root", style, vec![child]);
let laid = lay_with(&mut MemState::new(), root, &cells(100.0, 37.0));
assert_eq!(rect(&laid, "root"), (0.0, 0.0, 10.0, 2.0));
assert_eq!(rect(&laid, "child"), (1.0, 1.0, 3.0, 1.0));
let border = Paint { background: None, border: Some(Border { color: ColorRef::Rgba(Rgba { r: 0, g: 0, b: 0, a: 255 }), width: 16.0 }), radius: 0.0 };
let framed = bx_paint("framed", sized(80.0, 48.0), border, vec![bx("inner", BoxStyle { grow: 1.0, ..plain() }, vec![])]);
let laid = lay_with(&mut MemState::new(), framed, &cells(100.0, 37.0));
assert_eq!(rect(&laid, "inner"), (2.0, 1.0, 6.0, 1.0), "a 16 px border is 2 cells across and 1 down");
let along = |direction: Direction| {
let style = BoxStyle { direction, ..sized(80.0, 80.0) };
let item = bx("item", BoxStyle { basis: px(32.0), ..plain() }, vec![]);
let laid = lay_with(&mut MemState::new(), bx("root", style, vec![item]), &cells(100.0, 37.0));
rect(&laid, "item")
};
assert_eq!(along(Direction::Row).2, 4.0, "a row's basis runs across: 32 px is 4 cells");
assert_eq!(along(Direction::Column).3, 2.0, "a column's basis runs down: 32 px is 2 rows");
let grid = BoxStyle {
display: Display::Grid,
grid_columns: vec![px(24.0), Dimension::Fr(Scalar { value: 1.0 })],
grid_rows: vec![px(32.0)],
gap: size2(px(16.0), px(16.0)),
..sized(80.0, 80.0)
};
let laid = lay_with(&mut MemState::new(), bx("grid", grid, vec![bx("a", plain(), vec![]), bx("b", plain(), vec![])]), &cells(100.0, 37.0));
assert_eq!((rect(&laid, "a").2, rect(&laid, "a").3), (3.0, 2.0), "tracks: 24 px across, 32 px down");
assert_eq!(rect(&laid, "b").0, 5.0, "the gap across is 16 px: 2 cells");
}

View file

@ -558,7 +558,7 @@ fn wrapping_text_is_one_command_per_engine_line_at_the_node_origin() {
assert_eq!(t.3, 64.0, "layout sized the leaf for the lines the engine returns");
// Cells: the line's characters, one row each.
let cells = frame(20.0, 10.0, 1.0, Metrics::Cells);
let root = if let Node::Box(mut b) = root { b.style.size = size2(px(5.0), Dimension::Auto); b.style.padding = edges(px(0.0)); Node::Box(b) } else { unreachable!() };
let root = if let Node::Box(mut b) = root { b.style.size = size2(px(40.0), Dimension::Auto); b.style.padding = edges(px(0.0)); Node::Box(b) } else { unreachable!() };
let (_, rendered) = inline(root, &cells, &ScrollOffsets::default());
let texts: Vec<(f32, f32, String)> = rendered
.commands
@ -1208,7 +1208,7 @@ fn cells_content_keeps_clear_of_every_bordered_controls_border() {
// A Button's content likewise, with the label centred between the borders of a tall Button.
let button = |height: f64| {
let mut style = plain();
style.size = size2(px(20.0), px(height));
style.size = size2(px(20.0 * 8.0), px(height * 16.0));
let node = Node::Button(ButtonNode { common: common("b"), content: vec![text("label", "Go")], on_activate: command("dismiss"), enabled: lit_bool(true) });
flat("root", style, vec![node])
};
@ -1226,3 +1226,17 @@ fn cells_content_keeps_clear_of_every_bordered_controls_border() {
let r = rendered(flat("root", plain(), vec![pixels_input]));
assert!(matches!(r.commands.last(), Some(RenderCommand::Text { origin, .. }) if origin.0 == 2.0));
}
#[test]
fn an_image_extent_and_a_px_box_of_the_same_size_are_the_same_cells() {
// One cell is 8x16 device px for both: the Image's pixel extent and a Box's Px size.
let provider = ProviderId::new(PROVIDER);
let mut state = MemState::new();
state.put(&provider, &catalog(&[("pic", 64, 32)]));
let root = flat("root", plain(), vec![image("pic", "pic", ImageFit::Fill), flat("twin", sized(64.0, 32.0), vec![])]);
let tree = bind(&mut state, &surface_of(root)).expect("resolves");
let frame = frame(30.0, 12.0, 1.0, Metrics::Cells);
let (_, rendered) = draw_with(Engine::Real, &tree, &frame, &ScrollOffsets::default());
assert_eq!(xywh(placed(&rendered, "pic")), (0.0, 0.0, 8.0, 2.0));
assert_eq!(xywh(placed(&rendered, "twin")), (8.0, 0.0, 8.0, 2.0));
}

View file

@ -1,25 +1,8 @@
surface thing:surface:provider.swarm.dashboard 100x37
42.0% Eureka
42.0% Eureka
Libby Kiko
[Restart ]
Libby Kiko
[Restart ]
@ -36,42 +19,56 @@ surface thing:surface:provider.swarm.dashboard 100x37
style 0 0 100 - #1e1e2e -
style 0 0 5 #ffffff #1e1e2e -
style 0 5 46 - #1e1e2e -
style 0 51 6 #eeeef4 #1e1e2e -
style 0 57 43 - #1e1e2e -
style 1 0 100 - #1e1e2e -
style 2 0 2 - #1e1e2e -
style 2 2 5 #ffffff #1e1e2e -
style 2 7 47 - #1e1e2e -
style 2 54 6 #eeeef4 #1e1e2e -
style 2 60 40 - #1e1e2e -
style 3 0 100 - #1e1e2e -
style 4 0 100 - #1e1e2e -
style 5 0 100 - #1e1e2e -
style 6 0 100 - #1e1e2e -
style 7 0 100 - #1e1e2e -
style 8 0 100 - #1e1e2e -
style 9 0 100 - #1e1e2e -
style 10 0 100 - #1e1e2e -
style 11 0 2 - #1e1e2e -
style 11 2 5 #eeeef4 #1e1e2e -
style 11 7 47 - #1e1e2e -
style 11 54 4 #eeeef4 #1e1e2e -
style 11 58 42 - #1e1e2e -
style 12 0 100 - #1e1e2e -
style 13 0 100 - #1e1e2e -
style 14 0 100 - #1e1e2e -
style 15 0 100 - #1e1e2e -
style 16 0 100 - #1e1e2e -
style 17 0 100 - #1e1e2e -
style 18 0 100 - #1e1e2e -
style 19 0 100 - #1e1e2e -
style 20 0 2 - #1e1e2e -
style 20 2 1 #4a4a60 #2c2c3e -
style 20 3 7 #eeeef4 #2c2c3e -
style 20 10 39 - #2c2c3e -
style 20 49 1 #4a4a60 #2c2c3e -
style 20 50 50 - #1e1e2e -
style 21 0 100 - #1e1e2e -
style 22 0 100 - #1e1e2e -
style 2 0 5 #eeeef4 #1e1e2e -
style 2 5 46 - #1e1e2e -
style 2 51 4 #eeeef4 #1e1e2e -
style 2 55 45 - #1e1e2e -
style 3 0 1 #4a4a60 #2c2c3e -
style 3 1 7 #eeeef4 #2c2c3e -
style 3 8 41 - #2c2c3e -
style 3 49 1 #4a4a60 #2c2c3e -
style 3 50 50 - #1e1e2e -
style 4 0 100 - - -
style 5 0 100 - - -
style 6 0 100 - - -
style 7 0 100 - - -
style 8 0 100 - - -
style 9 0 100 - - -
style 10 0 100 - - -
style 11 0 100 - - -
style 12 0 100 - - -
style 13 0 100 - - -
style 14 0 100 - - -
style 15 0 100 - - -
style 16 0 100 - - -
style 17 0 100 - - -
style 18 0 100 - - -
style 19 0 100 - - -
style 20 0 100 - - -
style 21 0 100 - - -
style 22 0 100 - - -
style 23 0 100 - - -
style 24 0 100 - - -
style 25 0 100 - - -

View file

@ -1,16 +1,7 @@
surface thing:surface:provider.login.login 100x37
[username ]
[username ]
[Sign in ]
[Sign in ]
@ -36,14 +27,24 @@ surface thing:surface:provider.login.login 100x37
style 0 0 100 - - -
style 0 0 1 #4a4a60 - -
style 0 1 8 #6e6e80 - -
style 0 9 90 - - -
style 0 99 1 #4a4a60 - -
style 1 0 100 - - -
style 2 0 2 - - -
style 2 2 1 #4a4a60 - -
style 2 3 8 #6e6e80 - -
style 2 11 86 - - -
style 2 97 1 #4a4a60 - -
style 2 98 2 - - -
style 2 0 1 #4a4a60 #2c2c3e -
style 2 1 7 #eeeef4 #2c2c3e -
style 2 8 91 - #2c2c3e -
style 2 99 1 #4a4a60 #2c2c3e -
style 3 0 100 - - -
style 4 0 100 - - -
style 5 0 100 - - -
@ -52,12 +53,7 @@ style 7 0 100 - - -
style 8 0 100 - - -
style 9 0 100 - - -
style 10 0 100 - - -
style 11 0 2 - - -
style 11 2 1 #4a4a60 #2c2c3e -
style 11 3 7 #eeeef4 #2c2c3e -
style 11 10 87 - #2c2c3e -
style 11 97 1 #4a4a60 #2c2c3e -
style 11 98 2 - - -
style 11 0 100 - - -
style 12 0 100 - - -
style 13 0 100 - - -
style 14 0 100 - - -

View file

@ -1,15 +1,13 @@
surface thing:surface:provider.muninn.input-target 100x37
The board the target sits on░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░Ready░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░Ready░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
@ -36,6 +34,8 @@ surface thing:surface:provider.muninn.input-target 100x37
style 0 0 100 - - -
style 1 0 100 - - -
style 2 0 100 - - -
@ -44,9 +44,9 @@ style 4 0 100 - - -
style 5 0 100 - - -
style 6 0 100 - - -
style 7 0 100 - - -
style 8 0 42 - - -
style 8 42 5 #eeeef4 - -
style 8 47 53 - - -
style 8 0 35 - - -
style 8 35 5 #eeeef4 - -
style 8 40 60 - - -
style 9 0 100 - - -
style 10 0 100 - - -
style 11 0 100 - - -

View file

@ -1,7 +1,10 @@
surface thing:surface:provider.settings.form 100x37
[ ]
[ ]
[Dark ]
[8080 ]
@ -19,7 +22,6 @@ surface thing:surface:provider.settings.form 100x37
[Dark ]
@ -28,34 +30,34 @@ surface thing:surface:provider.settings.form 100x37
[8080 ]
style 0 0 100 - - -
style 0 0 1 #4a4a60 - -
style 0 1 97 - - -
style 0 98 1 - #7c9cff -
style 0 99 1 #4a4a60 - -
style 1 0 100 - - -
style 2 0 2 - - -
style 2 2 1 #4a4a60 - -
style 2 3 93 - - -
style 2 96 1 - #7c9cff -
style 2 97 1 #4a4a60 - -
style 2 98 2 - - -
style 3 0 100 - - -
style 2 0 99 - #4a4a60 -
style 2 99 1 - #7c9cff -
style 3 0 1 #4a4a60 - -
style 3 1 4 #eeeef4 - -
style 3 5 94 - - -
style 3 99 1 #4a4a60 - -
style 4 0 100 - - -
style 5 0 100 - - -
style 5 0 1 #4a4a60 - -
style 5 1 4 #eeeef4 - -
style 5 5 94 - - -
style 5 99 1 #4a4a60 - -
style 6 0 100 - - -
style 7 0 100 - - -
style 8 0 100 - - -
style 9 0 100 - - -
style 10 0 100 - - -
style 11 0 2 - - -
style 11 2 95 - #4a4a60 -
style 11 97 1 - #7c9cff -
style 11 98 2 - - -
style 11 0 100 - - -
style 12 0 100 - - -
style 13 0 100 - - -
style 14 0 100 - - -
@ -64,12 +66,7 @@ style 16 0 100 - - -
style 17 0 100 - - -
style 18 0 100 - - -
style 19 0 100 - - -
style 20 0 2 - - -
style 20 2 1 #4a4a60 - -
style 20 3 4 #eeeef4 - -
style 20 7 90 - - -
style 20 97 1 #4a4a60 - -
style 20 98 2 - - -
style 20 0 100 - - -
style 21 0 100 - - -
style 22 0 100 - - -
style 23 0 100 - - -
@ -78,12 +75,7 @@ style 25 0 100 - - -
style 26 0 100 - - -
style 27 0 100 - - -
style 28 0 100 - - -
style 29 0 2 - - -
style 29 2 1 #4a4a60 - -
style 29 3 4 #eeeef4 - -
style 29 7 90 - - -
style 29 97 1 #4a4a60 - -
style 29 98 2 - - -
style 29 0 100 - - -
style 30 0 100 - - -
style 31 0 100 - - -
style 32 0 100 - - -

View file

@ -1,32 +1,5 @@
surface thing:surface:provider.dialog.modal 100x37
The archive holds 12 items.
Delete the archive?
[Delete ]
[Cancel ]
The archive holds 12 items.
@ -36,50 +9,71 @@ surface thing:surface:provider.dialog.modal 100x37
style 0 0 100 - #000000 -
Delete the archive?
[Delete ]
[Cancel ]
style 0 0 27 #eeeef4 #000000 -
style 0 27 73 - #000000 -
style 1 0 100 - #000000 -
style 2 0 2 - #000000 -
style 2 2 27 #eeeef4 #000000 -
style 2 29 71 - #000000 -
style 2 0 100 - #000000 -
style 3 0 100 - #000000 -
style 4 0 100 - #000000 -
style 5 0 100 - #000000 -
style 6 0 100 - #000000 -
style 7 0 100 - #2c2c3e -
style 8 0 100 - #2c2c3e -
style 9 0 2 - #2c2c3e -
style 9 2 19 #eeeef4 #2c2c3e -
style 9 21 79 - #2c2c3e -
style 10 0 100 - #2c2c3e -
style 11 0 100 - #2c2c3e -
style 12 0 100 - #2c2c3e -
style 13 0 100 - #2c2c3e -
style 14 0 100 - #2c2c3e -
style 15 0 100 - #2c2c3e -
style 7 0 100 - #000000 -
style 8 0 100 - #000000 -
style 9 0 100 - #000000 -
style 10 0 100 - #000000 -
style 11 0 100 - #000000 -
style 12 0 100 - #000000 -
style 13 0 100 - #000000 -
style 14 0 100 - #000000 -
style 15 0 100 - #000000 -
style 16 0 100 - #2c2c3e -
style 17 0 100 - #2c2c3e -
style 18 0 2 - #2c2c3e -
style 18 2 1 #4a4a60 #2c2c3e -
style 18 3 6 #eeeef4 #2c2c3e -
style 18 9 88 - #2c2c3e -
style 18 97 1 #4a4a60 #2c2c3e -
style 18 98 2 - #2c2c3e -
style 17 0 19 #eeeef4 #2c2c3e -
style 17 19 81 - #2c2c3e -
style 18 0 1 #4a4a60 #2c2c3e -
style 18 1 6 #eeeef4 #2c2c3e -
style 18 7 92 - #2c2c3e -
style 18 99 1 #4a4a60 #2c2c3e -
style 19 0 100 - #2c2c3e -
style 20 0 100 - #2c2c3e -
style 21 0 100 - #2c2c3e -
style 22 0 100 - #2c2c3e -
style 23 0 100 - #2c2c3e -
style 24 0 100 - #2c2c3e -
style 25 0 100 - #2c2c3e -
style 26 0 100 - #2c2c3e -
style 27 0 2 - #2c2c3e -
style 27 2 1 #4a4a60 #2c2c3e -
style 27 3 6 #eeeef4 #2c2c3e -
style 27 9 88 - #2c2c3e -
style 27 97 1 #4a4a60 #2c2c3e -
style 27 98 2 - #2c2c3e -
style 28 0 100 - #2c2c3e -
style 29 0 100 - #2c2c3e -
style 20 0 1 #4a4a60 #2c2c3e -
style 20 1 6 #eeeef4 #2c2c3e -
style 20 7 92 - #2c2c3e -
style 20 99 1 #4a4a60 #2c2c3e -
style 21 0 100 - #000000 -
style 22 0 100 - #000000 -
style 23 0 100 - #000000 -
style 24 0 100 - #000000 -
style 25 0 100 - #000000 -
style 26 0 100 - #000000 -
style 27 0 100 - #000000 -
style 28 0 100 - #000000 -
style 29 0 100 - #000000 -
style 30 0 100 - #000000 -
style 31 0 100 - #000000 -
style 32 0 100 - #000000 -

View file

@ -1,9 +1,28 @@
surface thing:surface:provider.feed.scroll-list 100x37
Item 0
Item 1
Item 2
Item 3
Item 4
Item 0
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
Item 11
Item 12
Item 13
@ -16,75 +35,66 @@ surface thing:surface:provider.feed.scroll-list 100x37
Item 1
Item 2
style 0 0 99 - - -
style 0 99 1 - #666666 -
style 1 0 99 - - -
style 1 99 1 - #666666 -
style 2 0 99 - - -
style 2 99 1 - #666666 -
style 3 0 99 - - -
style 3 99 1 - #666666 -
style 4 0 4 - - -
style 4 4 6 #eeeef4 - -
style 4 10 89 - - -
style 4 99 1 - #666666 -
style 5 0 99 - - -
style 5 99 1 - #666666 -
style 6 0 99 - - -
style 6 99 1 - #666666 -
style 7 0 99 - - -
style 7 99 1 - #666666 -
style 8 0 99 - - -
style 8 99 1 - #666666 -
style 9 0 99 - - -
style 9 99 1 - #666666 -
style 10 0 99 - - -
style 10 99 1 - #666666 -
style 11 0 99 - - -
style 11 99 1 - #666666 -
style 0 0 1 - - -
style 0 1 6 #eeeef4 - -
style 0 7 93 - - -
style 1 0 100 - - -
style 2 0 1 - - -
style 2 1 6 #eeeef4 - -
style 2 7 93 - - -
style 3 0 100 - - -
style 4 0 1 - - -
style 4 1 6 #eeeef4 - -
style 4 7 93 - - -
style 5 0 100 - - -
style 6 0 1 - - -
style 6 1 6 #eeeef4 - -
style 6 7 93 - - -
style 7 0 1 - - -
style 7 1 6 #eeeef4 - -
style 7 7 93 - - -
style 8 0 100 - - -
style 9 0 1 - - -
style 9 1 6 #eeeef4 - -
style 9 7 93 - - -
style 10 0 100 - - -
style 11 0 1 - - -
style 11 1 6 #eeeef4 - -
style 11 7 93 - - -
style 12 0 100 - - -
style 13 0 100 - - -
style 14 0 100 - - -
style 13 0 1 - - -
style 13 1 6 #eeeef4 - -
style 13 7 93 - - -
style 14 0 1 - - -
style 14 1 6 #eeeef4 - -
style 14 7 93 - - -
style 15 0 100 - - -
style 16 0 100 - - -
style 17 0 4 - - -
style 17 4 6 #eeeef4 - -
style 17 10 90 - - -
style 18 0 100 - - -
style 16 0 1 - - -
style 16 1 6 #eeeef4 - -
style 16 7 93 - - -
style 17 0 100 - - -
style 18 0 1 - - -
style 18 1 7 #eeeef4 - -
style 18 8 92 - - -
style 19 0 100 - - -
style 20 0 100 - - -
style 21 0 100 - - -
style 20 0 1 - - -
style 20 1 7 #eeeef4 - -
style 20 8 92 - - -
style 21 0 1 - - -
style 21 1 7 #eeeef4 - -
style 21 8 92 - - -
style 22 0 100 - - -
style 23 0 100 - - -
style 23 0 1 - - -
style 23 1 7 #eeeef4 - -
style 23 8 92 - - -
style 24 0 100 - - -
style 25 0 100 - - -
style 26 0 100 - - -
style 27 0 100 - - -
style 28 0 100 - - -
style 29 0 100 - - -
style 30 0 4 - - -
style 30 4 6 #eeeef4 - -
style 30 10 90 - - -
style 30 0 100 - - -
style 31 0 100 - - -
style 32 0 100 - - -
style 33 0 100 - - -

View file

@ -1,16 +1,14 @@
surface thing:surface:provider.market.plot 100x37
⢀⠎⠒⢄⡀
⢠⠃ ⠈⠑⠤⡀
⡰⠁ ⠈⠑⠢⣀
⡜
⢀⠎
⡠⠊⠒⠤⣀ ⡠⠃
⡠⠊ ⠉⠒⠤⣀ ⡰⠁
⢀⠎ ⠉⠒⠜
⢀⠔⠁
⢀⠎⠒⢄⡀
⢠⠃ ⠈⠑⠤⡀
⡰⠁ ⠈⠑⠢⣀
⡜
⢀⠎
⡠⠊⠒⠤⣀ ⡠⠃
⡠⠊ ⠉⠒⠤⣀ ⡰⠁
⢀⠎ ⠉⠒⠜
⢀⠔⠁
⢀⠔⠁
@ -36,92 +34,94 @@ surface thing:surface:provider.market.plot 100x37
style 0 0 100 - - -
style 1 0 100 - - -
style 2 0 29 - - -
style 2 29 5 #7c9cff - -
style 2 34 66 - - -
style 3 0 28 - - -
style 3 28 2 #7c9cff - -
style 3 30 3 - - -
style 3 33 4 #7c9cff - -
style 3 37 63 - - -
style 4 0 27 - - -
style 4 27 2 #7c9cff - -
style 4 29 7 - - -
style 4 36 4 #7c9cff - -
style 4 40 60 - - -
style 5 0 26 - - -
style 5 26 1 #7c9cff - -
style 5 27 73 - - -
style 6 0 24 - - -
style 6 24 2 #7c9cff - -
style 6 26 74 - - -
style 7 0 10 - - -
style 7 10 5 #7c9cff - -
style 7 15 8 - - -
style 7 23 2 #7c9cff - -
style 7 25 75 - - -
style 8 0 8 - - -
style 8 8 2 #7c9cff - -
style 8 10 5 - - -
style 8 15 4 #7c9cff - -
style 8 19 3 - - -
style 8 22 2 #7c9cff - -
style 8 24 76 - - -
style 9 0 6 - - -
style 9 6 2 #7c9cff - -
style 9 8 11 - - -
style 9 19 3 #7c9cff - -
style 9 22 78 - - -
style 10 0 4 - - -
style 10 4 3 #7c9cff - -
style 10 7 93 - - -
style 11 0 2 - - -
style 11 2 3 #7c9cff - -
style 11 5 95 - - -
style 12 0 100 - - -
style 13 0 100 - - -
style 14 0 100 - - -
style 15 0 100 - - -
style 16 0 100 - - -
style 17 0 100 - - -
style 18 0 100 - - -
style 19 0 100 - - -
style 20 0 25 - - -
style 20 25 7 - #7c9cff -
style 20 32 68 - - -
style 21 0 25 - - -
style 21 25 7 - #7c9cff -
style 21 32 68 - - -
style 22 0 25 - - -
style 22 25 15 - #7c9cff -
style 22 40 60 - - -
style 23 0 10 - - -
style 23 10 7 - #7c9cff -
style 23 17 8 - - -
style 23 25 15 - #7c9cff -
style 23 40 60 - - -
style 24 0 10 - - -
style 24 10 7 - #7c9cff -
style 24 17 8 - - -
style 24 25 15 - #7c9cff -
style 24 40 60 - - -
style 25 0 10 - - -
style 25 10 30 - #7c9cff -
style 25 40 60 - - -
style 26 0 2 - - -
style 26 2 38 - #7c9cff -
style 26 40 60 - - -
style 27 0 2 - - -
style 27 2 38 - #7c9cff -
style 27 40 60 - - -
style 28 0 2 - - -
style 28 2 38 - #7c9cff -
style 28 40 60 - - -
style 29 0 2 - - -
style 29 2 38 - #7c9cff -
style 29 40 60 - - -
style 0 0 27 - - -
style 0 27 5 #7c9cff - -
style 0 32 68 - - -
style 1 0 26 - - -
style 1 26 2 #7c9cff - -
style 1 28 3 - - -
style 1 31 4 #7c9cff - -
style 1 35 65 - - -
style 2 0 25 - - -
style 2 25 2 #7c9cff - -
style 2 27 7 - - -
style 2 34 4 #7c9cff - -
style 2 38 62 - - -
style 3 0 24 - - -
style 3 24 1 #7c9cff - -
style 3 25 75 - - -
style 4 0 22 - - -
style 4 22 2 #7c9cff - -
style 4 24 76 - - -
style 5 0 8 - - -
style 5 8 5 #7c9cff - -
style 5 13 8 - - -
style 5 21 2 #7c9cff - -
style 5 23 77 - - -
style 6 0 6 - - -
style 6 6 2 #7c9cff - -
style 6 8 5 - - -
style 6 13 4 #7c9cff - -
style 6 17 3 - - -
style 6 20 2 #7c9cff - -
style 6 22 78 - - -
style 7 0 4 - - -
style 7 4 2 #7c9cff - -
style 7 6 11 - - -
style 7 17 3 #7c9cff - -
style 7 20 80 - - -
style 8 0 2 - - -
style 8 2 3 #7c9cff - -
style 8 5 95 - - -
style 9 0 3 #7c9cff - -
style 9 3 97 - - -
style 10 0 100 - - -
style 11 0 23 - - -
style 11 23 7 - #7c9cff -
style 11 30 70 - - -
style 12 0 23 - - -
style 12 23 7 - #7c9cff -
style 12 30 70 - - -
style 13 0 23 - - -
style 13 23 15 - #7c9cff -
style 13 38 62 - - -
style 14 0 8 - - -
style 14 8 7 - #7c9cff -
style 14 15 8 - - -
style 14 23 15 - #7c9cff -
style 14 38 62 - - -
style 15 0 8 - - -
style 15 8 7 - #7c9cff -
style 15 15 8 - - -
style 15 23 15 - #7c9cff -
style 15 38 62 - - -
style 16 0 8 - - -
style 16 8 30 - #7c9cff -
style 16 38 62 - - -
style 17 0 38 - #7c9cff -
style 17 38 62 - - -
style 18 0 38 - #7c9cff -
style 18 38 62 - - -
style 19 0 38 - #7c9cff -
style 19 38 62 - - -
style 20 0 38 - #7c9cff -
style 20 38 62 - - -
style 21 0 2 - #7c9cff -
style 21 2 98 - - -
style 22 0 2 - #7c9cff -
style 22 2 98 - - -
style 23 0 2 - #7c9cff -
style 23 2 98 - - -
style 24 0 2 - #7c9cff -
style 24 2 98 - - -
style 25 0 2 - #7c9cff -
style 25 2 98 - - -
style 26 0 100 - - -
style 27 0 100 - - -
style 28 0 100 - - -
style 29 0 100 - - -
style 30 0 100 - - -
style 31 0 100 - - -
style 32 0 100 - - -

View file

@ -1,7 +1,5 @@
surface thing:surface:provider.viewport.embed-viewport 100x37
before after
before after
@ -36,13 +34,13 @@ surface thing:surface:provider.viewport.embed-viewport 100x37
style 0 0 100 - - -
style 0 0 6 #eeeef4 - -
style 0 6 89 - - -
style 0 95 5 #eeeef4 - -
style 1 0 100 - - -
style 2 0 2 - - -
style 2 2 6 #eeeef4 - -
style 2 8 85 - - -
style 2 93 5 #eeeef4 - -
style 2 98 2 - - -
style 2 0 100 - - -
style 3 0 100 - - -
style 4 0 100 - - -
style 5 0 100 - - -
@ -77,4 +75,4 @@ style 33 0 100 - - -
style 34 0 100 - - -
style 35 0 100 - - -
style 36 0 100 - - -
embed 31 2 40 10 "viewport.world" "main"
embed 31 0 40 11 "viewport.world" "main"

View file

@ -1,7 +1,14 @@
surface thing:surface:provider.stack.stack 100x37
Load
Load
Card
[Open ]
Card
[Open ]
nested
@ -17,16 +24,6 @@ surface thing:surface:provider.stack.stack 100x37
Card
[Open ]
@ -36,18 +33,35 @@ surface thing:surface:provider.stack.stack 100x37
style 0 0 100 - - -
style 0 0 4 #ff00ff - -
style 0 4 96 - - -
style 1 0 100 - - -
style 2 0 2 - - -
style 2 2 4 #ff00ff - -
style 2 6 94 - - -
style 3 0 100 - - -
style 2 0 100 - - -
style 3 0 1 - - -
style 3 1 4 #ffffff - -
style 3 5 95 - - -
style 4 0 100 - - -
style 5 0 100 - - -
style 6 0 100 - - -
style 5 0 1 - - -
style 5 1 1 #4a4a60 #2c2c3e -
style 5 2 4 #eeeef4 #2c2c3e -
style 5 6 93 - #2c2c3e -
style 5 99 1 #4a4a60 #2c2c3e -
style 6 0 1 - - -
style 6 1 4 #ffffff - -
style 6 5 95 - - -
style 7 0 100 - - -
style 8 0 100 - - -
style 9 0 100 - - -
style 8 0 1 - - -
style 8 1 1 #4a4a60 #2c2c3e -
style 8 2 4 #eeeef4 #2c2c3e -
style 8 6 92 - #2c2c3e -
style 8 98 1 #4a4a60 #2c2c3e -
style 8 99 1 - - -
style 9 0 1 - - -
style 9 1 6 #eeeef4 - -
style 9 7 93 - - -
style 10 0 100 - - -
style 11 0 100 - - -
style 12 0 100 - - -
@ -56,9 +70,7 @@ style 14 0 100 - - -
style 15 0 100 - - -
style 16 0 100 - - -
style 17 0 100 - - -
style 18 0 4 - - -
style 18 4 4 #ffffff - -
style 18 8 92 - - -
style 18 0 100 - - -
style 19 0 100 - - -
style 20 0 100 - - -
style 21 0 100 - - -
@ -67,12 +79,7 @@ style 23 0 100 - - -
style 24 0 100 - - -
style 25 0 100 - - -
style 26 0 100 - - -
style 27 0 4 - - -
style 27 4 1 #4a4a60 #2c2c3e -
style 27 5 4 #eeeef4 #2c2c3e -
style 27 9 86 - #2c2c3e -
style 27 95 1 #4a4a60 #2c2c3e -
style 27 96 4 - - -
style 27 0 100 - - -
style 28 0 100 - - -
style 29 0 100 - - -
style 30 0 100 - - -

View file

@ -1,8 +1,6 @@
surface thing:surface:provider.hostile.duplicate-id refused DuplicateNodeId
surface thing:surface:provider.hostile.schema-mismatch 100x37
[ ]
[ ]
@ -37,13 +35,13 @@ surface thing:surface:provider.hostile.schema-mismatch 100x37
style 0 0 100 - - -
style 0 0 1 #e5484d - -
style 0 1 98 - - -
style 0 99 1 #e5484d - -
style 1 0 100 - - -
style 2 0 2 - - -
style 2 2 1 #e5484d - -
style 2 3 94 - - -
style 2 97 1 #e5484d - -
style 2 98 2 - - -
style 2 0 100 - - -
style 3 0 100 - - -
style 4 0 100 - - -
style 5 0 100 - - -
@ -80,9 +78,7 @@ style 35 0 100 - - -
style 36 0 100 - - -
surface thing:surface:provider.hostile.undeclared-command refused UndeclaredCommand
surface thing:surface:provider.hostile.unresolved-use 100x37
[ ]
[ ]
@ -117,13 +113,13 @@ surface thing:surface:provider.hostile.unresolved-use 100x37
style 0 0 100 - - -
style 0 0 1 #e5484d #6e6e80 -
style 0 1 98 - #6e6e80 -
style 0 99 1 #e5484d #6e6e80 -
style 1 0 100 - - -
style 2 0 2 - - -
style 2 2 1 #e5484d #6e6e80 -
style 2 3 94 - #6e6e80 -
style 2 97 1 #e5484d #6e6e80 -
style 2 98 2 - - -
style 2 0 100 - - -
style 3 0 100 - - -
style 4 0 100 - - -
style 5 0 100 - - -

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,18 @@
surface thing:surface:provider.text.text-edge 100x37
Hello שלום עולם and مرحبا بالعالم then 123 end.
日本語テスト 你好世界 한국어 ABC123
é ä ñ ộ z͛͏̀
Hello שלום עולם and مرحبا بالعالم then 123 end.
👩‍👩‍👧‍👦 👨🏽‍💻 🏳️‍🌈
The quick brown fox jumps over the lazy dog while the evening light slides across the valley, and
the long paragraph keeps going so that any reasonable column must break it across several lines. The
quick brown fox jumps over the lazy dog while the evening light slides across the valley, and the
long paragraph keeps going so that any reasonable column must break it across several lines. The
quick brown fox jumps over the lazy dog while the evening light slides across the valley, and the
long paragraph keeps going so that any reasonable column must break it across several lines. The
quick brown fox jumps over the lazy dog while the evening light slides across the valley, and the
long paragraph keeps going so that any reasonable column must break it across several lines.
@ -10,7 +21,6 @@ surface thing:surface:provider.text.text-edge 100x37
日本語テスト 你好世界 한국어 ABC123
@ -19,7 +29,6 @@ surface thing:surface:provider.text.text-edge 100x37
é ä ñ ộ z͛͏̀
@ -27,42 +36,38 @@ surface thing:surface:provider.text.text-edge 100x37
👩‍👩‍👧‍👦 👨🏽‍💻 🏳️‍🌈
style 0 0 100 - - -
style 0 0 47 #eeeef4 - -
style 0 47 53 - - -
style 1 0 100 - - -
style 2 0 2 - - -
style 2 2 47 #eeeef4 - -
style 2 49 51 - - -
style 3 0 100 - - -
style 2 0 41 #eeeef4 - -
style 2 41 59 - - -
style 3 0 9 #eeeef4 - -
style 3 9 91 - - -
style 4 0 100 - - -
style 5 0 100 - - -
style 6 0 100 - - -
style 7 0 100 - - -
style 8 0 100 - - -
style 9 0 100 - - -
style 10 0 100 - - -
style 11 0 2 - - -
style 11 2 41 #eeeef4 - -
style 11 43 57 - - -
style 12 0 100 - - -
style 13 0 100 - - -
style 5 0 8 #eeeef4 - -
style 5 8 92 - - -
style 6 0 97 #eeeef4 - -
style 6 97 3 - - -
style 7 0 100 #eeeef4 - -
style 8 0 97 #eeeef4 - -
style 8 97 3 - - -
style 9 0 96 #eeeef4 - -
style 9 96 4 - - -
style 10 0 97 #eeeef4 - -
style 10 97 3 - - -
style 11 0 96 #eeeef4 - -
style 11 96 4 - - -
style 12 0 97 #eeeef4 - -
style 12 97 3 - - -
style 13 0 93 #eeeef4 - -
style 13 93 7 - - -
style 14 0 100 - - -
style 15 0 100 - - -
style 16 0 100 - - -
style 17 0 100 - - -
style 18 0 100 - - -
style 19 0 100 - - -
style 20 0 2 - - -
style 20 2 9 #eeeef4 - -
style 20 11 89 - - -
style 20 0 100 - - -
style 21 0 100 - - -
style 22 0 100 - - -
style 23 0 100 - - -
@ -71,9 +76,7 @@ style 25 0 100 - - -
style 26 0 100 - - -
style 27 0 100 - - -
style 28 0 100 - - -
style 29 0 2 - - -
style 29 2 8 #eeeef4 - -
style 29 10 90 - - -
style 29 0 100 - - -
style 30 0 100 - - -
style 31 0 100 - - -
style 32 0 100 - - -

View file

@ -1,5 +1,7 @@
//! Screen goldens: every fixture through resolve, bind, layout and render in Cells, painted onto a
//! 100x37 screen. The composition is test-only: the shipped crate composes nothing.
//! Screen goldens: every fixture, unedited, through resolve, bind, layout and render in Cells,
//! painted onto a 100x37 screen. A Px length of a fixture is a Px length in Cells too: it converts
//! at the cell metric (ruling cells-px-metric). The composition is test-only: the shipped crate
//! composes nothing.
//! `THING_BLESS=1` rewrites the goldens through the testkit's one door.
mod common;
@ -7,7 +9,7 @@ mod common;
use std::path::PathBuf;
use common::well_formed;
use thing_contract::{Border, ColorRef, Dimension, Edges, Node, Rgba, SurfaceDocument};
use thing_contract::SurfaceDocument;
use thing_core::bind::Binder;
use thing_core::diagnostic::Code;
use thing_core::layout::{LayoutFrame, Metrics, layout};
@ -16,7 +18,6 @@ use thing_core::render::{RenderInput, ScrollOffsets, render};
use thing_core::resolve::{Limits, resolve};
use thing_core::text::CellMeasure;
use thing_core::theme::Theme;
use thing_testkit::build::{px, size2};
use thing_testkit::fixture::Fixture;
use thing_testkit::golden;
use thing_testkit::mem_state::MemState;
@ -30,35 +31,6 @@ fn golden_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/goldens")
}
/// Three fixtures carry pixel sizes, which in Cells are numbers of cells: f03's 640x360 board and
/// f08's 320x180 viewport lie far off a 100x37 screen, and f11's chain of Boxes has no paint, so
/// it draws nothing in any mode. Each is cut down (or its boxes outlined) so that its Image,
/// Embed or boxes show on screen; every other fixture runs as authored.
fn as_cells(fixture: Fixture, node: &mut Node, depth: usize) {
match node {
Node::Box(b) => {
match fixture {
Fixture::F03InputTarget if b.common.id.as_str() == "root" => b.style.size = size2(px(60.0), px(20.0)),
Fixture::F03InputTarget if b.common.id.as_str() == "target" => {
b.style.inset = Edges { left: px(20.0), top: px(6.0), right: Dimension::Auto, bottom: Dimension::Auto };
b.style.size = size2(px(12.0), px(3.0));
}
Fixture::F11Deep => {
let shade = (depth * 12 % 120) as u8;
let color = ColorRef::Rgba(Rgba { r: 80 + shade, g: 160, b: 255 - shade, a: 255 });
b.paint.border = Some(Border { color, width: 1.0 });
}
_ => {}
}
for child in &mut b.children {
as_cells(fixture, child, depth + 1);
}
}
Node::Embed(e) if fixture == Fixture::F08EmbedViewport => (e.width, e.height) = (40.0, 10.0),
_ => {}
}
}
fn screen_of(state: &mut MemState, document: &SurfaceDocument) -> Result<(Screen, Painted), Code> {
let limits = Limits::default();
let resolution = resolve(document, state, &limits);
@ -89,9 +61,7 @@ fn golden_text(fixture: Fixture) -> String {
state::script(fixture, &mut state);
let mut out = String::new();
for document in &set.surfaces {
let mut document = document.clone();
as_cells(fixture, &mut document.root, 0);
match screen_of(&mut state, &document) {
match screen_of(&mut state, document) {
Ok((screen, painted)) => {
well_formed(&screen);
out += &format!("surface {} {COLS}x{ROWS}\n{}", document.record_key(), screen.dump());
@ -112,12 +82,12 @@ fn goldens() {
}
}
/// The substitutes the table promises show up on the screens that carry them.
/// The substitutes the table promises show up on the screens that carry them. f11 is a chain of
/// Boxes with no paint, so it draws nothing in any mode: its nesting is a layout fact, not a screen one.
#[test]
fn image_embed_and_deep_boxes_are_on_screen() {
fn image_and_embed_are_on_screen() {
let glyphs = |fixture| golden_text(fixture).lines().take(ROWS + 1).collect::<String>();
let f03 = glyphs(Fixture::F03InputTarget);
assert!(f03.contains('\u{2591}') && f03.contains("The board"), "f03 draws its Image as a shaded block with its alt");
assert!(golden_text(Fixture::F08EmbedViewport).contains("\nembed "), "f08 reports its Embed to the host");
assert!(glyphs(Fixture::F11Deep).matches('\u{250c}').count() >= 10, "f11 shows its nested boxes");
}