land fw-contract: resolve the ui-contract conflicts of the craft-libs next sync

- body/hooks: upstream's step split (header/end/label/body steps, MeasurePlan) with the
  port's least-width floor (MeasurePlan.pad, measured_took), body_end hook in run_body,
  exiting end regions and content_width() label room
- cx/body: RegionShare constructor; the port's with_exiting kept
- layout/body: upstream's per-layout functions; run_row keeps the wrapping row's paragraph measure
- access/scope+emit, steps/report: the port's held/leave label scope (arranged rows) with
  upstream's rule that static texts are no label controls; node check before node facts,
  note_command and pass_through kept
- icon, ghost, icon_trials: theme icon packs (no IconSpec.set) with IconMark and layered paint;
  pointer art stays in runtime::cursor; both icon trials kept
- env/tokens: UiTokens::of_theme with the app's pins
- focus, cx/focus, keys/input: register_menu_bar(id, by_claim) journalled for replay
- commands/board+mod: maps for modal and page roots; port exports kept
- inspect, run, text, items/hooks, viewport, layout/mod, host_key_trials: both sides kept

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Martin Ball
2026-11-19 20:56:45 +00:00
co-authored by Claude Opus 5.5
parent 6dedbe4fe6
commit e6e78aebd6
22 changed files with 116 additions and 759 deletions
+45 -315
View File
@@ -313,7 +313,7 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
Err(extent) => return extent,
};
let plan = self.measure_plan(at, cx.core.id, scrolled_share);
let vertical = plan.vertical;
let (vertical, pad) = (plan.vertical, plan.pad);
let took = match plan.reused {
Some(reused) => self.take_reused(at, plan, reused),
// A share of a scrolling view is laid out as given while the content fits it, so the children that fill
@@ -326,20 +326,7 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
None if self.capped(&self.props, at.env, at.at) => self.measure_capped(comp, at, cx, plan),
None => self.measure_run(comp, at, cx, plan.key, None),
};
<<<<<<< HEAD
// A layer hung from an opener or a rect is at least as wide as its overlay asks for, in the measuring run too,
// so the rows of a content-sized list inside it are placed at that width.
let took = Vec2::new(overlay_of(&props).map_or(took.x, |overlay| took.x.max(crate::contract::overlay::anchor_floor(overlay))), took.y);
// The least width holds in the measure a parent places it by, as in its own extent (`wanted_width`): a row
// measuring a side menu among its children gave it only its content's width, so the menu shrank to its widest
// row's name.
let took = Vec2::new(took.x.max(self.least_width + pad.x), took.y);
self.overflow = (took.x - self.room.x).max(0.0);
// A body wider than the room overflows it, or scrolls along it; either way the container keeps to the room.
Vec2::new(took.x.min(self.room.x), if vertical { took.y.min(self.room.y) } else { took.y })
=======
self.measured_took(took, vertical)
>>>>>>> up/next
self.measured_took(took, pad, vertical)
}
/// A real pass places the container by what its measuring run in this pass found: the record a measuring run of
@@ -591,308 +578,21 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
// The body is measured in the line the real run gives it: what the header and the end region leave. The
// measuring run places it once both have measured, so its end region runs first (its content never depends
// on the body); the real run places it from what they took and keeps reading order.
<<<<<<< HEAD
if !real && is_open && props.end.is_some() {
let mut end_cx = BodyCx::new(body_id, line_env.view(), resolved, regions.end, &mut *cx.core.memory, &mut open, gate.as_mut())
.with_field_message(field_message.clone())
.with_owner(owner)
.with_exiting(self.exiting);
close = close.or(self.end_region(comp, ui, &mut end_cx, &end_frame, &props, regions.end, None));
=======
if !plan.real && plan.is_open && props.end.is_some() {
self.end_step(comp, ui, cx, &mut plan);
>>>>>>> up/next
}
// A footer the body places is measured before the body, as the end region is.
if footer_in_body(&props) {
self.footer_slot_step(comp, ui, cx, &mut plan);
}
// B2 label: the control gets the rect the label leaves; the label column adds to the container's extent.
<<<<<<< HEAD
let mut body_rect = regions.body;
let mut label_rect = Rect::NOTHING;
let mut label_input = None;
let mut caption = 0.0;
if let Some(side) = props.label.as_ref() {
let resolved = cx.core.resolved;
let input = LabelIn {
scope: id,
owner: id,
parent: node.then_some(id),
row: regions.body,
room: if self.sizing(&props).content_width() {
layout::ambient_room(&ctx).map_or(room.x, |offered| room.x.max(offered))
} else {
regions.body.width()
},
content_row: false,
text: resolved.label_value,
side,
help: props.help.as_ref(),
enabled: resolved.enabled,
size: resolved.size,
control_min: scope::measured_control_min(&ctx, id),
leaf: false,
in_column: self.in_column,
claims: false,
status: props.footer.is_some_and(|footer| footer.status),
trailing: Vec2::ZERO,
};
let placed = label::run(ui, env, &input, None);
(body_rect, label_rect, caption) = (placed.control, placed.label, placed.caption);
label_input = Some(input);
}
// Where the body runs; a measuring run may move it once the control reported its minimum width.
let ran_top = body_rect.min.y;
let label_extra = label_extra_of(regions.body, body_rect, label_rect, rtl);
// The body's control shows an inside label in its slot, in the measuring run and the real run alike.
let inside = props.label.as_ref().and_then(|side| label::inside(env.view(), side, cx.core.resolved.enabled));
// In an inspector the control beside its label fills the width the label leaves.
let cell_fills = props.label.as_ref().is_some_and(|side| side.layout == label::FieldLayout::Beside)
&& env.values.get::<label::LabelScheme>() == label::LabelScheme::Inspector;
let body_env = line_env.derive_local(|scoped| {
let label_width = label_extra.x;
self.scope_body(scoped, &props, id, BodyScope { room, real, content_column, scroll, label_width, beside: regions.beside });
scoped.inside_label = inside.map(|inside| inside as crate::runtime::env::Held);
scoped.cell_fills = cell_fills;
// A scrolling body shows its first child wherever the view is: the container has no first line there.
scoped.first_line = (!real && scroll.is_none()).then_some(first_body);
});
// B3 body, if open, under the body env; the gate is read after the header changed it.
if is_open {
let mut bcx = BodyCx::new(body_id, body_env.view(), resolved, body_rect, &mut *cx.core.memory, &mut open, gate.as_mut())
.with_field_message(field_message.clone())
.with_owner(owner);
// While the body opens or closes, it shows only the part of its last height that the presence reaches.
let reveal_clip = (animated && self.presence.t < 1.0).then(|| {
Rect::from_min_max(
body_rect.min,
Pos2::new(body_rect.max.x, body_rect.min.y + self.measured_body.map_or(0.0, |size| size.y) * self.presence.t),
)
});
let wide = self.wide();
let columns = LabelColumns::of(&props, !wide && !self.held(&props, env));
let (layout, body) = (&props.layout, &mut *self.body);
// The room a scrolling body's bars take under or beside its content this run: no part of the line.
let mut bars_inset = Vec2::ZERO;
// The body-end hook runs in the body's own column below its layout and scroll region, outside the shared label
// columns, so it lies under the body and above the footer in every footer place: beside an `EndTop` footer
// column too.
let mut run = |parent: &mut Ui, at: Rect, bcx: &mut BodyCx<'_>| -> Option<Vec2> {
let mut body_ui = alloc::child(parent, {
let builder = UiBuilder::new().max_rect(at).layout(child::column_layout(rtl)).scope_id(body_id);
if node { access::with_parent(builder, id) } else { builder }
});
style::set_item_spacing(&mut body_ui, gap);
if let Some(clip) = reveal_clip {
body_ui.set_clip_rect(clip.intersect(body_ui.clip_rect()));
}
let installed = Env::install_for(&body_ui, body_env.clone());
let mut labels = LabelsFound::default();
// The size the body took: a scrolling body takes the visible part of its content, since its region
// is a child that allocates nothing in `body_ui`.
let took = match scroll {
Some(scroll) => {
let off = self.offset;
let big = crate::contract::MAX_EXTENT;
let bar = scroll_bar_look(&body_env.tokens).thickness;
let last = Vec2::new(self.last_extent.0, self.last_extent.1);
let inset = overflow_inset(scroll, last, at.size(), bar);
let shows = view_within(scroll, last, at, self.strip);
let seen = Rect::from_min_max(
Pos2::new(if rtl { shows.min.x + inset.x } else { shows.min.x }, shows.min.y),
Pos2::new(if rtl { shows.max.x } else { shows.max.x - inset.x }, shows.max.y - inset.y),
);
let (width, height) =
(if scroll.horizontal_on() { big } else { seen.width() }, if scroll.vertical_on() { big } else { seen.height() });
let x = if scroll.horizontal_on() { off.x as f32 } else { 0.0 };
let min_x = if rtl { seen.max.x - width + x } else { seen.min.x - x };
let max = Rect::from_min_size(Pos2::new(min_x, seen.min.y - off.y as f32), Vec2::new(width, height));
let layout_of = *body_ui.layout();
let mut region_ui =
alloc::child(&mut body_ui, UiBuilder::new().scope_id(sub(id, "scroll_region")).layout(layout_of).max_rect(max));
region_ui.set_clip_rect(shows.intersect(body_ui.clip_rect()));
// The view this pass shows, where this run lays the content out.
let shown = self.view_offset;
let shift = Vec2::new(
if scroll.horizontal_on() { (shown.x - off.x) as f32 * if rtl { -1.0 } else { 1.0 } } else { 0.0 },
if scroll.vertical_on() { (shown.y - off.y) as f32 } else { 0.0 },
);
let view = crate::runtime::lazy::View {
owner: id,
rect: seen.translate(shift),
content: max,
axes: (scroll.horizontal_on(), scroll.vertical_on()),
rtl,
anchor: self.anchor.map(|anchor| anchor.child),
reveal: self.glide.map(|glide| glide.child),
};
// Only the run that lays the content out for the view places its children; a measure lays it
// out for its own question.
let lays_out = real && !crate::runtime::measure::active(&ctx);
if lays_out {
crate::runtime::lazy::begin(&ctx, id);
}
let view_env = body_env.derive_local(|scoped| scoped.lazy = Some(view));
let region_env = Env::install_for(&region_ui, view_env.clone());
layout::run_body_measured(&mut region_ui, &view_env, layout_id, layout, gap, line, |ui| {
shared_labels(ui, id, columns, room.x, self.settle.clone(), &mut labels, |ui| {
body(ui, bcx);
})
});
Env::restore(&ctx, region_env);
if lays_out {
crate::contract::run::close_bar_line(&ctx, id);
}
let extent = region_ui.min_rect().size();
if lays_out {
let placed = crate::runtime::lazy::placed(&ctx, id);
let keeps = !self.scroll_bound && !self.follows_end;
follow_anchor(
&ctx,
(&placed, scroll, keeps),
(extent, seen.size()),
(&mut self.offset, self.offset_at_read),
&mut self.anchor,
);
aim_glide(&mut self.glide, placed.reveal, shown, (extent, seen.size()), scroll);
if self.glide.is_some_and(|glide| glide.to != Some(Vec2::new(shown.x as f32, shown.y as f32))) {
repaint::request(&ctx);
}
}
if real {
crate::runtime::egui::widgets::note_scroll_region(&ctx, region_ui.clip_rect(), region_ui.min_rect().intersect(max));
}
self.extent = Some(extent);
// Along an axis it scrolls the body took what the view shows; along the other it took its content.
bars_inset = overflow_inset(scroll, extent, at.size(), bar);
// Strips take their height from the view: a body that overflows takes all of its room.
let strips = strips_of(scroll, extent, at, self.strip).map_or(0.0, |(back, forward)| back.height() + forward.height());
let took = extent + bars_inset + Vec2::new(0.0, strips);
Some(Vec2::new(
if scroll.horizontal_on() { took.x.min(at.width()) } else { took.x },
if scroll.vertical_on() { took.y.min(at.height()) } else { took.y },
))
}
// A row that places its block itself asks for its children's width, not the room it spans.
None => {
let (_, natural) = layout::run_body_measured(&mut body_ui, &body_env, layout_id, layout, gap, line, |ui| {
shared_labels(ui, id, columns, room.x, self.settle.clone(), &mut labels, |ui| {
body(ui, bcx);
})
});
natural.map(|width| Vec2::new(width, body_ui.min_rect().height()))
}
};
// A scrolling body's region allocates nothing in `body_ui`, so the hook starts below the part it shows.
if scroll.is_some() {
body_ui.allocate_space(Vec2::new(0.0, took.map_or(0.0, |size| size.y)));
}
let before = body_ui.min_rect().height();
comp.body_end(&mut body_ui, bcx);
let ended = body_ui.min_rect().height() - before;
let took = took.map(|size| Vec2::new(size.x, size.y + ended));
Env::restore(&ctx, installed);
let took = took.unwrap_or_else(|| body_ui.min_rect().size());
// A content-sized column of rows takes, in a measuring run, the width they take at its group's widest
// label: the rows measured before the widest one measured against a narrower column.
let stacked = matches!(layout, layout::BodyLayout::Stack) && !wide;
let took = match labels.extent.filter(|_| stacked && !real) {
Some(width) => Vec2::new(took.x.max(width), took.y),
None => took,
};
// A content-sized body hands its rows' reaches on to the group around once its measure is known.
if !real && !wide {
self.reached = labels.reached.map(|reached| (reached, !matches!(layout, layout::BodyLayout::Stack)));
}
if !real {
self.unsettled = labels.unsettled;
}
Some(took)
};
self.body_size = match props.transform {
// The measuring run lays the body out on the layer the real run shows it on.
Some(_) if !real => {
let builder = UiBuilder::new().layer_id(areas::body_layer(ui.layer_id(), id)).max_rect(body_rect);
run(&mut alloc::child(ui, builder), body_rect, &mut bcx)
}
Some(transform) => {
let parent = ui.layer_id();
let layer = areas::body_layer(parent, id);
let tf = areas::body_transform(body_rect.min, transform.scale, transform.offset);
if props.arena {
crate::primitives::sensing::set_layer(&ctx, ArenaId::new(id), layer);
}
let forward = areas::Forward { root: id, sense: response::to_egui(cx.core.root_sense), rect: rect.intersect(ui.clip_rect()) };
let body_layer = areas::BodyLayer {
parent,
layer,
transform: tf,
at: body_rect.min,
clip: body_rect.intersect(ui.clip_rect()),
forward: Some(forward),
};
areas::show_body_layer(&ctx, body_layer, |area_ui| run(area_ui, body_rect, &mut bcx))
}
None => run(ui, body_rect, &mut bcx),
};
close = close.or(bcx.close_requested());
// A measuring run decided the label before the control reported its minimum width: it decides again
// from the minimum this run recorded, so the extent it measures is the one the real run lays out.
let mut label_extra = label_extra;
if let (false, Some(input)) = (real, label_input.as_mut()) {
input.control_min = scope::open_control_min(&ctx, id);
// The footer starts under the control column this decision gives, not the one before the control
// reported its minimum.
let placed = label::control_after(ui, env, input);
(body_rect, label_rect, caption) = (placed.control, placed.label, placed.caption);
label_extra = label_extra_of(regions.body, body_rect, label_rect, rtl);
}
if let Some(size) = &mut self.body_size {
// A body beside its label in a content-sized column of rows reports how far it reaches past the label
// column, so that column's container measures its rows at the widest label.
let beside = |side: &&label::SideLabel| side.layout != label::FieldLayout::After && label_extra.x > 0.0 && label_extra.y <= 0.0;
if let (false, true, Some(side)) = (real, env.content.0, props.label.as_ref().filter(beside)) {
let column = if matches!(side.kind, label::LabelKind::Glyph(_)) { layout::GLYPHS } else { layout::LABELS };
layout::report_beyond(&ctx, std::slice::from_ref(&column), label::label_gap(env) + size.x);
}
*size += label_extra;
// A caption above the control counts whole toward the container's width, so a row never narrows the
// field below it.
size.x = size.x.max(caption);
if let (false, true, Some(side)) = (real, env.content.0, props.label.as_ref()) {
label::report_after_reach(&ctx, env, side, (regions.body, body_rect), size.x);
}
}
self.view = Some(body_rect);
if real && props.end.is_some() {
let mut end_cx = BodyCx::new(body_id, line_env.view(), resolved, regions.end, &mut *cx.core.memory, &mut open, gate.as_mut())
.with_field_message(field_message.clone())
.with_owner(owner)
.with_exiting(self.exiting);
// The end region shares the body's line, above a scroll bar under the body: its children sit on the
// members' line, from the body's top (a label may stand above the body).
let mut end = regions.end;
let mut line = None;
if !end_full_height(&props) {
end.max.y = (end.max.y - bars_inset.y).max(end.min.y);
let down = body_rect.min.y - end.min.y;
line = layout::members_line(&ctx, layout_id).map(|line| RowLine {
centre: line.centre.map(|centre| centre + down),
height: line.height.map(|height| height + down),
..line
});
}
close = close.or(self.end_region(comp, ui, &mut end_cx, &end_frame, &props, end, line));
=======
self.label_step(ui, env, cx, &mut plan);
// B3 body, if open, under the body env; the gate is read after the header changed it.
if plan.is_open {
self.body_step(ui, env, cx, &mut plan);
self.body_step(comp, ui, env, cx, &mut plan);
self.after_body(ui, env, &mut plan);
if plan.real && props.end.is_some() {
self.end_step(comp, ui, cx, &mut plan);
>>>>>>> up/next
}
} else {
// A collapsed body keeps its last full size in layout memory, so opening it again places by that size
@@ -1438,7 +1138,8 @@ impl BodyHooks<'_> {
&mut plan.open,
plan.gate.as_mut(),
Some(share),
);
)
.with_exiting(self.exiting);
// The end region shares the body's line, above a scroll bar under the body: its children sit on the
// members' line, from the body's top (a label may stand above the body).
let mut end = plan.regions.end;
@@ -1480,7 +1181,7 @@ impl BodyHooks<'_> {
owner: id,
parent: plan.node.then_some(id),
row: plan.regions.body,
room: if self.sizing(props) == Sizing::Content {
room: if self.sizing(props).content_width() {
layout::ambient_room(ctx).map_or(plan.room.x, |offered| plan.room.x.max(offered))
} else {
plan.regions.body.width()
@@ -1529,7 +1230,7 @@ impl BodyHooks<'_> {
/// B3: the body region, on the body layer when the container transforms its body.
#[expect(clippy::expect_used, reason = "the label step sets the body env before the body step")]
fn body_step<C: Container>(&mut self, ui: &mut Ui, env: &Env, cx: &mut Cx<'_, C>, plan: &mut BodyPlan<'_>) {
fn body_step<C: Container>(&mut self, comp: &mut C, ui: &mut Ui, env: &Env, cx: &mut Cx<'_, C>, plan: &mut BodyPlan<'_>) {
let props = plan.props;
let body_env = plan.body_env.as_ref().expect("the label step ran");
let reveal_clip = (plan.animated && self.presence.t < 1.0).then(|| {
@@ -1569,9 +1270,12 @@ impl BodyHooks<'_> {
Some(share),
);
let mut bars = Vec2::ZERO;
let mut end = |ui: &mut Ui, bcx: &mut BodyCx<'_>| comp.body_end(ui, bcx);
self.body_size = match props.transform {
Some(transform) => self.run_transformed(&run, ui, (transform, cx.core.root_sense, plan.rect, body_rect), &mut bcx, &mut bars),
None => self.run_body(&run, ui, body_rect, &mut bcx, &mut bars),
Some(transform) => {
self.run_transformed(&run, ui, (transform, cx.core.root_sense, plan.rect, body_rect), &mut bcx, &mut bars, &mut end)
}
None => self.run_body(&run, ui, body_rect, &mut bcx, &mut bars, &mut end),
};
plan.close = plan.close.or(bcx.close_requested());
plan.bars_inset = bars;
@@ -1586,9 +1290,10 @@ impl BodyHooks<'_> {
(transform, root_sense, rect, body_rect): (craft_behavior::CanvasTransform, craft_behavior::Sense, Rect, Rect),
bcx: &mut BodyCx<'_>,
bars: &mut Vec2,
end: &mut dyn FnMut(&mut Ui, &mut BodyCx<'_>),
) -> Option<Vec2> {
if !run.real {
return self.run_body(run, &mut measure_layer_ui(ui, run.id, body_rect), body_rect, bcx, bars);
return self.run_body(run, &mut measure_layer_ui(ui, run.id, body_rect), body_rect, bcx, bars, end);
}
let parent = ui.layer_id();
let layer = areas::body_layer(parent, run.id);
@@ -1599,12 +1304,20 @@ impl BodyHooks<'_> {
let forward = areas::Forward { root: run.id, sense: response::to_egui(root_sense), rect: rect.intersect(ui.clip_rect()) };
let body_layer =
areas::BodyLayer { parent, layer, transform: tf, at: body_rect.min, clip: body_rect.intersect(ui.clip_rect()), forward: Some(forward) };
areas::show_body_layer(run.ctx, body_layer, |area_ui| self.run_body(run, area_ui, body_rect, bcx, bars))
areas::show_body_layer(run.ctx, body_layer, |area_ui| self.run_body(run, area_ui, body_rect, bcx, bars, end))
}
/// The body region's run at `at` in `parent`: its `Ui`, its layout and the label columns its rows share. Returns
/// the size the body took.
fn run_body(&mut self, run: &BodyRun<'_>, parent: &mut Ui, at: Rect, bcx: &mut BodyCx<'_>, bars: &mut Vec2) -> Option<Vec2> {
/// The body region's run at `at` in `parent`: its `Ui`, its layout and the label columns its rows share, then the
/// body-end hook `end`. Returns the size the body took.
fn run_body(
&mut self,
run: &BodyRun<'_>,
parent: &mut Ui,
at: Rect,
bcx: &mut BodyCx<'_>,
bars: &mut Vec2,
end: &mut dyn FnMut(&mut Ui, &mut BodyCx<'_>),
) -> Option<Vec2> {
let mut body_ui = body_ui(run, parent, at);
let installed = Env::install_for(&body_ui, run.env.clone());
let mut labels = LabelsFound::default();
@@ -1621,6 +1334,17 @@ impl BodyHooks<'_> {
natural.map(|width| Vec2::new(width, body_ui.min_rect().height()))
}
};
// The body-end hook runs in the body's own column below its layout and scroll region, outside the shared label
// columns, so it lies under the body and above the footer in every footer place: beside an `EndTop` footer
// column too. A scrolling body's region allocates nothing in `body_ui`, so the hook starts below the part it
// shows.
if run.scroll.is_some() {
body_ui.allocate_space(Vec2::new(0.0, took.map_or(0.0, |size| size.y)));
}
let before = body_ui.min_rect().height();
end(&mut body_ui, bcx);
let ended = body_ui.min_rect().height() - before;
let took = took.map(|size| Vec2::new(size.x, size.y + ended));
Env::restore(run.ctx, installed);
let took = took.unwrap_or_else(|| body_ui.min_rect().size());
self.body_took(run, took, labels)
@@ -1935,6 +1659,8 @@ struct MeasurePlan {
/// The inputs the run's record is kept under.
key: MeasureKey,
tolerance: f32,
/// The container's padding on both sides, along each axis.
pad: Vec2,
/// The body scrolls vertically: it takes at most the room's height.
vertical: bool,
/// The body shares a scrolling view along y.
@@ -2046,7 +1772,7 @@ impl BodyHooks<'_> {
serves.then(|| self.reusable(&props, &ctx, id, pad, tolerance)).flatten().map(|took| (took, found))
})
.flatten();
MeasurePlan { ctx, id, key, tolerance, vertical, scrolled_share, reused }
MeasurePlan { ctx, id, key, tolerance, pad, vertical, scrolled_share, reused }
}
/// A record that serves: it stands for the run, and a kept one is noted under this run's inputs too.
@@ -2085,10 +1811,14 @@ impl BodyHooks<'_> {
}
/// The extent a measuring run reports from what its regions `took`.
fn measured_took(&mut self, took: Vec2, vertical: bool) -> Vec2 {
fn measured_took(&mut self, took: Vec2, pad: Vec2, vertical: bool) -> Vec2 {
// A layer hung from an opener or a rect is at least as wide as its overlay asks for, in the measuring run too,
// so the rows of a content-sized list inside it are placed at that width.
let took = Vec2::new(overlay_of(&self.props).map_or(took.x, |overlay| took.x.max(crate::contract::overlay::anchor_floor(overlay))), took.y);
// The least width holds in the measure a parent places it by, as in its own extent (`wanted_width`): a row
// measuring a side menu among its children gave it only its content's width, so the menu shrank to its widest
// row's name.
let took = Vec2::new(took.x.max(self.least_width + pad.x), took.y);
self.overflow = (took.x - self.room.x).max(0.0);
// A body wider than the room overflows it, or scrolls along it; either way the container keeps to the room.
Vec2::new(took.x.min(self.room.x), if vertical { took.y.min(self.room.y) } else { took.y })
+1 -18
View File
@@ -46,13 +46,9 @@ impl<'a> BodyCx<'a> {
shared: Option<RegionShare<'a>>,
) -> Self {
memory.claim(id);
<<<<<<< HEAD
BodyCx { id, env, resolved, rect, memory, open, gate, gate_mixed: false, close: None, exiting: false, field_message: None, owner: None }
=======
let (gate_mixed, field_message, owner) =
shared.map_or((false, None, None), |shared| (shared.gate_mixed, shared.field_message, Some(shared.owner)));
BodyCx { id, env, resolved, rect, memory, open, gate, gate_mixed, close: None, field_message, owner }
>>>>>>> up/next
BodyCx { id, env, resolved, rect, memory, open, gate, gate_mixed, close: None, exiting: false, field_message, owner }
}
/// Asks the platform to open `url`, in a new tab where the platform has tabs and `new_tab` is set: the opener
@@ -70,7 +66,6 @@ impl<'a> BodyCx<'a> {
self.env.host()?.files().take_answer(ticket)
}
<<<<<<< HEAD
pub(crate) fn with_exiting(mut self, exiting: bool) -> Self {
self.exiting = exiting;
self
@@ -82,18 +77,6 @@ impl<'a> BodyCx<'a> {
self.exiting
}
pub(crate) fn with_gate_mixed(mut self, mixed: bool) -> Self {
self.gate_mixed = mixed;
self
}
pub(crate) fn with_field_message(mut self, message: Option<(Message, craft_theme::variant::Tone)>) -> Self {
self.field_message = message;
self
}
=======
>>>>>>> up/next
/// The validity message of the first control in the container's label scope, recorded last frame, with the
/// tone it shows in: a container whose footer declares `FooterRegion::status` shows it as its status text. `None`
/// when the container has no label or no control reported one.
@@ -107,7 +107,6 @@ impl Focus for CxCore<'_> {
}
fn register_menu_bar(&mut self) {
<<<<<<< HEAD
focus::register_menu_bar(&self.ctx, self.id, false);
}
@@ -117,9 +116,6 @@ impl Focus for CxCore<'_> {
fn take_first_claimed(&mut self, chords: &[Chord]) -> Option<Chord> {
crate::runtime::keys::take_first_claimed(&self.ctx, self.id, chords)
=======
focus::register_menu_bar(&self.ctx, self.id);
>>>>>>> up/next
}
fn take_menu_keys(&mut self) -> Vec<MenuKey> {
+1 -66
View File
@@ -4,13 +4,7 @@
//! one. They come from the drag session's data and the cursor record; the layer takes no input. Value readouts beside
//! the pointer during a gesture paint here too, for the pass that asks.
<<<<<<< HEAD
use crate::primitives::{Draw, DrawEnv, PaintRecord, PaintShape, RuleKind, TextRun, outline};
=======
use crate::primitives::pointer_art::{self as pointers, Art};
use crate::primitives::{Draw, DrawEnv, Mirror, PaintRecord, PaintShape, RuleKind, Span, SvgIcon, TextRun, outline};
>>>>>>> up/next
use crate::primitives::{Draw, DrawEnv, PaintRecord, PaintShape, RuleKind, Span, TextRun, outline};
use crate::runtime::drag::{self, DragPreview, DropMark};
use crate::runtime::egui::areas;
use crate::runtime::env::{Env, EnvView, Label};
@@ -119,66 +113,7 @@ fn paint_pointer(ctx: &Context, env: &Env, painter: &egui::Painter) {
return;
}
}
<<<<<<< HEAD
cursor::pointer_art(env, &cursor, closed, false).paint(painter, at);
=======
pointer_art(env, &cursor, closed, false).paint(painter, at);
}
/// The art of `cursor`: the hand as a fist while `closed`; with `marks_only`, a brush tip's centre cross and badge
/// without its ring.
fn pointer_art(env: &Env, cursor: &craft_behavior::PaintedCursor, closed: bool, marks_only: bool) -> Art {
use craft_behavior::{PaintedCursor, PointerGlyph};
let overlay = &env.tokens.color.overlay;
let pen = pointers::Pen {
art: RefCell::new(Art::default()),
fill: crate::style::rgba_color(overlay.stroke),
halo: crate::style::rgba_color(overlay.halo),
thin: env.tokens.stroke.thin,
rtl: env.direction.is_rtl(),
};
let ink = crate::style::ink_color(&env.tokens, Ink::OnDark);
let edge = env.tokens.stroke.thin;
match cursor {
PaintedCursor::Outline { rings, centre, badge, .. } => {
if !marks_only {
pointers::outline(&pen, rings);
}
pointers::tip_marks(&pen, *centre || marks_only, *badge, pen.thin, pen.fill);
}
PaintedCursor::Circle { radius, centre, badge, .. } => {
if !marks_only {
pointers::circle(&pen, *radius, edge, ink);
}
pointers::tip_marks(&pen, *centre || marks_only, *badge, edge, ink);
}
PaintedCursor::Crosshair => pointers::crosshair(&pen, env.tokens.size.icon.sm, edge, ink),
PaintedCursor::Hand => pointers::hand(&pen, closed),
PaintedCursor::Zoom { out, .. } => pointers::zoom(&pen, *out),
PaintedCursor::Tool { icon, hotspot, badge, .. } => {
let side = env.tokens.size.icon.md;
let icon = SvgIcon::of(&env.tokens, env.direction, side, icon, Mirror::Auto);
pointers::tool(&pen, icon, *hotspot, *badge, side);
}
PaintedCursor::Badged { badge, .. } => pointers::badge_beside(&pen, *badge),
PaintedCursor::Turn { toward, .. } => pointers::turn(&pen, *toward),
PaintedCursor::Distort { dir, .. } => pointers::distort(&pen, *dir),
PaintedCursor::Skew { dir, .. } => pointers::skew(&pen, *dir),
PaintedCursor::TypeOn { path, .. } => pointers::type_on(&pen, *path),
PaintedCursor::Locator => pointers::locator(&pen),
PaintedCursor::Arrow { hollow, .. } => pointers::arrow(&pen, *hollow),
PaintedCursor::PathText { start, end, .. } => pointers::path_text(&pen, *start, *end),
PaintedCursor::PointerTool { pointer, icon, .. } => {
// The arrow's icon sits under its body, so it takes the larger size to show past the arrow.
let side = if *pointer == PointerGlyph::Arrow { env.tokens.size.icon.md } else { env.tokens.size.icon.sm };
let icon = SvgIcon::of(&env.tokens, env.direction, side, icon, Mirror::Auto);
pointers::pointer_tool(&pen, *pointer, icon, side, edge, ink);
}
// `Hidden` has no marks.
_ => {}
}
pen.art.into_inner()
>>>>>>> up/next
}
/// The drag preview, in `env`, the source's, and the drop mark of the running drag, with the payload's name in it.
@@ -185,12 +185,7 @@ impl<C: Collection> ShapeHooks<C> for ItemsHooks<'_, '_, C> {
let scx = &scx.measured_by(ui).owned_by(id, env.motion);
self.room = room;
self.indent_step = scx.control().icon;
<<<<<<< HEAD
let room = Self::inner_room(comp, &env.tokens, room);
=======
let env = Env::of(ui);
let room = Self::inner_room(comp, scx.tokens, room);
>>>>>>> up/next
// Where the enclosing body does not give the width, the collection takes its width from its content, whether
// it fills or fills the width, as a container does. Held in a content-sized column it measures so, and shows
// across the width the column settles on.
+1 -5
View File
@@ -1287,12 +1287,8 @@ fn report_steps(p: &mut Pass<'_, '_, '_>, ui: &mut Ui, env: &Env, h: &HostStep)
},
);
let shows_label = e.shows_label();
<<<<<<< HEAD
let tip_in = tooltip::TipIn { ui: &*ui, env, rich: p.tip.take(), parts: &parts.decls, shows_label, canvas_control: facts.canvas_control, message };
let tip_in = tooltip::TipIn { ui: &*ui, env, rich: p.tip.take(), parts: &h.decls, shows_label, canvas_control: facts.canvas_control, message };
tooltip::run(e.core_ref(), tip_in);
=======
tooltip::run(e.core_ref(), tooltip::TipIn { ui: &*ui, env, rich: p.tip.take(), parts: &h.decls, shows_label, message });
>>>>>>> up/next
// Activations accumulate across the passes of a viewport mount; step 17 fires the bound command once, with the
// injected source when there is one.
let natural = e.activated() && resolved.enabled;
+10 -33
View File
@@ -89,6 +89,9 @@ fn report_access(p: &dyn ErasedPass<'_>, facts: &TypeFacts, input: &ReportIn<'_>
debug_assert!(access.role.is_none_or(|alt| facts.alt_roles.contains(&alt)), "`Access::role` picks one of `ALT_ROLES`");
let flags = core.state.flags;
let resolved = core.resolved;
// Before any return: a component without an AccessKit node (merged, or AccessKit off) still records its command
// for the inspected region, which keytips place their badges by.
inspect::note_command(ctx, id, core.command.as_deref().map(|command| command.command.clone()));
let paint = core.paint.borrow();
if role == Role::Merged {
let facts = scope::Merged {
@@ -98,11 +101,18 @@ fn report_access(p: &dyn ErasedPass<'_>, facts: &TypeFacts, input: &ReportIn<'_>
enabled: resolved.enabled,
};
scope::finish(ctx, id, Some(facts));
scope::leave(ctx, id);
return;
}
scope::finish(ctx, id, None);
let carried = scope::carried_name(ctx, id);
// Step 8 created the node by the type's role; the role this pass reports may be none (`Access::role`). The node
// then stays only as the place of the children shown inside it, which assistive technology passes over: left
// unwritten it would be reported as a node of unknown role.
let Role::Node(role) = role else {
if input.node {
access::pass_through(ctx, id);
}
scope::leave(ctx, id);
return;
};
@@ -138,39 +148,6 @@ fn report_access(p: &dyn ErasedPass<'_>, facts: &TypeFacts, input: &ReportIn<'_>
access.position =
input.group.and_then(|group| focus::group_position(ctx, id, group)).or_else(|| core.env.facts_of(id).map(|facts| facts.position));
}
<<<<<<< HEAD
// Before any return: a component without an AccessKit node (merged, or AccessKit off) still records its command
// for the inspected region, which keytips place their badges by.
inspect::note_command(ctx, id, core.command.as_deref().map(|command| command.command.clone()));
let paint = core.paint.borrow();
if role == Role::Merged {
let facts = scope::Merged {
name: resolved.label.to_owned(),
description: access.description.clone().or_else(|| resolved.description.map(str::to_owned)).or_else(|| validity.clone()),
flags,
enabled: resolved.enabled,
};
scope::finish(ctx, id, Some(facts));
scope::leave(ctx, id);
return;
}
scope::finish(ctx, id, None);
let carried = scope::carried_name(ctx, id);
// Step 8 created the node by the type's role; the role this pass reports may be none (`Access::role`). The node
// then stays only as the place of the children shown inside it, which assistive technology passes over: left
// unwritten it would be reported as a node of unknown role.
let Role::Node(role) = role else {
if input.node {
access::pass_through(ctx, id);
}
scope::leave(ctx, id);
return;
};
if !input.node {
return;
}
=======
>>>>>>> up/next
let inner_of = access::fold::owner_of(ctx, id);
let folded = access::fold::take(ctx, id);
if access.value.is_none() {
+1 -5
View File
@@ -426,16 +426,12 @@ pub(crate) fn run<C: Component>(
let read_only = cx.core.resolved.read_only || !enabled;
let ink = decl.options.ink.map_or(ink, |own| crate::style::ink_color(&crate::runtime::env::Env::of(ui).tokens, own));
let ink = if enabled { ink } else { crate::style::rgba_color(crate::runtime::env::Env::of(ui).tokens.color.text.disabled) };
<<<<<<< HEAD
let held = cx.popup(EDIT_MENU).is_open_in(&mut cx.core);
let held = cx.popup(EDIT_MENU).is_open_in(cx.core);
// The bound caret is compared with the widget's before anything else this pass moves it (AccessKit, Select All,
// the typing): last pass reported the widget's caret, so only an app write differs here. A composition keeps its
// caret.
let caret_placed =
state.preedit.is_none() && adapter::place_caret(&ctx, widget, state.draft.as_deref().unwrap_or(&decl.shown), decl.options.caret);
=======
let held = cx.popup(EDIT_MENU).is_open_in(cx.core);
>>>>>>> up/next
serve_access(cx, &mut state, widget, &decl.shown, read_only);
if std::mem::take(&mut state.select_all) {
let len = state.draft.as_deref().unwrap_or(&decl.shown).chars().count();
+8 -107
View File
@@ -1602,118 +1602,11 @@ pub(crate) fn run_body_measured<R>(
// Each layout runs in its own function, so a body nested in bodies keeps only its own layout's frame on the stack.
let line = RowIn { id, gap, shared, sizing, rtl };
match layout {
<<<<<<< HEAD
BodyLayout::Stack => {
// Each leaf shows at most the stack's room, never below its least.
let env = env.derive_local(|scoped| scoped.shrink = Some(Shrink::Fit));
let installed = Env::install_for(ui, env.clone());
// A held child of a column whose own room is unbounded keeps the width it measured at.
let inner = if env.content_column && flow_room(ui).x.is_finite() {
run_column(ui, &env, id, child::column_layout(rtl), body)
} else {
run_sharing(ui, &env, id, Axis::Y, child::column_layout(rtl), body)
};
Env::restore(&ctx, installed);
(inner, None)
}
BodyLayout::Row { wrap: false, align: RowAlign::SpaceBetween } => {
let (inner, _) = child::block(ui, None, child::row_layout(rtl, false), |ui| {
let line = on_line(id, row_line(&ctx, sizing, id, shared), shared);
let installed = Env::install_for(
ui,
env.derive_local(|scoped| {
scoped.grid = Some(id);
scoped.row_line = Some(line);
scoped.first_line = None;
}),
);
let inner = run_spread(ui, id, gap.x, rtl, &mut body);
Env::restore(&ctx, installed);
record_line(ui, sizing, id, shared);
inner
});
inner
}
BodyLayout::Row { wrap: false, align: RowAlign::Start } => {
let room = ui.available_rect_before_wrap();
let line = on_line(id, row_line(&ctx, sizing, id, shared), shared);
let inner = run_sharing(ui, env, id, Axis::X, child::row_layout(rtl, false), |ui| {
let installed = Env::install_for(
ui,
Env::of(ui).derive_local(|scoped| {
scoped.row_room = Some(room.width());
scoped.row_line = Some(line);
scoped.first_line = None;
}),
);
let inner = run_shrinking(ui, id, &mut body);
Env::restore(&ctx, installed);
record_line(ui, sizing, id, shared);
inner
});
(inner, None)
}
BodyLayout::Row { wrap, align } => {
let room = ui.available_rect_before_wrap();
let rect = match *align {
// A wrapping row wraps at the line length its container sets for paragraphs (a dialog's), as the
// paragraphs beside it do: a dialog sized from its content stays as wide as its text, and a row of
// radios that would not fit there takes a second line instead of widening the dialog.
// A room unbounded at its end edge (a measuring run's) is cut from its start edge.
RowAlign::Start | RowAlign::SpaceBetween if *wrap => env
.measure
.filter(|measure| *measure < room.width() && (!rtl || room.right().is_finite()))
.map(|measure| Flow::new(room, rtl).span(0.0, measure)),
RowAlign::Start | RowAlign::SpaceBetween => None,
RowAlign::Center | RowAlign::End => {
let last = this_pass(&ctx, sizing, id);
// In a body that scrolls along x the band is the width its view shows, not the scroll region.
let band = if Env::of(ui).unbounded.0 { shrink_room(ui) } else { room.width() };
// Without a measuring run, or in a band without an end, the block is placed as `Start`.
last.filter(|last| band.is_finite() && last.x > 0.0 && last.x < band).map(|last| {
let spare = band - last.x;
let lead = if *align == RowAlign::Center { spare / 2.0 } else { spare };
Flow::new(room, rtl).take_start(lead).1.rect()
})
}
};
// A wrapped row has a line per wrap, so its children stay on the top of each, and its first child gives its
// first line.
let line = (!*wrap).then(|| on_line(id, row_line(&ctx, sizing, id, shared), shared));
// Where its least is asked, a wrapping row is as narrow as its widest child at its least: every child on a
// line of its own.
let block_layout = if *wrap && env.least { child::column_layout(rtl) } else { child::row_layout(rtl, *wrap) };
let (inner, took) = child::block(ui, rect, block_layout, |ui| {
let installed = Env::install_for(
ui,
env.derive_local(|scoped| {
scoped.row_room = Some(room.width());
scoped.row_line = line;
if line.is_some() {
scoped.first_line = None;
}
}),
);
let inner = if *wrap { body(ui) } else { run_shrinking(ui, id, &mut body) };
Env::restore(&ctx, installed);
if !*wrap {
record_line(ui, sizing, id, shared);
}
inner
});
if *align != RowAlign::Start {
found(&ctx, sizing, id, room.size(), took.size());
}
(inner, (*align != RowAlign::Start).then(|| took.width()))
}
BodyLayout::Grid { columns } => (run_grid(ui, env, id, columns, gap, body), None),
=======
BodyLayout::Stack => (run_stack(ui, env, &line, body), None),
BodyLayout::Row { wrap: false, align: RowAlign::SpaceBetween } => run_spread_row(ui, env, &line, body),
BodyLayout::Row { wrap: false, align: RowAlign::Start } => (run_start_row(ui, env, &line, body), None),
BodyLayout::Row { wrap, align } => run_row(ui, env, &line, (*wrap, *align), body),
BodyLayout::Grid { columns, fit, cells } => (run_grid(ui, env, id, (&columns[..], *fit, *cells), gap, body), None),
>>>>>>> up/next
}
}
@@ -1795,6 +1688,14 @@ fn run_row<R>(ui: &mut Ui, env: &Env, at: &RowIn, (wrap, align): (bool, RowAlign
let RowIn { id, shared, sizing, rtl, .. } = *at;
let room = ui.available_rect_before_wrap();
let rect = match align {
// A wrapping row wraps at the line length its container sets for paragraphs (a dialog's), as the paragraphs
// beside it do: a dialog sized from its content stays as wide as its text, and a row of radios that would not
// fit there takes a second line instead of widening the dialog. A room unbounded at its end edge (a measuring
// run's) is cut from its start edge.
RowAlign::Start | RowAlign::SpaceBetween if wrap => env
.measure
.filter(|measure| *measure < room.width() && (!rtl || room.right().is_finite()))
.map(|measure| Flow::new(room, rtl).span(0.0, measure)),
RowAlign::Start | RowAlign::SpaceBetween => None,
RowAlign::Center | RowAlign::End => {
let last = this_pass(&ctx, sizing, id);
+1 -5
View File
@@ -7,11 +7,7 @@ mod label;
mod slot;
pub use arrange::{Placed, arrange};
<<<<<<< HEAD
pub use body::{BodyLayout, RowAlign, ShrinkOrder, ShrinkUnit, levelled_unit, plan_levels, shrink_widths};
=======
pub use body::{BodyLayout, CellAlign, GridFit, RowAlign, ShrinkOrder, ShrinkUnit, empty_cell, shrink_widths};
>>>>>>> up/next
pub use body::{BodyLayout, CellAlign, GridFit, RowAlign, ShrinkOrder, ShrinkUnit, empty_cell, levelled_unit, plan_levels, shrink_widths};
pub use column_group::ColumnGroup;
#[doc(hidden)]
pub use column_group::ambient_width;
+1 -13
View File
@@ -95,9 +95,6 @@ pub struct IconSpec<'a> {
pub color: Option<StyleColor>,
/// Mirroring under right-to-left.
pub mirror: Mirror,
<<<<<<< HEAD
/// The set an SVG icon is drawn from.
pub set: IconSet,
/// A data-colour mark on the icon: a dot at the bottom-trailing corner (see [`badge`](Self::badge)) or a bar across
/// the bottom (see [`with_mark`](Self::with_mark)).
pub badge: Option<IconMark>,
@@ -128,10 +125,6 @@ impl IconMark {
pub const fn weighted_bar(color: DataColor, weight: f32) -> Self {
IconMark::Bar { color, weight: Some(weight) }
}
=======
/// A dot of a colour from data at the icon's bottom-trailing corner; see [`badge`](Self::badge).
pub badge: Option<DataColor>,
>>>>>>> up/next
}
impl<'a> IconSpec<'a> {
@@ -254,13 +247,8 @@ pub(crate) fn paint(painter: &Painter, tokens: &UiTokens, direction: Direction,
}
IconSource::Glyph(glyph) => glyph.paint(painter, tokens, square, color, rtl && glyph.directional() && spec.mirror == Mirror::Auto),
IconSource::Svg(id) => {
<<<<<<< HEAD
if let Some(icon) = SvgIcon::of(tokens, direction, side, id, spec.set, spec.mirror) {
icon.paint_layers(painter, square, LayerInks::of(tokens, color, single_ink));
=======
if let Some(icon) = SvgIcon::of(tokens, direction, side, id, spec.mirror) {
icon.paint(painter, square, color);
>>>>>>> up/next
icon.paint_layers(painter, square, LayerInks::of(tokens, color, single_ink));
}
}
IconSource::Mark(badge) => super::pointer_art::paint_badge(painter, tokens, direction, square, *badge, color),
@@ -330,11 +330,8 @@ pub(crate) fn report(ctx: &Context, own: &Own<'_>) {
inner_stop: None,
focusable: own.focusable || crate::runtime::focus::has_reachable_stop(ctx, own.id),
disabled: !own.enabled,
<<<<<<< HEAD
arranged: false,
=======
display: own.display,
>>>>>>> up/next
},
);
}
+7 -61
View File
@@ -127,22 +127,10 @@ struct Scope {
/// The component whose eviction takes the facts the scope records.
owner: Id,
kind: Kind,
/// The direct controls, decided when the scope closes: node components inside this scope that sit in no other
/// component that has a node.
/// The direct controls: node components inside this scope that sit in no other node component of it.
nodes: Vec<ScopeNode>,
<<<<<<< HEAD
/// Node components inside this scope whose step 16 has not come yet, outermost first.
open: Vec<Open>,
=======
/// Every node component that reported inside this scope, with the node components that were open around it.
reported: Vec<(ScopeNode, Vec<Id>)>,
/// Node components that began as a node at step 8 and turned out to have none at step 16 (a layout container
/// with no label): the controls inside them are direct controls of the scope.
hollow: Vec<Id>,
/// Node components inside this scope whose step 16 has not come yet, outermost first, with the number of focus stops
/// registered before they began.
open: Vec<(Id, usize)>,
>>>>>>> up/next
/// The screen y of the top of the rect the label step placed the controls in; the recorded baseline and centre
/// are stored measured from it.
control_top: f32,
@@ -190,14 +178,11 @@ pub(crate) struct ScopeNode {
pub focusable: bool,
/// The control is disabled: a label that names only disabled controls is disabled too.
pub disabled: bool,
<<<<<<< HEAD
/// The control reached the scope through a node component that reports no node (an unlabelled row): it is part
/// of the field's arrangement, so the label names the field's group and the control keeps its own name.
pub arranged: bool,
=======
/// The node is static display (a text): it is no control of the scope.
/// The node is static display (a text): it is no control of a label scope.
pub display: bool,
>>>>>>> up/next
}
/// What a control tells its label scope about its reset (10.2).
@@ -236,8 +221,6 @@ pub(crate) fn begin(ctx: &Context, container: Id, owner: Id, kind: Kind) {
owner,
kind,
nodes: Vec::new(),
reported: Vec::new(),
hollow: Vec::new(),
open: Vec::new(),
control_top: 0.0,
first_bottom: None,
@@ -273,7 +256,6 @@ pub(crate) fn enter(ctx: &Context, id: Id) {
}
/// Registers the node `id` with the innermost scope at its step 16. Children reach step 16 first, so they find their
<<<<<<< HEAD
/// parent still open: a node inside an open node component is held by it until that component's own step 16, which
/// drops it when the component reports a node and passes it on (`leave`) when it reports none.
pub(crate) fn register(ctx: &Context, mut node: ScopeNode) {
@@ -287,24 +269,6 @@ pub(crate) fn register(ctx: &Context, mut node: ScopeNode) {
}
scope.hold(node);
unnamed
=======
/// parent still open. Whether it is a direct control is decided when the scope closes, once every node component
/// around it has said whether it has a node (`leave`).
pub(crate) fn register(ctx: &Context, mut node: ScopeNode) {
let unnamed = pass_state::with::<Stack, _>(ctx, |stack| {
let Some(scope) = stack.0.last_mut() else { return node.unnamed.take() };
let around = match scope.open.iter().rposition(|(open, _)| *open == node.id) {
Some(at) => {
node.inner_stop = crate::runtime::focus::first_stop_inside(ctx, node.id, scope.open[at].1);
let around = scope.open[..at].iter().map(|(open, _)| *open).collect();
scope.open.truncate(at);
around
}
None => scope.open.iter().map(|(open, _)| *open).collect(),
};
scope.reported.push((node, around));
None
>>>>>>> up/next
});
unnamed.into_iter().for_each(|finding| report_unnamed(ctx, Some(finding)));
}
@@ -332,18 +296,6 @@ impl Scope {
}
}
/// Notes that the node component `id`, which began as a node at step 8, reports none at step 16.
pub(crate) fn leave(ctx: &Context, id: Id) {
pass_state::with::<Stack, _>(ctx, |stack| {
if let Some(scope) = stack.0.last_mut()
&& let Some(at) = scope.open.iter().rposition(|(open, _)| *open == id)
{
scope.open.truncate(at);
scope.hollow.push(id);
}
});
}
fn report_unnamed(ctx: &Context, unnamed: Option<Finding>) {
if let Some(finding) = unnamed {
emit::report_finding(ctx, finding);
@@ -634,21 +586,15 @@ pub(crate) fn finish(ctx: &Context, container: Id, merged: Option<Merged>) {
(stack.0.last().is_some_and(|scope| scope.container == container)).then(|| stack.0.pop()).flatten()
});
let Some(mut scope) = scope else { return };
<<<<<<< HEAD
// A node component still open never reported its own node (it folded into its owner's): what it held is inside
// it, so none of it is a control of the scope.
scope.open.drain(..).flat_map(|open| open.held).for_each(|node| report_unnamed(ctx, node.unnamed));
=======
for (node, around) in std::mem::take(&mut scope.reported) {
// A label scope's controls are not its static texts; a merged container shows whatever one component it has.
let counts = !node.display || matches!(scope.kind, Kind::Merge);
if counts && around.iter().all(|id| scope.hollow.contains(id)) {
scope.nodes.push(node);
} else {
report_unnamed(ctx, node.unnamed);
}
// A label scope's controls are not its static texts; a merged container shows whatever one component it has.
if matches!(scope.kind, Kind::Label(_)) {
let (texts, controls): (Vec<ScopeNode>, Vec<ScopeNode>) = std::mem::take(&mut scope.nodes).into_iter().partition(|node| node.display);
scope.nodes = controls;
texts.into_iter().for_each(|node| report_unnamed(ctx, node.unnamed));
}
>>>>>>> up/next
match scope.kind {
Kind::Label(label) => {
let patches = label_patches(scope.container, &label, &scope.nodes);
@@ -138,13 +138,9 @@ pub(crate) struct Board {
matcher: Matcher,
held: Vec<Held>,
/// The top modal layer's root container of each viewport that has one.
<<<<<<< HEAD
modal_roots: Vec<(ViewportId, Id)>,
/// The root of the page region the window's shell shows, per viewport: where keys with nothing focused also go.
page_roots: Vec<(ViewportId, Id)>,
=======
modal_roots: HashMap<ViewportId, Id>,
>>>>>>> up/next
/// The root of the page region the window's shell shows, per viewport: where keys with nothing focused also go.
page_roots: HashMap<ViewportId, Id>,
/// The states published this pass, and the pass before, by an instance inside the top modal layer.
modal_published: HashSet<StateKey>,
modal_published_last: HashSet<StateKey>,
@@ -841,8 +837,7 @@ pub(crate) fn set_modal_open(ctx: &Context, open: bool, viewport: ViewportId, ro
#[doc(hidden)]
pub fn note_page_root(ctx: &Context, viewport: ViewportId, root: Id) {
with(ctx, |board| {
board.page_roots.retain(|(of, _)| *of != viewport);
board.page_roots.push((viewport, root));
board.page_roots.insert(viewport, root);
});
}
@@ -1308,14 +1303,8 @@ pub(crate) fn begin(ctx: &Context) {
board.chains.get(&viewport).filter(|(id, _)| Some(*id) == focused).map(|(_, chain)| chain.ids().collect()).unwrap_or_default()
});
// Nothing focused inside a modal: the modal's root takes the commands, as a plain Enter goes to its default button.
<<<<<<< HEAD
let chain = match (chain.is_empty() && focused.is_none(), board.modal_roots.iter().find(|(of, _)| *of == viewport)) {
(true, Some((_, root))) => vec![*root],
=======
let chain = match (chain.is_empty() && focused.is_none(), board.modal_roots.get(&viewport)) {
(true, Some(root)) => vec![*root],
>>>>>>> up/next
_ => chain,
};
if !chain.is_empty() {
@@ -1325,7 +1314,7 @@ pub(crate) fn begin(ctx: &Context) {
// before an app command's, and the page region's after it. Nothing holds focus there, so the chain last focused
// stays.
let chain = if chain.is_empty() && focused.is_none() {
let page = board.page_roots.iter().find(|(of, _)| *of == viewport).map(|(_, root)| *root);
let page = board.page_roots.get(&viewport).copied();
shell.into_iter().chain(page).collect()
} else {
chain
@@ -19,15 +19,9 @@ pub use registry::{SetEntry, sets};
pub use board::declare_child;
#[doc(hidden)]
pub use board::focus_within;
<<<<<<< HEAD
pub use board::keymap;
#[cfg(feature = "testing")]
#[doc(hidden)]
pub use board::keymap_builds;
#[doc(hidden)]
pub use board::note_page_root;
=======
>>>>>>> up/next
pub(crate) use board::publish as publish_for;
pub(crate) use board::runs_now;
pub(crate) use board::take as take_for_instance;
+3 -19
View File
@@ -4,11 +4,7 @@ use super::root::{ResolvedRoot, RootEnv};
use crate::runtime::egui::pass;
use crate::runtime::pass_state;
use crate::style::UiTokens;
<<<<<<< HEAD
use craft_theme::{AppId, AppSizes, Appearance, Contrast, Mode, SUITE_DEFAULT, Size, TextSize, ThemeDef, ThemeId, builtins, resolve_sized};
=======
use craft_theme::{AppSizes, Appearance, Contrast, Mode, SUITE_DEFAULT, Size, TextSize, ThemeDef, ThemeId, builtins};
>>>>>>> up/next
use craft_theme::{AppId, AppSizes, Appearance, Contrast, Mode, SUITE_DEFAULT, Size, TextSize, ThemeDef, ThemeId, builtins};
use egui::Context;
use std::sync::Arc;
@@ -110,23 +106,11 @@ fn resolve_inputs(inputs: &TokenInputs) -> Arc<UiTokens> {
Appearance { mode: inputs.mode, contrast: inputs.contrast, size: inputs.density, text_size: inputs.text_size, reduced_motion: false };
let themes = builtins();
if let Some(def) = &inputs.theme_def {
<<<<<<< HEAD
return Arc::new(UiTokens::new(
Arc::new(resolve_sized(def, appearance, inputs.app.as_ref(), &inputs.sizes).tokens),
inputs.contrast,
inputs.density,
));
return Arc::new(UiTokens::of_theme(def, appearance, inputs.app.as_ref(), &inputs.sizes));
}
let theme: &ThemeDef =
[inputs.theme.as_str(), SUITE_DEFAULT].into_iter().find_map(|id| themes.iter().find(|theme| theme.id.as_str() == id)).unwrap_or(&themes[0]);
Arc::new(UiTokens::new(Arc::new(resolve_sized(theme, appearance, inputs.app.as_ref(), &inputs.sizes).tokens), inputs.contrast, inputs.density))
=======
return Arc::new(UiTokens::of_theme(def, appearance, &inputs.sizes));
}
let theme: &ThemeDef =
[inputs.theme.as_str(), SUITE_DEFAULT].into_iter().find_map(|id| themes.iter().find(|theme| theme.id.as_str() == id)).unwrap_or(&themes[0]);
Arc::new(UiTokens::of_theme(theme, appearance, &inputs.sizes))
>>>>>>> up/next
Arc::new(UiTokens::of_theme(theme, appearance, inputs.app.as_ref(), &inputs.sizes))
}
/// What the resolved root tokens depend on. The sizes are compared by identity, as `set_input` does.
+3 -17
View File
@@ -80,16 +80,11 @@ pub(crate) struct FocusedRecord {
pub(crate) menu: Option<Id>,
/// The focused stop switches pages with Ctrl+Tab.
pub(crate) pages: bool,
<<<<<<< HEAD
/// The component that registered as the window's menu bar (`register_menu_bar`) in the last pass: it takes the
/// menu-bar keys, and its state-dependent claims (the letters keytips badges take) hold beside the focused one's.
pub(crate) menu_bar: Option<Id>,
/// The registered menu bar takes only the Alt+letter chords it claims as mnemonics (`register_menu_bar_by_claim`).
pub(crate) menu_bar_by_claim: bool,
=======
/// The menu bar the last pass registered, which takes F10, a lone Alt and Alt with a letter.
pub(crate) menu_bar: Option<Id>,
>>>>>>> up/next
/// egui focus is on a widget no framework component made, or an egui popup is open, and no framework press or
/// drag is captured: an app's own focused widget or popup keeps the keys a focused component keeps (Tab, Escape,
/// the clipboard events). Written by the end hook after its focus moves.
@@ -160,11 +155,8 @@ pub(crate) struct State {
pub(crate) visible: bool,
pub(crate) record: FocusedRecord,
pub(super) menu_bar: Option<Id>,
<<<<<<< HEAD
/// The registered menu bar takes only the Alt+letter chords it claims as mnemonics.
pub(super) menu_bar_by_claim: bool,
=======
>>>>>>> up/next
/// The menu bar that took focus and the stop it took focus from, for the bar or a menu pick to give back.
pub(super) bar_return: Option<(Id, StopKey)>,
pub(crate) press: press::PressState,
@@ -472,14 +464,15 @@ pub(crate) fn pop_scope(ctx: &Context) {
apply(ctx, acts);
}
<<<<<<< HEAD
/// Registers the component `id` as the menu bar that can take the menu-bar keys of the next input hook (spec 9.7).
/// Its claims hold as the focused component's do, so a bar that is not a focus stop (keytips) keeps the letters it
/// takes from the focused field. The last registration of a pass wins.
/// takes from the focused field. The last registration of a pass wins. A settled bar registers again when it replays
/// its last run, and the keys it takes run it (`keys::routed_to`).
///
/// With `by_claim` the bar has no mnemonic letters of its own: an Alt+letter reaches it only as a chord it claims, and
/// any other stays the app's shortcut. A menu bar's titles name their letters, so it registers without.
pub(crate) fn register_menu_bar(ctx: &Context, id: Id, by_claim: bool) {
crate::runtime::replay::journal(ctx, || (id, by_claim), |ctx, &(id, by_claim)| register_menu_bar(ctx, id, by_claim));
with(ctx, |state| {
state.menu_bar = Some(id);
state.menu_bar_by_claim = by_claim;
@@ -492,13 +485,6 @@ pub(crate) fn register_menu_bar(ctx: &Context, id: Id, by_claim: bool) {
/// type while no lone Alt or F10 has started them.
pub fn takes_letters(keys: &KeyUse) -> bool {
matches!(keys.owner, OwnerClass::Text | OwnerClass::Recorder) && !keys.is_document_editor()
=======
/// Registers that the menu bar `bar` takes the menu-bar keys of the next input hook (spec 9.7). A settled bar
/// registers again when it replays its last run, and the keys it takes run it (`keys::routed_to`).
pub(crate) fn register_menu_bar(ctx: &Context, bar: Id) {
crate::runtime::replay::journal(ctx, || bar, |ctx, &bar| register_menu_bar(ctx, bar));
with(ctx, |state| state.menu_bar = Some(bar));
>>>>>>> up/next
}
/// A registered menu bar takes the keyboard (F10, a lone Alt): focus moves to `target`, a stop of the bar, in this
@@ -355,13 +355,8 @@ fn finish(ctx: &Context, open: Open) -> Recorded {
let Some(owner) = index.get(&(id, None)).copied() else { continue };
let rect = hits.iter().find(|hit| hit.owner == id && hit.part == part).map_or(elements[owner].rect, |hit| hit.rect);
let depth = elements[owner].depth + 1;
<<<<<<< HEAD
let element =
Element { id, part, component: elements[owner].component, depth, rect, content: rect, facts: None, stop: None, command: None };
elements.insert(owner + 1, element);
owner + 1
=======
let element = Element { id, part, component: elements[owner].component, depth, rect, content: rect, facts: None, stop: None };
let at = owner + 1;
elements.insert(at, element);
for old in index.values_mut() {
@@ -371,7 +366,6 @@ fn finish(ctx: &Context, open: Open) -> Recorded {
}
index.insert((id, part), at);
at
>>>>>>> up/next
}
};
elements[at].stop = Some(stop + 1);
@@ -464,11 +464,7 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec<Arriv
let os = crate::runtime::windows::os_of(ctx);
let record = focus::record(ctx, viewport);
let keys = record.keys;
<<<<<<< HEAD
let menu_bar = record.menu_bar.is_some() && keys.is_none_or(|keys| !focus::takes_letters(&keys));
=======
let menu_bar = record.menu_bar.is_some() && keys.is_none_or(|keys| !matches!(keys.owner, OwnerClass::Text | OwnerClass::Recorder));
>>>>>>> up/next
let before = events.len();
let canvas = focus::canvas_keys(ctx, viewport).filter(|_| keys.is_none() && !record.foreign);
let lists_edits = |keys: &KeyUse| EditCommands::ALL.iter().any(|command| command.edit().is_some_and(|edit| keys.edits.contains(edit)));
@@ -64,11 +64,8 @@ pub(crate) fn show_viewport(ctx: &Context, open: &ViewportOpen<'_>, mut body: im
record.chrome = Some(chrome);
record.captions = captions.clone();
record.resizable = Some(open.resizable);
<<<<<<< HEAD
record.min_size = open.limits.0;
=======
record.moved_by_app = open.moved_by_app;
>>>>>>> up/next
record.awaiting_first_paint |= spec.shown_after_first_paint && record.facts.is_none();
if record.title.as_deref() != Some(open.title) {
record.title = Some(open.title.to_owned());
@@ -4,13 +4,8 @@ use crate::contract::{Common, Component, Container, ContainerProps, Cx, Mount, O
use crate::runtime::commands::{AppCatalog, Binding, CommandDef, CommandInput, CommandSet as _, EditCommands, NavCommand, Scope, TypingRule};
use crate::runtime::drag::{self, DragPreview};
use crate::runtime::egui::{areas, fixture};
<<<<<<< HEAD
use crate::runtime::env::RootEnv;
use crate::runtime::focus::{EditSet, FocusPolicy, FocusTarget, KeepKeys, KeyUse, host_canvas, request};
=======
use crate::runtime::env::{Env, RootEnv};
use crate::runtime::focus::{EditSet, FocusTarget, KeepKeys, KeyUse, host_canvas, request};
>>>>>>> up/next
use crate::runtime::focus::{EditSet, FocusPolicy, FocusTarget, KeepKeys, KeyUse, host_canvas, request};
use crate::runtime::frame::{ChromeToggle, take_output};
use crate::runtime::keys::with_window_intents;
use crate::style::{ComponentStyle, StyleCx};
+29 -43
View File
@@ -1,27 +1,14 @@
<<<<<<< HEAD
//! Trials of the app icon registry: the catalog wins a clashing name, the first set keeps a name two sets share; and
//! of an app icon's layers by class.
//! Trials of the icon lookup: the app icon registry (the catalog wins a clashing name, the first set keeps a name two
//! sets share), the set a theme's icon pack picks, and an app icon's layers by class.
use crate::primitives::{AppIcons, DataMode, Draw, DrawEnv, IconSet, IconSpec, Layer, Mirror, PaintRecord, SvgIcon, icon_names, register_app_icons};
use crate::style::{Ink, StyleColor, ink_color, rgba_color};
use crate::primitives::{AppIcons, DataMode, Draw, DrawEnv, IconSpec, Layer, Mirror, PaintRecord, SvgIcon, icon_names, register_app_icons};
use crate::style::{Ink, StyleColor, UiTokens, ink_color, rgba_color};
use crate::testing::{Frames, style, trial};
use craft_behavior::IconId;
use craft_i18n::Direction;
use craft_theme::{Contrast, Mode};
use craft_theme::{AppSizes, Appearance, Contrast, IconPackId, Mode, Size, TextSize, builtins};
use egui::{Color32, ColorImage, Rect, Shape, TextureId, pos2};
use std::cell::RefCell;
=======
//! Trials of the icon lookup: the app icon registry (the catalog wins a clashing name, the first set keeps a name two
//! sets share) and the set a theme's icon pack picks.
use crate::primitives::{AppIcons, Mirror, SvgIcon, icon_names, register_app_icons};
use crate::style::UiTokens;
use crate::testing::{style, trial};
use craft_behavior::IconId;
use craft_i18n::Direction;
use craft_theme::{AppSizes, Appearance, Contrast, IconPackId, Mode, Size, TextSize, builtins};
use egui::ColorImage;
>>>>>>> up/next
// Built from parts so the workspace scan of icon-id literals does not read them.
const FIRST_NAME: &str = concat!("zz_t10_", "first");
@@ -74,17 +61,38 @@ fn an_app_icon_set_resolves_after_the_catalog_and_the_first_set_keeps_a_shared_n
assert_eq!(icon_names().len(), catalog);
}
<<<<<<< HEAD
/// The mask of `name` under the first built-in theme with its icon pack set to `pack`.
fn mask_under_pack(pack: Option<&str>, name: &'static str) -> Option<ColorImage> {
let mut theme = builtins()[0].clone();
let pack = pack.map(IconPackId::parse).transpose();
assert!(pack.is_ok(), "{pack:?}");
theme.icon_pack = pack.unwrap_or_default();
let appearance =
Appearance { mode: Mode::Dark, contrast: Contrast::Standard, size: Size::Compact, text_size: TextSize::Small, reduced_motion: false };
let tokens = UiTokens::of_theme(&theme, appearance, None, &AppSizes::default());
SvgIcon::of(&tokens, Direction::Ltr, 24.0, &IconId::from(std::borrow::Cow::Borrowed(name)), Mirror::Auto).map(|icon| icon.mask(24.0, 1.0))
}
#[trial]
fn a_theme_icon_pack_picks_the_set_and_an_unknown_pack_draws_the_default() {
let default = mask_under_pack(None, CATALOG_NAME);
assert!(default.is_some());
// Carbon's close is a fill drawing; Lucide's and Tabler's are the same two strokes.
assert_ne!(mask_under_pack(Some("craft.carbon"), CATALOG_NAME), default, "a built-in pack draws its own icon");
assert_eq!(mask_under_pack(Some("craft.lucide"), CATALOG_NAME), default, "the default set by name draws the default");
assert_eq!(mask_under_pack(Some("user.missing"), CATALOG_NAME), default, "a pack that is not installed draws the default");
}
const LAYERED_NAME: &str = concat!("zz_t19_", "pen");
/// A plain body, an accent nib (a group, so the class reaches its children) and a fixed red cap.
const LAYERED: &[u8] = b"<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">\
<rect x=\"4\" y=\"8\" width=\"10\" height=\"8\" fill=\"black\"/>\
<g class=\"accent\"><path d=\"M14 8 L22 12 L14 16 Z\" fill=\"black\"/></g>\
<rect class=\"fixed\" x=\"2\" y=\"8\" width=\"2\" height=\"8\" fill=\"#d02020\"/></svg>";
static LAYERED_SET: AppIcons = AppIcons { name: "t19-layers", stroke_width: None, icons: &[(LAYERED_NAME, LAYERED)] };
const LAYERED_SET: AppIcons = AppIcons { name: "t19-layers", stroke_width: None, icons: &[(LAYERED_NAME, LAYERED)] };
/// A plain icon with no classed part.
const PLAIN_NAME: &str = concat!("zz_t19_", "plain");
static PLAIN_SET: AppIcons = AppIcons { name: "t19-plain", stroke_width: None, icons: &[(PLAIN_NAME, DISC)] };
const PLAIN_SET: AppIcons = AppIcons { name: "t19-plain", stroke_width: None, icons: &[(PLAIN_NAME, DISC)] };
/// The texture and tint of every textured shape `shapes` holds, in paint order.
fn textured(shapes: &[Shape]) -> Vec<(TextureId, Color32)> {
@@ -156,26 +164,4 @@ fn an_accent_part_paints_in_the_accent_ink_a_fixed_part_as_drawn_and_both_take_t
// An icon with no classed part paints its ink layer alone.
assert_eq!(paint(PLAIN_NAME, DataMode::Full, ink).len(), 1, "a layer with no part paints no quad");
=======
/// The mask of `name` under the first built-in theme with its icon pack set to `pack`.
fn mask_under_pack(pack: Option<&str>, name: &'static str) -> Option<ColorImage> {
let mut theme = builtins()[0].clone();
let pack = pack.map(IconPackId::parse).transpose();
assert!(pack.is_ok(), "{pack:?}");
theme.icon_pack = pack.unwrap_or_default();
let appearance =
Appearance { mode: Mode::Dark, contrast: Contrast::Standard, size: Size::Compact, text_size: TextSize::Small, reduced_motion: false };
let tokens = UiTokens::of_theme(&theme, appearance, &AppSizes::default());
SvgIcon::of(&tokens, Direction::Ltr, 24.0, &IconId::from(std::borrow::Cow::Borrowed(name)), Mirror::Auto).map(|icon| icon.mask(24.0, 1.0))
}
#[trial]
fn a_theme_icon_pack_picks_the_set_and_an_unknown_pack_draws_the_default() {
let default = mask_under_pack(None, CATALOG_NAME);
assert!(default.is_some());
// Carbon's close is a fill drawing; Lucide's and Tabler's are the same two strokes.
assert_ne!(mask_under_pack(Some("craft.carbon"), CATALOG_NAME), default, "a built-in pack draws its own icon");
assert_eq!(mask_under_pack(Some("craft.lucide"), CATALOG_NAME), default, "the default set by name draws the default");
assert_eq!(mask_under_pack(Some("user.missing"), CATALOG_NAME), default, "a pack that is not installed draws the default");
>>>>>>> up/next
}