fw-sync fw-contract-runtime: resolve ui-contract runtime, egui glue, fonts, style, testing kit, manifest and runtime trials

Union of the port's and upstream next's changes: document-face chains carried onto
upstream's over-interface faces (one begin-pass edit), refused/declined commands and
requested pastes onto the rewritten command board (resolve_once, Instances), drop
operations beside region tokens in drag registration, wheel layers/exit gate/modal
family beside scroll_owner_inside, locate_wheel beside press records, text_edit
scroll + submit_key, both focus/policy additions, test module lists and trials.
This commit is contained in:
Dylan M. Taylor committed 2026-11-22 22:57:47 -05:00
1 parent cb3101725c
commit a9126c6a72
26 files changed
+227 -495

No files matched your search

+1 -5
View File
@@ -89,13 +89,9 @@ image = { version = "0.25", default-features = false, features = ["png"], option
# The window host's end hook sets `NSWindow.movable` through craft-window's AppKit code.
[target.'cfg(target_arch = "wasm32")'.dependencies]
# `screen::available`: whether the browser has the EyeDropper, read at install for `Caps::SCREEN_CAPTURE`.
<<<<<<< HEAD
craft-platform = { workspace = true, features = ["screen", "browser"] }
craft-platform = { workspace = true, features = ["screen", "browser", "clipboard"] }
# `egui/files.rs`: a pathless dropped file's bytes, which the page reads only asynchronously.
wasm-bindgen-futures = "0.4"
=======
craft-platform = { workspace = true, features = ["screen", "browser", "clipboard"] }
>>>>>>> origin/next
[target.'cfg(target_os = "macos")'.dependencies]
craft-window = { workspace = true, features = ["ui", "appkit"] }
+29 -62
View File
@@ -4,19 +4,17 @@
//! per frame; past [`MAX_DOCUMENT_FACES`] the faces the previous frame did not draw are taken out again, which keeps
//! memory to the faces on screen. Faces still on screen stay, however many there are.
//!
<<<<<<< HEAD
//! A face may name a chain of other document faces ([`FaceBytes::chain`]): a font split over several subsets (Word
//! embeds one subset per run of characters) draws each character from the first subset that has it, before the
//! interface family. The chains are linked in the begin-pass step after a face was added or taken out, when egui has
//! applied every face the pass before added.
=======
//! A face is drawn alone ([`DocumentFaces::face`]: a font sample shows what the face itself has) or over the interface
//! fonts ([`DocumentFaces::over_interface`]: document text such as an input method's composition, whose characters
//! the face lacks come from the interface stack, CJK included). A face over the interface fonts is installed by the
//! begin-pass step of the frame after it is asked for, as a family whose chain is the face followed by the
//! proportional family's: egui builds a family's chain from the definitions alone, so the chain is written into them
//! where nothing of the pass has queued definitions of its own.
>>>>>>> origin/next
//!
//! A face may name a chain of other document faces ([`FaceBytes::chain`]): a font split over several subsets (Word
//! embeds one subset per run of characters) draws each character from the first subset that has it, before the
//! interface family. The chains are linked in the begin-pass step after a face was added or taken out, when egui has
//! applied every face the pass before added.
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
@@ -34,17 +32,13 @@ pub const DOCUMENT_FACES_PER_PASS: usize = 6;
/// The faces kept before the ones the previous frame did not draw are taken out.
pub const MAX_DOCUMENT_FACES: usize = 64;
<<<<<<< HEAD
/// The bytes of a face, its index in a collection, its variation coordinates (axis tag, value) and the faces that
/// draw what it lacks.
=======
/// The largest font file a face over the interface fonts is drawn from, in bytes (16 MiB). egui parses every face of
/// the definitions again whenever they change, and a document's CJK fallback can be far larger (Microsoft YaHei is
/// about 19 MB): text in a larger face is drawn in the interface fonts.
pub const MAX_INTERFACE_FACE_BYTES: usize = 16 << 20;
/// The bytes of a face, its index in a collection and its variation coordinates (axis tag, value).
>>>>>>> origin/next
/// The bytes of a face, its index in a collection, its variation coordinates (axis tag, value) and the faces that
/// draw what it lacks.
#[derive(Clone)]
#[non_exhaustive]
pub struct FaceBytes {
@@ -101,7 +95,7 @@ pub enum FaceState {
Unavailable,
}
/// A registered face: the frame it was last drawn in, the frame it was added in and the keys of its chain.
/// A registered face: the frame it was last drawn in, the frame it was added in and the families of its chain.
struct Registered {
used: u64,
added: u64,
@@ -145,13 +139,9 @@ impl Registry {
for name in &stale {
self.faces.remove(name);
}
<<<<<<< HEAD
self.relink |= !stale.is_empty();
stale.iter().map(|key| family_name(key)).collect()
=======
self.pending.retain(|(name, _)| !stale.contains(name));
self.relink |= !stale.is_empty();
stale
>>>>>>> origin/next
}
/// The family of every face with a chain, with the families of its chain's registered faces in order.
@@ -159,17 +149,17 @@ impl Registry {
self.faces
.iter()
.filter(|(_, face)| !face.chain.is_empty())
.map(|(key, face)| {
let chain = face.chain.iter().filter(|link| *link != key && self.faces.contains_key(*link)).map(|link| family_name(link)).collect();
(family_name(key), chain)
.map(|(name, face)| {
let chain = face.chain.iter().filter(|link| *link != name && self.faces.contains_key(*link)).cloned().collect();
(name.clone(), chain)
})
.collect()
}
/// Marks the face `key` and the faces of its chain drawn in this frame.
fn mark_drawn(&mut self, key: &str) {
/// Marks the face of the family `name` and the faces of its chain drawn in this frame.
fn mark_drawn(&mut self, name: &str) {
let frame = self.frame;
let Some(face) = self.faces.get_mut(key) else { return };
let Some(face) = self.faces.get_mut(name) else { return };
face.used = frame;
let chain = face.chain.clone();
for link in &chain {
@@ -206,33 +196,21 @@ enum Known {
New,
}
<<<<<<< HEAD
/// The begin-pass step: starts the frame, evicts the faces past the cap and, after a face was added or taken out,
/// links the chains. Both happen only here, before any install of the pass can queue its definitions, because they
/// rebuild them from the applied ones; egui has applied the faces the previous pass added before this step runs.
/// The begin-pass step: starts the frame, evicts the faces past the cap, installs the faces over the interface fonts
/// the last frame loaded and, after a face was added or taken out, links the chains. All happen only here, in one
/// edit, before any install of the pass can queue its definitions, because they rebuild them from the applied ones;
/// egui has applied the faces the previous pass added before this step runs.
fn begin_pass(ctx: &Context) {
let now = pass::root_frame_nr(ctx);
let changed = memory::with::<Registry, _>(ctx, |registry| {
registry.begin(now);
let stale = registry.evict(now);
std::mem::take(&mut registry.relink).then(|| (stale, registry.chains()))
let pending = std::mem::take(&mut registry.pending);
let relink = std::mem::take(&mut registry.relink);
(relink || !pending.is_empty()).then(|| (stale, pending, registry.chains()))
});
if let Some((stale, chains)) = changed {
egui_fonts::set_document_faces(ctx, &stale, &chains);
=======
/// The begin-pass step: starts the frame, evicts the faces past the cap and installs the faces over the interface fonts
/// the last frame loaded. Both happen only here, in one edit, before any install of the pass can queue its
/// definitions, because they rebuild them from the applied ones.
fn begin_pass(ctx: &Context) {
let now = pass::root_frame_nr(ctx);
let (stale, pending) = memory::with::<Registry, _>(ctx, |registry| {
registry.begin(now);
let stale = registry.evict(now);
(stale, std::mem::take(&mut registry.pending))
});
if !stale.is_empty() || !pending.is_empty() {
egui_fonts::edit_faces(ctx, &stale, pending);
>>>>>>> origin/next
if let Some((stale, pending, chains)) = changed {
egui_fonts::edit_faces(ctx, &stale, pending, &chains);
}
}
@@ -273,15 +251,9 @@ impl DocumentFaces {
let (now, known) = memory::with::<Registry, _>(ctx, |registry| {
let known = if registry.failed.contains(&name) {
Known::Failed
<<<<<<< HEAD
} else if let Some(added) = registry.faces.get(key).map(|face| face.added) {
registry.mark_drawn(key);
} else if let Some(added) = registry.faces.get(&name).map(|face| face.added) {
registry.mark_drawn(&name);
Known::Added(added)
=======
} else if let Some(face) = registry.faces.get_mut(&name) {
face.used = registry.frame;
Known::Added(face.added)
>>>>>>> origin/next
} else {
Known::New
};
@@ -313,12 +285,6 @@ impl DocumentFaces {
});
return FaceState::Unavailable;
};
<<<<<<< HEAD
egui_fonts::add_family_face(ctx, &family, bytes.data());
memory::with::<Registry, _>(ctx, |registry| {
registry.faces.insert(key.to_owned(), Registered { used: now, added: now, chain: bytes.chain });
registry.relink = true;
=======
if kind == Kind::Alone {
egui_fonts::add_family_face(ctx, &family, bytes.data());
}
@@ -327,8 +293,9 @@ impl DocumentFaces {
registry.pending.retain(|(pending, _)| *pending != name);
registry.pending.push((name.clone(), bytes.data()));
}
registry.faces.insert(name.clone(), Registered { used: now, added: now })
>>>>>>> origin/next
let chain = bytes.chain.iter().map(|link| Kind::Alone.family_name(link)).collect();
registry.faces.insert(name.clone(), Registered { used: now, added: now, chain });
registry.relink = true;
});
FaceState::Loading
}
@@ -122,14 +122,9 @@ pub(crate) fn report_text(ctx: &Context, owner: Id, facts: &TextFacts, value_ove
let (focus_node, focus_at) = end_of(&entries, owner, focus)?;
Some((anchor_node, anchor_at, focus_node, focus_at))
});
<<<<<<< HEAD
// An empty editor can name a mixed value without turning its label into editable text.
let value = (!facts.masked).then_some(if facts.text.is_empty() { value_override.unwrap_or(&facts.text) } else { &facts.text });
adapter::write_text(ctx, owner, &TextNode { value, editable: facts.editable, selection });
=======
let value = (!facts.masked).then_some(facts.text.as_str());
adapter::write_text(ctx, owner, &TextNode { value, editable: facts.editable, disabled: facts.disabled, selection });
>>>>>>> origin/next
Service::<Tables>::run(ctx, |tables| tables.0.insert(owner, entries));
}
@@ -800,13 +800,9 @@ impl Board {
catalog_label: def.map(|def| Arc::from(def.label.as_str())),
icon: state.and_then(|s| s.icon_ref().cloned()).or_else(|| def.and_then(|def| def.icon.clone())),
chord,
<<<<<<< HEAD
chord_text,
enabled: flags.enabled && !refused,
refused,
=======
chord_text,
enabled: flags.enabled && modal && live && !matches!(declaring, Some(Declaration::Focused { inactive: true })),
>>>>>>> origin/next
checked: flags.checked,
marked: state.is_some_and(CommandState::is_marked),
hint: state.and_then(|s| s.hint_ref().cloned()),
@@ -1344,6 +1340,7 @@ fn resolve_in(
let gate = board.gate_answer(command);
if gate.is_some_and(|(_, allowed)| !allowed) {
resolved.enabled = false;
resolved.refused = true;
}
let view = board.view_gens(pass::current_viewport(ctx));
let key = ResolveKey {
@@ -1361,13 +1358,6 @@ fn resolve_in(
if first_unknown {
log::warn!("the command {} is in no registered command set: it is an app command with its id as its label", command.id);
}
<<<<<<< HEAD
if gate.is_some_and(|gate| !gate.allows(command)) {
resolved.enabled = false;
resolved.refused = true;
}
=======
>>>>>>> origin/next
(resolved, key)
}
@@ -1635,24 +1625,18 @@ fn queue(ctx: &Context, fired: Fired) {
pub(crate) fn fall_through(ctx: &Context, command: craft_behavior::EditCommand) {
let Some(command) = EditCommands::of(command) else { return };
let command = CommandRef::from(command);
<<<<<<< HEAD
// The focused component already declined the command: it answers for it no more.
let from = with(ctx, |board| Vantage { edits: Some(EditSet::NONE), inactive: Some(EditSet::NONE), ..board.here.clone() });
let (app, instance) = with(ctx, |board| board.target_of(ctx, &command, &from));
if !app && instance.is_none() {
return;
}
let (resolved, _) = resolve_in(ctx, &command, instance, Reach::Focus, Some(&from));
let resolved = resolve_once(ctx, &command, instance, Reach::Focus, Some(&from));
if !resolved.enabled {
return;
}
// An app-scope command a modal layer's instance declares is delivered to that instance.
let target = if app { resolved.instance } else { instance };
=======
#[cfg(feature = "testing")]
measure::count_resolve(ctx, Resolve::New);
let target = with(ctx, |board| board.resolve(ctx, &command, None, Reach::Focus, &board.here, &mut Reads::default()).0.instance);
>>>>>>> origin/next
let fired = Fired { target, ..Fired::new(command, FireSource::Key, FirePhase::Press, pass::now(ctx)) };
with(ctx, |board| if fired.target.is_some() { board.queue.push(fired) } else { board.out.push(fired) });
repaint::request_of(ctx, ViewportId::ROOT);
@@ -1682,7 +1666,7 @@ pub(crate) fn request_paste_at(ctx: &Context, at: egui::Pos2) {
if !app && instance.is_none() {
return;
}
let (resolved, _) = resolve_in(ctx, &command, instance, Reach::Focus, None);
let resolved = resolve_once(ctx, &command, instance, Reach::Focus, None);
if !resolved.enabled {
return;
}
@@ -1732,7 +1716,7 @@ fn fire_in(ctx: &Context, command: &CommandRef, source: FireSource, from: Option
let target = if app { resolved.instance } else { instance };
// A command fired from no component of the window (a native menu, the palette) closes the open popups, as a key's
// command and a menu pick do, except the popup its instance is in and the popups it was opened from.
let inside: Vec<Id> = with(ctx, |board| target.and_then(|target| board.instances.iter().find(|i| i.id == target)?.layer).into_iter().collect());
let inside: Vec<Id> = with(ctx, |board| target.and_then(|target| board.instances.get(target)?.layer).into_iter().collect());
overlay::close_popups_outside(ctx, &inside);
queue(ctx, Fired { target, ..Fired::new(command.clone(), source, FirePhase::Press, pass::now(ctx)) });
true
@@ -1858,13 +1842,9 @@ pub(crate) fn binds_scoped(ctx: &Context, chord: &Chord) -> bool {
let instance = board.innermost(&chain, board.scope_of(&command));
Some((command, instance, chain))
});
<<<<<<< HEAD
// Key routing runs before the command board refreshes its focus vantage for this pass. Check the actual focused
// chain, so a focus that just entered a modal can reach its own commands without opening the modal to outsiders.
found.is_some_and(|(command, instance, chain)| resolve_in(ctx, &command, instance, Reach::Chain(&chain), None).0.enabled)
=======
found.is_some_and(|(command, instance)| resolve_once(ctx, &command, instance, Reach::Focus, None).enabled)
>>>>>>> origin/next
found.is_some_and(|(command, instance, chain)| resolve_once(ctx, &command, instance, Reach::Chain(&chain), None).enabled)
}
/// Where a shortcut pressed with focus in a menu or on a menu bar matches, and where a hit gives the focus back. The
+2 -10
View File
@@ -26,23 +26,15 @@ pub use board::declare_child;
pub use board::focus_within;
pub use board::keymap;
#[doc(hidden)]
<<<<<<< HEAD
pub use board::keymap_builds;
pub use board::note_page_root;
#[cfg(feature = "testing")]
pub(crate) use board::observe_fired;
=======
pub use board::note_page_root;
>>>>>>> origin/next
pub(crate) use board::publish as publish_for;
pub(crate) use board::runs_now;
pub(crate) use board::take as take_for_instance;
pub(crate) use board::{
<<<<<<< HEAD
begin, binds_scoped, edit_chords, end, install, note_focus, platform, register_instance, set_input, take_declined, take_delivered, take_fired,
begin, binds_scoped, edit_chords, end, install, note_focus, register_instance, set_input, take_declined, take_delivered, take_fired,
window_shortcuts,
=======
begin, binds_scoped, edit_chords, end, install, note_focus, register_instance, set_input, take_delivered, take_fired, window_shortcuts,
>>>>>>> origin/next
};
#[doc(hidden)]
pub use board::{bound_around, keymap_generation, take_around};
+14 -55
View File
@@ -74,7 +74,7 @@ pub enum DropMark {
},
}
crate::stays!(Arc<crate::style::UiTokens>);
crate::stays!(Arc<crate::style::UiTokens>, DropOperation);
impl crate::runtime::Shift for DropMark {
fn shifted(&self, by: &egui::RecordShift) -> Self {
@@ -284,13 +284,10 @@ struct Registration {
/// The overlay layer whose body registered the target; `None` for the window's own content.
scope: Option<Id>,
mark: DropMark,
<<<<<<< HEAD
/// What a drop on the target does with the keys held now; the pointer shows it while the target wins.
op: DropOperation,
=======
/// The tokens of the target's region.
tokens: Arc<UiTokens>,
>>>>>>> origin/next
/// The target covers the whole window: any target over a component beats it.
window: bool,
}
@@ -462,7 +459,7 @@ fn os_files(ctx: &Context) {
let viewport = pass::current_viewport(ctx);
let hovering = !seen.hovered.is_empty();
let host = WindowHost::of(ctx);
let position = if host.desktop_pointer().is_some() { host.pointer_in(viewport) } else { pointer::frame(ctx).pos };
let position = if host.desktop_pointer().is_some() { host.pointer_in(viewport) } else { pointer::frame_raw(ctx).pos };
let positioned = position.is_some();
// A window target can take the drop immediately only if the pointer has not moved since resolution.
let window_winner = PerViewport::<Targets>::with(ctx, viewport, |targets| targets.winner_window && targets.pointer == position);
@@ -600,21 +597,14 @@ pub(crate) fn show_mark(ctx: &Context, mark: Option<DropMark>) {
});
}
<<<<<<< HEAD
/// Records that `owner`'s `ordinal`th target on `layer` accepts at the pointer a drop doing `op`, with its mark in
/// layer space. A `window` target covers the whole window.
pub(crate) fn register(ctx: &Context, owner: Id, layer: Layer, mark: DropMark, op: DropOperation, window: bool) {
crate::runtime::replay::journal(ctx, || move |ctx: &Context| register(ctx, owner, layer, mark, op, window));
=======
/// Records that `owner`'s `ordinal`th target on `layer` accepts at the pointer, with its mark in layer space and the
/// tokens of the target's region. A `window` target covers the whole window.
pub(crate) fn register(ctx: &Context, owner: Id, layer: Layer, mark: DropMark, tokens: Arc<UiTokens>, window: bool) {
/// layer space and the tokens of the target's region. A `window` target covers the whole window.
pub(crate) fn register(ctx: &Context, owner: Id, layer: Layer, mark: DropMark, op: DropOperation, tokens: Arc<UiTokens>, window: bool) {
crate::runtime::replay::journal(
ctx,
|| (owner, layer, mark, tokens.clone(), window),
|ctx, (owner, layer, mark, tokens, window)| register(ctx, *owner, *layer, *mark, tokens.clone(), *window),
|| (owner, layer, mark, op, tokens.clone(), window),
|ctx, (owner, layer, mark, op, tokens, window)| register(ctx, *owner, *layer, *mark, *op, tokens.clone(), *window),
);
>>>>>>> origin/next
let mark = match areas::layer_map(ctx, layer) {
Some(map) => mark.mapped(|point| map.to_screen(point)),
None => mark,
@@ -622,11 +612,7 @@ pub(crate) fn register(ctx: &Context, owner: Id, layer: Layer, mark: DropMark, t
let scope = overlay::drawing_parent(ctx);
PerViewport::<Targets>::with(ctx, pass::current_viewport(ctx), |targets| {
let ordinal = targets.this.iter().filter(|registration| registration.owner == owner).count() as u32;
<<<<<<< HEAD
targets.this.push(Registration { owner, ordinal, layer, scope, mark, op, window });
=======
targets.this.push(Registration { owner, ordinal, layer, scope, mark, tokens, window });
>>>>>>> origin/next
targets.this.push(Registration { owner, ordinal, layer, scope, mark, op, tokens, window });
});
}
@@ -644,15 +630,9 @@ pub fn next_ordinal(ctx: &Context, owner: Id) -> u32 {
})
}
<<<<<<< HEAD
/// The operation the held modifiers pick now over a target that copies with `copy`.
pub(crate) fn current_operation(ctx: &Context, copy: CopyKeys) -> DropOperation {
operation(ctx, pointer::frame(ctx).mods, copy)
=======
/// The operation the held modifiers pick now.
pub(crate) fn current_operation(ctx: &Context) -> DropOperation {
operation(ctx, pointer::frame_raw(ctx).mods)
>>>>>>> origin/next
operation(ctx, pointer::frame_raw(ctx).mods, copy)
}
/// Whether the session's button was released in this pass.
@@ -712,11 +692,7 @@ pub(crate) fn target_of<T: DropTarget<dyn Any + Send + Sync>>(
let op = current_operation(ctx, target.copy_keys());
let drop = target.accept(&*payload, at, op)?;
let ordinal = next_ordinal(ctx, owner);
<<<<<<< HEAD
register(ctx, owner, zone.layer, target.mark(&drop), op, false);
=======
register(ctx, owner, zone.layer, target.mark(&drop), tokens, false);
>>>>>>> origin/next
register(ctx, owner, zone.layer, target.mark(&drop), op, tokens, false);
take_drop(ctx, owner, ordinal, op, payload_type).then_some(drop)
}
@@ -771,7 +747,7 @@ pub(crate) fn ended<P: 'static>(ctx: &Context, source: Id) -> Option<DropOperati
pub(crate) fn end_pass(ctx: &Context) {
let viewport = pass::current_viewport(ctx);
let host = WindowHost::of(ctx);
let position = if host.desktop_pointer().is_some() { host.pointer_in(viewport) } else { pointer::frame(ctx).pos };
let position = if host.desktop_pointer().is_some() { host.pointer_in(viewport) } else { pointer::frame_raw(ctx).pos };
// A modal holds input: targets on layers below it, and on the window, never accept.
let scopes: Vec<Option<Id>> =
PerViewport::<Targets>::with(ctx, viewport, |targets| targets.this.iter().map(|registration| registration.scope).collect());
@@ -786,28 +762,17 @@ pub(crate) fn end_pass(ctx: &Context) {
.filter(|(at, _)| open[*at])
.max_by_key(|(at, registration)| (!registration.window, areas::layer_position(ctx, registration.layer), *at))
.map(|(_, registration)| registration);
<<<<<<< HEAD
targets.winner_window = best.is_some_and(|registration| registration.window);
targets.pointer = position;
let best = best.map(|registration| ((registration.owner, registration.ordinal), (registration.mark, registration.op)));
targets.winner = best.map(|(key, _)| key);
=======
let best = best.map(|registration| ((registration.owner, registration.ordinal), (registration.mark, registration.tokens.clone())));
let best =
best.map(|registration| ((registration.owner, registration.ordinal), (registration.mark, registration.op, registration.tokens.clone())));
targets.winner = best.as_ref().map(|(key, _)| *key);
>>>>>>> origin/next
targets.this.clear();
best.map(|(_, won)| won)
});
<<<<<<< HEAD
let over_this_window = pointer::frame(ctx).pos.is_some();
let primary_down = pointer::with_pass_pointer(ctx, |pointer| pointer.primary_down);
let buttons = pointer::frame(ctx).buttons;
=======
let op = current_operation(ctx);
let over_this_window = pointer::frame_raw(ctx).pos.is_some();
let primary_down = pointer::with_pass_raw(ctx, |pointer| pointer.primary_down);
let buttons = pointer::frame_raw(ctx).buttons;
>>>>>>> origin/next
let frame = pass::root_frame_nr(ctx);
let held = board(ctx, |board| board.session.as_ref().map(|session| (session.os, session.button, session.dropped))).is_none_or(
|(os, button, dropped)| match (os, button) {
@@ -833,15 +798,9 @@ pub(crate) fn end_pass(ctx: &Context) {
}
}
if let Some(session) = &mut board.session {
<<<<<<< HEAD
match winner {
Some((mark, _)) => session.mark = Some((viewport, mark)),
None if session.mark.is_some_and(|(marked, _)| marked == viewport) => session.mark = None,
=======
match &winner {
Some((mark, tokens)) => session.mark = Some(ShownMark { viewport, mark: *mark, tokens: tokens.clone() }),
Some((mark, _, tokens)) => session.mark = Some(ShownMark { viewport, mark: *mark, tokens: tokens.clone() }),
None if session.mark.as_ref().is_some_and(|shown| shown.viewport == viewport) => session.mark = None,
>>>>>>> origin/next
None => {}
}
}
@@ -859,7 +818,7 @@ pub(crate) fn end_pass(ctx: &Context) {
if running && over_this_window {
match winner {
None => cursor::request(ctx, Cursor::System(CursorIcon::NotAllowed), CursorPriority::Drag),
Some((_, op)) => {
Some((_, op, _)) => {
let icon = match op {
DropOperation::Copy => CursorIcon::Copy,
DropOperation::Link => CursorIcon::Alias,
+13 -24
View File
@@ -70,20 +70,27 @@ pub(crate) fn has_family(ctx: &Context, family: &FontRef) -> bool {
ctx.fonts(|fonts| fonts.definitions().families.contains_key(&family.family()))
}
<<<<<<< HEAD
/// Takes the faces called `gone`, and the families of those names, out of egui's definitions and out of every family
/// that lists them. Then each `(name, chain)` family of a face named after it lists its own face first, then the
/// faces of `chain` that egui holds, in order, then the faces it listed besides (those script coverage added).
/// that lists them, and adds each face of `over_interface` under its name with a family of that name: the face, then
/// the proportional family's chain, so what the face lacks the interface fonts draw. Then each `(name, chain)` family
/// of a face named after it lists its own face first, then the faces of `chain` that egui holds, in order, then the
/// faces it listed besides (the interface chain, those script coverage added).
/// It rebuilds the definitions from the applied ones, so call it only from a begin-pass step, before an install of the
/// pass can queue its own.
pub(crate) fn set_document_faces(ctx: &Context, gone: &[String], chains: &[(String, Vec<String>)]) {
pub(crate) fn edit_faces(ctx: &Context, gone: &[String], over_interface: Vec<(String, FontData)>, chains: &[(String, Vec<String>)]) {
let mut definitions = ctx.fonts(|fonts| fonts.definitions().clone());
let mut changed = !gone.is_empty();
let mut changed = !gone.is_empty() || !over_interface.is_empty();
definitions.font_data.retain(|name, _| !gone.contains(name));
definitions.families.retain(|family, _| !matches!(family, FontFamily::Name(name) if gone.iter().any(|g| g.as_str() == &**name)));
definitions.families.retain(|family, _| !matches!(family, FontFamily::Name(name) if gone.iter().any(|gone| gone.as_str() == &**name)));
for names in definitions.families.values_mut() {
names.retain(|name| !gone.contains(name));
}
let interface = definitions.families.get(&FontFamily::Proportional).cloned().unwrap_or_default();
for (name, data) in over_interface {
let chain = std::iter::once(name.clone()).chain(interface.iter().filter(|face| **face != name).cloned()).collect();
definitions.families.insert(FontFamily::Name(name.as_str().into()), chain);
definitions.font_data.insert(name, Arc::new(data));
}
for (name, chain) in chains {
if !definitions.font_data.contains_key(name) {
continue;
@@ -100,24 +107,6 @@ pub(crate) fn set_document_faces(ctx: &Context, gone: &[String], chains: &[(Stri
if changed {
set_definitions(ctx, definitions);
}
=======
/// Takes the faces called `gone`, and the families of those names, out of egui's definitions, and adds each face of
/// `over_interface` under its name with a family of that name: the face, then the proportional family's chain, so
/// what the face lacks the interface fonts draw.
/// It rebuilds the definitions from the applied ones, so call it only from a begin-pass step, before an install of the
/// pass can queue its own.
pub(crate) fn edit_faces(ctx: &Context, gone: &[String], over_interface: Vec<(String, FontData)>) {
let mut definitions = ctx.fonts(|fonts| fonts.definitions().clone());
definitions.font_data.retain(|name, _| !gone.contains(name));
definitions.families.retain(|family, _| !matches!(family, FontFamily::Name(name) if gone.iter().any(|gone| gone.as_str() == &**name)));
let interface = definitions.families.get(&FontFamily::Proportional).cloned().unwrap_or_default();
for (name, data) in over_interface {
let chain = std::iter::once(name.clone()).chain(interface.iter().filter(|face| **face != name).cloned()).collect();
definitions.families.insert(FontFamily::Name(name.as_str().into()), chain);
definitions.font_data.insert(name, Arc::new(data));
}
set_definitions(ctx, definitions);
>>>>>>> origin/next
}
/// Whether egui's definitions hold the face called `name`.
@@ -46,14 +46,11 @@ pub(crate) struct Edit<'a> {
/// The screen y of the baseline a single line without a laid-out galley sits on: its control's line's, which a
/// text in another face (mono digits) shares. `None` centres the line's row on the rect's centre line.
pub baseline: Option<f32>,
<<<<<<< HEAD
/// The Enter chord that submits a multi-line text; the line break takes the other one.
pub submit_key: SubmitKey,
=======
/// How far a multi-line text taller than `rect` is scrolled up inside it, in points; the text part owns the offset
/// (`text_adapter`), and a single line or a laid-out galley ignores it.
pub scroll: f32,
>>>>>>> origin/next
/// The Enter chord that submits a multi-line text; the line break takes the other one.
pub submit_key: SubmitKey,
}
/// What the widget did in one pass.
@@ -99,11 +96,8 @@ pub(crate) fn show(ui: &mut Ui, env: &crate::runtime::env::Env, edit: Edit<'_>)
underline,
galley,
baseline,
<<<<<<< HEAD
submit_key,
=======
scroll,
>>>>>>> origin/next
submit_key,
} = edit;
// egui inserts the line break itself before the adapter sees the Enter, so the chord that submits must not be the
// one egui breaks the line on: under `Enter` the line break is Shift+Enter and plain Enter reaches `entered` untaken.
+1 -6
View File
@@ -8,13 +8,8 @@ use super::{Env, Restore, Scoped};
use crate::runtime::egui::child;
use craft_behavior::MotionMode;
use craft_i18n::{Direction, WordRows, Words};
<<<<<<< HEAD
use craft_theme::{ControlSize, Mode};
use egui::{Context, Rect, Ui, UiBuilder};
=======
use craft_theme::{Contrast, ControlSize, Mode, Size, ThemeDef};
use egui::{Context, Ui};
>>>>>>> origin/next
use egui::{Context, Rect, Ui, UiBuilder};
use std::sync::Arc;
/// Token-changing values for a container: the container itself (its surface, header, rules, scroll bars, pads and
+2 -3
View File
@@ -693,7 +693,6 @@ pub fn request(ctx: &Context, target: FocusTarget) -> bool {
true
}
<<<<<<< HEAD
/// Takes the one-shot request of the component `id` (`Props::request_focus`) right after its stops registered in the
/// running pass: its own stop, else its first part stop, takes the focus as a layer's initial stop does, so the press
/// of the pass does not take it back. A component with no stop this pass (a disabled one) takes none, and a
@@ -712,12 +711,12 @@ pub(crate) fn take_request(ctx: &Context, id: Id, request: FocusRequest) {
state.focus_stop(rec)
});
apply(ctx, acts);
=======
}
/// Whether focus is on the component `id` or on one of its parts (a canvas's editor part), from the focus record of
/// the stop focus is on. An app asks it of a component it shows, such as whether its document canvas has focus.
pub fn has(ctx: &Context, id: Id) -> bool {
focused_rec(ctx).is_some_and(|rec| rec.stop.id == id)
>>>>>>> origin/next
}
/// Applies `target` now, for an AccessKit `Focus` action, which moves focus in the pass that carries it.
@@ -496,18 +496,17 @@ impl KeyUse {
self
}
<<<<<<< HEAD
/// The same use with `nudge_mods` as the modifiers a document canvas acts on with the arrows.
pub const fn with_nudge_mods(mut self, nudge_mods: NudgeMods) -> Self {
self.nudge_mods = nudge_mods;
self
=======
}
/// Whether the component is a document canvas's editor part: the document (`chrome_key`) holding its editor's
/// text keys. It types letters as a text field does, but it is the document the window's menu keys act over, not
/// a field inside the chrome.
pub const fn is_document_editor(&self) -> bool {
self.chrome_key && matches!(self.owner, OwnerClass::Text)
>>>>>>> origin/next
}
/// Whether the component claims `chord`.
+4 -6
View File
@@ -22,11 +22,7 @@ pub use claims::capture;
pub use claims::claim;
#[doc(hidden)]
pub use claims::take_claimed;
<<<<<<< HEAD
pub(crate) use claims::{fire_claimed, hold_escape};
=======
pub(crate) use claims::take_first_claimed;
>>>>>>> origin/next
pub(crate) use claims::{fire_claimed, hold_escape, take_first_claimed};
/// The types `Intents` reads and returns, for an app that reads the window's intents (`with_window_intents`).
pub use craft_behavior::{AccessRequest, Intent, MoveMods, NavMove, PartRef};
pub(crate) use input::{claims_press, count_sent, input_hook, keys_state, queue_nav, sent, take_menu_keys, take_nav};
@@ -48,7 +44,9 @@ pub(crate) use intents::{
pub use intents::{with_canvas_window_intents, with_window_intents};
pub(crate) use nodes::{redirect_node, register_expanded, register_node};
pub use route::focus_holds;
pub(crate) use route::{activated_member, begin, focus_in_modal_dialog, layout_of, owner_at, pasted, pasted_text, queue_edit, routed_to, take_shortcuts};
pub(crate) use route::{
activated_member, begin, focus_in_modal_dialog, layout_of, owner_at, pasted, pasted_text, queue_edit, routed_to, take_shortcuts,
};
/// A menu-bar key of an in-window bar (spec 9.7). F10 reaches the bar on every OS; Alt keys only off a Mac.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+3 -11
View File
@@ -50,16 +50,13 @@ struct Strip<'a> {
no_stops: bool,
/// egui holds a label text selection, which a copy or cut event copies.
label_selection: bool,
<<<<<<< HEAD
/// The focus is in a menu (`FocusedRecord::menu`).
in_menu: bool,
=======
/// An Alt release in this input ended an Alt+numpad code (`raw_input::take_alt_code_ended`): the code's digits
/// never reach this stage, so without this the release would read as a lone Alt.
alt_code_ended: bool,
/// Whether the window's keymap binds a chord to a command that is enabled now (`commands::runs_now`).
bound: &'a dyn Fn(&Chord) -> bool,
>>>>>>> origin/next
}
impl Strip<'_> {
@@ -488,14 +485,11 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec<Arriv
let window_shortcuts = commands::window_shortcuts(ctx);
let no_stops = keys.is_none() && !record.foreign && focus::tab_from_nothing(ctx, viewport);
let latin = &input.latin_layout_chars;
<<<<<<< HEAD
let requested_paste = commands::board::has_pending_paste(ctx, viewport);
let mut requested_content = None::<commands::ClipContent>;
=======
// S-L177: an Alt chord's text is withheld only when the press can run its command; a bound command that is
// disabled (Word's Alt+Shift+- Collapse outside Outline) leaves the text typed (Option+Shift+- is an em dash).
let bound = |chord: &Chord| commands::runs_now(ctx, chord);
>>>>>>> origin/next
let (batch, visible, later) = with(ctx, viewport, |stage| {
let claims = stage_claims(&record, stage);
let edits = |command| keys.is_some_and(|keys| keys.edits.contains(command));
@@ -518,12 +512,9 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec<Arriv
canvas,
no_stops,
label_selection: record.label_selection,
<<<<<<< HEAD
in_menu: record.menu.is_some(),
=======
alt_code_ended,
bound: &bound,
>>>>>>> origin/next
};
let mut batch = Batch::default();
let mut visible = None;
@@ -556,8 +547,9 @@ pub(crate) fn input_hook(ctx: &Context, input: &RawInput, events: &mut Vec<Arriv
visible = match &read {
KeyEvent::PointerPress => Some(false),
// An accessibility activation is not the preceding key: a menu it opens must wait for its own navigation.
KeyEvent::Access(action)
if matches!(action.kind(), raw_input::ActionKind::Click | raw_input::ActionKind::ShowContextMenu) => Some(false),
KeyEvent::Access(action) if matches!(action.kind(), raw_input::ActionKind::Click | raw_input::ActionKind::ShowContextMenu) => {
Some(false)
}
KeyEvent::Press { .. } | KeyEvent::Text(_) => Some(true),
_ => visible,
};
+1 -6
View File
@@ -767,18 +767,13 @@ fn route_access(ctx: &Context, request: &Action, nodes: &HashMap<u64, Node>, rou
/// The components the running pass's intents are routed to (keys, AccessKit requests, edits): a memoized view that
/// holds one runs, so the component takes them.
pub(crate) fn routed_to(ctx: &Context) -> Vec<Id> {
<<<<<<< HEAD
let mut ids: Vec<Id> = current(ctx, |stage| stage.routed.keys().flatten().copied().collect());
ids.extend(crate::contract::steps::scroll_owner::move_targets(ctx));
ids
=======
let (mut routed, menu_keys) = current(ctx, |stage| (stage.routed.keys().flatten().copied().collect::<Vec<_>>(), !stage.menu.is_empty()));
// The menu keys of the pass go to the menu bar the last pass registered.
if menu_keys {
routed.extend(focus::menu_bar(ctx, crate::runtime::egui::pass::current_viewport(ctx)));
}
routed.extend(crate::contract::steps::scroll_owner::move_targets(ctx));
routed
>>>>>>> origin/next
}
/// The member whose `Activate` the group `root` reads this pass.
-11
View File
@@ -168,15 +168,10 @@ pub(crate) fn begin(ctx: &Context, hit: HitSizes, latched: craft_keymap::Mods) {
// Every pass reads its own input and the frame's latches, so a second pass of a frame builds the same
// modifiers from its own (event-free) input and counts no press twice.
let mods = with_latched(read.mods, latched);
<<<<<<< HEAD
let press_mods = read.press_mods.map(|mods| with_latched(mods, latched));
// A drag that started in another window reaches this one through the desktop pointer (8.4).
if read.pos.is_none() {
=======
// A drag that started in another window reaches this one through the desktop pointer (8.4), never at the place
// this window saw the pointer last: the source window holds the pointer, and the window may have had no exit.
if drag::runs_elsewhere(ctx, viewport) {
>>>>>>> origin/next
read.pos = drag::cross_window_pointer(ctx, viewport);
}
let wheel = input::wheel_read(ctx, WHEEL_LINE_POINTS, WHEEL_PAGE_POINTS);
@@ -920,16 +915,10 @@ fn find_under(ctx: &Context, viewport: ViewportId, at: Pos2, targets: PressTarge
type Ranked = ((u8, u32), Winner<Id>, Id, bool);
/// The press winners among `ranked`, each root's topmost shape under a point that takes a press with its rank and
<<<<<<< HEAD
/// whether the root takes clicks anywhere, and under a top shape that passes its drag the root's next shape that drags:
/// by the per-kind rule of [`PressWinners`].
fn winners_of(mut ranked: Vec<((u8, u32), Winner<Id>, Id, bool)>) -> PressWinners {
ranked.sort_by(|a, b| b.0.cmp(&a.0));
=======
/// whether the root takes clicks anywhere: by the per-kind rule of [`PressWinners`].
fn winners_of(mut ranked: Vec<Ranked>) -> PressWinners {
ranked.sort_by_key(|entry| std::cmp::Reverse(entry.0));
>>>>>>> origin/next
let mut winners = PressWinners::default();
for (_, winner, root, root_clicks) in ranked {
let (clicks, drags) = (winner.sense.contains(craft_behavior::Sense::CLICK), winner.sense.contains(craft_behavior::Sense::DRAG));
+3 -16
View File
@@ -12,11 +12,7 @@ use craft_behavior::{
GESTURE_GAP, PointerButton, PointerEvent, Wheel, WheelEase, WheelFocus, WheelGesture, WheelPhase, WheelSource, WheelTaker, WheelUnit,
};
use craft_keymap::Mods;
<<<<<<< HEAD
use egui::{Context, Id, IdMap, Pos2, Rect, Vec2};
=======
use egui::{Context, Id, Pos2, Vec2};
>>>>>>> origin/next
use egui::{Context, Id, IdMap, Pos2, Vec2};
#[derive(Default)]
pub(crate) struct State {
@@ -155,20 +151,15 @@ impl State {
/// Registers a taker for next pass's split. A layer that fades out takes no input, so a taker in its body registers
/// none: it would hold the wheel over what already shows through it.
pub(crate) fn register(ctx: &Context, taker: WheelTaker<Id>) {
<<<<<<< HEAD
if crate::runtime::overlay::drawing_exiting(ctx) {
return;
}
crate::runtime::replay::journal(ctx, || move |ctx: &Context| register(ctx, taker));
crate::runtime::replay::journal(ctx, || taker, |ctx, &taker| register(ctx, taker));
let layer = crate::runtime::overlay::drawing_parent(ctx);
PerViewport::<State>::with(ctx, pass::current_viewport(ctx), |state| {
state.this_layers.insert(taker.owner, layer);
state.this.push(taker);
});
=======
crate::runtime::replay::journal(ctx, || taker, |ctx, &taker| register(ctx, taker));
PerViewport::<State>::with(ctx, pass::current_viewport(ctx), |state| state.this.push(taker));
>>>>>>> origin/next
}
/// The innermost scroll owner inside the field `owner` under `at` that can still move by the vertical scroll `dy`: the
@@ -287,12 +278,8 @@ pub(crate) fn begin(ctx: &Context) {
}
state.device_ended = None;
// The device's lines and pages become points of each taker: the notch is the scroll owner's to choose.
<<<<<<< HEAD
for (owner, mut share) in shares {
=======
for (owner, mut share) in split(&state.last, at, share, focus, state.armed, &mut state.gesture, now) {
let owner = scroll_owner_inside(&state.last, owner, at, share.scroll.y).unwrap_or(owner);
>>>>>>> origin/next
let owner = scroll_owner_inside(&eligible, owner, at, share.scroll.y).unwrap_or(owner);
if unit == WheelUnit::Line {
share.lines = share.scroll;
}
+9 -13
View File
@@ -332,7 +332,15 @@ pub(crate) fn input_hook(ctx: &Context, input: &mut RawInput) -> bool {
if handed_off && tracked == Some(viewport) {
shared(ctx, |shared| shared.tracked_move = None);
}
<<<<<<< HEAD
let pressed =
input.events.iter().any(|event| matches!(event, egui::Event::PointerButton { button: egui::PointerButton::Primary, pressed: true, .. }));
if pressed {
let frame = pass::root_frame_nr(ctx);
shared(ctx, |shared| {
shared.presses.retain(|(_, at)| at + 1 >= frame);
shared.presses.push((viewport, frame));
});
}
released || located
}
@@ -360,18 +368,6 @@ fn locate_wheel(ctx: &Context, input: &mut RawInput) -> bool {
}
input.events.insert(0, egui::Event::PointerMoved(local));
true
=======
let pressed =
input.events.iter().any(|event| matches!(event, egui::Event::PointerButton { button: egui::PointerButton::Primary, pressed: true, .. }));
if pressed {
let frame = pass::root_frame_nr(ctx);
shared(ctx, |shared| {
shared.presses.retain(|(_, at)| at + 1 >= frame);
shared.presses.push((viewport, frame));
});
}
released
>>>>>>> origin/next
}
/// The begin hook (H5), where the viewport is current: refreshes its window info, and raises the modal's window
@@ -23,10 +23,6 @@ pub(crate) fn save_placement(ctx: &Context, key: &str, placement: &Placement) {
/// Keeps the window's placement in the store, as [`placement_of`] records it. A minimized window keeps the last
/// placement it was shown at: Windows reports it as 0 × 0 far off screen, which would reopen at egui's size floor.
pub(super) fn record_placement(ctx: &Context, viewport: ViewportId, key: &str, facts: &viewports::Facts) {
<<<<<<< HEAD
=======
// Some systems report a parked rectangle for a minimized window.
>>>>>>> origin/next
if facts.minimized {
return;
}
+2 -7
View File
@@ -3,13 +3,8 @@
use super::key::{EnvKey, Ink};
use super::look::{DataColor, FocusLook, StyleColor, SurfaceKind, SurfaceLook, TrackLook};
use super::paint::{
<<<<<<< HEAD
AutoScrollMarkLook, HandleLook, MarkerLook, ResetMarkLook, RuleKind, RuleLook, ScrollBarLook, auto_scroll_mark_look, handle_look, marker_look,
reset_mark_look, rule_look, scroll_bar_look,
=======
HandleLook, MarkerLook, ResetMarkLook, RuleKind, RuleLook, ScrollBarKind, ScrollBarLook, handle_look, marker_look, reset_mark_look, rule_look,
scroll_bar_look_of,
>>>>>>> origin/next
AutoScrollMarkLook, HandleLook, MarkerLook, ResetMarkLook, RuleKind, RuleLook, ScrollBarKind, ScrollBarLook, auto_scroll_mark_look, handle_look,
marker_look, reset_mark_look, rule_look, scroll_bar_look_of,
};
use super::surface::{SurfaceStyle, surface_style};
use super::tokens::UiTokens;
+2 -7
View File
@@ -27,15 +27,10 @@ pub use key::{EnvKey, Ink, StyleKey};
pub(crate) use look::StyleView;
pub use look::{ComponentStyle, Corners, DataColor, FocusLook, IconLook, StyleColor, SurfaceKind, SurfaceLook, TextLook, TrackLook};
pub use paint::{
<<<<<<< HEAD
AutoScrollMarkLook, HandleLook, MarkerLook, ResetMarkLook, ResizeLineLook, RuleKind, RuleLook, RuleWidth, ScrollBarLook, resize_line_look,
AutoScrollMarkLook, HandleLook, MarkerLook, ResetMarkLook, ResizeLineLook, RuleKind, RuleLook, RuleWidth, ScrollBarKind, ScrollBarLook,
resize_line_look,
};
pub(crate) use paint::{auto_scroll_mark_look, min_thumb, scroll_bar_look};
=======
HandleLook, MarkerLook, ResetMarkLook, ResizeLineLook, RuleKind, RuleLook, RuleWidth, ScrollBarKind, ScrollBarLook, resize_line_look,
};
pub(crate) use paint::{min_thumb, scroll_bar_look};
>>>>>>> origin/next
pub use replacements::{DuplicateStyle, StyleReplacements};
pub use span::Span;
pub use state::StateSet;
+5 -6
View File
@@ -463,16 +463,15 @@ impl Fixture {
self.frames.repaint_requested()
}
<<<<<<< HEAD
/// The system cursor the latest frame's output asked for.
pub fn cursor_icon(&self) -> egui::CursorIcon {
self.frames.cursor_icon()
=======
/// The wait the latest frame asked for before the next pass: `Duration::ZERO` for an immediate repaint, `None` when
/// it asked for none.
pub fn repaint_delay(&self) -> Option<std::time::Duration> {
self.frames.repaint_delay()
>>>>>>> origin/next
}
/// The system cursor the latest frame's output asked for.
pub fn cursor_icon(&self) -> egui::CursorIcon {
self.frames.cursor_icon()
}
/// The IME output of the latest frame.
+1 -5
View File
@@ -67,12 +67,8 @@ pub use registry::{Registered, Registry};
pub use stage::{least_stage_width, room_height, stage, stage_fitting, stage_width};
#[doc(hidden)]
pub use story::{
<<<<<<< HEAD
CollectionKind, Drive, EditKind, Grip, Required, Story, StoryData, StoryOutput, StoryRegistration, StorySnapshot, show_as_only_item,
show_as_only_item_across, stories,
=======
CollectionKind, Drive, EditKind, Grip, Required, Story, StoryData, StoryOutput, StoryRegistration, StorySnapshot, ValueAt, show_as_only_item,
>>>>>>> origin/next
show_as_only_item_across,
};
pub use windows::install_spec;
+9 -48
View File
@@ -2,14 +2,9 @@
use super::Fixture;
use crate::contract::{CollectionEvent, Inner, Outcome, TooltipSpec};
<<<<<<< HEAD
use crate::runtime::commands::{CommandInput, CommandRef};
use craft_behavior::{EditEvent, EditEvents, PartKey, PartRef, Value};
=======
use crate::runtime::commands::CommandStates;
use crate::runtime::commands::{CommandRef, CommandStates};
use craft_behavior::{EditEvent, EditEvents, Mixed, PartKey, PartRef, Value};
use craft_tracked::{Revision, Tracked};
>>>>>>> origin/next
use egui::{Id, Response, Ui, Vec2};
use std::any::{Any, TypeId};
use std::collections::HashMap;
@@ -790,56 +785,23 @@ pub fn show_as_only_item<C>(ui: &mut Ui, row: C) -> C::Output
where
C: crate::contract::Component + crate::contract::Props + crate::contract::Show,
{
<<<<<<< HEAD
only_item(ui, row, None)
crate::contract::show_item_in_flow(ui, row, crate::runtime::access::SetPosition::new(0).of(1))
}
/// Shows `row` as the only item of a collection across `span`, as a collection shows its rows across its columns: a
/// row with column cells spans the cells it is given, where in the flow it would take its own width. The row is as
/// high as it measures at the span's width, as a collection measures it.
pub fn show_as_only_item_across<C>(ui: &mut Ui, row: C, span: egui::Rangef) -> C::Output
pub fn show_as_only_item_across<C>(ui: &mut Ui, mut row: C, span: egui::Rangef) -> C::Output
where
C: crate::contract::Component + crate::contract::Props + crate::contract::Show,
{
only_item(ui, row, Some(span))
}
fn only_item<C>(ui: &mut Ui, row: C, span: Option<egui::Rangef>) -> C::Output
where
C: crate::contract::Component + crate::contract::Props + crate::contract::Show,
{
let id = ui.scope_id().with("only item");
let facts = crate::runtime::env::ItemFacts {
item: id,
flags: crate::style::Flags::empty(),
position: crate::runtime::access::SetPosition::new(0).of(1),
columns: Vec::new(),
toggles: Vec::new(),
toggle_keys: Vec::new(),
aligns: Vec::new(),
pressed: None,
menu_open: false,
};
let installed = crate::runtime::env::Env::install_for(
ui,
crate::runtime::env::Env::of(ui).derive_local(|scoped| scoped.item_facts = Some(std::sync::Arc::new(facts))),
);
let mut row = row.id(id);
let shown = match span {
Some(span) => {
let height = row.measure_in(ui, craft_behavior::Proposal::Width(span.span())).y;
let top = ui.cursor().min.y;
let rect = egui::Rect::from_x_y_ranges(span, top..=top + height);
let shown = row.show_at(ui, rect);
ui.advance_cursor_after_rect(rect);
shown
}
None => row.show(ui),
};
crate::runtime::env::Env::restore(ui.ctx(), installed);
let at = crate::runtime::access::SetPosition::new(0).of(1);
let height = crate::contract::measure_item(ui, &mut row, at, craft_behavior::Proposal::Width(span.span())).y;
let top = ui.cursor().min.y;
let rect = egui::Rect::from_x_y_ranges(span, top..=top + height);
let shown = crate::contract::show_item(ui, rect, row, at);
ui.advance_cursor_after_rect(rect);
shown
=======
crate::contract::show_item_in_flow(ui, row, crate::runtime::access::SetPosition::new(0).of(1))
}
/// A story value's place in its data, by its name and type, as the data keeps it: with the data's source it names the
@@ -849,5 +811,4 @@ fn slot_offset(name: &str, ty: TypeId) -> usize {
let mut hasher = std::collections::hash_map::DefaultHasher::new();
(name, ty).hash(&mut hasher);
hasher.finish() as usize
>>>>>>> origin/next
}
+1 -17
View File
@@ -1,19 +1,3 @@
<<<<<<< HEAD
mod control_click;
mod cursor;
mod elapsed;
mod env;
mod frame;
mod latch;
mod memory;
mod paste;
mod pen;
mod pointer;
mod wheel;
mod window_move;
mod windows;
mod words;
=======
pub(crate) mod alt_code;
pub(crate) mod chord_fallthrough;
// `clipboard.rs` is platform-w3's trial (F-28); this file is shell-w1's, so its line is written here.
@@ -27,6 +11,7 @@ pub(crate) mod focus;
pub(crate) mod frame;
pub(crate) mod latch;
pub(crate) mod memory;
pub(crate) mod paste;
pub(crate) mod pen;
pub(crate) mod pointer;
pub(crate) mod theme_app;
@@ -34,6 +19,5 @@ pub(crate) mod wheel;
pub(crate) mod window_move;
pub(crate) mod windows;
pub(crate) mod words;
>>>>>>> origin/next
pub(crate) mod screenshot;
+108 -116
View File
@@ -2,22 +2,15 @@
use craft_behavior::{GESTURE_GAP, Sense, Wheel, WheelNotch, WheelPhase, WheelTaker, WheelUnit};
use craft_host::target::Os;
<<<<<<< HEAD
use craft_ui::contract::{Common, Component, Cx, Pointer as _, Props as _, Role, Show as _};
use craft_ui::style::StyleCx;
=======
use craft_ui::runtime::env::{RootEnv, WheelSpeed};
>>>>>>> origin/next
use craft_ui::style::StyleCx;
use craft_ui::testing::pointer;
use craft_ui::testing::sensing::{ProbeRoot, show};
use craft_ui::testing::wheel::{register, take, take_share};
use craft_ui::testing::{Fixture, Frames, trial};
<<<<<<< HEAD
use craft_ui_test_kit::contract::PlainStyle;
use egui::{Event, Id, Modifiers, MouseWheelSource, MouseWheelUnit, Pos2, Rect, Response, TouchPhase, Vec2};
=======
use egui::{Event, Id, Modifiers, MouseWheelSource, MouseWheelUnit, Pos2, Rect, TouchPhase, Vec2, ViewportId};
>>>>>>> origin/next
use egui::{Event, Id, Modifiers, MouseWheelSource, MouseWheelUnit, Pos2, Rect, Response, TouchPhase, Vec2, ViewportId};
use std::cell::{Cell, RefCell};
use std::rc::Rc;
@@ -196,7 +189,112 @@ fn a_wheel_gesture_ends_for_a_value_control_in_any_wheel_scope_and_not_for_a_scr
}
}
<<<<<<< HEAD
/// What the view under the pointer took over one step: the summed scroll, the product of the zooms and the number of
/// shares.
#[derive(Clone, Copy, Debug, PartialEq)]
struct Took {
scroll: Vec2,
zoom: f32,
shares: usize,
}
/// One step of the wheel-speed trial in `viewport`: a frame with `events` that runs two passes, then a frame with no
/// input, as an app's tick between OS frames runs one. Returns what the view took over both frames.
fn speed_step(
frames: &mut Frames,
viewport: ViewportId,
events: Vec<Event>,
show: &mut dyn FnMut(&mut egui::Ui),
rerun: &Cell<bool>,
seen: &RefCell<Vec<Wheel>>,
) -> Took {
seen.borrow_mut().clear();
rerun.set(true);
let passes = frames.frame_in_viewport(viewport, events, &mut *show);
rerun.set(false);
assert_eq!(passes, 2, "the wheel frame runs a second pass, which gets none of the frame's events");
frames.frame_in_viewport(viewport, Vec::new(), &mut *show);
let shares = std::mem::take(&mut *seen.borrow_mut());
Took {
scroll: shares.iter().fold(Vec2::ZERO, |sum, share| sum + share.scroll),
zoom: shares.iter().map(|share| share.zoom).product(),
shares: shares.len(),
}
}
/// The wheel-speed trial's steps on `os` with the user's wheel speed `speed`: a line notch, a point delta, a zoom
/// notch (Ctrl+wheel, Cmd+wheel on macOS) in the main window, then a point delta in a second window.
fn speed_steps(os: Os, speed: WheelSpeed) -> [Took; 4] {
let view = Id::unique("wheel_speed_view");
let seen = RefCell::new(Vec::new());
let rerun = Cell::new(false);
let mut show = |ui: &mut egui::Ui| {
register(ui.ctx(), WheelTaker::new(view, Rect::from_min_size(Pos2::ZERO, Vec2::new(400.0, 300.0))).vertical(true).zoom(true));
let share = take_share(ui.ctx(), view);
seen.borrow_mut().extend(share);
if rerun.get() && ui.ctx().current_pass_index() == 0 {
ui.ctx().request_discard("the wheel frame runs twice");
}
};
let at = Pos2::new(200.0, 150.0);
let mut frames = Frames::new();
craft_ui::testing::windows::set_os(&frames.ctx, os);
frames.root(RootEnv::default().wheel_speed(speed));
frames.idle(2, &mut show);
frames.frame(vec![pointer::moved(at)], &mut show);
// egui reports Ctrl as `ctrl` and `command` off macOS, and Cmd as `mac_cmd` and `command` on it: egui's zoom
// modifier either way.
let zoom_mods = if os == Os::Mac {
Modifiers { mac_cmd: true, command: true, ..Modifiers::NONE }
} else {
Modifiers { ctrl: true, command: true, ..Modifiers::NONE }
};
let zoom_notch = wheel_event(MouseWheelUnit::Line, Vec2::new(0.0, 1.0), TouchPhase::Move, zoom_mods);
let root = ViewportId::ROOT;
let line = speed_step(&mut frames, root, vec![pointer::wheel_lines(-1.0)], &mut show, &rerun, &seen);
let point = speed_step(&mut frames, root, vec![pointer::wheel(-30.0)], &mut show, &rerun, &seen);
let zoom = speed_step(&mut frames, root, vec![zoom_notch], &mut show, &rerun, &seen);
let second = ViewportId::from_hash_of("wheel speed second window");
frames.frame_in_viewport(second, vec![pointer::moved(at)], &mut show);
frames.frame_in_viewport(second, Vec::new(), &mut show);
let secondary = speed_step(&mut frames, second, vec![pointer::wheel(-30.0)], &mut show, &rerun, &seen);
[line, point, zoom, secondary]
}
/// SG-31: the runtime multiplies each wheel delta by the user's `WheelSpeed` in the raw-input step, `line` for notches
/// and `point` for touchpad deltas, in every window. A frame's events reach only its first pass, so a delta is scaled
/// once however many passes the frame runs and whatever frames follow it. A Ctrl+wheel (Cmd+wheel) zooms by the
/// device's notch: its distance does not follow the speed.
#[trial]
fn the_users_wheel_speed_scales_each_delta_once_and_leaves_zoom_alone() {
let speed = WheelSpeed::new(3.0, 2.0);
let close = |a: Vec2, b: Vec2| (a - b).length() < 1e-3;
for os in [Os::Windows, Os::Linux, Os::Mac] {
let [line, point, zoom, secondary] = speed_steps(os, WheelSpeed::default());
let [fast_line, fast_point, fast_zoom, fast_secondary] = speed_steps(os, speed);
for (name, took) in [("line", fast_line), ("point", fast_point), ("zoom", fast_zoom), ("second window", fast_secondary)] {
assert_eq!(took.shares, 1, "{os:?} {name}: one share over the frame's two passes and the frame after: {took:?}");
}
assert!(
line.scroll.y != 0.0 && close(fast_line.scroll, line.scroll * speed.line),
"{os:?}: a notch scrolls `line` times as far: {fast_line:?} against {line:?}"
);
assert!(
point.scroll.y != 0.0 && close(fast_point.scroll, point.scroll * speed.point),
"{os:?}: a point delta scrolls `point` times as far: {fast_point:?} against {point:?}"
);
assert!(
zoom.zoom != 1.0 && (fast_zoom.zoom - zoom.zoom).abs() < 1e-4,
"{os:?}: a zoom notch zooms as far at any speed: {fast_zoom:?} against {zoom:?}"
);
assert!(close(fast_zoom.scroll, Vec2::ZERO), "{os:?}: a zoom notch scrolls nothing: {fast_zoom:?}");
assert!(
secondary.scroll.y != 0.0 && close(fast_secondary.scroll, secondary.scroll * speed.point),
"{os:?}: a second window's delta is scaled too: {fast_secondary:?} against {secondary:?}"
);
}
}
/// The points of one wheel line for the takers below.
const NOTCH: f32 = 25.0;
@@ -396,110 +494,4 @@ fn direct_precise_input_cancels_only_older_motion_on_its_axis() {
// A press drops every ease.
assert_eq!(step(&mut frames, vec![pointer::press(at.get())]), Vec2::ZERO, "a press stops the owed motion");
assert_eq!(step(&mut frames, vec![pointer::release(at.get())]), Vec2::ZERO);
=======
/// What the view under the pointer took over one step: the summed scroll, the product of the zooms and the number of
/// shares.
#[derive(Clone, Copy, Debug, PartialEq)]
struct Took {
scroll: Vec2,
zoom: f32,
shares: usize,
}
/// One step of the wheel-speed trial in `viewport`: a frame with `events` that runs two passes, then a frame with no
/// input, as an app's tick between OS frames runs one. Returns what the view took over both frames.
fn speed_step(
frames: &mut Frames,
viewport: ViewportId,
events: Vec<Event>,
show: &mut dyn FnMut(&mut egui::Ui),
rerun: &Cell<bool>,
seen: &RefCell<Vec<Wheel>>,
) -> Took {
seen.borrow_mut().clear();
rerun.set(true);
let passes = frames.frame_in_viewport(viewport, events, &mut *show);
rerun.set(false);
assert_eq!(passes, 2, "the wheel frame runs a second pass, which gets none of the frame's events");
frames.frame_in_viewport(viewport, Vec::new(), &mut *show);
let shares = std::mem::take(&mut *seen.borrow_mut());
Took {
scroll: shares.iter().fold(Vec2::ZERO, |sum, share| sum + share.scroll),
zoom: shares.iter().map(|share| share.zoom).product(),
shares: shares.len(),
}
}
/// The wheel-speed trial's steps on `os` with the user's wheel speed `speed`: a line notch, a point delta, a zoom
/// notch (Ctrl+wheel, Cmd+wheel on macOS) in the main window, then a point delta in a second window.
fn speed_steps(os: Os, speed: WheelSpeed) -> [Took; 4] {
let view = Id::unique("wheel_speed_view");
let seen = RefCell::new(Vec::new());
let rerun = Cell::new(false);
let mut show = |ui: &mut egui::Ui| {
register(ui.ctx(), WheelTaker::new(view, Rect::from_min_size(Pos2::ZERO, Vec2::new(400.0, 300.0))).vertical(true).zoom(true));
let share = take_share(ui.ctx(), view);
seen.borrow_mut().extend(share);
if rerun.get() && ui.ctx().current_pass_index() == 0 {
ui.ctx().request_discard("the wheel frame runs twice");
}
};
let at = Pos2::new(200.0, 150.0);
let mut frames = Frames::new();
craft_ui::testing::windows::set_os(&frames.ctx, os);
frames.root(RootEnv::default().wheel_speed(speed));
frames.idle(2, &mut show);
frames.frame(vec![pointer::moved(at)], &mut show);
// egui reports Ctrl as `ctrl` and `command` off macOS, and Cmd as `mac_cmd` and `command` on it: egui's zoom
// modifier either way.
let zoom_mods = if os == Os::Mac {
Modifiers { mac_cmd: true, command: true, ..Modifiers::NONE }
} else {
Modifiers { ctrl: true, command: true, ..Modifiers::NONE }
};
let zoom_notch = wheel_event(MouseWheelUnit::Line, Vec2::new(0.0, 1.0), TouchPhase::Move, zoom_mods);
let root = ViewportId::ROOT;
let line = speed_step(&mut frames, root, vec![pointer::wheel_lines(-1.0)], &mut show, &rerun, &seen);
let point = speed_step(&mut frames, root, vec![pointer::wheel(-30.0)], &mut show, &rerun, &seen);
let zoom = speed_step(&mut frames, root, vec![zoom_notch], &mut show, &rerun, &seen);
let second = ViewportId::from_hash_of("wheel speed second window");
frames.frame_in_viewport(second, vec![pointer::moved(at)], &mut show);
frames.frame_in_viewport(second, Vec::new(), &mut show);
let secondary = speed_step(&mut frames, second, vec![pointer::wheel(-30.0)], &mut show, &rerun, &seen);
[line, point, zoom, secondary]
}
/// SG-31: the runtime multiplies each wheel delta by the user's `WheelSpeed` in the raw-input step, `line` for notches
/// and `point` for touchpad deltas, in every window. A frame's events reach only its first pass, so a delta is scaled
/// once however many passes the frame runs and whatever frames follow it. A Ctrl+wheel (Cmd+wheel) zooms by the
/// device's notch: its distance does not follow the speed.
#[trial]
fn the_users_wheel_speed_scales_each_delta_once_and_leaves_zoom_alone() {
let speed = WheelSpeed::new(3.0, 2.0);
let close = |a: Vec2, b: Vec2| (a - b).length() < 1e-3;
for os in [Os::Windows, Os::Linux, Os::Mac] {
let [line, point, zoom, secondary] = speed_steps(os, WheelSpeed::default());
let [fast_line, fast_point, fast_zoom, fast_secondary] = speed_steps(os, speed);
for (name, took) in [("line", fast_line), ("point", fast_point), ("zoom", fast_zoom), ("second window", fast_secondary)] {
assert_eq!(took.shares, 1, "{os:?} {name}: one share over the frame's two passes and the frame after: {took:?}");
}
assert!(
line.scroll.y != 0.0 && close(fast_line.scroll, line.scroll * speed.line),
"{os:?}: a notch scrolls `line` times as far: {fast_line:?} against {line:?}"
);
assert!(
point.scroll.y != 0.0 && close(fast_point.scroll, point.scroll * speed.point),
"{os:?}: a point delta scrolls `point` times as far: {fast_point:?} against {point:?}"
);
assert!(
zoom.zoom != 1.0 && (fast_zoom.zoom - zoom.zoom).abs() < 1e-4,
"{os:?}: a zoom notch zooms as far at any speed: {fast_zoom:?} against {zoom:?}"
);
assert!(close(fast_zoom.scroll, Vec2::ZERO), "{os:?}: a zoom notch scrolls nothing: {fast_zoom:?}");
assert!(
secondary.scroll.y != 0.0 && close(fast_secondary.scroll, secondary.scroll * speed.point),
"{os:?}: a second window's delta is scaled too: {fast_secondary:?} against {secondary:?}"
);
}
>>>>>>> origin/next
}
+6 -14
View File
@@ -1,15 +1,9 @@
//! `runtime::windows`: the input hook per viewport, window info per viewport, the press release after an OS
//! resize (H4), the raise of a modal's window, the mount of a full-window container (in a window of its own, or in a
<<<<<<< HEAD
//! full-screen or Wayland-maximized main window), the size of a content-sized window, the app id of child windows,
//! injected keys across a focus loss, non-finite injected points, a repeated injected press, the window that has the
//! keys, a wheel with no known pointer, the placement of a minimized window, the root frame decided again, a held
//! close, and `act`.
=======
//! full-screen or Wayland-maximized main window), the size of a content-sized window, the app id of child windows, a
//! palette's level under a modal and its visibility while the main window is minimized, injected keys across a focus
//! loss, non-finite injected points, a repeated injected press, the window that has the keys, and `act`.
>>>>>>> origin/next
//! loss, non-finite injected points, a repeated injected press, the window that has the keys, a wheel with no known
//! pointer, the placement of a minimized window, the root frame decided again, a held close, and `act`.
use craft_behavior::{Cursor, CursorIcon, PointerButton};
use craft_host::target::{Backend, Caps, Os, ShellInfo, WindowChrome, WindowInfo, WindowKind};
@@ -89,7 +83,6 @@ fn a_press_is_released_after_an_os_resize_of_an_undecorated_window() {
}
}
<<<<<<< HEAD
/// #1518: after the user switches back to a window, the platform sends no pointer move until the mouse moves, so the
/// first wheel turn found no pointer and scrolled nothing. The pass that receives the wheel gets a move to the system
/// pointer, mapped into the window, before it; a rerun pass of that frame gets neither again, and the next wheel, with
@@ -256,7 +249,8 @@ fn a_held_close_brings_the_root_window_forward() {
"{backend:?}: with no close request nothing is raised"
);
}
=======
}
/// A window that moves reports its inner size again, in points from its physical pixels: at a fractional scale the
/// same size can come back a float step off (290.4 as 290.40002). That is no OS resize, so the press stays down: a
/// release there ended every move of a floating panel on Windows a few points into the drag.
@@ -281,7 +275,6 @@ fn a_press_survives_a_size_that_differs_only_by_float_rounding() {
frame(vec![]);
frame(vec![]);
assert!(down.get(), "a float step of size is no resize: the press stays down");
>>>>>>> origin/next
}
/// One frame of `windows` with the `Modal` open in the child viewport.
@@ -332,7 +325,6 @@ fn an_app_modal_in_one_window_blocks_the_cursor_and_the_close_of_the_others() {
}
}
<<<<<<< HEAD
/// A window that a modal in another window blocks takes no wheel, as it takes no press or key: what is under the
/// pointer there does not scroll.
#[trial]
@@ -421,7 +413,8 @@ fn wheel_over_a_modal_never_reaches_a_view_under_it_during_a_drag() {
frame(vec![wheel(-30.0)]);
assert!(modal_taken.get().is_some(), "the modal's own scroll region takes the wheel");
assert!(taken.get().is_none(), "the background stays still when the modal scrolls");
=======
}
/// A window that closes leaves the next frame's input, as an integration drops it, so the modal it showed in its last
/// pass blocks no other window: the root window's close request then reaches the app in that frame.
#[trial]
@@ -437,7 +430,6 @@ fn a_closed_windows_modal_no_longer_blocks_the_root_close() {
});
assert!(!listed.get(), "the closed window is gone from the input");
assert!(asked.get(), "the closed window's modal refuses no close");
>>>>>>> origin/next
}
/// L-17: the user clicking the main window while a modal in another window blocks it brings the modal's window