From 29cb69f9d8ca85d485e1fe72f11cf2810e47ef9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 6 Nov 2026 14:07:44 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Curve=20editor:=20each=20key=20r?= =?UTF-8?q?ow's=20editor=20reads=20its=20own=20box,=20so=20two=20custom=20?= =?UTF-8?q?curves=20on=20the=20transform=20card=20each=20take=20their=20ow?= =?UTF-8?q?n=20drags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/app/src/main.rs | 9 +++++---- crates/app/src/ui/cards/curve.rs | 5 +++-- crates/app/src/ui/cards/keys.rs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 92fb52d..02f4a10 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -1304,9 +1304,10 @@ struct Player { opacity_drag: bool, /// The opacity row's bar, recorded at prepaint like the transform bars. opacity_bar: Rc>>, - /// The easing curve editor's box, recorded at prepaint: a press and a drag on it are read - /// against it. One editor is on screen at a time, since one card is open at a time. - curve_bounds: Rc>>, + /// Each easing curve editor's box, by key kind (placement, opacity, colour), recorded at + /// prepaint: a press and a drag on an editor are read against its own box. The transform + /// card can show two editors at once, one per key row. + curve_bounds: [Rc>>; 3], /// A curve handle is held: its draft curve, written to the key when the button comes up. curve_drag: Option, /// Each slider's box, recorded at prepaint -- [`Self::color_bars`]' own @@ -1812,7 +1813,7 @@ fn main() { transform_dragging: false, opacity_drag: false, opacity_bar: Rc::default(), - curve_bounds: Rc::default(), + curve_bounds: Default::default(), curve_drag: None, transform_bars: std::array::from_fn(|_| Rc::default()), pending_transform: None, diff --git a/crates/app/src/ui/cards/curve.rs b/crates/app/src/ui/cards/curve.rs index ad7a00f..92ec1e8 100644 --- a/crates/app/src/ui/cards/curve.rs +++ b/crates/app/src/ui/cards/curve.rs @@ -151,7 +151,7 @@ impl Player { let Some(KeyEase::Bezier(shown)) = self.key_here(kind) else { return; }; - let Some(unit) = unit_point(at, self.curve_bounds.get()) else { + let Some(unit) = unit_point(at, self.curve_bounds[super::keys::kind_id(kind)].get()) else { return; }; let handle = nearest_handle(shown, unit); @@ -161,7 +161,8 @@ impl Player { /// Moves the held handle to the pointer. The draft is drawn until the button comes up. pub(crate) fn drag_curve(&mut self, at: Point, cx: &mut Context) { - let unit = unit_point(at, self.curve_bounds.get()); + let Some(kind) = self.curve_drag.as_ref().map(|d| d.kind) else { return cx.notify() }; + let unit = unit_point(at, self.curve_bounds[super::keys::kind_id(kind)].get()); if let (Some(unit), Some(drag)) = (unit, self.curve_drag.as_mut()) && let Some(draft) = moved(drag.draft, drag.handle, unit) { diff --git a/crates/app/src/ui/cards/keys.rs b/crates/app/src/ui/cards/keys.rs index a75d79c..0fe4760 100644 --- a/crates/app/src/ui/cards/keys.rs +++ b/crates/app/src/ui/cards/keys.rs @@ -40,7 +40,7 @@ fn row_label(kind: KeyKind) -> &'static str { } } -fn kind_id(kind: KeyKind) -> usize { +pub(super) fn kind_id(kind: KeyKind) -> usize { match kind { KeyKind::Placement => 0, KeyKind::Opacity => 1, @@ -194,7 +194,7 @@ impl Player { ("key-curve", kind_id(kind)), kind, shown, - self.curve_bounds.clone(), + self.curve_bounds[kind_id(kind)].clone(), cx, )) .into_any_element()