mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 02:09:00 +00:00
fw sync: L-319: moves a region passes its fallback collection stay its keys (page and end included); the rows' own scroll moves page
This commit is contained in:
@@ -979,8 +979,10 @@ fn scroll_rows(core: &mut CxCore<'_>, rect: Rect, scrolls: bool, mut offset: f64
|
||||
// The moves are taken once, in the real run (peeked while measuring). A control in a row left a page or end move
|
||||
// untaken: the collection, its rows' scroll owner, pages the rows.
|
||||
let view = f64::from(rect.height());
|
||||
let mut unpaged = Vec::new();
|
||||
for (mv, mods) in crate::contract::steps::scroll_moves(&ctx, id, quiet) {
|
||||
// A region's fallback collection (F-116) takes every move its region passed it as its own keys, page and end
|
||||
// included (L-319); the page and end moves a control in the rows left page the rows.
|
||||
let (scrolled, mut unpaged) = crate::contract::steps::scroll_and_fallback_moves(&ctx, id, quiet);
|
||||
for (mv, mods) in scrolled {
|
||||
let span = ScrollSpan::new(0.0..maximum + view, offset..offset + view);
|
||||
match craft_behavior::scroll::jump(&span, mv).filter(|_| scrolls) {
|
||||
Some(range) => offset = range.start,
|
||||
|
||||
@@ -39,7 +39,7 @@ pub(crate) use report::{ReportIn, report, report_inert, report_parts, validity_o
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) use scroll_owner::queue_reveal;
|
||||
pub use scroll_owner::scroll_step;
|
||||
pub(crate) use scroll_owner::{child_reveal, peek_reveal, queue_child_reveal, reveal_move, scroll_moves, take_reveal};
|
||||
pub(crate) use scroll_owner::{child_reveal, peek_reveal, queue_child_reveal, reveal_move, scroll_and_fallback_moves, scroll_moves, take_reveal};
|
||||
pub(crate) use sense::{part_state, register_wheel};
|
||||
pub(crate) use settle::settle;
|
||||
pub(crate) use state::{register_reset, state, value_flags};
|
||||
|
||||
@@ -17,7 +17,7 @@ pub(super) fn route_to_scroll_owner(core: &mut CxCore<'_>) {
|
||||
moves.push(mv);
|
||||
}
|
||||
if !moves.is_empty() {
|
||||
pass_state::with::<ScrollMoves, _>(&core.ctx, |queue| queue.0.extend(moves.drain(..).map(|(mv, mods)| (collection, mv, mods))));
|
||||
pass_state::with::<ScrollMoves, _>(&core.ctx, |queue| queue.0.extend(moves.drain(..).map(|(mv, mods)| (collection, mv, mods, true))));
|
||||
repaint::request(&core.ctx);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ pub(super) fn route_to_scroll_owner(core: &mut CxCore<'_>) {
|
||||
return;
|
||||
}
|
||||
let Some(owner) = core.env.scroll_owner() else { return };
|
||||
pass_state::with::<ScrollMoves, _>(&core.ctx, |queue| queue.0.extend(moves.into_iter().map(|(mv, mods)| (owner, mv, mods))));
|
||||
pass_state::with::<ScrollMoves, _>(&core.ctx, |queue| queue.0.extend(moves.into_iter().map(|(mv, mods)| (owner, mv, mods, false))));
|
||||
if reveal {
|
||||
pass_state::with::<Reveals, _>(&core.ctx, |reveals| reveals.0.push(Reveal { owner, to: RevealTo::Rect(core.rect) }));
|
||||
}
|
||||
@@ -124,12 +124,13 @@ pub(crate) fn child_reveal(ctx: &Context, owner: Id, quiet: bool) -> Option<Id>
|
||||
/// A page or end move a focused component left untaken, with its modifiers, addressed to the scroll owner around it
|
||||
/// (9.2 rule 5).
|
||||
#[derive(Default)]
|
||||
pub(crate) struct ScrollMoves(Vec<(Id, NavMove, MoveMods)>);
|
||||
/// Each move carries whether it came through a region's fallback collection (`ContainerProps::fallback_collection`).
|
||||
pub(crate) struct ScrollMoves(Vec<(Id, NavMove, MoveMods, bool)>);
|
||||
|
||||
/// The scroll moves addressed to `owner`, in the order they arrived: taken, or left queued when `quiet`.
|
||||
pub(crate) fn scroll_moves(ctx: &Context, owner: Id, quiet: bool) -> Vec<(NavMove, MoveMods)> {
|
||||
pass_state::with::<ScrollMoves, _>(ctx, |moves| {
|
||||
let mine = moves.0.iter().filter(|(id, ..)| *id == owner).map(|(_, mv, mods)| (*mv, *mods)).collect();
|
||||
let mine = moves.0.iter().filter(|(id, ..)| *id == owner).map(|(_, mv, mods, _)| (*mv, *mods)).collect();
|
||||
if !quiet {
|
||||
moves.0.retain(|(id, ..)| *id != owner);
|
||||
}
|
||||
@@ -137,6 +138,23 @@ pub(crate) fn scroll_moves(ctx: &Context, owner: Id, quiet: bool) -> Vec<(NavMov
|
||||
})
|
||||
}
|
||||
|
||||
/// [`scroll_moves`] apart: the page and end moves a component inside left for its scroll owner, and the moves a
|
||||
/// region's fallback collection takes as its own keys (every move, page and end included, L-319).
|
||||
pub(crate) fn scroll_and_fallback_moves(ctx: &Context, owner: Id, quiet: bool) -> (Vec<(NavMove, MoveMods)>, Vec<(NavMove, MoveMods)>) {
|
||||
pass_state::with::<ScrollMoves, _>(ctx, |moves| {
|
||||
let (mut scrolls, mut fallback) = (Vec::new(), Vec::new());
|
||||
for &(id, mv, mods, through_fallback) in &moves.0 {
|
||||
if id == owner {
|
||||
if through_fallback { fallback.push((mv, mods)) } else { scrolls.push((mv, mods)) }
|
||||
}
|
||||
}
|
||||
if !quiet {
|
||||
moves.0.retain(|(id, ..)| *id != owner);
|
||||
}
|
||||
(scrolls, fallback)
|
||||
})
|
||||
}
|
||||
|
||||
/// Targets with queued moves, to wake settled regions containing them.
|
||||
pub(crate) fn move_targets(ctx: &Context) -> Vec<Id> {
|
||||
pass_state::with::<ScrollMoves, _>(ctx, |moves| moves.0.iter().map(|(id, ..)| *id).collect())
|
||||
|
||||
Reference in New Issue
Block a user