forge
Explore
Log in

Don't you dare go Hollow

The floor, the notices and the silent refusals

Browse files at this commit

2c8e3aa151eb0ab655f319f6cdc69a4f66f2b3ffAhmet Kaan GümüşParent: 2171351
  • feat
    • the floor, the notices and the silent refusals
Show full message
✨ feat(ui): the floor, the notices and the silent refusals

The transient bars hang off the bottom of the picture instead of taking a row
of the column -- a notice arriving used to push the transport, the toolbar and
the timeline down by its own height, which is every control below it moving
with state.

At 640x360 the timeline takes at most its share of the window and its lanes
scroll inside it, the library tabs wrap rather than hanging off the panel, and
the level's bar stands down while its button and its keys stay.

A class refusal (esc with nothing exporting) is silent; a state refusal speaks.
crates/app/src/main.rsmodified+56 -17
@@ -1620,10 +1620,19 @@ impl Player {
16201620 // same controls sat dim and *dead* to the pointer. Whatever refuses the
16211621 // button refuses the key, in the oracle's own words -- and a refusal
16221622 // 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,
16271636 }
16281637 match action {
16291638 ActionId::Play => self.toggle_or_restart(cx),
@@ -5844,25 +5853,47 @@ impl Render for Player {
58445853 )
58455854 // After the picture, so the plate is drawn
58465855 // 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+ ),
58485877 )
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+ )),
58505884 )
58515885 // The settings cards live in here rather than over the
58525886 // timeline: adjusting a clip must not hide the clip.
58535887 .child(self.inspector(window.viewport_size(), cx)),
58545888 )
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))
58645889 .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+ ))
58665897 // Over the region they were opened on, and under the modal cards:
58675898 // they are only ever up while none of those is (`modal`).
58685899 .children(self.context_card(window.viewport_size(), cx))
@@ -6902,7 +6933,10 @@ fn enable(action: ActionId, ctx: Ctx) -> Enable {
69026933 ActionId::ToggleSubtitles | ActionId::RemoveSubtitleTrack if !ctx.subtitles => {
69036934 Enable::No("no subtitles yet")
69046935 }
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"),
69066940 // A clock started against an empty timeline is a clock counting
69076941 // nothing: the transport says so by being dim, which is what its own
69086942 // ad-hoc boolean used to say before the oracle knew the question.
@@ -8293,6 +8327,11 @@ fn timeline_h(lanes: usize) -> f32 {
82938327 /// cannot push a lane off the bottom.
82948328 const TIMELINE_FIXED_H: f32 = 16. + 18. + 8. + RULER_HIT_H + 8. + 4.;
82958329
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+
82968335 /// The edit toolbar directly above the timeline: one control's height in its
82978336 /// own padding, fixed so nothing in it can push the timeline down.
82988337 const TOOLBAR_H: f32 = CONTROL_H + 16.;
crates/app/src/ui/library.rsmodified+14 -2
@@ -231,6 +231,11 @@ impl Player {
231231 .flex_1()
232232 .min_w(px(0.))
233233 .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()
234239 .gap(px(2.))
235240 .children(LIBRARY_TABS.map(|tab| {
236241 let on = tab == self.library_tab;
@@ -264,9 +269,16 @@ impl Player {
264269 .child(tab.label())
265270 })),
266271 )
267- .child(control(
272+ ,
273+ )
274+ .child(
275+ div().flex_none().child(control(
268276 "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.,
270282 BG_RAISED,
271283 None,
272284 "Import",
crates/app/src/ui/overlays.rsmodified+3 -0
@@ -53,6 +53,9 @@ impl Player {
5353 // Hugs its label: the bar's own line is what wants
5454 // the width, and this button never relabels.
5555 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,
5659 None,
5760 "Cancel",
5861 "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 {
1414 position: f64,
1515 duration: f64,
1616 state: Transport,
17+ viewport_h: f32,
1718 cx: &mut Context<Self>,
1819 ) -> impl IntoElement {
1920 // Where the playhead is *on the bed*, in pixels from its left edge.
@@ -100,7 +101,10 @@ impl Player {
100101 };
101102 div()
102103 .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)))
104108 .flex()
105109 .flex_col()
106110 .gap(px(8.))
@@ -227,7 +231,12 @@ impl Player {
227231 .child(
228232 div()
229233 .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.))
231240 .flex()
232241 .flex_col()
233242 .gap(px(8.))
crates/app/src/ui/toolbar.rsmodified+22 -7
@@ -131,9 +131,18 @@ impl Player {
131131 &self,
132132 position: f64,
133133 state: Transport,
134+ viewport_w: f32,
134135 cx: &mut Context<Self>,
135136 ) -> impl IntoElement {
136137 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;
137146 div()
138147 .flex_none()
139148 .h(px(TRANSPORT_H))
@@ -160,7 +169,7 @@ impl Player {
160169 .child(
161170 div()
162171 .flex_none()
163- .w(px(TIME_W))
172+ .w(px(clock_w))
164173 .truncate()
165174 .text_color(rgb(FG_PRIMARY))
166175 .child(format!(
@@ -201,12 +210,14 @@ impl Player {
201210 true => STATUS_WARNING,
202211 false => FG_PRIMARY,
203212 }))
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+ })
210221 }
211222
212223 /// The edit toolbar, directly above the timeline it acts on: split, delete,
@@ -420,3 +431,7 @@ pub(crate) const ZOOM_SLOT_W: f32 = 76.;
420431 pub(crate) const VOLUME_SLOT_W: f32 = 76.;
421432 /// The HDR rendition's names are the longest words on any button here.
422433 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.;