Skip to content

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

Build the window for Android and iOS

Jareerafd34023cde1
diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml
new file mode 100644
index 00000000..7985a3f9
--- /dev/null
+++ b/.github/workflows/mobile.yml
@@ -0,0 +1,156 @@
+name: Build for phones
+
+# Builds Concat for Android and iOS on every push to main and every pull
+# request, and uploads what each produces: an APK, and the iOS app bundle
+# ready for a signing identity. Phones are cross-compiled - the Android
+# job runs on Linux with the NDK, the iOS job on macOS with Xcode - and
+# the two native libraries that cannot be fetched prebuilt for a phone are
+# built from source here and cached: FFmpeg by engine/scripts/ffmpeg-mobile.sh,
+# with the platform's hardware codecs, and whisper.cpp by its crate.
+# sherpa-onnx comes prebuilt from k2-fsa through engine/scripts/sherpa-mobile.sh.
+#
+# engine/scripts/mobile-env.sh is the one description of the build
+# environment, here and on a developer's machine.
+on:
+ push:
+ branches: [main]
+ pull_request:
+ workflow_dispatch:
+
+concurrency:
+ group: mobile-${{ github.ref }}
+ cancel-in-progress: true
+
+env:
+ CARGO_TERM_COLOR: always
+ # ggml compiles to the portable baseline for the architecture, NEON on
+ # ARM, rather than to whatever the build machine has.
+ GGML_NATIVE: "OFF"
+
+jobs:
+ android:
+ name: Android arm64
+ runs-on: ubuntu-latest
+ timeout-minutes: 90
+ steps:
+ - uses: actions/checkout@v7
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: aarch64-linux-android
+ - uses: taiki-e/cache-cargo-install-action@v2
+ with:
+ tool: cargo-apk
+
+ # The runner image carries the SDK and an NDK; the script finds the
+ # newest NDK under the SDK on its own, and the build scripts of
+ # whisper.cpp, Skia and Slint's backend each read it by their own
+ # name from what mobile-env.sh exports.
+ - name: System libraries
+ run: sudo apt-get update && sudo apt-get install -y cmake libclang-dev
+
+ - name: FFmpeg for Android (cached)
+ id: ffmpeg
+ uses: actions/cache@v4
+ with:
+ path: engine/vendor/ffmpeg/aarch64-linux-android
+ key: ffmpeg-aarch64-linux-android-${{ hashFiles('engine/scripts/ffmpeg-mobile.sh') }}
+ - name: FFmpeg for Android
+ if: steps.ffmpeg.outputs.cache-hit != 'true'
+ run: engine/scripts/ffmpeg-mobile.sh aarch64-linux-android
+
+ - name: sherpa-onnx for Android
+ run: engine/scripts/sherpa-mobile.sh aarch64-linux-android
+
+ - uses: Swatinem/rust-cache@v2
+ with:
+ workspaces: engine
+ key: aarch64-linux-android
+
+ # The build environment first, then the build under it. The APK is
+ # signed with the debug key, which is what a build without a store
+ # listing installs with.
+ - name: Build the APK
+ working-directory: engine
+ run: |
+ set -o pipefail
+ eval "$(scripts/mobile-env.sh aarch64-linux-android)"
+ cargo apk build --release -p concat-android 2>&1 | tee build.log
+
+ - name: Build log to the summary (failure only)
+ if: failure()
+ run: |
+ if [ -f engine/build.log ]; then
+ {
+ echo "### Build failed: Android arm64"
+ echo '```'
+ tail -n 150 engine/build.log
+ echo '```'
+ } >> "$GITHUB_STEP_SUMMARY"
+ fi
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: Concat-android-arm64
+ path: engine/target/release/apk/Concat.apk
+ if-no-files-found: error
+
+ ios:
+ name: iOS arm64
+ runs-on: macos-15
+ timeout-minutes: 90
+ steps:
+ - uses: actions/checkout@v7
+ - uses: dtolnay/rust-toolchain@stable
+ with:
+ targets: aarch64-apple-ios
+
+ - run: brew install cmake
+
+ - name: FFmpeg for iOS (cached)
+ id: ffmpeg
+ uses: actions/cache@v4
+ with:
+ path: engine/vendor/ffmpeg/aarch64-apple-ios
+ key: ffmpeg-aarch64-apple-ios-${{ hashFiles('engine/scripts/ffmpeg-mobile.sh') }}
+ - name: FFmpeg for iOS
+ if: steps.ffmpeg.outputs.cache-hit != 'true'
+ run: engine/scripts/ffmpeg-mobile.sh aarch64-apple-ios
+
+ - name: sherpa-onnx for iOS
+ run: engine/scripts/sherpa-mobile.sh aarch64-apple-ios
+
+ - uses: Swatinem/rust-cache@v2
+ with:
+ workspaces: engine
+ key: aarch64-apple-ios
+
+ - name: Build
+ working-directory: engine
+ run: |
+ set -o pipefail
+ eval "$(scripts/mobile-env.sh aarch64-apple-ios)"
+ cargo build --release -p concat --target aarch64-apple-ios 2>&1 | tee build.log
+
+ - name: Build log to the summary (failure only)
+ if: failure()
+ run: |
+ if [ -f engine/build.log ]; then
+ {
+ echo "### Build failed: iOS arm64"
+ echo '```'
+ tail -n 150 engine/build.log
+ echo '```'
+ } >> "$GITHUB_STEP_SUMMARY"
+ fi
+
+ # The bundle: binary, Info.plist and the sherpa-onnx framework, ad-hoc
+ # signed. A developer's identity and provisioning profile go on with
+ # codesign before it can be installed on a phone.
+ - name: Bundle
+ run: engine/scripts/ios-app.sh aarch64-apple-ios release
+
+ - uses: actions/upload-artifact@v4
+ with:
+ name: Concat-ios-arm64
+ path: engine/target/aarch64-apple-ios/release/Concat.app
+ if-no-files-found: error
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 013673db..e4beb857 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -284,7 +284,8 @@ The Rust side is small and split by what it owns:
| File | Owns |
|---|---|
-| `main.rs` | Startup (renderer selection, the services), and one binding per callback the `Editor` global exposes. Every handler is "mutate the state, then republish". |
+| `lib.rs` | Startup (the backend, the services), and one binding per callback the `Editor` global exposes. Every handler is "mutate the state, then republish". `main.rs` is the desktop's and iOS's call into it; `concat-android` is Android's. |
+| `platform.rs` | The three things a phone does differently from a desk: how the backend is chosen, how a file or folder is picked, whether the title strip is dragged. Everything else is shared. |
| `studio.rs` | The window's state. Reads the engine's `Project` through the open `Session`; writes every edit as a `Command`. Holds what the document does not: selection, playhead, zoom, tool, which lanes are locked, the dock tree, what the sheets show. Publishes it all into Slint's models. |
| `host.rs` | The engine's services (playback, monitor, exporter, transcriber, speech, app directories) and the bridge from worker threads back to the event loop. |
| `dock.rs` | The workspace's arrangement as a tree, walked flat for Slint. |
@@ -370,14 +371,40 @@ else touches the audio path.
green on all three platforms. Windows (libclang via chocolatey,
`FFMPEG_DIR`, MSVC for whisper.cpp) is the one to watch.
-### 8.8 DTO shapes in the export path
+### 8.8 Phones
+
+The window builds and packages for Android and iOS (`mobile.yml`, the
+`scripts/*-mobile.sh` trio, `concat-android`), and what runs there is the
+desktop's tree on a phone's screen. The next work, in order:
+
+- A phone layout. The dock, the inspector and the timeline assume a wide
+ window and a pointer; a phone wants one seat at a time, touch-sized
+ targets, and the timeline under the monitor. The `.slint` tree can carry
+ a second arrangement chosen by the window's size.
+- Picking files. `platform.rs` returns nothing for a pick on a phone; the
+ system document picker (Storage Access Framework, `UIDocumentPicker`)
+ has to hand the window a readable path or a file descriptor, and
+ `concat-media` opens by path today.
+- Hardware codecs are linked, not yet asked for: `concat-media` opens the
+ software decoder by name. MediaCodec also needs `av_jni_set_java_vm`
+ from the activity before FFmpeg can reach it.
+- The monitor on Android composites on the CPU: Slint's android-activity
+ backend creates its own wgpu device and there is no way to hand it ours,
+ so the shared-texture path in `gpu.rs` is desktop and iOS only.
+- The iOS build is exercised only in CI, on a runner with Xcode.
+- Three build-script quirks are papered over in `scripts/mobile-env.sh`
+ rather than fixed upstream: whisper-rs-sys names `ggml-blas` whenever
+ the *host* is a Mac, Slint's Android backend reads the NDK API level as
+ the SDK platform, and cargo-apk does not pass bindgen the NDK sysroot.
+
+### 8.9 DTO shapes in the export path
`ExportClip`, `ExportRequest` and `PreviewFrameRequest` are JSON-shaped
DTOs. `concat-export` could take the engine's `Project` and settings
directly and drop the flattening-through-a-DTO; the `serde` derives on the
host's view types go with them.
-### 8.9 Panics in runtime paths
+### 8.10 Panics in runtime paths
Engine `.expect()`s exist in `decode.rs`, `encode.rs`, `pool.rs` and
`time.rs` ("rational overflowed i64"). Most are genuine invariants
@@ -385,7 +412,7 @@ Engine `.expect()`s exist in `decode.rs`, `encode.rs`, `pool.rs` and
if wrong. The host's `templates.rs` and `media.rs` counts are dominated by
tests, which is fine.
-### 8.10 Housekeeping
+### 8.11 Housekeeping
- **Zero TODO/FIXME/HACK comments** in the tree. Invariants live in prose
comments instead; keep it that way.
diff --git a/TODO.MD b/TODO.MD
new file mode 100644
index 00000000..904632f1
--- /dev/null
+++ b/TODO.MD
@@ -0,0 +1,13 @@
+# ToDo
+
+### QoL or UX features
+- [ ] The ability to move/reposition timelines on the timeline tray. For example if one has three different timelines they can drag and drop the first between, after, or before the other timelines thereby reordering the order.
+- [ ] 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.
+- [ ] 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.
+- [ ] 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.
+- [ ] In Library>Transitions>Basic: use the same light/thinner font-weight as Transitions>Motion.
+- [ ] Remove the "Concat" watermark from the bottom-left of the Preview.
+- [ ] Add basic CapCut-like keybinds to the app. Like for delete, CTRL+B to toggle split tool, etc.
+- [ ] Recheck and fix Export system/modal. Things like 9:16 export output is broken and does not work.
+- [ ] in Settings>Appearance: remove the "Dark is the edit's own room" text-paragraph.
+- [ ] Change the Timeline>Timestamps-line tray background color from dark to the same as Tracks section background.
diff --git a/engine/Cargo.lock b/engine/Cargo.lock
index 2f70557f..eb083140 100644
--- a/engine/Cargo.lock
+++ b/engine/Cargo.lock
@@ -211,6 +211,27 @@ dependencies = [
"pkg-config",
]
+[[package]]
+name = "android-activity"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289"
+dependencies = [
+ "android-properties",
+ "bitflags 2.13.1",
+ "cc",
+ "cesu8",
+ "jni 0.21.1",
+ "jni-sys 0.3.1",
+ "libc",
+ "log",
+ "ndk 0.8.0",
+ "ndk-context",
+ "ndk-sys 0.5.0+25.2.9519653",
+ "num_enum",
+ "thiserror 1.0.69",
+]
+
[[package]]
name = "android-activity"
version = "0.6.1"
@@ -223,9 +244,9 @@ dependencies = [
"jni 0.22.4",
"libc",
"log",
- "ndk",
+ "ndk 0.9.0",
"ndk-context",
- "ndk-sys",
+ "ndk-sys 0.6.0+11769913",
"num_enum",
"thiserror 2.0.20",
]
@@ -1112,6 +1133,14 @@ dependencies = [
"wgpu",
]
+[[package]]
+name = "concat-android"
+version = "0.2.0"
+dependencies = [
+ "concat",
+ "slint",
+]
+
[[package]]
name = "concat-cli"
version = "0.2.0"
@@ -1362,7 +1391,7 @@ dependencies = [
"js-sys",
"libc",
"mach2",
- "ndk",
+ "ndk 0.9.0",
"ndk-context",
"num-derive",
"num-traits",
@@ -2472,11 +2501,14 @@ version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9805bcdcbeea6626a0054347ee55d2424e0d5574b563472719d3fc7a11852242"
dependencies = [
+ "android-activity 0.5.2",
+ "android-activity 0.6.1",
"android-build",
"i-slint-common",
"i-slint-core",
"i-slint-renderer-skia",
"jni 0.22.4",
+ "ndk 0.9.0",
"raw-window-handle",
]
@@ -2512,6 +2544,7 @@ checksum = "2247a4590a02a466b2f4916cc789dfe66247f6af826f00eb84a2685259a45c1c"
dependencies = [
"cfg-if",
"cfg_aliases",
+ "i-slint-backend-android-activity",
"i-slint-backend-linuxkms",
"i-slint-backend-testing",
"i-slint-backend-winit",
@@ -3634,6 +3667,20 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308d96db8debc727c3fd9744aac51751243420e46edf401010908da7f8d5e57c"
+[[package]]
+name = "ndk"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7"
+dependencies = [
+ "bitflags 2.13.1",
+ "jni-sys 0.3.1",
+ "log",
+ "ndk-sys 0.5.0+25.2.9519653",
+ "num_enum",
+ "thiserror 1.0.69",
+]
+
[[package]]
name = "ndk"
version = "0.9.0"
@@ -3643,7 +3690,7 @@ dependencies = [
"bitflags 2.13.1",
"jni-sys 0.3.1",
"log",
- "ndk-sys",
+ "ndk-sys 0.6.0+11769913",
"num_enum",
"raw-window-handle",
"thiserror 1.0.69",
@@ -3655,6 +3702,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
+[[package]]
+name = "ndk-sys"
+version = "0.5.0+25.2.9519653"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691"
+dependencies = [
+ "jni-sys 0.3.1",
+]
+
[[package]]
name = "ndk-sys"
version = "0.6.0+11769913"
@@ -5611,7 +5667,7 @@ dependencies = [
"fastrand",
"js-sys",
"memmap2",
- "ndk",
+ "ndk 0.9.0",
"objc2 0.6.4",
"objc2-core-foundation",
"objc2-core-graphics",
@@ -6725,7 +6781,7 @@ dependencies = [
"libloading",
"log",
"naga",
- "ndk-sys",
+ "ndk-sys 0.6.0+11769913",
"objc2 0.6.4",
"objc2-core-foundation",
"objc2-foundation 0.3.2",
@@ -7177,7 +7233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6755fa58a9f8350bd1e472d4c3fcc25f824ec358933bba33306d0b63df5978d"
dependencies = [
"ahash",
- "android-activity",
+ "android-activity 0.6.1",
"atomic-waker",
"bitflags 2.13.1",
"block2 0.5.1",
@@ -7192,7 +7248,7 @@ dependencies = [
"js-sys",
"libc",
"memmap2",
- "ndk",
+ "ndk 0.9.0",
"objc2 0.5.2",
"objc2-app-kit 0.2.2",
"objc2-foundation 0.2.2",
diff --git a/engine/Cargo.toml b/engine/Cargo.toml
index 837d49ae..ff917766 100644
--- a/engine/Cargo.toml
+++ b/engine/Cargo.toml
@@ -18,6 +18,7 @@ concat-host = { path = "crates/concat-host" }
concat-speech = { path = "crates/concat-speech" }
concat-effects = { path = "crates/concat-effects" }
concat-text = { path = "crates/concat-text" }
+concat = { path = "crates/concat" }
serde_json = "1"
thiserror = "2"
diff --git a/engine/README.md b/engine/README.md
index 1a019dd5..c64f95ea 100644
--- a/engine/README.md
+++ b/engine/README.md
@@ -16,6 +16,7 @@ The video engine behind Concat. Rust, no GC, no hidden control flow.
| `concat-host` | What the window needs that is not the edit: sessions, project folders, previews, playback, templates, job slots. | `concat-media`, `concat-project`, `concat-export`, cpal |
| `concat-speech` | Transcription (whisper.cpp, in-process) and text to speech (Kokoro via sherpa-onnx). | `concat-host`, `concat-media`, whisper-rs, sherpa-onnx |
| `concat` | The editor window: every pane, dialog and primitive, in Slint. The app a user launches. | slint, `concat-host`, `concat-speech` |
+| `concat-android` | The Android activity: the entry point that hosts the window on a phone. | `concat`, slint |
The dependency arrows point one way:
@@ -74,6 +75,42 @@ talks to the audio device and the file system, `concat-speech` compiles in
whisper.cpp and sherpa-onnx, and `concat` is a window. `concat-export` goes
with them for now because its render loop reads through `concat-media`.
+### Phones
+
+The whole engine and the window build for Android (arm64) and iOS
+(arm64). Two native libraries come from source for a phone, because no
+prebuilt covers them: FFmpeg, which `scripts/ffmpeg-mobile.sh` cross-builds
+as static archives with the platform's hardware codecs turned on -
+MediaCodec on Android, VideoToolbox on iOS - and whisper.cpp, which its
+crate builds with cmake for the target. sherpa-onnx ships as the shared
+library k2-fsa publishes, fetched by `scripts/sherpa-mobile.sh`; on Android
+the app carries it in `jniLibs`, on iOS as an embedded framework. Both
+scripts leave their output under `vendor/`, outside `target/`, and
+`scripts/mobile-env.sh` turns that into the build environment:
+
+```sh
+# Android: the NDK under the SDK, a JDK, and cargo-ndk or cargo-apk.
+scripts/ffmpeg-mobile.sh aarch64-linux-android
+scripts/sherpa-mobile.sh aarch64-linux-android
+eval "$(scripts/mobile-env.sh aarch64-linux-android)"
+cargo ndk -t arm64-v8a --platform 26 build -p concat-android # the activity's .so
+cargo apk build --release -p concat-android # the APK
+
+# iOS: Xcode.
+scripts/ffmpeg-mobile.sh aarch64-apple-ios
+scripts/sherpa-mobile.sh aarch64-apple-ios
+eval "$(scripts/mobile-env.sh aarch64-apple-ios)"
+cargo build --release -p concat --target aarch64-apple-ios
+scripts/ios-app.sh aarch64-apple-ios release # Concat.app
+```
+
+`.github/workflows/mobile.yml` runs exactly this on every push and keeps
+the FFmpeg builds cached. The window is one library: `concat` on the
+desktop and on iOS runs it from `main.rs`, `concat-android` from the
+activity's `android_main`, and `crates/concat/src/platform.rs` is where
+the three differ - how the backend is chosen, how files are picked, and
+whether there is a title strip to drag.
+
## Reading this codebase cold
1. [`../ARCHITECTURE.md`](../ARCHITECTURE.md) - the map of the whole system. Read it first.
diff --git a/engine/crates/concat-android/Cargo.toml b/engine/crates/concat-android/Cargo.toml
new file mode 100644
index 00000000..bc258ba8
--- /dev/null
+++ b/engine/crates/concat-android/Cargo.toml
@@ -0,0 +1,52 @@
+[package]
+name = "concat-android"
+version.workspace = true
+edition.workspace = true
+rust-version.workspace = true
+license.workspace = true
+publish = false
+description = "Concat on Android: the activity that hosts the editor window."
+
+# An Android app is a shared object the activity loads, not a program.
+[lib]
+crate-type = ["cdylib"]
+
+[dependencies]
+# The window, whole. Slint's android-activity backend is chosen by the
+# window's own manifest for this target; this crate only names the
+# activity's entry point.
+concat.workspace = true
+slint = { version = "1.17", default-features = false, features = [
+ "std",
+ "backend-android-activity-06",
+ "compat-1-2",
+] }
+
+# `cargo apk build -p concat-android` packages the shared object, the
+# sherpa-onnx runtime libraries and the manifest below into an APK. The
+# runtime libraries come from scripts/sherpa-mobile.sh.
+[package.metadata.android]
+package = "app.concat.editor"
+apk_name = "Concat"
+build_targets = ["aarch64-linux-android"]
+runtime_libs = "../../vendor/sherpa-onnx/jniLibs"
+
+[package.metadata.android.sdk]
+# Android 8.0: AAudio, the audio path the engine plays through.
+min_sdk_version = 26
+target_sdk_version = 35
+
+# Speech models are downloaded on first use.
+[[package.metadata.android.uses_permission]]
+name = "android.permission.INTERNET"
+
+[package.metadata.android.application]
+label = "Concat"
+# The editor keeps its own state across a rotation; the activity is not
+# recreated for one.
+[package.metadata.android.application.activity]
+config_changes = "orientation|keyboardHidden|screenSize"
+launch_mode = "singleTop"
+
+[lints]
+workspace = true
diff --git a/engine/crates/concat-android/src/lib.rs b/engine/crates/concat-android/src/lib.rs
new file mode 100644
index 00000000..67f62b9e
--- /dev/null
+++ b/engine/crates/concat-android/src/lib.rs
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! The activity's entry point. android-activity calls `android_main` on
+//! its own thread once the activity is up; Slint's backend takes the
+//! activity from there, and the window runs exactly as it does anywhere
+//! else.
+
+/// Called by the activity's native glue; the name is the contract.
+#[cfg(target_os = "android")]
+#[unsafe(no_mangle)]
+fn android_main(app: slint::android::AndroidApp) {
+ if let Err(error) = slint::android::init(app) {
+ eprintln!("concat: could not start the Android backend: {error}");
+ return;
+ }
+ if let Err(error) = concat::run() {
+ eprintln!("concat: {error}");
+ }
+}
diff --git a/engine/crates/concat/Cargo.toml b/engine/crates/concat/Cargo.toml
index aa91805d..5c192cc8 100644
--- a/engine/crates/concat/Cargo.toml
+++ b/engine/crates/concat/Cargo.toml
@@ -8,12 +8,16 @@ publish = false
description = "Concat, the editor window: the Slint front end that drives the engine."
# The product's name is the binary's name, unsuffixed: `concat` is what a
-# user launches, and the concat-* crates are what it is made of.
+# user launches, and the concat-* crates are what it is made of. The window
+# itself is the library, so that the binary here and the Android activity
+# in concat-android are each a few lines over the same code.
+[lib]
+path = "src/lib.rs"
+
[[bin]]
name = "concat"
path = "src/main.rs"
-[dependencies]
# Slint is taken under its GPL-3.0-only option to sit beside the AGPL engine.
# See ../../../THIRD_PARTY_NOTICES.md for why those two combine legally.
#
@@ -25,6 +29,13 @@ path = "src/main.rs"
# minus that one renderer.
#
# 1.17, not 1.14: renderer-femtovg-wgpu does not exist in 1.14.
+#
+# Three platforms, three feature sets. The desktop and iOS draw through the
+# winit backend, iOS without the system tray; Android draws through Slint's
+# android-activity backend, which owns the window and the renderer itself
+# (see platform.rs). The renderer and wgpu features are the same on all
+# three, chosen by the `skia`/`wgpu` features below.
+[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
slint = { version = "1.17", default-features = false, features = [
"std",
"backend-default",
@@ -32,16 +43,42 @@ slint = { version = "1.17", default-features = false, features = [
"accessibility",
"compat-1-2",
"system-tray",
- # The custom title bar: main.rs needs the winit window to hide the native
- # title bar (macOS traffic-light overlay) and to start window drags from
- # the strip's drag region.
+ # The custom title bar: platform.rs needs the winit window to hide the
+ # native title bar (macOS traffic-light overlay) and to start window
+ # drags from the strip's drag region.
"unstable-winit-030",
# The renderer draws on a wgpu device the window creates and shares with
# the engine's compositor, so a monitor frame is a texture Slint shows
# as it is - see gpu.rs.
"unstable-wgpu-29",
] }
+# Native file and folder dialogs, which Slint deliberately does not have.
+rfd = "0.17"
+# Reveal an exported file in the platform's file manager.
+opener = { version = "0.8", features = ["reveal"] }
+[target.'cfg(target_os = "ios")'.dependencies]
+slint = { version = "1.17", default-features = false, features = [
+ "std",
+ "backend-winit",
+ "renderer-software",
+ "accessibility",
+ "compat-1-2",
+ "unstable-winit-030",
+ "unstable-wgpu-29",
+] }
+
+[target.'cfg(target_os = "android")'.dependencies]
+slint = { version = "1.17", default-features = false, features = [
+ "std",
+ "backend-android-activity-06",
+ "renderer-software",
+ "accessibility",
+ "compat-1-2",
+ "unstable-wgpu-29",
+] }
+
+[dependencies]
# The one device: created in gpu.rs, handed to Slint and to the monitor.
wgpu.workspace = true
pollster.workspace = true
@@ -57,10 +94,6 @@ concat-speech.workspace = true
# The effect catalogue: the inspector's shelves and each link's knobs.
concat-effects.workspace = true
-# Native file and folder dialogs, which Slint deliberately does not have.
-rfd = "0.17"
-# Reveal an exported file in the platform's file manager.
-opener = { version = "0.8", features = ["reveal"] }
# Remembered preferences, as a small JSON file in the config directory.
serde = { version = "1", features = ["derive"] }
serde_json.workspace = true
diff --git a/engine/crates/concat/src/gpu.rs b/engine/crates/concat/src/gpu.rs
index a76e7f32..73293316 100644
--- a/engine/crates/concat/src/gpu.rs
+++ b/engine/crates/concat/src/gpu.rs
@@ -9,6 +9,10 @@
//! Created before the backend is selected, because Slint takes the device at
//! selection time; `None` when the machine offers no adapter, and then the
//! window renders the way it did without one.
+//!
+//! On Android the backend owns its device and none is shared, so the type
+//! is carried and never opened there; see platform.rs.
+#![cfg_attr(target_os = "android", allow(dead_code))]
/// The shared device and what it was created from.
#[derive(Clone)]
@@ -31,7 +35,7 @@ impl Gpu {
// other backend is refused at selection time. PRIMARY let wgpu pick
// Vulkan on Windows machines that offer it, and the window then
// failed to open with "Unsupported WGPU backend for use with Skia".
- let backends = if cfg!(target_os = "macos") {
+ let backends = if cfg!(target_vendor = "apple") {
wgpu::Backends::METAL
} else if cfg!(windows) {
wgpu::Backends::DX12
diff --git a/engine/crates/concat/src/lib.rs b/engine/crates/concat/src/lib.rs
new file mode 100644
index 00000000..0f5f48cf
--- /dev/null
+++ b/engine/crates/concat/src/lib.rs
@@ -0,0 +1,1021 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! Concat's editor window, in Slint.
+//!
+//! This file is the wiring: it starts the engine's services, builds the
+//! window, and binds every callback the `.slint` tree exposes to the state
+//! in [`studio`]. The state reads the engine's project and writes commands
+//! to it; nothing here decides what an edit means.
+//!
+//! A library so that every entry point is a few lines: `main.rs` on the
+//! desktop and on iOS, and the `concat-android` activity on Android. Each
+//! one calls [`run`].
+
+use std::cell::RefCell;
+use std::collections::HashMap;
+use std::rc::Rc;
+
+use slint::{ModelRc, SharedString, VecModel};
+
+// `DataTransfer` is what a drag carries. Slint keeps the platform's drag
+// object opaque and leaves building and reading one to the host language.
+use slint::private_unstable_api::re_exports::DataTransfer;
+
+// Everything the .slint tree exports, in a module of its own: the workspace
+// lints every public item for documentation, and the generated accessors are
+// thousands of public items nobody documents. The allow covers them and
+// nothing in this file.
+#[allow(missing_docs)]
+mod ui {
+ slint::include_modules!();
+}
+
+mod chips;
+mod dock;
+mod format;
+mod gpu;
+mod host;
+mod platform;
+mod prefs;
+mod studio;
+mod sysinfo;
+
+use dock::{Dock, SEAT_MIN_GRAB, SEAT_MIN_H, SEAT_MIN_W};
+use host::{Host, Shell};
+use studio::{LANGUAGES, Models, OUTPUTS, RESOLUTIONS, START_RATES, Studio};
+use ui::*;
+
+/// Builds the window, binds it to the engine, and runs it until it closes.
+pub fn run() -> Result<(), slint::PlatformError> {
+ let gpu = platform::select_backend()?;
+
+ let host = match Host::start(gpu) {
+ Ok(host) => host,
+ Err(error) => {
+ eprintln!("concat: {error}");
+ return Err(slint::PlatformError::Other(error));
+ }
+ };
+
+ let app = App::new()?;
+ app.set_macos(platform::MACOS);
+
+ let studio = Studio::new(host);
+ let dark = studio.prefs.dark.unwrap_or(false);
+ app.global::<Theme>().set_dark(dark);
+
+ let shell = Rc::new(Shell {
+ app: app.as_weak(),
+ studio: RefCell::new(studio),
+ models: Models::new(),
+ });
+ Shell::install(shell.clone());
+
+ // Handed over once, here, and never replaced: a fresh model is a reset,
+ // and a reset rebuilds every row that hangs off it.
+ {
+ let editor = app.global::<Editor>();
+ let models = &shell.models;
+ editor.set_timeline_tabs(ModelRc::from(models.tabs.clone()));
+ editor.set_tracks(ModelRc::from(models.tracks.clone()));
+ editor.set_clips(ModelRc::from(models.clips.clone()));
+ editor.set_stage_items(ModelRc::from(models.stage.clone()));
+ editor.set_stage_guides(ModelRc::from(models.guides.clone()));
+ editor.set_media(ModelRc::from(models.media.clone()));
+ editor.set_video_effects(ModelRc::from(models.video_effects.clone()));
+ editor.set_audio_effects(ModelRc::from(models.audio_effects.clone()));
+ editor.set_catalogue_effects(ModelRc::from(models.catalogue_effects.clone()));
+ editor.set_catalogue_filters(ModelRc::from(models.catalogue_filters.clone()));
+ editor.set_catalogue_audio(ModelRc::from(models.catalogue_audio.clone()));
+ editor.set_effect_groups(ModelRc::from(models.effect_groups.clone()));
+ editor.set_filter_groups(ModelRc::from(models.filter_groups.clone()));
+ editor.set_audio_groups(ModelRc::from(models.audio_groups.clone()));
+ editor.set_applied_visual(ModelRc::from(models.applied_visual.clone()));
+ editor.set_applied_audio(ModelRc::from(models.applied_audio.clone()));
+ editor.set_visual_params(ModelRc::from(models.visual_params.clone()));
+ editor.set_audio_params(ModelRc::from(models.audio_params.clone()));
+ editor.set_adjust_params(ModelRc::from(models.adjust_params.clone()));
+ editor.set_menu_items(ModelRc::from(models.menu.clone()));
+ editor.set_av_items(ModelRc::from(models.av.clone()));
+ app.set_app_menu_items(ModelRc::from(models.bar.clone()));
+ app.set_transcribers(ModelRc::from(models.transcribers.clone()));
+ app.set_voices(ModelRc::from(models.voices.clone()));
+ editor.set_seats(ModelRc::from(models.seats.clone()));
+ editor.set_dividers(ModelRc::from(models.dividers.clone()));
+ app.set_recents(ModelRc::from(models.recents.clone()));
+ }
+
+ // Settings > About's block, gathered once: nothing in it changes while
+ // the process runs.
+ let facts = sysinfo::system_facts();
+ app.set_system_report(
+ facts
+ .iter()
+ .map(|(label, value)| format!("{label}: {value}"))
+ .collect::<Vec<_>>()
+ .join("\n")
+ .into(),
+ );
+ app.set_system_facts(ModelRc::from(Rc::new(VecModel::from(
+ facts
+ .into_iter()
+ .map(|(label, value)| SystemFactData {
+ label: label.into(),
+ value: value.into(),
+ })
+ .collect::<Vec<_>>(),
+ ))));
+
+ // The ladders' labels, handed over once; the index the form reports back
+ // is what carries the meaning.
+ app.set_start_resolutions(ModelRc::from(Rc::new(VecModel::from(
+ RESOLUTIONS
+ .iter()
+ .map(|(label, _, _)| SharedString::from(*label))
+ .collect::<Vec<_>>(),
+ ))));
+ app.set_start_rates(ModelRc::from(Rc::new(VecModel::from(
+ START_RATES
+ .iter()
+ .map(|(label, _, _)| SharedString::from(*label))
+ .collect::<Vec<_>>(),
+ ))));
+ app.set_languages(ModelRc::from(Rc::new(VecModel::from(
+ LANGUAGES
+ .iter()
+ .map(|label| SharedString::from(*label))
+ .collect::<Vec<_>>(),
+ ))));
+
+ // The strip's drag region and double-click. Only the platform's window
+ // can do either; the scene graph forwards the gestures here.
+ app.on_titlebar_begin_drag({
+ let weak = app.as_weak();
+ move || {
+ if let Some(app) = weak.upgrade() {
+ platform::begin_drag(app.window());
+ }
+ }
+ });
+ app.on_titlebar_toggle_maximize({
+ let weak = app.as_weak();
+ move || {
+ if let Some(app) = weak.upgrade() {
+ platform::toggle_maximize(app.window());
+ }
+ }
+ });
+
+ // Mutate, then republish. Every handler is one of these three: the whole
+ // window, the lanes alone (for the handlers a pointer drives directly,
+ // which arrive as a stream), or the dock alone (a gutter drag).
+ macro_rules! handler {
+ ($publish:ident, |$state:ident $(, $arg:ident : $ty:ty)*| $body:block) => {{
+ move |$($arg : $ty),*| {
+ Shell::with(|shell, app| {
+ {
+ let mut $state = shell.studio.borrow_mut();
+ $body
+ }
+ shell.studio.borrow_mut().refresh_art();
+ shell.studio.borrow().$publish(&app, &shell.models);
+ });
+ }
+ }};
+ }
+ macro_rules! on_window {
+ ($($handler:tt)*) => { handler!(publish, $($handler)*) };
+ }
+ macro_rules! on_lanes {
+ ($($handler:tt)*) => { handler!(publish_lanes, $($handler)*) };
+ }
+ macro_rules! on_dock {
+ ($($handler:tt)*) => { handler!(publish_dock, $($handler)*) };
+ }
+
+ let editor = app.global::<Editor>();
+
+ // ── the launch screen ──
+ app.on_start_name_edited(on_window!(|state, name: SharedString| {
+ state.start.name = name.to_string();
+ }));
+ app.on_start_location_edited(on_window!(|state, path: SharedString| {
+ state.start.location = path.to_string();
+ }));
+ app.on_start_resolution_changed(on_window!(|state, index: i32| {
+ state.start.resolution = (index.max(0) as usize).min(RESOLUTIONS.len() - 1);
+ }));
+ app.on_start_rate_changed(on_window!(|state, index: i32| {
+ state.start.rate = (index.max(0) as usize).min(START_RATES.len() - 1);
+ }));
+ app.on_start_dismiss_error(on_window!(|state| {
+ state.start.error.clear();
+ }));
+ app.on_start_browse(on_window!(|state| {
+ if let Some(folder) =
+ platform::pick_folder("Where should the project folder go?", &state.start.location)
+ {
+ state.start.location = folder.to_string_lossy().into_owned();
+ }
+ }));
+ app.on_start_create(on_window!(|state| {
+ state.create_project();
+ }));
+ app.on_start_open_recent(on_window!(|state, path: SharedString| {
+ state.open_recent(path.as_str());
+ }));
+ app.on_start_forget_recent(on_window!(|state, path: SharedString| {
+ state.forget_recent(path.as_str());
+ }));
+
+ // ── the workspace's arrangement ──
+ editor.on_workspace_resized(on_dock!(|state, width: f32, height: f32| {
+ state.workspace = (width, height);
+ }));
+ editor.on_dock_set(on_dock!(|state, seat: i32, kind: PaneKind| {
+ let Some(path) = state.dock.leaf_path(seat.max(0) as usize) else {
+ return;
+ };
+ if let Dock::Leaf(held) = state.dock.at_mut(&path) {
+ *held = kind;
+ }
+ }));
+ editor.on_dock_dropped(on_dock!(|state, from: i32, onto: i32, side: DockSide| {
+ let (from, onto) = (from.max(0) as usize, onto.max(0) as usize);
+ if from == onto {
+ return;
+ }
+ let (Some(taken), Some(displaced)) = (state.dock.kind_at(from), state.dock.kind_at(onto))
+ else {
+ return;
+ };
+ if side == DockSide::Centre {
+ for (index, kind) in [(from, displaced), (onto, taken)] {
+ let Some(path) = state.dock.leaf_path(index) else {
+ continue;
+ };
+ if let Dock::Leaf(held) = state.dock.at_mut(&path) {
+ *held = kind;
+ }
+ }
+ return;
+ }
+ let (Some(onto_path), Some(from_path)) =
+ (state.dock.leaf_path(onto), state.dock.leaf_path(from))
+ else {
+ return;
+ };
+ state.dock.split_leaf(&onto_path, taken, side);
+ state.dock.remove_leaf(&from_path);
+ }));
+ editor.on_dock_add(on_dock!(|state, kind: PaneKind| {
+ let seats = state.dock_layout().seats;
+ let Some(biggest) = seats
+ .iter()
+ .max_by(|a, b| (a.width * a.height).total_cmp(&(b.width * b.height)))
+ else {
+ return;
+ };
+ let across = biggest.width >= SEAT_MIN_W * 2.0;
+ let down = biggest.height >= SEAT_MIN_H * 2.0;
+ let side = if biggest.width >= biggest.height && (across || !down) {
+ DockSide::Right
+ } else {
+ DockSide::Bottom
+ };
+ let Some(path) = state.dock.leaf_path(biggest.index.max(0) as usize) else {
+ return;
+ };
+ state.dock.split_leaf(&path, kind, side);
+ }));
+ editor.on_dock_remove(on_dock!(|state, seat: i32| {
+ let Some(path) = state.dock.leaf_path(seat.max(0) as usize) else {
+ return;
+ };
+ state.dock.remove_leaf(&path);
+ }));
+ editor.on_divider_pressed(on_dock!(|state, index: i32| {
+ let index = index.max(0) as usize;
+ state.divider_press = match (state.split_ratio(index), state.split_extent(index)) {
+ (Some(ratio), Some(extent)) => Some((index, ratio, extent)),
+ _ => None,
+ };
+ }));
+ editor.on_divider_dragged(on_dock!(|state, index: i32, delta: f32| {
+ let Some((held, from, extent)) = state.divider_press else {
+ return;
+ };
+ if held != index.max(0) as usize || extent <= 0.0 {
+ return;
+ }
+ let Some(path) = state.dock.split_path(held) else {
+ return;
+ };
+ let Dock::Split { columns, ratio, .. } = state.dock.at_mut(&path) else {
+ return;
+ };
+ let wanted = if *columns { SEAT_MIN_W } else { SEAT_MIN_H };
+ let floor = if wanted * 2.0 <= extent {
+ wanted
+ } else {
+ SEAT_MIN_GRAB.min(extent / 2.0)
+ } / extent;
+ *ratio = (from + delta / extent).clamp(floor, 1.0 - floor);
+ }));
+
+ // ── the bin ──
+ editor.on_media_filter_changed(on_window!(|state, filter: MediaFilter| {
+ state.set_media_filter(filter);
+ }));
+ editor.on_media_select(on_window!(|state, id: i32, additive: bool| {
+ state.media_select(id, additive);
+ }));
+ editor.on_media_band_selected(on_window!(
+ |state,
+ columns: i32,
+ from_col: i32,
+ to_col: i32,
+ from_row: i32,
+ to_row: i32,
+ additive: bool| {
+ state.media_band(columns, from_col, to_col, from_row, to_row, additive);
+ }
+ ));
+ editor.on_media_remove(on_window!(|state, id: i32| {
+ state.media_remove(id);
+ }));
+ editor.on_media_remove_selected(on_window!(|state| {
+ state.media_remove_selected();
+ }));
+ editor.on_import_media(on_window!(|state| {
+ if state.session.is_none() {
+ return;
+ }
+ let picked = platform::pick_files(
+ "Import media",
+ Some((
+ "Media",
+ &[
+ "mp4", "mov", "mkv", "webm", "avi", "m4v", "mp3", "wav", "aac", "m4a", "flac",
+ "ogg", "png", "jpg", "jpeg", "webp", "gif", "bmp", "tif", "tiff",
+ ],
+ )),
+ );
+ if let Some(paths) = picked {
+ state.import(paths);
+ }
+ }));
+ 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");
+ }));
+ // A filter is a colour look on the picture; audio is the sound's chain.
+ editor.on_library_apply_filter(on_window!(
+ |state, id: SharedString, _label: SharedString| {
+ state.apply_catalogue(id.as_str(), true);
+ }
+ ));
+ editor.on_library_apply_effect(on_window!(|state, id: SharedString| {
+ state.apply_catalogue(id.as_str(), true);
+ }));
+ editor.on_library_apply_audio(on_window!(|state, id: SharedString| {
+ state.apply_catalogue(id.as_str(), false);
+ }));
+ editor.on_library_apply_transition(on_window!(|state, id: SharedString| {
+ state.apply_transition(id.as_str());
+ }));
+ editor.on_library_save_template(on_window!(|state| {
+ state.save_template();
+ }));
+
+ // ── the inspector's effect stacks ──
+ editor.on_add_effect(on_window!(|state, _audio: bool| {
+ state.notify("Pick an effect or filter from the library", false);
+ }));
+ editor.on_remove_effect(on_window!(|state, id: i32| {
+ state.remove_effect(id);
+ }));
+
+ // ── tabs ──
+ editor.on_tab_selected(on_window!(|state, index: i32| {
+ let Some(id) = state
+ .project()
+ .timelines
+ .get(index.max(0) as usize)
+ .map(|timeline| timeline.id.clone())
+ else {
+ return;
+ };
+ state.selection.clear();
+ state.apply(concat_project::Command::SelectTimeline { timeline_id: id });
+ }));
+ editor.on_tab_renamed(on_window!(|state, index: i32, name: SharedString| {
+ let trimmed = name.trim().to_string();
+ let Some(id) = state
+ .project()
+ .timelines
+ .get(index.max(0) as usize)
+ .map(|timeline| timeline.id.clone())
+ else {
+ return;
+ };
+ if !trimmed.is_empty() {
+ state.apply(concat_project::Command::RenameTimeline {
+ timeline_id: id,
+ name: trimmed,
+ });
+ }
+ }));
+ editor.on_tab_added(on_window!(|state| {
+ if let Some(id) = state.apply(concat_project::Command::AddTimeline) {
+ state.selection.clear();
+ state.apply(concat_project::Command::SelectTimeline { timeline_id: id });
+ }
+ }));
+ editor.on_tab_close_requested(on_window!(|state, index: i32| {
+ let Some(id) = state
+ .project()
+ .timelines
+ .get(index.max(0) as usize)
+ .map(|timeline| timeline.id.clone())
+ else {
+ return;
+ };
+ state.selection.clear();
+ state.apply(concat_project::Command::RemoveTimeline { timeline_id: id });
+ }));
+
+ // ── the tray ──
+ editor.on_tool_changed(on_window!(|state, tool: TimelineTool| {
+ state.tool = tool;
+ }));
+ editor.on_snap_changed(on_window!(|state, snap: bool| {
+ state.snap = snap;
+ }));
+ editor.on_add_track(on_window!(|state| {
+ state.apply(concat_project::Command::AddTrack);
+ }));
+ editor.on_delete_selected(on_window!(|state| {
+ state.delete_selected();
+ }));
+ editor.on_split(on_window!(|state| {
+ let at = state.playhead;
+ state.split_at(at, true);
+ }));
+ editor.on_merge(on_window!(|state| {
+ state.merge();
+ }));
+
+ // ── the view ──
+ editor.on_scrubbed(on_lanes!(|state, seconds: f32| {
+ state.seek(seconds.max(0.0));
+ }));
+ editor.on_scrolled(on_lanes!(|state, seconds: f32| {
+ state.scroll_left = seconds.max(0.0);
+ }));
+ editor.on_zoom(on_lanes!(|state, factor: f32, anchor: f32| {
+ let before = state.seconds_per_pixel;
+ let after = (before * factor).clamp(0.000_5, 1.5);
+ state.seconds_per_pixel = after;
+ if anchor >= 0.0 {
+ state.scroll_left = (anchor - (anchor - state.scroll_left) * (after / before)).max(0.0);
+ }
+ }));
+ editor.on_zoom_to_fit(on_lanes!(|state, width: f32| {
+ let span = state.duration().max(1.0) * 1.05;
+ if width > 1.0 {
+ state.seconds_per_pixel = (span / width).clamp(0.000_5, 1.5);
+ state.scroll_left = 0.0;
+ }
+ }));
+
+ // ── lanes ──
+ editor.on_track_flag_changed(on_window!(
+ |state, row: i32, visible: bool, muted: bool, locked: bool| {
+ state.track_flags(row, visible, muted, locked);
+ }
+ ));
+ editor.on_track_renamed(on_window!(|state, row: i32, name: SharedString| {
+ let trimmed = name.trim().to_string();
+ let Some(id) = state.row_track(row).map(|track| track.id.clone()) else {
+ return;
+ };
+ if !trimmed.is_empty() {
+ state.apply(concat_project::Command::RenameTrack {
+ track_id: id,
+ name: trimmed,
+ });
+ }
+ }));
+ editor.on_track_sized(on_window!(|state, row: i32, size: TrackSize| {
+ state.set_lane_size(row, size);
+ }));
+ editor.on_track_removed(on_window!(|state, row: i32| {
+ let Some(id) = state.row_track(row).map(|track| track.id.clone()) else {
+ return;
+ };
+ state.apply(concat_project::Command::RemoveTrack { track_id: id });
+ }));
+
+ // ── the gestures ──
+ editor.on_clip_pressed(on_lanes!(|state,
+ id: SharedString,
+ additive: bool,
+ edge: i32| {
+ state.clip_pressed(id.as_str(), additive, edge);
+ }));
+ editor.on_clip_dragged(on_lanes!(|state, seconds: f32, pixels: f32| {
+ state.clip_dragged(seconds, pixels);
+ }));
+ editor.on_clip_released(on_window!(|state| {
+ state.clip_released();
+ }));
+
+ // ── drag and drop from the library ──
+ editor.on_drag_hovered(on_lanes!(|state,
+ payload: SharedString,
+ seconds: f32,
+ y: f32| {
+ let row = state.row_at(y);
+ state.drop = state.plan(payload.as_str(), seconds, row);
+ }));
+ editor.on_dropped(on_window!(|state,
+ payload: SharedString,
+ seconds: f32,
+ y: f32| {
+ state.drop = None;
+ let row = state.row_at(y);
+ if let Some(plan) = state.plan(payload.as_str(), seconds, row) {
+ state.place(&plan);
+ }
+ }));
+ editor.on_razored(on_window!(|state, id: SharedString, seconds: f32| {
+ let Some(clip) = state.clip(id.as_str()).cloned() else {
+ return;
+ };
+ if state.locked(&clip.track_id) {
+ return;
+ }
+ state.selection = vec![id.to_string()];
+ state.split_at(seconds, true);
+ }));
+ editor.on_band_selected(on_lanes!(
+ |state, from: f32, to: f32, from_y: f32, to_y: f32, additive: bool| {
+ let (from_row, to_row) = (state.row_at(from_y), state.row_at(to_y));
+ let caught: Vec<String> = state
+ .timeline()
+ .clips
+ .iter()
+ .filter(|clip| {
+ let row = state.row_of(&clip.track_id);
+ row >= from_row
+ && row <= to_row
+ && (clip.start + clip.duration) as f32 >= from
+ && clip.start as f32 <= to
+ && !state.locked(&clip.track_id)
+ })
+ .map(|clip| clip.id.clone())
+ .collect();
+ if additive {
+ for id in caught {
+ if !state.selection.contains(&id) {
+ state.selection.push(id);
+ }
+ }
+ } else {
+ state.selection = caught;
+ }
+ }
+ ));
+
+ // ── the inspector ──
+ editor.on_clip_set(on_lanes!(|state, field: ClipField, value: f32| {
+ state.clip_set(field, value);
+ }));
+ editor.on_clip_set_text(on_lanes!(
+ |state, field: ClipTextField, value: SharedString| {
+ state.clip_set_text(field, value.as_str());
+ }
+ ));
+ editor.on_clip_set_colour(on_lanes!(
+ |state, field: ClipTextField, value: slint::Color| {
+ state.clip_set_colour(field, value);
+ }
+ ));
+ editor.on_clip_commit(on_window!(|state| {
+ state.clip_commit();
+ }));
+
+ // ── the chains ──
+ editor.on_chain_add(on_window!(|state, audio: bool, id: SharedString| {
+ state.chain_add(audio, id.as_str());
+ }));
+ editor.on_chain_toggle(on_window!(|state, audio: bool, index: i32| {
+ state.chain_toggle(audio, index);
+ }));
+ editor.on_chain_move_by(on_window!(|state, audio: bool, index: i32, delta: i32| {
+ state.chain_move(audio, index, delta);
+ }));
+ editor.on_chain_remove(on_window!(|state, audio: bool, index: i32| {
+ state.chain_remove(audio, index);
+ }));
+ editor.on_chain_set_param(on_lanes!(
+ |state, audio: bool, index: i32, key: SharedString, value: f32| {
+ state.chain_set_param(audio, index, key.as_str(), value);
+ }
+ ));
+
+ editor.on_adjust_set(on_lanes!(|state, key: SharedString, value: f32| {
+ state.adjust_set(key.as_str(), value);
+ }));
+
+ // ── the monitor ──
+ editor.on_seek(on_lanes!(|state, seconds: f32| {
+ state.pause();
+ state.seek(seconds);
+ }));
+ editor.on_step_frames(on_lanes!(|state, frames: f32| {
+ state.pause();
+ let fps = state.frame_rate().round().max(1.0);
+ let at = (state.playhead * fps).round() + frames;
+ state.seek(at / fps);
+ }));
+ editor.on_ratio_changed(on_window!(|state, index: i32| {
+ state.set_output((index.max(0) as usize).min(OUTPUTS.len() - 1));
+ }));
+ editor.on_quality_changed(on_window!(|state, index: i32| {
+ state.quality = (index.max(0) as usize).min(2);
+ state.request_preview();
+ }));
+ editor.on_play_toggled(on_window!(|state| {
+ state.play_toggle();
+ }));
+
+ // ── the stage ──
+ editor.on_stage_pressed(on_window!(|state, x: f32, y: f32, additive: bool| {
+ state.stage_pressed(x, y, additive);
+ }));
+ editor.on_stage_grip_pressed(on_window!(
+ |state, id: SharedString, grip: i32, x: f32, y: f32| {
+ state.stage_grip_pressed(id.as_str(), grip, x, y);
+ }
+ ));
+ editor.on_stage_dragged(on_lanes!(|state, x: f32, y: f32, snap: bool| {
+ state.stage_dragged(x, y, snap);
+ }));
+ editor.on_stage_released(on_window!(|state| {
+ state.stage_released();
+ }));
+
+ // ── the context menu ──
+ editor.on_clip_context(on_window!(|state, id: SharedString| {
+ state.menu_token += 1;
+ if state.clip(id.as_str()).is_none() {
+ state.menu_target = None;
+ return;
+ }
+ if !state.selection.iter().any(|held| held == id.as_str()) {
+ state.selection = vec![id.to_string()];
+ }
+ state.menu_target = Some(id.to_string());
+ }));
+ editor.on_menu_selected(on_window!(|state, action: SharedString| {
+ // The clip the menu was opened on; failing that, the one clip that
+ // is selected, which is what the menu was showing anyway.
+ let target = state.menu_target.clone().or_else(|| state.sole_selection());
+ let Some(id) = target else {
+ return;
+ };
+ let Some(clip) = state.clip(&id).cloned() else {
+ return;
+ };
+ match action.as_str() {
+ "copy" => state.clipboard = Some(clip),
+ "duplicate" => state.duplicate(&clip),
+ "paste" => {
+ if let Some(held) = state.clipboard.clone() {
+ let mut source = held;
+ // Pasted after the clip that was right-clicked, on its lane.
+ source.track_id = clip.track_id.clone();
+ source.start = clip.start + clip.duration - source.duration;
+ state.duplicate(&source);
+ }
+ }
+ "split" => {
+ let at = state.playhead;
+ state.selection = vec![id];
+ state.split_at(at, true);
+ }
+ "mute" => {
+ let volume = if clip.volume <= 0.0 { 1.0 } else { 0.0 };
+ state.apply(concat_project::Command::UpdateClip {
+ clip_id: id,
+ patch: concat_project::commands::ClipPatch {
+ volume: Some(volume),
+ ..Default::default()
+ },
+ });
+ }
+ "lock" => state.toggle_lock(&clip.track_id),
+ "delete" => {
+ state.apply(concat_project::Command::RemoveClips { clip_ids: vec![id] });
+ state.menu_target = None;
+ }
+ _ => {}
+ }
+ }));
+
+ // ── the dialogs ──
+ app.on_export_clicked(on_window!(|state| {
+ state.export.open = true;
+ state.export.phase = ExportPhase::Idle;
+ state.export.message.clear();
+ }));
+ app.on_open_settings(on_window!(|state| {
+ state.refresh_models();
+ state.settings.open = true;
+ }));
+ // The theme is one bool on the Theme global, and every colour in the
+ // tree is a binding away from it; it is also remembered.
+ app.on_settings_theme_changed({
+ move |dark| {
+ Shell::with(|shell, app| {
+ app.global::<Theme>().set_dark(dark);
+ let mut studio = shell.studio.borrow_mut();
+ studio.prefs.dark = Some(dark);
+ studio.prefs.save(&studio.host.dirs);
+ });
+ }
+ });
+ app.on_export_closed(on_window!(|state| {
+ state.export.open = false;
+ }));
+ app.on_settings_closed(on_window!(|state| {
+ state.settings.open = false;
+ }));
+ app.on_export_name_edited(on_window!(|state, name: SharedString| {
+ state.export.name = name.to_string();
+ }));
+ app.on_export_resolution_changed(on_window!(|state, index: i32| {
+ state.export.resolution = (index.max(0) as usize).min(3);
+ }));
+ app.on_export_rate_changed(on_window!(|state, index: i32| {
+ state.export.rate = (index.max(0) as usize).min(2);
+ }));
+ app.on_export_quality_changed(on_window!(|state, index: i32| {
+ state.export.quality = (index.max(0) as usize).min(2);
+ }));
+ app.on_export_again(on_window!(|state| {
+ state.export.phase = ExportPhase::Idle;
+ state.export.progress = 0.0;
+ }));
+ app.on_export_browse(on_window!(|state| {
+ if let Some(folder) = platform::pick_folder("Export to", &state.export.folder) {
+ state.export.folder = folder.to_string_lossy().into_owned();
+ }
+ }));
+ app.on_export_reveal(on_window!(|state| {
+ if !state.export.written.is_empty()
+ && let Err(error) = platform::reveal(&state.export.written)
+ {
+ state.notify(&format!("Could not show the file: {error}"), true);
+ }
+ }));
+ app.on_export_cancel(on_window!(|state| {
+ state.export_cancel();
+ }));
+ app.on_export_start(on_window!(|state| {
+ state.export_start();
+ }));
+
+ // ── settings ──
+ app.on_settings_page_changed(on_window!(|state, index: i32| {
+ state.settings.tab = index;
+ }));
+ app.on_settings_language_changed(on_window!(|state, index: i32| {
+ state.settings.language = index.max(0) as usize;
+ state.prefs.language = Some(state.settings.language);
+ state.prefs.save(&state.host.dirs);
+ }));
+ app.on_settings_transcribe_language_changed(on_window!(|state, index: i32| {
+ state.settings.transcribe_language = index
+ .max(0)
+ .min(studio::TRANSCRIBE_LANGUAGES.len() as i32 - 1);
+ state.prefs.transcribe_language = Some(state.settings.transcribe_language);
+ state.prefs.save(&state.host.dirs);
+ }));
+ app.on_model_activated(on_window!(|state, id: SharedString| {
+ state.model_activate(id.as_str());
+ }));
+ app.on_model_download(on_window!(|state, id: SharedString| {
+ state.model_download(id.as_str());
+ }));
+ app.on_model_cancel(on_window!(|state, id: SharedString| {
+ state.model_cancel(id.as_str());
+ }));
+ app.on_model_remove(on_window!(|state, id: SharedString| {
+ state.model_remove(id.as_str());
+ }));
+
+ // ── the tray's A/V menu ──
+ editor.on_av_tools(on_window!(|state| {
+ state.av_token += 1;
+ }));
+ editor.on_av_selected(on_window!(|state, action: SharedString| {
+ let Some(id) = state.selection.first().cloned() else {
+ return;
+ };
+ match action.as_str() {
+ "captions" => state.caption_selected(),
+ "speak" => state.speak_selected(),
+ "detach" => {
+ state.apply(concat_project::Command::DetachAudio { clip_id: id });
+ }
+ "reattach" => {
+ state.apply(concat_project::Command::ReattachAudio { clip_id: id });
+ }
+ _ => {}
+ }
+ }));
+
+ // ── the title-bar menus ──
+ app.on_menu_opened(on_window!(|state, index: i32| {
+ state.open_menu = index;
+ state.menu_bar_token += 1;
+ }));
+ app.on_app_menu_selected({
+ move |action| {
+ Shell::with(|shell, app| {
+ {
+ let mut state = shell.studio.borrow_mut();
+ state.open_menu = -1;
+ match action.as_str() {
+ "add-selected" => state.add_selected_media(),
+ "import" => {
+ if let Some(paths) = platform::pick_files("Import media", None) {
+ state.import(paths);
+ }
+ }
+ "export" => {
+ state.export.open = true;
+ state.export.phase = ExportPhase::Idle;
+ state.export.message.clear();
+ }
+ "template" => state.save_template(),
+ "speech" => state.speak_selected(),
+ "settings" => {
+ state.refresh_models();
+ state.settings.open = true;
+ }
+ "close-project" => state.close_project(),
+ "undo" => state.undo(),
+ "redo" => state.redo(),
+ "snap" => state.snap = !state.snap,
+ "zoom-in" => {
+ state.seconds_per_pixel = (state.seconds_per_pixel / 1.4).max(0.000_5)
+ }
+ "zoom-out" => {
+ state.seconds_per_pixel = (state.seconds_per_pixel * 1.4).min(1.5)
+ }
+ "start" => {
+ state.pause();
+ state.seek(0.0);
+ }
+ "end" => {
+ state.pause();
+ let end = state.duration();
+ state.seek(end);
+ }
+ "delete" => state.delete_selected(),
+ "split" => {
+ let at = state.playhead;
+ state.split_at(at, false);
+ }
+ "save" => state.save(true),
+ _ => {}
+ }
+ }
+ if action == "close-window" {
+ shell.studio.borrow_mut().close_project();
+ app.window().hide().ok();
+ return;
+ }
+ shell.studio.borrow_mut().refresh_art();
+ shell.studio.borrow().publish(&app, &shell.models);
+ });
+ }
+ });
+
+ // --- the pieces Slint cannot express ---------------------------------
+ app.global::<Curves>().on_ease(format::bezier_y_at_x);
+ app.global::<Curves>()
+ .on_parse(|text, fallback| format::parse_bezier(text.as_str(), fallback));
+ app.global::<Fmt>()
+ .on_parse_timecode(|text| format::parse_timecode(text.as_str()));
+ app.global::<Fmt>().on_tick_interval(format::tick_interval);
+ app.global::<Fmt>()
+ .on_parse_frames(|text, rate| format::parse_frames(text.as_str(), rate));
+
+ // The drag payloads: plain text, because a drag that says "media:12" is
+ // one that can be read in a log.
+ app.global::<Payload>().on_of(DataTransfer::from);
+ app.global::<Payload>()
+ .on_text(|payload| payload.plain_text().unwrap_or_default());
+ app.global::<Payload>().on_pane_seat(|text| {
+ text.strip_prefix("pane:")
+ .and_then(|rest| rest.split(':').next())
+ .and_then(|seat| seat.parse().ok())
+ .unwrap_or(-1)
+ });
+
+ // The picture the cursor carries, resolved through the same `incoming`
+ // the drop uses, memoised by theme and payload.
+ app.global::<Payload>().on_preview({
+ let chips: RefCell<HashMap<String, slint::Image>> = RefCell::new(HashMap::new());
+ move |payload| {
+ let mut result = slint::Image::default();
+ Shell::with(|shell, app| {
+ let theme = app.global::<Theme>();
+ let key = format!("{}{payload}", if theme.get_dark() { 'd' } else { 'l' });
+ if let Some(chip) = chips.borrow().get(&key) {
+ result = chip.clone();
+ return;
+ }
+ if let Some(rest) = payload.strip_prefix("pane:") {
+ let mut fields = rest.splitn(3, ':').skip(1);
+ let label = fields.next().unwrap_or_default();
+ let slug = fields.next().unwrap_or_default();
+ let chip = slint::Image::load_from_svg_data(
+ chips::drag_chip_svg(
+ chips::pane_glyph(slug),
+ label,
+ "",
+ theme.get_accent(),
+ theme.get_field(),
+ theme.get_raised(),
+ theme.get_fg(),
+ )
+ .as_bytes(),
+ )
+ .unwrap_or_default();
+ chips.borrow_mut().insert(key, chip.clone());
+ result = chip;
+ return;
+ }
+ let studio = shell.studio.borrow();
+ let Some(plan) = studio.incoming(payload.as_str()) else {
+ return;
+ };
+ let (mark, well) = match plan.kind {
+ ClipKind::Video => (theme.get_kind_video(), theme.get_kind_video_well()),
+ ClipKind::Audio => (theme.get_kind_audio(), theme.get_kind_audio_well()),
+ ClipKind::Image => (theme.get_kind_image(), theme.get_kind_image_well()),
+ ClipKind::Text => (theme.get_kind_text(), theme.get_kind_text_well()),
+ ClipKind::Filter => (theme.get_kind_filter(), theme.get_kind_filter_well()),
+ };
+ let wave = studio
+ .peaks
+ .get(&plan.media)
+ .filter(|_| plan.kind == ClipKind::Audio)
+ .map(|peaks| format::wave_path(peaks, 0.0, plan.duration, 1.0))
+ .unwrap_or_default();
+ let document = chips::drag_chip_svg(
+ chips::chip_glyph(plan.kind),
+ &plan.label,
+ &wave,
+ mark,
+ well,
+ theme.get_raised(),
+ theme.get_fg(),
+ );
+ let chip =
+ slint::Image::load_from_svg_data(document.as_bytes()).unwrap_or_default();
+ chips.borrow_mut().insert(key, chip.clone());
+ result = chip;
+ });
+ result
+ }
+ });
+
+ // The programme level meter has no feed yet: playback's mix does not
+ // report levels. It stays parked at silence.
+ app.on_meter_watched_changed({
+ let weak = app.as_weak();
+ move |_watched| {
+ if let Some(app) = weak.upgrade() {
+ app.global::<Editor>().set_level(0.0);
+ app.global::<Editor>().set_peak(-1.0);
+ }
+ }
+ });
+
+ {
+ shell.studio.borrow_mut().refresh_art();
+ shell.studio.borrow().publish(&app, &shell.models);
+ }
+
+ app.run()
+}
diff --git a/engine/crates/concat/src/main.rs b/engine/crates/concat/src/main.rs
index d9472421..265090d8 100644
--- a/engine/crates/concat/src/main.rs
+++ b/engine/crates/concat/src/main.rs
@@ -1,1076 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
-//! Concat's editor window, in Slint.
-//!
-//! This file is the wiring: it starts the engine's services, builds the
-//! window, and binds every callback the `.slint` tree exposes to the state
-//! in [`studio`]. The state reads the engine's project and writes commands
-//! to it; nothing here decides what an edit means.
+//! The editor window as a program: what a desktop or an iPhone launches.
+//! Everything is in the library; see `lib.rs`.
// Hide the console window on Windows in release builds.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
-use std::cell::RefCell;
-use std::collections::HashMap;
-use std::rc::Rc;
-
-use slint::{ModelRc, SharedString, VecModel};
-
-// `DataTransfer` is what a drag carries. Slint keeps the platform's drag
-// object opaque and leaves building and reading one to the host language.
-use slint::private_unstable_api::re_exports::DataTransfer;
-
-// Everything the .slint tree exports, in a module of its own: the workspace
-// lints every public item for documentation, and the generated accessors are
-// thousands of public items nobody documents. The allow covers them and
-// nothing in this file.
-#[allow(missing_docs)]
-mod ui {
- slint::include_modules!();
-}
-
-mod chips;
-mod dock;
-mod format;
-mod gpu;
-mod host;
-mod prefs;
-mod studio;
-mod sysinfo;
-
-use dock::{Dock, SEAT_MIN_GRAB, SEAT_MIN_H, SEAT_MIN_W};
-use host::{Host, Shell};
-use studio::{LANGUAGES, Models, OUTPUTS, RESOLUTIONS, START_RATES, Studio};
-use ui::*;
-
fn main() -> Result<(), slint::PlatformError> {
- // The device the renderer and the monitor share. Taken first, because
- // the backend is selected with it.
- let gpu = gpu::Gpu::acquire();
- if gpu.is_none() {
- eprintln!("concat: no GPU adapter; the monitor composites on the CPU");
- }
-
- let mut selector = slint::BackendSelector::new().backend_name("winit".into());
- selector = match &gpu {
- Some(gpu) => selector.require_wgpu_29(gpu.configuration()),
- None => {
- // Without a shared device, ask for the platform's own API by
- // name: Skia picks its surface from a cfg chain, and requiring
- // one turns a silent fall back to the CPU rasteriser into a
- // refusal to start, which is a fault you can see.
- #[cfg(target_os = "macos")]
- {
- selector.require_metal()
- }
- #[cfg(target_family = "windows")]
- {
- selector.require_d3d()
- }
- #[cfg(not(any(target_os = "macos", target_family = "windows")))]
- {
- selector
- }
- }
- };
-
- // The custom title bar. On macOS the native bar is hidden and the traffic
- // lights are overlaid on the strip the UI draws. Other platforms keep
- // their decorations for now.
- #[cfg(target_os = "macos")]
- {
- use slint::winit_030::winit::platform::macos::WindowAttributesExtMacOS;
- selector = selector.with_winit_window_attributes_hook(|attributes| {
- attributes
- .with_titlebar_transparent(true)
- .with_title_hidden(true)
- .with_fullsize_content_view(true)
- });
- }
- selector.select()?;
-
- let host = match Host::start(gpu) {
- Ok(host) => host,
- Err(error) => {
- eprintln!("concat: {error}");
- return Err(slint::PlatformError::Other(error));
- }
- };
-
- let app = App::new()?;
- app.set_macos(cfg!(target_os = "macos"));
-
- let studio = Studio::new(host);
- let dark = studio.prefs.dark.unwrap_or(false);
- app.global::<Theme>().set_dark(dark);
-
- let shell = Rc::new(Shell {
- app: app.as_weak(),
- studio: RefCell::new(studio),
- models: Models::new(),
- });
- Shell::install(shell.clone());
-
- // Handed over once, here, and never replaced: a fresh model is a reset,
- // and a reset rebuilds every row that hangs off it.
- {
- let editor = app.global::<Editor>();
- let models = &shell.models;
- editor.set_timeline_tabs(ModelRc::from(models.tabs.clone()));
- editor.set_tracks(ModelRc::from(models.tracks.clone()));
- editor.set_clips(ModelRc::from(models.clips.clone()));
- editor.set_stage_items(ModelRc::from(models.stage.clone()));
- editor.set_stage_guides(ModelRc::from(models.guides.clone()));
- editor.set_media(ModelRc::from(models.media.clone()));
- editor.set_video_effects(ModelRc::from(models.video_effects.clone()));
- editor.set_audio_effects(ModelRc::from(models.audio_effects.clone()));
- editor.set_catalogue_effects(ModelRc::from(models.catalogue_effects.clone()));
- editor.set_catalogue_filters(ModelRc::from(models.catalogue_filters.clone()));
- editor.set_catalogue_audio(ModelRc::from(models.catalogue_audio.clone()));
- editor.set_effect_groups(ModelRc::from(models.effect_groups.clone()));
- editor.set_filter_groups(ModelRc::from(models.filter_groups.clone()));
- editor.set_audio_groups(ModelRc::from(models.audio_groups.clone()));
- editor.set_applied_visual(ModelRc::from(models.applied_visual.clone()));
- editor.set_applied_audio(ModelRc::from(models.applied_audio.clone()));
- editor.set_visual_params(ModelRc::from(models.visual_params.clone()));
- editor.set_audio_params(ModelRc::from(models.audio_params.clone()));
- editor.set_adjust_params(ModelRc::from(models.adjust_params.clone()));
- editor.set_menu_items(ModelRc::from(models.menu.clone()));
- editor.set_av_items(ModelRc::from(models.av.clone()));
- app.set_app_menu_items(ModelRc::from(models.bar.clone()));
- app.set_transcribers(ModelRc::from(models.transcribers.clone()));
- app.set_voices(ModelRc::from(models.voices.clone()));
- editor.set_seats(ModelRc::from(models.seats.clone()));
- editor.set_dividers(ModelRc::from(models.dividers.clone()));
- app.set_recents(ModelRc::from(models.recents.clone()));
- }
-
- // Settings > About's block, gathered once: nothing in it changes while
- // the process runs.
- let facts = sysinfo::system_facts();
- app.set_system_report(
- facts
- .iter()
- .map(|(label, value)| format!("{label}: {value}"))
- .collect::<Vec<_>>()
- .join("\n")
- .into(),
- );
- app.set_system_facts(ModelRc::from(Rc::new(VecModel::from(
- facts
- .into_iter()
- .map(|(label, value)| SystemFactData {
- label: label.into(),
- value: value.into(),
- })
- .collect::<Vec<_>>(),
- ))));
-
- // The ladders' labels, handed over once; the index the form reports back
- // is what carries the meaning.
- app.set_start_resolutions(ModelRc::from(Rc::new(VecModel::from(
- RESOLUTIONS
- .iter()
- .map(|(label, _, _)| SharedString::from(*label))
- .collect::<Vec<_>>(),
- ))));
- app.set_start_rates(ModelRc::from(Rc::new(VecModel::from(
- START_RATES
- .iter()
- .map(|(label, _, _)| SharedString::from(*label))
- .collect::<Vec<_>>(),
- ))));
- app.set_languages(ModelRc::from(Rc::new(VecModel::from(
- LANGUAGES
- .iter()
- .map(|label| SharedString::from(*label))
- .collect::<Vec<_>>(),
- ))));
-
- // The strip's drag region and double-click. Only the winit window can do
- // either; the scene graph forwards the gestures here.
- app.on_titlebar_begin_drag({
- let weak = app.as_weak();
- move || {
- use slint::winit_030::WinitWindowAccessor;
- if let Some(app) = weak.upgrade() {
- app.window().with_winit_window(|window| {
- let _ = window.drag_window();
- });
- }
- }
- });
- app.on_titlebar_toggle_maximize({
- let weak = app.as_weak();
- move || {
- use slint::winit_030::WinitWindowAccessor;
- if let Some(app) = weak.upgrade() {
- app.window().with_winit_window(|window| {
- window.set_maximized(!window.is_maximized());
- });
- }
- }
- });
-
- // Mutate, then republish. Every handler is one of these three: the whole
- // window, the lanes alone (for the handlers a pointer drives directly,
- // which arrive as a stream), or the dock alone (a gutter drag).
- macro_rules! handler {
- ($publish:ident, |$state:ident $(, $arg:ident : $ty:ty)*| $body:block) => {{
- move |$($arg : $ty),*| {
- Shell::with(|shell, app| {
- {
- let mut $state = shell.studio.borrow_mut();
- $body
- }
- shell.studio.borrow_mut().refresh_art();
- shell.studio.borrow().$publish(&app, &shell.models);
- });
- }
- }};
- }
- macro_rules! on_window {
- ($($handler:tt)*) => { handler!(publish, $($handler)*) };
- }
- macro_rules! on_lanes {
- ($($handler:tt)*) => { handler!(publish_lanes, $($handler)*) };
- }
- macro_rules! on_dock {
- ($($handler:tt)*) => { handler!(publish_dock, $($handler)*) };
- }
-
- let editor = app.global::<Editor>();
-
- // ── the launch screen ──
- app.on_start_name_edited(on_window!(|state, name: SharedString| {
- state.start.name = name.to_string();
- }));
- app.on_start_location_edited(on_window!(|state, path: SharedString| {
- state.start.location = path.to_string();
- }));
- app.on_start_resolution_changed(on_window!(|state, index: i32| {
- state.start.resolution = (index.max(0) as usize).min(RESOLUTIONS.len() - 1);
- }));
- app.on_start_rate_changed(on_window!(|state, index: i32| {
- state.start.rate = (index.max(0) as usize).min(START_RATES.len() - 1);
- }));
- app.on_start_dismiss_error(on_window!(|state| {
- state.start.error.clear();
- }));
- app.on_start_browse(on_window!(|state| {
- let mut dialog = rfd::FileDialog::new().set_title("Where should the project folder go?");
- if !state.start.location.is_empty() {
- dialog = dialog.set_directory(&state.start.location);
- }
- if let Some(folder) = dialog.pick_folder() {
- state.start.location = folder.to_string_lossy().into_owned();
- }
- }));
- app.on_start_create(on_window!(|state| {
- state.create_project();
- }));
- app.on_start_open_recent(on_window!(|state, path: SharedString| {
- state.open_recent(path.as_str());
- }));
- app.on_start_forget_recent(on_window!(|state, path: SharedString| {
- state.forget_recent(path.as_str());
- }));
-
- // ── the workspace's arrangement ──
- editor.on_workspace_resized(on_dock!(|state, width: f32, height: f32| {
- state.workspace = (width, height);
- }));
- editor.on_dock_set(on_dock!(|state, seat: i32, kind: PaneKind| {
- let Some(path) = state.dock.leaf_path(seat.max(0) as usize) else {
- return;
- };
- if let Dock::Leaf(held) = state.dock.at_mut(&path) {
- *held = kind;
- }
- }));
- editor.on_dock_dropped(on_dock!(|state, from: i32, onto: i32, side: DockSide| {
- let (from, onto) = (from.max(0) as usize, onto.max(0) as usize);
- if from == onto {
- return;
- }
- let (Some(taken), Some(displaced)) = (state.dock.kind_at(from), state.dock.kind_at(onto))
- else {
- return;
- };
- if side == DockSide::Centre {
- for (index, kind) in [(from, displaced), (onto, taken)] {
- let Some(path) = state.dock.leaf_path(index) else {
- continue;
- };
- if let Dock::Leaf(held) = state.dock.at_mut(&path) {
- *held = kind;
- }
- }
- return;
- }
- let (Some(onto_path), Some(from_path)) =
- (state.dock.leaf_path(onto), state.dock.leaf_path(from))
- else {
- return;
- };
- state.dock.split_leaf(&onto_path, taken, side);
- state.dock.remove_leaf(&from_path);
- }));
- editor.on_dock_add(on_dock!(|state, kind: PaneKind| {
- let seats = state.dock_layout().seats;
- let Some(biggest) = seats
- .iter()
- .max_by(|a, b| (a.width * a.height).total_cmp(&(b.width * b.height)))
- else {
- return;
- };
- let across = biggest.width >= SEAT_MIN_W * 2.0;
- let down = biggest.height >= SEAT_MIN_H * 2.0;
- let side = if biggest.width >= biggest.height && (across || !down) {
- DockSide::Right
- } else {
- DockSide::Bottom
- };
- let Some(path) = state.dock.leaf_path(biggest.index.max(0) as usize) else {
- return;
- };
- state.dock.split_leaf(&path, kind, side);
- }));
- editor.on_dock_remove(on_dock!(|state, seat: i32| {
- let Some(path) = state.dock.leaf_path(seat.max(0) as usize) else {
- return;
- };
- state.dock.remove_leaf(&path);
- }));
- editor.on_divider_pressed(on_dock!(|state, index: i32| {
- let index = index.max(0) as usize;
- state.divider_press = match (state.split_ratio(index), state.split_extent(index)) {
- (Some(ratio), Some(extent)) => Some((index, ratio, extent)),
- _ => None,
- };
- }));
- editor.on_divider_dragged(on_dock!(|state, index: i32, delta: f32| {
- let Some((held, from, extent)) = state.divider_press else {
- return;
- };
- if held != index.max(0) as usize || extent <= 0.0 {
- return;
- }
- let Some(path) = state.dock.split_path(held) else {
- return;
- };
- let Dock::Split { columns, ratio, .. } = state.dock.at_mut(&path) else {
- return;
- };
- let wanted = if *columns { SEAT_MIN_W } else { SEAT_MIN_H };
- let floor = if wanted * 2.0 <= extent {
- wanted
- } else {
- SEAT_MIN_GRAB.min(extent / 2.0)
- } / extent;
- *ratio = (from + delta / extent).clamp(floor, 1.0 - floor);
- }));
-
- // ── the bin ──
- editor.on_media_filter_changed(on_window!(|state, filter: MediaFilter| {
- state.set_media_filter(filter);
- }));
- editor.on_media_select(on_window!(|state, id: i32, additive: bool| {
- state.media_select(id, additive);
- }));
- editor.on_media_band_selected(on_window!(
- |state,
- columns: i32,
- from_col: i32,
- to_col: i32,
- from_row: i32,
- to_row: i32,
- additive: bool| {
- state.media_band(columns, from_col, to_col, from_row, to_row, additive);
- }
- ));
- editor.on_media_remove(on_window!(|state, id: i32| {
- state.media_remove(id);
- }));
- editor.on_media_remove_selected(on_window!(|state| {
- state.media_remove_selected();
- }));
- editor.on_import_media(on_window!(|state| {
- if state.session.is_none() {
- return;
- }
- let picked = rfd::FileDialog::new()
- .set_title("Import media")
- .add_filter(
- "Media",
- &[
- "mp4", "mov", "mkv", "webm", "avi", "m4v", "mp3", "wav", "aac", "m4a", "flac",
- "ogg", "png", "jpg", "jpeg", "webp", "gif", "bmp", "tif", "tiff",
- ],
- )
- .pick_files();
- if let Some(paths) = picked {
- state.import(paths);
- }
- }));
- 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");
- }));
- // A filter is a colour look on the picture; audio is the sound's chain.
- editor.on_library_apply_filter(on_window!(
- |state, id: SharedString, _label: SharedString| {
- state.apply_catalogue(id.as_str(), true);
- }
- ));
- editor.on_library_apply_effect(on_window!(|state, id: SharedString| {
- state.apply_catalogue(id.as_str(), true);
- }));
- editor.on_library_apply_audio(on_window!(|state, id: SharedString| {
- state.apply_catalogue(id.as_str(), false);
- }));
- editor.on_library_apply_transition(on_window!(|state, id: SharedString| {
- state.apply_transition(id.as_str());
- }));
- editor.on_library_save_template(on_window!(|state| {
- state.save_template();
- }));
-
- // ── the inspector's effect stacks ──
- editor.on_add_effect(on_window!(|state, _audio: bool| {
- state.notify("Pick an effect or filter from the library", false);
- }));
- editor.on_remove_effect(on_window!(|state, id: i32| {
- state.remove_effect(id);
- }));
-
- // ── tabs ──
- editor.on_tab_selected(on_window!(|state, index: i32| {
- let Some(id) = state
- .project()
- .timelines
- .get(index.max(0) as usize)
- .map(|timeline| timeline.id.clone())
- else {
- return;
- };
- state.selection.clear();
- state.apply(concat_project::Command::SelectTimeline { timeline_id: id });
- }));
- editor.on_tab_renamed(on_window!(|state, index: i32, name: SharedString| {
- let trimmed = name.trim().to_string();
- let Some(id) = state
- .project()
- .timelines
- .get(index.max(0) as usize)
- .map(|timeline| timeline.id.clone())
- else {
- return;
- };
- if !trimmed.is_empty() {
- state.apply(concat_project::Command::RenameTimeline {
- timeline_id: id,
- name: trimmed,
- });
- }
- }));
- editor.on_tab_added(on_window!(|state| {
- if let Some(id) = state.apply(concat_project::Command::AddTimeline) {
- state.selection.clear();
- state.apply(concat_project::Command::SelectTimeline { timeline_id: id });
- }
- }));
- editor.on_tab_close_requested(on_window!(|state, index: i32| {
- let Some(id) = state
- .project()
- .timelines
- .get(index.max(0) as usize)
- .map(|timeline| timeline.id.clone())
- else {
- return;
- };
- state.selection.clear();
- state.apply(concat_project::Command::RemoveTimeline { timeline_id: id });
- }));
-
- // ── the tray ──
- editor.on_tool_changed(on_window!(|state, tool: TimelineTool| {
- state.tool = tool;
- }));
- editor.on_snap_changed(on_window!(|state, snap: bool| {
- state.snap = snap;
- }));
- editor.on_add_track(on_window!(|state| {
- state.apply(concat_project::Command::AddTrack);
- }));
- editor.on_delete_selected(on_window!(|state| {
- state.delete_selected();
- }));
- editor.on_split(on_window!(|state| {
- let at = state.playhead;
- state.split_at(at, true);
- }));
- editor.on_merge(on_window!(|state| {
- state.merge();
- }));
-
- // ── the view ──
- editor.on_scrubbed(on_lanes!(|state, seconds: f32| {
- state.seek(seconds.max(0.0));
- }));
- editor.on_scrolled(on_lanes!(|state, seconds: f32| {
- state.scroll_left = seconds.max(0.0);
- }));
- editor.on_zoom(on_lanes!(|state, factor: f32, anchor: f32| {
- let before = state.seconds_per_pixel;
- let after = (before * factor).clamp(0.000_5, 1.5);
- state.seconds_per_pixel = after;
- if anchor >= 0.0 {
- state.scroll_left = (anchor - (anchor - state.scroll_left) * (after / before)).max(0.0);
- }
- }));
- editor.on_zoom_to_fit(on_lanes!(|state, width: f32| {
- let span = state.duration().max(1.0) * 1.05;
- if width > 1.0 {
- state.seconds_per_pixel = (span / width).clamp(0.000_5, 1.5);
- state.scroll_left = 0.0;
- }
- }));
-
- // ── lanes ──
- editor.on_track_flag_changed(on_window!(
- |state, row: i32, visible: bool, muted: bool, locked: bool| {
- state.track_flags(row, visible, muted, locked);
- }
- ));
- editor.on_track_renamed(on_window!(|state, row: i32, name: SharedString| {
- let trimmed = name.trim().to_string();
- let Some(id) = state.row_track(row).map(|track| track.id.clone()) else {
- return;
- };
- if !trimmed.is_empty() {
- state.apply(concat_project::Command::RenameTrack {
- track_id: id,
- name: trimmed,
- });
- }
- }));
- editor.on_track_sized(on_window!(|state, row: i32, size: TrackSize| {
- state.set_lane_size(row, size);
- }));
- editor.on_track_removed(on_window!(|state, row: i32| {
- let Some(id) = state.row_track(row).map(|track| track.id.clone()) else {
- return;
- };
- state.apply(concat_project::Command::RemoveTrack { track_id: id });
- }));
-
- // ── the gestures ──
- editor.on_clip_pressed(on_lanes!(|state,
- id: SharedString,
- additive: bool,
- edge: i32| {
- state.clip_pressed(id.as_str(), additive, edge);
- }));
- editor.on_clip_dragged(on_lanes!(|state, seconds: f32, pixels: f32| {
- state.clip_dragged(seconds, pixels);
- }));
- editor.on_clip_released(on_window!(|state| {
- state.clip_released();
- }));
-
- // ── drag and drop from the library ──
- editor.on_drag_hovered(on_lanes!(|state,
- payload: SharedString,
- seconds: f32,
- y: f32| {
- let row = state.row_at(y);
- state.drop = state.plan(payload.as_str(), seconds, row);
- }));
- editor.on_dropped(on_window!(|state,
- payload: SharedString,
- seconds: f32,
- y: f32| {
- state.drop = None;
- let row = state.row_at(y);
- if let Some(plan) = state.plan(payload.as_str(), seconds, row) {
- state.place(&plan);
- }
- }));
- editor.on_razored(on_window!(|state, id: SharedString, seconds: f32| {
- let Some(clip) = state.clip(id.as_str()).cloned() else {
- return;
- };
- if state.locked(&clip.track_id) {
- return;
- }
- state.selection = vec![id.to_string()];
- state.split_at(seconds, true);
- }));
- editor.on_band_selected(on_lanes!(
- |state, from: f32, to: f32, from_y: f32, to_y: f32, additive: bool| {
- let (from_row, to_row) = (state.row_at(from_y), state.row_at(to_y));
- let caught: Vec<String> = state
- .timeline()
- .clips
- .iter()
- .filter(|clip| {
- let row = state.row_of(&clip.track_id);
- row >= from_row
- && row <= to_row
- && (clip.start + clip.duration) as f32 >= from
- && clip.start as f32 <= to
- && !state.locked(&clip.track_id)
- })
- .map(|clip| clip.id.clone())
- .collect();
- if additive {
- for id in caught {
- if !state.selection.contains(&id) {
- state.selection.push(id);
- }
- }
- } else {
- state.selection = caught;
- }
- }
- ));
-
- // ── the inspector ──
- editor.on_clip_set(on_lanes!(|state, field: ClipField, value: f32| {
- state.clip_set(field, value);
- }));
- editor.on_clip_set_text(on_lanes!(
- |state, field: ClipTextField, value: SharedString| {
- state.clip_set_text(field, value.as_str());
- }
- ));
- editor.on_clip_set_colour(on_lanes!(
- |state, field: ClipTextField, value: slint::Color| {
- state.clip_set_colour(field, value);
- }
- ));
- editor.on_clip_commit(on_window!(|state| {
- state.clip_commit();
- }));
-
- // ── the chains ──
- editor.on_chain_add(on_window!(|state, audio: bool, id: SharedString| {
- state.chain_add(audio, id.as_str());
- }));
- editor.on_chain_toggle(on_window!(|state, audio: bool, index: i32| {
- state.chain_toggle(audio, index);
- }));
- editor.on_chain_move_by(on_window!(|state, audio: bool, index: i32, delta: i32| {
- state.chain_move(audio, index, delta);
- }));
- editor.on_chain_remove(on_window!(|state, audio: bool, index: i32| {
- state.chain_remove(audio, index);
- }));
- editor.on_chain_set_param(on_lanes!(
- |state, audio: bool, index: i32, key: SharedString, value: f32| {
- state.chain_set_param(audio, index, key.as_str(), value);
- }
- ));
-
- editor.on_adjust_set(on_lanes!(|state, key: SharedString, value: f32| {
- state.adjust_set(key.as_str(), value);
- }));
-
- // ── the monitor ──
- editor.on_seek(on_lanes!(|state, seconds: f32| {
- state.pause();
- state.seek(seconds);
- }));
- editor.on_step_frames(on_lanes!(|state, frames: f32| {
- state.pause();
- let fps = state.frame_rate().round().max(1.0);
- let at = (state.playhead * fps).round() + frames;
- state.seek(at / fps);
- }));
- editor.on_ratio_changed(on_window!(|state, index: i32| {
- state.set_output((index.max(0) as usize).min(OUTPUTS.len() - 1));
- }));
- editor.on_quality_changed(on_window!(|state, index: i32| {
- state.quality = (index.max(0) as usize).min(2);
- state.request_preview();
- }));
- editor.on_play_toggled(on_window!(|state| {
- state.play_toggle();
- }));
-
- // ── the stage ──
- editor.on_stage_pressed(on_window!(|state, x: f32, y: f32, additive: bool| {
- state.stage_pressed(x, y, additive);
- }));
- editor.on_stage_grip_pressed(on_window!(
- |state, id: SharedString, grip: i32, x: f32, y: f32| {
- state.stage_grip_pressed(id.as_str(), grip, x, y);
- }
- ));
- editor.on_stage_dragged(on_lanes!(|state, x: f32, y: f32, snap: bool| {
- state.stage_dragged(x, y, snap);
- }));
- editor.on_stage_released(on_window!(|state| {
- state.stage_released();
- }));
-
- // ── the context menu ──
- editor.on_clip_context(on_window!(|state, id: SharedString| {
- state.menu_token += 1;
- if state.clip(id.as_str()).is_none() {
- state.menu_target = None;
- return;
- }
- if !state.selection.iter().any(|held| held == id.as_str()) {
- state.selection = vec![id.to_string()];
- }
- state.menu_target = Some(id.to_string());
- }));
- editor.on_menu_selected(on_window!(|state, action: SharedString| {
- // The clip the menu was opened on; failing that, the one clip that
- // is selected, which is what the menu was showing anyway.
- let target = state.menu_target.clone().or_else(|| state.sole_selection());
- let Some(id) = target else {
- return;
- };
- let Some(clip) = state.clip(&id).cloned() else {
- return;
- };
- match action.as_str() {
- "copy" => state.clipboard = Some(clip),
- "duplicate" => state.duplicate(&clip),
- "paste" => {
- if let Some(held) = state.clipboard.clone() {
- let mut source = held;
- // Pasted after the clip that was right-clicked, on its lane.
- source.track_id = clip.track_id.clone();
- source.start = clip.start + clip.duration - source.duration;
- state.duplicate(&source);
- }
- }
- "split" => {
- let at = state.playhead;
- state.selection = vec![id];
- state.split_at(at, true);
- }
- "mute" => {
- let volume = if clip.volume <= 0.0 { 1.0 } else { 0.0 };
- state.apply(concat_project::Command::UpdateClip {
- clip_id: id,
- patch: concat_project::commands::ClipPatch {
- volume: Some(volume),
- ..Default::default()
- },
- });
- }
- "lock" => state.toggle_lock(&clip.track_id),
- "delete" => {
- state.apply(concat_project::Command::RemoveClips { clip_ids: vec![id] });
- state.menu_target = None;
- }
- _ => {}
- }
- }));
-
- // ── the dialogs ──
- app.on_export_clicked(on_window!(|state| {
- state.export.open = true;
- state.export.phase = ExportPhase::Idle;
- state.export.message.clear();
- }));
- app.on_open_settings(on_window!(|state| {
- state.refresh_models();
- state.settings.open = true;
- }));
- // The theme is one bool on the Theme global, and every colour in the
- // tree is a binding away from it; it is also remembered.
- app.on_settings_theme_changed({
- move |dark| {
- Shell::with(|shell, app| {
- app.global::<Theme>().set_dark(dark);
- let mut studio = shell.studio.borrow_mut();
- studio.prefs.dark = Some(dark);
- studio.prefs.save(&studio.host.dirs);
- });
- }
- });
- app.on_export_closed(on_window!(|state| {
- state.export.open = false;
- }));
- app.on_settings_closed(on_window!(|state| {
- state.settings.open = false;
- }));
- app.on_export_name_edited(on_window!(|state, name: SharedString| {
- state.export.name = name.to_string();
- }));
- app.on_export_resolution_changed(on_window!(|state, index: i32| {
- state.export.resolution = (index.max(0) as usize).min(3);
- }));
- app.on_export_rate_changed(on_window!(|state, index: i32| {
- state.export.rate = (index.max(0) as usize).min(2);
- }));
- app.on_export_quality_changed(on_window!(|state, index: i32| {
- state.export.quality = (index.max(0) as usize).min(2);
- }));
- app.on_export_again(on_window!(|state| {
- state.export.phase = ExportPhase::Idle;
- state.export.progress = 0.0;
- }));
- app.on_export_browse(on_window!(|state| {
- let mut dialog = rfd::FileDialog::new().set_title("Export to");
- if !state.export.folder.is_empty() {
- dialog = dialog.set_directory(&state.export.folder);
- }
- if let Some(folder) = dialog.pick_folder() {
- state.export.folder = folder.to_string_lossy().into_owned();
- }
- }));
- app.on_export_reveal(on_window!(|state| {
- if !state.export.written.is_empty()
- && let Err(error) = opener::reveal(&state.export.written)
- {
- state.notify(&format!("Could not show the file: {error}"), true);
- }
- }));
- app.on_export_cancel(on_window!(|state| {
- state.export_cancel();
- }));
- app.on_export_start(on_window!(|state| {
- state.export_start();
- }));
-
- // ── settings ──
- app.on_settings_page_changed(on_window!(|state, index: i32| {
- state.settings.tab = index;
- }));
- app.on_settings_language_changed(on_window!(|state, index: i32| {
- state.settings.language = index.max(0) as usize;
- state.prefs.language = Some(state.settings.language);
- state.prefs.save(&state.host.dirs);
- }));
- app.on_settings_transcribe_language_changed(on_window!(|state, index: i32| {
- state.settings.transcribe_language = index
- .max(0)
- .min(studio::TRANSCRIBE_LANGUAGES.len() as i32 - 1);
- state.prefs.transcribe_language = Some(state.settings.transcribe_language);
- state.prefs.save(&state.host.dirs);
- }));
- app.on_model_activated(on_window!(|state, id: SharedString| {
- state.model_activate(id.as_str());
- }));
- app.on_model_download(on_window!(|state, id: SharedString| {
- state.model_download(id.as_str());
- }));
- app.on_model_cancel(on_window!(|state, id: SharedString| {
- state.model_cancel(id.as_str());
- }));
- app.on_model_remove(on_window!(|state, id: SharedString| {
- state.model_remove(id.as_str());
- }));
-
- // ── the tray's A/V menu ──
- editor.on_av_tools(on_window!(|state| {
- state.av_token += 1;
- }));
- editor.on_av_selected(on_window!(|state, action: SharedString| {
- let Some(id) = state.selection.first().cloned() else {
- return;
- };
- match action.as_str() {
- "captions" => state.caption_selected(),
- "speak" => state.speak_selected(),
- "detach" => {
- state.apply(concat_project::Command::DetachAudio { clip_id: id });
- }
- "reattach" => {
- state.apply(concat_project::Command::ReattachAudio { clip_id: id });
- }
- _ => {}
- }
- }));
-
- // ── the title-bar menus ──
- app.on_menu_opened(on_window!(|state, index: i32| {
- state.open_menu = index;
- state.menu_bar_token += 1;
- }));
- app.on_app_menu_selected({
- move |action| {
- Shell::with(|shell, app| {
- {
- let mut state = shell.studio.borrow_mut();
- state.open_menu = -1;
- match action.as_str() {
- "add-selected" => state.add_selected_media(),
- "import" => {
- if let Some(paths) = rfd::FileDialog::new()
- .set_title("Import media")
- .pick_files()
- {
- state.import(paths);
- }
- }
- "export" => {
- state.export.open = true;
- state.export.phase = ExportPhase::Idle;
- state.export.message.clear();
- }
- "template" => state.save_template(),
- "speech" => state.speak_selected(),
- "settings" => {
- state.refresh_models();
- state.settings.open = true;
- }
- "close-project" => state.close_project(),
- "undo" => state.undo(),
- "redo" => state.redo(),
- "snap" => state.snap = !state.snap,
- "zoom-in" => {
- state.seconds_per_pixel = (state.seconds_per_pixel / 1.4).max(0.000_5)
- }
- "zoom-out" => {
- state.seconds_per_pixel = (state.seconds_per_pixel * 1.4).min(1.5)
- }
- "start" => {
- state.pause();
- state.seek(0.0);
- }
- "end" => {
- state.pause();
- let end = state.duration();
- state.seek(end);
- }
- "delete" => state.delete_selected(),
- "split" => {
- let at = state.playhead;
- state.split_at(at, false);
- }
- "save" => state.save(true),
- _ => {}
- }
- }
- if action == "close-window" {
- shell.studio.borrow_mut().close_project();
- app.window().hide().ok();
- return;
- }
- shell.studio.borrow_mut().refresh_art();
- shell.studio.borrow().publish(&app, &shell.models);
- });
- }
- });
-
- // --- the pieces Slint cannot express ---------------------------------
- app.global::<Curves>().on_ease(format::bezier_y_at_x);
- app.global::<Curves>()
- .on_parse(|text, fallback| format::parse_bezier(text.as_str(), fallback));
- app.global::<Fmt>()
- .on_parse_timecode(|text| format::parse_timecode(text.as_str()));
- app.global::<Fmt>().on_tick_interval(format::tick_interval);
- app.global::<Fmt>()
- .on_parse_frames(|text, rate| format::parse_frames(text.as_str(), rate));
-
- // The drag payloads: plain text, because a drag that says "media:12" is
- // one that can be read in a log.
- app.global::<Payload>().on_of(DataTransfer::from);
- app.global::<Payload>()
- .on_text(|payload| payload.plain_text().unwrap_or_default());
- app.global::<Payload>().on_pane_seat(|text| {
- text.strip_prefix("pane:")
- .and_then(|rest| rest.split(':').next())
- .and_then(|seat| seat.parse().ok())
- .unwrap_or(-1)
- });
-
- // The picture the cursor carries, resolved through the same `incoming`
- // the drop uses, memoised by theme and payload.
- app.global::<Payload>().on_preview({
- let chips: RefCell<HashMap<String, slint::Image>> = RefCell::new(HashMap::new());
- move |payload| {
- let mut result = slint::Image::default();
- Shell::with(|shell, app| {
- let theme = app.global::<Theme>();
- let key = format!("{}{payload}", if theme.get_dark() { 'd' } else { 'l' });
- if let Some(chip) = chips.borrow().get(&key) {
- result = chip.clone();
- return;
- }
- if let Some(rest) = payload.strip_prefix("pane:") {
- let mut fields = rest.splitn(3, ':').skip(1);
- let label = fields.next().unwrap_or_default();
- let slug = fields.next().unwrap_or_default();
- let chip = slint::Image::load_from_svg_data(
- chips::drag_chip_svg(
- chips::pane_glyph(slug),
- label,
- "",
- theme.get_accent(),
- theme.get_field(),
- theme.get_raised(),
- theme.get_fg(),
- )
- .as_bytes(),
- )
- .unwrap_or_default();
- chips.borrow_mut().insert(key, chip.clone());
- result = chip;
- return;
- }
- let studio = shell.studio.borrow();
- let Some(plan) = studio.incoming(payload.as_str()) else {
- return;
- };
- let (mark, well) = match plan.kind {
- ClipKind::Video => (theme.get_kind_video(), theme.get_kind_video_well()),
- ClipKind::Audio => (theme.get_kind_audio(), theme.get_kind_audio_well()),
- ClipKind::Image => (theme.get_kind_image(), theme.get_kind_image_well()),
- ClipKind::Text => (theme.get_kind_text(), theme.get_kind_text_well()),
- ClipKind::Filter => (theme.get_kind_filter(), theme.get_kind_filter_well()),
- };
- let wave = studio
- .peaks
- .get(&plan.media)
- .filter(|_| plan.kind == ClipKind::Audio)
- .map(|peaks| format::wave_path(peaks, 0.0, plan.duration, 1.0))
- .unwrap_or_default();
- let document = chips::drag_chip_svg(
- chips::chip_glyph(plan.kind),
- &plan.label,
- &wave,
- mark,
- well,
- theme.get_raised(),
- theme.get_fg(),
- );
- let chip =
- slint::Image::load_from_svg_data(document.as_bytes()).unwrap_or_default();
- chips.borrow_mut().insert(key, chip.clone());
- result = chip;
- });
- result
- }
- });
-
- // The programme level meter has no feed yet: playback's mix does not
- // report levels. It stays parked at silence.
- app.on_meter_watched_changed({
- let weak = app.as_weak();
- move |_watched| {
- if let Some(app) = weak.upgrade() {
- app.global::<Editor>().set_level(0.0);
- app.global::<Editor>().set_peak(-1.0);
- }
- }
- });
-
- {
- shell.studio.borrow_mut().refresh_art();
- shell.studio.borrow().publish(&app, &shell.models);
- }
-
- app.run()
+ concat::run()
}
diff --git a/engine/crates/concat/src/platform.rs b/engine/crates/concat/src/platform.rs
new file mode 100644
index 00000000..19df3e09
--- /dev/null
+++ b/engine/crates/concat/src/platform.rs
@@ -0,0 +1,157 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! What the window asks of the platform it runs on.
+//!
+//! Three things differ between a desk and a phone: how the backend is
+//! chosen, how a file or folder is picked, and whether the window has a
+//! title strip of its own to drag. Everything else in the crate is the same
+//! tree, the same state and the same callbacks, so the differences live here
+//! and nowhere else.
+//!
+//! Desktop and iOS draw through the winit backend; Android through Slint's
+//! android-activity backend, which the activity sets up before [`crate::run`]
+//! is called. File dialogs are the desktop's: on a phone a pick goes through
+//! the system's document picker, which arrives with the phone layout.
+
+use std::path::PathBuf;
+
+use slint::PlatformError;
+
+use crate::gpu::Gpu;
+
+/// Whether the window draws the macOS traffic lights over its own strip.
+pub const MACOS: bool = cfg!(target_os = "macos");
+
+/// Chooses and installs the backend, and hands back the device the
+/// renderer and the engine's compositor share, when there is one.
+#[cfg(not(target_os = "android"))]
+pub fn select_backend() -> Result<Option<Gpu>, PlatformError> {
+ // The device the renderer and the monitor share. Taken first, because
+ // the backend is selected with it.
+ let gpu = Gpu::acquire();
+ if gpu.is_none() {
+ eprintln!("concat: no GPU adapter; the monitor composites on the CPU");
+ }
+
+ let mut selector = slint::BackendSelector::new().backend_name("winit".into());
+ selector = match &gpu {
+ Some(gpu) => selector.require_wgpu_29(gpu.configuration()),
+ None => {
+ // Without a shared device, ask for the platform's own API by
+ // name: Skia picks its surface from a cfg chain, and requiring
+ // one turns a silent fall back to the CPU rasteriser into a
+ // refusal to start, which is a fault you can see.
+ #[cfg(target_vendor = "apple")]
+ {
+ selector.require_metal()
+ }
+ #[cfg(target_family = "windows")]
+ {
+ selector.require_d3d()
+ }
+ #[cfg(not(any(target_vendor = "apple", target_family = "windows")))]
+ {
+ selector
+ }
+ }
+ };
+
+ // The custom title bar. On macOS the native bar is hidden and the traffic
+ // lights are overlaid on the strip the UI draws. Other platforms keep
+ // their decorations.
+ #[cfg(target_os = "macos")]
+ {
+ use slint::winit_030::winit::platform::macos::WindowAttributesExtMacOS;
+ selector = selector.with_winit_window_attributes_hook(|attributes| {
+ attributes
+ .with_titlebar_transparent(true)
+ .with_title_hidden(true)
+ .with_fullsize_content_view(true)
+ });
+ }
+ selector.select()?;
+ Ok(gpu)
+}
+
+/// On Android the activity installed the backend before calling in, and
+/// that backend draws on a device of its own; the monitor composites on the
+/// CPU and hands the renderer finished pixels.
+#[cfg(target_os = "android")]
+pub fn select_backend() -> Result<Option<Gpu>, PlatformError> {
+ Ok(None)
+}
+
+/// Starts a window drag from the title strip.
+pub fn begin_drag(window: &slint::Window) {
+ #[cfg(not(target_os = "android"))]
+ {
+ use slint::winit_030::WinitWindowAccessor;
+ window.with_winit_window(|window| {
+ let _ = window.drag_window();
+ });
+ }
+ #[cfg(target_os = "android")]
+ let _ = window;
+}
+
+/// Maximises the window, or restores it: the title strip's double-click.
+pub fn toggle_maximize(window: &slint::Window) {
+ #[cfg(not(target_os = "android"))]
+ {
+ use slint::winit_030::WinitWindowAccessor;
+ window.with_winit_window(|window| {
+ window.set_maximized(!window.is_maximized());
+ });
+ }
+ #[cfg(target_os = "android")]
+ let _ = window;
+}
+
+/// Asks for a folder, starting at `start` when there is one.
+pub fn pick_folder(title: &str, start: &str) -> Option<PathBuf> {
+ #[cfg(not(any(target_os = "android", target_os = "ios")))]
+ {
+ let mut dialog = rfd::FileDialog::new().set_title(title);
+ if !start.is_empty() {
+ dialog = dialog.set_directory(start);
+ }
+ dialog.pick_folder()
+ }
+ #[cfg(any(target_os = "android", target_os = "ios"))]
+ {
+ let _ = (title, start);
+ None
+ }
+}
+
+/// Asks for files. `filter` names a family and its extensions, and limits
+/// the dialog to them.
+pub fn pick_files(title: &str, filter: Option<(&str, &[&str])>) -> Option<Vec<PathBuf>> {
+ #[cfg(not(any(target_os = "android", target_os = "ios")))]
+ {
+ let mut dialog = rfd::FileDialog::new().set_title(title);
+ if let Some((name, extensions)) = filter {
+ dialog = dialog.add_filter(name, extensions);
+ }
+ dialog.pick_files()
+ }
+ #[cfg(any(target_os = "android", target_os = "ios"))]
+ {
+ let _ = (title, filter);
+ None
+ }
+}
+
+/// Shows a written file in the platform's file manager.
+pub fn reveal(path: &str) -> Result<(), String> {
+ #[cfg(not(any(target_os = "android", target_os = "ios")))]
+ {
+ opener::reveal(path).map_err(|error| error.to_string())
+ }
+ #[cfg(any(target_os = "android", target_os = "ios"))]
+ {
+ let _ = path;
+ Ok(())
+ }
+}
diff --git a/engine/scripts/ios-app.sh b/engine/scripts/ios-app.sh
new file mode 100755
index 00000000..d459e96d
--- /dev/null
+++ b/engine/scripts/ios-app.sh
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+# Wraps the iOS build of the window into an app bundle.
+#
+# scripts/ios-app.sh aarch64-apple-ios [release|debug]
+# scripts/ios-app.sh aarch64-apple-ios-sim [release|debug]
+#
+# Build first (`cargo build -p concat --target aarch64-apple-ios --release`
+# under `eval "$(scripts/mobile-env.sh aarch64-apple-ios)"`), then this
+# lays out target/<target>/<profile>/Concat.app: the binary, an Info.plist,
+# the icon, and the sherpa-onnx framework the binary loads, with the load
+# path rewritten to the bundle. The bundle is ad-hoc signed, which is what
+# a simulator accepts; a phone needs a developer identity and provisioning
+# profile on top, with `codesign --force --sign "<identity>"`.
+set -euo pipefail
+
+target=${1:?target triple: aarch64-apple-ios or aarch64-apple-ios-sim}
+profile=${2:-release}
+engine=$(cd "$(dirname "$0")/.." && pwd)
+root=$(cd "$engine/.." && pwd)
+version=$(sed -n 's/^version = "\(.*\)"/\1/p' "$engine/Cargo.toml" | head -1)
+ios_min=${IPHONEOS_DEPLOYMENT_TARGET:-15.0}
+
+binary=$engine/target/$target/$profile/concat
+[ -f "$binary" ] || { echo "no binary at $binary: build first" >&2; exit 1; }
+framework=$(find "$engine/vendor/sherpa-onnx/ios" -maxdepth 2 -name '*.xcframework' | head -1)
+[ -n "$framework" ] || { echo "no sherpa-onnx xcframework: run scripts/sherpa-mobile.sh $target" >&2; exit 1; }
+slice=ios-arm64
+[ "$target" = aarch64-apple-ios-sim ] && slice=ios-arm64_x86_64-simulator
+
+app=$engine/target/$target/$profile/Concat.app
+rm -rf "$app"
+mkdir -p "$app/Frameworks"
+cp "$binary" "$app/Concat"
+cp -R "$framework/$slice/SherpaOnnxC.framework" "$app/Frameworks/"
+cp "$root/assets/icons/concat_logo_512.png" "$app/AppIcon.png" 2>/dev/null || true
+
+# The binary was linked against the dylib by the name the linker saw in
+# vendor/; in the bundle it lives in Frameworks/ under the framework's
+# own name.
+old=$(otool -L "$app/Concat" | awk '/sherpa-onnx-c-api|SherpaOnnxC/ {print $1; exit}')
+if [ -n "$old" ]; then
+ install_name_tool -change "$old" "@rpath/SherpaOnnxC.framework/SherpaOnnxC" "$app/Concat"
+fi
+install_name_tool -add_rpath "@executable_path/Frameworks" "$app/Concat" 2>/dev/null || true
+
+platform=iPhoneOS
+[ "$target" = aarch64-apple-ios-sim ] && platform=iPhoneSimulator
+cat > "$app/Info.plist" <<PLIST
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleName</key><string>Concat</string>
+ <key>CFBundleDisplayName</key><string>Concat</string>
+ <key>CFBundleIdentifier</key><string>app.concat.editor</string>
+ <key>CFBundleVersion</key><string>${version}</string>
+ <key>CFBundleShortVersionString</key><string>${version}</string>
+ <key>CFBundleExecutable</key><string>Concat</string>
+ <key>CFBundlePackageType</key><string>APPL</string>
+ <key>CFBundleSupportedPlatforms</key><array><string>${platform}</string></array>
+ <key>MinimumOSVersion</key><string>${ios_min}</string>
+ <key>UIDeviceFamily</key><array><integer>1</integer><integer>2</integer></array>
+ <key>UILaunchScreen</key><dict/>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>UIRequiresFullScreen</key><true/>
+ <key>LSApplicationCategoryType</key><string>public.app-category.video</string>
+ <key>NSPhotoLibraryUsageDescription</key><string>Concat imports the clips you pick.</string>
+ <key>NSMicrophoneUsageDescription</key><string>Concat records voice-over.</string>
+ <key>NSHumanReadableCopyright</key><string>AGPL-3.0-or-later. See THIRD_PARTY_NOTICES.md.</string>
+</dict>
+</plist>
+PLIST
+
+codesign --force --sign - "$app/Frameworks/SherpaOnnxC.framework"
+codesign --force --sign - "$app"
+echo "Bundled $app"
diff --git a/engine/scripts/mobile-env.sh b/engine/scripts/mobile-env.sh
new file mode 100755
index 00000000..1f46238c
--- /dev/null
+++ b/engine/scripts/mobile-env.sh
@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+# The build environment for a phone, as shell exports:
+#
+# eval "$(scripts/mobile-env.sh aarch64-linux-android)"
+# cargo ndk -t arm64-v8a --platform 26 build -p concat-android
+#
+# eval "$(scripts/mobile-env.sh aarch64-apple-ios)"
+# cargo build -p concat --target aarch64-apple-ios
+#
+# It names what the two fetch scripts left in vendor/ - FFmpeg through
+# FFMPEG_DIR, sherpa-onnx through SHERPA_ONNX_LIB_DIR - and on Android the
+# SDK pieces the build scripts of Slint's backend and whisper.cpp read.
+# Run scripts/ffmpeg-mobile.sh and scripts/sherpa-mobile.sh for the target
+# first.
+set -euo pipefail
+
+target=${1:?target triple: aarch64-linux-android or aarch64-apple-ios}
+engine=$(cd "$(dirname "$0")/.." && pwd)
+ffmpeg=$engine/vendor/ffmpeg/$target
+[ -d "$ffmpeg/lib" ] || { echo "no FFmpeg for $target: run scripts/ffmpeg-mobile.sh $target" >&2; exit 1; }
+echo "export FFMPEG_DIR='$ffmpeg'"
+
+case "$target" in
+ aarch64-linux-android)
+ sherpa=$engine/vendor/sherpa-onnx/jniLibs/arm64-v8a
+ [ -d "$sherpa" ] || { echo "no sherpa-onnx for $target: run scripts/sherpa-mobile.sh $target" >&2; exit 1; }
+ echo "export SHERPA_ONNX_LIB_DIR='$sherpa'"
+
+ sdk=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}}
+ ndk=${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT:-$(ls -d "$sdk"/ndk/* 2>/dev/null | sort -V | tail -1 || true)}}
+ [ -d "$ndk" ] || { echo "no Android NDK: set ANDROID_NDK_HOME" >&2; exit 1; }
+ # Every name the toolchain is asked by: cargo-ndk and cargo-apk read
+ # ANDROID_NDK_HOME, CMake's Android platform (whisper.cpp) reads
+ # ANDROID_NDK_ROOT, and skia-bindings reads ANDROID_NDK.
+ echo "export ANDROID_HOME='$sdk' ANDROID_NDK_HOME='$ndk' ANDROID_NDK_ROOT='$ndk' ANDROID_NDK='$ndk'"
+ # bindgen reads FFmpeg's headers with its own libclang, which knows
+ # nothing of the NDK until told where the sysroot is.
+ host_tag=$(ls "$ndk/toolchains/llvm/prebuilt" | head -1)
+ echo "export BINDGEN_EXTRA_CLANG_ARGS_aarch64_linux_android='--sysroot=$ndk/toolchains/llvm/prebuilt/$host_tag/sysroot'"
+ # Slint's backend compiles a Java helper against the SDK platform's
+ # android.jar. cargo-ndk names the NDK API level as ANDROID_PLATFORM,
+ # which is also the name the lookup reads for the SDK platform, and the
+ # two need not be installed together; the jar is named outright.
+ platform=$(ls -d "$sdk"/platforms/android-* 2>/dev/null | sort -V | tail -1 || true)
+ [ -f "$platform/android.jar" ] || { echo "no SDK platform under $sdk/platforms" >&2; exit 1; }
+ echo "export ANDROID_JAR='$platform/android.jar'"
+
+ # whisper-rs-sys names ggml-blas on the link line whenever the machine
+ # doing the build is a Mac, a fact it reads with cfg!(target_os) in its
+ # build script, where that is the host and not the target. Building
+ # for Android on a Mac, ggml has no BLAS and no such archive. An empty
+ # archive under that name, on the search path, is what the linker finds
+ # instead, and it contributes exactly what the missing library would
+ # have. The ar magic alone is a well-formed archive with no members.
+ if [ "$(uname -s)" = Darwin ]; then
+ shim=$engine/vendor/shim/$target
+ mkdir -p "$shim"
+ printf '!<arch>\n' > "$shim/libggml-blas.a"
+ echo "export RUSTFLAGS='-L native=$shim'"
+ fi
+ ;;
+ aarch64-apple-ios)
+ sherpa=$engine/vendor/sherpa-onnx/ios/lib
+ [ -d "$sherpa" ] || { echo "no sherpa-onnx for $target: run scripts/sherpa-mobile.sh $target" >&2; exit 1; }
+ echo "export SHERPA_ONNX_LIB_DIR='$sherpa'"
+ echo "export IPHONEOS_DEPLOYMENT_TARGET='${IPHONEOS_DEPLOYMENT_TARGET:-15.0}'"
+ ;;
+ *)
+ echo "unknown target $target" >&2; exit 1 ;;
+esac
diff --git a/engine/scripts/sherpa-mobile.sh b/engine/scripts/sherpa-mobile.sh
new file mode 100755
index 00000000..ff66f8e4
--- /dev/null
+++ b/engine/scripts/sherpa-mobile.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+# Fetches the sherpa-onnx runtime libraries for a phone: the shared
+# libraries k2-fsa publishes, which the app carries with it.
+#
+# scripts/sherpa-mobile.sh aarch64-linux-android [out-dir]
+# scripts/sherpa-mobile.sh aarch64-apple-ios [out-dir]
+#
+# The version is the one the lockfile resolved for sherpa-onnx-sys, so a
+# bump of the crate cannot desynchronise from the libraries.
+#
+# Android: vendor/sherpa-onnx/jniLibs/<abi>/*.so, the layout an APK's
+# native library directory takes, with the NDK's libc++_shared.so beside
+# them because onnxruntime loads it. Point SHERPA_ONNX_LIB_DIR at the ABI
+# directory to build, and cargo-apk packages the whole tree through
+# concat-android's manifest.
+#
+# iOS: vendor/sherpa-onnx/ios/sherpa-onnx.xcframework, the framework the
+# app bundle embeds; SHERPA_ONNX_LIB_DIR is its device slice.
+set -euo pipefail
+
+target=${1:?target triple: aarch64-linux-android or aarch64-apple-ios}
+engine=$(cd "$(dirname "$0")/.." && pwd)
+version=$(grep -A1 'name = "sherpa-onnx-sys"' "$engine/Cargo.lock" | sed -n 's/^version = "\(.*\)"/\1/p')
+release=https://github.com/k2-fsa/sherpa-onnx/releases/download
+
+case "$target" in
+ aarch64-linux-android)
+ out=${2:-$engine/vendor/sherpa-onnx}
+ ndk=${ANDROID_NDK_HOME:-${ANDROID_NDK_ROOT:-}}
+ if [ -z "$ndk" ]; then
+ sdk=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Library/Android/sdk}}
+ ndk=$(ls -d "$sdk"/ndk/* 2>/dev/null | sort -V | tail -1 || true)
+ fi
+ [ -d "$ndk" ] || { echo "no Android NDK: set ANDROID_NDK_HOME" >&2; exit 1; }
+ host_tag=$(ls "$ndk/toolchains/llvm/prebuilt" | head -1)
+ echo "Fetching sherpa-onnx $version for Android"
+ mkdir -p "$out"
+ curl -fsSL --retry 5 --retry-all-errors -o "$out/sherpa-onnx-android.tar.bz2" \
+ "$release/v$version/sherpa-onnx-v$version-android.tar.bz2"
+ tar -xjf "$out/sherpa-onnx-android.tar.bz2" -C "$out"
+ rm "$out/sherpa-onnx-android.tar.bz2"
+ # Only the ABI the app is built for ships; the rest is left behind.
+ find "$out/jniLibs" -mindepth 1 -maxdepth 1 -type d ! -name arm64-v8a -exec rm -rf {} +
+ # The C API and its runtime are what the engine loads; the JNI and
+ # C++ bindings are for other languages.
+ rm -f "$out"/jniLibs/arm64-v8a/libsherpa-onnx-jni.so "$out"/jniLibs/arm64-v8a/libsherpa-onnx-cxx-api.so
+ cp "$ndk/toolchains/llvm/prebuilt/$host_tag/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so" \
+ "$out/jniLibs/arm64-v8a/"
+ echo "sherpa-onnx for Android is in $out/jniLibs"
+ echo " export SHERPA_ONNX_LIB_DIR=$out/jniLibs/arm64-v8a"
+ ;;
+ aarch64-apple-ios)
+ out=${2:-$engine/vendor/sherpa-onnx/ios}
+ echo "Fetching sherpa-onnx $version for iOS"
+ mkdir -p "$out"
+ curl -fsSL --retry 5 --retry-all-errors -o "$out/sherpa-onnx-ios.zip" \
+ "$release/xcframework/sherpa-onnx-v$version-ios-shared-onnxruntime-static.xcframework.zip"
+ (cd "$out" && unzip -qo sherpa-onnx-ios.zip && rm sherpa-onnx-ios.zip)
+ framework=$(find "$out" -maxdepth 2 -name '*.xcframework' | head -1)
+ [ -n "$framework" ] || { echo "no xcframework in the archive" >&2; exit 1; }
+ binary=$framework/ios-arm64/SherpaOnnxC.framework/SherpaOnnxC
+ [ -f "$binary" ] || { echo "no device slice in $framework" >&2; exit 1; }
+ # The linker looks for the library by its lib-prefixed name; the
+ # framework carries the dylib under the framework's own.
+ mkdir -p "$out/lib"
+ ln -sf "$binary" "$out/lib/libsherpa-onnx-c-api.dylib"
+ echo "sherpa-onnx for iOS is $framework"
+ echo " export SHERPA_ONNX_LIB_DIR=$out/lib"
+ ;;
+ *)
+ echo "unknown target $target" >&2; exit 1 ;;
+esac