forge
Explore
Log in

Don't you dare go Hollow

🐛 Curve editor: each key row's editor reads its own box, so two custom curves on the transform card each take their own drags

Browse files at this commit

29cb69f9d8ca85d485e1fe72f11cf2810e47ef9eAhmet Kaan GümüşParent: c77583c
crates/app/src/main.rsmodified+5 -4
@@ -1304,9 +1304,10 @@ struct Player {
13041304 opacity_drag: bool,
13051305 /// The opacity row's bar, recorded at prepaint like the transform bars.
13061306 opacity_bar: Rc<Cell<Bounds<Pixels>>>,
1307- /// The easing curve editor's box, recorded at prepaint: a press and a drag on it are read
1308- /// against it. One editor is on screen at a time, since one card is open at a time.
1309- curve_bounds: Rc<Cell<Bounds<Pixels>>>,
1307+ /// Each easing curve editor's box, by key kind (placement, opacity, colour), recorded at
1308+ /// prepaint: a press and a drag on an editor are read against its own box. The transform
1309+ /// card can show two editors at once, one per key row.
1310+ curve_bounds: [Rc<Cell<Bounds<Pixels>>>; 3],
13101311 /// A curve handle is held: its draft curve, written to the key when the button comes up.
13111312 curve_drag: Option<ui::cards::curve::CurveDrag>,
13121313 /// Each slider's box, recorded at prepaint -- [`Self::color_bars`]' own
@@ -1812,7 +1813,7 @@ fn main() {
18121813 transform_dragging: false,
18131814 opacity_drag: false,
18141815 opacity_bar: Rc::default(),
1815- curve_bounds: Rc::default(),
1816+ curve_bounds: Default::default(),
18161817 curve_drag: None,
18171818 transform_bars: std::array::from_fn(|_| Rc::default()),
18181819 pending_transform: None,
crates/app/src/ui/cards/curve.rsmodified+3 -2
@@ -151,7 +151,7 @@ impl Player {
151151 let Some(KeyEase::Bezier(shown)) = self.key_here(kind) else {
152152 return;
153153 };
154- let Some(unit) = unit_point(at, self.curve_bounds.get()) else {
154+ let Some(unit) = unit_point(at, self.curve_bounds[super::keys::kind_id(kind)].get()) else {
155155 return;
156156 };
157157 let handle = nearest_handle(shown, unit);
@@ -161,7 +161,8 @@ impl Player {
161161
162162 /// Moves the held handle to the pointer. The draft is drawn until the button comes up.
163163 pub(crate) fn drag_curve(&mut self, at: Point<Pixels>, cx: &mut Context<Self>) {
164- let unit = unit_point(at, self.curve_bounds.get());
164+ let Some(kind) = self.curve_drag.as_ref().map(|d| d.kind) else { return cx.notify() };
165+ let unit = unit_point(at, self.curve_bounds[super::keys::kind_id(kind)].get());
165166 if let (Some(unit), Some(drag)) = (unit, self.curve_drag.as_mut())
166167 && let Some(draft) = moved(drag.draft, drag.handle, unit)
167168 {
crates/app/src/ui/cards/keys.rsmodified+2 -2
@@ -40,7 +40,7 @@ fn row_label(kind: KeyKind) -> &'static str {
4040 }
4141 }
4242
43-fn kind_id(kind: KeyKind) -> usize {
43+pub(super) fn kind_id(kind: KeyKind) -> usize {
4444 match kind {
4545 KeyKind::Placement => 0,
4646 KeyKind::Opacity => 1,
@@ -194,7 +194,7 @@ impl Player {
194194 ("key-curve", kind_id(kind)),
195195 kind,
196196 shown,
197- self.curve_bounds.clone(),
197+ self.curve_bounds[kind_id(kind)].clone(),
198198 cx,
199199 ))
200200 .into_any_element()