diff --git a/core/build-icon-font.sh b/core/build-icon-font.sh index 0ad510c..dc46542 100755 --- a/core/build-icon-font.sh +++ b/core/build-icon-font.sh @@ -18,11 +18,8 @@ # Needs python3 and network access; fontTools is fetched into a temporary # venv, so nothing has to be installed on the machine. # -# The same arrangement as the Compose app's `app/build-icon-font.sh`, which -# this is copied from -- including the Mono face and the Material Design -# family, so an icon means the same thing in both apps. Copied rather than -# shared because most of it is the GLYPHS list, which has to differ: the -# point of subsetting is to ship only the codepoints one app draws. +# The Mono face makes icon metrics stable; the Material Design family keeps +# their meanings conventional. set -euo pipefail GLYPHS=( @@ -48,8 +45,7 @@ unicodes="$(IFS=,; echo "${GLYPHS[*]}")" mkdir -p "$(dirname "$out")" # The Mono face, where every glyph is one em wide and one em tall, so two # icons at the same font size are the same size without either being given -# one -- the same reason the Compose app's script takes it. It is also what -# makes an icon's box predictable beside a line of text. +# one, which makes an icon's box predictable beside a line of text. "$work/venv/bin/pyftsubset" "$work/SymbolsNerdFontMono-Regular.ttf" \ --unicodes="$unicodes" \ --layout-features= \ diff --git a/run-headless.sh b/run-headless.sh index 750c19e..d7b0b30 100755 --- a/run-headless.sh +++ b/run-headless.sh @@ -3,14 +3,14 @@ # # ./run-headless.sh tabs [-- cargo args] # ./run-headless.sh tabs --shot /tmp/tabs.png --seconds 4 -# ./run-headless.sh phone --phone --dir ../app-rust --shot /tmp/p.png -# ./run-headless.sh phone --phone --dir ../app-rust \ -# --replay ../app-rust/touch/flick-120hz.touch --shot /tmp/p.png +# ./run-headless.sh phone --phone --dir ../app --shot /tmp/p.png +# ./run-headless.sh phone --phone --dir ../app \ +# --replay ../app/touch/flick-120hz.touch --shot /tmp/p.png # # `--dir DIR` names the workspace to build in, defaulting to `iris/` (this # script's own directory). The app's examples -- the phone-sized transcript # screen and everything else that is about *this product* -- live in -# `app-rust/`, which is a workspace of its own; `replay-touch` is still +# `app/`, which is a workspace of its own; `replay-touch` is still # built from iris, since it is part of the rig rather than of either app. # # `--phone` is layer 2 of docs/RUST.md's "Three test layers": the output @@ -24,7 +24,7 @@ # shaped, which is what every other example wants. # # `--replay FILE` drives one of the `.touch` recordings the headless -# tests use (`app-rust/touch/`) into the window through +# tests use (`app/touch/`) into the window through # `rig-input`'s `replay-touch` -- one recording, both layers. With # `--shot` it also writes `-before.png` from just before the # gesture, since "the list moved" is a claim about two pictures. diff --git a/src/android/access.rs b/src/android/access.rs index a6922ab..1de2787 100644 --- a/src/android/access.rs +++ b/src/android/access.rs @@ -8,7 +8,7 @@ use iris_core::{AccessTree, UiRenderState, UiRsc, Widgets}; /// The `ActivationHandler` `accesskit_android::Adapter` asks for its /// initial tree from -- unlike `accesskit_winit`'s handlers (see -/// `default/access.rs`), this one is only ever invoked synchronously from +/// `desktop/access.rs`), this one is only ever invoked synchronously from /// inside a JNI callback that already holds everything it needs, so it can /// just borrow `IrisViewPeer`'s own fields for the length of one call /// rather than going through a channel. diff --git a/src/android/view.rs b/src/android/view.rs index efdbfe3..dc65117 100644 --- a/src/android/view.rs +++ b/src/android/view.rs @@ -217,7 +217,11 @@ impl IrisViewPeer { .get_or_insert_with(|| DeviceClock::anchored(Instant::now(), event_time, oldest)) } - fn generic_motion(&mut self, ctx: &mut CallbackCtx, event: &MotionEvent<'_>) -> bool { + fn generic_motion<'local>( + &mut self, + ctx: &mut CallbackCtx<'local>, + event: &MotionEvent<'local>, + ) -> bool { let action = event.action_masked(&mut ctx.env); let event_time = event.event_time_nanos(&mut ctx.env); let mut clock = self.device_clock(event_time, event_time); @@ -539,11 +543,20 @@ impl ViewPeer for IrisViewPeer { let action = event.action(&mut ctx.env); let x = event.x(&mut ctx.env); let y = event.y(&mut ctx.env); - let ui = self.state.android_state_mut(); - if let Some(events) = ui - .access_adapter - .on_hover_event(&mut NullActionHandler, action, x, y) - { + let access_events = { + let render_handle = self.rsc.ui.render_state(); + let render_state = render_handle.get(); + let mut source = AndroidAccessSource { + widgets: self.rsc.widgets(), + render: &render_state, + rsc: &self.rsc, + }; + self.state + .android_state_mut() + .access_adapter + .on_hover_event(&mut source, action, x, y) + }; + if let Some(events) = access_events { ctx.push_dynamic_deferred_callback(move |env, view| { raise_if_enabled(env, view, events); }); diff --git a/src/lib.rs b/src/lib.rs index 5144d22..93cae5b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,24 +12,20 @@ pub mod android; #[cfg(not(target_os = "android"))] pub mod desktop; -pub mod attr; pub mod diagnostics; -pub mod event; pub mod harness; -pub mod overlay; pub mod platform; -pub mod runtime; -pub mod sense; -pub mod state; -pub mod task; +pub mod rsc; pub mod widget; +// Preserve concise public paths while implementation files stay grouped. +pub use rsc::attr; +pub use rsc::{event, overlay, sense, state, task}; + #[cfg(test)] mod access_tests; #[cfg(test)] mod layout_tests; -#[cfg(test)] -mod sense_tests; pub use iris_core as core; pub use iris_macro as macros; @@ -41,16 +37,10 @@ pub mod prelude { #[cfg(not(target_os = "android"))] pub use desktop::*; - pub use attr::*; - pub use event::*; pub use iris_core::*; pub use iris_macro::*; - pub use overlay::*; pub use platform::*; - pub use runtime::*; - pub use sense::*; - pub use state::*; - pub use task::*; + pub use rsc::*; pub use widget::*; pub use iris_core::util::Vec2; diff --git a/src/attr.rs b/src/rsc/attr.rs similarity index 100% rename from src/attr.rs rename to src/rsc/attr.rs diff --git a/src/event.rs b/src/rsc/event.rs similarity index 98% rename from src/event.rs rename to src/rsc/event.rs index f6a317e..1b8ba67 100644 --- a/src/event.rs +++ b/src/rsc/event.rs @@ -2,7 +2,7 @@ use iris_core::*; use iris_macro::*; use std::sync::Arc; -use crate::task::{TaskCtx, TaskUpdate, Tasks}; +use super::task::{TaskCtx, TaskUpdate, Tasks}; #[derive(Eq, PartialEq, Hash, Clone)] pub struct Submit; diff --git a/src/runtime.rs b/src/rsc/mod.rs similarity index 88% rename from src/runtime.rs rename to src/rsc/mod.rs index b3a2c79..72c83b8 100644 --- a/src/runtime.rs +++ b/src/rsc/mod.rs @@ -1,3 +1,22 @@ +//! Host-independent resources carried by [`AppRsc`]. + +pub mod attr; +pub mod event; +pub mod overlay; +pub mod sense; +pub mod state; +pub mod task; + +#[cfg(test)] +mod sense_tests; + +pub use attr::*; +pub use event::*; +pub use overlay::*; +pub use sense::*; +pub use state::*; +pub use task::*; + use crate::prelude::*; use std::sync::Arc; diff --git a/src/overlay.rs b/src/rsc/overlay.rs similarity index 100% rename from src/overlay.rs rename to src/rsc/overlay.rs diff --git a/src/sense.rs b/src/rsc/sense.rs similarity index 100% rename from src/sense.rs rename to src/rsc/sense.rs diff --git a/src/sense_tests.rs b/src/rsc/sense_tests.rs similarity index 100% rename from src/sense_tests.rs rename to src/rsc/sense_tests.rs diff --git a/src/state.rs b/src/rsc/state.rs similarity index 92% rename from src/state.rs rename to src/rsc/state.rs index d9cff08..d166663 100644 --- a/src/state.rs +++ b/src/rsc/state.rs @@ -78,9 +78,8 @@ impl<'a, T: 'static> FnOnce<(&'a mut WidgetState,)> for WeakState { /// What `Rsc[weak_handle]` indexes through -- one impl per kind of handle /// (a widget, a piece of per-widget state), shared by both backends' `Rsc` /// types since indexing a widget tree has nothing to do with windowing. -/// Each backend still needs its own `Index`/`IndexMut for ItsRsc` -/// (`default/mod.rs`, `android/view.rs`), because a blanket impl over every -/// `I: RscIdx` for every possible `Rsc` would conflict between crates. +/// `AppRsc` supplies the shared `Index`/`IndexMut` implementation; a blanket +/// implementation over every possible resource type would conflict. pub trait RscIdx { type Output; fn get(self, rsc: &Rsc) -> &Self::Output; diff --git a/src/task.rs b/src/rsc/task.rs similarity index 98% rename from src/task.rs rename to src/rsc/task.rs index 752a6f9..ff9ffbd 100644 --- a/src/task.rs +++ b/src/rsc/task.rs @@ -19,7 +19,7 @@ use tokio::{ /// android-view has no `Window` at all, and the redraw request there is a /// JNI call (`View::post_frame_callback`) rather than a method call on a /// value this crate owns. Each backend supplies its own implementation -- -/// `default/render.rs` for winit, `android/render.rs` for android-view -- +/// `desktop/render.rs` for winit, `android/render.rs` for android-view -- /// and this module never needs to know which one it is holding. pub trait RequestRedraw: Send + Sync + 'static { fn request_redraw(&self); diff --git a/src/widget/event.rs b/src/widget/event.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/widget/position/align.rs b/src/widget/layout/align.rs similarity index 100% rename from src/widget/position/align.rs rename to src/widget/layout/align.rs diff --git a/src/widget/position/layer.rs b/src/widget/layout/layer.rs similarity index 100% rename from src/widget/position/layer.rs rename to src/widget/layout/layer.rs diff --git a/src/widget/position/lazy_span.rs b/src/widget/layout/lazy_span.rs similarity index 100% rename from src/widget/position/lazy_span.rs rename to src/widget/layout/lazy_span.rs diff --git a/src/widget/position/max_size.rs b/src/widget/layout/max_size.rs similarity index 100% rename from src/widget/position/max_size.rs rename to src/widget/layout/max_size.rs diff --git a/src/widget/position/mod.rs b/src/widget/layout/mod.rs similarity index 100% rename from src/widget/position/mod.rs rename to src/widget/layout/mod.rs diff --git a/src/widget/position/offset.rs b/src/widget/layout/offset.rs similarity index 100% rename from src/widget/position/offset.rs rename to src/widget/layout/offset.rs diff --git a/src/widget/position/pad.rs b/src/widget/layout/pad.rs similarity index 100% rename from src/widget/position/pad.rs rename to src/widget/layout/pad.rs diff --git a/src/widget/position/scroll_area.rs b/src/widget/layout/scroll_area.rs similarity index 100% rename from src/widget/position/scroll_area.rs rename to src/widget/layout/scroll_area.rs diff --git a/src/widget/position/scrollable.rs b/src/widget/layout/scrollable.rs similarity index 100% rename from src/widget/position/scrollable.rs rename to src/widget/layout/scrollable.rs diff --git a/src/widget/position/sized.rs b/src/widget/layout/sized.rs similarity index 100% rename from src/widget/position/sized.rs rename to src/widget/layout/sized.rs diff --git a/src/widget/position/span.rs b/src/widget/layout/span.rs similarity index 100% rename from src/widget/position/span.rs rename to src/widget/layout/span.rs diff --git a/src/widget/position/stack.rs b/src/widget/layout/stack.rs similarity index 100% rename from src/widget/position/stack.rs rename to src/widget/layout/stack.rs diff --git a/src/widget/mod.rs b/src/widget/mod.rs index 016fbe8..2dc3385 100644 --- a/src/widget/mod.rs +++ b/src/widget/mod.rs @@ -1,14 +1,14 @@ mod image; +mod layout; mod mask; -mod position; mod ptr; mod rect; mod text; mod trait_fns; pub use image::*; +pub use layout::*; pub use mask::*; -pub use position::*; pub use ptr::*; pub use rect::*; pub use text::*;