From 5178f3fd3bdb6d2b3e6034f33b19d7ccebbc7573 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 01:37:30 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(ui):=20a=20settings=20page=20f?= =?UTF-8?q?or=20the=20project=20and=20the=20editor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Splits by the rule that project settings change what is rendered and belong to the project, while editor settings describe this machine. Reaches its rows through the openers and pickers that already exist rather than new card bodies. Reachable two ways on purpose: a visible St glyph on the spine and ctrl+, — chord-only entry is the defect class this room keeps repeating. --- crates/app/src/keymap.rs | 19 +- crates/app/src/main.rs | 6 + crates/app/src/oracle.rs | 6 +- crates/app/src/player/actions.rs | 1 + crates/app/src/player/cards.rs | 18 ++ crates/app/src/ui/mod.rs | 1 + crates/app/src/ui/settings_stance.rs | 269 +++++++++++++++++++++++++++ crates/app/src/ui/spine_stance.rs | 6 + crates/app/src/ui/stance.rs | 2 + 9 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 crates/app/src/ui/settings_stance.rs diff --git a/crates/app/src/keymap.rs b/crates/app/src/keymap.rs index 9e520ef..5dd25d5 100644 --- a/crates/app/src/keymap.rs +++ b/crates/app/src/keymap.rs @@ -210,6 +210,14 @@ actions! { /// The cue plate's font and size -- a person's own preference, kept /// beside the theme and not the project, and opened the same way. SubtitleStyle, + /// The settings page: PROJECT rows (resolution, fps, sample-rate, HDR + /// tonemap, the mix) beside EDITOR rows (proxies, auto-proxies, subtitle + /// font) -- one door, two clearly-headed sections, per the split rule + /// that "anything that changes the rendered output or lives in the + /// project file is PROJECT; anything about this machine, this person, + /// this window is EDITOR." Always answerable, same as `Theme`: it is + /// about the editor and the project's own numbers, not about a clip. + Settings, } impl ActionId { @@ -290,6 +298,7 @@ impl ActionId { ActionId::ShowActions => "All actions and their keys…", ActionId::Screenshot => "Save the frame on screen as a PNG", ActionId::SubtitleStyle => "Subtitle style: font and size…", + ActionId::Settings => "Settings: project and editor…", } } @@ -368,6 +377,7 @@ impl ActionId { ActionId::ShowActions => "show-actions", ActionId::Screenshot => "screenshot", ActionId::SubtitleStyle => "subtitle-style", + ActionId::Settings => "settings", } } @@ -448,7 +458,10 @@ impl ActionId { | ActionId::SubtitleStyle // ...and whether that window fills the screen: a way of looking, // same as the zoom and the theme beside it. - | ActionId::Fullscreen => Category::View, + | ActionId::Fullscreen + // The settings page: it changes no clip and no lane, only the + // project's own numbers and this window's preferences. + | ActionId::Settings => Category::View, ActionId::Cut | ActionId::Regroup | ActionId::Detach @@ -1205,6 +1218,10 @@ impl Keymap { // opened as often as the theme, not a switch thrown once a // session. b(ActionId::SubtitleStyle, "y", false), + // The consumer-editor convention (Cmd/Ctrl+,) -- free here: + // bare "," is WalkCutPrev, and nothing else answers to the + // ctrl chord. + b(ActionId::Settings, ",", true), ], } } diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 2feb555..6c818b4 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -500,6 +500,11 @@ struct Player { /// pointer: a stroke or a click meant for a row must not also cut the /// timeline. keys_open: bool, + /// The settings page is up (`?` overlay's sibling, but a latch rather + /// than a hold -- it carries clickable rows, not a glance-and-release + /// list). Cleared by [`Player::close_card`], the one reset list every + /// opener routes through. + settings_open: bool, /// What has been typed into the card's search box, which is the card's own /// input exactly as the export card's digits are (nothing in it takes /// focus, so the root's key handler is the field). Emptied every time the @@ -944,6 +949,7 @@ fn main() { autosave_armed: false, keymap: keymap.clone(), keys_open: false, + settings_open: false, keys_search: String::new(), keys_scroll: ScrollHandle::new(), lanes_scroll: ScrollHandle::new(), diff --git a/crates/app/src/oracle.rs b/crates/app/src/oracle.rs index 61073ec..4003610 100644 --- a/crates/app/src/oracle.rs +++ b/crates/app/src/oracle.rs @@ -102,7 +102,11 @@ pub(crate) fn enable(action: ActionId, ctx: Ctx) -> Enable { // touching no timeline, live through an export the same way. // ...and the cue plate's own font and size: a reading preference like the // theme, never burned into an export, live the same way. - if action == ActionId::Theme || action == ActionId::Fullscreen || action == ActionId::SubtitleStyle { + if action == ActionId::Theme + || action == ActionId::Fullscreen + || action == ActionId::SubtitleStyle + || action == ActionId::Settings + { return Enable::Yes; } if action == ActionId::ShowActions { diff --git a/crates/app/src/player/actions.rs b/crates/app/src/player/actions.rs index 22385fd..8e72d42 100644 --- a/crates/app/src/player/actions.rs +++ b/crates/app/src/player/actions.rs @@ -163,6 +163,7 @@ impl Player { // the key handler is what answers this one while there is. ActionId::CancelExport => {} ActionId::ShowActions => self.show_actions(cx), + ActionId::Settings => self.open_settings(cx), ActionId::Screenshot => self.take_screenshot(cx), // Cut machinery (DESIGN.md §6): the subject cut is the marked // clip ([`Selection::anchor`]) -- the oracle already refused diff --git a/crates/app/src/player/cards.rs b/crates/app/src/player/cards.rs index 0e82abd..917ab11 100644 --- a/crates/app/src/player/cards.rs +++ b/crates/app/src/player/cards.rs @@ -853,6 +853,22 @@ impl Player { /// Nothing here is a clip's or even the project's -- it never reaches the /// export, which never burns a cue into the picture -- so like the mix /// card it opens with no timeline required and nothing to refuse. + /// Opens the settings page (PROJECT rows beside EDITOR rows, + /// `ui::settings_stance`): the one door for "edit project and editor + /// settings" -- always answerable, since the oracle treats it like + /// `Theme` (`oracle.rs`), and refused only while an export is running, + /// same as every other card here. + pub(crate) fn open_settings(&mut self, cx: &mut Context) { + if self.exporting().is_some() { + return; + } + // One card at a time -- `close_card`'s own rule. + self.close_card(); + self.settings_open = true; + self.context_menu = None; + cx.notify(); + } + pub(crate) fn open_subtitle_style(&mut self, cx: &mut Context) { // One card at a time -- `close_card`'s own rule. self.close_card(); @@ -1241,6 +1257,7 @@ impl Player { pub(crate) fn modal(&self) -> bool { self.keys_open + || self.settings_open || self.export_open || self.eq_open.is_some() || self.color_open.is_some() @@ -1262,6 +1279,7 @@ impl Player { /// "the" card and closing all of them are the same act. pub(crate) fn close_card(&mut self) { self.keys_open = false; + self.settings_open = false; self.keys_search.clear(); self.rebinding = None; self.export_open = false; diff --git a/crates/app/src/ui/mod.rs b/crates/app/src/ui/mod.rs index 3c824ca..4741449 100644 --- a/crates/app/src/ui/mod.rs +++ b/crates/app/src/ui/mod.rs @@ -10,6 +10,7 @@ pub mod inspector; pub mod library; pub mod overlays; pub mod preview; +pub mod settings_stance; pub mod spine_stance; pub mod stance; pub mod theme; diff --git a/crates/app/src/ui/settings_stance.rs b/crates/app/src/ui/settings_stance.rs new file mode 100644 index 0000000..247eb49 --- /dev/null +++ b/crates/app/src/ui/settings_stance.rs @@ -0,0 +1,269 @@ +//! The settings page (user complaint: "we should have a settings page that +//! we can edit project and editor settings"). Two clearly-headed sections, +//! per the split rule a rubric pass settled: +//! +//! - PROJECT: anything that changes the rendered output or is stored in the +//! `.edith` file -- resolution, fps, sample-rate, the HDR tonemap, the mix. +//! - EDITOR: anything about this machine, this person, this window -- +//! proxies/auto-proxies (this window's decode/import policy) and the +//! subtitle font (a reading preference, kept in `~/.config/edith` like the +//! theme beside it, per [`crate::load_subtitle_style`]). +//! +//! Every row here reuses an opener or a picker this editor already has +//! ([`Player::open_picker`], [`Player::open_mix`], [`Player::open_subtitle_style`], +//! [`Player::toggle_proxies`], [`Player::toggle_auto_proxies`]) -- no new card +//! body, no second source of truth for what a value is or how it is set. +//! 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`] +//! exactly as `inspector.rs`'s legacy panel already does. + +use crate::*; +use crate::ui::type_scale; + +/// A 9px uppercase Archivo section head, `ink3` -- [`dock_stance::section_head`]'s +/// exact shape, repeated rather than imported across a `pub(crate)` seam for +/// one nine-line function. +fn section_head(text: impl Into) -> impl IntoElement { + let style = type_scale::head(); + div() + .flex_none() + .pt(px(4.)) + .font(style.font) + .text_size(style.size) + .text_color(rgb(INK3())) + .child(text.into()) +} + +/// One row: a ≤16-char label, its current value in mono (units carried, +/// never a bare number -- the density rule this task's charter names), and +/// a hover hint carrying the sentence a label must not. [`dock_stance::ghost_verb`]'s +/// anatomy, with a live value where that row has a chord badge -- this room +/// is a picker's own door, not a keystroke's. +fn row( + id: &'static str, + label_text: &'static str, + value: impl Into, + hint: &'static str, + player: &Player, + on_click: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static, +) -> 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); + let exporting = player.exporting().is_some(); + 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()) + .when(exporting, |d| d.opacity(0.4).cursor_not_allowed()) + .when(!exporting, |d| { + d.cursor_pointer().hover(|s| s.bg(rgb(DARK_RAISED()))).on_click(on_click) + }) + .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(INK1())) + .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 +/// reimplemented (same `Pick`/`open_mix` doors). +fn project_section(player: &Player, cx: &mut Context) -> impl IntoElement { + let resolution = player.session.as_ref().map(PlaybackSession::resolution); + let res_val = match resolution.or(player.pending_settings.0) { + Some((_, h)) => format!("{h}p"), + None => "Size".to_string(), + }; + let fps_val = match (player.session.is_some(), player.pending_settings.1) { + (true, _) => format!("{} fps", fps_label(player.fps)), + (false, Some(fps)) => format!("{} fps", fps_label(fps)), + (false, None) => "Rate".to_string(), + }; + let rate_val = match player.session.as_ref().map_or(player.pending_settings.2, |s| s.sample_rate()) { + Some(rate) => format!("{rate} Hz"), + None => "Source".to_string(), + }; + let tone_val = match &player.session { + Some(session) => format!("HDR {}", tone_label(session.tone())), + None => "HDR".to_string(), + }; + div() + .flex_none() + .flex() + .flex_col() + .gap(px(2.)) + .child(section_head("PROJECT · stored in the .edith file")) + .child(row( + "settings-resolution", + "Resolution", + res_val, + "the canvas every clip is composed onto, and the size the export comes out at", + player, + cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Resolution, event.position(), cx)), + )) + .child(row( + "settings-fps", + "Frame rate", + fps_val, + "the rate the whole timeline is cut and written at", + player, + cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Fps, event.position(), cx)), + )) + .child(row( + "settings-sample-rate", + "Sample rate", + rate_val, + "the rate the project's own sound mix is run at; source derives it from the first audio source", + 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( + "settings-tonemap", + "HDR tonemap", + tone_val, + "which rendition HDR media is watched in; SDR media is untouched", + player, + cx.listener(|this, event: &ClickEvent, _, cx| this.open_picker(Pick::Tone, event.position(), cx)), + )) + .child(row( + "settings-mix", + "Mix", + "Tracks…", + "a fader per track and the limiter over the sum of them", + player, + cx.listener(|this, _: &ClickEvent, _, cx| this.open_mix(None, cx)), + )) +} + +/// EDITOR: this window's own decode/import policy and this person's own +/// reading preference -- never written into the `.edith` file. +fn editor_section(player: &Player, cx: &mut Context) -> impl IntoElement { + div() + .flex_none() + .flex() + .flex_col() + .gap(px(2.)) + .child(section_head("EDITOR · kept in ~/.config/edith")) + .child(row( + "settings-proxies", + "Proxies", + match player.proxies_on { + true => format!("On{}", player.proxy_tail()), + false => "Off".to_string(), + }, + "cuts on small stand-ins of the big films; the sound and every export stay the film's own", + player, + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_proxies(cx)), + )) + .child(row( + "settings-auto-proxies", + "Auto proxies", + if player.auto_proxies_on { "On" } else { "Off" }, + "makes a stand-in for every big film as it is imported", + player, + cx.listener(|this, _: &ClickEvent, _, cx| this.toggle_auto_proxies(cx)), + )) + .child(row( + "settings-subtitle-style", + "Subtitle font", + "Font…", + "the cue plate's own font and size", + player, + cx.listener(|this, _: &ClickEvent, _, cx| this.open_subtitle_style(cx)), + )) +} + +/// The page itself: a modal card, the same drag-scrim-and-click-away shape +/// every other card in this room takes ([`crate::ui::cards`]'s +/// eq/color/transform/speed cards) -- closed by a click away or `esc`, +/// through [`Player::close_card`], exactly like them. +pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElement { + drag_scrim(cx) + .flex() + .justify_center() + .items_center() + .bg(rgba(SCRIM())) + .on_mouse_down( + MouseButton::Left, + cx.listener(|this, _: &MouseDownEvent, _, cx| { + this.close_card(); + cx.notify(); + cx.stop_propagation(); + }), + ) + .child( + div() + .id("settings-card") + .w_full() + .max_w(px(360.)) + .max_h(relative(0.86)) + .on_mouse_down(MouseButton::Left, swallow) + .flex() + .flex_col() + .gap(px(8.)) + .p(px(12.)) + .rounded(px(6.)) + .bg(rgb(DARK_PANEL())) + .border_1() + .border_color(rgba(DARK_SEAM())) + .child({ + let head = type_scale::head(); + div() + .flex_none() + .flex() + .justify_between() + .items_baseline() + .font(head.font) + .text_size(head.size) + .text_color(rgb(INK3())) + .child("SETTINGS") + .child( + div() + .font(type_scale::mono(type_scale::CHORD_METADATA_MIN_PX, gpui::FontWeight::MEDIUM).font) + .text_size(px(type_scale::CHORD_METADATA_MIN_PX)) + .text_color(rgb(INK3())) + .child(player.keymap.display(ActionId::Settings)), + ) + }) + .child( + div() + .id("settings-rows") + .min_h(px(0.)) + .overflow_y_scroll() + .flex() + .flex_col() + .gap(px(10.)) + .child(project_section(player, cx)) + .child(editor_section(player, cx)), + ), + ) +} diff --git a/crates/app/src/ui/spine_stance.rs b/crates/app/src/ui/spine_stance.rs index bb2d96d..545ee62 100644 --- a/crates/app/src/ui/spine_stance.rs +++ b/crates/app/src/ui/spine_stance.rs @@ -312,5 +312,11 @@ pub(crate) fn render(player: &Player, cx: &mut Context) -> impl IntoElem glyph("spine-fullscreen", "FS", ActionId::Fullscreen, false, true, player, cx), )) .child(glyph("spine-screenshot", "Sh", ActionId::Screenshot, false, true, player, cx)) + // The settings page's own visible door (user complaint: "some + // options are only reachable via keyboard shortcut") -- a chord + // alone is a defect class this room has hit repeatedly, so this + // glyph sits beside the other once-a-session ROOM acts even though + // its chord (`^,`) is a preference, not a mnemonic. + .child(glyph("spine-settings", "St", ActionId::Settings, player.settings_open, true, player, cx)) .child(div().flex_1()) } diff --git a/crates/app/src/ui/stance.rs b/crates/app/src/ui/stance.rs index 4185f57..effbb97 100644 --- a/crates/app/src/ui/stance.rs +++ b/crates/app/src/ui/stance.rs @@ -11,6 +11,7 @@ use crate::*; use crate::ui::bench_stance; use crate::ui::dock_stance; +use crate::ui::settings_stance; use crate::ui::timeband_stance; use crate::ui::spine_stance; use crate::ui::type_scale::{self, Typeset}; @@ -759,6 +760,7 @@ pub(crate) fn render( el.child(notice_plate(n)) }) .when(player.keys_open, |el| el.child(keys_overlay(player))) + .when(player.settings_open, |el| el.child(settings_stance::render(player, cx))) // The two menus (DESIGN §9: "verbs of the thing under the // cursor", plate styling, the same scrim-and-row component // the legacy tree already uses -- `library.rs`'s own doc