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 | /// What is known about a source's audio. Three states and not two, because a | 351 | /// What is known about a source's audio. Three states and not two, because a |
| 310 | /// file whose peaks have not come back yet must not be drawn as one that has no | 352 | /// file whose peaks have not come back yet must not be drawn as one that has no |
| 311 | /// audio at all: the first shows a bed, the second shows nothing. | 353 | /// audio at all: the first shows a bed, the second shows nothing. |
| @@ -1121,6 +1163,10 @@ struct Player { | |||
| 1121 | /// rebuilt. Its own selection and not the timeline's: Delete keeps acting | 1163 | /// rebuilt. Its own selection and not the timeline's: Delete keeps acting |
| 1122 | /// on the clip that was clicked in a lane, whatever the library is showing. | 1164 | /// on the clip that was clicked in a lane, whatever the library is showing. |
| 1123 | selected_asset: Option<(PathBuf, usize)>, | 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 | /// What is known about each source's audio, taken once and kept. Keyed on | 1170 | /// What is known about each source's audio, taken once and kept. Keyed on |
| 1125 | /// the path *and stream* -- two streams of one file are two envelopes -- and | 1171 | /// the path *and stream* -- two streams of one file are two envelopes -- and |
| 1126 | /// the key is inserted the moment the decode is *started*: presence means | 1172 | /// the key is inserted the moment the decode is *started*: presence means |
| @@ -8233,13 +8279,20 @@ fn panel_h(lanes: usize) -> f32 { | |||
| 8233 | PANEL_H + lanes_h(lanes.clamp(2, LANES_MAX)) - lanes_h(2) | 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 | 8282 | +/// How tall the timeline region is: its own padding, the timecode line, the |
| 8237 | -/// row that used to sit inside it, which is now its own region above | 8283 | +/// ruler and the gaps between them, plus a row per lane. Measured from its |
| 8238 | -/// ([`Player::toolbar`], [`TOOLBAR_H`]). | 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 | fn timeline_h(lanes: usize) -> f32 { | 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 | /// The edit toolbar directly above the timeline: one control's height in its | 8296 | /// The edit toolbar directly above the timeline: one control's height in its |
| 8244 | /// own padding, fixed so nothing in it can push the timeline down. | 8297 | /// own padding, fixed so nothing in it can push the timeline down. |
| 8245 | const TOOLBAR_H: f32 = CONTROL_H + 16.; | 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 | #[test] | 14309 | #[test] |
| 14178 | fn nothing_clickable_is_smaller_than_the_wcag_minimum() { | 14310 | fn nothing_clickable_is_smaller_than_the_wcag_minimum() { |
| 14179 | // Every hit target in the panel, including the scrub strip -- whose bar | 14311 | // Every hit target in the panel, including the scrub strip -- whose bar |
| @@ -15128,6 +15260,7 @@ fn main() { | |||
| 15128 | picker: None, | 15260 | picker: None, |
| 15129 | library_menu: None, | 15261 | library_menu: None, |
| 15130 | selected_asset: None, | 15262 | selected_asset: None, |
| 15263 | + library_tab: LibraryTab::Media, | ||
| 15131 | waves: HashMap::new(), | 15264 | waves: HashMap::new(), |
| 15132 | streams: HashMap::new(), | 15265 | streams: HashMap::new(), |
| 15133 | bitrates: HashMap::new(), | 15266 | bitrates: HashMap::new(), |
crates/app/src/ui/inspector.rsmodified+12 -1
| @@ -8,6 +8,7 @@ | |||
| 8 | //! (`an_inspector_section_occludes_no_timeline`). | 8 | //! (`an_inspector_section_occludes_no_timeline`). |
| 9 | 9 | ||
| 10 | use crate::*; | 10 | use crate::*; |
| 11 | +use crate::ui::toolbar::{TONE_SLOT_W, ZOOM_SLOT_W}; | ||
| 11 | use crate::ui::widgets::*; | 12 | use crate::ui::widgets::*; |
| 12 | 13 | ||
| 13 | impl Player { | 14 | impl Player { |
| @@ -124,6 +125,7 @@ impl Player { | |||
| 124 | .child(self.action_control( | 125 | .child(self.action_control( |
| 125 | "inspect-speed", | 126 | "inspect-speed", |
| 126 | 0., | 127 | 0., |
| 128 | + BG_RAISED, | ||
| 127 | None, | 129 | None, |
| 128 | "Speed", | 130 | "Speed", |
| 129 | "how fast this clip and its group play", | 131 | "how fast this clip and its group play", |
| @@ -133,6 +135,7 @@ impl Player { | |||
| 133 | .child(self.action_control( | 135 | .child(self.action_control( |
| 134 | "inspect-color", | 136 | "inspect-color", |
| 135 | 0., | 137 | 0., |
| 138 | + BG_RAISED, | ||
| 136 | None, | 139 | None, |
| 137 | "Colour", | 140 | "Colour", |
| 138 | "exposure, contrast, saturation and temperature", | 141 | "exposure, contrast, saturation and temperature", |
| @@ -142,6 +145,7 @@ impl Player { | |||
| 142 | .child(self.action_control( | 145 | .child(self.action_control( |
| 143 | "inspect-eq", | 146 | "inspect-eq", |
| 144 | 0., | 147 | 0., |
| 148 | + BG_RAISED, | ||
| 145 | None, | 149 | None, |
| 146 | "Equalizer", | 150 | "Equalizer", |
| 147 | "the bands this clip's sound is filtered through", | 151 | "the bands this clip's sound is filtered through", |
| @@ -151,6 +155,7 @@ impl Player { | |||
| 151 | .child(self.action_control( | 155 | .child(self.action_control( |
| 152 | "inspect-silence", | 156 | "inspect-silence", |
| 153 | 0., | 157 | 0., |
| 158 | + BG_RAISED, | ||
| 154 | None, | 159 | None, |
| 155 | "Silence", | 160 | "Silence", |
| 156 | "finds the quiet stretches and cuts or speeds them", | 161 | "finds the quiet stretches and cuts or speeds them", |
| @@ -160,6 +165,7 @@ impl Player { | |||
| 160 | .child(self.action_control( | 165 | .child(self.action_control( |
| 161 | "inspect-fit", | 166 | "inspect-fit", |
| 162 | 0., | 167 | 0., |
| 168 | + BG_RAISED, | ||
| 163 | None, | 169 | None, |
| 164 | "Fit", | 170 | "Fit", |
| 165 | "how this picture is placed on the project canvas", | 171 | "how this picture is placed on the project canvas", |
| @@ -169,6 +175,7 @@ impl Player { | |||
| 169 | .child(self.action_control( | 175 | .child(self.action_control( |
| 170 | "inspect-delete", | 176 | "inspect-delete", |
| 171 | 0., | 177 | 0., |
| 178 | + BG_RAISED, | ||
| 172 | None, | 179 | None, |
| 173 | "Delete", | 180 | "Delete", |
| 174 | "takes this clip off the timeline", | 181 | "takes this clip off the timeline", |
| @@ -206,6 +213,7 @@ impl Player { | |||
| 206 | .child(self.action_control( | 213 | .child(self.action_control( |
| 207 | "resolution", | 214 | "resolution", |
| 208 | ZOOM_SLOT_W, | 215 | ZOOM_SLOT_W, |
| 216 | + BG_RAISED, | ||
| 209 | None, | 217 | None, |
| 210 | resolution.map_or_else(|| "Size".to_string(), |(_, h)| format!("{h}p")), | 218 | resolution.map_or_else(|| "Size".to_string(), |(_, h)| format!("{h}p")), |
| 211 | "the canvas every clip is composed onto, and the size the export comes out at", | 219 | "the canvas every clip is composed onto, and the size the export comes out at", |
| @@ -217,6 +225,7 @@ impl Player { | |||
| 217 | .child(self.action_control( | 225 | .child(self.action_control( |
| 218 | "fps", | 226 | "fps", |
| 219 | ZOOM_SLOT_W, | 227 | ZOOM_SLOT_W, |
| 228 | + BG_RAISED, | ||
| 220 | None, | 229 | None, |
| 221 | match self.session.is_some() { | 230 | match self.session.is_some() { |
| 222 | true => format!("{} fps", fps_label(self.fps)), | 231 | true => format!("{} fps", fps_label(self.fps)), |
| @@ -230,7 +239,8 @@ impl Player { | |||
| 230 | )) | 239 | )) |
| 231 | .child(self.action_control( | 240 | .child(self.action_control( |
| 232 | "tonemap", | 241 | "tonemap", |
| 233 | - ZOOM_SLOT_W, | 242 | + TONE_SLOT_W, |
| 243 | + BG_RAISED, | ||
| 234 | None, | 244 | None, |
| 235 | match &self.session { | 245 | match &self.session { |
| 236 | Some(session) => format!("HDR {}", tone_label(session.tone())), | 246 | Some(session) => format!("HDR {}", tone_label(session.tone())), |
| @@ -245,6 +255,7 @@ impl Player { | |||
| 245 | .child(self.action_control( | 255 | .child(self.action_control( |
| 246 | "inspect-mix", | 256 | "inspect-mix", |
| 247 | 0., | 257 | 0., |
| 258 | + BG_RAISED, | ||
| 248 | None, | 259 | None, |
| 249 | "Mix", | 260 | "Mix", |
| 250 | "a fader per track and the limiter over the sum of them", | 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 | .into_iter() | 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 | .enumerate() | 47 | .enumerate() |
| 48 | + .filter(|(_, row)| self.library_tab.holds(&row.path)) | ||
| 44 | .map(|(i, row)| { | 49 | .map(|(i, row)| { |
| 45 | let picked = self | 50 | let picked = self |
| 46 | .selected_asset | 51 | .selected_asset |
| @@ -225,14 +230,44 @@ impl Player { | |||
| 225 | div() | 230 | div() |
| 226 | .flex_1() | 231 | .flex_1() |
| 227 | .min_w(px(0.)) | 232 | .min_w(px(0.)) |
| 228 | - .truncate() | 233 | + .flex() |
| 229 | - .text_size(px(11.)) | 234 | + .gap(px(2.)) |
| 230 | - .text_color(rgb(FG_SECONDARY)) | 235 | + .children(LIBRARY_TABS.map(|tab| { |
| 231 | - .child("Media"), | 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 | .child(control( | 267 | .child(control( |
| 234 | "import", | 268 | "import", |
| 235 | 0., | 269 | 0., |
| 270 | + BG_RAISED, | ||
| 236 | None, | 271 | None, |
| 237 | "Import", | 272 | "Import", |
| 238 | "adds a file to this list — or drop one on the window".to_string(), | 273 | "adds a file to this list — or drop one on the window".to_string(), |
| @@ -256,7 +291,7 @@ impl Player { | |||
| 256 | div() | 291 | div() |
| 257 | .text_size(px(11.)) | 292 | .text_size(px(11.)) |
| 258 | .text_color(rgb(FG_SECONDARY)) | 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 | .children(rows), | 297 | .children(rows), |
| @@ -264,10 +299,13 @@ impl Player { | |||
| 264 | // Under the media it belongs to: a subtitle track is not a source -- | 299 | // Under the media it belongs to: a subtitle track is not a source -- |
| 265 | // it goes on no lane and is dragged nowhere -- but it is a thing the | 300 | // it goes on no lane and is dragged nowhere -- but it is a thing the |
| 266 | // timeline holds, and this is the list of those. | 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 | .child(control( | 305 | .child(control( |
| 269 | "add-asset", | 306 | "add-asset", |
| 270 | 0., | 307 | 0., |
| 308 | + BG_RAISED, | ||
| 271 | None, | 309 | None, |
| 272 | "Add at playhead", | 310 | "Add at playhead", |
| 273 | match self.selected_asset { | 311 | match self.selected_asset { |
crates/app/src/ui/toolbar.rsmodified+35 -5
| @@ -26,6 +26,7 @@ impl Player { | |||
| 26 | &self, | 26 | &self, |
| 27 | id: &'static str, | 27 | id: &'static str, |
| 28 | w: f32, | 28 | w: f32, |
| 29 | + bg: u32, | ||
| 29 | glyph: Option<AnyElement>, | 30 | glyph: Option<AnyElement>, |
| 30 | label: impl Into<SharedString>, | 31 | label: impl Into<SharedString>, |
| 31 | hint: &str, | 32 | hint: &str, |
| @@ -41,7 +42,7 @@ impl Player { | |||
| 41 | Some(why) => format!("{key} — {why}"), | 42 | Some(why) => format!("{key} — {why}"), |
| 42 | None => format!("{key} — {hint}"), | 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 | /// The bar over everything: what is open on the left, the two actions that | 48 | /// The bar over everything: what is open on the left, the two actions that |
| @@ -78,6 +79,7 @@ impl Player { | |||
| 78 | .child(self.action_control( | 79 | .child(self.action_control( |
| 79 | "save", | 80 | "save", |
| 80 | 0., | 81 | 0., |
| 82 | + BG_RAISED, | ||
| 81 | None, | 83 | None, |
| 82 | "Save", | 84 | "Save", |
| 83 | "writes the project file", | 85 | "writes the project file", |
| @@ -93,6 +95,10 @@ impl Player { | |||
| 93 | .child(self.action_control( | 95 | .child(self.action_control( |
| 94 | "export", | 96 | "export", |
| 95 | EXPORT_SLOT_W, | 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 | None, | 102 | None, |
| 97 | if exporting { "Cancel" } else { "Export" }, | 103 | if exporting { "Cancel" } else { "Export" }, |
| 98 | if exporting { | 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))) | 123 | + , |
| 118 | - .when(exporting, |d| d.text_color(rgb(FG_PRIMARY))), | ||
| 119 | ) | 124 | ) |
| 120 | } | 125 | } |
| 121 | 126 | ||
| @@ -142,6 +147,7 @@ impl Player { | |||
| 142 | .child(self.action_control( | 147 | .child(self.action_control( |
| 143 | "transport", | 148 | "transport", |
| 144 | 40., | 149 | 40., |
| 150 | + BG_RAISED, | ||
| 145 | Some(transport_glyph(state).into_any_element()), | 151 | Some(transport_glyph(state).into_any_element()), |
| 146 | "", | 152 | "", |
| 147 | "plays and pauses the timeline", | 153 | "plays and pauses the timeline", |
| @@ -175,10 +181,15 @@ impl Player { | |||
| 175 | .child(self.action_control( | 181 | .child(self.action_control( |
| 176 | "volume", | 182 | "volume", |
| 177 | VOLUME_SLOT_W, | 183 | VOLUME_SLOT_W, |
| 184 | + BG_RAISED, | ||
| 178 | None, | 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 | match muted { | 190 | match muted { |
| 180 | - true => format!("🔇 {}%", self.volume.percent()), | 191 | + true => format!("× {}%", self.volume.percent()), |
| 181 | - false => format!("🔊 {}%", self.volume.percent()), | 192 | + false => format!("{}%", self.volume.percent()), |
| 182 | }, | 193 | }, |
| 183 | "mutes and unmutes; the level is what it comes back to", | 194 | "mutes and unmutes; the level is what it comes back to", |
| 184 | ActionId::ToggleMute, | 195 | ActionId::ToggleMute, |
| @@ -186,6 +197,10 @@ impl Player { | |||
| 186 | this.set_volume(|volume| volume.muted = !volume.muted, cx) | 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 | .child(volume_slider( | 204 | .child(volume_slider( |
| 190 | self.volume, | 205 | self.volume, |
| 191 | self.volume_bar.clone(), | 206 | self.volume_bar.clone(), |
| @@ -226,6 +241,7 @@ impl Player { | |||
| 226 | .child(self.action_control( | 241 | .child(self.action_control( |
| 227 | "cut", | 242 | "cut", |
| 228 | 0., | 243 | 0., |
| 244 | + BG_RAISED, | ||
| 229 | Some(cut_glyph().into_any_element()), | 245 | Some(cut_glyph().into_any_element()), |
| 230 | "Split", | 246 | "Split", |
| 231 | "splits the clip under the playhead", | 247 | "splits the clip under the playhead", |
| @@ -235,6 +251,7 @@ impl Player { | |||
| 235 | .child(self.action_control( | 251 | .child(self.action_control( |
| 236 | "delete", | 252 | "delete", |
| 237 | 0., | 253 | 0., |
| 254 | + BG_RAISED, | ||
| 238 | Some(delete_glyph().into_any_element()), | 255 | Some(delete_glyph().into_any_element()), |
| 239 | "Delete", | 256 | "Delete", |
| 240 | "takes the marked clip off the timeline", | 257 | "takes the marked clip off the timeline", |
| @@ -244,6 +261,7 @@ impl Player { | |||
| 244 | .child(self.action_control( | 261 | .child(self.action_control( |
| 245 | "undo", | 262 | "undo", |
| 246 | 0., | 263 | 0., |
| 264 | + BG_RAISED, | ||
| 247 | None, | 265 | None, |
| 248 | "Undo", | 266 | "Undo", |
| 249 | "takes the last edit back", | 267 | "takes the last edit back", |
| @@ -254,6 +272,7 @@ impl Player { | |||
| 254 | .child(self.action_control( | 272 | .child(self.action_control( |
| 255 | "add-video-lane", | 273 | "add-video-lane", |
| 256 | 0., | 274 | 0., |
| 275 | + BG_RAISED, | ||
| 257 | None, | 276 | None, |
| 258 | "+ V", | 277 | "+ V", |
| 259 | "adds a video track under the ones there", | 278 | "adds a video track under the ones there", |
| @@ -265,6 +284,7 @@ impl Player { | |||
| 265 | .child(self.action_control( | 284 | .child(self.action_control( |
| 266 | "add-audio-lane", | 285 | "add-audio-lane", |
| 267 | 0., | 286 | 0., |
| 287 | + BG_RAISED, | ||
| 268 | None, | 288 | None, |
| 269 | "+ A", | 289 | "+ A", |
| 270 | "adds an audio track under the ones there", | 290 | "adds an audio track under the ones there", |
| @@ -276,6 +296,7 @@ impl Player { | |||
| 276 | .child(self.action_control( | 296 | .child(self.action_control( |
| 277 | "add-subtitle-track", | 297 | "add-subtitle-track", |
| 278 | 0., | 298 | 0., |
| 299 | + BG_RAISED, | ||
| 279 | None, | 300 | None, |
| 280 | "+ S", | 301 | "+ S", |
| 281 | "adds every subtitle track in a file you pick", | 302 | "adds every subtitle track in a file you pick", |
| @@ -291,6 +312,7 @@ impl Player { | |||
| 291 | .child(self.action_control( | 312 | .child(self.action_control( |
| 292 | "snap", | 313 | "snap", |
| 293 | SNAP_SLOT_W, | 314 | SNAP_SLOT_W, |
| 315 | + BG_RAISED, | ||
| 294 | None, | 316 | None, |
| 295 | if self.snap { "Snap on" } else { "Snap off" }, | 317 | if self.snap { "Snap on" } else { "Snap off" }, |
| 296 | match self.snap { | 318 | match self.snap { |
| @@ -303,6 +325,7 @@ impl Player { | |||
| 303 | .child(self.action_control( | 325 | .child(self.action_control( |
| 304 | "subs", | 326 | "subs", |
| 305 | SNAP_SLOT_W, | 327 | SNAP_SLOT_W, |
| 328 | + BG_RAISED, | ||
| 306 | None, | 329 | None, |
| 307 | match (self.subtitle_track().is_some(), self.subs_on) { | 330 | match (self.subtitle_track().is_some(), self.subs_on) { |
| 308 | (false, _) => "No subs", | 331 | (false, _) => "No subs", |
| @@ -317,6 +340,7 @@ impl Player { | |||
| 317 | .child(self.action_control( | 340 | .child(self.action_control( |
| 318 | "zoom-out", | 341 | "zoom-out", |
| 319 | CONTROL_H, | 342 | CONTROL_H, |
| 343 | + BG_RAISED, | ||
| 320 | None, | 344 | None, |
| 321 | "−", | 345 | "−", |
| 322 | "show more of the timeline; stops with all of it on the bed", | 346 | "show more of the timeline; stops with all of it on the bed", |
| @@ -328,6 +352,7 @@ impl Player { | |||
| 328 | .child(self.action_control( | 352 | .child(self.action_control( |
| 329 | "zoom-fit", | 353 | "zoom-fit", |
| 330 | ZOOM_SLOT_W, | 354 | ZOOM_SLOT_W, |
| 355 | + BG_RAISED, | ||
| 331 | None, | 356 | None, |
| 332 | span_label(self.view().span()), | 357 | span_label(self.view().span()), |
| 333 | "fit the whole timeline on the bed", | 358 | "fit the whole timeline on the bed", |
| @@ -337,6 +362,7 @@ impl Player { | |||
| 337 | .child(self.action_control( | 362 | .child(self.action_control( |
| 338 | "zoom-in", | 363 | "zoom-in", |
| 339 | CONTROL_H, | 364 | CONTROL_H, |
| 365 | + BG_RAISED, | ||
| 340 | None, | 366 | None, |
| 341 | "+", | 367 | "+", |
| 342 | "magnify around the playhead; ctrl+wheel on the ruler zooms at the pointer", | 368 | "magnify around the playhead; ctrl+wheel on the ruler zooms at the pointer", |
| @@ -346,6 +372,7 @@ impl Player { | |||
| 346 | .child(self.action_control( | 372 | .child(self.action_control( |
| 347 | "keys", | 373 | "keys", |
| 348 | 0., | 374 | 0., |
| 375 | + BG_RAISED, | ||
| 349 | None, | 376 | None, |
| 350 | "Actions", | 377 | "Actions", |
| 351 | "do any action, or change the key that does it", | 378 | "do any action, or change the key that does it", |
| @@ -365,6 +392,7 @@ impl Player { | |||
| 365 | .child(control( | 392 | .child(control( |
| 366 | "controls-more", | 393 | "controls-more", |
| 367 | CONTROL_H, | 394 | CONTROL_H, |
| 395 | + BG_RAISED, | ||
| 368 | None, | 396 | None, |
| 369 | "⋯", | 397 | "⋯", |
| 370 | format!( | 398 | format!( |
| @@ -390,3 +418,5 @@ pub(crate) const EXPORT_SLOT_W: f32 = 76.; | |||
| 390 | pub(crate) const SNAP_SLOT_W: f32 = 76.; | 418 | pub(crate) const SNAP_SLOT_W: f32 = 76.; |
| 391 | pub(crate) const ZOOM_SLOT_W: f32 = 76.; | 419 | pub(crate) const ZOOM_SLOT_W: f32 = 76.; |
| 392 | pub(crate) const VOLUME_SLOT_W: f32 = 76.; | 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 | // that relabels itself ("Export"/"Cancel") from shoving its neighbours | 48 | // that relabels itself ("Export"/"Cancel") from shoving its neighbours |
| 49 | // along the row every time its state changes. | 49 | // along the row every time its state changes. |
| 50 | w: f32, | 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 | glyph: Option<AnyElement>, | 54 | glyph: Option<AnyElement>, |
| 52 | // Not `&'static str`: the volume button's label is its state. | 55 | // Not `&'static str`: the volume button's label is its state. |
| 53 | label: impl Into<SharedString>, | 56 | label: impl Into<SharedString>, |
| @@ -68,7 +71,8 @@ pub(crate) fn control( | |||
| 68 | .px(px(8.)) | 71 | .px(px(8.)) |
| 69 | .when(w > 0., |d| d.w(px(w)).overflow_hidden()) | 72 | .when(w > 0., |d| d.w(px(w)).overflow_hidden()) |
| 70 | .rounded(px(4.)) | 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 | .children(glyph) | 76 | .children(glyph) |
| 73 | .child(label) | 77 | .child(label) |
| 74 | .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into()) | 78 | .tooltip(move |_, cx| cx.new(|_| Tip(tip.clone())).into()) |