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 {
1304 opacity_drag: bool,1304 opacity_drag: bool,
1305 /// The opacity row's bar, recorded at prepaint like the transform bars.1305 /// The opacity row's bar, recorded at prepaint like the transform bars.
1306 opacity_bar: Rc<Cell<Bounds<Pixels>>>,1306 opacity_bar: Rc<Cell<Bounds<Pixels>>>,
1307- /// The easing curve editor's box, recorded at prepaint: a press and a drag on it are read1307+ /// Each easing curve editor's box, by key kind (placement, opacity, colour), recorded at
1308- /// against it. One editor is on screen at a time, since one card is open at a time.1308+ /// prepaint: a press and a drag on an editor are read against its own box. The transform
1309- curve_bounds: Rc<Cell<Bounds<Pixels>>>,1309+ /// card can show two editors at once, one per key row.
1310+ curve_bounds: [Rc<Cell<Bounds<Pixels>>>; 3],
1310 /// A curve handle is held: its draft curve, written to the key when the button comes up.1311 /// A curve handle is held: its draft curve, written to the key when the button comes up.
1311 curve_drag: Option<ui::cards::curve::CurveDrag>,1312 curve_drag: Option<ui::cards::curve::CurveDrag>,
1312 /// Each slider's box, recorded at prepaint -- [`Self::color_bars`]' own1313 /// Each slider's box, recorded at prepaint -- [`Self::color_bars`]' own
@@ -1812,7 +1813,7 @@ fn main() {
1812 transform_dragging: false,1813 transform_dragging: false,
1813 opacity_drag: false,1814 opacity_drag: false,
1814 opacity_bar: Rc::default(),1815 opacity_bar: Rc::default(),
1815- curve_bounds: Rc::default(),1816+ curve_bounds: Default::default(),
1816 curve_drag: None,1817 curve_drag: None,
1817 transform_bars: std::array::from_fn(|_| Rc::default()),1818 transform_bars: std::array::from_fn(|_| Rc::default()),
1818 pending_transform: None,1819 pending_transform: None,
crates/app/src/ui/cards/curve.rsmodified+3 -2
@@ -151,7 +151,7 @@ impl Player {
151 let Some(KeyEase::Bezier(shown)) = self.key_here(kind) else {151 let Some(KeyEase::Bezier(shown)) = self.key_here(kind) else {
152 return;152 return;
153 };153 };
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 {
155 return;155 return;
156 };156 };
157 let handle = nearest_handle(shown, unit);157 let handle = nearest_handle(shown, unit);
@@ -161,7 +161,8 @@ impl Player {
161 161
162 /// Moves the held handle to the pointer. The draft is drawn until the button comes up.162 /// Moves the held handle to the pointer. The draft is drawn until the button comes up.
163 pub(crate) fn drag_curve(&mut self, at: Point<Pixels>, cx: &mut Context<Self>) {163 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());
165 if let (Some(unit), Some(drag)) = (unit, self.curve_drag.as_mut())166 if let (Some(unit), Some(drag)) = (unit, self.curve_drag.as_mut())
166 && let Some(draft) = moved(drag.draft, drag.handle, unit)167 && let Some(draft) = moved(drag.draft, drag.handle, unit)
167 {168 {
crates/app/src/ui/cards/keys.rsmodified+2 -2
@@ -40,7 +40,7 @@ fn row_label(kind: KeyKind) -> &'static str {
40 }40 }
41 }41 }
42 42
43-fn kind_id(kind: KeyKind) -> usize {43+pub(super) fn kind_id(kind: KeyKind) -> usize {
44 match kind {44 match kind {
45 KeyKind::Placement => 0,45 KeyKind::Placement => 0,
46 KeyKind::Opacity => 1,46 KeyKind::Opacity => 1,
@@ -194,7 +194,7 @@ impl Player {
194 ("key-curve", kind_id(kind)),194 ("key-curve", kind_id(kind)),
195 kind,195 kind,
196 shown,196 shown,
197- self.curve_bounds.clone(),197+ self.curve_bounds[kind_id(kind)].clone(),
198 cx,198 cx,
199 ))199 ))
200 .into_any_element()200 .into_any_element()