From e88fbc827e6ad0aa043ee2a598b38227bcb87d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 21 Aug 2026 06:02:00 +0300 Subject: [PATCH] feat(ui): the settings page shows the HDR reference the file declared Surfaces the MaxCLL/MaxFALL and mastering-display peak the demuxers already parse into ContentLight but nothing in the UI ever read (grep across crates/app/src returned zero hits outside tests). Two new read-only rows sit beside the existing HDR tonemap picker in the settings page's PROJECT section -- "HDR reference" (mastering peak) and "Content light" (CLL/FALL) -- using the page's own row_static idiom (no cursor/hover/click) since nothing in engine::project::Project has a field to persist an override into. PlaybackSession gains a content_light() accessor, populated at every open site (fresh open, saved-project reopen) by a second header-only Demuxer::open for the light level, matching the same double-open-for-a-header trade this file already accepts for audio probes. --- crates/app/src/tests/layout.rs | 33 ++++++++++ crates/app/src/ui/settings_stance.rs | 98 +++++++++++++++++++++++++--- crates/engine/src/playback.rs | 37 ++++++++++- 3 files changed, 158 insertions(+), 10 deletions(-) diff --git a/crates/app/src/tests/layout.rs b/crates/app/src/tests/layout.rs index aa90a93..f8237a5 100644 --- a/crates/app/src/tests/layout.rs +++ b/crates/app/src/tests/layout.rs @@ -2272,3 +2272,36 @@ fn settings_project_rows_have_no_bare_noun_placeholder() { ); } } + +/// The HDR reference rows must read the file's own declared numbers off +/// [`engine::colorspace::ContentLight`] -- not invent a monitor override the +/// engine has nowhere to persist -- and must fall back to the page's one +/// established empty state (a bare `—` in `INK4`, [`row_ink`]/[`row_static`]'s +/// own idiom) rather than a second placeholder idiom. No `TestAppContext` +/// here either, so this is the same source-scan the guard above it is. +#[test] +fn hdr_reference_rows_read_content_light_and_use_the_established_empty_state() { + let source = src_text("ui/settings_stance.rs"); + let project_start = source.find("fn project_section(").expect("the project section"); + let editor_start = source.find("fn editor_section(").expect("the editor section"); + let project_body = &source[project_start..editor_start]; + + assert!(project_body.contains("settings-hdr-reference"), "the HDR reference row is missing"); + assert!(project_body.contains("settings-content-light"), "the content-light row is missing"); + + // Reads the real declared numbers, not an invented default or a fixed + // string standing in for one. + for field in ["mastering_max", "max_cll", "max_fall"] { + assert!(project_body.contains(field), "the HDR reference rows do not read ContentLight::{field}"); + } + + // No override field exists on the engine side to write one into, so the + // row must never claim a picker/opener the way every other PROJECT row + // does -- it is built with `row_static`, not `row`/`row_ink`. + assert!(project_body.contains("row_static(\n \"settings-hdr-reference\""), "the HDR reference row must be read-only (row_static), not a picker"); + assert!(project_body.contains("row_static(\n \"settings-content-light\""), "the content-light row must be read-only (row_static), not a picker"); + + // The established empty state: a bare "—" reused, never a second idiom + // ("N/A", "None", "Unknown"...) invented for the same absence. + assert!(project_body.contains("\"—\".to_string()"), "the HDR reference rows must reuse the page's own empty-state dash"); +} diff --git a/crates/app/src/ui/settings_stance.rs b/crates/app/src/ui/settings_stance.rs index 98bf4a7..38ecdb1 100644 --- a/crates/app/src/ui/settings_stance.rs +++ b/crates/app/src/ui/settings_stance.rs @@ -21,16 +21,20 @@ //! Values apply live through those same doors; there is no Apply button here //! to be inconsistent with the rest of the room. //! -//! Seams left for other builders (this task's scope boundary): the HDR -//! mastering-display target row (a monitor fact, not in `inspector.rs`'s own -//! project section yet) has no row here either -- it plugs into -//! `project_section` below, beside the tonemap row it is the pair of. A -//! finer fps/sample-rate/tone picker is the same builder's to extend; this -//! page only ever asks for [`Pick::Fps`]/[`Pick::SampleRate`]/[`Pick::Tone`] +//! Seams left for other builders (this task's scope boundary): a finer +//! fps/sample-rate/tone picker is the same builder's to extend; this page +//! only ever asks for [`Pick::Fps`]/[`Pick::SampleRate`]/[`Pick::Tone`] //! exactly as `inspector.rs`'s legacy panel already does. +//! +//! The HDR reference numbers beside the tonemap row (`HDR reference` and +//! `Content light`) are the *file's* declared light level +//! ([`engine::colorspace::ContentLight`]), not a monitor fact -- read-only, +//! since nothing in [`engine::project::Project`] holds a place to persist an +//! override into. use crate::*; use crate::ui::type_scale; +use engine::colorspace::ContentLight; /// A 9px uppercase Archivo section head, `ink3` -- [`dock_stance::section_head`]'s /// exact shape, repeated rather than imported across a `pub(crate)` seam for @@ -110,6 +114,51 @@ fn row_ink( ) } +/// [`row_ink`] with no opener: a readout rather than a picker, for a value +/// this editor cannot set because nothing behind it can hold a pick -- +/// [`engine::playback::PlaybackSession`] has no field to persist one into. +/// No `cursor_pointer`, no hover paint, no click: the row must not read as a +/// button that does nothing when pressed. The hint still names where the +/// number came from, since a reader who wants that detail should get it from +/// the same door every other row's hint answers from. +fn row_static( + id: &'static str, + label_text: &'static str, + value: impl Into, + hint: &'static str, + value_ink: u32, +) -> impl IntoElement { + let value: SharedString = value.into(); + let hint: SharedString = hint.into(); + let label_style = type_scale::label(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM); + let value_style = type_scale::mono(type_scale::LABEL_ROW_PX, gpui::FontWeight::MEDIUM); + div() + .id(id) + .flex_none() + .flex() + .items_center() + .justify_between() + .h(px(CONTROL_H)) + .px(px(8.)) + .rounded(px(3.)) + .tooltip(move |_, cx| cx.new(|_| Tip(hint.clone())).into()) + .child( + div() + .font(label_style.font) + .text_size(label_style.size) + .text_color(rgb(INK2())) + .child(label_text), + ) + .child( + div() + .flex_none() + .font(value_style.font) + .text_size(value_style.size) + .text_color(rgb(value_ink)) + .child(value), + ) +} + /// PROJECT: the canvas every clip is composed onto, the rate it is cut at, /// the HDR rendition it is watched in, and the mix everything sums into -- /// [`inspector.rs`]'s own four-plus-Mix list, ported rather than @@ -140,6 +189,23 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen Some(session) => (format!("HDR {}", tone_label(session.tone())), INK1()), None => ("—".to_string(), INK4()), }; + // The reference row's own numbers: what source 0's file actually declared + // ([`engine::colorspace::ContentLight`], read at open by + // [`engine::playback::PlaybackSession::content_light`]) -- read-only, + // since nothing in [`engine::project::Project`] holds an override to + // persist one into. `—` for a project with no session, and for a session + // whose file is SDR or simply declared nothing (most files declare + // nothing here at all). + let light = player.session.as_ref().map_or(ContentLight::default(), engine::playback::PlaybackSession::content_light); + let (master_val, master_ink) = match (&player.session, light.mastering_max) { + (Some(_), Some(nits)) => (format!("{nits:.0} nits"), INK1()), + _ => ("—".to_string(), INK4()), + }; + let (content_val, content_ink) = match (&player.session, light.max_cll, light.max_fall) { + (Some(_), Some(cll), Some(fall)) => (format!("{cll:.0}/{fall:.0} nits"), INK1()), + (Some(_), Some(cll), None) => (format!("{cll:.0} nits"), INK1()), + _ => ("—".to_string(), INK4()), + }; div() .flex_none() .flex() @@ -172,9 +238,6 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen player, cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::SampleRate, event.position(), cx)), )) - // hook: the mastering-display target (a monitor peak-nits fact, not - // yet in `inspector.rs`'s own project section) is this row's pair -- - // another builder's row, plugged in right here once it exists. .child(row_ink( "settings-tonemap", "HDR tonemap", @@ -184,6 +247,23 @@ fn project_section(player: &Player, cx: &mut Context) -> impl IntoElemen cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Tone, event.position(), cx)), tone_ink, )) + // The tonemap row's pair: what the file actually declared, read-only + // ([`row_static`] -- there is nowhere in the project to persist a + // pick even if this page offered one). + .child(row_static( + "settings-hdr-reference", + "HDR reference", + master_val, + "the mastering display's own peak white, in cd/m^2, as the grade declared it -- what a 'Reference' tonemap targets before it ever looks at this film's own pixels", + master_ink, + )) + .child(row_static( + "settings-content-light", + "Content light", + content_val, + "MaxCLL/MaxFALL: the brightest single pixel and the brightest frame average measured in the finished encode -- what a 'Reference' tonemap actually rolls off from when the file declares it, ahead of the mastering peak above", + content_ink, + )) .child(row( "settings-mix", "Mix", diff --git a/crates/engine/src/playback.rs b/crates/engine/src/playback.rs index cf55f8d..5822f1a 100644 --- a/crates/engine/src/playback.rs +++ b/crates/engine/src/playback.rs @@ -22,7 +22,7 @@ use crate::ao::AoSession; use crate::audio::{AudioChunk, AudioSession}; use crate::clock::{ClockSource, PlaybackClock}; use crate::color::ColorParams; -use crate::colorspace::ColorDescription; +use crate::colorspace::{ColorDescription, ContentLight}; use crate::decode::{Backend, BackendCell, DecodeSession, Frame, Worker}; use crate::demux::{Codec, Demuxer, VideoMeta}; use crate::eq::EqParams; @@ -312,6 +312,13 @@ pub struct PlaybackSession { /// `resolution` line makes it after that. Every clip is composed onto it, so /// a file of another size is a placed picture rather than a refusal. meta: VideoMeta, + /// What source 0's own file declared about how bright it gets + /// ([`crate::colorspace::ContentLight`]) -- MaxCLL/MaxFALL and the + /// mastering display's peak/black, read once at open exactly as `native` + /// is, since the value is a property of the file and never changes under + /// a running session. [`ContentLight::default()`] (every field `None`) + /// for an SDR file and for a song or a still, neither of which is graded. + content_light: ContentLight, /// Source 0's own picture, kept from the open: the project resolution /// starts here, and a caller offering sizes to pick from needs the media's /// own among them or a project moved off it could never come back. @@ -585,8 +592,15 @@ impl PlaybackSession { // first edit -- and the range opened above is exactly that clip's. let project = Project::single(&path, meta.frame_count); let span = project.composite_span_at(0); + // A second, header-only open purely for the light level: `open_worker` + // above already read one to hand the decode thread its own, but never + // hands it back out. The same trade the audio header cache above this + // makes -- a second container open, paid once at open rather than never + // -- since nothing here decodes a single picture. + let content_light = Demuxer::open(&path).map(|(_, d)| d.light()).unwrap_or_default(); Ok(Self { meta, + content_light, native: (meta.width, meta.height), native_fps: meta.frame_rate, frames: stream.frames, @@ -707,6 +721,7 @@ impl PlaybackSession { let stream = DecodeSession::open_black(width, height, span.map_or(1, |s| s.len)); Ok(Self { meta, + content_light: ContentLight::default(), native: (width, height), native_fps: frame_rate, frames: stream.frames, @@ -803,6 +818,7 @@ impl PlaybackSession { )?; Ok(Self { meta, + content_light: ContentLight::default(), native: (meta.width, meta.height), native_fps: IMAGE_ONLY_RATE, frames: stream.frames, @@ -897,6 +913,15 @@ impl PlaybackSession { // ([`open_audio_only`](Self::open_audio_only)), and the placeholder // black stream is superseded by the `seek` at the end of this function // like every other worker opened here. + // What source 0's own file declares about its light level, read the + // same way [`open_stream`](Self::open_stream) reads it for a fresh + // open: [`ContentLight::default()`] for a song or a still, neither of + // which is graded. + let content_light = if crate::is_audio(&first.path) || crate::is_image(&first.path) { + ContentLight::default() + } else { + Demuxer::open(&first.path).map(|(_, d)| d.light()).unwrap_or_default() + }; let (mut meta, stream) = match crate::is_audio(&first.path) { true => { let (width, height, canvas_fps) = AUDIO_ONLY_CANVAS; @@ -1109,6 +1134,7 @@ impl PlaybackSession { }; let mut session = Self { meta, + content_light, native, native_fps, frames: stream.frames, @@ -2716,6 +2742,15 @@ impl PlaybackSession { self.project.tone() } + /// What source 0's own file declared about how bright it gets + /// ([`ContentLight`]): a property of the film, read once at open, and + /// entirely absent (every field `None`) for an SDR file, a song or a + /// still. Read-only -- the number a file carries, never a project setting + /// a user can override, since nothing in [`Project`] holds one to persist. + pub fn content_light(&self) -> ContentLight { + self.content_light + } + /// Picks one. Rebuilds the **picture** where the playhead is, exactly as /// [`set_resolution`](Self::set_resolution) does -- the frame on screen is /// remapped at once, paused or playing, and the sound is not touched: a