mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 13:57:06 +00:00
Lints: fix clippy and rustdoc findings in ui-contract, i18n, heif, mesh, video, audio, doc and the doc links
This commit is contained in:
@@ -50,8 +50,8 @@ fn run(case: &Case, rate: u32) -> (f64, f64, Vec<Mode>) {
|
||||
let layout = match case.channels {
|
||||
1 => "mono",
|
||||
2 => "stereo",
|
||||
6 => "5.1",
|
||||
_ => unreachable!(),
|
||||
// The cases have 1, 2 or 6 channels.
|
||||
_ => "5.1",
|
||||
};
|
||||
let mut cmd = Command::new(&ff);
|
||||
cmd.args(["-hide_banner", "-loglevel", "error", "-y", "-f", "f32le", "-ar", "48000", "-ch_layout", layout, "-i"]).arg(&raw);
|
||||
|
||||
@@ -96,8 +96,7 @@ fn excessive_window_and_size_less_expansion_are_limits() {
|
||||
let z = frame(&payload);
|
||||
// Producer frames omit their content size; output admission must work without that hint.
|
||||
assert_eq!(z[4] & 0xc0, 0);
|
||||
let mut limits = Limits::default();
|
||||
limits.max_entry = 1024;
|
||||
let limits = Limits { max_entry: 1024, ..Limits::default() };
|
||||
assert!(matches!(pcraft_icc_profile(&zip(&[store("manifest.json", m.as_bytes()), store(&path, &z)]), &limits), Err(Error::LimitExceeded(_))));
|
||||
let mut large_window = z.clone();
|
||||
assert_eq!(large_window[4] & 0x20, 0);
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
//!
|
||||
//! `heic-rs`, a pure-Rust HEIF container and HEVC still-picture decoder, reads the container and
|
||||
//! reconstructs the coded pictures (bit-exact against libde265 on iPhone photos); this crate turns
|
||||
//! them into RGB itself ([`ycc`]) so the colours match libheif: it honours the HEVC VUI's range
|
||||
//! and matrix ([`vui`]) where heic-rs assumes BT.709 limited range, and upsamples chroma like
|
||||
//! them into RGB itself (`ycc`) so the colours match libheif: it honours the HEVC VUI's range
|
||||
//! and matrix (`vui`) where heic-rs assumes BT.709 limited range, and upsamples chroma like
|
||||
//! libheif. Single pictures and grid-tiled photos, 8- to 16-bit, monochrome, alpha auxiliary
|
||||
//! images, ICC, EXIF and XMP. The API is plain data ([`Info`], [`Decoded`], [`Error`]) so the
|
||||
//! crate knows nothing about any app; each app's codec layer adapts it behind its own optional
|
||||
|
||||
@@ -16,7 +16,7 @@ pub(super) const RLM: char = '\u{200F}';
|
||||
pub(super) const ALM: char = '\u{061C}';
|
||||
|
||||
/// `value` as a first-strong isolate (FSI…PDI): it takes the direction of its first strong
|
||||
/// letter and can't reorder the text around it. What [`fmt`] does to each value in text with a
|
||||
/// letter and can't reorder the text around it. What [`crate::fmt`] does to each value in text with a
|
||||
/// right-to-left letter.
|
||||
pub fn isolate(value: &str) -> String {
|
||||
wrap(FSI, value)
|
||||
@@ -24,13 +24,13 @@ pub fn isolate(value: &str) -> String {
|
||||
|
||||
/// `value` as a left-to-right isolate (LRI…PDI), for numbers, paths, file sizes, timecodes and
|
||||
/// codes, which read left to right in every language. In an RTL first-strong isolate, the
|
||||
/// segments of `/home/مستخدم/file.txt` would run right to left. [`fmt`] takes the isolate off
|
||||
/// segments of `/home/مستخدم/file.txt` would run right to left. [`crate::fmt`] takes the isolate off
|
||||
/// again in text with no right-to-left letter.
|
||||
pub fn ltr(value: &str) -> String {
|
||||
wrap(LRI, value)
|
||||
}
|
||||
|
||||
/// `text` without isolate marks (LRI, RLI, FSI, PDI): a [`fmt`] or [`I18n::trn`] result made fit
|
||||
/// `text` without isolate marks (LRI, RLI, FSI, PDI): a [`crate::fmt`] or [`crate::I18n::trn`] result made fit
|
||||
/// for a file name, a log or a comparison.
|
||||
pub fn strip_isolates(text: &str) -> String {
|
||||
text.chars().filter(|c| !matches!(*c, LRI | RLI | FSI | PDI)).collect()
|
||||
|
||||
@@ -29,7 +29,9 @@ mod bidi;
|
||||
mod negotiation;
|
||||
|
||||
use bidi::{FSI, has_bidi_control, has_rtl, is_one_isolate, unwrap_isolate, wrap};
|
||||
use negotiation::{bare, candidates, is_region, marked, plural_rules, posix_env_tags};
|
||||
#[cfg(all(unix, not(any(target_vendor = "apple", target_os = "android"))))]
|
||||
use negotiation::posix_env_tags;
|
||||
use negotiation::{bare, candidates, is_region, marked, plural_rules};
|
||||
|
||||
pub use bidi::{isolate, ltr, strip_isolates};
|
||||
|
||||
|
||||
@@ -217,6 +217,8 @@ fn texture_and_sampler_inventory_includes_unreferenced_entries() {
|
||||
invalid.texture_variants[0].image = invalid.images.len();
|
||||
assert!(matches!(invalid.validate(), Err(Error::Malformed(_))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn glb_container_checks() {
|
||||
let glb = quad();
|
||||
let (json, bin) = split_glb(&glb).unwrap();
|
||||
|
||||
@@ -316,7 +316,7 @@ impl Document {
|
||||
}
|
||||
|
||||
/// Follow a reference if `o` is one; otherwise return `o` itself. An object can be nothing but
|
||||
/// a reference to another, which is followed too, up to [`MAX_REFERENCE_HOPS`] of them.
|
||||
/// a reference to another, which is followed too, up to 32 of them.
|
||||
pub fn resolve(&self, o: &Object) -> Arc<Object> {
|
||||
let Object::Ref(r) = o else { return Arc::new(o.clone()) };
|
||||
let mut held = self.get(*r);
|
||||
|
||||
@@ -168,7 +168,7 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
|
||||
Mount::Viewport { .. } if viewports::available(&ctx) => 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);
|
||||
let screen = crate::contract::overlay::screen_for(&ctx, env, overlay);
|
||||
shown_placement(&ctx, id, save.as_ref(), overlay, screen, env.tokens.space.inset.screen)
|
||||
});
|
||||
// A layer the user sized takes that size, at its saved position or where its anchor places it.
|
||||
@@ -674,6 +674,10 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::cognitive_complexity,
|
||||
reason = "the body step of the pass: its sub-steps share locals and run in one order, so a split would pass them all through"
|
||||
)]
|
||||
fn content(&mut self, comp: &mut C, ui: &mut Ui, env: &Env, cx: &mut Cx<'_, C>, values: &AppValues) {
|
||||
let props = Arc::clone(&self.props);
|
||||
let (id, ctx, rect) = (cx.core.id, cx.core.ctx.clone(), cx.core.rect);
|
||||
|
||||
@@ -40,9 +40,10 @@ pub(crate) struct Decls {
|
||||
|
||||
impl Decls {
|
||||
fn push(&mut self, decl: PartDecl) -> (&mut PartDecl, &mut PartExtras) {
|
||||
let at = self.parts.len();
|
||||
self.parts.push(decl);
|
||||
self.extras.push(PartExtras::default());
|
||||
(self.parts.last_mut().expect("just pushed"), self.extras.last_mut().expect("just pushed"))
|
||||
(&mut self.parts[at], &mut self.extras[at])
|
||||
}
|
||||
|
||||
/// The sensing core's declarations, in declaration order.
|
||||
|
||||
@@ -82,6 +82,9 @@ pub struct SweepApply {
|
||||
show_only: bool,
|
||||
}
|
||||
|
||||
/// A move of a collection's own items as they stand before the drop, and as the drop leaves them.
|
||||
type MovePair<K> = (ReorderMove<K>, ReorderMove<K>);
|
||||
|
||||
impl SweepApply {
|
||||
/// A plain column: Alt is ignored.
|
||||
pub fn new() -> Self {
|
||||
@@ -472,7 +475,7 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
|
||||
|
||||
/// The move a drop of the collection's own `payload` at `landed` makes, before and after; `None` when it would
|
||||
/// leave every item where it is.
|
||||
fn own_move(&self, payload: &ListDrag<C::Key>, landed: Landed, groups: bool) -> Option<(ReorderMove<C::Key>, ReorderMove<C::Key>)> {
|
||||
fn own_move(&self, payload: &ListDrag<C::Key>, landed: Landed, groups: bool) -> Option<MovePair<C::Key>> {
|
||||
// The moved items in display order, as they stand in the source now.
|
||||
let at: Vec<usize> =
|
||||
payload.keys.iter().filter_map(|key| self.index_of(key)).collect::<std::collections::BTreeSet<_>>().into_iter().collect();
|
||||
|
||||
@@ -611,12 +611,8 @@ impl<C: Collection> ShapeHooks<C> for ItemsHooks<'_, '_, C> {
|
||||
Some((row_ui, installed))
|
||||
}
|
||||
};
|
||||
{
|
||||
let measure_ui = match (&row_ui, &members_ui) {
|
||||
(Some((row_ui, _)), _) => row_ui,
|
||||
(None, Some((members_ui, _))) => members_ui,
|
||||
(None, None) => unreachable!("a row is a run or a member"),
|
||||
};
|
||||
// A row is a run or a member, so one of the two is there.
|
||||
if let Some((measure_ui, _)) = row_ui.as_ref().or(members_ui.as_ref()) {
|
||||
if layout.is_auto(at) && !self.measured_for_reveal.contains(&at) {
|
||||
let measured = item.measure_in(measure_ui, Proposal::Width(row.width())).y;
|
||||
#[cfg(feature = "testing")]
|
||||
@@ -842,7 +838,7 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
|
||||
self.renaming.draft = draft;
|
||||
if let Some(editor) = editor {
|
||||
if !self.renaming.focused {
|
||||
focus::request_now(&ctx, focus::FocusTarget::Id(editor.response.id));
|
||||
focus::request_now(ctx, focus::FocusTarget::Id(editor.response.id));
|
||||
self.renaming.focused = true;
|
||||
}
|
||||
let gesture = self.renaming.gesture;
|
||||
@@ -851,15 +847,15 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
|
||||
let end = editor.events.iter().rev().find(|event| matches!(event, EditEvent::Commit { .. } | EditEvent::Cancel { .. })).cloned();
|
||||
let edited = !editor.events.is_empty();
|
||||
if end.is_some() {
|
||||
self.refocus = focus::is_focused(&ctx, editor.response.id);
|
||||
self.refocus = focus::is_focused(ctx, editor.response.id);
|
||||
}
|
||||
// The editor claims Escape for the whole rename, as a text part with a draft does: Escape does not leave the
|
||||
// row. One the editor leaves untaken (it holds no draft yet) cancels the rename.
|
||||
keys::hold_escape(&ctx, editor.response.id);
|
||||
let escaped = !edited && focus::is_focused(&ctx, editor.response.id) && {
|
||||
let mut intents = keys::intents_of(&ctx, Some(editor.response.id), rtl);
|
||||
keys::hold_escape(ctx, editor.response.id);
|
||||
let escaped = !edited && focus::is_focused(ctx, editor.response.id) && {
|
||||
let mut intents = keys::intents_of(ctx, Some(editor.response.id), rtl);
|
||||
let left = intents.take(Intent::Cancel);
|
||||
keys::settle(&ctx, Some(editor.response.id), &intents);
|
||||
keys::settle(ctx, Some(editor.response.id), &intents);
|
||||
left
|
||||
};
|
||||
match end {
|
||||
@@ -896,7 +892,7 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
|
||||
let next = if forward { (at + 1..len).find(renamable) } else { (0..at).rev().find(renamable) };
|
||||
self.refocus = next.is_none();
|
||||
if let Some(next) = next {
|
||||
request::request_rename(&ctx, id, &self.source.key(next));
|
||||
request::request_rename(ctx, id, &self.source.key(next));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ use crate::style::Flags;
|
||||
use craft_behavior::Sense;
|
||||
use egui::{Context, Id, Rect, Ui};
|
||||
|
||||
/// A member with its id, whether it is enabled, its sense and what its run prepared.
|
||||
type Prepared<K, I> = (Member<K, ()>, Id, bool, Sense, run::MemberPrep<I>);
|
||||
|
||||
/// A visible item of a members collection, built by the row loop and shown once every member has joined the arena.
|
||||
pub(super) struct Member<K, I> {
|
||||
pub at: usize,
|
||||
@@ -45,7 +48,7 @@ impl<'r, C: Collection> ItemsHooks<'_, 'r, C> {
|
||||
let enabled = cx.core.resolved.enabled;
|
||||
let parent = access::fold::owner_of(ctx, id).unwrap_or(id);
|
||||
let hover = sensing::read_outcome(ctx, ArenaId::new(id)).hover.map(|hit| hit.owner);
|
||||
let mut prepared: Vec<(Member<C::Key, ()>, Id, bool, Sense, run::MemberPrep<C::Item<'r>>)> = members
|
||||
let mut prepared: Vec<Prepared<C::Key, C::Item<'r>>> = members
|
||||
.into_iter()
|
||||
.map(|member| {
|
||||
let Member { at, key, mut item, row, clip, flags, position, renaming, openers, shown } = member;
|
||||
|
||||
@@ -42,6 +42,10 @@ impl<C: Collection> ItemsHooks<'_, '_, C> {
|
||||
}
|
||||
|
||||
/// A press on a row selects it; a double press activates it; a right press asks for its menu.
|
||||
#[expect(
|
||||
clippy::cognitive_complexity,
|
||||
reason = "one match over the press kinds (select, activate, menu), each arm short; splitting it only moves the match"
|
||||
)]
|
||||
pub(super) fn press_step(&mut self, comp: &C, cx: &mut Cx<'_, C>, props: &CollectionProps, layout: &C::ItemLayout, at: Placement) {
|
||||
let Placement { rect, offset, rtl } = at;
|
||||
let ctx = cx.core.ctx.clone();
|
||||
|
||||
@@ -62,11 +62,14 @@ fn field_label(env: &Env, input: &LabelIn<'_>, id: Id, rect: Rect) -> FieldLabel
|
||||
if described.is_empty() { label } else { label.detail(described.join(". ")) }
|
||||
}
|
||||
|
||||
/// Draws trailing content in the rect the label step gives it.
|
||||
pub(crate) type ShowTrailing<'a> = Box<dyn FnOnce(&mut Ui, Rect) + 'a>;
|
||||
|
||||
/// Content the leaf label step shows after the label's text, inside the label (`BodyCx::labelled_with`): its size
|
||||
/// and how to show it in the rect the step gives it.
|
||||
pub(crate) struct Trailing<'a> {
|
||||
pub size: Vec2,
|
||||
pub show: Box<dyn FnOnce(&mut Ui, Rect) + 'a>,
|
||||
pub show: ShowTrailing<'a>,
|
||||
}
|
||||
|
||||
/// What the label step needs of one leaf child it labels (`PaintUi::labelled`, `BodyCx::labelled`).
|
||||
|
||||
@@ -322,10 +322,10 @@ fn snake(name: &str) -> Vec<String> {
|
||||
let starts = c.is_uppercase()
|
||||
&& index > 0
|
||||
&& (chars[index - 1].is_lowercase() || chars[index - 1].is_ascii_digit() || chars.get(index + 1).is_some_and(|next| next.is_lowercase()));
|
||||
if starts || words.is_empty() {
|
||||
words.push(String::new());
|
||||
match words.last_mut() {
|
||||
Some(word) if !starts => word.extend(c.to_lowercase()),
|
||||
_ => words.push(c.to_lowercase().collect()),
|
||||
}
|
||||
words.last_mut().expect("a word").extend(c.to_lowercase());
|
||||
}
|
||||
words
|
||||
}
|
||||
|
||||
@@ -71,10 +71,11 @@ pub(super) fn host(props: &ContainerProps, at: &HostCx<'_>, open: bool, title: &
|
||||
}
|
||||
}
|
||||
};
|
||||
if (open || mounted.exiting) && opens_dialog(&props.mount) {
|
||||
if let Some(shell) = at.env.get::<ShellEntry>().0 {
|
||||
shell.note_dialog();
|
||||
}
|
||||
if (open || mounted.exiting)
|
||||
&& opens_dialog(&props.mount)
|
||||
&& let Some(shell) = at.env.get::<ShellEntry>().0
|
||||
{
|
||||
shell.note_dialog();
|
||||
}
|
||||
mounted
|
||||
}
|
||||
|
||||
@@ -134,6 +134,10 @@ fn resolved_anchor(ctx: &Context, overlay: &Overlay, resolved: Rect, bounds: Rec
|
||||
/// The room a layer's body is measured in before the layer is placed: `content_room` for the anchor as the host
|
||||
/// resolves it in this pass, inside the screen rect the layer opened in `env` keeps inside.
|
||||
/// `id` is the layer, whose memory holds the pointer where it opened. `own` and `own_to_screen` are the owner's rect and its layer's map to screen space.
|
||||
#[expect(
|
||||
clippy::too_many_arguments,
|
||||
reason = "the measuring room reads the pass facts the caller holds as separate values; a struct would only restate them"
|
||||
)]
|
||||
pub(crate) fn measuring_room(
|
||||
ctx: &Context,
|
||||
env: &Env,
|
||||
|
||||
@@ -845,6 +845,10 @@ fn create_node(ctx: &Context, ui: &Ui, id: Id, member: bool, role: Role) -> bool
|
||||
}
|
||||
|
||||
/// Steps 6 to 16 of the pass, run in the `Ui` the host gives.
|
||||
#[expect(
|
||||
clippy::cognitive_complexity,
|
||||
reason = "steps 6 to 16 in their fixed order; each step is already its own function and the rest is the order"
|
||||
)]
|
||||
fn run_in_host(p: &mut Pass<'_, '_, '_>, ui: &mut Ui, host_at: Option<ShowAt>, host_env: Option<&Env>) {
|
||||
let ctx = p.p.core_ref().ctx.clone();
|
||||
let (id, rtl) = (p.resolved.id, p.env.direction.is_rtl());
|
||||
@@ -1274,6 +1278,10 @@ fn measured(t: &mut dyn Erased, input: &MeasureIn<'_>, style: &dyn StyleView, re
|
||||
}
|
||||
|
||||
/// The pipeline: steps 1 to 17 for one component, whatever its type and shape.
|
||||
#[expect(
|
||||
clippy::cognitive_complexity,
|
||||
reason = "steps 1 to 17 in their fixed order; each step is already its own function and the rest is the order"
|
||||
)]
|
||||
pub(super) fn run(t: &mut dyn Erased, ui: &mut Ui, at: ShowAt, mut tip: Option<TipFn<'_>>) {
|
||||
let ctx = ui.ctx().clone();
|
||||
let facts = t.facts();
|
||||
|
||||
@@ -31,7 +31,14 @@ enum Held<'c, C> {
|
||||
Lent(&'c mut C),
|
||||
}
|
||||
|
||||
/// The style step 2 stored for the later steps of the run.
|
||||
#[expect(clippy::expect_used, reason = "step 2 stores the style before any step that reads it")]
|
||||
fn step_style<S>(style: &Option<Arc<S>>) -> &S {
|
||||
style.as_deref().expect("step 2 ran")
|
||||
}
|
||||
|
||||
impl<C> Held<'_, C> {
|
||||
#[expect(clippy::expect_used, reason = "`Owned` holds the component from `new` until `finish`, the only call that empties it")]
|
||||
fn get(&mut self) -> &mut C {
|
||||
match self {
|
||||
Held::Owned(comp) => comp.as_mut().expect("the component is held until `finish`"),
|
||||
@@ -39,6 +46,7 @@ impl<C> Held<'_, C> {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::expect_used, reason = "`Owned` holds the component from `new` until `finish`, the only call that empties it")]
|
||||
fn get_ref(&self) -> &C {
|
||||
match self {
|
||||
Held::Owned(comp) => comp.as_ref().expect("the component is held until `finish`"),
|
||||
@@ -46,6 +54,7 @@ impl<C> Held<'_, C> {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::expect_used, clippy::unreachable, reason = "`finish` runs once per show, and only on the component a show owns")]
|
||||
fn take(&mut self) -> C {
|
||||
match self {
|
||||
Held::Owned(comp) => comp.take().expect("`finish` runs once"),
|
||||
@@ -123,22 +132,23 @@ impl<C: Component> Erased for Typed<'_, '_, C> {
|
||||
}
|
||||
|
||||
fn measure_content(&mut self, input: &MeasureIn<'_>, resolved: &Resolved<'_>) -> (Vec2, Inputs) {
|
||||
let style = self.style.as_deref().expect("step 2 ran");
|
||||
let style = step_style(&self.style);
|
||||
steps::measure_content(self.comp.get(), input, style, resolved, self.shown.as_deref())
|
||||
}
|
||||
|
||||
fn measured_extent(&mut self, at: &Measuring<'_, '_>, stage: &mut MemoryStage) -> Vec2 {
|
||||
let style = self.style.as_deref().expect("step 2 ran");
|
||||
let style = step_style(&self.style);
|
||||
let (extent, shown) = measured_extent(self.comp.get(), &mut *self.hooks, at, stage, style, self.shown.take());
|
||||
self.shown = shown;
|
||||
extent
|
||||
}
|
||||
|
||||
fn pass_extent(&mut self, at: &Measuring<'_, '_>) -> Vec2 {
|
||||
let style = self.style.as_deref().expect("step 2 ran");
|
||||
let style = step_style(&self.style);
|
||||
self.hooks.pass_extent(self.comp.get(), at, style, self.shown.clone())
|
||||
}
|
||||
|
||||
#[expect(clippy::expect_used, reason = "`Erased::style` produced the style this pipeline now hands back, so its type is `C::Style`")]
|
||||
fn with_cx<'a>(&mut self, core: CxCore<'a>, style: &'a dyn StyleView, rest: &mut dyn FnMut(&mut dyn ErasedPass<'a>) -> bool) {
|
||||
let style = style.as_any().downcast_ref::<C::Style>().expect("the pipeline holds the style `Erased::style` gave");
|
||||
let events = std::mem::take(&mut self.cancelled);
|
||||
@@ -459,6 +469,7 @@ impl<'a, C: Component> ErasedPass<'a> for TypedPass<'_, 'a, C> {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::expect_used, reason = "`super::run` runs every step, and the last one sets the output")]
|
||||
fn run<C: Component>(comp: C, ui: &mut Ui, at: ShowAt, tip: Option<TipFn<'_>>, hooks: &mut dyn ShapeHooks<C>) -> C::Output {
|
||||
let mut typed = Typed::new(Held::Owned(Some(comp)), hooks);
|
||||
super::run(&mut typed, ui, at, tip);
|
||||
@@ -533,7 +544,7 @@ fn unshown<C: Container>(comp: &mut C, ui: &Ui) -> Option<C::Output> {
|
||||
}
|
||||
let props = props.clone();
|
||||
let facts = TypeFacts::of::<C>();
|
||||
let source = comp.common(Internal::new()).id.clone();
|
||||
let source = comp.common(Internal::new()).id;
|
||||
let id = steps::id(ui, &source, false, false, facts.style_key, facts.name);
|
||||
let output = <C::Output as crate::contract::Outcome>::unshown(steps::inert_response(ui, id))?;
|
||||
let sizing = ui.is_sizing_pass();
|
||||
@@ -606,8 +617,8 @@ pub(crate) fn paint_face<C: Show>(ui: &mut Ui, env: &Env, source: &super::FaceSo
|
||||
let ctx = ui.ctx().clone();
|
||||
let common = std::mem::take(face.common_mut(Internal::new()));
|
||||
debug_assert!(common.tooltip.is_none(), "a face instance carries no tooltip; use `PartBuilder::tooltip`");
|
||||
let step1 = steps::env(&ctx, &env, &common, steps::variants::<C>(common.variant));
|
||||
let scx = steps::style_cx(&ctx, &env, &step1);
|
||||
let step1 = steps::env(&ctx, env, &common, steps::variants::<C>(common.variant));
|
||||
let scx = steps::style_cx(&ctx, env, &step1);
|
||||
let scx = source.ink.map_or(scx, |ink| scx.hosted(ink, source.muted));
|
||||
let style = steps::style::<C>(&ctx, &scx, face.style_key());
|
||||
let id = face_id(source.id, part);
|
||||
@@ -639,12 +650,12 @@ pub(crate) fn paint_face<C: Show>(ui: &mut Ui, env: &Env, source: &super::FaceSo
|
||||
cx.core.state = state;
|
||||
cx.core.stated = true;
|
||||
cx.core.ink = steps::surface_ink(StyleView::surface(&*style), &state, env.ink);
|
||||
steps::paint_surface(ui, &env, &cx.core, &*style);
|
||||
steps::paint_surface(ui, env, &cx.core, &*style);
|
||||
{
|
||||
let results = HashMap::new();
|
||||
let mut pui = PaintUi {
|
||||
ui: &mut *ui,
|
||||
env: &env,
|
||||
env: env,
|
||||
ink: cx.core.ink,
|
||||
// A face of an inactive part paints its data as `draw_part` does for the host.
|
||||
data: if source.result.inactive { crate::primitives::DataMode::Inactive } else { crate::primitives::DataMode::of(&state) },
|
||||
|
||||
@@ -167,13 +167,13 @@ pub fn fill_polygon(points: &[Pos2], color: Color32, feather: f32) -> Mesh {
|
||||
// An opaque inner and a clear outer vertex per point, half the feather each side of the edge (egui's
|
||||
// `fill_closed_path`), with the normals of egui's `Path::add_line_loop`.
|
||||
let edge_normal = |i: usize| (ring[(i + 1) % n] - ring[i]).normalized().rot90();
|
||||
for i in 0..n {
|
||||
for (i, &point) in ring.iter().enumerate() {
|
||||
let (before, after) = (edge_normal((i + n - 1) % n), edge_normal(i));
|
||||
let normal = (before + after) * 0.5;
|
||||
let length_sq = normal.length_sq();
|
||||
let normal = if length_sq > f32::EPSILON { normal / length_sq } else { after };
|
||||
mesh.colored_vertex(ring[i] - normal * (0.5 * feather), color);
|
||||
mesh.colored_vertex(ring[i] + normal * (0.5 * feather), Color32::TRANSPARENT);
|
||||
mesh.colored_vertex(point - normal * (0.5 * feather), color);
|
||||
mesh.colored_vertex(point + normal * (0.5 * feather), Color32::TRANSPARENT);
|
||||
}
|
||||
for i in 0..n as u32 {
|
||||
let before = (i + n as u32 - 1) % n as u32;
|
||||
|
||||
@@ -608,6 +608,7 @@ pub(crate) struct MemberResult {
|
||||
pub activated: bool,
|
||||
}
|
||||
|
||||
#[expect(clippy::unreachable, reason = "`sense_members` returns one result per spec")]
|
||||
pub(crate) fn sense_member(ui: &Ui, arena: ArenaId, spec: MemberSpec<'_>) -> MemberResult {
|
||||
let mut results = sense_members(ui, arena, std::slice::from_ref(&spec));
|
||||
results.pop().unwrap_or_else(|| unreachable!("one result per member"))
|
||||
|
||||
@@ -429,6 +429,6 @@ pub(crate) fn run(state: &mut TextState, mut input: AdapterIn<'_>) -> AdapterOut
|
||||
state.focused = shown.focused || input.held;
|
||||
let full = display;
|
||||
let layout = TextLayout::new(shown.galley, false, full);
|
||||
let baseline = (!layout.full.is_empty()).then(|| shown.galley_pos.y + layout.first_baseline);
|
||||
let baseline = (!layout.full.is_empty()).then_some(shown.galley_pos.y + layout.first_baseline);
|
||||
AdapterOut { layout, focused: shown.focused, baseline }
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ impl ImeResets {
|
||||
|
||||
/// Runs one pass of `viewport` at `time` seconds with `events` and `files`, on a window of `native_pixels_per_point`
|
||||
/// (egui's default when `None`). A viewport other than the root is a child window of the root, which stays live.
|
||||
#[expect(clippy::too_many_arguments, reason = "the arguments are the facts of one frame, and every caller passes them all")]
|
||||
pub(crate) fn run_frame(
|
||||
ctx: &Context,
|
||||
time: f64,
|
||||
|
||||
@@ -159,8 +159,9 @@ impl Request {
|
||||
let announce = (self.held.mods != mods).then(|| modifiers_changed(mods));
|
||||
let events: Frame = announce.into_iter().chain(events).collect();
|
||||
self.held.apply(&events);
|
||||
let at = self.steps.len();
|
||||
self.steps.push(events.into());
|
||||
self.steps.last_mut().expect("just pushed")
|
||||
&mut self.steps[at]
|
||||
}
|
||||
|
||||
/// A move to `at` unless the pointer is there, with `mods` announced.
|
||||
@@ -339,7 +340,6 @@ pub(crate) fn input_hook(ctx: &Context, input: &mut egui::RawInput) -> bool {
|
||||
let held = injected.held.entry(viewport).or_default();
|
||||
let before = held.clone();
|
||||
held.apply(&step.events);
|
||||
let lane = injected.lanes.get_mut(&viewport).expect("the lane of the popped step");
|
||||
lane.flight = Some(Flight { step, pass: pass_nr, focus: focused, until, before });
|
||||
return !lane.queue.is_empty();
|
||||
}
|
||||
|
||||
@@ -1261,6 +1261,7 @@ pub(crate) mod guard {
|
||||
|
||||
/// A service of type `S` is touched.
|
||||
#[cfg(feature = "testing")]
|
||||
#[expect(clippy::panic, reason = "the guard exists to stop a measuring run that reads a service outside the recorded paths")]
|
||||
pub(crate) fn touch<S>() {
|
||||
if !crate::runtime::egui::fixture::driving() || MEASURING.with(std::cell::Cell::get) == 0 || EMITTING.with(std::cell::Cell::get) > 0 {
|
||||
return;
|
||||
|
||||
@@ -183,6 +183,7 @@ pub(crate) fn with<S: PassLocal, R>(ctx: &Context, f: impl FnOnce(&mut S) -> R)
|
||||
let _release = Release(ctx);
|
||||
HELD.with(|held| {
|
||||
let held = held.borrow();
|
||||
#[expect(clippy::expect_used, reason = "`hold` has just moved the context's state into this thread")]
|
||||
let held = held.iter().find(|held| held.ctx == *ctx).expect("the state was just taken");
|
||||
f(&mut S::cell(&held.state).borrow_mut())
|
||||
})
|
||||
|
||||
@@ -266,8 +266,10 @@ fn tab_from_nothing(before: Before, shift: bool) -> (Option<Id>, bool) {
|
||||
};
|
||||
let mut frames = Frames::new();
|
||||
frames.idle(2, &mut show);
|
||||
if matches!(before, Before::FocusedUnstopped) {
|
||||
fixture::host_focus(&frames.ctx, unstopped.get().expect("the widget was shown"));
|
||||
if matches!(before, Before::FocusedUnstopped)
|
||||
&& let Some(id) = unstopped.get()
|
||||
{
|
||||
fixture::host_focus(&frames.ctx, id);
|
||||
frames.idle(2, &mut show);
|
||||
}
|
||||
assert_eq!(egui_focused(&frames.ctx), unstopped.get().filter(|_| matches!(before, Before::FocusedUnstopped)));
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Renderer {
|
||||
/// # Errors
|
||||
/// When wgpu fails to render or read back the image.
|
||||
pub fn render(&mut self, ctx: &Context, mut paint: FullOutput) -> Result<RgbaImage, String> {
|
||||
self.textures.extend(paint.textures_delta.set.iter().map(|(id, _)| *id));
|
||||
self.textures.extend(paint.textures_delta.set.keys().copied());
|
||||
for id in &paint.textures_delta.free {
|
||||
self.textures.remove(id);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ pub fn entry(tail: &[u8], [offset, len]: [u64; 2]) -> Option<&[u8]> {
|
||||
/// once. Entries whose different ranges overlap copy the shared bytes once each, and are refused
|
||||
/// once their copies pass that size, as VectorCraft's reader refuses them. Unlike
|
||||
/// [`Image::bytes`], `Entries` puts no limit on one entry: VectorCraft opens an uncompressed file
|
||||
/// whose entry is larger than [`MAX_ENTRY`].
|
||||
/// whose entry is larger than [`crate::MAX_ENTRY`].
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Entries<'a> {
|
||||
tail: &'a [u8],
|
||||
@@ -240,7 +240,7 @@ pub struct Tail<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Tail<'a> {
|
||||
/// An empty tail for a file of `version`, which is the file's own `version`; [`File::tail`]
|
||||
/// An empty tail for a file of `version`, which is the file's own `version`; [`crate::File::tail`]
|
||||
/// takes it from the file.
|
||||
pub fn new(version: u32) -> Self {
|
||||
Self { parts: vec![], len: 0, after: version >= TAIL_SINCE }
|
||||
|
||||
@@ -584,7 +584,6 @@ mod alpha_decode_tests {
|
||||
use crate::prores::bits::{Sink, Writer};
|
||||
use crate::prores::encode::encode_alpha;
|
||||
|
||||
#[test]
|
||||
#[test]
|
||||
fn custom_limits_preserve_large_4444_geometry_before_allocating() {
|
||||
let hdr = FrameHeader {
|
||||
@@ -622,6 +621,8 @@ mod alpha_decode_tests {
|
||||
let too_few_pixels = DecodeLimits { max_pixels: 8192 * 8192 - 1, ..soundcraft };
|
||||
assert!(matches!(decode_frame_with_limits(&data, &DecodeOptions::default(), &too_few_pixels), Err(Error::Unsupported("frame size"))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alpha_decoder_requires_complete_bounded_runs() {
|
||||
let mut out = [0u16; 1];
|
||||
assert!(decode_alpha(&[], AlphaType::Bits16, &mut out).is_err());
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
//! | `ready` | app → host | `version`, `appVersion?`, `file?` (`true`: it reads a `File`/`Blob` in slices) |
|
||||
//! | `host` | host → app | `version`, `handoff?` (`true`: the host routes hand-offs) |
|
||||
//! | `open` | host → app | `name`, and `bytes` or `file` + `size` |
|
||||
//! | `attach-pdf` | host → app | `name`, `bytes`, `page` (from 1), `insertion` ([x,y,z]), `width`, `height` in drawing units |
|
||||
//! | `attach-pdf` | host → app | `name`, `bytes`, `page` (from 1), `insertion` (`[x, y, z]`), `width`, `height` in drawing units |
|
||||
//! | `save` | app → host | `name`, `bytes`, `id?`, `saveAs?` |
|
||||
//! | `saved` | host → app | `id` |
|
||||
//! | `dirty` | app → host | `dirty` |
|
||||
|
||||
Reference in New Issue
Block a user