Every spine verb answers a right-click on the thing it acts on
Browse files at this commitcb302ca8ef23fa3081f06c265fd09f3a0a201d23Parent: b8a94e6- feat
- every spine verb answers a right-click on the thing it acts on
7 changed files +298 -19
- crates/app/src/menus.rs +67 -3
- crates/app/src/oracle.rs +20 -1
- crates/app/src/player/timeline_edit.rs +43 -0
- crates/app/src/tests/editing.rs +78 -2
- crates/app/src/tests/mod.rs +3 -3
- crates/app/src/ui/bench_stance.rs +45 -1
- crates/app/src/ui/overlays.rs +42 -9
crates/app/src/menus.rsmodified+67 -3
| @@ -13,6 +13,15 @@ pub(crate) enum MenuOn { | |||
| 13 | /// `(start, frames)` of the gap, in timeline frames -- what | 13 | /// `(start, frames)` of the gap, in timeline frames -- what |
| 14 | /// [`Player::close_gap`] ripples shut. | 14 | /// [`Player::close_gap`] ripples shut. |
| 15 | Gap(u32, u32), | 15 | Gap(u32, u32), |
| 16 | + /// The bench itself: the ruler, or the empty stretch below the last lane. | ||
| 17 | + /// Nothing under the pointer is a clip, so what the menu offers is what | ||
| 18 | + /// the *timeline* can be told -- walking its cuts, its zoom, its snap and | ||
| 19 | + /// the undo pair ([`BENCH_ITEMS`]). The lane field means nothing here and | ||
| 20 | + /// no row reads it. | ||
| 21 | + Bench, | ||
| 22 | + /// A lane head: the verbs of the track itself, on the lane the menu | ||
| 23 | + /// already names ([`oracle::lane_items`]). | ||
| 24 | + Head, | ||
| 16 | } | 25 | } |
| 17 | 26 | ||
| 18 | /// An open clip menu: what it was opened on, where it hangs, and whether it | 27 | /// An open clip menu: what it was opened on, where it hangs, and whether it |
| @@ -179,15 +188,22 @@ impl RowItem { | |||
| 179 | /// action a stroke already reaches -- the menu is a second way *to* the actions | 188 | /// action a stroke already reaches -- the menu is a second way *to* the actions |
| 180 | /// and never a second version of them -- so both the label and the hint come | 189 | /// and never a second version of them -- so both the label and the hint come |
| 181 | /// out of the keymap registry and the two can never disagree. | 190 | /// out of the keymap registry and the two can never disagree. |
| 182 | -pub(crate) const MENU_ITEMS: [ActionId; 16] = [ | 191 | +pub(crate) const MENU_ITEMS: [ActionId; 21] = [ |
| 183 | ActionId::Cut, | 192 | ActionId::Cut, |
| 193 | + // The cut machinery (DESIGN.md §6) on the very clip it is about: the | ||
| 194 | + // trims, their trim-to-playhead pair and the loop-trim were strokes the | ||
| 195 | + // spine rail listed and nothing else did, and the subject cut a | ||
| 196 | + // right-click names is exactly the one they act on. | ||
| 197 | + ActionId::TrimIn, | ||
| 198 | + ActionId::TrimOut, | ||
| 199 | + ActionId::TrimInToPlayhead, | ||
| 200 | + ActionId::TrimOutToPlayhead, | ||
| 201 | + ActionId::LoopTrim, | ||
| 184 | // The clipboard pair, which had no door but a chord: copy takes the clip the | 202 | // The clipboard pair, which had no door but a chord: copy takes the clip the |
| 185 | // menu names, and paste is the timeline's rather than this clip's -- the | 203 | // menu names, and paste is the timeline's rather than this clip's -- the |
| 186 | // same kind of global item the mute below already is. | 204 | // same kind of global item the mute below already is. |
| 187 | ActionId::Copy, | 205 | ActionId::Copy, |
| 188 | ActionId::Paste, | 206 | ActionId::Paste, |
| 189 | - ActionId::Delete, | ||
| 190 | - ActionId::Lift, | ||
| 191 | ActionId::Regroup, | 207 | ActionId::Regroup, |
| 192 | ActionId::Detach, | 208 | ActionId::Detach, |
| 193 | ActionId::Group, | 209 | ActionId::Group, |
| @@ -205,8 +221,56 @@ pub(crate) const MENU_ITEMS: [ActionId; 16] = [ | |||
| 205 | ActionId::Transform, | 221 | ActionId::Transform, |
| 206 | ActionId::Fit, | 222 | ActionId::Fit, |
| 207 | ActionId::ToggleMute, | 223 | ActionId::ToggleMute, |
| 224 | + // Last, under the rule line the render draws before the first of them | ||
| 225 | + // (DESIGN §9): the two that take the clip off the lane. | ||
| 226 | + ActionId::Delete, | ||
| 227 | + ActionId::Lift, | ||
| 228 | +]; | ||
| 229 | + | ||
| 230 | +/// What a right-click on the bench itself offers -- the ruler and the empty | ||
| 231 | +/// stretch under the lanes. The verbs of the *timeline*: walking its cuts at | ||
| 232 | +/// either stride (DESIGN §6's odometer), what it is looked at through, and the | ||
| 233 | +/// undo pair, which is the one thing every editor expects on empty canvas. | ||
| 234 | +/// Not a junk drawer (§9): nothing here acts on a clip, and everything here | ||
| 235 | +/// acts on the thing the pointer is over. | ||
| 236 | +pub(crate) const BENCH_ITEMS: [ActionId; 10] = [ | ||
| 237 | + ActionId::WalkCutPrev, | ||
| 238 | + ActionId::WalkCutNext, | ||
| 239 | + ActionId::WalkCutPrev10, | ||
| 240 | + ActionId::WalkCutNext10, | ||
| 241 | + ActionId::ZoomOut, | ||
| 242 | + ActionId::ZoomIn, | ||
| 243 | + ActionId::ZoomFit, | ||
| 244 | + ActionId::ToggleSnap, | ||
| 245 | + ActionId::Undo, | ||
| 246 | + ActionId::Redo, | ||
| 208 | ]; | 247 | ]; |
| 209 | 248 | ||
| 249 | +/// The tracks a lane head's menu can add, in the order it lists them. Its | ||
| 250 | +/// remove is the one of the clicked lane's own kind and comes from | ||
| 251 | +/// [`oracle::lane_items`], which is what puts it under the rule line. | ||
| 252 | +pub(crate) const HEAD_ADDS: [ActionId; 3] = [ | ||
| 253 | + ActionId::AddVideoLane, | ||
| 254 | + ActionId::AddAudioLane, | ||
| 255 | + ActionId::AddSubtitleLane, | ||
| 256 | +]; | ||
| 257 | + | ||
| 258 | +/// Whether a menu row takes something away -- what DESIGN §9 puts below a rule | ||
| 259 | +/// line, wherever the row is listed. One answer, so the clip menu and the lane | ||
| 260 | +/// head's menu cannot come to disagree about which of their rows is the | ||
| 261 | +/// dangerous one. | ||
| 262 | +pub(crate) fn destructive(action: ActionId) -> bool { | ||
| 263 | + matches!( | ||
| 264 | + action, | ||
| 265 | + ActionId::Delete | ||
| 266 | + | ActionId::Lift | ||
| 267 | + | ActionId::RemoveVideoLane | ||
| 268 | + | ActionId::RemoveAudioLane | ||
| 269 | + | ActionId::RemoveSubtitleLane | ||
| 270 | + ) | ||
| 271 | +} | ||
| 272 | + | ||
| 273 | + | ||
| 210 | /// One row of the actions card, in the order it lists them: a heading, then | 274 | /// One row of the actions card, in the order it lists them: a heading, then |
| 211 | /// every action the registry files under it, then the strokes the modal cards | 275 | /// every action the registry files under it, then the strokes the modal cards |
| 212 | /// answer themselves. | 276 | /// answer themselves. |
crates/app/src/oracle.rsmodified+20 -1
| @@ -314,7 +314,7 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { | |||
| 314 | ActionId::TrimInToPlayhead | ActionId::TrimOutToPlayhead => match ctx.clip { | 314 | ActionId::TrimInToPlayhead | ActionId::TrimOutToPlayhead => match ctx.clip { |
| 315 | None => Enable::No("no subject cut"), | 315 | None => Enable::No("no subject cut"), |
| 316 | Some((clip, _)) if ctx.playhead < clip.start || ctx.playhead > clip.end() => { | 316 | Some((clip, _)) if ctx.playhead < clip.start || ctx.playhead > clip.end() => { |
| 317 | - Enable::No("playhead is outside the subject cut") | 317 | + Enable::No("the playhead is off this cut") |
| 318 | } | 318 | } |
| 319 | _ => Enable::Yes, | 319 | _ => Enable::Yes, |
| 320 | }, | 320 | }, |
| @@ -358,6 +358,25 @@ pub(crate) fn enable_lane(action: ActionId, lane: Lane, ctx: Ctx) -> Enable { | |||
| 358 | } | 358 | } |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | +/// The rows a lane head's menu draws: the three tracks a project can gain, | ||
| 362 | +/// and -- under the rule line the render draws before it ([`destructive`]) -- | ||
| 363 | +/// the one remove that means anything on the lane that was right-clicked. A | ||
| 364 | +/// video head never offers to take an audio track off: DESIGN §9's "verbs of | ||
| 365 | +/// the thing under the cursor", read literally. | ||
| 366 | +/// | ||
| 367 | +/// The removes take the *last* track of the kind (the engine's own rule, | ||
| 368 | +/// which their labels say), so this lists at most one of them and never a | ||
| 369 | +/// second row arguing about the same act. | ||
| 370 | +pub(crate) fn lane_items(lane: Lane) -> Vec<ActionId> { | ||
| 371 | + let mut items = HEAD_ADDS.to_vec(); | ||
| 372 | + items.push(match lane.kind { | ||
| 373 | + LaneKind::Video => ActionId::RemoveVideoLane, | ||
| 374 | + LaneKind::Audio => ActionId::RemoveAudioLane, | ||
| 375 | + LaneKind::Subtitle => ActionId::RemoveSubtitleLane, | ||
| 376 | + }); | ||
| 377 | + items | ||
| 378 | +} | ||
| 379 | + | ||
| 361 | /// The rows a clip menu draws, for the clip it was opened on: the registry | 380 | /// The rows a clip menu draws, for the clip it was opened on: the registry |
| 362 | /// filtered by the one availability oracle, and the *only* way that menu is | 381 | /// filtered by the one availability oracle, and the *only* way that menu is |
| 363 | /// built. An action that means nothing for what was right-clicked -- a grade on | 382 | /// built. An action that means nothing for what was right-clicked -- a grade on |
crates/app/src/player/timeline_edit.rsmodified+43 -0
| @@ -1212,6 +1212,49 @@ impl Player { | |||
| 1212 | cx.notify(); | 1212 | cx.notify(); |
| 1213 | } | 1213 | } |
| 1214 | 1214 | ||
| 1215 | + /// Opens the bench's own menu: what a right-click on the ruler, or on the | ||
| 1216 | + /// empty stretch under the last lane, names -- the timeline rather than | ||
| 1217 | + /// anything on it ([`BENCH_ITEMS`]). No lane and no selection: the lane | ||
| 1218 | + /// field is `V1` because the struct has one, and no row reads it. | ||
| 1219 | + /// | ||
| 1220 | + /// Refused with no timeline open, like every menu here: a card that paints | ||
| 1221 | + /// nothing while `overlaid()` swallows the keys is an invisible modal | ||
| 1222 | + /// (`tests/cards.rs`'s FAULT 2 rule). | ||
| 1223 | + pub(crate) fn open_bench_menu(&mut self, at: Point<Pixels>, cx: &mut Context<Self>) { | ||
| 1224 | + if self.modal() || self.session.is_none() { | ||
| 1225 | + return; | ||
| 1226 | + } | ||
| 1227 | + self.context_menu = Some(ContextMenu { | ||
| 1228 | + lane: Lane::V1, | ||
| 1229 | + on: MenuOn::Bench, | ||
| 1230 | + at, | ||
| 1231 | + details: false, | ||
| 1232 | + }); | ||
| 1233 | + cx.notify(); | ||
| 1234 | + } | ||
| 1235 | + | ||
| 1236 | + /// Opens a lane head's menu on the track that was right-clicked: the tracks | ||
| 1237 | + /// a project can gain, and the one remove that applies to this lane's kind | ||
| 1238 | + /// ([`oracle::lane_items`]). Nothing is selected -- a head owns no clip -- | ||
| 1239 | + /// which is [`Player::open_gap_menu`]'s rule on the other empty target. | ||
| 1240 | + pub(crate) fn open_head_menu( | ||
| 1241 | + &mut self, | ||
| 1242 | + lane: Lane, | ||
| 1243 | + at: Point<Pixels>, | ||
| 1244 | + cx: &mut Context<Self>, | ||
| 1245 | + ) { | ||
| 1246 | + if self.modal() || self.session.is_none() { | ||
| 1247 | + return; | ||
| 1248 | + } | ||
| 1249 | + self.context_menu = Some(ContextMenu { | ||
| 1250 | + lane, | ||
| 1251 | + on: MenuOn::Head, | ||
| 1252 | + at, | ||
| 1253 | + details: false, | ||
| 1254 | + }); | ||
| 1255 | + cx.notify(); | ||
| 1256 | + } | ||
| 1257 | + | ||
| 1215 | /// Closes the gap `(start, frames)` -- Premiere's "Close Gap", scoped to | 1258 | /// Closes the gap `(start, frames)` -- Premiere's "Close Gap", scoped to |
| 1216 | /// `lane` and, when the gap borders a take, to the take's other lane too | 1259 | /// `lane` and, when the gap borders a take, to the take's other lane too |
| 1217 | /// ([`engine::PlaybackSession::gap_take_scope`]): a lane not sharing the | 1260 | /// ([`engine::PlaybackSession::gap_take_scope`]): a lane not sharing the |
crates/app/src/tests/editing.rsmodified+78 -2
| @@ -335,10 +335,12 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() { | |||
| 335 | menu_items(cap), | 335 | menu_items(cap), |
| 336 | vec![ | 336 | vec![ |
| 337 | ActionId::Paste, | 337 | ActionId::Paste, |
| 338 | - ActionId::Delete, | ||
| 339 | ActionId::Detach, | 338 | ActionId::Detach, |
| 340 | ActionId::Group, | 339 | ActionId::Group, |
| 341 | ActionId::ToggleMute, | 340 | ActionId::ToggleMute, |
| 341 | + // Below the rule line the render draws before it, like every | ||
| 342 | + // other row that takes something away (DESIGN §9). | ||
| 343 | + ActionId::Delete, | ||
| 342 | ], | 344 | ], |
| 343 | "the caption's menu is its removal, its group rows, and the global ones", | 345 | "the caption's menu is its removal, its group rows, and the global ones", |
| 344 | ); | 346 | ); |
| @@ -1964,7 +1966,7 @@ fn trim_to_playhead_needs_a_subject_cut_with_the_playhead_on_it() { | |||
| 1964 | }; | 1966 | }; |
| 1965 | assert_eq!( | 1967 | assert_eq!( |
| 1966 | enable(ActionId::TrimOutToPlayhead, off), | 1968 | enable(ActionId::TrimOutToPlayhead, off), |
| 1967 | - Enable::No("playhead is outside the subject cut") | 1969 | + Enable::No("the playhead is off this cut") |
| 1968 | ); | 1970 | ); |
| 1969 | let on = Ctx { | 1971 | let on = Ctx { |
| 1970 | clip: Some((clip, Lane::V1)), | 1972 | clip: Some((clip, Lane::V1)), |
| @@ -2720,3 +2722,77 @@ fn escape_with_nothing_open_empties_the_selection() { | |||
| 2720 | "bare escape must still route to Deselect for that arm to ever run" | 2722 | "bare escape must still route to Deselect for that arm to ever run" |
| 2721 | ); | 2723 | ); |
| 2722 | } | 2724 | } |
| 2725 | + | ||
| 2726 | +/// The gate that keeps "option C" honest. The spine rail is gone -- nothing on | ||
| 2727 | +/// screen lists these verbs any more -- so every verb it used to carry has to | ||
| 2728 | +/// be a row on the menu of the thing it acts on, or it is a verb only a person | ||
| 2729 | +/// who already knows its chord can reach. Listed by action id rather than by | ||
| 2730 | +/// label, so a reworded row cannot make this pass while the door is gone. | ||
| 2731 | +/// | ||
| 2732 | +/// And the rule line's own half of DESIGN §9: the destructive rows come last | ||
| 2733 | +/// in every list here, which is what lets the render draw one seam before the | ||
| 2734 | +/// first of them instead of scattering seams through the plate. | ||
| 2735 | +#[test] | ||
| 2736 | +fn every_verb_the_spine_carried_is_a_right_click_row() { | ||
| 2737 | + use keymap::ActionId; | ||
| 2738 | + // The heads a project can have, so the removes are checked on the lane | ||
| 2739 | + // each of them belongs to. | ||
| 2740 | + let heads: Vec<ActionId> = [Lane::V1, Lane::A1, Lane::S1] | ||
| 2741 | + .into_iter() | ||
| 2742 | + .flat_map(lane_items) | ||
| 2743 | + .collect(); | ||
| 2744 | + for (action, menu) in [ | ||
| 2745 | + // EDIT | ||
| 2746 | + (ActionId::Cut, "clip"), | ||
| 2747 | + (ActionId::Lift, "clip"), | ||
| 2748 | + (ActionId::Undo, "bench"), | ||
| 2749 | + (ActionId::Redo, "bench"), | ||
| 2750 | + // CUT | ||
| 2751 | + (ActionId::WalkCutPrev, "bench"), | ||
| 2752 | + (ActionId::WalkCutNext, "bench"), | ||
| 2753 | + (ActionId::WalkCutPrev10, "bench"), | ||
| 2754 | + (ActionId::WalkCutNext10, "bench"), | ||
| 2755 | + (ActionId::TrimIn, "clip"), | ||
| 2756 | + (ActionId::TrimOut, "clip"), | ||
| 2757 | + (ActionId::TrimInToPlayhead, "clip"), | ||
| 2758 | + (ActionId::TrimOutToPlayhead, "clip"), | ||
| 2759 | + (ActionId::LoopTrim, "clip"), | ||
| 2760 | + // VIEW | ||
| 2761 | + (ActionId::ZoomOut, "bench"), | ||
| 2762 | + (ActionId::ZoomIn, "bench"), | ||
| 2763 | + (ActionId::ZoomFit, "bench"), | ||
| 2764 | + (ActionId::ToggleSnap, "bench"), | ||
| 2765 | + // TRACK | ||
| 2766 | + (ActionId::AddVideoLane, "lane head"), | ||
| 2767 | + (ActionId::AddAudioLane, "lane head"), | ||
| 2768 | + (ActionId::AddSubtitleLane, "lane head"), | ||
| 2769 | + (ActionId::RemoveVideoLane, "lane head"), | ||
| 2770 | + (ActionId::RemoveAudioLane, "lane head"), | ||
| 2771 | + (ActionId::RemoveSubtitleLane, "lane head"), | ||
| 2772 | + ] { | ||
| 2773 | + assert!( | ||
| 2774 | + MENU_ITEMS.contains(&action) | ||
| 2775 | + || BENCH_ITEMS.contains(&action) | ||
| 2776 | + || heads.contains(&action), | ||
| 2777 | + "{action:?} reaches no menu: the spine listed it and the {menu} menu does not" | ||
| 2778 | + ); | ||
| 2779 | + } | ||
| 2780 | + // Every menu is a list of actions the keyboard already reaches, so every | ||
| 2781 | + // row can wear its chord (DESIGN §4): a row built here out of an id the | ||
| 2782 | + // registry never files would print an empty column. | ||
| 2783 | + for action in MENU_ITEMS.into_iter().chain(BENCH_ITEMS).chain(heads.iter().copied()) { | ||
| 2784 | + assert!( | ||
| 2785 | + ActionId::ALL.contains(&action), | ||
| 2786 | + "{action:?} is a menu row and not a registered action" | ||
| 2787 | + ); | ||
| 2788 | + } | ||
| 2789 | + for list in [MENU_ITEMS.to_vec(), BENCH_ITEMS.to_vec(), lane_items(Lane::A1)] { | ||
| 2790 | + let first = list.iter().position(|&a| destructive(a)); | ||
| 2791 | + if let Some(first) = first { | ||
| 2792 | + assert!( | ||
| 2793 | + list[first..].iter().all(|&a| destructive(a)), | ||
| 2794 | + "a safe row sits below the rule line: {list:?}" | ||
| 2795 | + ); | ||
| 2796 | + } | ||
| 2797 | + } | ||
| 2798 | +} | ||
crates/app/src/tests/mod.rsmodified+3 -3
| @@ -16,17 +16,17 @@ use super::{ | |||
| 16 | EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, Enable, | 16 | EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, Enable, |
| 17 | BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN, EXPORT_MOMENT_H, EncoderSeat, FORMATS, Format, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, | 17 | BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN, EXPORT_MOMENT_H, EncoderSeat, FORMATS, Format, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, |
| 18 | KEYS_ROW_H, KEYS_W, KeyRow, LABEL_H, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W, | 18 | KEYS_ROW_H, KEYS_W, KeyRow, LABEL_H, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W, |
| 19 | - LIBRARY_MIN_W, Lane, MB_FLOOR, MENU_ITEMS, MENU_PAD, | 19 | + BENCH_ITEMS, LIBRARY_MIN_W, Lane, MB_FLOOR, MENU_ITEMS, MENU_PAD, |
| 20 | MENU_ROW_H, MENU_W, NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, RESYNC_GAP, | 20 | MENU_ROW_H, MENU_W, NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H, RESYNC_GAP, |
| 21 | ROW_ITEMS, RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS, | 21 | ROW_ITEMS, RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS, |
| 22 | SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS, | 22 | SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS, |
| 23 | Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, | 23 | Source, Speed, StreamInfo, TIMELINE_SHARE, Transport, VOLUME_W, Volume, WAVE_BPS, WAVE_COL, |
| 24 | WAVE_COLS_MAX, Wave, ZOOM_MIN_FRAMES, active_lane, auto_bps, band_label, bitrate_detail, | 24 | WAVE_COLS_MAX, Wave, ZOOM_MIN_FRAMES, active_lane, auto_bps, band_label, bitrate_detail, |
| 25 | - clipboard_after_remove, color_snap, containers, enable, enable_lane, envelope, eq_card_w, | 25 | + clipboard_after_remove, color_snap, containers, destructive, enable, enable_lane, envelope, eq_card_w, |
| 26 | eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path, | 26 | eq_freq, eq_freq_label, eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path, |
| 27 | export_settings, format_refusal, fps_choices, fps_label, frac_along, frac_down, | 27 | export_settings, format_refusal, fps_choices, fps_label, frac_along, frac_down, |
| 28 | frame_at, frame_rate_ladder, histogram, inserted_band, is_project, keymap, keys_rows, lanes_h, | 28 | frame_at, frame_rate_ladder, histogram, inserted_band, is_project, keymap, keys_rows, lanes_h, |
| 29 | - marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play, | 29 | + lane_items, marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play, |
| 30 | notice_tone, panel_h, parse_budget, project_path, range_word, proxies_to_start, push_notice, px_below, retarget, | 30 | notice_tone, panel_h, parse_budget, project_path, range_word, proxies_to_start, push_notice, px_below, retarget, |
| 31 | row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate, size_label, | 31 | row_enable, row_items, scrub_due, secs_label, should_resync, silence_rate, size_label, |
| 32 | rate_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal, | 32 | rate_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at, sub_pick_after_removal, |
crates/app/src/ui/bench_stance.rsmodified+45 -1
| @@ -908,6 +908,15 @@ fn lane_row( | |||
| 908 | cx.new(|_| Tip(head_ghost.clone())) | 908 | cx.new(|_| Tip(head_ghost.clone())) |
| 909 | }) | 909 | }) |
| 910 | .tooltip(crate::ui::widgets::tip_hover("Reorder lane", "drag", None)) | 910 | .tooltip(crate::ui::widgets::tip_hover("Reorder lane", "drag", None)) |
| 911 | + // The head's own verbs, never the bed's: a right-click here | ||
| 912 | + // names the *track* (DESIGN §9), so it opens the lane menu and | ||
| 913 | + // not the clip menu the bed beside it opens. | ||
| 914 | + .on_mouse_down( | ||
| 915 | + MouseButton::Right, | ||
| 916 | + cx.listener(move |this, event: &MouseDownEvent, _, cx| { | ||
| 917 | + this.open_head_menu(lane, event.position, cx); | ||
| 918 | + }), | ||
| 919 | + ) | ||
| 911 | .children(hitmap::dynamic( | 920 | .children(hitmap::dynamic( |
| 912 | move || { | 921 | move || { |
| 913 | ( | 922 | ( |
| @@ -1120,13 +1129,27 @@ fn lane_row( | |||
| 1120 | .on_mouse_down( | 1129 | .on_mouse_down( |
| 1121 | MouseButton::Right, | 1130 | MouseButton::Right, |
| 1122 | cx.listener(move |this, event: &MouseDownEvent, _, cx| { | 1131 | cx.listener(move |this, event: &MouseDownEvent, _, cx| { |
| 1132 | + // A clip's (or a caption's) own handler has already run | ||
| 1133 | + // by the time this bubbles up and has set its menu: the | ||
| 1134 | + // scrim swallows every press while a menu is open, so a | ||
| 1135 | + // menu standing here can only be the one this very | ||
| 1136 | + // press just opened, and the bed must not replace it. | ||
| 1137 | + if this.context_menu.is_some() { | ||
| 1138 | + return; | ||
| 1139 | + } | ||
| 1123 | let Some(session) = this.session.as_ref() else { | 1140 | let Some(session) = this.session.as_ref() else { |
| 1124 | return; | 1141 | return; |
| 1125 | }; | 1142 | }; |
| 1126 | let frame = this.frame_under(event.position.x); | 1143 | let frame = this.frame_under(event.position.x); |
| 1127 | - if let Some((start, frames)) = session.gap_at(lane, frame) { | 1144 | + match session.gap_at(lane, frame) { |
| 1145 | + Some((start, frames)) => { | ||
| 1128 | this.open_gap_menu(lane, start, frames, event.position, cx); | 1146 | this.open_gap_menu(lane, start, frames, event.position, cx); |
| 1129 | } | 1147 | } |
| 1148 | + // Empty bed past the end of the lane's contents: no | ||
| 1149 | + // hole to close there, so what the pointer is over | ||
| 1150 | + // is the bench itself (DESIGN §9). | ||
| 1151 | + None => this.open_bench_menu(event.position, cx), | ||
| 1152 | + } | ||
| 1130 | }), | 1153 | }), |
| 1131 | ) | 1154 | ) |
| 1132 | // The landing shadow (`Player::preview_ghost_asset`, the same | 1155 | // The landing shadow (`Player::preview_ghost_asset`, the same |
| @@ -1393,6 +1416,15 @@ pub(crate) fn render( | |||
| 1393 | this.scrub_to(event.position.x, true, cx); | 1416 | this.scrub_to(event.position.x, true, cx); |
| 1394 | }), | 1417 | }), |
| 1395 | ) | 1418 | ) |
| 1419 | + // The bench's own menu, on the strip that *is* the timeline: | ||
| 1420 | + // walking the cuts, the zoom, the snap and the undo pair, none | ||
| 1421 | + // of which is about a clip (DESIGN §9). | ||
| 1422 | + .on_mouse_down( | ||
| 1423 | + MouseButton::Right, | ||
| 1424 | + cx.listener(|this, event: &MouseDownEvent, _, cx| { | ||
| 1425 | + this.open_bench_menu(event.position, cx); | ||
| 1426 | + }), | ||
| 1427 | + ) | ||
| 1396 | .children(ticks.into_iter().map(|(x, label)| { | 1428 | .children(ticks.into_iter().map(|(x, label)| { |
| 1397 | div().absolute().top_0().left(px(x)).child( | 1429 | div().absolute().top_0().left(px(x)).child( |
| 1398 | div() | 1430 | div() |
| @@ -1480,6 +1512,18 @@ pub(crate) fn render( | |||
| 1480 | .child( | 1512 | .child( |
| 1481 | div() | 1513 | div() |
| 1482 | .id("bench-lanes") | 1514 | .id("bench-lanes") |
| 1515 | + // Empty room below the last lane is still the bench: the same | ||
| 1516 | + // menu the ruler opens, and the same guard the bed carries -- | ||
| 1517 | + // a menu standing here belongs to the press that opened it. | ||
| 1518 | + .on_mouse_down( | ||
| 1519 | + MouseButton::Right, | ||
| 1520 | + cx.listener(|this, event: &MouseDownEvent, _, cx| { | ||
| 1521 | + if this.context_menu.is_some() { | ||
| 1522 | + return; | ||
| 1523 | + } | ||
| 1524 | + this.open_bench_menu(event.position, cx); | ||
| 1525 | + }), | ||
| 1526 | + ) | ||
| 1483 | .flex_1() | 1527 | .flex_1() |
| 1484 | .min_h(px(0.)) | 1528 | .min_h(px(0.)) |
| 1485 | .overflow_y_scroll() | 1529 | .overflow_y_scroll() |
crates/app/src/ui/overlays.rsmodified+42 -9
| @@ -131,7 +131,7 @@ impl Player { | |||
| 131 | // would be a right-click that opens nothing. | 131 | // would be a right-click that opens nothing. |
| 132 | let idx = match menu.on { | 132 | let idx = match menu.on { |
| 133 | MenuOn::Clip(idx) => Some(idx), | 133 | MenuOn::Clip(idx) => Some(idx), |
| 134 | - MenuOn::Gap(..) => None, | 134 | + MenuOn::Gap(..) | MenuOn::Bench | MenuOn::Head => None, |
| 135 | }; | 135 | }; |
| 136 | let clip = idx.and_then(|idx| session.lane_clips(menu.lane).get(idx).copied()); | 136 | let clip = idx.and_then(|idx| session.lane_clips(menu.lane).get(idx).copied()); |
| 137 | let source = clip.and_then(|clip| session.sources().get(clip.source).cloned()); | 137 | let source = clip.and_then(|clip| session.sources().get(clip.source).cloned()); |
| @@ -173,6 +173,8 @@ impl Player { | |||
| 173 | }) | 173 | }) |
| 174 | }; | 174 | }; |
| 175 | let mut rows: Vec<AnyElement> = Vec::new(); | 175 | let mut rows: Vec<AnyElement> = Vec::new(); |
| 176 | + // Whether the rule line before the destructive rows has been drawn. | ||
| 177 | + let mut ruled = false; | ||
| 176 | if let (true, Some((clip, source))) = (menu.details, clip.zip(source.clone())) { | 178 | if let (true, Some((clip, source))) = (menu.details, clip.zip(source.clone())) { |
| 177 | // Read-only, so no ids and no hover: this side is a card, not a | 179 | // Read-only, so no ids and no hover: this side is a card, not a |
| 178 | // list of things to click. Each value is one truncated line, which | 180 | // list of things to click. Each value is one truncated line, which |
| @@ -259,9 +261,34 @@ impl Player { | |||
| 259 | // `menu_items`, so there is no second answer to keep in step. The | 261 | // `menu_items`, so there is no second answer to keep in step. The |
| 260 | // state refusals below stay, dimmed and saying why -- the next | 262 | // state refusals below stay, dimmed and saying why -- the next |
| 261 | // click of the playhead lights them. | 263 | // click of the playhead lights them. |
| 262 | - let idx = idx.expect("MenuOn::Gap handled above"); | 264 | + // The clip's own state where a clip was clicked; the editor's |
| 263 | - let ctx = self.ctx(Some((menu.lane, idx))); | 265 | + // otherwise -- the bench and the lane head both ask about the |
| 264 | - for action in menu_items(ctx) { | 266 | + // selection ([`Player::ctx`] falls back to it), which is exactly |
| 267 | + // what the cut machinery's rows act on. | ||
| 268 | + let ctx = self.ctx(idx.map(|idx| (menu.lane, idx))); | ||
| 269 | + // Three lists, one render: what the thing under the pointer can be | ||
| 270 | + // told (DESIGN §9). Nothing here is a second version of an action | ||
| 271 | + // -- every row is an [`ActionId`] the keyboard already reaches, so | ||
| 272 | + // the label and the chord still come out of the registry. | ||
| 273 | + let actions = match menu.on { | ||
| 274 | + MenuOn::Bench => BENCH_ITEMS.to_vec(), | ||
| 275 | + MenuOn::Head => lane_items(menu.lane), | ||
| 276 | + _ => menu_items(ctx), | ||
| 277 | + }; | ||
| 278 | + for action in actions { | ||
| 279 | + // DESIGN §9's rule line: the verbs that take something away sit | ||
| 280 | + // under a seam, wherever they are listed. Drawn once, before | ||
| 281 | + // the first of them, and never as the plate's own top edge. | ||
| 282 | + if destructive(action) && !rows.is_empty() && !ruled { | ||
| 283 | + ruled = true; | ||
| 284 | + rows.push( | ||
| 285 | + div() | ||
| 286 | + .my(px(3.)) | ||
| 287 | + .h(px(1.)) | ||
| 288 | + .bg(rgba(DARK_SEAM())) | ||
| 289 | + .into_any_element(), | ||
| 290 | + ); | ||
| 291 | + } | ||
| 265 | // The registry's own answer, the same one the actions card | 292 | // The registry's own answer, the same one the actions card |
| 266 | // dims a row with -- and a row that takes no click says *why* | 293 | // dims a row with -- and a row that takes no click says *why* |
| 267 | // rather than printing a stroke that would do nothing. | 294 | // rather than printing a stroke that would do nothing. |
| @@ -286,10 +313,16 @@ impl Player { | |||
| 286 | .or_else(|| full.split_once(" — ").map(|(head, _)| head)) | 313 | .or_else(|| full.split_once(" — ").map(|(head, _)| head)) |
| 287 | .or_else(|| full.split_once(": ").map(|(head, _)| head)) | 314 | .or_else(|| full.split_once(": ").map(|(head, _)| head)) |
| 288 | .unwrap_or(full); | 315 | .unwrap_or(full); |
| 289 | - let label = if matches!(action, ActionId::ToggleMute | ActionId::Paste) { | 316 | + let label = match action { |
| 290 | - format!("{verb} (global)") | 317 | + ActionId::ToggleMute | ActionId::Paste => format!("{verb} (global)"), |
| 291 | - } else { | 318 | + // A switch says which way it is set: a row reading "Snap on |
| 292 | - verb.to_string() | 319 | + // / off" beside a chord tells nobody whether snapping is on |
| 320 | + // right now, which is the one thing the spine's badge did | ||
| 321 | + // say before it went. | ||
| 322 | + ActionId::ToggleSnap => { | ||
| 323 | + format!("Snap — {}", if self.snap { "on" } else { "off" }) | ||
| 324 | + } | ||
| 325 | + _ => verb.to_string(), | ||
| 293 | }; | 326 | }; |
| 294 | let say: SharedString = full.to_string().into(); | 327 | let say: SharedString = full.to_string().into(); |
| 295 | rows.push( | 328 | rows.push( |
| @@ -336,7 +369,7 @@ impl Player { | |||
| 336 | // the list of them on this clip rather than | 369 | // the list of them on this clip rather than |
| 337 | // the next one stepped to behind the click. | 370 | // the next one stepped to behind the click. |
| 338 | // The stroke still steps -- same door. | 371 | // The stroke still steps -- same door. |
| 339 | - if action == ActionId::Fit { | 372 | + if let (ActionId::Fit, Some(idx)) = (action, idx) { |
| 340 | this.open_picker( | 373 | this.open_picker( |
| 341 | Pick::Fit(menu.lane, idx), | 374 | Pick::Fit(menu.lane, idx), |
| 342 | event.position(), | 375 | event.position(), |