Skip to content

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

feat(mobile): a document picker on Android, and a compact dock for narrow windows

Jareer796da2871989
diff --git a/engine/crates/concat-android/Cargo.toml b/engine/crates/concat-android/Cargo.toml
index 52c6dbd2..9ec5b0df 100644
--- a/engine/crates/concat-android/Cargo.toml
+++ b/engine/crates/concat-android/Cargo.toml
@@ -26,6 +26,15 @@ slint = { version = "1.17", default-features = false, features = [
log = "0.4"
android_logger = "0.15"
libc = "0.2"
+# The bridge to the activity's Java: the document picker in java/, loaded
+# from the dex that build.rs makes. The version Slint's backend uses, so
+# there is one JNI in the binary.
+jni = "0.22"
+
+[build-dependencies]
+# javac and d8 through the SDK, the way Slint's backend compiles its own
+# helper.
+android-build = "0.1"
# `cargo apk build -p concat-android` packages the shared object, the
# sherpa-onnx runtime libraries and the manifest below into an APK. The
diff --git a/engine/crates/concat-android/build.rs b/engine/crates/concat-android/build.rs
new file mode 100644
index 00000000..94da021d
--- /dev/null
+++ b/engine/crates/concat-android/build.rs
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! Compiles the Java the activity needs - the document picker fragment in
+//! java/ - into one dex file the binary carries and loads at run time.
+//! The same way Slint's Android backend builds its own helper: the SDK's
+//! javac and d8, found through ANDROID_HOME and JAVA_HOME. Nothing to do
+//! for any other target.
+
+fn main() {
+ println!("cargo:rerun-if-changed=java/ConcatFiles.java");
+ let target = std::env::var("TARGET").unwrap_or_default();
+ if !target.contains("android") {
+ return;
+ }
+
+ let release = std::env::var("PROFILE").as_deref() == Ok("release");
+ let out_dir = std::path::PathBuf::from(std::env::var_os("OUT_DIR").expect("OUT_DIR"));
+ let classes = out_dir.join("java");
+ if classes.exists() {
+ let _ = std::fs::remove_dir_all(&classes);
+ }
+ std::fs::create_dir_all(&classes).expect("could not create the class directory");
+
+ let android_jar = android_build::android_jar(None).expect("no Android platform found");
+ let compiled = android_build::JavaBuild::new()
+ .file("java/ConcatFiles.java")
+ .class_path(&android_jar)
+ .classes_out_dir(&classes)
+ .java_source_version(8)
+ .java_target_version(8)
+ .debug_info(android_build::DebugInfo {
+ line_numbers: !release,
+ variables: !release,
+ source_files: !release,
+ })
+ .command()
+ .expect("could not build the javac command")
+ .args(["-encoding", "UTF-8"])
+ .output()
+ .expect("could not run javac");
+ if !compiled.status.success() {
+ panic!(
+ "javac failed: {}",
+ String::from_utf8_lossy(&compiled.stderr)
+ );
+ }
+
+ let dexed = android_build::Dexer::new()
+ .android_jar(&android_jar)
+ .class_path(&classes)
+ .collect_classes(&classes)
+ .expect("could not collect the classes")
+ .release(release)
+ .android_min_api(26)
+ .out_dir(&out_dir)
+ .command()
+ .expect("could not build the d8 command")
+ .output()
+ .expect("could not run d8");
+ if !dexed.status.success() {
+ panic!("d8 failed: {}", String::from_utf8_lossy(&dexed.stderr));
+ }
+}
diff --git a/engine/crates/concat-android/java/ConcatFiles.java b/engine/crates/concat-android/java/ConcatFiles.java
new file mode 100644
index 00000000..798beef4
--- /dev/null
+++ b/engine/crates/concat-android/java/ConcatFiles.java
@@ -0,0 +1,199 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+package app.concat.editor;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.content.ClipData;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.provider.OpenableColumns;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The system's document picker, for an activity that has no Java of its
+ * own to receive its answer.
+ *
+ * The window is a NativeActivity: the framework's own class, with nothing
+ * of ours to override, and a picker's result comes back only through an
+ * activity's or a fragment's onActivityResult. So this is a fragment - a
+ * headless one, added to the activity for the length of one pick - and
+ * the result comes back here.
+ *
+ * What is picked is a content URI, which the engine's decoder cannot open:
+ * it reads files by path. Each is copied into the app's own external
+ * files, under Imported/, keeping its display name, and the paths are
+ * what the engine is handed - through the native method below, which the
+ * Rust side registers before it asks for a pick.
+ *
+ * Compiled by build.rs with the SDK's javac and d8, and loaded at run time
+ * from the dex inside the binary; see src/lib.rs.
+ */
+public class ConcatFiles extends Fragment {
+ private static final int REQUEST_PICK = 0xC0C4;
+ private static final String TAG = "concat-files";
+
+ /** Registered from Rust: the picked files' paths, or none. */
+ public static native void filesPicked(String[] paths);
+
+ /** Shows the picker. From any thread; the fragment is added on the UI thread. */
+ public static void pick(final Activity activity) {
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ConcatFiles fragment = new ConcatFiles();
+ activity.getFragmentManager()
+ .beginTransaction()
+ .add(fragment, TAG)
+ .commitAllowingStateLoss();
+ activity.getFragmentManager().executePendingTransactions();
+
+ Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.setType("*/*");
+ intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"video/*", "audio/*", "image/*"});
+ intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+ try {
+ fragment.startActivityForResult(intent, REQUEST_PICK);
+ } catch (Exception e) {
+ fragment.done(new ArrayList<Uri>());
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onActivityResult(int request, int result, Intent data) {
+ if (request != REQUEST_PICK) {
+ return;
+ }
+ List<Uri> uris = new ArrayList<Uri>();
+ if (result == Activity.RESULT_OK && data != null) {
+ ClipData clip = data.getClipData();
+ if (clip != null) {
+ for (int i = 0; i < clip.getItemCount(); i++) {
+ Uri uri = clip.getItemAt(i).getUri();
+ if (uri != null) {
+ uris.add(uri);
+ }
+ }
+ } else if (data.getData() != null) {
+ uris.add(data.getData());
+ }
+ }
+ done(uris);
+ }
+
+ /** Copies what was picked and reports it; then the fragment goes. */
+ private void done(final List<Uri> uris) {
+ final Activity activity = getActivity();
+ try {
+ getFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
+ } catch (Exception ignored) {
+ }
+ if (activity == null || uris.isEmpty()) {
+ filesPicked(new String[0]);
+ return;
+ }
+ // Off the UI thread: a video is big and the copy takes a while.
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ List<String> paths = new ArrayList<String>();
+ File dir = new File(activity.getExternalFilesDir(null), "Imported");
+ dir.mkdirs();
+ for (Uri uri : uris) {
+ File out = unique(dir, displayName(activity, uri));
+ if (copy(activity, uri, out)) {
+ paths.add(out.getAbsolutePath());
+ }
+ }
+ filesPicked(paths.toArray(new String[0]));
+ }
+ }, TAG).start();
+ }
+
+ /** The name the picker showed for the file, or one made from the URI. */
+ private static String displayName(Activity activity, Uri uri) {
+ String name = null;
+ Cursor cursor = null;
+ try {
+ cursor = activity.getContentResolver().query(uri, null, null, null, null);
+ if (cursor != null && cursor.moveToFirst()) {
+ int column = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
+ if (column >= 0) {
+ name = cursor.getString(column);
+ }
+ }
+ } catch (Exception ignored) {
+ } finally {
+ if (cursor != null) {
+ cursor.close();
+ }
+ }
+ if (name == null || name.isEmpty()) {
+ name = uri.getLastPathSegment();
+ }
+ if (name == null || name.isEmpty()) {
+ name = "import";
+ }
+ // Whatever the provider called it, it is one file name.
+ return name.replace('/', '_').replace('\\', '_');
+ }
+
+ /** `name`, or `name (2)`, `name (3)`... until nothing is overwritten. */
+ private static File unique(File dir, String name) {
+ File out = new File(dir, name);
+ if (!out.exists()) {
+ return out;
+ }
+ int dot = name.lastIndexOf('.');
+ String stem = dot > 0 ? name.substring(0, dot) : name;
+ String ext = dot > 0 ? name.substring(dot) : "";
+ for (int n = 2; ; n++) {
+ out = new File(dir, stem + " (" + n + ")" + ext);
+ if (!out.exists()) {
+ return out;
+ }
+ }
+ }
+
+ private static boolean copy(Activity activity, Uri uri, File out) {
+ InputStream in = null;
+ OutputStream os = null;
+ try {
+ in = activity.getContentResolver().openInputStream(uri);
+ if (in == null) {
+ return false;
+ }
+ os = new FileOutputStream(out);
+ byte[] buffer = new byte[1 << 16];
+ int read;
+ while ((read = in.read(buffer)) > 0) {
+ os.write(buffer, 0, read);
+ }
+ return true;
+ } catch (IOException e) {
+ out.delete();
+ return false;
+ } finally {
+ try {
+ if (in != null) in.close();
+ } catch (IOException ignored) {
+ }
+ try {
+ if (os != null) os.close();
+ } catch (IOException ignored) {
+ }
+ }
+ }
+}
diff --git a/engine/crates/concat-android/src/lib.rs b/engine/crates/concat-android/src/lib.rs
index 1a2df729..2daea09f 100644
--- a/engine/crates/concat-android/src/lib.rs
+++ b/engine/crates/concat-android/src/lib.rs
@@ -96,6 +96,161 @@ mod activity {
}
}
+/// The system's document picker, reached through the Java in java/.
+///
+/// The window is a NativeActivity with no Java of its own, and a picker's
+/// answer comes back only through Java; so the Java is a fragment
+/// compiled by build.rs into a dex the binary carries, loaded here through
+/// an in-memory class loader, and told - by registering a native method on
+/// it - where to bring the answer. The picked files are copied into the
+/// app's own storage by the Java, and their paths are what comes back.
+#[cfg(target_os = "android")]
+mod picker {
+ use std::ffi::c_void;
+ use std::path::PathBuf;
+ use std::sync::{Mutex, OnceLock};
+
+ use jni::objects::{Global, JClass, JObject, JObjectArray, JString};
+ use jni::{Env, JavaVM, jni_sig, jni_str, sys};
+ use slint::android::AndroidApp;
+
+ /// The classes build.rs compiled: app.concat.editor.ConcatFiles.
+ const DEX: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/classes.dex"));
+ const CLASS_NAME: &str = "app.concat.editor.ConcatFiles";
+
+ type Picked = Box<dyn FnOnce(Vec<PathBuf>) + Send>;
+
+ /// The pick in flight, waiting for Java to answer.
+ static PENDING: Mutex<Option<Picked>> = Mutex::new(None);
+ /// The fragment class, loaded once and kept.
+ static CLASS: OnceLock<Global<JClass<'static>>> = OnceLock::new();
+
+ /// Hands the window's crate a picker that runs on this activity.
+ pub fn install(app: &AndroidApp) {
+ let app = app.clone();
+ concat::install_file_picker(Box::new(move |on_picked| {
+ let previous = PENDING
+ .lock()
+ .map(|mut slot| slot.replace(on_picked))
+ .ok()
+ .flatten();
+ if let Some(previous) = previous {
+ // A pick was already up; the one that asked first is told
+ // it got nothing rather than left waiting for ever.
+ previous(Vec::new());
+ }
+ if let Err(error) = pick(&app) {
+ log::error!("could not show the document picker: {error}");
+ if let Some(pending) = PENDING.lock().ok().and_then(|mut slot| slot.take()) {
+ pending(Vec::new());
+ }
+ }
+ }));
+ }
+
+ fn pick(app: &AndroidApp) -> jni::errors::Result<()> {
+ // SAFETY: the pointer is the activity's JavaVM, live for the
+ // process; `from_raw` also seeds `JavaVM::singleton`, which the
+ // native callback below reaches for.
+ let vm = unsafe { JavaVM::from_raw(app.vm_as_ptr().cast()) };
+ vm.attach_current_thread(|env| {
+ // SAFETY: the activity pointer is a live reference the app
+ // holds for as long as it runs; it is only read here.
+ let activity = unsafe { JObject::from_raw(env, app.activity_as_ptr().cast()) };
+ let class = match CLASS.get() {
+ Some(class) => class,
+ None => {
+ let loaded = load_class(env, &activity)?;
+ let _ = CLASS.set(loaded);
+ CLASS.get().expect("set just above")
+ }
+ };
+ env.call_static_method(
+ class,
+ jni_str!("pick"),
+ jni_sig!("(Landroid/app/Activity;)V"),
+ &[(&activity).into()],
+ )?;
+ Ok(())
+ })
+ }
+
+ /// Loads the fragment class from the dex through the activity's own
+ /// class loader, and registers `filesPicked` on it.
+ fn load_class(
+ env: &mut Env,
+ activity: &JObject,
+ ) -> jni::errors::Result<Global<JClass<'static>>> {
+ let parent = env
+ .call_method(
+ activity,
+ jni_str!("getClassLoader"),
+ jni_sig!("()Ljava/lang/ClassLoader;"),
+ &[],
+ )?
+ .l()?;
+ // SAFETY: DEX is 'static and the loader never writes to it.
+ let buffer = unsafe { env.new_direct_byte_buffer(DEX.as_ptr().cast_mut(), DEX.len()) }?;
+ let loader = env.new_object(
+ jni_str!("dalvik/system/InMemoryDexClassLoader"),
+ jni_sig!("(Ljava/nio/ByteBuffer;Ljava/lang/ClassLoader;)V"),
+ &[(&buffer).into(), (&parent).into()],
+ )?;
+ let name = env.new_string(CLASS_NAME)?;
+ let class = env
+ .call_method(
+ &loader,
+ jni_str!("loadClass"),
+ jni_sig!("(Ljava/lang/String;)Ljava/lang/Class;"),
+ &[(&name).into()],
+ )?
+ .l()?;
+ let class = JClass::cast_local(env, class)?;
+ // SAFETY: the signature is the Java declaration's, and the
+ // function below takes exactly what it names.
+ let method = unsafe {
+ jni::NativeMethod::from_raw_parts(
+ jni_str!("filesPicked"),
+ jni_str!("([Ljava/lang/String;)V"),
+ files_picked as *mut c_void,
+ )
+ };
+ // SAFETY: as above.
+ unsafe { env.register_native_methods(&class, &[method]) }?;
+ env.new_global_ref(class)
+ }
+
+ /// `ConcatFiles.filesPicked`, on whichever thread the Java copied on.
+ unsafe extern "system" fn files_picked(
+ _env: *mut sys::JNIEnv,
+ _class: sys::jclass,
+ paths: sys::jobjectArray,
+ ) {
+ let read = JavaVM::singleton().and_then(|vm| {
+ vm.attach_current_thread(|env| {
+ // SAFETY: `paths` is the argument Java handed this frame.
+ let array = unsafe { JObjectArray::<JString>::from_raw(env, paths) };
+ let mut out = Vec::new();
+ for index in 0..array.len(env)? {
+ let item = array.get_element(env, index)?;
+ out.push(PathBuf::from(item.mutf8_chars(env)?.to_string()));
+ }
+ Ok::<_, jni::errors::Error>(out)
+ })
+ });
+ let paths = match read {
+ Ok(paths) => paths,
+ Err(error) => {
+ log::error!("could not read the picked files: {error}");
+ Vec::new()
+ }
+ };
+ if let Some(pending) = PENDING.lock().ok().and_then(|mut slot| slot.take()) {
+ pending(paths);
+ }
+ }
+}
+
/// Called by the activity's native glue; the name is the contract.
#[cfg(target_os = "android")]
#[unsafe(no_mangle)]
@@ -104,10 +259,12 @@ fn android_main(app: slint::android::AndroidApp) {
activity::name_directories(&app);
activity::open_log();
log::info!("Concat {} starting", env!("CARGO_PKG_VERSION"));
- if let Err(error) = slint::android::init(app) {
+ if let Err(error) = slint::android::init(app.clone()) {
log::error!("could not start the Android backend: {error}");
return;
}
+ // After the backend, which seeds the JavaVM the picker reaches for.
+ picker::install(&app);
if let Err(error) = concat::run() {
log::error!("{error}");
}
diff --git a/engine/crates/concat/src/dock.rs b/engine/crates/concat/src/dock.rs
index d5970643..01481a75 100644
--- a/engine/crates/concat/src/dock.rs
+++ b/engine/crates/concat/src/dock.rs
@@ -271,6 +271,19 @@ pub fn default_dock() -> Dock {
}
/// The top edge of a row, measured down the stack from the first lane.
+/// The dock a narrow window shows: the monitor over the timeline, and
+/// nothing beside either. The library and the inspector are a switch away
+/// on each seat - see `PaneSwitcher` - which on a phone is how they are
+/// reached in every editor: one at a time, in the space the picture had.
+pub fn compact_dock() -> Dock {
+ Dock::Split {
+ columns: false,
+ ratio: 0.5,
+ first: Dock::leaf(PaneKind::Preview),
+ second: Dock::leaf(PaneKind::Timeline),
+ }
+}
+
pub fn row_top(heights: &[f32], row: i32) -> f32 {
heights.iter().take(row.max(0) as usize).sum()
}
diff --git a/engine/crates/concat/src/lib.rs b/engine/crates/concat/src/lib.rs
index eead749b..daf8af2a 100644
--- a/engine/crates/concat/src/lib.rs
+++ b/engine/crates/concat/src/lib.rs
@@ -38,13 +38,17 @@ mod gpu;
mod host;
mod i18n;
mod platform;
+/// What a phone's own crate installs before the window runs: the way to
+/// the system's file picker. See `platform::pick_files_async`.
+#[cfg(any(target_os = "android", target_os = "ios"))]
+pub use platform::{FilePicker, install_file_picker};
mod prefs;
mod presets;
mod studio;
mod sysinfo;
use dock::{Dock, SEAT_MIN_GRAB, SEAT_MIN_H, SEAT_MIN_W};
-use host::{Host, Shell};
+use host::{Host, Shell, on_ui};
use studio::{Models, OUTPUTS, RESOLUTIONS, START_RATES, Studio};
use ui::*;
@@ -345,6 +349,13 @@ pub fn run() -> Result<(), slint::PlatformError> {
// ── the workspace's arrangement ──
editor.on_workspace_resized(on_dock!(|state, width: f32, height: f32| {
state.workspace = (width, height);
+ // A narrow window - a phone, a tablet held upright, a desktop
+ // window squeezed - gets the compact dock: two seats, the monitor
+ // over the timeline, with the switcher on each to bring the
+ // library or the inspector into it. The wide dock waits, whole,
+ // for the window to widen again; every dock operation works on
+ // whichever is showing.
+ state.set_compact(width < studio::COMPACT_WIDTH);
}));
editor.on_dock_set(on_dock!(|state, seat: i32, kind: PaneKind| {
let Some(path) = state.dock.leaf_path(seat.max(0) as usize) else {
@@ -466,24 +477,28 @@ pub fn run() -> Result<(), slint::PlatformError> {
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(
- &i18n::t("Import media"),
- Some((
- i18n::t("Media").as_str(),
- &[
- "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);
- }
- }));
+ // Not through the handler macro: nothing here changes the state, and
+ // the import is asynchronous - a phone's picker is another screen, and
+ // the files come back later, on whatever thread, to be imported on the
+ // window's. A desktop's dialog answers before this returns.
+ editor.on_import_media(|| {
+ Shell::with(|shell, _| {
+ if shell.studio.borrow().session.is_none() {
+ return;
+ }
+ platform::pick_files_async(
+ &i18n::t("Import media"),
+ Some((
+ i18n::t("Media").as_str(),
+ &[
+ "mp4", "mov", "mkv", "webm", "avi", "m4v", "mp3", "wav", "aac", "m4a",
+ "flac", "ogg", "png", "jpg", "jpeg", "webp", "gif", "bmp", "tif", "tiff",
+ ],
+ )),
+ |paths| on_ui(move |studio, _, _| studio.import(paths)),
+ );
+ });
+ });
editor.on_media_activate(on_window!(|state, id: i32| {
state.place_at_playhead(&format!("media:{id}"));
}));
@@ -1117,11 +1132,9 @@ pub fn run() -> Result<(), slint::PlatformError> {
}
}
"import" => {
- if let Some(paths) =
- platform::pick_files(&i18n::t("Import media"), None)
- {
- state.import(paths);
- }
+ platform::pick_files_async(&i18n::t("Import media"), None, |paths| {
+ on_ui(move |studio, _, _| studio.import(paths))
+ });
}
"export" => {
state.export.open = true;
diff --git a/engine/crates/concat/src/platform.rs b/engine/crates/concat/src/platform.rs
index c5a22bbb..fb5379a4 100644
--- a/engine/crates/concat/src/platform.rs
+++ b/engine/crates/concat/src/platform.rs
@@ -260,6 +260,52 @@ pub fn pick_folder(title: &str, start: &str) -> Option<PathBuf> {
}
}
+/// What a phone does when asked for files: shows the system's picker and
+/// calls back, later, with what was chosen - an empty list for nothing.
+/// Installed by the phone's own crate before the window runs; see
+/// [`install_file_picker`].
+#[cfg(any(target_os = "android", target_os = "ios"))]
+pub type FilePicker = Box<dyn Fn(Box<dyn FnOnce(Vec<PathBuf>) + Send>) + Send + Sync>;
+
+#[cfg(any(target_os = "android", target_os = "ios"))]
+static FILE_PICKER: std::sync::OnceLock<FilePicker> = std::sync::OnceLock::new();
+
+/// Installs the picker a phone answers [`pick_files_async`] with. Once;
+/// a second call is ignored.
+#[cfg(any(target_os = "android", target_os = "ios"))]
+pub fn install_file_picker(picker: FilePicker) {
+ let _ = FILE_PICKER.set(picker);
+}
+
+/// Asks for files and calls `on_picked` with them, on whichever thread the
+/// platform answers from - the caller hops to the window's thread itself.
+///
+/// On a desktop the dialog blocks and the callback runs before this
+/// returns. On a phone the system's picker is another screen: this returns
+/// at once and the callback comes when the picker is dismissed, through
+/// the picker the phone's crate installed. `filter` is the desktop
+/// dialog's; a phone's picker offers every kind of media on its own.
+pub fn pick_files_async(
+ title: &str,
+ filter: Option<(&str, &[&str])>,
+ on_picked: impl FnOnce(Vec<PathBuf>) + Send + 'static,
+) {
+ #[cfg(not(any(target_os = "android", target_os = "ios")))]
+ {
+ if let Some(paths) = pick_files(title, filter) {
+ on_picked(paths);
+ }
+ }
+ #[cfg(any(target_os = "android", target_os = "ios"))]
+ {
+ let _ = (title, filter);
+ match FILE_PICKER.get() {
+ Some(picker) => picker(Box::new(on_picked)),
+ None => log::warn!("no file picker on this platform yet"),
+ }
+ }
+}
+
/// 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>> {
diff --git a/engine/crates/concat/src/studio.rs b/engine/crates/concat/src/studio.rs
index 6aaeba2d..bbde64a0 100644
--- a/engine/crates/concat/src/studio.rs
+++ b/engine/crates/concat/src/studio.rs
@@ -145,6 +145,10 @@ const WAVE_STEPS: f32 = 30.0;
/// the picker chooses how fine, never which way round.
pub const EXPORT_SHORT_SIDES: [u32; 4] = [2160, 1440, 1080, 720];
pub const EXPORT_RATES: [(i64, i64); 3] = [(24, 1), (30, 1), (60, 1)];
+/// Narrower than this, in logical pixels, and the workspace shows the
+/// compact dock: a phone, a tablet held upright, a desktop window squeezed
+/// to a corner. Four panes across less than this is four slivers.
+pub const COMPACT_WIDTH: f32 = 860.0;
/// Megabits per second at 1080p30 for each quality tier, for the size
/// estimate; and the CRF each tier renders at.
const EXPORT_TIERS: [f32; 3] = [16.0, 8.0, 4.0];
@@ -756,6 +760,12 @@ pub struct Studio {
// ── the workspace ──
pub dock: Dock,
+ /// The dock not showing: the compact one while the window is wide,
+ /// the wide one while it is compact. Swapped with `dock` as the
+ /// window crosses `COMPACT_WIDTH`, so each keeps its shape.
+ pub dock_aside: Dock,
+ /// Whether `dock` is the compact one.
+ pub compact: bool,
pub workspace: (f32, f32),
pub divider_press: Option<(usize, f32, f32)>,
pub gesture: Gesture,
@@ -1425,6 +1435,8 @@ impl Studio {
posters_pending: HashSet::new(),
project_name: "Untitled project".into(),
dock: default_dock(),
+ dock_aside: crate::dock::compact_dock(),
+ compact: false,
workspace: (0.0, 0.0),
divider_press: None,
gesture: Gesture::None,
@@ -5880,6 +5892,15 @@ impl Studio {
sync(&models.dividers, out.dividers);
}
+ /// Shows the compact dock, or the wide one, keeping whichever is put
+ /// away whole; see `COMPACT_WIDTH`.
+ pub fn set_compact(&mut self, compact: bool) {
+ if compact != self.compact {
+ std::mem::swap(&mut self.dock, &mut self.dock_aside);
+ self.compact = compact;
+ }
+ }
+
pub fn dock_layout(&self) -> DockLayout {
let mut out = DockLayout::default();
let (width, height) = self.workspace;