From 335f41a8d08b7d2013fed5135fc680532fed7ef6 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 12 Nov 2026 01:01:03 +0000 Subject: [PATCH] Component::BINDS_VIEW: a binding that is the component's view takes the wheel without focus; TimelineView and the navigator preview set it --- crates/timeline/src/ui/view.rs | 1 + crates/ui-canvas/src/canvas/navigator/preview.rs | 1 + crates/ui-contract/src/contract/mod.rs | 4 ++++ crates/ui-contract/src/contract/run.rs | 4 +++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/timeline/src/ui/view.rs b/crates/timeline/src/ui/view.rs index 1351223b8..6be16f1a5 100644 --- a/crates/timeline/src/ui/view.rs +++ b/crates/timeline/src/ui/view.rs @@ -445,6 +445,7 @@ impl Component for TimelineView<'_> { const KEYS: KeyUse = KeyUse::SPLITTER; const OVERLAYS: bool = false; const SINGLE_VALUE: bool = true; + const BINDS_VIEW: bool = true; type Style = TimelineViewStyle; type Output = TimelineViewOutput; diff --git a/crates/ui-canvas/src/canvas/navigator/preview.rs b/crates/ui-canvas/src/canvas/navigator/preview.rs index ebd9c4e32..b11216082 100644 --- a/crates/ui-canvas/src/canvas/navigator/preview.rs +++ b/crates/ui-canvas/src/canvas/navigator/preview.rs @@ -286,6 +286,7 @@ impl Component for Navigator<'_> { const ROLE: Role = Role::GROUP; const OVERLAYS: bool = false; const KEYS: KeyUse = KeyUse::of(Input::Pointer).with_keep(KeepKeys::BlockArrows).with_activate(ActivateKeys::Neither); + const BINDS_VIEW: bool = true; type Style = NavigatorStyle; type Output = NavigatorOutput; diff --git a/crates/ui-contract/src/contract/mod.rs b/crates/ui-contract/src/contract/mod.rs index eb12ab7e2..010631aed 100644 --- a/crates/ui-contract/src/contract/mod.rs +++ b/crates/ui-contract/src/contract/mod.rs @@ -321,6 +321,10 @@ pub trait Component: Meta + Sized { /// Two sources: a canvas control (`#[component(canvas_control)]`) is single-value by kind, since it edits one /// layer's geometry; any other component declares it here. const SINGLE_VALUE: bool = false; + /// Whether the binding is the component's view of what it shows (a time area's scroll and zoom, a navigator's + /// canvas view), not a value the user edits. The wheel moves a view without focus, as it scrolls a scroll + /// region; a bound value control takes it only while focused or armed. + const BINDS_VIEW: bool = false; /// The style type. type Style: ComponentStyle; diff --git a/crates/ui-contract/src/contract/run.rs b/crates/ui-contract/src/contract/run.rs index 663124bd1..800b93bf7 100644 --- a/crates/ui-contract/src/contract/run.rs +++ b/crates/ui-contract/src/contract/run.rs @@ -398,6 +398,7 @@ pub(crate) struct TypeFacts { pub stops: bool, pub canvas_control: bool, pub labelled_after: bool, + pub binds_view: bool, /// The style key's type, which `Auto` ids are counted per. pub style_key: TypeId, } @@ -414,6 +415,7 @@ impl TypeFacts { stops: C::STOPS, canvas_control: C::CANVAS_CONTROL, labelled_after: C::LABELLED_AFTER, + binds_view: C::BINDS_VIEW, style_key: TypeId::of::(), } } @@ -842,7 +844,7 @@ fn run_in_host(p: &mut Pass<'_, '_, '_>, ui: &mut Ui, host_at: Option, h // A body's wheel share is its scroll taker (body step, step 7); the gate value does not take the wheel. A body root that // senses the wheel itself (a canvas) registers like any other component. if !inert && (e.shape() != ShapeKind::Body || own.intersects(Sense::WHEEL | Sense::WHEEL_X)) { - steps::register_wheel(&ctx, id, rect, own, e.bound().0, env.wheel); + steps::register_wheel(&ctx, id, rect, own, e.bound().0 && !facts.binds_view, env.wheel); } // 8 sense p.trace.mark(Step::Sense);