Library tabs, accent primary action, redesign guards
Browse files at this commit2171351fde6a8f912d76a8eccc4c1d0284637508Parent: 2ae5c26- feat
- library tabs, accent primary action, redesign guards
5 changed files +233 -17
- crates/app/src/main.rs +137 -4
- crates/app/src/ui/inspector.rs +12 -1
- crates/app/src/ui/library.rs +44 -6
- crates/app/src/ui/toolbar.rs +35 -5
- crates/app/src/ui/widgets.rs +5 -1
crates/app/src/main.rsmodified+137 -4
| @@ -306,6 +306,48 @@ impl Default for Volume { | ||
| 306 | 306 | } |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | +/// The library's three categories, in the order the giants list them: the | |
| 310 | +/// pictures, the sound, and the words. A file is in exactly one of them, so a | |
| 311 | +/// tab is a question with an answer rather than a filter with a guess. | |
| 312 | +#[derive(Clone, Copy, PartialEq, Eq, Debug)] | |
| 313 | +enum LibraryTab { | |
| 314 | + Media, | |
| 315 | + Audio, | |
| 316 | + Text, | |
| 317 | +} | |
| 318 | + | |
| 319 | +const LIBRARY_TABS: [LibraryTab; 3] = [LibraryTab::Media, LibraryTab::Audio, LibraryTab::Text]; | |
| 320 | + | |
| 321 | +impl LibraryTab { | |
| 322 | + fn label(self) -> &'static str { | |
| 323 | + match self { | |
| 324 | + LibraryTab::Media => "Media", | |
| 325 | + LibraryTab::Audio => "Audio", | |
| 326 | + LibraryTab::Text => "Text", | |
| 327 | + } | |
| 328 | + } | |
| 329 | + | |
| 330 | + /// Whether a source belongs on this tab. Subtitles are not sources at all | |
| 331 | + /// -- they are the [`Player::subtitle_section`] under the list -- so the | |
| 332 | + /// Text tab holds no rows of its own and says so. | |
| 333 | + fn holds(self, path: &Path) -> bool { | |
| 334 | + match self { | |
| 335 | + LibraryTab::Media => !engine::is_audio(path), | |
| 336 | + LibraryTab::Audio => engine::is_audio(path), | |
| 337 | + LibraryTab::Text => false, | |
| 338 | + } | |
| 339 | + } | |
| 340 | + | |
| 341 | + /// What an empty tab says instead of being a blank column. | |
| 342 | + fn empty(self) -> &'static str { | |
| 343 | + match self { | |
| 344 | + LibraryTab::Media => "No video or stills yet — Import, or drop a file on the window", | |
| 345 | + LibraryTab::Audio => "No sound yet — Import, or drop a file on the window", | |
| 346 | + LibraryTab::Text => "No subtitles yet — drop an .srt on the window, or + S in the toolbar", | |
| 347 | + } | |
| 348 | + } | |
| 349 | +} | |
| 350 | + | |
| 309 | 351 | /// What is known about a source's audio. Three states and not two, because a |
| 310 | 352 | /// file whose peaks have not come back yet must not be drawn as one that has no |
| 311 | 353 | /// audio at all: the first shows a bed, the second shows nothing. |
| @@ -1121,6 +1163,10 @@ struct Player { | ||
| 1121 | 1163 | /// rebuilt. Its own selection and not the timeline's: Delete keeps acting |
| 1122 | 1164 | /// on the clip that was clicked in a lane, whatever the library is showing. |
| 1123 | 1165 | selected_asset: Option<(PathBuf, usize)>, |
| 1166 | + /// Which category of the library is being looked at. A tab and not a | |
| 1167 | + /// filter box: the categories are what the media *is*, and every editor | |
| 1168 | + /// this one is measured against splits its pool the same way. | |
| 1169 | + library_tab: LibraryTab, | |
| 1124 | 1170 | /// What is known about each source's audio, taken once and kept. Keyed on |
| 1125 | 1171 | /// the path *and stream* -- two streams of one file are two envelopes -- and |
| 1126 | 1172 | /// the key is inserted the moment the decode is *started*: presence means |
| @@ -8233,13 +8279,20 @@ fn panel_h(lanes: usize) -> f32 { | ||
| 8233 | 8279 | PANEL_H + lanes_h(lanes.clamp(2, LANES_MAX)) - lanes_h(2) |
| 8234 | 8280 | } |
| 8235 | 8281 | |
| 8236 | -/// ...and how tall the timeline region alone is: the panel without the button | |
| 8237 | -/// row that used to sit inside it, which is now its own region above | |
| 8238 | -/// ([`Player::toolbar`], [`TOOLBAR_H`]). | |
| 8282 | +/// How tall the timeline region is: its own padding, the timecode line, the | |
| 8283 | +/// ruler and the gaps between them, plus a row per lane. Measured from its | |
| 8284 | +/// parts rather than taken off [`PANEL_H`] -- the button row moved out of it | |
| 8285 | +/// ([`Player::toolbar`]), and a height still carrying that row's pixels is a | |
| 8286 | +/// height that cuts the last lane off the bottom of the window. | |
| 8239 | 8287 | fn timeline_h(lanes: usize) -> f32 { |
| 8240 | - panel_h(lanes) - TOOLBAR_H | |
| 8288 | + TIMELINE_FIXED_H + lanes_h(lanes.clamp(2, LANES_MAX)) | |
| 8241 | 8289 | } |
| 8242 | 8290 | |
| 8291 | +/// 8+8 padding, the timecode line, the 24 px ruler strip and the two 8 px gaps | |
| 8292 | +/// between the three rows, with a couple of px of slack so a taller text line | |
| 8293 | +/// cannot push a lane off the bottom. | |
| 8294 | +const TIMELINE_FIXED_H: f32 = 16. + 18. + 8. + RULER_HIT_H + 8. + 4.; | |
| 8295 | + | |
| 8243 | 8296 | /// The edit toolbar directly above the timeline: one control's height in its |
| 8244 | 8297 | /// own padding, fixed so nothing in it can push the timeline down. |
| 8245 | 8298 | const TOOLBAR_H: f32 = CONTROL_H + 16.; |
| @@ -14174,6 +14227,85 @@ mod tests { | ||
| 14174 | 14227 | ); |
| 14175 | 14228 | } |
| 14176 | 14229 | |
| 14230 | + /// The whole reason `ui/theme.rs` exists: a colour written anywhere else is | |
| 14231 | + /// a colour the next palette sweep will miss, which is exactly how 186 grey | |
| 14232 | + /// calls survived every previous attempt at this. | |
| 14233 | + #[test] | |
| 14234 | + fn no_colour_is_written_outside_the_theme() { | |
| 14235 | + let source = ui_source(); | |
| 14236 | + let stray: Vec<&str> = source | |
| 14237 | + .lines() | |
| 14238 | + .filter(|l| l.contains("rgb(0x") || l.contains("rgba(0x")) | |
| 14239 | + .collect(); | |
| 14240 | + assert!(stray.is_empty(), "colour written outside the theme: {stray:?}"); | |
| 14241 | + } | |
| 14242 | + | |
| 14243 | + /// The cards are sections of the inspector, not sheets over the timeline: | |
| 14244 | + /// adjusting a clip must never hide the clip. Structural, because that is | |
| 14245 | + /// where the rule lives -- a card rendered from the root again would be an | |
| 14246 | + /// overlay again, whatever it looked like on the day it was written. | |
| 14247 | + #[test] | |
| 14248 | + fn an_inspector_section_occludes_no_timeline() { | |
| 14249 | + let inspector = include_str!("ui/inspector.rs"); | |
| 14250 | + let root = include_str!("main.rs").split("#[cfg(test)]").next().unwrap(); | |
| 14251 | + let render = &root[root.find("impl Render for Player").expect("the root render")..]; | |
| 14252 | + for card in [ | |
| 14253 | + "eq_card", "color_card", "speed_card", "silence_card", "mix_card", | |
| 14254 | + ] { | |
| 14255 | + assert!( | |
| 14256 | + inspector.contains(&format!("self.{card}(")), | |
| 14257 | + "{card} is not a section of the inspector" | |
| 14258 | + ); | |
| 14259 | + assert!( | |
| 14260 | + !render.contains(&format!("self.{card}(")), | |
| 14261 | + "{card} is drawn from the root again -- it is an overlay over the timeline" | |
| 14262 | + ); | |
| 14263 | + } | |
| 14264 | + // The docked cards are placed against the inspector's own box, which is | |
| 14265 | + // what turns `scrim()` (`absolute().inset_0()`) from a window-wide sheet | |
| 14266 | + // into this column. | |
| 14267 | + assert!( | |
| 14268 | + inspector.contains(".relative()"), | |
| 14269 | + "the inspector is not a positioning context: its cards would cover the window" | |
| 14270 | + ); | |
| 14271 | + } | |
| 14272 | + | |
| 14273 | + /// MUST 1, on the two named offenders: the button that relabels itself | |
| 14274 | + /// mid-export and the one that used to read "Muted 80%". Both live in a | |
| 14275 | + /// rect that is reserved once, so the words change and the box does not. | |
| 14276 | + #[test] | |
| 14277 | + fn a_stateful_button_keeps_its_rect() { | |
| 14278 | + use crate::ui::toolbar::{EXPORT_SLOT_W, SNAP_SLOT_W, VOLUME_SLOT_W}; | |
| 14279 | + // Widest word each slot can hold, at the 12 px text this window is set | |
| 14280 | + // in -- ~7 px a character plus the 16 px of padding. | |
| 14281 | + let fits = |slot: f32, word: &str| slot >= word.chars().count() as f32 * 7. + 16.; | |
| 14282 | + for word in ["Export", "Cancel"] { | |
| 14283 | + assert!(fits(EXPORT_SLOT_W, word), "{word} overflows its rect"); | |
| 14284 | + } | |
| 14285 | + for word in ["Snap on", "Snap off", "No subs", "Subs off"] { | |
| 14286 | + assert!(fits(SNAP_SLOT_W, word), "{word} overflows its rect"); | |
| 14287 | + } | |
| 14288 | + for word in ["100%", "× 100%"] { | |
| 14289 | + assert!(fits(VOLUME_SLOT_W, word), "{word} overflows its rect"); | |
| 14290 | + } | |
| 14291 | + // And the rect is passed, not hoped for: every stateful control in the | |
| 14292 | + // three chrome rows names its width. | |
| 14293 | + let toolbar = include_str!("ui/toolbar.rs"); | |
| 14294 | + for (id, slot) in [ | |
| 14295 | + ("\"export\"", "EXPORT_SLOT_W"), | |
| 14296 | + ("\"snap\"", "SNAP_SLOT_W"), | |
| 14297 | + ("\"subs\"", "SNAP_SLOT_W"), | |
| 14298 | + ("\"volume\"", "VOLUME_SLOT_W"), | |
| 14299 | + ("\"zoom-fit\"", "ZOOM_SLOT_W"), | |
| 14300 | + ] { | |
| 14301 | + let at = toolbar.find(id).unwrap_or_else(|| panic!("no {id} button")); | |
| 14302 | + assert!( | |
| 14303 | + toolbar[at..at + 120].contains(slot), | |
| 14304 | + "{id} does not reserve {slot}" | |
| 14305 | + ); | |
| 14306 | + } | |
| 14307 | + } | |
| 14308 | + | |
| 14177 | 14309 | #[test] |
| 14178 | 14310 | fn nothing_clickable_is_smaller_than_the_wcag_minimum() { |
| 14179 | 14311 | // Every hit target in the panel, including the scrub strip -- whose bar |
| @@ -15128,6 +15260,7 @@ fn main() { | ||
| 15128 | 15260 | picker: None, |
| 15129 | 15261 | library_menu: None, |
| 15130 | 15262 | selected_asset: None, |
| 15263 | + library_tab: LibraryTab::Media, | |
| 15131 | 15264 | waves: HashMap::new(), |
| 15132 | 15265 | streams: HashMap::new(), |
| 15133 | 15266 | bitrates: HashMap::new(), |
crates/app/src/ui/inspector.rsmodified+12 -1
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | //! (`an_inspector_section_occludes_no_timeline`). |
| 9 | 9 | |
| 10 | 10 | use crate::*; |
| 11 | +use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W}; | |
| 11 | 12 | use crate::ui::widgets::*; |
| 12 | 13 | |
| 13 | 14 | impl Player { |
| @@ -124,6 +125,7 @@ impl Player { | ||
| 124 | 125 | .child(self.action_control( |
| 125 | 126 | "inspect-speed", |
| 126 | 127 | 0., |
| 128 | + BG_RAISED, | |
| 127 | 129 | None, |
| 128 | 130 | "Speed", |
| 129 | 131 | "how fast this clip and its group play", |
| @@ -133,6 +135,7 @@ impl Player { | ||
| 133 | 135 | .child(self.action_control( |
| 134 | 136 | "inspect-color", |
| 135 | 137 | 0., |
| 138 | + BG_RAISED, | |
| 136 | 139 | None, |
| 137 | 140 | "Colour", |
| 138 | 141 | "exposure, contrast, saturation and temperature", |
| @@ -142,6 +145,7 @@ impl Player { | ||
| 142 | 145 | .child(self.action_control( |
| 143 | 146 | "inspect-eq", |
| 144 | 147 | 0., |
| 148 | + BG_RAISED, | |
| 145 | 149 | None, |
| 146 | 150 | "Equalizer", |
| 147 | 151 | "the bands this clip's sound is filtered through", |
| @@ -151,6 +155,7 @@ impl Player { | ||
| 151 | 155 | .child(self.action_control( |
| 152 | 156 | "inspect-silence", |
| 153 | 157 | 0., |
| 158 | + BG_RAISED, | |
| 154 | 159 | None, |
| 155 | 160 | "Silence", |
| 156 | 161 | "finds the quiet stretches and cuts or speeds them", |
| @@ -160,6 +165,7 @@ impl Player { | ||
| 160 | 165 | .child(self.action_control( |
| 161 | 166 | "inspect-fit", |
| 162 | 167 | 0., |
| 168 | + BG_RAISED, | |
| 163 | 169 | None, |
| 164 | 170 | "Fit", |
| 165 | 171 | "how this picture is placed on the project canvas", |
| @@ -169,6 +175,7 @@ impl Player { | ||
| 169 | 175 | .child(self.action_control( |
| 170 | 176 | "inspect-delete", |
| 171 | 177 | 0., |
| 178 | + BG_RAISED, | |
| 172 | 179 | None, |
| 173 | 180 | "Delete", |
| 174 | 181 | "takes this clip off the timeline", |
| @@ -206,6 +213,7 @@ impl Player { | ||
| 206 | 213 | .child(self.action_control( |
| 207 | 214 | "resolution", |
| 208 | 215 | ZOOM_SLOT_W, |
| 216 | + BG_RAISED, | |
| 209 | 217 | None, |
| 210 | 218 | resolution.map_or_else(|| "Size".to_string(), |(_, h)| format!("{h}p")), |
| 211 | 219 | "the canvas every clip is composed onto, and the size the export comes out at", |
| @@ -217,6 +225,7 @@ impl Player { | ||
| 217 | 225 | .child(self.action_control( |
| 218 | 226 | "fps", |
| 219 | 227 | ZOOM_SLOT_W, |
| 228 | + BG_RAISED, | |
| 220 | 229 | None, |
| 221 | 230 | match self.session.is_some() { |
| 222 | 231 | true => format!("{} fps", fps_label(self.fps)), |
| @@ -230,7 +239,8 @@ impl Player { | ||
| 230 | 239 | )) |
| 231 | 240 | .child(self.action_control( |
| 232 | 241 | "tonemap", |
| 233 | - ZOOM_SLOT_W, | |
| 242 | + TONE_SLOT_W, | |
| 243 | + BG_RAISED, | |
| 234 | 244 | None, |
| 235 | 245 | match &self.session { |
| 236 | 246 | Some(session) => format!("HDR {}", tone_label(session.tone())), |
| @@ -245,6 +255,7 @@ impl Player { | ||
| 245 | 255 | .child(self.action_control( |
| 246 | 256 | "inspect-mix", |
| 247 | 257 | 0., |
| 258 | + BG_RAISED, | |
| 248 | 259 | None, |
| 249 | 260 | "Mix", |
| 250 | 261 | "a fader per track and the limiter over the sum of them", |
crates/app/src/ui/library.rsmodified+44 -6
| @@ -40,7 +40,12 @@ impl Player { | ||
| 40 | 40 | }, |
| 41 | 41 | ) |
| 42 | 42 | .into_iter() |
| 43 | + // The tab is the one filter: `enumerate` stays *before* it, so a row's | |
| 44 | + // index is still its index in the whole library and the tints, the | |
| 45 | + // menus and the drags all keep naming the same file whichever tab is | |
| 46 | + // open. | |
| 43 | 47 | .enumerate() |
| 48 | + .filter(|(_, row)| self.library_tab.holds(&row.path)) | |
| 44 | 49 | .map(|(i, row)| { |
| 45 | 50 | let picked = self |
| 46 | 51 | .selected_asset |
| @@ -225,14 +230,44 @@ impl Player { | ||
| 225 | 230 | div() |
| 226 | 231 | .flex_1() |
| 227 | 232 | .min_w(px(0.)) |
| 228 | - .truncate() | |
| 229 | - .text_size(px(11.)) | |
| 230 | - .text_color(rgb(FG_SECONDARY)) | |
| 231 | - .child("Media"), | |
| 233 | + .flex() | |
| 234 | + .gap(px(2.)) | |
| 235 | + .children(LIBRARY_TABS.map(|tab| { | |
| 236 | + let on = tab == self.library_tab; | |
| 237 | + div() | |
| 238 | + .id(("library-tab", tab as usize)) | |
| 239 | + .flex_none() | |
| 240 | + .h(px(HIT_MIN)) | |
| 241 | + .px(px(6.)) | |
| 242 | + .flex() | |
| 243 | + .items_center() | |
| 244 | + .rounded(px(3.)) | |
| 245 | + .text_size(px(11.)) | |
| 246 | + .text_color(rgb(match on { | |
| 247 | + true => FG_PRIMARY, | |
| 248 | + false => FG_SECONDARY, | |
| 249 | + })) | |
| 250 | + // One selection language everywhere: the | |
| 251 | + // same stroke a picked clip and a picked | |
| 252 | + // row wear. | |
| 253 | + .when(on, |d| { | |
| 254 | + d.bg(rgb(BG_SELECTED)) | |
| 255 | + .border_b_2() | |
| 256 | + .border_color(rgb(STROKE_SELECTED)) | |
| 257 | + }) | |
| 258 | + .cursor_pointer() | |
| 259 | + .hover(|s| s.bg(rgb(BG_HOVER))) | |
| 260 | + .on_click(cx.listener(move |this, _: &ClickEvent, _, cx| { | |
| 261 | + this.library_tab = tab; | |
| 262 | + cx.notify(); | |
| 263 | + })) | |
| 264 | + .child(tab.label()) | |
| 265 | + })), | |
| 232 | 266 | ) |
| 233 | 267 | .child(control( |
| 234 | 268 | "import", |
| 235 | 269 | 0., |
| 270 | + BG_RAISED, | |
| 236 | 271 | None, |
| 237 | 272 | "Import", |
| 238 | 273 | "adds a file to this list — or drop one on the window".to_string(), |
| @@ -256,7 +291,7 @@ impl Player { | ||
| 256 | 291 | div() |
| 257 | 292 | .text_size(px(11.)) |
| 258 | 293 | .text_color(rgb(FG_SECONDARY)) |
| 259 | - .child("No media yet — Import, or drop a file on the window"), | |
| 294 | + .child(self.library_tab.empty()), | |
| 260 | 295 | ) |
| 261 | 296 | }) |
| 262 | 297 | .children(rows), |
| @@ -264,10 +299,13 @@ impl Player { | ||
| 264 | 299 | // Under the media it belongs to: a subtitle track is not a source -- |
| 265 | 300 | // it goes on no lane and is dragged nowhere -- but it is a thing the |
| 266 | 301 | // timeline holds, and this is the list of those. |
| 267 | - .children(self.subtitle_section(width, viewport_h, cx)) | |
| 302 | + .when(self.library_tab == LibraryTab::Text, |d| { | |
| 303 | + d.children(self.subtitle_section(width, viewport_h, cx)) | |
| 304 | + }) | |
| 268 | 305 | .child(control( |
| 269 | 306 | "add-asset", |
| 270 | 307 | 0., |
| 308 | + BG_RAISED, | |
| 271 | 309 | None, |
| 272 | 310 | "Add at playhead", |
| 273 | 311 | match self.selected_asset { |
crates/app/src/ui/toolbar.rsmodified+35 -5
| @@ -26,6 +26,7 @@ impl Player { | ||
| 26 | 26 | &self, |
| 27 | 27 | id: &'static str, |
| 28 | 28 | w: f32, |
| 29 | + bg: u32, | |
| 29 | 30 | glyph: Option<AnyElement>, |
| 30 | 31 | label: impl Into<SharedString>, |
| 31 | 32 | hint: &str, |
| @@ -41,7 +42,7 @@ impl Player { | ||
| 41 | 42 | Some(why) => format!("{key} — {why}"), |
| 42 | 43 | None => format!("{key} — {hint}"), |
| 43 | 44 | }; |
| 44 | - control(id, w, glyph, label, say, enabled.yes(), on_click) | |
| 45 | + control(id, w, bg, glyph, label, say, enabled.yes(), on_click) | |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | /// The bar over everything: what is open on the left, the two actions that |
| @@ -78,6 +79,7 @@ impl Player { | ||
| 78 | 79 | .child(self.action_control( |
| 79 | 80 | "save", |
| 80 | 81 | 0., |
| 82 | + BG_RAISED, | |
| 81 | 83 | None, |
| 82 | 84 | "Save", |
| 83 | 85 | "writes the project file", |
| @@ -93,6 +95,10 @@ impl Player { | ||
| 93 | 95 | .child(self.action_control( |
| 94 | 96 | "export", |
| 95 | 97 | EXPORT_SLOT_W, |
| 98 | + // The one accented button in the window: the primary | |
| 99 | + // action of an editor, where every consumer editor puts | |
| 100 | + // it. Cancel keeps the rect and the accent both. | |
| 101 | + ACCENT_PRIMARY, | |
| 96 | 102 | None, |
| 97 | 103 | if exporting { "Cancel" } else { "Export" }, |
| 98 | 104 | if exporting { |
| @@ -114,8 +120,7 @@ impl Player { | ||
| 114 | 120 | } |
| 115 | 121 | }), |
| 116 | 122 | )) |
| 117 | - .when(!exporting, |d| d.text_color(rgb(BG_CANVAS))) | |
| 118 | - .when(exporting, |d| d.text_color(rgb(FG_PRIMARY))), | |
| 123 | + , | |
| 119 | 124 | ) |
| 120 | 125 | } |
| 121 | 126 | |
| @@ -142,6 +147,7 @@ impl Player { | ||
| 142 | 147 | .child(self.action_control( |
| 143 | 148 | "transport", |
| 144 | 149 | 40., |
| 150 | + BG_RAISED, | |
| 145 | 151 | Some(transport_glyph(state).into_any_element()), |
| 146 | 152 | "", |
| 147 | 153 | "plays and pauses the timeline", |
| @@ -175,10 +181,15 @@ impl Player { | ||
| 175 | 181 | .child(self.action_control( |
| 176 | 182 | "volume", |
| 177 | 183 | VOLUME_SLOT_W, |
| 184 | + BG_RAISED, | |
| 178 | 185 | None, |
| 186 | + // The level is the label either way and it lives in a fixed | |
| 187 | + // rect: muting adds a mark and changes the colour, where it | |
| 188 | + // used to relabel the button "Muted 80%" and shove the slider | |
| 189 | + // beside it along the row. | |
| 179 | 190 | match muted { |
| 180 | - true => format!("🔇 {}%", self.volume.percent()), | |
| 181 | - false => format!("🔊 {}%", self.volume.percent()), | |
| 191 | + true => format!("× {}%", self.volume.percent()), | |
| 192 | + false => format!("{}%", self.volume.percent()), | |
| 182 | 193 | }, |
| 183 | 194 | "mutes and unmutes; the level is what it comes back to", |
| 184 | 195 | ActionId::ToggleMute, |
| @@ -186,6 +197,10 @@ impl Player { | ||
| 186 | 197 | this.set_volume(|volume| volume.muted = !volume.muted, cx) |
| 187 | 198 | }), |
| 188 | 199 | )) |
| 200 | + .text_color(rgb(match muted { | |
| 201 | + true => STATUS_WARNING, | |
| 202 | + false => FG_PRIMARY, | |
| 203 | + })) | |
| 189 | 204 | .child(volume_slider( |
| 190 | 205 | self.volume, |
| 191 | 206 | self.volume_bar.clone(), |
| @@ -226,6 +241,7 @@ impl Player { | ||
| 226 | 241 | .child(self.action_control( |
| 227 | 242 | "cut", |
| 228 | 243 | 0., |
| 244 | + BG_RAISED, | |
| 229 | 245 | Some(cut_glyph().into_any_element()), |
| 230 | 246 | "Split", |
| 231 | 247 | "splits the clip under the playhead", |
| @@ -235,6 +251,7 @@ impl Player { | ||
| 235 | 251 | .child(self.action_control( |
| 236 | 252 | "delete", |
| 237 | 253 | 0., |
| 254 | + BG_RAISED, | |
| 238 | 255 | Some(delete_glyph().into_any_element()), |
| 239 | 256 | "Delete", |
| 240 | 257 | "takes the marked clip off the timeline", |
| @@ -244,6 +261,7 @@ impl Player { | ||
| 244 | 261 | .child(self.action_control( |
| 245 | 262 | "undo", |
| 246 | 263 | 0., |
| 264 | + BG_RAISED, | |
| 247 | 265 | None, |
| 248 | 266 | "Undo", |
| 249 | 267 | "takes the last edit back", |
| @@ -254,6 +272,7 @@ impl Player { | ||
| 254 | 272 | .child(self.action_control( |
| 255 | 273 | "add-video-lane", |
| 256 | 274 | 0., |
| 275 | + BG_RAISED, | |
| 257 | 276 | None, |
| 258 | 277 | "+ V", |
| 259 | 278 | "adds a video track under the ones there", |
| @@ -265,6 +284,7 @@ impl Player { | ||
| 265 | 284 | .child(self.action_control( |
| 266 | 285 | "add-audio-lane", |
| 267 | 286 | 0., |
| 287 | + BG_RAISED, | |
| 268 | 288 | None, |
| 269 | 289 | "+ A", |
| 270 | 290 | "adds an audio track under the ones there", |
| @@ -276,6 +296,7 @@ impl Player { | ||
| 276 | 296 | .child(self.action_control( |
| 277 | 297 | "add-subtitle-track", |
| 278 | 298 | 0., |
| 299 | + BG_RAISED, | |
| 279 | 300 | None, |
| 280 | 301 | "+ S", |
| 281 | 302 | "adds every subtitle track in a file you pick", |
| @@ -291,6 +312,7 @@ impl Player { | ||
| 291 | 312 | .child(self.action_control( |
| 292 | 313 | "snap", |
| 293 | 314 | SNAP_SLOT_W, |
| 315 | + BG_RAISED, | |
| 294 | 316 | None, |
| 295 | 317 | if self.snap { "Snap on" } else { "Snap off" }, |
| 296 | 318 | match self.snap { |
| @@ -303,6 +325,7 @@ impl Player { | ||
| 303 | 325 | .child(self.action_control( |
| 304 | 326 | "subs", |
| 305 | 327 | SNAP_SLOT_W, |
| 328 | + BG_RAISED, | |
| 306 | 329 | None, |
| 307 | 330 | match (self.subtitle_track().is_some(), self.subs_on) { |
| 308 | 331 | (false, _) => "No subs", |
| @@ -317,6 +340,7 @@ impl Player { | ||
| 317 | 340 | .child(self.action_control( |
| 318 | 341 | "zoom-out", |
| 319 | 342 | CONTROL_H, |
| 343 | + BG_RAISED, | |
| 320 | 344 | None, |
| 321 | 345 | "−", |
| 322 | 346 | "show more of the timeline; stops with all of it on the bed", |
| @@ -328,6 +352,7 @@ impl Player { | ||
| 328 | 352 | .child(self.action_control( |
| 329 | 353 | "zoom-fit", |
| 330 | 354 | ZOOM_SLOT_W, |
| 355 | + BG_RAISED, | |
| 331 | 356 | None, |
| 332 | 357 | span_label(self.view().span()), |
| 333 | 358 | "fit the whole timeline on the bed", |
| @@ -337,6 +362,7 @@ impl Player { | ||
| 337 | 362 | .child(self.action_control( |
| 338 | 363 | "zoom-in", |
| 339 | 364 | CONTROL_H, |
| 365 | + BG_RAISED, | |
| 340 | 366 | None, |
| 341 | 367 | "+", |
| 342 | 368 | "magnify around the playhead; ctrl+wheel on the ruler zooms at the pointer", |
| @@ -346,6 +372,7 @@ impl Player { | ||
| 346 | 372 | .child(self.action_control( |
| 347 | 373 | "keys", |
| 348 | 374 | 0., |
| 375 | + BG_RAISED, | |
| 349 | 376 | None, |
| 350 | 377 | "Actions", |
| 351 | 378 | "do any action, or change the key that does it", |
| @@ -365,6 +392,7 @@ impl Player { | ||
| 365 | 392 | .child(control( |
| 366 | 393 | "controls-more", |
| 367 | 394 | CONTROL_H, |
| 395 | + BG_RAISED, | |
| 368 | 396 | None, |
| 369 | 397 | "⋯", |
| 370 | 398 | format!( |
| @@ -390,3 +418,5 @@ pub(crate) const EXPORT_SLOT_W: f32 = 76.; | ||
| 390 | 418 | pub(crate) const SNAP_SLOT_W: f32 = 76.; |
| 391 | 419 | pub(crate) const ZOOM_SLOT_W: f32 = 76.; |
| 392 | 420 | pub(crate) const VOLUME_SLOT_W: f32 = 76.; |
| 421 | +/// The HDR rendition's names are the longest words on any button here. | |
| 422 | +pub(crate) const TONE_SLOT_W: f32 = 148.; |
crates/app/src/ui/widgets.rsmodified+5 -1
| @@ -48,6 +48,9 @@ pub(crate) fn control( | ||
| 48 | 48 | // that relabels itself ("Export"/"Cancel") from shoving its neighbours |
| 49 | 49 | // along the row every time its state changes. |
| 50 | 50 | w: f32, |
| 51 | + // The plane the button stands on. One button in the window is the accent | |
| 52 | + // (Export, the primary action); everything else is `BG_RAISED`. | |
| 53 | + bg: u32, | |
| 51 | 54 | glyph: Option<AnyElement>, |
| 52 | 55 | // Not `&'static str`: the volume button's label is its state. |
| 53 | 56 | label: impl Into<SharedString>, |
| @@ -68,7 +71,8 @@ pub(crate) fn control( | ||
| 68 | 71 | .px(px(8.)) |
| 69 | 72 | .when(w > 0., |d| d.w(px(w)).overflow_hidden()) |
| 70 | 73 | .rounded(px(4.)) |
| 71 | - .bg(rgb(BG_RAISED)) | |
| 74 | + .bg(rgb(bg)) | |
| 75 | + .when(bg == ACCENT_PRIMARY, |d| d.text_color(rgb(BG_CANVAS))) | |
| 72 | 76 | .children(glyph) |
| 73 | 77 | .child(label) |
| 74 | 78 | .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into()) |