forge
Explore
Log in

Don't you dare go Hollow

The bench answers the mouse again

Browse files at this commit

aaf986f816b850410366a24ebb30b82da8a6c731Ahmet Kaan GümüşParent: ac08751
  • feat
    • the bench answers the mouse again
Show full message
✨ feat(ui): the bench answers the mouse again

Dragging did not work, zoom did not work, and there was no way to
seek through the project. All three were the same omission: the bench got
the drop from the dock and nothing else, while every other pointer gesture
stayed behind in the old room.

A clip drags along its lane and onto another one, its edges trim under the
pointer at any width the aim allows, the wheel pans and zooms about the
cursor as it always did, and a track head drags to reorder. None of this is
new machinery — it is the timeline's own doors, finally called from the new
room.

Zoom had no home: the actions existed and worked, but nothing in the room
showed them, so the only way in was a memorised key. The spine has a VIEW
group now, ranked below cutting and above the once-a-project lane adds.

The contact strip becomes the seek instrument it was meant to be: a drag
along it scrubs the film continuously rather than sliding the bench window,
it carries the playhead as a lamp-white mark so it reads as a slider with a
handle, and panning moves to the viewport bracket's own grips.
crates/app/src/ui/bench_stance.rsmodified+106 -9
@@ -18,17 +18,29 @@
18 //! trace, name plate, splice gaps) and the width ladder that degrades it18 //! trace, name plate, splice gaps) and the width ladder that degrades it
19 //! (DESIGN §7) -- neither existed on the legacy timeline in this shape.19 //! (DESIGN §7) -- neither existed on the legacy timeline in this shape.
20 //!20 //!
21-//! Not reused, deferred: `ClipDrag` (moving a placed clip to another lane by21+//! Now also reused: `ClipDrag` (moving a placed clip along its lane and onto
22-//! hand), the mouse edge-trim strips, fades/dissolve glyphs and the lane22+//! another, `Player::dragged`/`Player::move_clip`), the mouse edge-trim
23-//! header reorder drag. The cut grammar (`,` `.` `[` `]` `/` `s`) never needs23+//! strips (`Player::start_trim`/`trims(span)`, the same minimum-width rule
24-//! any of them -- `nudge_cut` and friends act on `Player::selected` directly,24+//! the legacy strips use), `Player::timeline_wheel` (ctrl+wheel zooms about
25-//! with no element under the pointer required -- so they are out of this25+//! the pointer, a bare wheel scrolls the bed -- the same mapping on the
26-//! slice's reach; `Player::pick` (click-select) and the asset drop (place)26+//! ruler and on every bed) and `LaneDrag`/`Player::reorder_lane` (drag a
27-//! are the two pointer gestures the charter actually asked this surface to27+//! track head onto another to swap their order). `Player::drag_move`/
28-//! answer for.28+//! `Player::drag_release`, wired once on the window's own root
29+//! (`render.rs`), already carry a trim or a scroll off the 6px strip that
30+//! started it, for the darkroom tree exactly as for the legacy one -- no
31+//! root wiring lives here.
32+//!
33+//! Still deferred: fades/dissolve glyphs, and the lane header's own
34+//! drop-line cue (the legacy `LaneDrop` preview) -- a plain drag_over
35+//! highlight stands in for it here, since the cue itself is display-only and
36+//! `reorder_lane` at the release does not need it.
37+//!
38+//! `nudge_cut` and friends still act on `Player::selected` directly, with no
39+//! element under the pointer required, and stay untouched by any of this.
29 40
30 use crate::*;41 use crate::*;
31 use crate::ui::type_scale::{self, Typeset};42 use crate::ui::type_scale::{self, Typeset};
43+use crate::ui::widgets::*;
32 44
33 /// The pinned ruler's own height, above the lane stack -- tall enough for a45 /// The pinned ruler's own height, above the lane stack -- tall enough for a
34 /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with46 /// tick line plus a mono `MM:SS` label under it (DESIGN §5's "tick marks with
@@ -149,6 +161,11 @@ fn clip_box(
149 pick_links: &[Option<u32>],161 pick_links: &[Option<u32>],
150 cx: &mut Context<Player>,162 cx: &mut Context<Player>,
151 ) -> impl IntoElement + use<> {163 ) -> impl IntoElement + use<> {
164+ // The placed clip, for the drag payload -- and the clip as an in-flight
165+ // edge trim is showing it, for the box (`Player::trimmed`, the same
166+ // split `ui/timeline.rs`'s own clip box makes).
167+ let placed = *clip;
168+ let clip = &player.trimmed(lane, idx, placed);
152 let (start, len) = (169 let (start, len) = (
153 f64::from(clip.start) / player.fps,170 f64::from(clip.start) / player.fps,
154 f64::from(clip.frames()) / player.fps,171 f64::from(clip.frames()) / player.fps,
@@ -191,6 +208,9 @@ fn clip_box(
191 }208 }
192 _ => format!("{len:.1}s"),209 _ => format!("{len:.1}s"),
193 };210 };
211+ // For the drag ghost and the fallback label both -- kept before `label`
212+ // is consumed by the name plate below.
213+ let ghost: SharedString = label.clone().unwrap_or_else(|| lane.label()).into();
194 div()214 div()
195 .id(("bench-clip", lane.ord * 1000 + lane.kind as usize * 100 + idx))215 .id(("bench-clip", lane.ord * 1000 + lane.kind as usize * 100 + idx))
196 .absolute()216 .absolute()
@@ -213,6 +233,44 @@ fn clip_box(
213 this.pick((lane, idx), event.modifiers.control, cx);233 this.pick((lane, idx), event.modifiers.control, cx);
214 }),234 }),
215 )235 )
236+ // Dragged, it moves: to the frame and the lane it is let go over
237+ // (`Player::move_clip`, `ClipDrag`) -- the same payload and the same
238+ // ghost tooltip `ui/timeline.rs`'s own clip box drags.
239+ .on_drag(ClipDrag { lane, idx, clip: placed }, {
240+ let ghost = ghost.clone();
241+ move |_, _, _, cx| cx.new(|_| Tip(ghost.clone()))
242+ })
243+ // The two edge strips a drag lengthens or shortens the clip by
244+ // (`Player::start_trim`), gated on the same `trims(span)` floor the
245+ // legacy strips use -- a clip too narrow to aim at keeps its whole
246+ // padded box as a body to select and drag by instead (the `[`/`]`
247+ // chords still trim it either way).
248+ .children(
249+ [Edge::Start, Edge::End]
250+ .into_iter()
251+ .filter(|_| trims(span))
252+ .map(|edge| {
253+ let mut zone = div()
254+ .absolute()
255+ .top_0()
256+ .h_full()
257+ .w(px(EDGE_W))
258+ .occlude()
259+ .cursor(CursorStyle::ResizeLeftRight)
260+ .hover(|s| s.bg(rgb(INK1())))
261+ .on_mouse_down(
262+ MouseButton::Left,
263+ cx.listener(move |this, event: &MouseDownEvent, _, cx| {
264+ this.start_trim(lane, idx, edge, event.modifiers.control, cx);
265+ }),
266+ );
267+ zone = match edge {
268+ Edge::Start => zone.left_0(),
269+ Edge::End => zone.right_0(),
270+ };
271+ zone
272+ }),
273+ )
216 // Ink spine: 3px left edge, the source's own ink (hook above).274 // Ink spine: 3px left edge, the source's own ink (hook above).
217 .when(has_spine, |d| {275 .when(has_spine, |d| {
218 d.child(276 d.child(
@@ -354,14 +412,25 @@ fn lane_row(
354 let dot = clips412 let dot = clips
355 .first()413 .first()
356 .map_or_else(INK4, |clip| source_tint(clip.source));414 .map_or_else(INK4, |clip| source_tint(clip.source));
415+ let head_ghost: SharedString = lane.label().into();
357 div()416 div()
358 .id(("bench-lane", lane.ord * 10 + lane.kind as usize))417 .id(("bench-lane", lane.ord * 10 + lane.kind as usize))
359 .flex_none()418 .flex_none()
360 .h(px(h))419 .h(px(h))
361 .flex()420 .flex()
421+ // Dragged, the whole track moves in the stack (`LaneDrag`,
422+ // `Player::reorder_lane`) -- let go anywhere along the row, not just
423+ // over the head column, since a slot is what is being aimed at.
424+ // corner-cut: no drop-line cue (module doc) -- a plain highlight
425+ // while the pointer is over the row stands in for it.
426+ .drag_over::<LaneDrag>(|d, _, _, _| d.bg(rgb(DARK_RAISED())))
427+ .on_drop(cx.listener(move |this, drag: &LaneDrag, _, cx| {
428+ this.reorder_lane(drag.0, lane, cx);
429+ }))
362 .child(430 .child(
363 // Pinned track head.431 // Pinned track head.
364 div()432 div()
433+ .id(("bench-lane-head", lane.ord * 10 + lane.kind as usize))
365 .flex_none()434 .flex_none()
366 .w(px(HEAD_W))435 .w(px(HEAD_W))
367 .h_full()436 .h_full()
@@ -371,6 +440,10 @@ fn lane_row(
371 .justify_center()440 .justify_center()
372 .gap(px(2.))441 .gap(px(2.))
373 .bg(rgb(DARK_PANEL()))442 .bg(rgb(DARK_PANEL()))
443+ .cursor(CursorStyle::OpenHand)
444+ .on_drag(LaneDrag(lane), move |_, _, _, cx| {
445+ cx.new(|_| Tip(head_ghost.clone()))
446+ })
374 // MOCK-SPEC.md "Bench": "V1, A1 in mono".447 // MOCK-SPEC.md "Bench": "V1, A1 in mono".
375 .type_style(type_scale::mono(448 .type_style(type_scale::mono(
376 type_scale::CHORD_METADATA_MIN_PX,449 type_scale::CHORD_METADATA_MIN_PX,
@@ -382,7 +455,8 @@ fn lane_row(
382 )455 )
383 .child(456 .child(
384 // The bed: a drop target for the Sources tab (`AssetDrag`,457 // The bed: a drop target for the Sources tab (`AssetDrag`,
385- // reused from `ui/timeline.rs`) and every clip on it.458+ // reused from `ui/timeline.rs`), a placed clip (`ClipDrag`) and
459+ // every clip on it.
386 div()460 div()
387 .id(("bench-bed", lane.ord * 10 + lane.kind as usize))461 .id(("bench-bed", lane.ord * 10 + lane.kind as usize))
388 .relative()462 .relative()
@@ -397,6 +471,22 @@ fn lane_row(
397 let at = this.place_frame(window.mouse_position().x).0;471 let at = this.place_frame(window.mouse_position().x).0;
398 this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx)472 this.insert_source(&drag.0.clone(), drag.1, Some(lane), Some(at), cx)
399 }))473 }))
474+ .drag_over::<ClipDrag>(|d, _, _, _| d.bg(rgb(DARK_RAISED())))
475+ .on_drop(cx.listener(move |this, drag: &ClipDrag, window, cx| {
476+ let Some(idx) = this.dragged(drag) else {
477+ return;
478+ };
479+ this.move_clip(drag.lane, idx, lane, window.mouse_position().x, cx)
480+ }))
481+ // The wheel, matched to the legacy timeline's own mapping:
482+ // ctrl+wheel zooms about the pointer, a bare wheel scrolls
483+ // the bed along the film (`Player::timeline_wheel`). Stopped
484+ // here so gpui's own overflow scroll on the lane column
485+ // (`bench-lanes`) never answers the same notch a second time.
486+ .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| {
487+ cx.stop_propagation();
488+ this.timeline_wheel(event, cx);
489+ }))
400 .children(boxes),490 .children(boxes),
401 )491 )
402 }492 }
@@ -471,6 +561,13 @@ pub(crate) fn render(player: &mut Player, box_h: f32, cx: &mut Context<Player>)
471 this.scrub_to(event.position.x, true, cx);561 this.scrub_to(event.position.x, true, cx);
472 }),562 }),
473 )563 )
564+ // Ctrl+wheel zooms about the pointer, a bare one scrolls the
565+ // bed along -- the same mapping every bed below gives, and
566+ // the legacy ruler's own (`ui/timeline.rs`'s
567+ // `on_scroll_wheel` at its ruler strip).
568+ .on_scroll_wheel(cx.listener(|this, event: &ScrollWheelEvent, _, cx| {
569+ this.timeline_wheel(event, cx);
570+ }))
474 .children(ticks.into_iter().map(|(x, label)| {571 .children(ticks.into_iter().map(|(x, label)| {
475 div()572 div()
476 .absolute()573 .absolute()
crates/app/src/ui/spine_stance.rsmodified+14 -0
@@ -226,6 +226,20 @@ pub(crate) fn render(player: &Player, cx: &mut Context<Player>) -> impl IntoElem
226 player,226 player,
227 cx,227 cx,
228 ))228 ))
229+ // VIEW group, added this task: ZoomIn/ZoomOut/ZoomFit (keymap.rs) had
230+ // real, already-working handlers (`Player::zoom`/`zoom_fit`, wired
231+ // into the legacy `ui/toolbar.rs`) but no home anywhere in the
232+ // darkroom -- a DESIGN §9 "nothing lives only on a key" violation.
233+ // Placed between CUT and TRACK per §11 check 1 (task frequency):
234+ // reading the timeline at a different scale happens many times a
235+ // session (more than the once-per-project lane add below it), but
236+ // less than walking/trimming cuts above it.
237+ .child(group_head("view"))
238+ .child(pair(
239+ glyph("spine-zoom-out", "−", ActionId::ZoomOut, false, player, cx),
240+ glyph("spine-zoom-in", "+", ActionId::ZoomIn, false, player, cx),
241+ ))
242+ .child(glyph("spine-zoom-fit", "⊡", ActionId::ZoomFit, false, player, cx))
229 .child(group_head("track"))243 .child(group_head("track"))
230 .child(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, player, cx))244 .child(glyph("spine-add-video", "+V", ActionId::AddVideoLane, false, player, cx))
231 .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, player, cx))245 .child(glyph("spine-add-audio", "+A", ActionId::AddAudioLane, false, player, cx))
crates/app/src/ui/timeband_stance.rsmodified+100 -58
@@ -173,7 +173,7 @@ fn cut_readout(player: &Player) -> impl IntoElement {
173 /// instead of `bench_stance`'s per-lane pixel scale -- the cheapest honest173 /// instead of `bench_stance`'s per-lane pixel scale -- the cheapest honest
174 /// whole-film trace this app can draw without a new decode pass. Splice174 /// whole-film trace this app can draw without a new decode pass. Splice
175 /// ticks (video-lane clip boundaries) still mark cut points on top of it.175 /// ticks (video-lane clip boundaries) still mark cut points on top of it.
176-fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement {176+fn contact_strip(player: &Player, position: f64, cx: &mut Context<Player>) -> impl IntoElement {
177 let duration = player.drawn_duration();177 let duration = player.drawn_duration();
178 let view = player.view();178 let view = player.view();
179 let (left_frac, width_frac) = if duration > 0. {179 let (left_frac, width_frac) = if duration > 0. {
@@ -230,9 +230,17 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement
230 .h(px(28.))230 .h(px(28.))
231 .cursor_pointer()231 .cursor_pointer()
232 .tooltip(|_, cx| {232 .tooltip(|_, cx| {
233- cx.new(|_| Tip("Contact strip — click jumps, drag pans the bench".into()))233+ cx.new(|_| Tip("Contact strip — drag scrubs the playhead, click jumps; drag the bracket's grips to pan the bench".into()))
234 .into()234 .into()
235 })235 })
236+ // Division of the plain drag (MOCK-SPEC "Contact strip", task's own
237+ // instruction to decide honestly): a person reaches for this strip to
238+ // move through the FILM far more often than to slide the bench's own
239+ // viewport window, so the strip's own drag now scrubs the playhead
240+ // continuously -- press-and-move is not just a jump on release. The
241+ // bracket keeps panning, but only from its own grip notches
242+ // (`viewport_bracket` below), which `stop_propagation` on their own
243+ // press so a pan-start never also fires a scrub-jump underneath it.
236 .on_mouse_down(244 .on_mouse_down(
237 MouseButton::Left,245 MouseButton::Left,
238 cx.listener({246 cx.listener({
@@ -243,30 +251,43 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement
243 let frac = frac_along(event.position.x, bounds.get());251 let frac = frac_along(event.position.x, bounds.get());
244 this.seek(f64::from(frac) * duration, cx);252 this.seek(f64::from(frac) * duration, cx);
245 }253 }
246- PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x))));
247 }254 }
248 }),255 }),
249 )256 )
250- .on_mouse_move(cx.listener(move |this, event: &MouseMoveEvent, _, cx| {257+ .on_mouse_move(cx.listener({
251- let Some(last_x) = PAN_ANCHOR.with(Cell::get) else {258+ let bounds = strip_bounds.clone();
252- return;259+ move |this, event: &MouseMoveEvent, _, cx| {
253- };260+ if event.pressed_button != Some(MouseButton::Left) {
254- match event.pressed_button {261+ PAN_ANCHOR.with(|a| a.set(None));
255- Some(MouseButton::Left) => {262+ return;
256- let bounds = STRIP_BOUNDS.with(Rc::clone).get();263+ }
257- let w = f32::from(bounds.size.width).max(1.);264+ match PAN_ANCHOR.with(Cell::get) {
258- let dx = f32::from(event.position.x) - last_x;265+ // A pan is live (started on the bracket's own grips): slide
259- let duration = this.drawn_duration();266+ // the bench viewport instead of the playhead.
260- if duration > 0. {267+ Some(last_x) => {
261- let delta = f64::from(dx / w) * duration;268+ let b = STRIP_BOUNDS.with(Rc::clone).get();
262- let span = this.view().span();269+ let w = f32::from(b.size.width).max(1.);
263- let max_start = (duration - span).max(0.);270+ let dx = f32::from(event.position.x) - last_x;
264- this.scale.start = (this.scale.start + delta).clamp(0., max_start);271+ let duration = this.drawn_duration();
272+ if duration > 0. {
273+ let delta = f64::from(dx / w) * duration;
274+ let span = this.view().span();
275+ let max_start = (duration - span).max(0.);
276+ this.scale.start = (this.scale.start + delta).clamp(0., max_start);
277+ }
278+ PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x))));
279+ }
280+ // No pan armed: the plain drag scrubs, continuously
281+ // reseeking to wherever the hand is along the strip.
282+ None => {
283+ let duration = this.drawn_duration();
284+ if duration > 0. {
285+ let frac = frac_along(event.position.x, bounds.get());
286+ this.seek(f64::from(frac) * duration, cx);
287+ }
265 }288 }
266- PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x))));
267- cx.notify();
268 }289 }
269- _ => PAN_ANCHOR.with(|a| a.set(None)),290+ cx.notify();
270 }291 }
271 }))292 }))
272 .on_mouse_up(293 .on_mouse_up(
@@ -323,42 +344,63 @@ fn contact_strip(player: &Player, cx: &mut Context<Player>) -> impl IntoElement
323 .border_l_1()344 .border_l_1()
324 .border_r_1()345 .border_r_1()
325 .border_color(rgb(INK1()))346 .border_color(rgb(INK1()))
326- .child(347+ .child(grip("stance-strip-grip-lt", true, true))
327- div()348+ .child(grip("stance-strip-grip-lb", true, false))
328- .absolute()349+ .child(grip("stance-strip-grip-rt", false, true))
329- .left_0()350+ .child(grip("stance-strip-grip-rb", false, false)),
330- .top_0()351+ )
331- .w(px(2.))352+ // The lamp-white playhead marker: this is what turns the strip from
332- .h(px(6.))353+ // a trace into a slider with a handle (task's own wording) -- the
333- .bg(rgb(INK1())),354+ // one 1px line on the whole band that names *this* film moment,
334- )355+ // drawn last so it always sits above the trace and the bracket.
335- .child(356+ .when(duration > 0., |el| {
336- div()357+ let frac = ((position / duration).clamp(0., 1.)) as f32;
337- .absolute()358+ el.child(
338- .left_0()359+ div()
339- .bottom_0()360+ .id("stance-strip-playhead")
340- .w(px(2.))361+ .absolute()
341- .h(px(6.))362+ .left(relative(frac))
342- .bg(rgb(INK1())),363+ .top_0()
343- )364+ .h_full()
344- .child(365+ .w(px(1.))
345- div()366+ .bg(rgb(LAMP_WHITE())),
346- .absolute()367+ )
347- .right_0()368+ })
348- .top_0()369+}
349- .w(px(2.))370+
350- .h(px(6.))371+/// One grip notch on the viewport bracket (MOCK-SPEC "grip notches"): the
351- .bg(rgb(INK1())),372+/// only part of the contact strip that pans the bench window rather than
352- )373+/// scrubbing the playhead (see [`contact_strip`]'s own doc on that split).
353- .child(374+/// `stop_propagation` on its own press so starting a pan here never also
354- div()375+/// fires the strip's scrub-jump underneath it.
355- .absolute()376+fn grip(id: &'static str, left: bool, top: bool) -> impl IntoElement {
356- .right_0()377+ div()
357- .bottom_0()378+ .id(id)
358- .w(px(2.))379+ .absolute()
359- .h(px(6.))380+ .when(left, |d| d.left(px(-3.)))
360- .bg(rgb(INK1())),381+ .when(!left, |d| d.right(px(-3.)))
361- ),382+ .when(top, |d| d.top_0())
383+ .when(!top, |d| d.bottom_0())
384+ .w(px(8.))
385+ .h(px(10.))
386+ .cursor_col_resize()
387+ .child(
388+ div()
389+ .absolute()
390+ .when(left, |d| d.left(px(3.)))
391+ .when(!left, |d| d.right(px(3.)))
392+ .when(top, |d| d.top_0())
393+ .when(!top, |d| d.bottom_0())
394+ .w(px(2.))
395+ .h(px(6.))
396+ .bg(rgb(INK1())),
397+ )
398+ .on_mouse_down(
399+ MouseButton::Left,
400+ move |event: &MouseDownEvent, _, cx| {
401+ PAN_ANCHOR.with(|a| a.set(Some(f32::from(event.position.x))));
402+ cx.stop_propagation();
403+ },
362 )404 )
363 }405 }
364 406
@@ -480,6 +522,6 @@ pub(crate) fn render(player: &mut Player, position: f64, cx: &mut Context<Player
480 )),522 )),
481 )523 )
482 .child(cut_readout(player))524 .child(cut_readout(player))
483- .child(contact_strip(player, cx))525+ .child(contact_strip(player, position, cx))
484 .child(export_chip(player, cx))526 .child(export_chip(player, cx))
485 }527 }