forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

menubar.rs1215 lines, 51.0 KiBHistoryRawDownload
1//! The menu bar across the top of the room (DESIGN §6.1): the wordmark, the six
2//! titles and their dropdowns on the left, the project's save state on the
3//! right. Every row is an [`ActionId`] run through [`Player::act`]; the bar owns
4//! no verb of its own, and a refused row is the oracle's answer, not the bar's.
5
6use gpui::deferred;
7
8use crate::files::stem;
9use crate::layout::MENU_BAR_H;
10use crate::oracle::Enable;
11use crate::ui::popup::{popup_plate, popup_row, popup_row_icon, popup_rule, popup_w, shortcut};
12use crate::ui::type_scale::{self, Typeset};
13use crate::*;
14
15/// One line of a dropdown, in the order it draws.
16#[derive(Clone, Copy, Debug, PartialEq, Eq)]
17pub(crate) enum Entry {
18 /// Runs the action. A refused one shows its reason in place of the key.
19 Act(ActionId),
20 /// [`Entry::Act`] with a check mark while the switch is on.
21 Switch(ActionId),
22 /// The rule line between groups. Destructive verbs sit below one.
23 Rule,
24 /// A row that opens a flyout of more entries beside the plate (Premiere's menu groups).
25 Sub(&'static str, &'static [Entry]),
26 /// A setting with several values: a row that opens a flyout of them beside it, the one in
27 /// force ticked, and picking one sets it outright ([`Player::menu_pick`]).
28 Choice(ActionId),
29}
30
31impl Entry {
32 pub(crate) fn action(self) -> Option<ActionId> {
33 match self {
34 Entry::Act(action) | Entry::Switch(action) | Entry::Choice(action) => Some(action),
35 Entry::Rule | Entry::Sub(..) => None,
36 }
37 }
38}
39
40/// The six titles, left to right.
41#[derive(Clone, Copy, Debug, PartialEq, Eq)]
42pub(crate) enum Title {
43 File,
44 Edit,
45 Clip,
46 Timeline,
47 Playback,
48 View,
49 Help,
50}
51
52use Entry::{Act, Choice, Rule, Sub, Switch};
53
54/// The File menu's Open recent flyout: a [`Sub`] by name whose rows are the recent projects
55/// ([`recent_flyout`]), not a static list, so it is drawn even though it lists no action.
56pub(crate) const RECENT_SUB: &str = "Open recent";
57/// The File submenu that starts a new project from a template.
58pub(crate) const TEMPLATE_SUB: &str = "New from template";
59
60impl Title {
61 pub(crate) const ALL: [Title; 7] = [
62 Title::File,
63 Title::Edit,
64 Title::Clip,
65 Title::Timeline,
66 Title::Playback,
67 Title::View,
68 Title::Help,
69 ];
70
71 pub(crate) fn label(self) -> &'static str {
72 match self {
73 Title::File => "File",
74 Title::Edit => "Edit",
75 Title::Clip => "Clip",
76 Title::Timeline => "Timeline",
77 Title::Playback => "Playback",
78 Title::View => "View",
79 Title::Help => "Help",
80 }
81 }
82
83 /// The rows, as DESIGN §6.1 lists them. Rows without an [`ActionId`] are
84 /// left out rather than given a stub, and [`UNLISTED`] names what is not
85 /// on any menu.
86 /// Every entry of the menu with the flyouts' rows inlined after where they hang: what the
87 /// door and wiring tests read.
88 #[cfg(test)]
89 pub(crate) fn entries(self) -> Vec<Entry> {
90 fn flat(list: &[Entry], out: &mut Vec<Entry>) {
91 for e in list {
92 match e {
93 Sub(_, inner) => flat(inner, out),
94 e => out.push(*e),
95 }
96 }
97 }
98 let mut out = Vec::new();
99 flat(self.layout(), &mut out);
100 out
101 }
102
103 /// The menu as it draws: top-level rows, rules and flyout rows.
104 pub(crate) fn layout(self) -> &'static [Entry] {
105 match self {
106 // New project and Open project (DESIGN §6.1) have no Player function
107 // yet, so they have no row.
108 Title::File => &[
109 Act(ActionId::AddFiles),
110 Act(ActionId::PasteFilePath),
111 Act(ActionId::ImportSubtitles),
112 Rule,
113 Act(ActionId::OpenProject),
114 Sub(RECENT_SUB, &[]),
115 Sub(TEMPLATE_SUB, &[]),
116 Sub(
117 "New",
118 &[
119 Act(ActionId::NewProject),
120 Rule,
121 Act(ActionId::NewBin),
122 Act(ActionId::NewSolid),
123 Act(ActionId::NewGradient),
124 Act(ActionId::NewCountdown),
125 Act(ActionId::NewBars),
126 Act(ActionId::NewTone),
127 Act(ActionId::NewBarsAndTone),
128 Act(ActionId::NewAdjustment),
129 Act(ActionId::NewRectangle),
130 Act(ActionId::NewEllipse),
131 Act(ActionId::NewLine),
132 Act(ActionId::NewArrow),
133 ],
134 ),
135 Rule,
136 Act(ActionId::Save),
137 Act(ActionId::SaveVersion),
138 Act(ActionId::SaveTemplate),
139 Act(ActionId::Versions),
140 Act(ActionId::ProjectNotes),
141 // Reads the file back over the window's edits, so it answers
142 // to the same question a changed file does ([`Player::reload_request`]).
143 Act(ActionId::ReloadProject),
144 Act(ActionId::Export),
145 // Shown only while an export runs (the oracle hides it otherwise).
146 Act(ActionId::CancelExport),
147 Act(ActionId::ExportCaptions),
148 Act(ActionId::Screenshot),
149 Act(ActionId::CollectMedia),
150 Sub(
151 "Export timeline as",
152 &[
153 Act(ActionId::ExportTimelineOtio),
154 Act(ActionId::ExportTimelineFcpxml),
155 Act(ActionId::ExportTimelineEdl),
156 ],
157 ),
158 Act(ActionId::ImportTimelineOtio),
159 Rule,
160 Act(ActionId::Settings),
161 ],
162 Title::Edit => &[
163 Act(ActionId::Undo),
164 Act(ActionId::Redo),
165 Act(ActionId::History),
166 Rule,
167 Act(ActionId::Copy),
168 Act(ActionId::Paste),
169 Sub(
170 "Paste attributes",
171 &[
172 Act(ActionId::PasteAttributes),
173 Rule,
174 Act(ActionId::PasteColor),
175 Act(ActionId::PasteEffects),
176 Act(ActionId::PasteTransform),
177 Act(ActionId::PasteSpeed),
178 Act(ActionId::PasteAudio),
179 ],
180 ),
181 Rule,
182 Act(ActionId::InsertSource),
183 Act(ActionId::OverwriteSource),
184 Act(ActionId::ReplaceEdit),
185 Act(ActionId::MatchFrame),
186 Rule,
187 Sub(
188 "Select",
189 &[
190 Act(ActionId::SelectAll),
191 Act(ActionId::Deselect),
192 Act(ActionId::Select),
193 Act(ActionId::SelectNext),
194 Act(ActionId::SelectPrev),
195 Act(ActionId::SelectForward),
196 Act(ActionId::SelectForwardAll),
197 ],
198 ),
199 ],
200 Title::Clip => &[
201 Act(ActionId::Cut),
202 Act(ActionId::CutSelectedWords),
203 Rule,
204 Sub(
205 "Trim",
206 &[
207 Act(ActionId::TrimIn),
208 Act(ActionId::TrimOut),
209 Act(ActionId::RippleTrimInToPlayhead),
210 Act(ActionId::TrimInToPlayhead),
211 Act(ActionId::RippleTrimOutToPlayhead),
212 Act(ActionId::TrimOutToPlayhead),
213 Rule,
214 Act(ActionId::RollBack),
215 Act(ActionId::RollForward),
216 Act(ActionId::SlipBack),
217 Act(ActionId::SlipForward),
218 Act(ActionId::SlideBack),
219 Act(ActionId::SlideForward),
220 Rule,
221 Act(ActionId::LoopTrim),
222 Rule,
223 Act(ActionId::ExtendAudio),
224 Act(ActionId::ExtendVideo),
225 ],
226 ),
227 Sub(
228 "Transitions",
229 &[
230 Act(ActionId::Crossfade),
231 Act(ActionId::Dissolve),
232 Rule,
233 Act(ActionId::TransitionDipBlack),
234 Act(ActionId::TransitionDipWhite),
235 Act(ActionId::TransitionZoom),
236 Rule,
237 Act(ActionId::TransitionWipeLeft),
238 Act(ActionId::TransitionWipeRight),
239 Act(ActionId::TransitionWipeUp),
240 Act(ActionId::TransitionWipeDown),
241 Rule,
242 Act(ActionId::TransitionSlideLeft),
243 Act(ActionId::TransitionSlideRight),
244 Act(ActionId::TransitionSlideUp),
245 Act(ActionId::TransitionSlideDown),
246 Rule,
247 Act(ActionId::TransitionPushLeft),
248 Act(ActionId::TransitionPushRight),
249 Act(ActionId::TransitionPushUp),
250 Act(ActionId::TransitionPushDown),
251 ],
252 ),
253 Sub(
254 "Nudge",
255 &[
256 Act(ActionId::NudgeBack),
257 Act(ActionId::NudgeForward),
258 Act(ActionId::NudgeBack10),
259 Act(ActionId::NudgeForward10),
260 ],
261 ),
262 Sub(
263 "Speed",
264 &[
265 Act(ActionId::Speed),
266 Act(ActionId::Reverse),
267 Act(ActionId::Freeze),
268 Rule,
269 Act(ActionId::SpeedRampUp),
270 Act(ActionId::SpeedRampDown),
271 Act(ActionId::SpeedRampSlowFastSlow),
272 Act(ActionId::SpeedRampFastSlowFast),
273 Act(ActionId::SpeedRampKey),
274 Act(ActionId::SpeedRampClear),
275 ],
276 ),
277 Sub(
278 "Adjust",
279 &[
280 Act(ActionId::Color),
281 Act(ActionId::AutoColour),
282 Act(ActionId::SaveLook),
283 Act(ActionId::Transform),
284 Act(ActionId::Effects),
285 Act(ActionId::Reframe),
286 Act(ActionId::TrackMask),
287 Choice(ActionId::Fit),
288 Act(ActionId::SubtitleStyle),
289 Rule,
290 Act(ActionId::Equalizer),
291 Act(ActionId::Silence),
292 Act(ActionId::MarkBeats),
293 Act(ActionId::Mix),
294 Act(ActionId::CleanVoice),
295 Act(ActionId::VoiceDynamics),
296 Act(ActionId::Visualizer),
297 ],
298 ),
299 Sub(
300 "Keyframes",
301 &[
302 Act(ActionId::KeyPlacement),
303 Act(ActionId::KeyOpacity),
304 Act(ActionId::KeyColor),
305 Choice(ActionId::KeyEasing),
306 ],
307 ),
308 Choice(ActionId::ClipLabel),
309 Switch(ActionId::ClipEnabled),
310 Rule,
311 Sub(
312 "Compound",
313 &[Act(ActionId::NestClips), Act(ActionId::BreakApart), Act(ActionId::OpenCompound)],
314 ),
315 Sub("Multicam", &[Act(ActionId::CreateMulticam), Act(ActionId::FlattenMulticam), Act(ActionId::Angle1)]),
316 Rule,
317 Act(ActionId::Group),
318 Act(ActionId::Regroup),
319 Act(ActionId::Detach),
320 Rule,
321 Act(ActionId::Delete),
322 Act(ActionId::Lift),
323 ],
324 Title::Timeline => &[
325 Sub(
326 "Sequence",
327 &[
328 Act(ActionId::NewSequence),
329 Act(ActionId::DuplicateSequence),
330 Act(ActionId::RenameSequence),
331 Act(ActionId::CloseCompound),
332 Rule,
333 Act(ActionId::DeleteSequence),
334 ],
335 ),
336 Act(ActionId::CloseGap),
337 Act(ActionId::NewTitle),
338 Act(ActionId::RecordVoiceover),
339 Rule,
340 Act(ActionId::SetIn),
341 Act(ActionId::SetOut),
342 Act(ActionId::ClearRange),
343 Rule,
344 Sub(
345 "Render preview",
346 &[
347 Act(ActionId::RenderInOut),
348 Act(ActionId::RenderAll),
349 Act(ActionId::CancelRender),
350 Act(ActionId::DeleteRenderFiles),
351 ],
352 ),
353 Rule,
354 Act(ActionId::ZoomIn),
355 Act(ActionId::ZoomOut),
356 Act(ActionId::ZoomFit),
357 Rule,
358 Act(ActionId::TrackSmall),
359 Act(ActionId::TrackMedium),
360 Act(ActionId::TrackLarge),
361 Act(ActionId::TracksSmaller),
362 Act(ActionId::TracksLarger),
363 Rule,
364 Switch(ActionId::ToggleSnap),
365 Rule,
366 Sub(
367 "Go to",
368 &[
369 Act(ActionId::WalkCutPrev),
370 Act(ActionId::WalkCutNext),
371 Act(ActionId::WalkCutPrev10),
372 Act(ActionId::WalkCutNext10),
373 Rule,
374 Act(ActionId::PrevSyncPoint),
375 Act(ActionId::NextSyncPoint),
376 ],
377 ),
378 Sub(
379 "Markers",
380 &[
381 Act(ActionId::AddMarker),
382 Act(ActionId::PrevMarker),
383 Act(ActionId::NextMarker),
384 Act(ActionId::Markers),
385 ],
386 ),
387 Sub("Captions", &[Act(ActionId::Captions), Act(ActionId::Fillers)]),
388 Sub("Audio", &[Act(ActionId::Normalize), Act(ActionId::Voiceover)]),
389 Sub(
390 "Tracks",
391 &[
392 Act(ActionId::AddVideoLane),
393 Act(ActionId::AddAudioLane),
394 Act(ActionId::AddSubtitleLane),
395 Rule,
396 Act(ActionId::RemoveVideoLane),
397 Act(ActionId::RemoveAudioLane),
398 Act(ActionId::RemoveSubtitleLane),
399 ],
400 ),
401 ],
402 Title::Playback => &[
403 Act(ActionId::Play),
404 Act(ActionId::ShuttleBack),
405 Act(ActionId::ShuttleStop),
406 Act(ActionId::ShuttleForward),
407 Rule,
408 Act(ActionId::StepBack),
409 Act(ActionId::StepForward),
410 Act(ActionId::JumpBack),
411 Act(ActionId::JumpForward),
412 Rule,
413 Switch(ActionId::Loop),
414 Act(ActionId::PlayAround),
415 Sub(
416 "Go to",
417 &[
418 Act(ActionId::GoStart),
419 Act(ActionId::GoEnd),
420 Rule,
421 Act(ActionId::GoToTime),
422 ],
423 ),
424 ],
425 Title::View => &[
426 Switch(ActionId::ToggleSubtitles),
427 Switch(ActionId::ToggleAngleMonitor),
428 Switch(ActionId::ToggleWaveforms),
429 Switch(ActionId::ToggleScrubAudio),
430 Sub("Compare grade", &[Switch(ActionId::CompareOff), Switch(ActionId::CompareSplit), Switch(ActionId::CompareSide)]),
431 Choice(ActionId::ViewZoom),
432 Act(ActionId::ZoomToSelection),
433 Choice(ActionId::PlaybackQuality),
434 Choice(ActionId::GuideStyle),
435 Choice(ActionId::GuideMask),
436 Act(ActionId::Fullscreen),
437 Switch(ActionId::ToggleOutputWindow),
438 Choice(ActionId::OutputDisplay),
439 Act(ActionId::FocusPanels),
440 ],
441 Title::Help => &[
442 Act(ActionId::ShowActions),
443 Act(ActionId::ShowKeys),
444 Rule,
445 Act(ActionId::About),
446 ],
447 }
448 }
449}
450
451/// Every [`ActionId`] that is on no menu, each with the one-line reason it is
452/// not. Empty: every action has a row. A verb that only makes sense for one
453/// kind of thing is still on its menu and drops out of the dropdown while the
454/// oracle hides it ([`Enable::Hidden`]). A new action that is in neither place
455/// fails [`every_action_has_a_door`] rather than going missing.
456#[cfg(test)]
457pub(crate) const UNLISTED: &[(ActionId, &str)] = &[
458 (ActionId::MarkerHere, "the ruler's menu: a marker at the frame the pointer named"),
459 (ActionId::RenameMarker, "the ruler's marker menu and a double-click on a ruler marker: the marker that was clicked"),
460 (ActionId::DeleteMarker, "the ruler's marker menu: the marker that was clicked"),
461 (ActionId::TransitionDissolve, "the same dissolve as Dissolve, at a cut: the Clip tab's own door"),
462 (ActionId::PlayheadHere, "the ruler's and the empty-track menu: the playhead to the frame the pointer named"),
463 (ActionId::Theme, "the command palette; a look-and-feel choice, not a view verb"),
464 (ActionId::AccentColour, "the command palette; a look-and-feel choice, not a view verb"),
465 (ActionId::VolumeUp, "the Up-arrow volume key, the viewer's volume control and the command palette"),
466 (ActionId::VolumeDown, "the Down-arrow volume key, the viewer's volume control and the command palette"),
467 (ActionId::ToggleMute, "the viewer's mute button, the M key and the command palette; it mutes the monitor, not the clip"),
468 (ActionId::Resolution, "Settings' Project tab and the command palette"),
469 (ActionId::ToggleProxies, "Settings' Project tab and the command palette"),
470 (ActionId::ToggleAutoProxies, "Settings' Project tab and the command palette"),
471 (ActionId::NewBinInside, "the bin row's right-click menu; it needs the bin that was clicked"),
472 (ActionId::RenameBin, "the bin row's right-click menu or a double-click on its name; it needs the bin that was clicked"),
473 (ActionId::RemoveBin, "the bin row's right-click menu; it needs the bin that was clicked"),
474 (ActionId::ToggleFavourite, "the star on each media row and the row's right-click menu; it needs the media that was clicked"),
475 (ActionId::MoveToBin, "the media row's right-click menu, or a drag onto a bin; it needs the media that was clicked"),
476 (ActionId::ShowFavourites, "the All / Favourites segmented control in the Media tab"),
477 (ActionId::ShowAllMedia, "the All / Favourites segmented control in the Media tab"),
478 (ActionId::Angle2, "the number keys: Clip > Multicam lists them as Switch to angle 1–9; the monitor's tiles are the pointer\'s way"),
479 (ActionId::Angle3, "the number keys: Clip > Multicam lists them as Switch to angle 1–9; the monitor's tiles are the pointer\'s way"),
480 (ActionId::Angle4, "the number keys: Clip > Multicam lists them as Switch to angle 1–9; the monitor's tiles are the pointer\'s way"),
481 (ActionId::Angle5, "the number keys: Clip > Multicam lists them as Switch to angle 1–9; the monitor's tiles are the pointer\'s way"),
482 (ActionId::Angle6, "the number keys: Clip > Multicam lists them as Switch to angle 1–9; the monitor's tiles are the pointer\'s way"),
483 (ActionId::Angle7, "the number keys: Clip > Multicam lists them as Switch to angle 1–9; the monitor's tiles are the pointer\'s way"),
484 (ActionId::Angle8, "the number keys: Clip > Multicam lists them as Switch to angle 1–9; the monitor's tiles are the pointer\'s way"),
485 (ActionId::Angle9, "the number keys: Clip > Multicam lists them as Switch to angle 1–9; the monitor's tiles are the pointer\'s way"),
486 (ActionId::RenameLane, "set from the track head: its right-click menu, or a double-click on the name; it needs the track that was clicked"),
487];
488
489/// Whether a switch is on, read off the state it names.
490fn checked(player: &Player, action: ActionId) -> bool {
491 match action {
492 ActionId::ToggleSnap => player.snap,
493 ActionId::Loop => player.loop_on,
494 ActionId::ToggleAngleMonitor => player.angle_monitor,
495 ActionId::ToggleOutputWindow => player.output.is_some(),
496 ActionId::ToggleSubtitles => player.subs_on,
497 ActionId::ToggleWaveforms => player.waveforms,
498 ActionId::ToggleScrubAudio => player.scrub_audio,
499 ActionId::CompareOff => player.compare == crate::viewer_view::Compare::Off,
500 ActionId::CompareSplit => player.compare == crate::viewer_view::Compare::Split,
501 ActionId::CompareSide => player.compare == crate::viewer_view::Compare::Side,
502 ActionId::ToggleProxies => player.proxies_on,
503 ActionId::ToggleAutoProxies => player.auto_proxies_on,
504 ActionId::ToggleMute => player.volume.muted,
505 ActionId::ClipEnabled => player
506 .label_target()
507 .and_then(|(lane, idx)| player.session.as_ref().map(|s| !s.mark_of(lane, idx).off))
508 .unwrap_or(true),
509 _ => false,
510 }
511}
512
513/// The bar itself (REDESIGN §3.1): the room's first row, [`MENU_BAR_H`] tall on
514/// `e0`, above the dock and the centre alike. Left, the `E` wordmark and the six
515/// menus; centre, the command-search field that opens the palette; right, the
516/// project's name with its unsaved dot, and Export, the one primary button.
517pub(crate) fn bar(player: &Player, view_w: f32, view_h: f32, cx: &mut Context<Player>) -> impl IntoElement {
518 use crate::ui::icons::{Icon, IconSize};
519 let t = crate::ui::theme::tokens();
520 let name = match (player.project_path.as_os_str().is_empty(), &player.new_project) {
521 (_, Some(path)) => stem(path),
522 // No project yet: the header says nothing rather than a name nobody has given.
523 (true, None) => String::new(),
524 // Saved or opened as a project: its own name. Not saved yet: "Untitled", never the
525 // guessed file beside the media or the autosave the window keeps for it.
526 (false, None) if player.autosave_armed => stem(&player.project_path),
527 (false, None) => "Untitled".to_string(),
528 };
529 // An unsaved project shows a dot, a saved one nothing ("Saved" is not
530 // displayed); the dot's slot is always there so the name never moves.
531 let dot = div()
532 .id("menubar-save")
533 .flex_none()
534 .flex()
535 .items_center()
536 .justify_center()
537 .size(px(16.))
538 .when(player.edited_since_save, |d| {
539 d.cursor_pointer()
540 .tooltip(crate::ui::widgets::action_hover(player, ActionId::Save))
541 .on_click(cx.listener(|this, _: &ClickEvent, window, cx| {
542 this.act(ActionId::Save, window, cx);
543 cx.notify();
544 }))
545 .child(div().size(px(6.)).rounded(px(3.)).bg(rgb(t.warn)))
546 });
547 let key = player.keymap.primary(ActionId::ShowActions);
548 let wide = view_w >= 1100.;
549 let search = div()
550 .id("menubar-search")
551 .flex_none()
552 .flex()
553 .items_center()
554 .gap(px(8.))
555 .h(px(24.))
556 .rounded(px(4.))
557 .bg(rgb(t.e2))
558 .cursor_pointer()
559 .hover(|s| s.bg(rgb(t.e3)))
560 .tooltip(crate::ui::widgets::action_hover(player, ActionId::ShowActions))
561 .on_click(cx.listener(|this, _: &ClickEvent, window, cx| {
562 this.act(ActionId::ShowActions, window, cx);
563 }))
564 .children(crate::ui::hitmap::action(ActionId::ShowActions, true))
565 .child(Icon::Search.el(IconSize::Inline, t.ink3))
566 .when(wide, |d| {
567 d.w(px(280.))
568 .px(px(8.))
569 .child(
570 div()
571 .flex_1()
572 .min_w(px(0.))
573 .type_style(type_scale::caption())
574 .text_color(rgb(t.ink3))
575 .child("Search commands"),
576 )
577 .child(crate::ui::kit::keycap(key))
578 })
579 .when(!wide, |d| d.w(px(24.)).justify_center());
580 let exporting = player.exporting().map(|h| match h.stage() {
581 Some((_, f)) => (f.clamp(0., 1.) * 100.) as u32,
582 None => (h.progress().clamp(0., 1.) * 100.) as u32,
583 });
584 let export = crate::ui::kit::Button::new("stance-export")
585 .style(crate::ui::kit::ButtonStyle::Primary)
586 .label(match exporting {
587 Some(pct) => format!("Export {pct}%"),
588 None => "Export".to_string(),
589 })
590 .min_w(100.)
591 // Dimmed with the reason in its tooltip while the timeline has nothing to write out; an
592 // export already running stays live, since its progress is what this button shows.
593 .enabled(exporting.is_some() || player.enable(ActionId::Export, None).yes())
594 .build()
595 .h(px(24.))
596 .tooltip(crate::ui::widgets::action_hover(player, ActionId::Export))
597 .children(crate::ui::hitmap::action(ActionId::Export, true))
598 // Always the sheet: while an export runs it is that export's progress
599 // (with its own two-press cancel), so one stray click can never end an
600 // hour of encoding.
601 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
602 this.open_export(cx);
603 cx.notify();
604 }));
605 div()
606 .id("menubar")
607 .absolute()
608 .top(px(0.))
609 .left(px(0.))
610 .w_full()
611 .h(px(MENU_BAR_H))
612 .flex()
613 .items_center()
614 .px(px(8.))
615 .bg(rgb(t.e0))
616 .child(
617 div()
618 .flex_none()
619 .pl(px(4.))
620 .pr(px(12.))
621 .type_style(type_scale::title())
622 .text_color(rgb(t.ink1))
623 .child("E"),
624 )
625 .children(Title::ALL.map(|title| title_button(player, title, view_h, cx).into_any_element()))
626 .child(
627 div()
628 .flex_1()
629 .min_w(px(0.))
630 .flex()
631 .justify_center()
632 .px(px(8.))
633 .child(search),
634 )
635 .child(
636 div()
637 .flex_none()
638 .flex()
639 .items_center()
640 .gap(px(8.))
641 .child(
642 div()
643 .id("menubar-project-name")
644 .max_w(px(160.))
645 .truncate()
646 .type_style(type_scale::body_strong())
647 .text_color(rgb(t.ink1))
648 .child(crate::ui::dock_stance::fit_name(&name, 156., type_scale::BODY_PX))
649 .tooltip(crate::ui::widgets::tip_hover(&name, "", None)),
650 )
651 .child(dot)
652 .child(export),
653 )
654}
655
656/// What a click on `title` leaves open. The pointer reaches a title by
657/// hovering it, which already switches the open menu to it; the click that
658/// follows must keep that menu (a switch), not toggle it shut.
659pub(crate) fn click_menu(open: Option<Title>, hopped: &mut Option<Title>, title: Title) -> Option<Title> {
660 let switched = hopped.take() == Some(title) && open == Some(title);
661 match open == Some(title) && !switched {
662 true => None,
663 false => Some(title),
664 }
665}
666
667/// One title. Clicking it opens its dropdown or closes it; while one is open,
668/// hovering another title switches to that one.
669fn title_button(player: &Player, title: Title, view_h: f32, cx: &mut Context<Player>) -> impl IntoElement {
670 let open = player.menu_open == Some(title);
671 // Mounted inside the title, so its anchor is the title's own corner; the
672 // plate is deferred so it paints over the room below the bar.
673 let plate = open.then(|| deferred(dropdown(player, title, view_h, cx)));
674 crate::ui::widgets::focus_ring(div().id(("menubar-title", title as usize)))
675 .relative()
676 .flex()
677 .items_center()
678 .h(px(MENU_BAR_H))
679 .px(px(10.))
680 .rounded(px(4.))
681 .cursor_pointer()
682 .type_style(type_scale::body_strong())
683 .text_color(rgb(if open { INK1() } else { INK2() }))
684 .when(open, |d| d.bg(rgb(crate::ui::theme::tokens().e3)))
685 .hover(|s| s.bg(rgb(BG_HOVER())).text_color(rgb(INK1())))
686 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
687 this.menu_open = click_menu(this.menu_open, &mut this.menu_hopped, title);
688 this.menu_sub = None;
689 cx.notify();
690 }))
691 .on_hover(cx.listener(move |this, hovered: &bool, _, cx| {
692 if *hovered && this.menu_open.is_some() && this.menu_open != Some(title) {
693 this.menu_open = Some(title);
694 this.menu_sub = None;
695 this.menu_hopped = Some(title);
696 cx.notify();
697 }
698 }))
699 .child(title.label())
700 .children(plate)
701}
702
703/// The entries of `list` that draw: a row the oracle hides for this context (a class refusal,
704/// DESIGN §4.8) is left out, a flyout with nothing left in it goes too, and a rule line stays
705/// only between two rows that do, so a group the context empties leaves no stray line.
706fn drawn_entries(player: &Player, list: &[Entry]) -> Vec<Entry> {
707 let mut drawn: Vec<Entry> = Vec::new();
708 for entry in list {
709 match entry {
710 Sub(name, inner) => {
711 if *name == RECENT_SUB || *name == TEMPLATE_SUB || drawn_entries(player, inner).iter().any(|e| e.action().is_some()) {
712 drawn.push(*entry);
713 }
714 }
715 e => match e.action() {
716 Some(action) if matches!(player.enable(action, None), Enable::Hidden(_)) => {}
717 Some(_) => drawn.push(*e),
718 None if drawn.last().is_some_and(|e| e.action().is_some() || matches!(e, Sub(..))) => {
719 drawn.push(*e)
720 }
721 None => {}
722 },
723 }
724 }
725 while drawn.last() == Some(&Rule) {
726 drawn.pop();
727 }
728 drawn
729}
730
731/// The height of a plate holding `list`: its padding plus a row each and a rule's 7 px.
732pub(crate) fn entries_h(list: &[Entry]) -> f32 {
733 crate::layout::MENU_PAD * 2.
734 + 2.
735 + list.iter().map(|e| if *e == Rule { 7. } else { crate::layout::MENU_ROW_H }).sum::<f32>()
736}
737
738/// The rows for `drawn`, with the text the plate's width is fitted to. `level` keeps the ids of a
739/// flyout's rows apart from the plate's; only the plate's own plain rows close an open flyout
740/// when the pointer comes onto them.
741fn menu_rows(
742 player: &Player,
743 title: Title,
744 drawn: &[Entry],
745 level: usize,
746 cx: &mut Context<Player>,
747) -> (Vec<AnyElement>, f32) {
748 let mut rows: Vec<AnyElement> = Vec::new();
749 let mut measure: Vec<(String, String)> = Vec::new();
750 // The check column exists only on a menu that has a switch in it.
751 // REDESIGN §3.1: every bar menu keeps the 16px icon column, blank or not.
752 let checks = true;
753 for (idx, entry) in drawn.iter().enumerate() {
754 let id = ("menubar-row", level * 10_000 + title as usize * 100 + idx);
755 if let Choice(action) = *entry {
756 let name = action.label();
757 let shown = name.trim_end_matches('…');
758 let refusal = player.enable(action, None);
759 let usable = refusal.yes() && player.menu_pick(action).is_some();
760 let open = match level {
761 0 => player.menu_sub == Some((title, name)),
762 _ => player.menu_sub2 == Some((title, name)),
763 };
764 measure.push((shown.to_string(), "▸".to_string()));
765 let row = popup_row_icon(id, shown, "▸", Some(false), crate::menus::icon(action), refusal.why());
766 rows.push(match usable {
767 true => row
768 .cursor_pointer()
769 .hover(|s| s.bg(rgb(BG_HOVER())))
770 .when(open, |d| d.bg(rgb(BG_HOVER())))
771 .on_hover(cx.listener(move |this, on: &bool, _, cx| {
772 if *on {
773 match level {
774 0 => this.menu_sub = Some((title, name)),
775 _ => this.menu_sub2 = Some((title, name)),
776 }
777 cx.notify();
778 }
779 }))
780 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
781 cx.stop_propagation();
782 match level {
783 0 => this.menu_sub = Some((title, name)),
784 _ => this.menu_sub2 = Some((title, name)),
785 }
786 cx.notify();
787 }))
788 .into_any_element(),
789 false => row.into_any_element(),
790 });
791 continue;
792 }
793 if let Sub(name, _) = *entry {
794 measure.push((name.to_string(), "▸".to_string()));
795 rows.push(
796 popup_row_icon(id, name, "▸", Some(false), crate::menus::icon_sub(name), None)
797 .cursor_pointer()
798 .hover(|s| s.bg(rgb(BG_HOVER())))
799 .when(player.menu_sub == Some((title, name)), |d| d.bg(rgb(BG_HOVER())))
800 .on_hover(cx.listener(move |this, on: &bool, _, cx| {
801 if *on && this.menu_sub != Some((title, name)) {
802 this.menu_sub = Some((title, name));
803 this.menu_sub2 = None;
804 cx.notify();
805 }
806 }))
807 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
808 cx.stop_propagation();
809 this.menu_sub = Some((title, name));
810 cx.notify();
811 }))
812 .into_any_element(),
813 );
814 continue;
815 }
816 let Some(action) = entry.action() else {
817 rows.push(popup_rule());
818 continue;
819 };
820 let refusal = player.enable(action, None);
821 let label = player.action_name(action);
822 // A switch that cannot be flipped shows no tick (nothing to be on), and says why on the row.
823 let on = matches!(entry, Switch(_)) && refusal.yes() && checked(player, action);
824 let hint = match refusal.why() {
825 Some(why) if matches!(entry, Switch(_)) && why.len() <= 24 => {
826 let mut c = why.chars();
827 c.next().map(|f| f.to_uppercase().chain(c).collect()).unwrap_or_default()
828 }
829 _ => shortcut(&player.keymap, action),
830 };
831 measure.push((label.clone(), hint.clone()));
832 // A switch wears its icon while off and a tick while on, so its state stays visible.
833 let icon = crate::menus::icon(action);
834 let row = popup_row_icon(id, &label, hint, Some(on), icon, refusal.why());
835 // A row whose name says little carries its one-line description on hover.
836 let row = match (refusal.yes(), crate::menus::note(action)) {
837 (true, Some(note)) => row.tooltip(crate::ui::widgets::overlay_tip_hover(&label, "", Some(note))),
838 _ => row,
839 };
840 let row = row
841 .when(level == 0, |d| {
842 d.on_hover(cx.listener(|this, on: &bool, _, cx| {
843 if *on && this.menu_sub.is_some() {
844 this.menu_sub = None;
845 this.menu_sub2 = None;
846 cx.notify();
847 }
848 }))
849 })
850 .when(level == 1, |d| {
851 d.on_hover(cx.listener(|this, on: &bool, _, cx| {
852 if *on && this.menu_sub2.is_some() {
853 this.menu_sub2 = None;
854 cx.notify();
855 }
856 }))
857 });
858 rows.push(match refusal.yes() {
859 true => row
860 .cursor_pointer()
861 .hover(|s| s.bg(rgb(BG_HOVER())))
862 .on_click(cx.listener(move |this, _: &ClickEvent, window, cx| {
863 // The row sits inside its title, so the title's own
864 // click (which toggles the menu) must not hear it too.
865 cx.stop_propagation();
866 this.menu_open = None;
867 this.menu_sub = None;
868 this.menu_sub2 = None;
869 this.act(action, window, cx);
870 cx.notify();
871 }))
872 .into_any_element(),
873 false => row.into_any_element(),
874 });
875 }
876 let w = popup_w(measure.iter().map(|(l, h)| (l.as_str(), h.as_str())), checks);
877 (rows, w)
878}
879
880/// The dropdown under a title: a menu plate, one row per entry, and the flyout of the group the
881/// pointer is on beside it.
882fn dropdown(player: &Player, title: Title, view_h: f32, cx: &mut Context<Player>) -> impl IntoElement {
883 let drawn = drawn_entries(player, title.layout());
884 let (rows, w) = menu_rows(player, title, &drawn, 0, cx);
885 // A menu longer than the window scrolls inside the plate rather than hanging off the bottom
886 // edge (the menus are grouped into flyouts so none is: `every_menu_fits_a_720_window`).
887 let room = (view_h - MENU_BAR_H - crate::layout::MENU_EDGE - crate::layout::MENU_PAD * 2.).max(crate::layout::MENU_ROW_H);
888 // The open flyout: its rows, hung at the right of the plate level with its row.
889 let flyout = drawn.iter().enumerate().find_map(|(idx, e)| match *e {
890 Sub(name, inner) if player.menu_sub == Some((title, name)) => Some((idx, name, inner)),
891 _ => None,
892 });
893 let flyout = flyout.map(|(idx, name, inner)| {
894 if name == RECENT_SUB {
895 return recent_flyout(entries_h(&drawn[..idx]) - crate::layout::MENU_PAD - 2., w - 2., cx);
896 }
897 if name == TEMPLATE_SUB {
898 let top = entries_h(&drawn[..idx]) - crate::layout::MENU_PAD - 2.;
899 return popup_plate("menubar-flyout", w - 2., top, 300.).children(template_rows(cx, true));
900 }
901 let inner = drawn_entries(player, inner);
902 let (frows, fw) = menu_rows(player, title, &inner, 1, cx);
903 let top = entries_h(&drawn[..idx]) - crate::layout::MENU_PAD - 2.;
904 // A list-row inside the group opens its own flyout beside this one.
905 let second = inner.iter().enumerate().find_map(|(i, e)| match *e {
906 Choice(action) if player.menu_sub2 == Some((title, action.label())) => Some((i, action)),
907 _ => None,
908 });
909 let second = second.and_then(|(i, action)| {
910 let top2 = entries_h(&inner[..i]) - crate::layout::MENU_PAD - 2.;
911 choice_plate(player, "menubar-flyout2", action, fw - 2., top2, cx)
912 });
913 popup_plate("menubar-flyout", w - 2., top, fw).children(frows).children(second)
914 });
915 // A list-row on the plate itself opens its flyout where a group's would be.
916 let choice_flyout = drawn.iter().enumerate().find_map(|(idx, e)| match *e {
917 Choice(action) if player.menu_sub == Some((title, action.label())) => {
918 let top = entries_h(&drawn[..idx]) - crate::layout::MENU_PAD - 2.;
919 choice_plate(player, "menubar-flyout", action, w - 2., top, cx)
920 }
921 _ => None,
922 });
923 popup_plate("menubar-plate", 0., MENU_BAR_H, w)
924 .child(
925 div()
926 .id("menubar-rows")
927 .flex()
928 .flex_col()
929 .max_h(px(room))
930 .overflow_y_scroll()
931 .children(rows),
932 )
933 .children(flyout)
934 .children(choice_flyout)
935}
936
937/// The Open recent flyout at the right of the File plate, level with its row: one two-line row per
938/// recent project (name, then its folder), a missing one dimmed with the reason in place of the
939/// folder, and Clear list under a rule.
940fn recent_flyout(top: f32, x: f32, cx: &mut Context<Player>) -> gpui::Stateful<gpui::Div> {
941 use crate::ui::theme::tokens;
942 let t = tokens();
943 let list = crate::recent::list();
944 let mut rows: Vec<AnyElement> = Vec::new();
945 for (n, r) in list.iter().enumerate() {
946 let path = r.path.clone();
947 let missing = r.missing;
948 let row = div()
949 .id(("menubar-recent", n))
950 .flex_none()
951 .flex()
952 .flex_col()
953 .justify_center()
954 .h(px(crate::layout::MENU_ROW_H + 12.))
955 .px(px(10.))
956 .rounded(px(3.))
957 .overflow_hidden()
958 .child(
959 div()
960 .truncate()
961 .type_style(type_scale::body_strong())
962 .text_color(rgb(if missing.is_some() { t.ink4 } else { t.ink1 }))
963 .child(r.name.clone()),
964 )
965 .child(
966 div()
967 .truncate()
968 .type_style(type_scale::caption())
969 .text_color(rgb(if missing.is_some() { t.ink4 } else { t.ink3 }))
970 .child(match missing {
971 Some(why) => format!("{} · {}", why.reason(), crate::recent::tail(&r.folder, 22)),
972 None => crate::recent::tail(&r.folder, 44),
973 }),
974 );
975 rows.push(match missing {
976 None => row
977 .cursor_pointer()
978 .hover(|s| s.bg(rgb(BG_HOVER())))
979 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
980 cx.stop_propagation();
981 this.menu_open = None;
982 this.menu_sub = None;
983 this.open_recent(&path, cx);
984 }))
985 .into_any_element(),
986 Some(_) => row.into_any_element(),
987 });
988 }
989 if list.is_empty() {
990 rows.push(popup_row("menubar-recent-none", "No recent projects", "", None, Some("Projects you open or save appear here")).into_any_element());
991 // The list is empty, so the way out is the one the menu offers beside it.
992 rows.push(
993 popup_row("menubar-recent-open", "Open project…", "", None, None)
994 .cursor_pointer()
995 .hover(|s| s.bg(rgb(BG_HOVER())))
996 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
997 cx.stop_propagation();
998 this.menu_open = None;
999 this.menu_sub = None;
1000 this.pick_open_project(cx);
1001 }))
1002 .into_any_element(),
1003 );
1004 } else {
1005 rows.push(popup_rule());
1006 rows.push(
1007 popup_row("menubar-recent-clear", "Clear list", "", None, None)
1008 .cursor_pointer()
1009 .hover(|s| s.bg(rgb(BG_HOVER())))
1010 .on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
1011 cx.stop_propagation();
1012 this.menu_open = None;
1013 this.menu_sub = None;
1014 crate::recent::clear();
1015 cx.notify();
1016 }))
1017 .into_any_element(),
1018 );
1019 }
1020 popup_plate("menubar-flyout", x, top, 340.).children(rows)
1021}
1022
1023/// One row per template for File > New from template and the welcome screen's From template list:
1024/// the built-ins, then the saved ones by name. A click starts a new project from the template. With
1025/// `close_menu` the File menu it hangs from closes too.
1026pub(crate) fn template_rows(cx: &mut Context<Player>, close_menu: bool) -> Vec<AnyElement> {
1027 let dir = engine::templates::dir().unwrap_or_default();
1028 let mut rows: Vec<AnyElement> = Vec::new();
1029 for (n, info) in engine::templates::list(&dir).into_iter().enumerate() {
1030 let name = info.name.clone();
1031 let hint = if info.clips { "keeps clips" } else { "" };
1032 rows.push(
1033 popup_row(("menubar-template-row", n), info.name.clone(), hint, None, None)
1034 .cursor_pointer()
1035 .hover(|s| s.bg(rgb(BG_HOVER())))
1036 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1037 cx.stop_propagation();
1038 if close_menu {
1039 this.menu_open = None;
1040 this.menu_sub = None;
1041 }
1042 this.open_new_project_from(Some(name.clone()), cx);
1043 }))
1044 .into_any_element(),
1045 );
1046 }
1047 rows
1048}
1049
1050/// The values of a list-row as a flyout plate at (`x`, `y`): one row each, the one in force
1051/// ticked, a click sets it and closes the menu. `None` while the setting has nothing to offer.
1052fn choice_plate(
1053 player: &Player,
1054 id: &'static str,
1055 action: ActionId,
1056 x: f32,
1057 y: f32,
1058 cx: &mut Context<Player>,
1059) -> Option<gpui::Stateful<gpui::Div>> {
1060 let choices = player.choices(player.menu_pick(action)?);
1061 let w = popup_w(choices.iter().map(|(_, l, d, _)| (l.as_ref(), d.as_ref())), true);
1062 let rows: Vec<AnyElement> = choices
1063 .into_iter()
1064 .enumerate()
1065 .map(|(n, (choice, label, detail, picked))| {
1066 popup_row(("menubar-choice", n), label, detail, Some(picked), None)
1067 .cursor_pointer()
1068 .hover(|s| s.bg(rgb(BG_HOVER())))
1069 .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| {
1070 cx.stop_propagation();
1071 this.menu_open = None;
1072 this.menu_sub = None;
1073 this.menu_sub2 = None;
1074 this.choose(choice, cx);
1075 }))
1076 .into_any_element()
1077 })
1078 .collect();
1079 Some(popup_plate(id, x, y, w).children(rows))
1080}
1081
1082/// The click-away for an open dropdown: a press anywhere below the bar closes
1083/// it. The bar itself stays live, so a press on another title still switches.
1084/// Mounted after the room, so it sits over it and under the dropdown plate.
1085pub(crate) fn backdrop(player: &Player, cx: &mut Context<Player>) -> Option<impl IntoElement> {
1086 player.menu_open?;
1087 Some(
1088 div()
1089 .id("menubar-away")
1090 .absolute()
1091 .top(px(MENU_BAR_H))
1092 .left(px(0.))
1093 .right(px(0.))
1094 .bottom(px(0.))
1095 .on_mouse_down(
1096 MouseButton::Left,
1097 cx.listener(|this, _: &MouseDownEvent, _, cx| {
1098 this.menu_open = None;
1099 this.menu_sub = None;
1100 cx.notify();
1101 }),
1102 )
1103 .on_mouse_down(
1104 MouseButton::Right,
1105 cx.listener(|this, _: &MouseDownEvent, _, cx| {
1106 this.menu_open = None;
1107 this.menu_sub = None;
1108 cx.notify();
1109 }),
1110 ),
1111 )
1112}
1113
1114#[cfg(test)]
1115mod tests {
1116 use super::*;
1117 use crate::menus::destructive;
1118
1119 #[test]
1120 fn clicking_another_title_with_a_menu_open_switches_to_it() {
1121 let mut hopped = None;
1122 // File open; the pointer hovers Edit (switch), then clicks it: stays open.
1123 hopped.replace(Title::Edit);
1124 assert_eq!(click_menu(Some(Title::Edit), &mut hopped, Title::Edit), Some(Title::Edit));
1125 // A second click on the open title closes it.
1126 assert_eq!(click_menu(Some(Title::Edit), &mut hopped, Title::Edit), None);
1127 // A click on a title when another is open (no hover seen) opens it.
1128 assert_eq!(click_menu(Some(Title::File), &mut hopped, Title::Edit), Some(Title::Edit));
1129 // Closed -> opens.
1130 assert_eq!(click_menu(None, &mut hopped, Title::File), Some(Title::File));
1131 }
1132
1133 /// Every action is on exactly one menu, or on [`UNLISTED`] with a reason,
1134 /// and never both. A new `ActionId` that is in neither place fails here.
1135 #[test]
1136 fn every_action_has_a_door() {
1137 for action in ActionId::ALL {
1138 let on_menus = Title::ALL
1139 .iter()
1140 .flat_map(|t| t.entries())
1141 .filter(|e| e.action() == Some(action))
1142 .count();
1143 let unlisted = UNLISTED.iter().filter(|(a, _)| *a == action).count();
1144 assert_eq!(
1145 on_menus + unlisted,
1146 1,
1147 "{action:?} is on {on_menus} menu row(s) and {unlisted} allowlist entries; want exactly one door"
1148 );
1149 }
1150 }
1151
1152 /// File carries the project rows this phase added, Open recent as a flyout.
1153 #[test]
1154 fn the_file_menu_has_versions_collect_and_open_recent() {
1155 let layout = Title::File.layout();
1156 assert!(layout.iter().any(|e| matches!(e, Sub(name, _) if *name == RECENT_SUB)));
1157 let all = Title::File.entries();
1158 for action in [ActionId::SaveVersion, ActionId::Versions, ActionId::CollectMedia, ActionId::ProjectNotes] {
1159 assert!(all.contains(&Act(action)), "{action:?}");
1160 assert!(action.label().ends_with('…'), "{action:?} opens a dialog");
1161 }
1162 }
1163
1164 #[test]
1165 fn unlisted_entries_have_a_reason() {
1166 for (action, why) in UNLISTED {
1167 assert!(!why.trim().is_empty(), "{action:?} has no reason");
1168 }
1169 }
1170
1171 /// DESIGN §6.1 and §9: a verb that takes something away sits below a rule
1172 /// line in its menu.
1173 #[test]
1174 fn destructive_rows_sit_below_a_rule() {
1175 for title in Title::ALL {
1176 let entries = title.entries();
1177 for (idx, entry) in entries.iter().enumerate() {
1178 let Some(action) = entry.action() else {
1179 continue;
1180 };
1181 if !destructive(action) {
1182 continue;
1183 }
1184 assert!(
1185 entries[..idx].contains(&Rule),
1186 "{action:?} in {} has no rule line above it",
1187 title.label()
1188 );
1189 }
1190 }
1191 }
1192
1193 /// Every menu, with all its rows listed, fits a 1280x720 window without scrolling, and so
1194 /// does every flyout.
1195 #[test]
1196 fn every_menu_fits_a_720_window() {
1197 let room = 720. - MENU_BAR_H - crate::layout::MENU_EDGE;
1198 fn lists(list: &'static [Entry], out: &mut Vec<&'static [Entry]>) {
1199 out.push(list);
1200 for e in list {
1201 if let Sub(_, inner) = e {
1202 lists(inner, out);
1203 }
1204 }
1205 }
1206 for title in Title::ALL {
1207 let mut all = Vec::new();
1208 lists(title.layout(), &mut all);
1209 for list in all {
1210 let h = entries_h(list);
1211 assert!(h <= room, "{} menu list is {h} px, over the {room} px a 720 window leaves", title.label());
1212 }
1213 }
1214 }
1215}