forge
Explore
Log in

Don't you dare go Hollow

edith

Clone
★ 0

0 watching0 forksRust18.3 MiBff99ad6Tahinli6 days ago1055 commits

polish5.rs150 lines, 6.7 KiBHistoryRawDownload
1//! Round-5 GUI polish: one text field for the renames, the sequence tab menu, a strip that
2//! never shifts, tooltips off the timeline, grouped menu bar menus, two-line media meta, the
3//! angle monitor's tiles and Flatten multicam's reach. Pure functions and scans of the wiring.
4
5use super::*;
6use crate::player::text_field::{FieldKey, TextField};
7use crate::ui::menubar::{Entry, Title};
8use keymap::ActionId;
9
10/// Ctrl+A selects the whole name, typing replaces a selection, backspace clears it, and both the
11/// sequence tab and the track head run the very same field.
12#[test]
13fn the_renames_share_one_text_field_with_select_all() {
14 let mut f = TextField::selected("Sequence 2");
15 assert!(f.all, "a rename opens fully selected");
16 assert_eq!(f.key("c", false, false, Some("C"), 80), FieldKey::Edited);
17 assert_eq!(f.text, "C", "typing replaces the selection");
18 f.key("u", false, false, Some("u"), 80);
19 assert_eq!(f.text, "Cu");
20 f.key("a", true, false, Some("a"), 80);
21 assert!(f.all && f.text == "Cu", "ctrl+a selects, and does not type");
22 f.key("t", false, false, Some("t"), 80);
23 assert_eq!(f.text, "t");
24 f.key("a", true, false, None, 80);
25 f.key("backspace", false, false, None, 80);
26 assert_eq!(f.text, "");
27 assert_eq!(f.key("enter", false, false, None, 80), FieldKey::Commit);
28 assert_eq!(f.key("escape", false, false, None, 80), FieldKey::Cancel);
29 let mut g = TextField::selected("");
30 for c in "abcdef".chars() {
31 g.key("x", false, false, Some(&c.to_string()), 3);
32 }
33 assert_eq!(g.text, "abc", "the cap holds");
34 assert!(src_text("player/sequences.rs").contains("field.key(key, ctrl, alt, key_char, MAX_SEQUENCE_NAME_CHARS)"));
35 assert!(src_text("player/lane_names.rs").contains("field.key(key, ctrl, alt, key_char, MAX_LANE_NAME_CHARS)"));
36}
37
38/// A sequence tab has a right-click menu in the shared popup look; deleting is undoable with a
39/// toast offering Undo.
40#[test]
41fn a_sequence_tab_has_a_menu_and_delete_offers_undo() {
42 assert_eq!(
43 crate::menus::SEQ_TAB_ITEMS,
44 [ActionId::RenameSequence, ActionId::DuplicateSequence, ActionId::DeleteSequence]
45 );
46 assert!(crate::menus::destructive(ActionId::DeleteSequence), "delete sits under the rule line");
47 let bar = src_text("ui/toolbar.rs");
48 assert!(bar.contains("MouseButton::Right") && bar.contains("open_seq_tab_menu(id"));
49 assert!(src_text("ui/overlays.rs").contains("MenuOn::SeqTab => SEQ_TAB_ITEMS.to_vec()"));
50 let seq = src_text("player/sequences.rs");
51 assert!(seq.contains("crate::notices::ToastAction::Undo"), "the delete toast offers Undo");
52}
53
54/// The back chevron's slot is always there (drawn only inside a compound), so the tabs never shift.
55#[test]
56fn the_back_button_is_always_drawn_so_the_tabs_never_shift() {
57 let bar = src_text("ui/toolbar.rs");
58 let at = bar.find("\"seq-back\"").expect("the back button");
59 let before = &bar[..at];
60 assert!(before[before.len() - 300..].contains(".w(px(78.))") && before[before.len() - 300..].contains(".h(px(24.))"), "its slot has a fixed size");
61 assert!(before[before.len() - 300..].contains(".when(back"), "it draws only inside a compound");
62}
63
64/// A tooltip with the pointer in the timeline region hangs above that region; above it, the
65/// ordinary place.
66#[test]
67fn tooltips_over_the_timeline_hang_above_it() {
68 use crate::ui::widgets::tip_lift;
69 assert_eq!(tip_lift(300., 400.), None, "above the region: ordinary place");
70 assert_eq!(tip_lift(300., 0.), None, "no region known");
71 let lift = tip_lift(460., 400.).expect("inside the region");
72 // The plate's bottom edge: the pointer's y (+1) minus the lift is above the region's top.
73 assert!(461. - lift < 400.);
74 assert_eq!(tip_lift(700., 400.), None, "over the lanes a plate stays by its pointer");
75 let render = src_text("render.rs");
76 assert!(render.contains("TIMELINE_TOP_BITS"));
77 assert!(src_text("ui/widgets.rs").contains("tip_lift(my, top)"), "one placement rule, in widgets.rs");
78}
79
80fn drawn_lists(list: &'static [Entry], out: &mut Vec<&'static [Entry]>) {
81 out.push(list);
82 for e in list {
83 if let Entry::Sub(_, inner) = e {
84 drawn_lists(inner, out);
85 }
86 }
87}
88
89/// Every menu bar menu, with every row present, fits a 1280x720 window; the Clip menu groups its
90/// verbs into flyouts the way Premiere does.
91#[test]
92fn every_menubar_menu_fits_1280_by_720() {
93 let room = 720. - crate::layout::MENU_BAR_H - crate::layout::MENU_EDGE;
94 for title in Title::ALL {
95 let mut all = Vec::new();
96 drawn_lists(title.layout(), &mut all);
97 for list in all {
98 let h = crate::ui::menubar::entries_h(list);
99 assert!(h <= room, "{} menu: {h} px over {room}", title.label());
100 }
101 }
102 let names: Vec<&str> = Title::Clip
103 .layout()
104 .iter()
105 .filter_map(|e| if let Entry::Sub(n, _) = e { Some(*n) } else { None })
106 .collect();
107 for want in ["Trim", "Speed", "Adjust", "Compound", "Multicam"] {
108 assert!(names.contains(&want), "Clip ▸ {want}");
109 }
110 assert!(Title::Clip.entries().contains(&Entry::Act(ActionId::FlattenMulticam)), "Flatten is in the Clip menu");
111}
112
113/// The media row's facts are one caption line that ends in an ellipsis rather
114/// than breaking mid-phrase (REDESIGN §3.8).
115#[test]
116fn media_meta_is_one_unbroken_line() {
117 let dock = src_text("ui/dock_stance.rs");
118 assert!(dock.contains(".whitespace_nowrap()") && dock.contains("let (line2, line2_ink)"));
119}
120
121/// The monitor draws no empty slot.
122#[test]
123fn the_angle_monitor_never_draws_an_empty_slot() {
124 use crate::player::multicam::monitor_rows;
125 for n in 1..=9 {
126 let rows = monitor_rows(n);
127 assert_eq!(rows.iter().sum::<usize>(), n, "{n} angles");
128 assert!(rows.iter().all(|&r| r > 0 && r <= 3));
129 }
130 assert_eq!(monitor_rows(2), [1, 1]);
131 assert_eq!(monitor_rows(9), [3, 3, 3]);
132}
133
134/// Flatten multicam is on whenever any piece of a multicam clip is selected or under the
135/// playhead, and hidden only for a plain clip.
136#[test]
137fn flatten_is_reachable_from_any_piece_of_a_multicam_clip() {
138 use crate::oracle::{Ctx, Enable, enable};
139 let piece = Ctx { multicam: true, timeline: true, playable: true, ..Ctx::default() };
140 assert_eq!(enable(ActionId::FlattenMulticam, piece), Enable::Yes, "no clip asked about, a piece picked");
141 let plain = Ctx {
142 clip: Some((Clip::source_range(0, 0, 10), Lane::V1)),
143 timeline: true,
144 playable: true,
145 ..Ctx::default()
146 };
147 assert!(matches!(enable(ActionId::FlattenMulticam, plain), Enable::Hidden(_)));
148 let src = src_text("player/actions.rs");
149 assert!(src.contains("picks.iter().any(|&(lane, idx)| session.multicam_at(lane, idx).is_some())"));
150}