Settings project rows stop pretending an empty picker is a value
Browse files at this commitba3306f901dc67e7e77968b0dd9085e70ebe086aParent: f4ba613- fix
- settings project rows stop pretending an empty picker is a value
2 changed files +58 -14
crates/app/src/tests/layout.rsmodified+19 -0
| @@ -1967,3 +1967,22 @@ fn settings_project_and_editor_sections_open_disjoint_doors() { | |||
| 1967 | assert!(!editor_body.contains(path_fn), "EDITOR section touches {path_fn} directly"); | 1967 | assert!(!editor_body.contains(path_fn), "EDITOR section touches {path_fn} directly"); |
| 1968 | } | 1968 | } |
| 1969 | } | 1969 | } |
| 1970 | + | ||
| 1971 | +/// With no project open, a PROJECT row must not fall back to a bare noun | ||
| 1972 | +/// ("Size"/"Rate"/"HDR") standing in the value slot -- it reads as a value | ||
| 1973 | +/// while carrying none. This binary has no `TestAppContext` to actually | ||
| 1974 | +/// render the page with `player.session` empty, so this is a source scan | ||
| 1975 | +/// for the fallback strings the bug shipped as, same as the guard above it. | ||
| 1976 | +#[test] | ||
| 1977 | +fn settings_project_rows_have_no_bare_noun_placeholder() { | ||
| 1978 | + let source = src_text("ui/settings_stance.rs"); | ||
| 1979 | + let project_start = source.find("fn project_section(").expect("the project section"); | ||
| 1980 | + let editor_start = source.find("fn editor_section(").expect("the editor section"); | ||
| 1981 | + let project_body = &source[project_start..editor_start]; | ||
| 1982 | + for placeholder in ["\"Size\".to_string()", "\"Rate\".to_string()", "\"HDR\".to_string()"] { | ||
| 1983 | + assert!( | ||
| 1984 | + !project_body.contains(placeholder), | ||
| 1985 | + "a PROJECT row fell back to the bare noun {placeholder} -- it reads as a value with no project open" | ||
| 1986 | + ); | ||
| 1987 | + } | ||
| 1988 | +} | ||
crates/app/src/ui/settings_stance.rsmodified+39 -14
| @@ -58,6 +58,21 @@ fn row( | |||
| 58 | hint: &'static str, | 58 | hint: &'static str, |
| 59 | player: &Player, | 59 | player: &Player, |
| 60 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | 60 | on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, |
| 61 | +) -> impl IntoElement { | ||
| 62 | + row_ink(id, label_text, value, hint, player, on_click, INK1()) | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +/// [`row`] with the value's ink chosen by the caller -- [`INK4`] for a value | ||
| 66 | +/// that is not really a value yet (nothing to show until a project opens), | ||
| 67 | +/// so it reads as absent rather than as a fifth real setting. | ||
| 68 | +fn row_ink( | ||
| 69 | + id: &'static str, | ||
| 70 | + label_text: &'static str, | ||
| 71 | + value: impl Into<SharedString>, | ||
| 72 | + hint: &'static str, | ||
| 73 | + player: &Player, | ||
| 74 | + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, | ||
| 75 | + value_ink: u32, | ||
| 61 | ) -> impl IntoElement { | 76 | ) -> impl IntoElement { |
| 62 | let value: SharedString = value.into(); | 77 | let value: SharedString = value.into(); |
| 63 | let hint: SharedString = hint.into(); | 78 | let hint: SharedString = hint.into(); |
| @@ -90,7 +105,7 @@ fn row( | |||
| 90 | .flex_none() | 105 | .flex_none() |
| 91 | .font(value_style.font) | 106 | .font(value_style.font) |
| 92 | .text_size(value_style.size) | 107 | .text_size(value_style.size) |
| 93 | - .text_color(rgb(INK1())) | 108 | + .text_color(rgb(value_ink)) |
| 94 | .child(value), | 109 | .child(value), |
| 95 | ) | 110 | ) |
| 96 | } | 111 | } |
| @@ -100,23 +115,30 @@ fn row( | |||
| 100 | /// [`inspector.rs`]'s own four-plus-Mix list, ported rather than | 115 | /// [`inspector.rs`]'s own four-plus-Mix list, ported rather than |
| 101 | /// reimplemented (same `Pick`/`open_mix` doors). | 116 | /// reimplemented (same `Pick`/`open_mix` doors). |
| 102 | fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { | 117 | fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElement { |
| 118 | + // corner-cut: no genuine default resolution or fps exists before either | ||
| 119 | + // a project opens or a pick is made, so the empty state is a bare dash | ||
| 120 | + // in INK4 -- quieter than a real value, never a noun that reads as one | ||
| 121 | + // (the "Size"/"Rate"/"HDR" placeholders this row used to fall back to). | ||
| 103 | let resolution = player.session.as_ref().map(PlaybackSession::resolution); | 122 | let resolution = player.session.as_ref().map(PlaybackSession::resolution); |
| 104 | - let res_val = match resolution.or(player.pending_settings.0) { | 123 | + let (res_val, res_ink) = match resolution.or(player.pending_settings.0) { |
| 105 | - Some((_, h)) => format!("{h}p"), | 124 | + Some((_, h)) => (format!("{h}p"), INK1()), |
| 106 | - None => "Size".to_string(), | 125 | + None => ("—".to_string(), INK4()), |
| 107 | }; | 126 | }; |
| 108 | - let fps_val = match (player.session.is_some(), player.pending_settings.1) { | 127 | + let (fps_val, fps_ink) = match (player.session.is_some(), player.pending_settings.1) { |
| 109 | - (true, _) => format!("{} fps", fps_label(player.fps)), | 128 | + (true, _) => (format!("{} fps", fps_label(player.fps)), INK1()), |
| 110 | - (false, Some(fps)) => format!("{} fps", fps_label(fps)), | 129 | + (false, Some(fps)) => (format!("{} fps", fps_label(fps)), INK1()), |
| 111 | - (false, None) => "Rate".to_string(), | 130 | + (false, None) => ("—".to_string(), INK4()), |
| 112 | }; | 131 | }; |
| 132 | + // Sample rate keeps its "Source" fallback: unlike resolution/fps it | ||
| 133 | + // states a real behaviour (derives from the first audio source) rather | ||
| 134 | + // than standing in for a value with nothing behind it. | ||
| 113 | let rate_val = match player.session.as_ref().map_or(player.pending_settings.2, |s| s.sample_rate()) { | 135 | let rate_val = match player.session.as_ref().map_or(player.pending_settings.2, |s| s.sample_rate()) { |
| 114 | Some(rate) => format!("{rate} Hz"), | 136 | Some(rate) => format!("{rate} Hz"), |
| 115 | None => "Source".to_string(), | 137 | None => "Source".to_string(), |
| 116 | }; | 138 | }; |
| 117 | - let tone_val = match &player.session { | 139 | + let (tone_val, tone_ink) = match &player.session { |
| 118 | - Some(session) => format!("HDR {}", tone_label(session.tone())), | 140 | + Some(session) => (format!("HDR {}", tone_label(session.tone())), INK1()), |
| 119 | - None => "HDR".to_string(), | 141 | + None => ("—".to_string(), INK4()), |
| 120 | }; | 142 | }; |
| 121 | div() | 143 | div() |
| 122 | .flex_none() | 144 | .flex_none() |
| @@ -124,21 +146,23 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | |||
| 124 | .flex_col() | 146 | .flex_col() |
| 125 | .gap(px(2.)) | 147 | .gap(px(2.)) |
| 126 | .child(section_head("PROJECT · stored in the .edith file")) | 148 | .child(section_head("PROJECT · stored in the .edith file")) |
| 127 | - .child(row( | 149 | + .child(row_ink( |
| 128 | "settings-resolution", | 150 | "settings-resolution", |
| 129 | "Resolution", | 151 | "Resolution", |
| 130 | res_val, | 152 | res_val, |
| 131 | "the canvas every clip is composed onto, and the size the export comes out at", | 153 | "the canvas every clip is composed onto, and the size the export comes out at", |
| 132 | player, | 154 | player, |
| 133 | cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Resolution, event.position(), cx)), | 155 | cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Resolution, event.position(), cx)), |
| 156 | + res_ink, | ||
| 134 | )) | 157 | )) |
| 135 | - .child(row( | 158 | + .child(row_ink( |
| 136 | "settings-fps", | 159 | "settings-fps", |
| 137 | "Frame rate", | 160 | "Frame rate", |
| 138 | fps_val, | 161 | fps_val, |
| 139 | "the rate the whole timeline is cut and written at", | 162 | "the rate the whole timeline is cut and written at", |
| 140 | player, | 163 | player, |
| 141 | cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Fps, event.position(), cx)), | 164 | cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Fps, event.position(), cx)), |
| 165 | + fps_ink, | ||
| 142 | )) | 166 | )) |
| 143 | .child(row( | 167 | .child(row( |
| 144 | "settings-sample-rate", | 168 | "settings-sample-rate", |
| @@ -151,13 +175,14 @@ fn project_section(player: &Player, cx: &mut Context<Player>) -> impl IntoElemen | |||
| 151 | // hook: the mastering-display target (a monitor peak-nits fact, not | 175 | // hook: the mastering-display target (a monitor peak-nits fact, not |
| 152 | // yet in `inspector.rs`'s own project section) is this row's pair -- | 176 | // yet in `inspector.rs`'s own project section) is this row's pair -- |
| 153 | // another builder's row, plugged in right here once it exists. | 177 | // another builder's row, plugged in right here once it exists. |
| 154 | - .child(row( | 178 | + .child(row_ink( |
| 155 | "settings-tonemap", | 179 | "settings-tonemap", |
| 156 | "HDR tonemap", | 180 | "HDR tonemap", |
| 157 | tone_val, | 181 | tone_val, |
| 158 | "which rendition HDR media is watched in; SDR media is untouched", | 182 | "which rendition HDR media is watched in; SDR media is untouched", |
| 159 | player, | 183 | player, |
| 160 | cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Tone, event.position(), cx)), | 184 | cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Tone, event.position(), cx)), |
| 185 | + tone_ink, | ||
| 161 | )) | 186 | )) |
| 162 | .child(row( | 187 | .child(row( |
| 163 | "settings-mix", | 188 | "settings-mix", |