Combine framework sync area contract

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. TaylorandClaude Opus 5.5 committed 2026-11-29 05:19:35 +00:00
commit becc015c98
23 files changed
+51 -420

No files matched your search

+15 -166
View File
@@ -153,102 +153,6 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
}
fn read(&mut self, comp: &mut C, stage: &mut MemoryStage, id: Id, env: &Env) {
<<<<<<< HEAD
let ctx = stage.ctx().clone();
// A header the OS title bar stands for is gone in a window whose frame the OS draws: every later step and
// region reads the props without it.
if let Mount::Viewport { spec, .. } = &self.props.mount
&& self.props.header.is_some_and(|header| header.os_title)
&& windows::os_title_bar(&ctx, id, spec.as_ref())
{
Arc::make_mut(&mut self.props).header = None;
}
let props = Arc::clone(&self.props);
let props = &*props;
let scroll = scroll_of(props);
let collapse = props.collapse;
let save = props.save.clone();
self.save = save.clone();
// The overlay host decides a layer's Escape; so does a full-window mount's.
self.layer = matches!(props.mount, Mount::Layer(_) | Mount::Viewport { .. } | Mount::FullWindow);
self.region_gap = gap_of(&env.tokens, Gap::Tight);
self.end_gap = gap_of(&env.tokens, props.end.map_or(Gap::Tight, |end| end.gap));
self.header_gap = header_gap_of(props, &env.tokens);
let start = layout::flow_start(&ctx, env);
self.after_rule = start == Some(true);
self.rules = RuleBands::of(props, env, crate::runtime::egui::scale::pixels_per_point(&ctx), start);
self.least_width = least_of(&env.tokens, props.least_width);
let quiet = stage.is_peek() || crate::runtime::measure::active(&ctx);
if !matches!(props.mount, Mount::Inline | Mount::Pane(_))
&& let Some(why) = if quiet { crate::runtime::overlay::peek_close(&ctx, id) } else { crate::runtime::overlay::take_close(&ctx, id) }
{
self.close = true;
self.reason = Some(why);
}
self.open_bound = comp.open().is_some();
self.open = open_now(comp, stage, id, props);
self.open_at_read = self.open;
self.presence = match collapse {
Some(collapse) if collapse.animated => {
Driver { stage: &*stage, base: id, policy: env.motion }.presence("collapse", self.open, spec::OPEN_RISE)
}
_ => Presence { t: f32::from(u8::from(self.open)), visible: self.open, exiting: false },
};
self.mode = stage.session::<WindowMode>(sub(id, "window_mode")).clone();
self.fixed = match &props.mount {
Mount::FullWindow => true,
// A viewport whose fallback covers the window is fixed in both modes, as a full-window mount is: its body
// never sizes as a layer's content.
Mount::Viewport { fallback, .. } if fallback.is_full_window() => true,
Mount::Viewport { spec, .. } if windows::mount_window(&ctx, id, spec.as_ref()) => true,
Mount::Layer(_) | Mount::Viewport { .. } => {
let placement = overlay_of(props).map_or_else(Placement::default, |overlay| {
let screen = crate::contract::overlay::screen_for(&ctx, env, overlay);
shown_placement(&ctx, id, save.as_ref(), overlay, None, screen, env.tokens.space.inset.screen)
});
// A layer the user sized takes that size, at its saved position or where its anchor places it.
placement.size.is_some()
}
_ => false,
};
self.last = stage.recall::<BodyView>(sub(id, "view"));
self.strip = scroll_strip_height(&env.tokens);
self.row = env.tokens.size.control.md;
let Some(scroll) = scroll else { return };
// A scrolled body of a layer, or in one, starts at the top at every opening of the layer, as at its first.
let opening = match props.mount {
Mount::Layer(_) => crate::runtime::overlay::appears(&ctx, id, false),
_ => crate::runtime::overlay::drawing_parent(&ctx).is_some_and(|layer| crate::runtime::overlay::opening(&ctx, layer)),
};
if opening && comp.scroll().is_none() {
*stage.session::<ScrollState>(sub(id, "scroll")) = ScrollState::default();
}
self.last_extent = stage.session::<ScrollState>(sub(id, "scroll")).extent;
self.scroll_bound = comp.scroll().is_some();
let held = match comp.scroll() {
Some(bind) => match bind.get() {
Some(Mixed::Same(pos)) => pos,
_ => ScrollPos::default(),
},
None => {
let state = stage.session::<ScrollState>(sub(id, "scroll"));
self.anchor = state.anchor;
ScrollPos { x: state.offset.0, y: state.offset.1 }
}
};
self.anchor_at_read = self.anchor;
self.offset = held;
self.offset_at_read = held;
let rtl = env.direction.is_rtl();
let view = self.last.view.map_or(Vec2::ZERO, |view| self.shown_view(scroll, rect_of(view)).size());
// Step 4 applies, in order, the scroll bar, AccessKit and reveal moves the update step of the last pass queued
// (`Jumps`), this pass's wheel share and the scroll moves queued for the body.
let frame = jump_frame(&ctx);
let jump = pass_state::with::<Jumps, _>(&ctx, |jumps| {
jumps.0.retain(|(.., queued)| queued + 1 >= frame);
let at = jumps.0.iter().position(|(owner, ..)| *owner == id)?;
Some(if quiet { jumps.0[at].1 } else { jumps.0.remove(at).1 })
=======
let quiet = self.read_before_open(stage, id, env);
self.open_bound = comp.open().is_some();
let props = Arc::clone(&self.props);
@@ -257,7 +161,6 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
let bound_scroll = comp.scroll().map(|bind| match bind.get() {
Some(Mixed::Same(pos)) => pos,
_ => ScrollPos::default(),
>>>>>>> 07a8c471ed
});
self.read_after_open(stage, id, env, quiet, bound_scroll);
}
@@ -271,14 +174,9 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
self.room = self.mount_room(props, (ui, env), id, at, scx.tokens);
self.given = self.given_axes(props, env, at);
self.fixed_height = self.fixed_height(props, at);
<<<<<<< HEAD
self.least_width = self.least_width_of(props, &env, scx.tokens);
self.passes = self.passes_width(props, &env, at);
self.held = self.held(props, &env);
=======
self.least_width = self.least_width_of(props, env, scx.tokens);
self.passes = self.passes_width(props, env, at);
self.held = self.held(props, env);
>>>>>>> 07a8c471ed
self.across = self.held && matches!(env.column, Some(ColumnSweep::Column(..)));
self.in_column = label::in_column(ui, env);
self.egui_cell = env.egui_cell;
@@ -518,70 +416,9 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
}
fn updated(&mut self, comp: &mut C, cx: &mut Cx<'_, C>) {
<<<<<<< HEAD
use crate::contract::Pointer as _;
let props = comp.props(Internal::new());
let (scroll, layer) = (scroll_of(props), matches!(props.mount, Mount::Layer(_) | Mount::Viewport { .. }));
// The OS asked a viewport mount's window to close: the container closes at step 15.
if matches!(props.mount, Mount::Viewport { .. }) && windows::take_close_request(cx.core.memory.ctx(), cx.core.id) {
self.close = true;
self.reason = self.reason.or(Some(CloseReason::Requested));
}
if scroll.is_some() {
self.scroll_input(props, cx);
}
// A reveal queued for the body moves its offset against the view this pass shows, on top of a move
// `scroll_input` queued, within the offsets the content allows; the next pass takes the offset at step 4, as it
// takes the scroll bar's, and places by it. A reveal that moves nothing queues no jump, so it costs no pass. The
// part of the rect the moved view shows goes on to the scroll owner around.
if let Some((scroll, view)) = scroll.zip(self.view)
&& let Some(rect) = crate::contract::take_reveal(&cx.core.ctx, cx.core.id)
{
let view = self.shown_view(scroll, view);
let (by, _) = crate::contract::steps::reveal_move(rect, view);
let rtl = cx.core.env.direction().is_rtl();
let id = cx.core.id;
let from = super::scroll::queued_jump(&cx.core.ctx, id).unwrap_or(self.offset);
let mut offset = from;
offset.y += f64::from(by.y);
offset.x += f64::from(if rtl { -by.x } else { by.x });
let offset = self.clamped(scroll, view.size(), offset);
// A reveal of what the view shows moves nothing: no jump, so no repeated pass.
if offset != from {
super::scroll::queue_jump(&cx.core.ctx, id, offset);
}
let moved = Vec2::new((offset.x - from.x) as f32, (offset.y - from.y) as f32);
let moved = Vec2::new(if rtl { -moved.x } else { moved.x }, moved.y);
crate::contract::Focus::reveal(cx, rect.translate(-moved).intersect(view));
}
// AccessKit Expand, Collapse and Click reach a collapsible container as an activation: it folds or unfolds.
if props.collapse.is_some() && cx.activation().is_some_and(|activation| activation.by_key) {
self.open = !self.open;
}
self.band_double(cx.core);
self.surface_press(comp.sense().contains(craft_behavior::Sense::SURFACE), cx.core);
let band = props.header.is_some_and(|header| header.band == DragBand::Move);
if (band || matches!(props.mount, Mount::Viewport { .. } | Mount::Window { .. }))
&& let Some(viewport) = os_window(props, cx.core.memory.ctx(), cx.core.id, &cx.core.env)
{
self.window_os(viewport, props, cx);
self.window_movable(viewport, cx.core);
}
self.pane_drag(props, cx.core);
let own_window = match &props.mount {
Mount::Viewport { spec, .. } => windows::mount_window(cx.core.memory.ctx(), cx.core.id, spec.as_ref()),
_ => false,
};
if layer && !own_window {
self.window_keys(props, cx);
self.window_drag(props, cx);
}
self.window_placed(props, cx.core);
=======
let style_min = cx.style.metrics().min_size;
let surface = comp.sense().contains(craft_behavior::Sense::SURFACE);
self.updated_core(comp.props(Internal::new()), surface, style_min, cx.core);
>>>>>>> 07a8c471ed
// The body moves and resizes the layer in screen space; the caller places it in its parent's layer space.
let from_screen = crate::runtime::overlay::parent_space(&cx.core.ctx, cx.core.id).inverse();
for mut change in std::mem::take(&mut self.reports) {
@@ -774,6 +611,14 @@ impl BodyHooks<'_> {
/// Whether the stage only peeks (a peek or a measuring pass), which the rest of the step needs too.
fn read_before_open(&mut self, stage: &mut MemoryStage, id: Id, env: &Env) -> bool {
let ctx = stage.ctx().clone();
// A header the OS title bar stands for is gone in a window whose frame the OS draws: every later step and
// region reads the props without it.
if let Mount::Viewport { spec, .. } = &self.props.mount
&& self.props.header.is_some_and(|header| header.os_title)
&& windows::os_title_bar(&ctx, id, spec.as_ref())
{
Arc::make_mut(&mut self.props).header = None;
}
let props = Arc::clone(&self.props);
let props = &*props;
self.save = props.save.clone();
@@ -817,7 +662,7 @@ impl BodyHooks<'_> {
// A viewport whose fallback covers the window is fixed in both modes, as a full-window mount is: its body
// never sizes as a layer's content.
Mount::Viewport { fallback, .. } if fallback.is_full_window() => true,
Mount::Viewport { .. } if windows::mount_window(&ctx, id) => true,
Mount::Viewport { spec, .. } if windows::mount_window(&ctx, id, spec.as_ref()) => true,
Mount::Layer(_) | Mount::Viewport { .. } => {
let placement = overlay_of(props).map_or_else(Placement::default, |overlay| {
let screen = crate::contract::overlay::screen_for(&ctx, env, overlay);
@@ -972,7 +817,11 @@ impl BodyHooks<'_> {
self.window_movable(viewport, core);
}
self.pane_drag(props, core);
if layer && !(matches!(props.mount, Mount::Viewport { .. }) && windows::mount_window(core.memory.ctx(), core.id)) {
let own_window = match &props.mount {
Mount::Viewport { spec, .. } => windows::mount_window(core.memory.ctx(), core.id, spec.as_ref()),
_ => false,
};
if layer && !own_window {
self.window_keys(props, core, style_min);
self.window_drag(props, core, style_min);
}
@@ -172,19 +172,9 @@ pub(super) fn overlay_of(props: &ContainerProps) -> Option<&crate::contract::Ove
pub(super) fn measure_layer(props: &ContainerProps, id: Id, ui: &Ui) -> areas::Layer {
let area = sub(id, "area");
match &props.mount {
<<<<<<< HEAD
Mount::Viewport { spec, .. } if windows::mount_window(ui.ctx(), id, spec.as_ref()) => ui.layer_id(),
Mount::Layer(overlay) | Mount::Viewport { fallback: overlay, .. } => {
areas::layer_of(crate::runtime::overlay::layer_tier(ui.ctx(), overlay.rank), area)
}
Mount::FullWindow => {
areas::layer_of(crate::runtime::overlay::layer_tier(ui.ctx(), crate::contract::Overlay::full_window(props.focus).rank), area)
}
=======
Mount::Viewport { .. } if windows::mount_window(ui.ctx(), id) => ui.layer_id(),
Mount::Layer(overlay) | Mount::Viewport { fallback: overlay, .. } => areas::layer_of(overlay.tier(ui.ctx()), area),
Mount::FullWindow => areas::layer_of(crate::contract::Overlay::full_window(props.focus).tier(ui.ctx()), area),
>>>>>>> 07a8c471ed
_ => ui.layer_id(),
}
}
-5
View File
@@ -69,12 +69,7 @@ mod request;
pub use drag::{SweepApply, SweepStep};
pub use header::ColumnCommands;
pub(crate) use header::HeaderFacts;
<<<<<<< HEAD
pub use header::toggle_cell_part;
=======
#[doc(hidden)]
pub use header::{RowToggle, put_toggle_names};
>>>>>>> 07a8c471ed
pub use press::item_part_open;
#[doc(hidden)]
pub use request::lead_position;
@@ -10,7 +10,6 @@ use craft_behavior::ColumnKey;
use egui::{Context, Id, Rect};
impl<C: Collection> ItemsHooks<'_, '_, C> {
<<<<<<< HEAD
/// Hands the collection the AccessKit requests on the node of each toggle cell the shown row `key` declared
/// (`PartsCx::toggle_cell`) below its node `item`: a click on one reaches `toggle_by_access`. A row that declared
/// no part for a column leaves nothing to redirect.
@@ -21,47 +20,6 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
}
let node = access::sub_node_id(item, crate::contract::toggle_cell_part(&column));
crate::runtime::keys::redirect_node(ctx, node, id, TOGGLE_CELL.at(key_hash(&(key, &column))));
=======
/// The access sub-node of each toggle cell of row `(at, key)`, named by its cell, else by its column's header, and carrying its state,
/// below the row's node for the cell, else the row's node `item`; an AccessKit click on it reaches `toggle_by_access`.
pub(super) fn report_toggle_cells(
&self,
ctx: &Context,
(id, item): (Id, Id),
(at, key): (usize, &C::Key),
(cells, enabled): (&[(ColumnKey, Rect)], bool),
env: &crate::runtime::env::EnvView<'_>,
) {
for (column, toggle) in self.header.toggle_columns() {
let Some((_, rect)) = cells.iter().find(|(held, _)| *held == column) else { continue };
let Some(cell) = self.header.toggle_cell(ctx, item, &column, env) else { continue };
let role = match (toggle.exclusive, cell.check_box) {
(true, _) => Role::RADIO_BUTTON,
(false, true) => Role::CHECK_BOX,
(false, false) => Role::SWITCH,
};
let mut node = access::SubNode::new(TOGGLE_CELL.at(key_hash(&(key, &column))), role);
node.name = access::Name::Text(cell.name);
node.flags.set(crate::style::Flags::CHECKED, self.source.toggled(at, &column));
node.flags.set(crate::style::Flags::MIXED, cell.mixed);
if let Some(chord) = toggle.key {
node.shortcut(chord.display(crate::runtime::windows::os_of(ctx)));
}
let decl = access::SubDecl {
owner: id,
component: "",
node: &node,
rect: *rect,
enabled: enabled && self.source.enabled(at) && self.toggle_open(at, &column),
focusable: false,
clickable: enabled && self.source.enabled(at) && self.toggle_open(at, &column),
active: false,
face: None,
label: "",
parent: cell.cell,
};
access::report_sub(ctx, &decl);
>>>>>>> 07a8c471ed
}
}
@@ -91,7 +91,6 @@ impl DropTarget<ColumnDrag> for ColumnGap {
}
}
<<<<<<< HEAD
/// The part of an item that shows its cell of a toggle column; the index is the hash of the column.
const ITEM_TOGGLE: PartKey = PartKey::new("item_toggle");
@@ -99,37 +98,6 @@ const ITEM_TOGGLE: PartKey = PartKey::new("item_toggle");
/// access node name this part.
pub fn toggle_cell_part(column: &ColumnKey) -> PartRef {
ITEM_TOGGLE.at(hash_of(column))
=======
/// One toggle cell of a row as the row records it for the collection's node of that cell.
#[doc(hidden)]
#[derive(Clone, Debug)]
pub struct RowToggle {
/// The cell's column.
pub column: ColumnKey,
/// The accessible name, `{row}` filled; empty when the cell gives none.
pub name: String,
/// The cell shows the mixed state.
pub mixed: bool,
/// The cell is announced as a check box.
pub check_box: bool,
/// The row's node for the cell, which the collection's node for the cell goes under.
pub cell: Id,
}
/// The toggle cells of one row this pass, by column.
#[derive(Clone, Default)]
struct ToggleNames(std::sync::Arc<[RowToggle]>);
/// Records the toggle cells of the row `item`, for the collection's cell nodes of the same pass. A row that has none
/// records an empty list.
#[doc(hidden)]
pub fn put_toggle_names(ctx: &Context, item: Id, names: Vec<RowToggle>) {
crate::runtime::egui::memory::put(ctx, sub(item, "toggle_names"), ToggleNames(names.into()));
}
fn recorded_toggle_names(ctx: &Context, item: Id) -> Option<std::sync::Arc<[RowToggle]>> {
crate::runtime::egui::memory::peek_clone::<ToggleNames>(ctx, sub(item, "toggle_names")).map(|ToggleNames(names)| names)
>>>>>>> 07a8c471ed
}
/// The id the widest cell of the `Content` column `key` of the collection `id` is recorded under.
@@ -375,31 +343,6 @@ impl Header {
self.toggle_columns().filter_map(|(column, toggle)| Some((column, toggle.key?))).collect()
}
<<<<<<< HEAD
=======
/// The cell of toggle column `key` in the row `item` as the row recorded it (`put_toggle_names`), else a cell under
/// the row's node. Its name is the one the row's cell gave, else the column's header text, else its icon's name,
/// resolved in `env`. `None` when the row recorded its toggle cells and has none in this column: the collection
/// reports no node there.
pub(super) fn toggle_cell(&self, ctx: &Context, item: Id, key: &ColumnKey, env: &crate::runtime::env::EnvView<'_>) -> Option<RowToggle> {
let recorded = recorded_toggle_names(ctx, item);
let mut cell = match &recorded {
Some(cells) => cells.iter().find(|cell| cell.column == *key).cloned()?,
None => RowToggle { column: key.clone(), name: String::new(), mixed: false, check_box: false, cell: item },
};
if !cell.name.is_empty() {
return Some(cell);
}
let Some(spec) = self.specs.iter().find(|spec| spec.key == *key) else { return Some(cell) };
let header = env.resolve(&spec.header);
cell.name = match (header.as_str(), &spec.icon) {
("", Some(icon)) => icon.name().to_owned(),
(text, _) => text.to_owned(),
};
Some(cell)
}
>>>>>>> 07a8c471ed
/// The key of the column at position `at`.
pub(super) fn key_at(&self, at: usize) -> Option<&ColumnKey> {
self.specs.get(at).map(|spec| &spec.key)
+5 -13
View File
@@ -152,23 +152,15 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
self.column_keys(cx, lead_at.filter(|_| !header_held));
// The pass's `update_inputs` turned an `Activate` intent into the keyed activation.
let activated = cx.core.intents.take(Intent::Activate) || cx.core.activation.is_some_and(|activation| activation.by_key);
<<<<<<< HEAD
// A disabled lead does not run, as a press on it does not: the collection is not activated, so the popup or menu
// it is in stays open.
if activated
&& !header_held
&& let Some(row) = lead_at.filter(|&row| !self.source.enabled(row))
{
cx.core.activation = None;
self.events.push(CollectionEvent::Refused(self.source.key(row)));
} else if activated
&& !header_held
=======
if activated
&& !header_held
>>>>>>> 07a8c471ed
&& let Some(row) = lead_at
{
// A disabled lead does not run, as a press on it does not: the collection is not activated, so the popup or
// menu it is in stays open.
if !self.source.enabled(row) {
cx.core.activation = None;
}
self.activate_lead(comp, props, row);
}
}
@@ -37,25 +37,16 @@ impl<'s, 'r, C: Collection> ItemsHooks<'s, 'r, C> {
}
/// The width a collection that fills the width takes where it is not given one, in a measuring run under a body
<<<<<<< HEAD
/// sized from its content: the header's least width, else its largest row's, with no rows its empty text's, at
/// least the width it asks for (`Collection::ideal_width`), up to `room`. The column it sits in holds it at that
/// width and shows it across the width the column settles on.
pub(super) fn width_from_content(&mut self, comp: &C, ui: &Ui, id: Id, room: Vec2, item: Option<Vec2>, scx: &StyleCx<'_>) -> f32 {
let rows = if self.header.has_columns() { self.header.least_width() } else { self.largest_in(comp, ui, id, room).x };
pub(super) fn width_from_content(&mut self, comp: &C, at: (&Ui, &Env), id: Id, room: Vec2, item: Option<Vec2>, scx: &StyleCx<'_>) -> f32 {
let rows = if self.header.has_columns() { self.header.least_width() } else { self.largest_in(comp, at, id, room).x };
let empty = match comp.items().empty.as_ref() {
Some(text) if self.source.is_empty() => super::empty_text::width(ui, scx.tokens, text),
Some(text) if self.source.is_empty() => super::empty_text::width(at.0, scx.tokens, text),
_ => 0.0,
};
rows.max(empty).max(comp.ideal_width(item, self.source.len(), scx)).min(room.x)
=======
/// sized from its content: the header's least width, else its largest row's, at least the width it asks for
/// (`Collection::ideal_width`), up to `room`. The column it sits in holds it at that width and shows it across
/// the width the column settles on.
pub(super) fn width_from_content(&mut self, comp: &C, at: (&Ui, &Env), id: Id, room: Vec2, item: Option<Vec2>, scx: &StyleCx<'_>) -> f32 {
let rows = if self.header.has_columns() { self.header.least_width() } else { self.largest_in(comp, at, id, room).x };
rows.max(comp.ideal_width(item, self.source.len(), scx)).min(room.x)
>>>>>>> 07a8c471ed
}
/// The largest ideal size of the rows in this pass, the sum of their ideal widths, and the widest cell each column's
-6
View File
@@ -90,15 +90,9 @@ pub use held::Held;
pub use hosted::{Hosted, HostedKey, Hosting};
pub use items::item_node;
pub use items::lead_position;
<<<<<<< HEAD
pub use items::toggle_cell_part;
// PLAN: assumed items::cancel_rename<K>(ctx: &Context, collection: Id) (panels-w12)
pub use items::{ColumnCommands, SweepApply, SweepStep, cancel_rename, item_part_open, request_rename, section_part};
=======
pub use items::{ColumnCommands, SweepApply, SweepStep, item_part_open, request_rename, section_part};
#[doc(hidden)]
pub use items::{RowToggle, put_toggle_names};
>>>>>>> 07a8c471ed
pub use items::{measure_item, show_item, show_item_in_flow};
#[doc(hidden)]
pub use label::colon_of;
@@ -21,13 +21,8 @@ pub(crate) use container_open::{opener_open, set_opener_open};
pub use host::paint_frame_layers;
pub(crate) use host::{Layer, forget_layer, host, host_window};
pub(crate) use opener::{LayerFloor, anchor_floor};
<<<<<<< HEAD
pub use opener::{Opener, Trigger, offer_context_menu};
pub use place::{Anchor, FloatPlace, OverlayFit, Place, Resize, ResizeEdges, SizeLimits, ViewportShare};
=======
pub use opener::{Opener, Trigger};
pub use place::{Anchor, DragBounds, FloatPlace, OverlayFit, Place, Resize, ResizeEdges, SizeLimits, ViewportShare};
>>>>>>> 07a8c471ed
pub use placement::{PopupRegion, layer_room};
pub(crate) use placement::{measuring_room, region_for, resolve_anchor, screen_for};
pub(crate) use popups::dwell;
+1 -5
View File
@@ -907,14 +907,10 @@ fn create_node(ctx: &Context, ui: &Ui, id: Id, member: bool, role: Role) -> bool
fn run_in_host(p: &mut Pass<'_, '_, '_>, ui: &mut Ui, host_at: Option<ShowAt>, host_env: Option<&Env>) {
let scope = enter_scope(p, ui);
let env = host_env.unwrap_or(p.env);
<<<<<<< HEAD
if let Some(mut h) = sense_steps(p, ui, host_at, env) {
sensing::open_host(ui);
=======
// A host that runs the pass in a `Ui` of its own installs the env it gives for it; else the pass runs in the parent.
let place = host_env.unwrap_or(p.place);
if let Some(mut h) = sense_steps(p, ui, (host_at, place), env) {
>>>>>>> 07a8c471ed
sensing::open_host(ui);
update_steps(p, env, &h);
overlay_step(p, ui, env, &h);
state_steps(p, ui, env, &h);
@@ -243,15 +243,11 @@ fn report_access(p: &dyn ErasedPass<'_>, facts: &TypeFacts, input: &ReportIn<'_>
}
}
if let Some(folded) = &folded {
<<<<<<< HEAD
keys::register_node(ctx, id, folded.inner, None, focusable, false);
=======
keys::register_node(ctx, id, folded.inner, None, focusable);
// Disabled with the inner component it stands for, or with that component's text part.
if !resolved.enabled || folded.disabled {
keys::register_disabled(ctx, id);
}
>>>>>>> 07a8c471ed
}
if let Some(facts) = text_facts {
crate::runtime::access::text::report_text(ctx, id, &facts, access.unit.as_deref(), access.value.as_deref());
@@ -314,15 +310,19 @@ fn report_sub(core: &CxCore<'_>, decls: &Decls, node: &SubNode, face: Option<&Fa
let declared = decls.iter().find(|(decl, _)| (decl.key, decl.index) == key);
let mut node = node.clone();
node.flags |= result.map_or(Flags::empty(), |result| result.flags);
// A toggle cell the collection does not flip in this row is declared inactive: its node is disabled and offers no
// Click.
let closed_cell = declared.is_some_and(|(_, extras)| extras.toggle_cell) && result.is_some_and(|result| result.inactive);
let decl = SubDecl {
owner: core.id,
component: "",
node: &node,
rect: result.map_or(core.rect, |result| result.rect),
enabled: core.resolved.enabled && node.enabled && face.is_none_or(|face| face.enabled),
enabled: core.resolved.enabled && node.enabled && !closed_cell && face.is_none_or(|face| face.enabled),
focusable: takes_focus(core.resolved) && node.enabled && declared.is_some_and(|(_, extras)| extras.focusable),
clickable: core.resolved.enabled
&& node.enabled
&& !closed_cell
&& declared.is_some_and(|(decl, extras)| (decl.sense.contains(Sense::CLICK) && !extras.no_access_click) || extras.toggle_cell),
active: core.active == Some(node.part),
face: face.map(|face| FaceFacts {
+2 -6
View File
@@ -64,13 +64,9 @@ pub use state_layer::{StateLayer, StateLayerKind};
pub(crate) use surface::{Frames as SurfaceFrames, SurfaceSlot, fit_to_frame};
pub use surface::{Surface, frame_surfaces};
pub use surround::paint_surround;
<<<<<<< HEAD
#[cfg(feature = "testing")]
pub(crate) use svg_set::Class;
#[cfg(feature = "testing")]
=======
#[cfg(feature = "suite")]
>>>>>>> 07a8c471ed
pub(crate) use svg_set::Class;
#[cfg(feature = "suite")]
pub(crate) use svg_set::Layer;
pub use svg_set::{AppIcons, register_app_icons};
pub use text::{ChordText, HAlign, LayoutRun, LeastLayout, ReadingMeasure, Span, TextLayout, TextRun, Wrap};
@@ -359,16 +359,11 @@ pub(crate) fn report(ctx: &Context, own: &Own<'_>) {
.controls(!relations.controls.is_empty()),
true,
);
<<<<<<< HEAD
keys::register_node(ctx, own.id, own.id, None, own.focusable, numeric.is_some());
keys::register_expanded(ctx, own.id, expanded);
=======
keys::register_node(ctx, own.id, own.id, None, own.focusable);
keys::register_expanded(ctx, own.id, expanded, own.toggle);
if !own.enabled {
keys::register_disabled(ctx, own.id);
}
>>>>>>> 07a8c471ed
scope::register(
ctx,
scope::ScopeNode {
@@ -405,14 +400,10 @@ pub fn report_sub(ctx: &Context, decl: &SubDecl<'_>) {
widths: &run.widths,
},
);
<<<<<<< HEAD
keys::register_node(ctx, id, decl.owner, Some(node.part), false, false);
=======
keys::register_node(ctx, id, decl.owner, Some(node.part), false);
if !decl.enabled {
keys::register_disabled(ctx, id);
}
>>>>>>> 07a8c471ed
return;
}
let name = match (&node.name, decl.face.as_ref()) {
@@ -470,16 +461,11 @@ pub fn report_sub(ctx: &Context, decl: &SubDecl<'_>) {
.expanded(expanded),
false,
);
<<<<<<< HEAD
keys::register_node(ctx, id, decl.owner, Some(node.part), decl.focusable, numeric.is_some());
keys::register_expanded(ctx, id, expanded);
=======
keys::register_node(ctx, id, decl.owner, Some(node.part), decl.focusable);
keys::register_expanded(ctx, id, expanded, None);
if !decl.enabled {
keys::register_disabled(ctx, id);
}
>>>>>>> 07a8c471ed
if decl.active {
adapter::set_focus(ctx, id);
}
@@ -113,14 +113,10 @@ pub(crate) fn report_text(ctx: &Context, owner: Id, facts: &TextFacts, unit: Opt
&RunNode { id, parent: owner, rect: line.rect, text, rtl: run.rtl, positions: &run.positions, widths: &run.widths },
);
let index = u64::try_from(entries.len()).ok();
<<<<<<< HEAD
keys::register_node(ctx, id, owner, Some(PartRef { key: RUN, index }), false, false);
=======
keys::register_node(ctx, id, owner, Some(PartRef { key: RUN, index }), false);
if facts.disabled {
keys::register_disabled(ctx, id);
}
>>>>>>> 07a8c471ed
entries.push(Entry { node: adapter::node_key(id), line: line_at, bytes: run.bytes.clone(), text: text.to_owned() });
}
}
+1 -8
View File
@@ -9,11 +9,7 @@ pub use label::{Label, Message, Word};
#[doc(hidden)]
pub use shell::ShellEntry;
pub use shell::{BodyMode, PageBandRoom, RevealEdge, ShellCx, ShellRegions, SlotKey, WindowKey};
<<<<<<< HEAD
pub use units::{ColumnSize, InchSpelling, LengthUnits, PointSize, UnitKind, UnitWords, Units};
=======
pub use units::{ColumnSize, LengthUnits, PointSize, UnitKind, UnitWords, Units, ZoomPrecision};
>>>>>>> 07a8c471ed
pub use units::{ColumnSize, InchSpelling, LengthUnits, PointSize, UnitKind, UnitWords, Units, ZoomPrecision};
use crate::runtime::commands::CommandChain;
use crate::runtime::egui::memory::{self, FastMap};
@@ -678,11 +674,8 @@ impl Env {
/// The scope's number format and unit words, to read and write numbers with their unit.
pub fn units(&self) -> Units {
Units::new(self.format.clone(), self.words::<UnitWords>(), self.words.clone(), self.values.get::<PointSize>())
<<<<<<< HEAD
.inches(self.values.get::<InchSpelling>())
=======
.with_zoom_precision(self.values.get::<ZoomPrecision>())
>>>>>>> 07a8c471ed
}
/// How long ago `seconds` was, in the scope's language and digits: "Just now", "3 minutes ago", "Yesterday".
+4 -15
View File
@@ -435,26 +435,18 @@ pub struct Units {
readers: Arc<[OnceLock<Reader>; UnitKind::ALL.len() + 1]>,
/// The scope's point size: what `reader` and `points_per_inch` use for Points and Picas.
point_size: PointSize,
<<<<<<< HEAD
/// The scope's spelling of inches.
inches: InchSpelling,
=======
/// The decimals a zoom shows (`zoom_codec`).
zoom: ZoomPrecision,
>>>>>>> 07a8c471ed
}
/// What every number it reads and writes depends on: the format, the unit words and the scope's words (each by its
/// generation) and the point size.
impl crate::contract::MemoProps for Units {
fn key(&self, key: &mut crate::contract::MemoKey) {
<<<<<<< HEAD
let Units { format, words, scope_words, readers: _, point_size, inches } = self;
crate::contract::MemoProps::key(&(format, words, scope_words, point_size, inches), key);
=======
let Units { format, words, scope_words, readers: _, point_size, zoom } = self;
crate::contract::MemoProps::key(&(format, words, scope_words, point_size, zoom), key);
>>>>>>> 07a8c471ed
let Units { format, words, scope_words, readers: _, point_size, inches, zoom } = self;
crate::contract::MemoProps::key(&(format, words, scope_words, point_size, inches, zoom), key);
}
}
@@ -483,22 +475,19 @@ const ZOOM_DECIMALS: usize = 2;
impl Units {
#[doc(hidden)]
pub fn new(format: Arc<Format>, words: Arc<UnitWords>, scope_words: Arc<Words>, point_size: PointSize) -> Units {
<<<<<<< HEAD
Units { format, words, scope_words, readers: Arc::default(), point_size, inches: InchSpelling::default() }
Units { format, words, scope_words, readers: Arc::default(), point_size, inches: InchSpelling::default(), zoom: ZoomPrecision::default() }
}
/// These units with inches spelt `inches`.
pub(crate) fn inches(mut self, inches: InchSpelling) -> Units {
self.inches = inches;
=======
Units { format, words, scope_words, readers: Arc::default(), point_size, zoom: ZoomPrecision::default() }
self
}
/// The same units with `zoom` as the decimals a zoom shows: the env's [`ZoomPrecision`].
#[must_use]
pub(crate) fn with_zoom_precision(mut self, zoom: ZoomPrecision) -> Self {
self.zoom = zoom;
>>>>>>> 07a8c471ed
self
}
+1 -8
View File
@@ -2,11 +2,7 @@
use super::app_values::EnvValue;
use super::label::Label;
<<<<<<< HEAD
use super::units::{InchSpelling, PointSize, UnitWords, Units};
=======
use super::units::{PointSize, UnitWords, Units, ZoomPrecision};
>>>>>>> 07a8c471ed
use super::units::{InchSpelling, PointSize, UnitWords, Units, ZoomPrecision};
use super::values::{MotionPolicy, Scale};
use super::{Held, ItemFacts, Scoped};
use crate::runtime::commands::CommandChain;
@@ -173,11 +169,8 @@ impl<'a> EnvView<'a> {
/// The scope's number format and unit words, to read and write numbers with their unit.
pub fn units(&self) -> Units {
Units::new(self.scoped.format.clone(), self.words::<UnitWords>(), self.scoped.words.clone(), self.scoped.values.get::<PointSize>())
<<<<<<< HEAD
.inches(self.scoped.values.get::<InchSpelling>())
=======
.with_zoom_precision(self.scoped.values.get::<ZoomPrecision>())
>>>>>>> 07a8c471ed
}
/// How long ago `seconds` was, in the scope's language and digits: "Just now", "3 minutes ago", "Yesterday".
+5 -5
View File
@@ -888,12 +888,12 @@ pub(super) fn initial_focus(state: &mut State, frame: u64, body: Option<usize>)
let pick = match policy.initial {
Initial::First => entry.as_ref(),
Initial::Default => stops.iter().find(|rec| rec.stop.default).or(entry.as_ref()),
<<<<<<< HEAD
// Read-only text is press-only (Tab passes over it), so it is not the field a dialog opens on.
Initial::FirstField => stops.iter().find(|rec| rec.stop.text && !rec.stop.press_only).or_else(|| stops.iter().find(|rec| rec.stop.default)),
=======
Initial::FirstField => stops.iter().find(|rec| rec.stop.text).or_else(|| stops.iter().find(|rec| rec.stop.default)).or(in_body.as_ref()),
>>>>>>> 07a8c471ed
Initial::FirstField => stops
.iter()
.find(|rec| rec.stop.text && !rec.stop.press_only)
.or_else(|| stops.iter().find(|rec| rec.stop.default))
.or(in_body.as_ref()),
Initial::Key(name) => stops.iter().find(|rec| rec.stop.name == Some(name)),
_ => None,
};
@@ -12,13 +12,9 @@ pub enum Initial {
Keep,
/// The scope's first stop.
First,
<<<<<<< HEAD
/// The scope's first editable text or number field (read-only text is passed over), else its default stop, else
/// nothing: a dialog's default.
=======
/// The scope's first text or number field, else its default stop, else the first stop of its body, else nothing:
/// a dialog's default. A footer's or a header's buttons are not taken by the last rule.
>>>>>>> 07a8c471ed
/// The scope's first editable text or number field (read-only text is passed over), else its default stop, else the
/// first stop of its body, else nothing: a dialog's default. A footer's or a header's buttons are not taken by the
/// last rule.
FirstField,
/// The stop registered as the default.
Default,
-6
View File
@@ -278,12 +278,9 @@ struct Source {
#[derive(Clone, Default)]
struct Routed {
items: Vec<Item>,
<<<<<<< HEAD
numeric_parts: Vec<PartRef>,
=======
/// Scalar-row moves selected by the canonical router, distinct from ordinary focused navigation.
scalar_moves: Vec<(NavMove, MoveMods)>,
>>>>>>> 07a8c471ed
nudge: Option<Nudge>,
/// The chords a recorder stop's presses spell this pass.
chords: Vec<Chord>,
@@ -299,12 +296,9 @@ struct Node {
owner: Id,
part: Option<PartRef>,
focusable: bool,
<<<<<<< HEAD
numeric: bool,
=======
/// The node is enabled this pass: a request that acts on a disabled node reaches no one.
enabled: bool,
>>>>>>> 07a8c471ed
/// The node's expanded state this pass, `None` when it has none.
expanded: Option<bool>,
/// The part of the owner that opens the popup whose state the node reports, when that part has no node of its own:
+1 -5
View File
@@ -57,10 +57,6 @@ pub(crate) fn register_node(ctx: &Context, node: Id, owner: Id, part: Option<Par
);
crate::runtime::replay::note_node_owner(ctx, owner);
current(ctx, |stage| {
<<<<<<< HEAD
stage.nodes.insert(node_key(node), Node { owner, part, focusable, numeric, expanded: None });
=======
stage.nodes.insert(node_key(node), Node { owner, part, focusable, enabled: true, expanded: None, toggle: None });
>>>>>>> 07a8c471ed
stage.nodes.insert(node_key(node), Node { owner, part, focusable, numeric, enabled: true, expanded: None, toggle: None });
});
}
+1 -3
View File
@@ -1077,10 +1077,9 @@ fn route_access(
let target = node.part.map_or(focus::FocusTarget::Id(node.owner), |part| focus::FocusTarget::Part(node.owner, part));
focus::request_now(ctx, target);
}
<<<<<<< HEAD
if matches!(request.kind(), ActionKind::Click) {
routed.entry(owner).or_default().access_click = Some(node.part);
=======
}
if matches!(request.kind(), ActionKind::Increment | ActionKind::Decrement)
&& (node.part.is_none() || node.focusable)
&& let Some(row) = scalar_rows.iter().find(|row| node.owner == row.slider || Some(node.owner) == row.editor)
@@ -1090,7 +1089,6 @@ fn route_access(
routed.entry(Some(row.owner)).or_default().scalar_moves.push((movement, MoveMods::PLAIN));
}
return;
>>>>>>> 07a8c471ed
}
match request.kind() {
ActionKind::Focus if node.focusable => {}
+4 -13
View File
@@ -1,21 +1,12 @@
//! Trials of the icon lookup: the app icon registry (the catalog wins a clashing name, the first set keeps a name two
<<<<<<< HEAD
//! sets share), the set a theme's icon pack picks, and app icons' ordered colour runs and disabled silhouettes.
//! sets share), the set a theme's icon pack picks, the audio and broadcast icons in every set, app icons' ordered colour
//! runs and disabled silhouettes, and an app icon's layers by class.
use crate::primitives::{
AppIcons, Class, DataMode, Draw, DrawEnv, FlagMark, IconSpec, Layer, Mirror, PaintRecord, SvgIcon, icon_names, register_app_icons,
};
use crate::style::{Ink, StyleColor, UiTokens, ink_color, rgba_color};
=======
//! sets share), the set a theme's icon pack picks, the audio and broadcast icons in every set, and an app icon's layers
//! by class.
use crate::primitives::{
AppIcons, DataMode, Draw, DrawEnv, Glyph, IconSet, IconSpec, Layer, Mirror, PaintRecord, SvgIcon, TextRun, icon_names, paint_icon,
register_app_icons,
AppIcons, Class, DataMode, Draw, DrawEnv, FlagMark, Glyph, IconSet, IconSpec, Layer, Mirror, PaintRecord, SvgIcon, TextRun, icon_names,
paint_icon, register_app_icons,
};
use crate::style::{Ink, StyleColor, TypeRole, UiTokens, ink_color, rgba_color};
>>>>>>> 07a8c471ed
use crate::testing::{Frames, style, trial};
use craft_behavior::IconId;
use craft_i18n::Direction;