The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
feat(project): any frame and any rate, typed, on the launch sheet and the project sheet
Jareera959c8af8a20
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rsindex d1a8ce04..65fef6b3 100644--- a/src/crates/concat/src/lib.rs+++ b/src/crates/concat/src/lib.rs@@ -429,6 +429,15 @@ pub fn run() -> Result<(), slint::PlatformError> {app.on_start_size_changed(on_window!(|state, index: i32| {state.handle(Msg::Start(StartMsg::SizeChanged(index)));}));+ app.on_start_custom_width_edited(on_window!(|state, width: f32| {+ state.handle(Msg::Start(StartMsg::CustomWidth(width)));+ }));+ app.on_start_custom_height_edited(on_window!(|state, height: f32| {+ state.handle(Msg::Start(StartMsg::CustomHeight(height)));+ }));+ app.on_start_custom_fps_edited(on_window!(|state, fps: f32| {+ state.handle(Msg::Start(StartMsg::CustomFps(fps)));+ }));app.on_start_rate_changed(on_window!(|state, index: i32| {state.handle(Msg::Start(StartMsg::RateChanged(index)));}));@@ -1124,6 +1133,15 @@ pub fn run() -> Result<(), slint::PlatformError> {app.on_project_rate_changed(on_window!(|state, index: i32| {state.handle(Msg::Project(ProjectMsg::RateChanged(index)));}));+ app.on_project_custom_width_edited(on_window!(|state, width: f32| {+ state.handle(Msg::Project(ProjectMsg::CustomWidth(width)));+ }));+ app.on_project_custom_height_edited(on_window!(|state, height: f32| {+ state.handle(Msg::Project(ProjectMsg::CustomHeight(height)));+ }));+ app.on_project_custom_fps_edited(on_window!(|state, fps: f32| {+ state.handle(Msg::Project(ProjectMsg::CustomFps(fps)));+ }));app.on_project_apply(on_window!(|state| {state.handle(Msg::Project(ProjectMsg::Apply));}));diff --git a/src/crates/concat/src/panes/project.rs b/src/crates/concat/src/panes/project.rsindex dfeb2752..99cd5c70 100644--- a/src/crates/concat/src/panes/project.rs+++ b/src/crates/concat/src/panes/project.rs@@ -6,7 +6,7 @@use concat_project::Command;use slint::SharedString;-use crate::studio::{OUTPUTS, START_RATES, Studio};+use crate::studio::{OUTPUTS, RATES, Studio, custom_frame, custom_rate, fps_of};use crate::ui::ProjectSheetData;/// Everything that can happen to the project sheet.@@ -18,6 +18,10 @@ pub enum ProjectMsg {NameEdited(String),SizeChanged(i32),RateChanged(i32),+ /// The custom frame's sides and rate, as typed.+ CustomWidth(f32),+ CustomHeight(f32),+ CustomFps(f32),Apply,}@@ -26,10 +30,14 @@ pub enum ProjectMsg {pub struct ProjectPane {pub open: bool,pub name: String,- /// Row in `OUTPUTS`, or -1 for a frame the list does not carry.- pub size: i32,- /// Row in `START_RATES`.+ /// Row in `OUTPUTS`, or one past its end for a custom frame.+ pub size: usize,+ /// Row in `RATES`, or one past its end for a custom rate.pub rate: usize,+ /// The custom frame, even on both sides.+ pub custom_size: (u32, u32),+ /// The custom rate, as the exact fraction.+ pub custom_rate: (i64, i64),}impl ProjectPane {@@ -42,25 +50,48 @@ impl ProjectPane {let (width, height) = studio.output_size();let video = studio.project().active().video;let (num, den) = (video.rate_num, video.rate_den);+ // A frame or a rate the lists do not carry opens as Custom+ // with the project's own numbers, exact: an Apply that only+ // renamed the project must not move its rate to the nearest+ // row, as it once moved every 23.976 project to 30.*self = ProjectPane {open: true,name: studio.project_name.clone(),size: OUTPUTS.iter().position(|size| *size == (width as i32, height as i32))- .map_or(-1, |index| index as i32),- rate: START_RATES+ .unwrap_or(OUTPUTS.len()),+ rate: RATES.iter().position(|(_, n, d)| (*n, *d) == (num, den))- .unwrap_or(3),+ .unwrap_or(RATES.len()),+ custom_size: (width, height),+ custom_rate: (num, den),};}ProjectMsg::Close => self.open = false,ProjectMsg::NameEdited(name) => self.name = name,- ProjectMsg::SizeChanged(index) => self.size = index,+ ProjectMsg::SizeChanged(index) => {+ let index = (index.max(0) as usize).min(OUTPUTS.len());+ if index == OUTPUTS.len() && self.size < OUTPUTS.len() {+ self.custom_size = self.frame();+ }+ self.size = index;+ }ProjectMsg::RateChanged(index) => {- self.rate = (index.max(0) as usize).min(START_RATES.len() - 1);+ let index = (index.max(0) as usize).min(RATES.len());+ if index == RATES.len() && self.rate < RATES.len() {+ self.custom_rate = self.rate();+ }+ self.rate = index;+ }+ ProjectMsg::CustomWidth(width) => {+ self.custom_size = custom_frame(width, self.custom_size.1 as f32);}+ ProjectMsg::CustomHeight(height) => {+ self.custom_size = custom_frame(self.custom_size.0 as f32, height);+ }+ ProjectMsg::CustomFps(fps) => self.custom_rate = custom_rate(f64::from(fps)),ProjectMsg::Apply => self.apply(studio),}}@@ -72,18 +103,14 @@ impl ProjectPane {fn apply(&mut self, studio: &mut Studio) {let sheet = std::mem::take(self);let name = sheet.name.trim().to_owned();- let size = usize::try_from(sheet.size)- .ok()- .and_then(|index| OUTPUTS.get(index).copied());- let (_, num, den) = START_RATES[sheet.rate.min(START_RATES.len() - 1)];+ let (width, height) = sheet.frame();+ let (num, den) = sheet.rate();let Some(session) = studio.session.as_mut() else {return;};let mut video = session.video();- if let Some((width, height)) = size {- video.width = width as u32;- video.height = height as u32;- }+ video.width = width;+ video.height = height;video.rate_num = num;video.rate_den = den;session.prepare_save((!name.is_empty()).then_some(name.as_str()));@@ -95,8 +122,26 @@ impl ProjectPane {studio.request_preview();}+ /// The frame the sheet describes: the row picked, or the typed one.+ fn frame(&self) -> (u32, u32) {+ OUTPUTS+ .get(self.size)+ .map_or(self.custom_size, |&(width, height)| {+ (width as u32, height as u32)+ })+ }++ /// The rate the sheet describes, as the exact fraction.+ fn rate(&self) -> (i64, i64) {+ RATES+ .get(self.rate)+ .map_or(self.custom_rate, |&(_, num, den)| (num, den))+ }+/// The sheet as Slint shows it.pub fn data(&self, studio: &Studio) -> ProjectSheetData {+ let (width, height) = self.frame();+ let (num, den) = self.rate();let folder: SharedString = studio.session.as_ref()@@ -108,8 +153,12 @@ impl ProjectPane {name: self.name.as_str().into(),folder,timeline: studio.timeline().name.as_str().into(),- size: self.size,+ size: self.size as i32,rate: self.rate as i32,+ custom_width: width as f32,+ custom_height: height as f32,+ custom_fps: fps_of(num, den) as f32,+ rate_readout: format!("{num}/{den}").into(),}}}diff --git a/src/crates/concat/src/panes/start.rs b/src/crates/concat/src/panes/start.rsindex b710ce9c..bed0ce59 100644--- a/src/crates/concat/src/panes/start.rs+++ b/src/crates/concat/src/panes/start.rs@@ -9,7 +9,9 @@ use concat_host::projects;use crate::i18n::{t, tf};use crate::platform;-use crate::studio::{ASPECTS, SIZES, START_RATES, Studio, frame_size, home_folder};+use crate::studio::{+ ASPECTS, SIZES, START_RATES, Studio, custom_frame, custom_rate, fps_of, frame_size, home_folder,+};use crate::ui::StartData;/// Everything that can happen to the launch screen's sheet.@@ -26,6 +28,10 @@ pub enum StartMsg {/// The frame's size, as the short edge: 720p, 1080p, 4K.SizeChanged(i32),RateChanged(i32),+ /// The custom frame's sides and rate, as typed.+ CustomWidth(f32),+ CustomHeight(f32),+ CustomFps(f32),DismissError,/// Pick where the project folder goes.Browse,@@ -46,9 +52,15 @@ pub struct StartPane {pub location: String,/// Index into [`ASPECTS`].pub aspect: usize,- /// Index into [`SIZES`].+ /// Index into [`SIZES`], or one past its end for a custom frame.pub size: usize,+ /// Index into [`START_RATES`], or one past its end for a custom rate.pub rate: usize,+ /// The custom frame, even on both sides; seeded from the preset that+ /// was picked when Custom was, so the fields start from a real frame.+ pub custom_size: (u32, u32),+ /// The custom rate, as an exact fraction.+ pub custom_rate: (i64, i64),pub busy: bool,pub error: String,}@@ -70,6 +82,8 @@ impl Default for StartPane {// in the app assumes, and the one a phone and a desk agree on.size: 1,rate: 3,+ custom_size: (1920, 1080),+ custom_rate: (30, 1),busy: false,error: String::new(),}@@ -94,11 +108,26 @@ impl StartPane {self.aspect = (index.max(0) as usize).min(ASPECTS.len() - 1);}StartMsg::SizeChanged(index) => {- self.size = (index.max(0) as usize).min(SIZES.len() - 1);+ let index = (index.max(0) as usize).min(SIZES.len());+ if index == SIZES.len() && !self.custom_frame() {+ self.custom_size = self.frame();+ }+ self.size = index;}StartMsg::RateChanged(index) => {- self.rate = (index.max(0) as usize).min(START_RATES.len() - 1);+ let index = (index.max(0) as usize).min(START_RATES.len());+ if index == START_RATES.len() && !self.custom_rate_on() {+ self.custom_rate = self.rate();+ }+ self.rate = index;+ }+ StartMsg::CustomWidth(width) => {+ self.custom_size = custom_frame(width, self.custom_size.1 as f32);+ }+ StartMsg::CustomHeight(height) => {+ self.custom_size = custom_frame(self.custom_size.0 as f32, height);}+ StartMsg::CustomFps(fps) => self.custom_rate = custom_rate(f64::from(fps)),StartMsg::DismissError => self.error.clear(),StartMsg::Browse => {if let Some(folder) =@@ -137,8 +166,8 @@ impl StartPane {} else {name};- let (width, height) = frame_size(self.aspect, self.size);- let (_, num, den) = START_RATES[self.rate.min(START_RATES.len() - 1)];+ let (width, height) = self.frame();+ let (num, den) = self.rate();if self.location.trim().is_empty() {self.error = t("Choose where the project folder should go");return;@@ -181,10 +210,40 @@ impl StartPane {}}+ /// Whether the frame is typed rather than picked.+ fn custom_frame(&self) -> bool {+ self.size >= SIZES.len()+ }++ /// Whether the rate is typed rather than picked.+ fn custom_rate_on(&self) -> bool {+ self.rate >= START_RATES.len()+ }++ /// The frame the sheet describes: the typed one, or the shape at the+ /// size.+ fn frame(&self) -> (u32, u32) {+ if self.custom_frame() {+ self.custom_size+ } else {+ frame_size(self.aspect, self.size)+ }+ }++ /// The rate the sheet describes, as an exact fraction.+ fn rate(&self) -> (i64, i64) {+ if self.custom_rate_on() {+ self.custom_rate+ } else {+ let (_, num, den) = START_RATES[self.rate];+ (num, den)+ }+ }+/// The sheet as Slint shows it.pub fn data(&self) -> StartData {- let (width, height) = frame_size(self.aspect, self.size);- let (_, num, den) = START_RATES[self.rate.min(START_RATES.len() - 1)];+ let (width, height) = self.frame();+ let (num, den) = self.rate();StartData {composing: self.composing,name: self.name.as_str().into(),@@ -193,6 +252,9 @@ impl StartPane {size: self.size as i32,rate: self.rate as i32,size_readout: format!("{width} x {height}").into(),+ custom_width: width as f32,+ custom_height: height as f32,+ custom_fps: fps_of(num, den) as f32,frame_aspect: width as f32 / height.max(1) as f32,rate_readout: format!("{num}/{den} fps").into(),busy: self.busy,diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex bc920a33..1aca5590 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -181,7 +181,12 @@ pub const ASPECTS: [(&str, u32, u32); 4] = [/// and 1080p vertical is 1080 x 1920, the same number of lines either way./// Naming the long edge instead would make a vertical 1080p a 1080 x 1920/// frame at one moment and a 608 x 1080 frame at another.-pub const SIZES: [(&str, u32); 3] = [("720p", 720), ("1080p", 1080), ("4K", 2160)];+pub const SIZES: [(&str, u32); 4] = [+ ("720p", 720),+ ("1080p", 1080),+ ("1440p", 1440),+ ("4K", 2160),+];/// The frame an aspect and a size name, in pixels.///@@ -220,6 +225,77 @@ pub const START_RATES: [(&str, i64, i64); 5] = [("60", 60, 1),];+/// The project sheet's rates: the launch sheet's five and the three a+/// camera also records at, in order. A list, not chips, so it can carry+/// them all; anything else is typed in as a custom rate.+pub const RATES: [(&str, i64, i64); 8] = [+ ("23.976", 24000, 1001),+ ("24", 24, 1),+ ("25", 25, 1),+ ("29.97", 30000, 1001),+ ("30", 30, 1),+ ("50", 50, 1),+ ("59.94", 60000, 1001),+ ("60", 60, 1),+];++/// The smallest and largest side a typed frame may have, in pixels. The+/// floor is a frame that still has a picture in it; the ceiling is 8K,+/// the texture size every GPU the compositor runs on can hold (the wgpu+/// floor), and past what any encoder the export drives will take.+pub const FRAME_SIDES: (u32, u32) = (16, 8192);++/// The slowest and fastest rate that may be typed, in frames a second.+pub const FRAME_RATES: (f64, f64) = (1.0, 240.0);++/// A typed frame as the project can hold it: each side within+/// [`FRAME_SIDES`] and even, rounded to the nearest even number rather+/// than down, so 1081 becomes 1082 and not a frame a line short.+pub fn custom_frame(width: f32, height: f32) -> (u32, u32) {+ let side = |value: f32| {+ let (low, high) = FRAME_SIDES;+ let value = if value.is_finite() { value } else { low as f32 };+ let nearest = ((value / 2.0).round() * 2.0) as i64;+ nearest.clamp(i64::from(low), i64::from(high)) as u32+ };+ (side(width), side(height))+}++/// A typed rate as the exact fraction a project stores. The NTSC rates are+/// the /1001 fractions cameras record at, so 29.97 and 23.976 come out as+/// 30000/1001 and 24000/1001 however they are rounded when typed; anything+/// else is kept to a thousandth, in lowest terms.+pub fn custom_rate(fps: f64) -> (i64, i64) {+ let (low, high) = FRAME_RATES;+ let fps = if fps.is_finite() {+ fps.clamp(low, high)+ } else {+ 30.0+ };+ for whole in [24_i64, 30, 48, 60, 120, 240] {+ let ntsc = whole as f64 * 1000.0 / 1001.0;+ if (fps - ntsc).abs() < 0.006 {+ return (whole * 1000, 1001);+ }+ }+ let num = (fps * 1000.0).round() as i64;+ let divisor = gcd(num, 1000);+ (num / divisor, 1000 / divisor)+}++/// A rate as frames a second, for a field to show.+pub fn fps_of(num: i64, den: i64) -> f64 {+ num as f64 / den.max(1) as f64+}++fn gcd(a: i64, b: i64) -> i64 {+ if b == 0 {+ a.abs().max(1)+ } else {+ gcd(b, a % b)+ }+}+/// What one effect library is showing: the words typed into it, the shelf/// picked, and whether the star is down.///@@ -8372,9 +8448,33 @@ impl Studio {#[cfg(test)]mod tests {use super::{- Command, Footprint, Studio, home_folder, key_commands, place_in, shown, write_keyable,+ Command, Footprint, Studio, custom_frame, custom_rate, fps_of, home_folder, key_commands,+ place_in, shown, write_keyable,};+ /// A typed frame is even on both sides and inside the limits.+ #[test]+ fn a_typed_frame_is_even_and_bounded() {+ assert_eq!(custom_frame(1920.0, 1080.0), (1920, 1080));+ assert_eq!(custom_frame(1081.0, 1079.0), (1082, 1080));+ assert_eq!(custom_frame(3.0, 99999.0), (16, 8192));+ assert_eq!(custom_frame(f32::NAN, -5.0), (16, 16));+ }++ /// A typed rate is the exact fraction: the NTSC ones as cameras record+ /// them, the rest to a thousandth in lowest terms, within the limits.+ #[test]+ fn a_typed_rate_is_an_exact_fraction() {+ assert_eq!(custom_rate(29.97), (30000, 1001));+ assert_eq!(custom_rate(23.976), (24000, 1001));+ assert_eq!(custom_rate(59.94), (60000, 1001));+ assert_eq!(custom_rate(30.0), (30, 1));+ assert_eq!(custom_rate(12.5), (25, 2));+ assert_eq!(custom_rate(0.2), (1, 1));+ assert_eq!(custom_rate(1000.0), (240, 1));+ assert!((fps_of(30000, 1001) - 29.97).abs() < 0.001);+ }+const FRAME: (u32, u32) = (1920, 1080);/// A suggested folder sits under the home directory, with thediff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slintindex 1b8e5777..d29afb2f 100644--- a/src/crates/concat/ui/app.slint+++ b/src/crates/concat/ui/app.slint@@ -136,6 +136,9 @@ export component App inherits Window {callback start-aspect-changed(index: int);callback start-size-changed(index: int);callback start-rate-changed(index: int);+ callback start-custom-width-edited(width: float);+ callback start-custom-height-edited(height: float);+ callback start-custom-fps-edited(fps: float);callback start-create();/// Open a project that already exists, picked from disk.callback start-open();@@ -244,6 +247,9 @@ export component App inherits Window {callback project-name-edited(name: string);callback project-size-changed(index: int);callback project-rate-changed(index: int);+ callback project-custom-width-edited(width: float);+ callback project-custom-height-edited(height: float);+ callback project-custom-fps-edited(fps: float);callback project-apply();/// The two speech sheets: captions from a clip's sound, and a title's@@ -527,6 +533,9 @@ export component App inherits Window {aspect-changed(index) => { root.start-aspect-changed(index); }size-changed(index) => { root.start-size-changed(index); }rate-changed(index) => { root.start-rate-changed(index); }+ custom-width-edited(width) => { root.start-custom-width-edited(width); }+ custom-height-edited(height) => { root.start-custom-height-edited(height); }+ custom-fps-edited(fps) => { root.start-custom-fps-edited(fps); }create => { root.start-create(); }dismiss-error => { root.start-dismiss-error(); }}@@ -607,6 +616,9 @@ export component App inherits Window {name-edited(name) => { root.project-name-edited(name); }size-changed(index) => { root.project-size-changed(index); }rate-changed(index) => { root.project-rate-changed(index); }+ custom-width-edited(width) => { root.project-custom-width-edited(width); }+ custom-height-edited(height) => { root.project-custom-height-edited(height); }+ custom-fps-edited(fps) => { root.project-custom-fps-edited(fps); }apply => { root.project-apply(); }}diff --git a/src/crates/concat/ui/dialogs/project.slint b/src/crates/concat/ui/dialogs/project.slintindex b5d3a08a..907af235 100644--- a/src/crates/concat/ui/dialogs/project.slint+++ b/src/crates/concat/ui/dialogs/project.slint@@ -6,6 +6,7 @@ import { Theme } from "../theme/theme.slint";import { Glyph } from "../icons.slint";import { Button, DialogRow, DialogSection, Field, Modal } from "../primitives/modal.slint";import { Select } from "../primitives/select.slint";+import { NumberField } from "../primitives/number-field.slint";// The project sheet: what the Details panel's Modify button opens.//@@ -21,10 +22,16 @@ export struct ProjectSheetData {/// active one, named so the sheet never looks like it is setting the/// whole project's.timeline: string,- /// Row in the frame list, or -1 for a size the list does not carry.+ /// Row in the frame list; one past its six rows is Custom.size: int,- /// Row in the rate list.+ /// Row in the rate list; one past its eight rows is Custom.rate: int,+ /// The frame and rate as numbers, for the custom fields.+ custom-width: float,+ custom-height: float,+ custom-fps: float,+ /// The rate as the fraction it is kept as: "24000/1001".+ rate-readout: string,}export component ProjectDialog inherits Modal {@@ -33,6 +40,9 @@ export component ProjectDialog inherits Modal {callback name-edited(name: string);callback size-changed(index: int);callback rate-changed(index: int);+ callback custom-width-edited(width: float);+ callback custom-height-edited(height: float);+ callback custom-fps-edited(fps: float);callback apply();open: root.data.open;@@ -71,27 +81,86 @@ export component ProjectDialog inherits Modal {// The same six frames the monitor's picker offers, in the same// order, so the two controls can never disagree about what a- // row means.+ // row means; then Custom, for any frame at all.DialogRow {label: I18n.t("Frame");Select {current: root.data.size;- placeholder: I18n.t("Custom");options: ["1920 × 1080", "3840 × 2160", "1080 × 1920",- "1080 × 1080", "1440 × 1080", "2560 × 1080"];- details: ["16:9", "16:9 4K", "9:16", "1:1", "4:3", "21:9"];+ "1080 × 1080", "1440 × 1080", "2560 × 1080", I18n.t("Custom")];+ details: ["16:9", "16:9 4K", "9:16", "1:1", "4:3", "21:9", ""];changed(index) => { root.size-changed(index); }}}+ // Each side even and within 16 to 8192: Rust rounds what is+ // typed to the nearest frame the project can hold.+ if root.data.size == 6: DialogRow {+ HorizontalLayout {+ spacing: 8px;++ NumberField {+ value: root.data.custom-width;+ minimum: 16;+ maximum: 8192;+ step: 2;+ unit: "W";+ changed(value) => { root.custom-width-edited(value); }+ }++ Text {+ text: "×";+ color: Theme.fg-dim;+ vertical-alignment: center;+ }++ NumberField {+ value: root.data.custom-height;+ minimum: 16;+ maximum: 8192;+ step: 2;+ unit: "H";+ changed(value) => { root.custom-height-edited(value); }+ }+ }+ }+DialogRow {label: I18n.t("Frame rate");Select {current: root.data.rate;- options: ["24 fps", "25 fps", "29.97 fps", "30 fps", "60 fps"];+ options: ["23.976 fps", "24 fps", "25 fps", "29.97 fps", "30 fps",+ "50 fps", "59.94 fps", "60 fps", I18n.t("Custom")];changed(index) => { root.rate-changed(index); }}}++ // From 1 to 240, kept as the exact fraction beside it: 23.976+ // is 24000/1001, as a camera records it.+ if root.data.rate == 8: DialogRow {+ HorizontalLayout {+ spacing: 10px;++ NumberField {+ value: root.data.custom-fps;+ minimum: 1;+ maximum: 240;+ step: 1;+ precision: 3;+ unit: "fps";+ changed(value) => { root.custom-fps-edited(value); }+ }++ Text {+ horizontal-stretch: 0;+ text: root.data.rate-readout;+ color: Theme.fg-dim;+ font-family: Theme.font-technical;+ font-size: Theme.fs-sm;+ vertical-alignment: center;+ }+ }+ }}Rectangle {diff --git a/src/crates/concat/ui/start.slint b/src/crates/concat/ui/start.slintindex 15a689e1..e12f3be5 100644--- a/src/crates/concat/ui/start.slint+++ b/src/crates/concat/ui/start.slint@@ -9,6 +9,7 @@ import { Glyph, Icon } from "icons.slint";import { ThinScrollbar } from "primitives/scrollbar.slint";import { Tip } from "primitives/tooltip.slint";import { Focus } from "util.slint";+import { NumberField } from "primitives/number-field.slint";// The launch screen: a launcher with a rail, and the window's own ground// under all of it — no card around the whole thing, no shadow. A setup@@ -103,6 +104,12 @@ export struct StartData {rate: int,/// "1920 x 1080"size-readout: string,+ /// The frame and rate as numbers, for the custom fields: the typed+ /// ones when Custom is picked, the preset's otherwise, so picking+ /// Custom starts the fields from the frame that was showing.+ custom-width: float,+ custom-height: float,+ custom-fps: float,/// The chosen frame's width over its height, for the swatch beside the/// readout that shows its shape: 1.78 for landscape HD, 0.56 upright.frame-aspect: float,@@ -341,6 +348,10 @@ component Chip inherits Rectangle {// which answer it is on.component ChipRow inherits Rectangle {in property <[ChipOption]> options;+ /// A last chip after the options, at index `options.length`: Custom,+ /// on the rows that can be typed. Named here rather than carried in+ /// `options` so its word is translated where it is drawn.+ in property <string> extra;in property <int> current;in property <bool> enabled: true;/// The chips share the width rather than take their own: the phone@@ -350,11 +361,12 @@ component ChipRow inherits Rectangle {callback changed(index: int);property <bool> ring;+ property <int> count: root.options.length + (root.extra != "" ? 1 : 0);height: 32px;function select(index: int) {- if (index >= 0 && index < root.options.length) {+ if (index >= 0 && index < root.count) {root.changed(index);}}@@ -370,12 +382,11 @@ component ChipRow inherits Rectangle {}key-pressed(event) => {if (event.text == Key.RightArrow || event.text == Key.DownArrow) {- root.select(Math.mod(root.current + 1, root.options.length));+ root.select(Math.mod(root.current + 1, root.count));return EventResult.accept;}if (event.text == Key.LeftArrow || event.text == Key.UpArrow) {- root.select(Math.mod(root.current - 1 + root.options.length,- root.options.length));+ root.select(Math.mod(root.current - 1 + root.count, root.count));return EventResult.accept;}return EventResult.reject;@@ -398,6 +409,18 @@ component ChipRow inherits Rectangle {root.select(index);}}++ if root.extra != "": Chip {+ label: root.extra;+ selected: root.current == root.options.length;+ enabled: root.enabled;+ block: root.block;+ ring: root.ring && root.current == root.options.length;+ clicked => {+ fs.focus();+ root.select(root.options.length);+ }+ }}}@@ -1102,6 +1125,9 @@ export component NewProjectDialog inherits Modal {callback aspect-changed(index: int);callback size-changed(index: int);callback rate-changed(index: int);+ callback custom-width-edited(width: float);+ callback custom-height-edited(height: float);+ callback custom-fps-edited(fps: float);callback create();callback dismiss-error();@@ -1119,9 +1145,9 @@ export component NewProjectDialog inherits Modal {// sheet dismissed out from under a create is a create nobody hears// about.dismissable: !root.data.busy;- // Wide enough for five rates and their readout beside an 84px label,- // and no wider than the window less a margin, on a phone.- surface-width: Math.min(600px, root.width - 32px);+ // Wide enough for five rates, Custom and their readout beside an 84px+ // label, and no wider than the window less a margin, on a phone.+ surface-width: Math.min(640px, root.width - 32px);// The caret goes to the name each time the sheet comes up, with the// name selected, so the default is replaced by typing over it. From@@ -1210,7 +1236,8 @@ export component NewProjectDialog inherits Modal {horizontal-stretch: 1;options: root.aspects;current: root.data.aspect;- enabled: !root.data.busy;+ // A typed frame is its own shape.+ enabled: !root.data.busy && root.data.size < root.sizes.length;block: root.narrow;changed(index) => { root.aspect-changed(index); }}@@ -1233,26 +1260,66 @@ export component NewProjectDialog inherits Modal {label: I18n.upper("Size");stacked: root.narrow;- HorizontalLayout {- spacing: 16px;+ VerticalLayout {+ spacing: 10px;- ChipRow {- horizontal-stretch: 1;- options: root.sizes;- current: root.data.size;- enabled: !root.data.busy;- block: root.narrow;- changed(index) => { root.size-changed(index); }+ HorizontalLayout {+ spacing: 16px;++ ChipRow {+ horizontal-stretch: 1;+ options: root.sizes;+ extra: I18n.t("Custom");+ current: root.data.size;+ enabled: !root.data.busy;+ block: root.narrow;+ changed(index) => { root.size-changed(index); }+ }++ VerticalLayout {+ alignment: center;+ horizontal-stretch: 0;+ Text {+ text: root.data.size-readout;+ color: Theme.fg-dim;+ font-family: Theme.font-technical;+ font-size: Theme.fs-sm;+ }+ }}- VerticalLayout {- alignment: center;- horizontal-stretch: 0;+ // The typed frame: width by height, each side even and+ // within 16 to 8192, which Rust rounds a typed number to.+ if root.data.size == root.sizes.length: HorizontalLayout {+ spacing: 8px;+ alignment: start;++ NumberField {+ width: 96px;+ value: root.data.custom-width;+ minimum: 16;+ maximum: 8192;+ step: 2;+ unit: "W";+ enabled: !root.data.busy;+ changed(value) => { root.custom-width-edited(value); }+ }+Text {- text: root.data.size-readout;+ text: "×";color: Theme.fg-dim;- font-family: Theme.font-technical;- font-size: Theme.fs-sm;+ vertical-alignment: center;+ }++ NumberField {+ width: 96px;+ value: root.data.custom-height;+ minimum: 16;+ maximum: 8192;+ step: 2;+ unit: "H";+ enabled: !root.data.busy;+ changed(value) => { root.custom-height-edited(value); }}}}@@ -1263,26 +1330,49 @@ export component NewProjectDialog inherits Modal {last: true;stacked: root.narrow;- HorizontalLayout {- spacing: 16px;+ VerticalLayout {+ spacing: 10px;- ChipRow {- horizontal-stretch: 1;- options: root.rates;- current: root.data.rate;- enabled: !root.data.busy;- block: root.narrow;- changed(index) => { root.rate-changed(index); }+ HorizontalLayout {+ spacing: 16px;++ ChipRow {+ horizontal-stretch: 1;+ options: root.rates;+ extra: I18n.t("Custom");+ current: root.data.rate;+ enabled: !root.data.busy;+ block: root.narrow;+ changed(index) => { root.rate-changed(index); }+ }++ VerticalLayout {+ alignment: center;+ horizontal-stretch: 0;+ Text {+ text: root.data.rate-readout;+ color: Theme.fg-dim;+ font-family: Theme.font-technical;+ font-size: Theme.fs-sm;+ }+ }}- VerticalLayout {- alignment: center;- horizontal-stretch: 0;- Text {- text: root.data.rate-readout;- color: Theme.fg-dim;- font-family: Theme.font-technical;- font-size: Theme.fs-sm;+ // The typed rate, from 1 to 240. The readout above says the+ // fraction it is kept as: 23.976 is 24000/1001.+ if root.data.rate == root.rates.length: HorizontalLayout {+ alignment: start;++ NumberField {+ width: 112px;+ value: root.data.custom-fps;+ minimum: 1;+ maximum: 240;+ step: 1;+ precision: 3;+ unit: "fps";+ enabled: !root.data.busy;+ changed(value) => { root.custom-fps-edited(value); }}}}