The floor, the notices and the silent refusals
Browse files at this commit2c8e3aa151eb0ab655f319f6cdc69a4f66f2b3ffParent: 2171351- feat
- the floor, the notices and the silent refusals
5 changed files +106 -28
- crates/app/src/main.rs +56 -17
- crates/app/src/ui/library.rs +14 -2
- crates/app/src/ui/overlays.rs +3 -0
- crates/app/src/ui/timeline.rs +11 -2
- crates/app/src/ui/toolbar.rs +22 -7
crates/app/src/main.rsmodified+56 -17
| @@ -1620,10 +1620,19 @@ impl Player { | ||
| 1620 | 1620 | // same controls sat dim and *dead* to the pointer. Whatever refuses the |
| 1621 | 1621 | // button refuses the key, in the oracle's own words -- and a refusal |
| 1622 | 1622 | // that is silent from the keyboard is a bug the same size. |
| 1623 | - if let Some(why) = self.enable(action, None).why() { | |
| 1624 | - self.notice = Some(format!("{} — {why}", action.label()).into()); | |
| 1625 | - cx.notify(); | |
| 1626 | - return; | |
| 1623 | + match self.enable(action, None) { | |
| 1624 | + Enable::Yes => {} | |
| 1625 | + // A state refusal is spoken: the thing exists and cannot happen | |
| 1626 | + // *now*, which is exactly what a silent key press fails to say. | |
| 1627 | + Enable::No(why) => { | |
| 1628 | + self.notice = Some(format!("{} — {why}", action.label()).into()); | |
| 1629 | + cx.notify(); | |
| 1630 | + return; | |
| 1631 | + } | |
| 1632 | + // A class refusal is not: the action does not exist for what is in | |
| 1633 | + // front of the user, and `esc` with nothing exporting must not | |
| 1634 | + // answer with a line about exports. | |
| 1635 | + Enable::Hidden(_) => return, | |
| 1627 | 1636 | } |
| 1628 | 1637 | match action { |
| 1629 | 1638 | ActionId::Play => self.toggle_or_restart(cx), |
| @@ -5844,25 +5853,47 @@ impl Render for Player { | ||
| 5844 | 5853 | ) |
| 5845 | 5854 | // After the picture, so the plate is drawn |
| 5846 | 5855 | // over it rather than under. |
| 5847 | - .children(self.subtitle_overlay(position, window)), | |
| 5856 | + .children(self.subtitle_overlay(position, window)) | |
| 5857 | + // The three transient lines hang off the | |
| 5858 | + // bottom of the picture rather than taking | |
| 5859 | + // a row of the column: a notice that | |
| 5860 | + // arrives must not push the transport, the | |
| 5861 | + // toolbar and the timeline down by its own | |
| 5862 | + // height -- which is a control moving with | |
| 5863 | + // state, on every control below it at once. | |
| 5864 | + .child( | |
| 5865 | + div() | |
| 5866 | + .absolute() | |
| 5867 | + .bottom_0() | |
| 5868 | + .left_0() | |
| 5869 | + .right_0() | |
| 5870 | + .flex() | |
| 5871 | + .flex_col() | |
| 5872 | + .gap(px(2.)) | |
| 5873 | + .children(self.import_bar(cx)) | |
| 5874 | + .children(self.seek_bar()) | |
| 5875 | + .children(self.notice_bar(cx)), | |
| 5876 | + ), | |
| 5848 | 5877 | ) |
| 5849 | - .child(self.transport_bar(position, state, cx)), | |
| 5878 | + .child(self.transport_bar( | |
| 5879 | + position, | |
| 5880 | + state, | |
| 5881 | + f32::from(window.viewport_size().width), | |
| 5882 | + cx, | |
| 5883 | + )), | |
| 5850 | 5884 | ) |
| 5851 | 5885 | // The settings cards live in here rather than over the |
| 5852 | 5886 | // timeline: adjusting a clip must not hide the clip. |
| 5853 | 5887 | .child(self.inspector(window.viewport_size(), cx)), |
| 5854 | 5888 | ) |
| 5855 | - // Above the toolbar and only when there is one to show, so it costs | |
| 5856 | - // the picture nothing the rest of the time. The import's line sits | |
| 5857 | - // over the notice's: a notice is about something that has already | |
| 5858 | - // happened, and this is about something still happening. | |
| 5859 | - .children(self.import_bar(cx)) | |
| 5860 | - // The same slot and the same reason: work still going on, said out | |
| 5861 | - // loud because a still picture is the only other evidence of it. | |
| 5862 | - .children(self.seek_bar()) | |
| 5863 | - .children(self.notice_bar(cx)) | |
| 5864 | 5889 | .child(self.toolbar(cx)) |
| 5865 | - .child(self.timeline(position, duration, state, cx)) | |
| 5890 | + .child(self.timeline( | |
| 5891 | + position, | |
| 5892 | + duration, | |
| 5893 | + state, | |
| 5894 | + f32::from(window.viewport_size().height), | |
| 5895 | + cx, | |
| 5896 | + )) | |
| 5866 | 5897 | // Over the region they were opened on, and under the modal cards: |
| 5867 | 5898 | // they are only ever up while none of those is (`modal`). |
| 5868 | 5899 | .children(self.context_card(window.viewport_size(), cx)) |
| @@ -6902,7 +6933,10 @@ fn enable(action: ActionId, ctx: Ctx) -> Enable { | ||
| 6902 | 6933 | ActionId::ToggleSubtitles | ActionId::RemoveSubtitleTrack if !ctx.subtitles => { |
| 6903 | 6934 | Enable::No("no subtitles yet") |
| 6904 | 6935 | } |
| 6905 | - ActionId::CancelExport => Enable::No("nothing is exporting"), | |
| 6936 | + // Not `No`: with nothing running there is no export for this to be | |
| 6937 | + // about at all, which is what keeps `esc` -- the same key -- a quiet | |
| 6938 | + // way out of a card rather than a line about exports. | |
| 6939 | + ActionId::CancelExport => Enable::Hidden("nothing is exporting"), | |
| 6906 | 6940 | // A clock started against an empty timeline is a clock counting |
| 6907 | 6941 | // nothing: the transport says so by being dim, which is what its own |
| 6908 | 6942 | // ad-hoc boolean used to say before the oracle knew the question. |
| @@ -8293,6 +8327,11 @@ fn timeline_h(lanes: usize) -> f32 { | ||
| 8293 | 8327 | /// cannot push a lane off the bottom. |
| 8294 | 8328 | const TIMELINE_FIXED_H: f32 = 16. + 18. + 8. + RULER_HIT_H + 8. + 4.; |
| 8295 | 8329 | |
| 8330 | +/// The most of a short window the timeline may take. At the 640x360 floor that | |
| 8331 | +/// is 151 px of the 360, which leaves the picture a region rather than a | |
| 8332 | +/// letterbox stripe -- and the lanes scroll inside it. | |
| 8333 | +const TIMELINE_SHARE: f32 = 0.42; | |
| 8334 | + | |
| 8296 | 8335 | /// The edit toolbar directly above the timeline: one control's height in its |
| 8297 | 8336 | /// own padding, fixed so nothing in it can push the timeline down. |
| 8298 | 8337 | const TOOLBAR_H: f32 = CONTROL_H + 16.; |
crates/app/src/ui/library.rsmodified+14 -2
| @@ -231,6 +231,11 @@ impl Player { | ||
| 231 | 231 | .flex_1() |
| 232 | 232 | .min_w(px(0.)) |
| 233 | 233 | .flex() |
| 234 | + // Wraps rather than clipping: at the 640 px floor | |
| 235 | + // this column is 128 px wide and the third tab | |
| 236 | + // would hang off its edge, which is a control the | |
| 237 | + // pointer cannot reach. | |
| 238 | + .flex_wrap() | |
| 234 | 239 | .gap(px(2.)) |
| 235 | 240 | .children(LIBRARY_TABS.map(|tab| { |
| 236 | 241 | let on = tab == self.library_tab; |
| @@ -264,9 +269,16 @@ impl Player { | ||
| 264 | 269 | .child(tab.label()) |
| 265 | 270 | })), |
| 266 | 271 | ) |
| 267 | - .child(control( | |
| 272 | + , | |
| 273 | + ) | |
| 274 | + .child( | |
| 275 | + div().flex_none().child(control( | |
| 268 | 276 | "import", |
| 269 | - 0., | |
| 277 | + // Full width of the column: the way media gets in is | |
| 278 | + // the one affordance in this panel that is always | |
| 279 | + // there, whatever tab is open and however narrow the | |
| 280 | + // window is. | |
| 281 | + width - 16., | |
| 270 | 282 | BG_RAISED, |
| 271 | 283 | None, |
| 272 | 284 | "Import", |
crates/app/src/ui/overlays.rsmodified+3 -0
| @@ -53,6 +53,9 @@ impl Player { | ||
| 53 | 53 | // Hugs its label: the bar's own line is what wants |
| 54 | 54 | // the width, and this button never relabels. |
| 55 | 55 | 0., |
| 56 | + // The ordinary plane -- the accent is Export's, and | |
| 57 | + // a way out of a read is not the primary action. | |
| 58 | + BG_RAISED, | |
| 56 | 59 | None, |
| 57 | 60 | "Cancel", |
| 58 | 61 | "stops this file and anything queued behind it; the read already \ |
crates/app/src/ui/timeline.rsmodified+11 -2
| @@ -14,6 +14,7 @@ impl Player { | ||
| 14 | 14 | position: f64, |
| 15 | 15 | duration: f64, |
| 16 | 16 | state: Transport, |
| 17 | + viewport_h: f32, | |
| 17 | 18 | cx: &mut Context<Self>, |
| 18 | 19 | ) -> impl IntoElement { |
| 19 | 20 | // Where the playhead is *on the bed*, in pixels from its left edge. |
| @@ -100,7 +101,10 @@ impl Player { | ||
| 100 | 101 | }; |
| 101 | 102 | div() |
| 102 | 103 | .flex_none() |
| 103 | - .h(px(timeline_h(lanes.len()) + strip_h)) | |
| 104 | + // Never more than its share of a short window: the lane column | |
| 105 | + // scrolls inside whatever it gets, and a timeline that pushes the | |
| 106 | + // picture off the screen at the 640x360 floor is not a timeline. | |
| 107 | + .h(px((timeline_h(lanes.len()) + strip_h).min(viewport_h * TIMELINE_SHARE))) | |
| 104 | 108 | .flex() |
| 105 | 109 | .flex_col() |
| 106 | 110 | .gap(px(8.)) |
| @@ -227,7 +231,12 @@ impl Player { | ||
| 227 | 231 | .child( |
| 228 | 232 | div() |
| 229 | 233 | .id("lanes") |
| 230 | - .flex_none() | |
| 234 | + // Takes whatever the region has left and scrolls inside it: | |
| 235 | + // at the 640x360 floor the region is capped | |
| 236 | + // ([`TIMELINE_SHARE`]) and a fixed column would be clipped | |
| 237 | + // by it rather than scrolled. | |
| 238 | + .flex_1() | |
| 239 | + .min_h(px(0.)) | |
| 231 | 240 | .flex() |
| 232 | 241 | .flex_col() |
| 233 | 242 | .gap(px(8.)) |
crates/app/src/ui/toolbar.rsmodified+22 -7
| @@ -131,9 +131,18 @@ impl Player { | ||
| 131 | 131 | &self, |
| 132 | 132 | position: f64, |
| 133 | 133 | state: Transport, |
| 134 | + viewport_w: f32, | |
| 134 | 135 | cx: &mut Context<Self>, |
| 135 | 136 | ) -> impl IntoElement { |
| 136 | 137 | let muted = self.volume.muted; |
| 138 | + // The room this strip actually has: the window less the two side | |
| 139 | + // panels. At the 640 px floor that is ~300 px, which the clock and the | |
| 140 | + // level together do not fit -- so the level's *bar* stands down (its | |
| 141 | + // button, its keys and its row on the actions card all remain), and | |
| 142 | + // the clock keeps a narrower rect rather than being pushed off. | |
| 143 | + let room = viewport_w - library_w(viewport_w) - inspector_w(viewport_w); | |
| 144 | + let clock_w = TIME_W.min(room - 140.).max(96.); | |
| 145 | + let slider = room >= TRANSPORT_ROOMY; | |
| 137 | 146 | div() |
| 138 | 147 | .flex_none() |
| 139 | 148 | .h(px(TRANSPORT_H)) |
| @@ -160,7 +169,7 @@ impl Player { | ||
| 160 | 169 | .child( |
| 161 | 170 | div() |
| 162 | 171 | .flex_none() |
| 163 | - .w(px(TIME_W)) | |
| 172 | + .w(px(clock_w)) | |
| 164 | 173 | .truncate() |
| 165 | 174 | .text_color(rgb(FG_PRIMARY)) |
| 166 | 175 | .child(format!( |
| @@ -201,12 +210,14 @@ impl Player { | ||
| 201 | 210 | true => STATUS_WARNING, |
| 202 | 211 | false => FG_PRIMARY, |
| 203 | 212 | })) |
| 204 | - .child(volume_slider( | |
| 205 | - self.volume, | |
| 206 | - self.volume_bar.clone(), | |
| 207 | - self.enable(ActionId::ToggleMute, None).yes(), | |
| 208 | - cx, | |
| 209 | - )) | |
| 213 | + .when(slider, |d| { | |
| 214 | + d.child(volume_slider( | |
| 215 | + self.volume, | |
| 216 | + self.volume_bar.clone(), | |
| 217 | + self.enable(ActionId::ToggleMute, None).yes(), | |
| 218 | + cx, | |
| 219 | + )) | |
| 220 | + }) | |
| 210 | 221 | } |
| 211 | 222 | |
| 212 | 223 | /// The edit toolbar, directly above the timeline it acts on: split, delete, |
| @@ -420,3 +431,7 @@ pub(crate) const ZOOM_SLOT_W: f32 = 76.; | ||
| 420 | 431 | pub(crate) const VOLUME_SLOT_W: f32 = 76.; |
| 421 | 432 | /// The HDR rendition's names are the longest words on any button here. |
| 422 | 433 | pub(crate) const TONE_SLOT_W: f32 = 148.; |
| 434 | + | |
| 435 | +/// The width the transport strip needs before the level's bar fits beside the | |
| 436 | +/// clock: play + clock + the mute button + the bar, in their gaps. | |
| 437 | +pub(crate) const TRANSPORT_ROOMY: f32 = 460.; |