Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

Text presets: nine looks on the Text page, and a folder that adds more

Jareer1c9949dab979
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 9b470947..968852fa 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -566,7 +566,13 @@ object moved. `dock.rs` is the workspace tree, addressed by path rather
than index, with a default of library beside preview-over-inspector,
above the timeline. `chips.rs` draws drag chips as SVG so Slint rasterises
them with the window's fonts at the window's scale. `prefs.rs` is a small
-JSON file of remembered choices. `sysinfo.rs` gathers one list of facts
+JSON file of remembered choices. `presets.rs` is the Text page's looks: the
+built-in ones, a folder of TOML files that adds more, and the font
+installer that copies a preset's face into the app's `fonts/` once and
+registers it on the project the first time the preset is placed. The
+sheets - export, settings, the project's own facts, captions and speech -
+are structs on the studio published whole, the way the export sheet always
+was, each with its worker reporting into it through `on_ui`. `sysinfo.rs` gathers one list of facts
that feeds both the About rows and the copyable block, so a fact cannot be
on the page and missing from the report. Fonts, the logo and the effect
previews are embedded by `build.rs`.
@@ -704,6 +710,13 @@ loudly.
maximum. Nothing in Rust changes.
- **A new pane.** A `PaneKind`, its entry in the `Panes` global, a branch
in `Seat`, and the `Editor` properties and callbacks it needs.
+- **A new text preset.** A TOML file under the config directory's
+ `text-presets/`, or a folder there with `preset.toml` and the font
+ beside it; the format is at the top of `concat/src/presets.rs`. Nothing
+ in Rust changes.
+- **A new keyboard chord.** A line in the key table in `app.slint` that
+ names a verb, and the verb's arm in `Studio::shortcut` - or, for a chord
+ that is also a menu row, the row's id, so the two stay one thing.
- **A new decode or encode backend.** Implement `FrameSource` or
`FrameSink` in `concat-media`. Nothing else in the workspace changes.
- **A new platform.** `platform.rs` for the window's three seams,
diff --git a/TODO.MD b/TODO.MD
index 975405f6..54b42ca6 100644
--- a/TODO.MD
+++ b/TODO.MD
@@ -9,7 +9,7 @@ DO NOT DELETE ANY OF THE TODOs, JUST MARK THEM DONE.
- feature: add langauge support locales and fast i18n support. Locales live in editable json files.
- [x] in Library>Media panel: the audio waveform pattern has padding/margin on the x-axis which should be removed. we need the waveform pattern to start at the very begining of the audio preview card.
- [x] The timeline tools tray needs a revamp, a lot of people wont be able to find tools like Text to Speech if they are placed in tabs in File (macOS). We need to show more tools (or dropdowns) on the Timeline tools tray. _(Captions, Speak and Detach audio sit on the tray with names; greyed with a reason when the selection cannot use them.)_
-- [ ] We need to add texts presets. In Library>Text, create a new tab/dropdown under Text in the sidebar called Presets where pre-designed Texts profiles/configs are shown and can be used immediately. Text profiles use typography settings like font, size, etc. For font we create a consistent/idempotent copy where if a Text preset is distributed openly among the users/community the "Installer" checks if the new text preset-profile font is already cached/installed/imported for used in Concat, else it installs the font bundled with the Text preset/profile. Each profile has a unique name/identifier.
+- [x] We need to add texts presets. In Library>Text, create a new tab/dropdown under Text in the sidebar called Presets where pre-designed Texts profiles/configs are shown and can be used immediately. Text profiles use typography settings like font, size, etc. For font we create a consistent/idempotent copy where if a Text preset is distributed openly among the users/community the "Installer" checks if the new text preset-profile font is already cached/installed/imported for used in Concat, else it installs the font bundled with the Text preset/profile. Each profile has a unique name/identifier. _(Library › Text › Presets: nine built-in looks, each card drawn in its own style; click places at the playhead, drag places on a lane. Community presets are TOML files under the app's `text-presets/` folder (macOS: ~/Library/Application Support/app.concat.editor/text-presets), a folder per preset with its font beside it; the font is copied into the app's `fonts/` once and registered on the project the first time the preset is used. Format documented at the top of engine/crates/concat/src/presets.rs.)_
- [x] In Library>Transitions>Basic: use the same light/thinner font-weight as Transitions>Motion.
- [x] Remove the "Concat" watermark from the bottom-left of the Preview. _(That corner showed the name of the clip under the playhead; it no longer does.)_
- [x] Add basic CapCut-like keybinds to the app. Like for delete, CTRL+B to toggle split tool, etc. _(⌘B split all at playhead · S split selected · A/V select · B razor toggle · N snap · M mute · Delete/Backspace · ⌘A select all · ⌘C/⌘V/⌘D · ⌘E export · ⌘I import · ⌘, settings · ⌘+/⌘- zoom · Home/End · ←/→ a frame, ⇧ ten.)_
diff --git a/engine/Cargo.lock b/engine/Cargo.lock
index f9aa0c63..f868a507 100644
--- a/engine/Cargo.lock
+++ b/engine/Cargo.lock
@@ -1130,6 +1130,7 @@ dependencies = [
"serde_json",
"slint",
"slint-build",
+ "toml",
"wgpu",
]
diff --git a/engine/crates/concat/Cargo.toml b/engine/crates/concat/Cargo.toml
index 5c192cc8..6e3499f7 100644
--- a/engine/crates/concat/Cargo.toml
+++ b/engine/crates/concat/Cargo.toml
@@ -97,6 +97,8 @@ concat-effects.workspace = true
# Remembered preferences, as a small JSON file in the config directory.
serde = { version = "1", features = ["derive"] }
serde_json.workspace = true
+# Text presets are TOML files, as the effect manifests are.
+toml = "1.1"
# The renderer is picked by a feature here rather than by editing the
# dependency, so both variants build from one tree and can be compared:
diff --git a/engine/crates/concat/src/lib.rs b/engine/crates/concat/src/lib.rs
index c4add212..7ec53797 100644
--- a/engine/crates/concat/src/lib.rs
+++ b/engine/crates/concat/src/lib.rs
@@ -38,6 +38,7 @@ mod gpu;
mod host;
mod platform;
mod prefs;
+mod presets;
mod studio;
mod sysinfo;
@@ -107,6 +108,7 @@ pub fn run() -> Result<(), slint::PlatformError> {
editor.set_seats(ModelRc::from(models.seats.clone()));
editor.set_dividers(ModelRc::from(models.dividers.clone()));
app.set_recents(ModelRc::from(models.recents.clone()));
+ editor.set_text_presets(ModelRc::from(models.text_presets.clone()));
}
// Settings > About's block, gathered once: nothing in it changes while
@@ -372,8 +374,8 @@ pub fn run() -> Result<(), slint::PlatformError> {
editor.on_media_activate(on_window!(|state, id: i32| {
state.place_at_playhead(&format!("media:{id}"));
}));
- editor.on_library_add_text(on_window!(|state| {
- state.place_at_playhead("text:default:Title");
+ editor.on_library_add_text(on_window!(|state, preset: SharedString| {
+ state.place_at_playhead(&format!("text:{preset}:Title"));
}));
// A filter is a colour look on the picture; audio is the sound's chain.
editor.on_library_apply_filter(on_window!(
@@ -1020,7 +1022,7 @@ pub fn run() -> Result<(), slint::PlatformError> {
}
// A timeline tab in flight wears the timeline pane's mark.
if let Some(rest) = payload.strip_prefix("tab:") {
- let name = rest.splitn(2, ':').nth(1).unwrap_or_default();
+ let name = rest.split_once(':').map_or("", |(_, name)| name);
let chip = slint::Image::load_from_svg_data(
chips::drag_chip_svg(
chips::pane_glyph("timeline"),
diff --git a/engine/crates/concat/src/presets.rs b/engine/crates/concat/src/presets.rs
new file mode 100644
index 00000000..a459a42e
--- /dev/null
+++ b/engine/crates/concat/src/presets.rs
@@ -0,0 +1,350 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! Text presets: a title's look, named, that the library's Text page
+//! offers as a card. The built-in ones ship in the binary; a folder of
+//! TOML files beside the app's settings adds more, and a preset shared
+//! between people travels as a folder with its font inside.
+//!
+//! A preset file, `text-presets/<anything>.toml` or
+//! `text-presets/<anything>/preset.toml` under the config directory:
+//!
+//! ```toml
+//! id = "studio.big-red" # unique for ever: project files store it
+//! name = "Big Red"
+//! font = "BigRed.ttf" # optional: a file beside this one
+//! offsetY = 0.3 # optional: a frame-height fraction from centre
+//!
+//! [style] # any of a title's fields; the rest default
+//! fontFamily = "Big Red"
+//! fontSize = 0.1
+//! fontWeight = 700
+//! color = "#ff0000"
+//! strokeColor = "#000000"
+//! strokeWidth = 0.01
+//! align = "center"
+//! ```
+//!
+//! The font is installed when the preset is first used, not when it is
+//! read: copied once into the app's own `fonts/` folder if it is not there
+//! already, and registered on the project so the title painter finds it.
+//! A preset used on two machines therefore renders the same on both, and
+//! a project carries the font's path the way it carries any font added by
+//! hand.
+
+use std::path::{Path, PathBuf};
+
+use concat_host::AppDirs;
+use concat_project::model::{TextAlign, TextStyle};
+use serde::Deserialize;
+
+/// One look a title can be given.
+pub struct TextPreset {
+ /// Stable for ever; "default" is the plain title.
+ pub id: String,
+ pub name: String,
+ /// The look, with `content` as the words the card places.
+ pub style: TextStyle,
+ /// Where the title sits, as a frame-height fraction from the centre,
+ /// when the preset has an opinion - a lower third does.
+ pub offset_y: Option<f64>,
+ /// A font file the preset brings with it, resolved to a path.
+ pub font: Option<PathBuf>,
+}
+
+#[derive(Deserialize)]
+#[serde(rename_all = "camelCase")]
+struct PresetFile {
+ id: String,
+ name: String,
+ #[serde(default)]
+ font: Option<String>,
+ #[serde(default)]
+ offset_y: Option<f64>,
+ #[serde(default)]
+ style: PresetStyle,
+}
+
+/// A title's fields, every one optional, laid over the default style.
+#[derive(Deserialize, Default)]
+#[serde(rename_all = "camelCase")]
+struct PresetStyle {
+ content: Option<String>,
+ font_family: Option<String>,
+ font_size: Option<f64>,
+ font_weight: Option<f64>,
+ italic: Option<bool>,
+ color: Option<String>,
+ align: Option<String>,
+ opacity: Option<f64>,
+ stroke_width: Option<f64>,
+ stroke_color: Option<String>,
+ shadow: Option<bool>,
+ background: Option<String>,
+ line_height: Option<f64>,
+ tracking: Option<f64>,
+}
+
+impl PresetStyle {
+ fn over(self, name: &str) -> TextStyle {
+ let base = TextStyle::default();
+ TextStyle {
+ content: self.content.unwrap_or_else(|| name.to_owned()),
+ font_family: self.font_family.unwrap_or_else(|| "Inter".to_owned()),
+ font_size: self.font_size.unwrap_or(base.font_size).clamp(0.005, 1.0),
+ font_weight: self
+ .font_weight
+ .unwrap_or(base.font_weight)
+ .clamp(100.0, 900.0),
+ italic: self.italic.unwrap_or(false),
+ color: self.color.unwrap_or(base.color),
+ align: match self.align.as_deref() {
+ Some("left") => TextAlign::Left,
+ Some("right") => TextAlign::Right,
+ _ => TextAlign::Center,
+ },
+ opacity: self.opacity.unwrap_or(1.0).clamp(0.0, 1.0),
+ stroke_width: self.stroke_width.unwrap_or(0.0).max(0.0),
+ stroke_color: self.stroke_color.unwrap_or(base.stroke_color),
+ shadow: self.shadow.unwrap_or(true),
+ background: self.background.unwrap_or_default(),
+ line_height: self.line_height.unwrap_or(base.line_height).max(0.5),
+ tracking: self.tracking.unwrap_or(0.0),
+ }
+ }
+}
+
+/// Where the user's presets live.
+pub fn dir(dirs: &AppDirs) -> PathBuf {
+ dirs.config.join("text-presets")
+}
+
+/// The presets that ship with the app.
+pub fn builtin() -> Vec<TextPreset> {
+ let look = |id: &str, name: &str, style: TextStyle, offset_y: Option<f64>| TextPreset {
+ id: id.to_owned(),
+ name: name.to_owned(),
+ style,
+ offset_y,
+ font: None,
+ };
+ let inter = |content: &str, weight: f64, size: f64| TextStyle {
+ content: content.to_owned(),
+ font_family: "Inter".to_owned(),
+ font_weight: weight,
+ font_size: size,
+ ..TextStyle::default()
+ };
+ vec![
+ look("default", "Title", inter("New title", 600.0, 0.09), None),
+ look(
+ "concat.headline",
+ "Headline",
+ TextStyle {
+ stroke_width: 0.008,
+ ..inter("Headline", 700.0, 0.12)
+ },
+ None,
+ ),
+ look(
+ "concat.subtitle",
+ "Subtitle",
+ TextStyle {
+ background: "#000000b3".to_owned(),
+ shadow: false,
+ ..inter("Subtitle", 500.0, 0.045)
+ },
+ Some(0.36),
+ ),
+ look(
+ "concat.lower-third",
+ "Lower third",
+ TextStyle {
+ color: "#10160a".to_owned(),
+ background: "#c6f432".to_owned(),
+ align: TextAlign::Left,
+ shadow: false,
+ ..inter("Name — Title", 600.0, 0.05)
+ },
+ Some(0.32),
+ ),
+ look(
+ "concat.caption",
+ "Caption",
+ TextStyle {
+ color: "#ffe14a".to_owned(),
+ stroke_width: 0.006,
+ ..inter("Caption", 600.0, 0.05)
+ },
+ Some(0.35),
+ ),
+ look(
+ "concat.elegant",
+ "Elegant",
+ TextStyle {
+ font_family: "Synonym".to_owned(),
+ italic: true,
+ tracking: 0.01,
+ shadow: false,
+ ..inter("Elegant", 400.0, 0.08)
+ },
+ None,
+ ),
+ look(
+ "concat.neon",
+ "Neon",
+ TextStyle {
+ color: "#c6f432".to_owned(),
+ stroke_color: "#1c3b06".to_owned(),
+ stroke_width: 0.006,
+ ..inter("Neon", 700.0, 0.1)
+ },
+ None,
+ ),
+ look(
+ "concat.outline",
+ "Outline",
+ TextStyle {
+ stroke_width: 0.012,
+ shadow: false,
+ ..inter("Outline", 700.0, 0.11)
+ },
+ None,
+ ),
+ look(
+ "concat.minimal",
+ "Minimal",
+ TextStyle {
+ tracking: 0.03,
+ shadow: false,
+ ..inter("Minimal", 400.0, 0.06)
+ },
+ None,
+ ),
+ ]
+}
+
+/// The presets in the user's folder. A file that does not parse is
+/// skipped: one broken preset should not empty the page.
+pub fn user(dirs: &AppDirs) -> Vec<TextPreset> {
+ let mut found = Vec::new();
+ let Ok(entries) = std::fs::read_dir(dir(dirs)) else {
+ return found;
+ };
+ let mut paths: Vec<PathBuf> = entries
+ .flatten()
+ .map(|entry| entry.path())
+ .filter_map(|path| {
+ if path.is_dir() {
+ let inner = path.join("preset.toml");
+ inner.is_file().then_some(inner)
+ } else {
+ (path.extension().and_then(|e| e.to_str()) == Some("toml")).then_some(path)
+ }
+ })
+ .collect();
+ paths.sort();
+ for path in paths {
+ if let Some(preset) = read(&path) {
+ found.push(preset);
+ }
+ }
+ found
+}
+
+fn read(path: &Path) -> Option<TextPreset> {
+ let text = std::fs::read_to_string(path).ok()?;
+ let file: PresetFile = toml::from_str(&text).ok()?;
+ let id = file.id.trim().to_owned();
+ if id.is_empty() {
+ return None;
+ }
+ let font = file
+ .font
+ .filter(|name| !name.trim().is_empty())
+ .map(|name| path.parent().unwrap_or(Path::new(".")).join(name.trim()));
+ Some(TextPreset {
+ name: if file.name.trim().is_empty() {
+ id.clone()
+ } else {
+ file.name.trim().to_owned()
+ },
+ id,
+ style: file.style.over(&file.name),
+ offset_y: file.offset_y,
+ font,
+ })
+}
+
+/// Every preset the page offers: the built-in ones, then the user's. A
+/// user preset with a built-in id replaces it, which is how a look can be
+/// overridden without a second card for it.
+pub fn all(dirs: &AppDirs) -> Vec<TextPreset> {
+ let mut presets = builtin();
+ for preset in user(dirs) {
+ match presets.iter().position(|held| held.id == preset.id) {
+ Some(index) => presets[index] = preset,
+ None => presets.push(preset),
+ }
+ }
+ presets
+}
+
+/// Puts the preset's font where the app keeps fonts, if it is not there
+/// already, and says how to register it: the family the style names and
+/// the installed file. None for a preset that brings no font, or whose
+/// file cannot be read.
+pub fn install_font(dirs: &AppDirs, preset: &TextPreset) -> Option<(String, String)> {
+ let source = preset.font.as_ref().filter(|path| path.is_file())?;
+ let name = source.file_name()?;
+ let fonts = dirs.config.join("fonts");
+ let installed = fonts.join(name);
+ if !installed.is_file() {
+ std::fs::create_dir_all(&fonts).ok()?;
+ std::fs::copy(source, &installed).ok()?;
+ }
+ let family = preset.style.font_family.trim().trim_matches('"').to_owned();
+ if family.is_empty() {
+ return None;
+ }
+ Some((family, installed.to_string_lossy().into_owned()))
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn built_in_ids_are_unique_and_the_plain_title_is_first() {
+ let presets = builtin();
+ assert_eq!(presets[0].id, "default");
+ for (index, preset) in presets.iter().enumerate() {
+ assert!(
+ !presets[..index].iter().any(|held| held.id == preset.id),
+ "{} twice",
+ preset.id
+ );
+ }
+ }
+
+ #[test]
+ fn a_partial_style_lays_over_the_default() {
+ let file: PresetFile = toml::from_str(
+ r##"
+ id = "t.red"
+ name = "Red"
+ offsetY = 0.3
+ [style]
+ color = "#ff0000"
+ align = "left"
+ "##,
+ )
+ .expect("parses");
+ let style = file.style.over(&file.name);
+ assert_eq!(style.color, "#ff0000");
+ assert_eq!(style.align, TextAlign::Left);
+ assert_eq!(style.content, "Red");
+ assert_eq!(style.font_weight, TextStyle::default().font_weight);
+ assert_eq!(file.offset_y, Some(0.3));
+ }
+}
diff --git a/engine/crates/concat/src/studio.rs b/engine/crates/concat/src/studio.rs
index b01ec738..d67aed25 100644
--- a/engine/crates/concat/src/studio.rs
+++ b/engine/crates/concat/src/studio.rs
@@ -45,6 +45,7 @@ use crate::format::{
};
use crate::host::{Host, MediaArt, image_at, image_of, media_art, on_ui, spawn};
use crate::prefs::Preferences;
+use crate::presets::{self, TextPreset};
use crate::ui::*;
/// The monitor's output sizes, matching the picker's rows.
@@ -490,6 +491,8 @@ pub struct Models {
pub seats: Rc<VecModel<SeatBox>>,
pub dividers: Rc<VecModel<DockDivider>>,
pub recents: Rc<VecModel<RecentProjectData>>,
+ /// The Text page's presets, published once from the loaded list.
+ pub text_presets: Rc<VecModel<TextPresetData>>,
}
impl Models {
@@ -525,6 +528,7 @@ impl Models {
seats: Rc::new(VecModel::default()),
dividers: Rc::new(VecModel::default()),
recents: Rc::new(VecModel::default()),
+ text_presets: Rc::new(VecModel::default()),
}
}
}
@@ -650,6 +654,8 @@ pub struct Studio {
pub speech: SpeechSheet,
/// Every speaker the voice engine offers, in its own order.
pub speakers: Vec<concat_speech::tts::VoiceInfo>,
+ /// The looks the Text page offers; see `presets`.
+ pub text_presets: Vec<TextPreset>,
}
// ── conversions between the document and the window ─────────────────────
@@ -953,6 +959,7 @@ impl Studio {
pub fn new(host: Host) -> Self {
let prefs = Preferences::load(&host.dirs);
let recents = projects::list(&host.dirs.config);
+ let text_presets = presets::all(&host.dirs);
let mut studio = Self {
prefs,
session: None,
@@ -1013,6 +1020,7 @@ impl Studio {
captions: CaptionsSheet::default(),
speech: SpeechSheet::default(),
speakers: Vec::new(),
+ text_presets,
host,
};
studio.settings.language = studio.prefs.language.unwrap_or(0);
@@ -1751,10 +1759,12 @@ impl Studio {
row: 0,
})
}
+ // A title: the preset's id rides where a file's media id would,
+ // "default" for the plain one.
"text" => Some(DropPlan {
kind: ClipKind::Text,
label: label.to_owned(),
- media: String::new(),
+ media: id.to_owned(),
start: 0.0,
duration: LAYER_DURATION,
row: 0,
@@ -1799,13 +1809,12 @@ impl Studio {
return;
};
let created = if plan.kind == ClipKind::Text {
- self.apply(Command::AddTextClip {
- track_id: Some(track_id),
- start: f64::from(plan.start),
- style: Some(new_title_style()),
- duration: Some(f64::from(plan.duration)),
- offset_y: None,
- })
+ self.add_title(
+ Some(track_id),
+ f64::from(plan.start),
+ f64::from(plan.duration),
+ &plan.media,
+ )
} else if plan.kind == ClipKind::Filter {
self.apply(Command::AddLayerClip {
track_id: Some(track_id),
@@ -1834,13 +1843,7 @@ impl Studio {
};
let start = f64::from(self.playhead.max(0.0));
let created = if plan.kind == ClipKind::Text {
- self.apply(Command::AddTextClip {
- track_id: None,
- start,
- style: Some(new_title_style()),
- duration: Some(f64::from(plan.duration)),
- offset_y: None,
- })
+ self.add_title(None, start, f64::from(plan.duration), &plan.media)
} else if plan.kind == ClipKind::Filter {
self.apply(Command::AddLayerClip {
track_id: None,
@@ -1860,6 +1863,41 @@ impl Studio {
}
}
+ /// Places a title in the look a preset names - "default" for the plain
+ /// title - and, when the preset brings a font, registers the font on
+ /// the project in the same step, so the painter finds it the first
+ /// time it draws the words.
+ fn add_title(
+ &mut self,
+ track_id: Option<String>,
+ start: f64,
+ duration: f64,
+ preset: &str,
+ ) -> Option<String> {
+ let (style, offset_y, font) = match self.text_presets.iter().find(|held| held.id == preset)
+ {
+ Some(found) => (
+ found.style.clone(),
+ found.offset_y,
+ presets::install_font(&self.host.dirs, found),
+ ),
+ None => (new_title_style(), None, None),
+ };
+ let add = Command::AddTextClip {
+ track_id,
+ start,
+ style: Some(style),
+ duration: Some(duration),
+ offset_y,
+ };
+ match font {
+ Some((family, path)) => self.apply(Command::Batch {
+ commands: vec![Command::AddFont { family, path }, add],
+ }),
+ None => self.apply(add),
+ }
+ }
+
/// The selected clip's id, when exactly one is selected.
pub fn sole_selection(&self) -> Option<String> {
(self.selection.len() == 1).then(|| self.selection[0].clone())
@@ -4495,6 +4533,31 @@ impl Studio {
.collect(),
);
+ // The Text page's presets: the look each card draws its name in.
+ sync(
+ &models.text_presets,
+ self.text_presets
+ .iter()
+ .map(|preset| {
+ let plate = colour_of(&preset.style.background);
+ TextPresetData {
+ id: preset.id.as_str().into(),
+ name: preset.name.as_str().into(),
+ family: preset.style.font_family.trim_matches('"').into(),
+ weight: preset.style.font_weight.round() as i32,
+ italic: preset.style.italic,
+ fill: colour_of(&preset.style.color),
+ plate,
+ plated: plate.alpha() > 0,
+ stroke: colour_of(&preset.style.stroke_color),
+ stroke_width: preset.style.stroke_width as f32,
+ size: preset.style.font_size as f32,
+ align: align_of(preset.style.align),
+ }
+ })
+ .collect(),
+ );
+
// The bin.
let filter = self.media_filter;
let items = &self.project().media;
diff --git a/engine/crates/concat/ui/app.slint b/engine/crates/concat/ui/app.slint
index ffe1f6a2..20876a1a 100644
--- a/engine/crates/concat/ui/app.slint
+++ b/engine/crates/concat/ui/app.slint
@@ -19,7 +19,7 @@ import "fonts/Synonym-SemiBold.ttf";
import { Theme } from "theme/theme.slint";
import { Bezier, Curves, Fmt, Payload } from "util.slint";
import { EffectData } from "demo/effects-panel.slint";
-import { MediaFilter, MediaItemData, MediaKind } from "workspace/media-pane.slint";
+import { MediaFilter, MediaItemData, MediaKind, TextPresetData } from "workspace/media-pane.slint";
import { ContextMenu, MenuItemData, MenuRow } from "primitives/context-menu.slint";
import { ExportData, ExportDialog, ExportPhase } from "dialogs/export.slint";
import { ModelData, SettingsData, SettingsDialog, SystemFactData } from "dialogs/settings.slint";
@@ -49,7 +49,7 @@ export {
Curves, Fmt, Payload, Theme, Bezier, Editor,
AppliedEntryData, AppliedParamData, CatalogueEntryData, ParamFormat,
DockDivider, DockSide, PaneKind, SeatBox,
- EffectData, MediaFilter, MediaItemData, MediaKind,
+ EffectData, MediaFilter, MediaItemData, MediaKind, TextPresetData,
ClipData, ClipField, ClipKind, ClipTextField, DropData, SelectedClipData,
StageGuideData, StageItemData, TextAlignment, TimelineTabData, TimelineTool,
TrackData, TrackSize, MenuItemData, MenuRow, ExportData, ExportPhase, ModelData, SettingsData,
diff --git a/engine/crates/concat/ui/editor.slint b/engine/crates/concat/ui/editor.slint
index 3f9388c1..57779aa8 100644
--- a/engine/crates/concat/ui/editor.slint
+++ b/engine/crates/concat/ui/editor.slint
@@ -5,7 +5,7 @@ import { EffectData } from "demo/effects-panel.slint";
import {
AppliedEntryData, AppliedParamData, CatalogueEntryData,
} from "inspector/clip-inspector.slint";
-import { MediaFilter, MediaItemData } from "workspace/media-pane.slint";
+import { MediaFilter, MediaItemData, TextPresetData } from "workspace/media-pane.slint";
import { DockDivider, DockSide, SeatBox } from "dock.slint";
import { PaneKind } from "workspace/pane-switcher.slint";
import { MenuItemData } from "primitives/context-menu.slint";
@@ -86,7 +86,11 @@ export global Editor {
callback media-activate(id: int);
// library catalogue pages
- callback library-add-text();
+ /// The looks the Text page offers, published once.
+ in-out property <[TextPresetData]> text-presets;
+ /// A title placed at the playhead in the look `preset` names;
+ /// "default" is the plain title.
+ callback library-add-text(preset: string);
callback library-apply-effect(effect-id: string);
callback library-apply-transition(transition-id: string);
callback library-apply-filter(filter-id: string, label: string);
diff --git a/engine/crates/concat/ui/workspace/media-pane.slint b/engine/crates/concat/ui/workspace/media-pane.slint
index 4ae15964..d2f393f0 100644
--- a/engine/crates/concat/ui/workspace/media-pane.slint
+++ b/engine/crates/concat/ui/workspace/media-pane.slint
@@ -5,6 +5,7 @@ import { Theme, Fmt, Glyph, Icon, Payload } from "../primitives/primitives.slint
import { Pane, PaneScroll } from "pane.slint";
import { HairlineSplitter } from "splitter.slint";
import { PaneKind, PaneSwitcher } from "pane-switcher.slint";
+import { TextAlignment } from "../timeline/model.slint";
// The library pane: a strip of pages across the top, then a narrow category
// sidebar and the browsing area beside it. Media is the bin; Text adds a
@@ -18,6 +19,27 @@ export enum MediaKind { video, audio, image }
/// value here and not the absence of one.
export enum MediaFilter { all, video, audio, images }
+/// One look a title can be given, as the Text page's Presets shelf shows
+/// it: enough of the style to draw the name in it. Published by Rust from
+/// the preset list; the id is what is placed, and ids are stable for ever
+/// because project files store them.
+export struct TextPresetData {
+ id: string,
+ name: string,
+ family: string,
+ weight: int,
+ italic: bool,
+ fill: color,
+ plate: color,
+ plated: bool,
+ stroke: color,
+ /// as a fraction of the frame; zero for none
+ stroke-width: float,
+ /// the cap height as a fraction of the frame, for the sample's size
+ size: float,
+ align: TextAlignment,
+}
+
export struct MediaItemData {
id: int,
name: string,
@@ -952,6 +974,126 @@ component TextPage inherits Rectangle {
}
}
+// One preset, as a card: the name drawn in the look, on the stage's own
+// dark ground so a white title reads as it will on footage, with the plate
+// behind it when the look has one.
+component PresetCard inherits Rectangle {
+ in property <TextPresetData> preset;
+
+ callback applied();
+
+ opacity: drag.dragging ? 0.45 : 1.0;
+
+ /// The sample's size follows the preset's: the plain title's 9% of the
+ /// frame is 16px on a card, and the rest scale with it within reason.
+ property <length> sample-size: Fmt.clamp(root.preset.size / 0.09, 0.6, 1.6) * 16px;
+
+ drag := DragArea {
+ data: Payload.of("text:\{root.preset.id}:\{root.preset.name}");
+ drag-image: Payload.preview("text:\{root.preset.id}:\{root.preset.name}");
+ drag-image-offset-x: -8;
+ drag-image-offset-y: -4;
+ allow-copy: true;
+
+ touch := TouchArea {
+ mouse-cursor: pointer;
+ clicked => { root.applied(); }
+ double-clicked => { root.applied(); }
+
+ tile := Rectangle {
+ y: 0;
+ height: root.width * 9 / 16;
+ border-radius: Theme.r;
+ background: Theme.stage;
+ border-width: 1px;
+ border-color: touch.has-hover ? Theme.line-strong : Theme.line;
+ clip: true;
+
+ if root.preset.plated: Rectangle {
+ x: (parent.width - self.width) / 2;
+ y: (parent.height - self.height) / 2;
+ width: Math.min(parent.width - 8px, sample.preferred-width + 14px);
+ height: sample.preferred-height + 6px;
+ border-radius: Theme.r-xs;
+ background: root.preset.plate;
+ }
+
+ sample := Text {
+ x: (parent.width - self.width) / 2;
+ y: (parent.height - self.height) / 2;
+ width: Math.min(parent.width - 12px, self.preferred-width);
+ text: root.preset.name;
+ color: root.preset.fill;
+ font-family: root.preset.family;
+ font-weight: root.preset.weight;
+ font-italic: root.preset.italic;
+ font-size: root.sample-size;
+ stroke: root.preset.stroke;
+ stroke-width: root.preset.stroke-width > 0 ? 1px : 0px;
+ horizontal-alignment: center;
+ overflow: elide;
+ }
+
+ if touch.has-hover: Rectangle {
+ x: parent.width - self.width - 4px;
+ y: parent.height - self.height - 4px;
+ width: 20px;
+ height: 20px;
+ border-radius: Theme.r-xs;
+ background: Theme.scrim;
+
+ Icon {
+ x: (parent.width - self.width) / 2;
+ y: (parent.height - self.height) / 2;
+ glyph: Glyph.plus;
+ size: 11px;
+ tint: Theme.on-scrim;
+ }
+ }
+ }
+
+ Text {
+ x: 0;
+ y: tile.height + 4px;
+ width: root.width;
+ height: 14px;
+ text: root.preset.name;
+ color: Theme.fg-muted;
+ font-size: Theme.fs-sm;
+ vertical-alignment: center;
+ overflow: elide;
+ }
+ }
+ }
+}
+
+// The Presets shelf: the same auto-fill arithmetic as the other grids.
+component PresetGrid inherits Rectangle {
+ in property <[TextPresetData]> items;
+
+ callback applied(id: string);
+
+ property <length> gap: 8px;
+ property <length> min-card: 88px;
+ property <int> cols: Math.max(1,
+ Math.floor((root.width + root.gap) / (root.min-card + root.gap)));
+ property <length> card-w: (root.width - (root.cols - 1) * root.gap) / root.cols;
+ property <length> card-h: root.card-w * 9 / 16 + 4px + 14px;
+ property <int> rows: Math.ceil(root.items.length / root.cols);
+
+ height: root.rows > 0 ? root.rows * (root.card-h + root.gap) - root.gap : 0px;
+
+ for entry[index] in root.items: PresetCard {
+ x: Math.mod(index, root.cols) * (root.card-w + root.gap);
+ y: Math.floor(index / root.cols) * (root.card-h + root.gap);
+ width: root.card-w;
+ height: root.card-h;
+ preset: entry;
+
+ applied => { root.applied(entry.id); }
+ }
+}
+
// ── the pane ─────────────────────────────────────────────────────────────────
// Centred placeholder for a page with nothing on it.
@@ -1009,8 +1151,10 @@ export component MediaPane inherits Rectangle {
/// double-clicked: place it on the timeline at the playhead
callback activate(id: int);
- /// Text page: add a title at the playhead.
- callback add-text();
+ /// The looks the Text page's Presets shelf offers.
+ in property <[TextPresetData]> presets;
+ /// Text page: add a title at the playhead, in the look `preset` names.
+ callback add-text(preset: string);
/// Catalogue pages: apply to the selected clip; Rust validates & explains.
callback apply-effect(effect-id: string);
callback apply-transition(transition-id: string);
@@ -1034,6 +1178,8 @@ export component MediaPane inherits Rectangle {
property <int> tab;
property <bool> categories-open: true;
property <bool> text-open: true;
+ /// 0 = Titles, 1 = Presets
+ property <int> text-category;
property <bool> transitions-open: true;
property <bool> effects-open: true;
property <bool> filters-open: true;
@@ -1340,7 +1486,14 @@ export component MediaPane inherits Rectangle {
if root.text-open: CategoryRow {
height: 24px;
label: "Titles";
- current: true;
+ current: root.text-category == 0;
+ clicked => { root.text-category = 0; }
+ }
+ if root.text-open: CategoryRow {
+ height: 24px;
+ label: "Presets";
+ current: root.text-category == 1;
+ clicked => { root.text-category = 1; }
}
}
@@ -1564,12 +1717,25 @@ export component MediaPane inherits Rectangle {
}
}
- if root.tab == 1: HorizontalLayout {
+ if root.tab == 1 && root.text-category == 0: HorizontalLayout {
padding: 8px;
TextPage {
horizontal-stretch: 1;
- add-text => { root.add-text(); }
+ add-text => { root.add-text("default"); }
+ }
+ }
+
+ // The looks. Each card is a title in that look, placed at
+ // the playhead on a click or dragged onto a lane; a preset
+ // that brings a font installs it on the way.
+ if root.tab == 1 && root.text-category == 1: HorizontalLayout {
+ padding: 8px;
+
+ PresetGrid {
+ horizontal-stretch: 1;
+ items: root.presets;
+ applied(id) => { root.add-text(id); }
}
}
diff --git a/engine/crates/concat/ui/workspace/seat.slint b/engine/crates/concat/ui/workspace/seat.slint
index a2d9d684..119ebd59 100644
--- a/engine/crates/concat/ui/workspace/seat.slint
+++ b/engine/crates/concat/ui/workspace/seat.slint
@@ -115,7 +115,8 @@ export component Seat inherits Rectangle {
remove-selected => { Editor.media-remove-selected(); }
activate(id) => { Editor.media-activate(id); }
- add-text => { Editor.library-add-text(); }
+ presets: Editor.text-presets;
+ add-text(preset) => { Editor.library-add-text(preset); }
apply-effect(id) => { Editor.library-apply-effect(id); }
apply-transition(id) => { Editor.library-apply-transition(id); }
apply-filter(id, label) => { Editor.library-apply-filter(id, label); }