Thing 2.0 cut 6b: fit table runs in a clipping row; drop an unused import

This commit is contained in:
Meta Vens 2026-11-28 08:07:39 +01:00
commit e7f84b22eb
3 changed files with 7 additions and 5 deletions

View file

@ -19,7 +19,7 @@ pub use scroll::{ScrollOffsets, clamp};
use crate::bind::{Bound, BoundTree, Field};
use crate::diagnostic::{Code, Diagnostic};
use crate::layout::{LaidTree, MAX_DEVICE, Measure, Metrics, Rect, TextRequest};
use crate::layout::{LaidTree, MAX_DEVICE, Measure, Metrics, Rect};
use crate::resolve::grow;
use crate::theme::{Theme, fallback};

View file

@ -115,7 +115,7 @@ impl Painter<'_> {
}
PlotMark::Line | PlotMark::Area => {
let mut run: Vec<(f32, f32)> = Vec::new();
let mut flush = |run: &mut Vec<(f32, f32)>, shapes: &mut Vec<RenderCommand>| {
let flush = |run: &mut Vec<(f32, f32)>, shapes: &mut Vec<RenderCommand>| {
if run.len() >= 2 {
let mut points = std::mem::take(run);
if n.mark == PlotMark::Area {

View file

@ -804,10 +804,12 @@ fn fit_table() {
let run = |asset: &str, fit: ImageFit| {
let mut state = MemState::new();
state.put(&provider, &catalog(&[("wide", 400, 200), ("tall", 100, 400)]));
// A 100x100 row: the image is squeezed to the row's height and width, so its rect is not its ratio.
let rendered = with_state(&mut state, flat("root", sized(100.0, 100.0), vec![image("pic", asset, fit)]), &pixels(1.0));
// A clipping 100x100 row squeezes the image to its height and width, so its rect is not its ratio.
let row = BoxStyle { overflow: Overflow::Clip, ..sized(100.0, 100.0) };
let rendered = with_state(&mut state, flat("root", row, vec![image("pic", asset, fit)]), &pixels(1.0));
assert_eq!(placed(&rendered, "pic").rect, rect(0.0, 0.0, 100.0, 100.0), "the image fills the row");
rendered.commands
let all = rendered.commands;
all[1..all.len() - 1].to_vec()
};
let img = |r: Rect, uri: &str| RenderCommand::Image { rect: r, uri: format!("asset://{uri}"), alt: "alt".into() };
let clip = |inner: Vec<RenderCommand>| {