Merge branch 'red/f3' into fw/mac1

This commit is contained in:
aiongg
2026-11-17 05:25:10 +00:00
7 changed files with 69 additions and 16 deletions
+4
View File
@@ -175,6 +175,10 @@ where
SelectToolPass::new(&mut *self.tool.borrow_mut(), &self.probe).claims()
}
fn takes_every_move(&self) -> bool {
SelectToolPass::new(&mut *self.tool.borrow_mut(), &self.probe).takes_every_move()
}
fn access(&self, cx: &ToolContext<'_>) -> Option<ToolAccess> {
SelectToolPass::new(&mut *self.tool.borrow_mut(), &self.probe).access(cx)
}
@@ -3,7 +3,7 @@
use crate::contract::{
BodyCx, Common, Component, Container, ContainerProps, Cx, FooterPlace, HeaderRegion, NoValue, Outcome, Pad, Props as _, Role, RowAlign, Scroll,
Show as _, ShowContainer as _, Sizing, WordSetCx as _,
Show as _, ShowContainer as _, Sizing, WordSetCx as _, WrapWidth,
};
use crate::layout_components::Row;
use crate::runtime::focus::FocusPolicy;
@@ -99,7 +99,8 @@ impl Outcome for FullWindowSideOutput {
/// [`headerless`](Self::headerless); the body padded by the panel tier.
/// - **Body.** Scrolls vertically when taller than the room; [`unscrolled`](Self::unscrolled) leaves the scroll out
/// for a pane that bounds itself.
/// - **Size.** As wide as its content; as high as its content, at most the room of the side columns.
/// - **Size.** As wide as its content; as high as its content, at most the room of the side columns. Its paragraphs
/// (a message, a failure) wrap at a dialog's line length, so a long one does not widen the column past it.
/// - **Footer.** None of its own: the dialog's buttons sit in the dialog's footer, which [`SideFooter`] places among
/// the side columns.
/// - **Keyboard and AccessKit.** A group named by the label, an F6 pane; Tab goes top to bottom.
@@ -121,6 +122,7 @@ impl FullWindowSide {
.surface(SurfaceKind::Panel)
.pad(Pad::Regular)
.sizing(Sizing::Content)
.wrap_width(WrapWidth::Dialog)
.header(HeaderRegion::new().rule(true))
.scroll(Scroll::vertical())
.focus(FocusPolicy::PANE);
@@ -126,10 +126,13 @@ impl BodyHooks<'_> {
if scroll.is_some() || props.scroll_owner {
scoped.scroll_owner = Some(ScrollOwner { id, view: scroll.is_none() });
}
match scroll {
Some(scroll) => scoped.unbounded = (scroll.horizontal_on(), scroll.vertical_on()),
// A container that sized an axis itself (a rect it was shown at, a fixed layer) bounds the room along it.
None => scoped.unbounded = (scoped.unbounded.0 && !self.room.x.is_finite(), scoped.unbounded.1 && !self.room.y.is_finite()),
}
// A container that sized an axis itself (a rect it was shown at, a fixed layer) bounds the room along it; one
// measured in a room unbounded along an axis it does not scroll (a row's probe for its units' leasts) leaves
// that axis unbounded, so its children never take a width from an infinite rect.
let (x, y) = (scoped.unbounded.0 && !self.room.x.is_finite(), scoped.unbounded.1 && !self.room.y.is_finite());
scoped.unbounded = match scroll {
Some(scroll) => (scroll.horizontal_on() || x, scroll.vertical_on() || y),
None => (x, y),
};
}
}
+8 -6
View File
@@ -558,14 +558,16 @@ impl Component for Notice<'_> {
room.map_or(width, |room| width.min(room))
}
(NoticeLayout::Centred, None) => natural.min(cx.style.reading_width),
// A row notice takes the room it is given; an unbounded room (a column sized by its content) leaves it at
// its natural width.
(_, Some(room)) if room.is_finite() => room,
(_, _) => natural,
(_, Some(room)) => room,
// A row notice offered no room (a unit of a row, a column sized by its content) takes its line, at most
// the column's room: in a container that sets a line length, its paragraphs' wrap width.
(_, None) => cx.column_room().map_or(natural, |column| natural.min(column)),
};
if !width.is_finite() || cx.room.is_some_and(|room| !room.is_finite()) {
{
let test = std::thread::current().name().unwrap_or("?").rsplit("::").next().unwrap_or("?").to_owned();
eprintln!("DIAG {test}: notice measure room {:?} natural {natural} width {width}", cx.room);
if test.starts_with("an_erased_sampling") || test.starts_with("brush_strokes_change") {
eprintln!("DIAG {test}: notice measure room {:?} column {:?} natural {natural} width {width}", cx.room, cx.column_room());
}
}
Vec2::new(width, self.plan(cx, &texts, self.wrap_width(cx, width)).height)
}
+4 -3
View File
@@ -54,7 +54,8 @@ pub enum FaceKind {
/// and the chevron need, at least a field wide; a [fitted](SelectFace::fit) box is at most a field wide and has no
/// floor; a thumbnail alone takes only its own width. A host shows it as the look of one of its parts with
/// `ui.face(part, SelectFace::new(text))` over the field well it paints itself, and gives the box the width of its
/// widest text so the width does not change with the pick. A thumbnail goes before the text, or alone.
/// widest text so the width does not change with the pick. A thumbnail goes before the text, or alone. The face is
/// no node of its own: its text is the pick, which every host reports as its own node's value.
#[derive(crate::contract::Component, crate::contract::Props)]
#[component(sample = SelectFace::sample)]
pub struct SelectFace<'a> {
@@ -71,7 +72,7 @@ pub struct SelectFace<'a> {
#[prop(into)]
thumb_caption: Option<Label>,
/// Whether the text shows beside the thumbnail; `false` shows the thumbnail alone, as wide as the thumbnail and
/// the chevron need. The text is the face's accessible name either way.
/// the chevron need. The text stays the host's accessible value either way.
#[style_key]
#[prop]
name: bool,
@@ -135,7 +136,7 @@ impl<'a> SelectFace<'a> {
}
impl Component for SelectFace<'_> {
const ROLE: Role = Role::LABEL;
const ROLE: Role = Role::None;
const PARTS: bool = false;
const STOPS: bool = false;
const INPUT: craft_behavior::Input = craft_behavior::Input::Display;
+1
View File
@@ -11,3 +11,4 @@ mod rtl_scroll;
mod scroll_region;
mod shrink_order;
mod stack_header;
mod zero_width;
@@ -0,0 +1,40 @@
//! A row given no width lays its units out at zero, never in a NaN room. The row is short, so it probes its bodies for
//! their leasts in a room unbounded along x; a body there that scrolls vertically keeps that axis unbounded for what
//! it holds, so a centred row inside it and the stack in that row never take a width from an infinite rect.
use craft_ui::buttons::Button;
use craft_ui::contract::{Props as _, RowAlign, Scroll, Show as _, ShowContainer as _};
use craft_ui::layout_components::{Row, Stack};
use craft_ui::testing::{Fixture, trial};
use egui::{Rect, Vec2};
use std::cell::Cell;
use std::rc::Rc;
#[trial]
fn a_row_given_no_width_lays_out_its_stack_child_with_finite_rects() {
// The stack's rect from the last real run.
let seen = Rc::new(Cell::new(Rect::NOTHING));
let out = Rc::clone(&seen);
let mut fixture = Fixture::new(move |ui| {
let out = Rc::clone(&out);
ui.allocate_ui(Vec2::new(0.0, 300.0), move |ui| {
Row::new().fill().show(ui, |ui, _| {
Stack::new().scroll(Scroll::vertical()).show(ui, |ui, _| {
Row::new().fill_width().align(RowAlign::Center).show(ui, |ui, _| {
let stack = Stack::new().show(ui, |ui, _| {
Button::new("Tool").show(ui);
});
if !ui.is_sizing_pass() {
out.set(stack.output.rect);
}
});
});
Button::new("Canvas").show(ui);
});
});
});
fixture.room(Vec2::new(400.0, 300.0)).settle();
let rect = seen.get();
assert!(rect != Rect::NOTHING, "the stack showed");
assert!(rect.min.is_finite() && rect.max.is_finite(), "the stack's rect is finite: {rect:?}");
}