Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(poc-d3d): typed inspector params, a param store, and sync on activation

Etienne Lescot5e503a69370a
diff --git a/poc-d3d/compositor-view-napi/src/lib.rs b/poc-d3d/compositor-view-napi/src/lib.rs
index 41bc463bc..6b9356165 100644
--- a/poc-d3d/compositor-view-napi/src/lib.rs
+++ b/poc-d3d/compositor-view-napi/src/lib.rs
@@ -81,11 +81,17 @@ pub fn set_rect(id: i32, rect: CompositorViewRect) {
}
}
-/// Param live. Phase 1 : seul `backgroundBlur` (booléen) est branché côté compositeur.
+/// Param live (inspector). Le type de valeur route vers le bon setter :
+/// bool = switch (backgroundBlur…), number = slider (shadow/roundness/motionBlur),
+/// string = sélection (backgroundColor "#rrggbb").
#[napi]
-pub fn set_param(id: i32, key: String, value: bool) {
+pub fn set_param(id: i32, key: String, value: Either3<bool, f64, String>) {
if let Some(v) = registry().lock().unwrap().get(&id) {
- v.set_param(&key, value);
+ match value {
+ Either3::A(b) => v.set_param_bool(&key, b),
+ Either3::B(n) => v.set_param_num(&key, n),
+ Either3::C(s) => v.set_param_str(&key, &s),
+ }
}
}
diff --git a/poc-d3d/src/compositor.rs b/poc-d3d/src/compositor.rs
index 57b50c7ff..e426d057e 100644
--- a/poc-d3d/src/compositor.rs
+++ b/poc-d3d/src/compositor.rs
@@ -36,6 +36,23 @@ pub struct LayerCB {
pub mb: [f32; 4], // mb[0] = nombre de taps de motion blur
}
+/// Valeurs continues pilotées par l'inspector (celles qui étaient codées en dur dans
+/// `compose_frame`). Le défaut reproduit le rendu actuel → bench/export inchangés.
+/// Les booléens/taps (fond flouté, ombre on/off, coins on/off, motion blur) restent
+/// portés par le `Cfg` que le thread live reconstruit depuis les switches.
+#[derive(Clone, Copy)]
+pub struct LiveParams {
+ pub bg_color: [f32; 4], // fond plat (mode couleur) quand non flouté
+ pub shadow_scale: f32, // multiplie l'opacité des ombres (1 = défaut, 0 = off)
+ pub radius_scale: f32, // multiplie le rayon des coins (1 = défaut, 0 = carré)
+}
+
+impl Default for LiveParams {
+ fn default() -> Self {
+ Self { bg_color: [0.10, 0.11, 0.14, 1.0], shadow_scale: 1.0, radius_scale: 1.0 }
+ }
+}
+
pub struct Compositor {
dev: ID3D11Device,
ctx: ID3D11DeviceContext,
@@ -78,6 +95,7 @@ pub struct Compositor {
// cache des SRV décodeur par (texture array, slice) : le pool réutilise ~32 textures,
// donc après warmup plus aucune création de SRV par frame (overhead CPU supprimé).
srv_cache: RefCell<HashMap<(usize, u32), (ID3D11ShaderResourceView, ID3D11ShaderResourceView)>>,
+ live_params: RefCell<LiveParams>,
}
pub const HALF_W: u32 = OUT_W / 2;
@@ -483,9 +501,15 @@ impl Compositor {
blend_add: blend_add.unwrap(),
cursor: None,
srv_cache: RefCell::new(HashMap::new()),
+ live_params: RefCell::new(LiveParams::default()),
})
}
+ /// Met à jour les paramètres continus pilotés par l'inspector (thread live uniquement).
+ pub fn set_live_params(&self, p: LiveParams) {
+ *self.live_params.borrow_mut() = p;
+ }
+
/// Crée les SRV Y (R8) et UV (R8G8) sur la tranche d'array de la frame décodeur.
pub unsafe fn nv12_srvs(
&self,
@@ -698,9 +722,10 @@ impl Compositor {
let p = timeline(frame, cfg);
let pp = timeline(frame - 1.0, cfg); // frame précédente, pour la vélocité (§8)
+ let lp = *self.live_params.borrow();
let mb_taps = cfg.mblur_n as f32;
- let s_radius = if cfg.rounded { p.screen.radius } else { 0.0 };
- let w_radius = if cfg.rounded { p.webcam.radius } else { 0.0 };
+ let s_radius = if cfg.rounded { p.screen.radius * lp.radius_scale } else { 0.0 };
+ let w_radius = if cfg.rounded { p.webcam.radius * lp.radius_scale } else { 0.0 };
self.begin([0.0, 0.0, 0.0, 1.0]);
@@ -731,7 +756,7 @@ impl Compositor {
self.draw_solid(&LayerCB {
dst: [0.0, 0.0, 1.0, 1.0],
mode: 1.0,
- color: [0.10, 0.11, 0.14, 1.0],
+ color: lp.bg_color,
..Default::default()
});
}
@@ -750,7 +775,7 @@ impl Compositor {
let sv0_p = (cy - hv_p).clamp(0.0, v_max - 2.0 * hv_p);
let s_px = [p.screen.dst[2] * OUT_W as f32, p.screen.dst[3] * OUT_H as f32];
if cfg.shadow {
- self.draw_shadow(p.screen.dst, s_px, s_radius, 40.0, [0.0, 16.0], 0.45);
+ self.draw_shadow(p.screen.dst, s_px, s_radius, 40.0, [0.0, 16.0], 0.45 * lp.shadow_scale);
}
self.draw_video(
&LayerCB {
@@ -812,7 +837,7 @@ impl Compositor {
let u1 = u0 + sq / wtw as f32;
let w_px = [p.webcam.dst[2] * OUT_W as f32, p.webcam.dst[3] * OUT_H as f32];
if cfg.shadow {
- self.draw_shadow(p.webcam.dst, w_px, w_radius, 32.0, [0.0, 12.0], 0.5);
+ self.draw_shadow(p.webcam.dst, w_px, w_radius, 32.0, [0.0, 12.0], 0.5 * lp.shadow_scale);
}
self.draw_video(
&LayerCB {
diff --git a/poc-d3d/src/live.rs b/poc-d3d/src/live.rs
index 05c4991f1..b3b5b07dc 100644
--- a/poc-d3d/src/live.rs
+++ b/poc-d3d/src/live.rs
@@ -8,7 +8,7 @@
//! Present) tourne sur un **thread dédié** — le thread JS/UI n'est jamais bloqué. Les
//! objets COM restent sur le thread de rendu (le HWND, lui, traverse en `isize`).
-use crate::compositor::Compositor;
+use crate::compositor::{Compositor, LiveParams};
use crate::config::{self, Cfg};
use crate::cursor::CursorTrack;
use crate::d3d::Gpu;
@@ -40,6 +40,18 @@ fn wide(s: &str) -> Vec<u16> {
s.encode_utf16().chain(std::iter::once(0)).collect()
}
+/// "#rrggbb" (ou "rrggbb") → [r, g, b, 1] en 0..1. None si invalide.
+fn parse_hex_color(s: &str) -> Option<[f32; 4]> {
+ let h = s.trim().trim_start_matches('#');
+ if h.len() != 6 {
+ return None;
+ }
+ let r = u8::from_str_radix(&h[0..2], 16).ok()? as f32 / 255.0;
+ let g = u8::from_str_radix(&h[2..4], 16).ok()? as f32 / 255.0;
+ let b = u8::from_str_radix(&h[4..6], 16).ok()? as f32 / 255.0;
+ Some([r, g, b, 1.0])
+}
+
/// Lit deux sources en lockstep et compose la frame courante dans le RT du compositeur.
/// Partagé avec la GUI standalone (`app.rs`).
pub struct Player {
@@ -89,12 +101,35 @@ impl Player {
}
}
+/// Paramètres inspector pilotés depuis l'UI (setParam). Le thread de rendu les applique :
+/// booléens/taps → reconstruits dans le `Cfg` ; valeurs continues → `set_live_params`.
+#[derive(Clone, Copy)]
+struct InspectorParams {
+ bg_blur: bool,
+ bg_color: [f32; 4],
+ shadow_scale: f32,
+ radius_scale: f32,
+ mblur_taps: u32,
+}
+
+impl Default for InspectorParams {
+ fn default() -> Self {
+ Self {
+ bg_blur: false,
+ bg_color: [0.10, 0.11, 0.14, 1.0],
+ shadow_scale: 1.0,
+ radius_scale: 1.0,
+ mblur_taps: 8,
+ }
+ }
+}
+
/// État partagé thread appelant → thread de rendu (commandes sans blocage).
struct Shared {
/// rect viewport en px device [x, y, w, h], relatif au client de la fenêtre parente.
/// Le thread de rendu le mappe en coords écran (le parent peut bouger) et repositionne.
rect: Mutex<[i32; 4]>,
- bg_blur: AtomicBool,
+ inspector: Mutex<InspectorParams>,
playing: AtomicBool,
stop: AtomicBool,
}
@@ -149,7 +184,7 @@ impl LiveView {
let shared = Arc::new(Shared {
rect: Mutex::new([x, y, w, h]),
- bg_blur: AtomicBool::new(false),
+ inspector: Mutex::new(InspectorParams::default()),
playing: AtomicBool::new(true),
stop: AtomicBool::new(false),
});
@@ -175,10 +210,37 @@ impl LiveView {
}
}
- /// Paramètre live (Phase 1 : un seul, le fond flouté).
- pub fn set_param(&self, key: &str, value: bool) {
- if key == "backgroundBlur" {
- self.shared.bg_blur.store(value, Ordering::Relaxed);
+ /// Switch inspector (booléen).
+ pub fn set_param_bool(&self, key: &str, value: bool) {
+ if let Ok(mut p) = self.shared.inspector.lock() {
+ if key == "backgroundBlur" {
+ p.bg_blur = value;
+ }
+ }
+ }
+
+ /// Slider inspector (numérique). Conventions : `shadow`/`roundness` = échelle (1 = défaut),
+ /// `motionBlur` = 0..1 mappé sur 1..16 taps.
+ pub fn set_param_num(&self, key: &str, value: f64) {
+ if let Ok(mut p) = self.shared.inspector.lock() {
+ let v = value as f32;
+ match key {
+ "shadow" => p.shadow_scale = v.max(0.0),
+ "roundness" => p.radius_scale = v.max(0.0),
+ "motionBlur" => p.mblur_taps = (1.0 + value.clamp(0.0, 1.0) * 15.0).round() as u32,
+ _ => {}
+ }
+ }
+ }
+
+ /// Sélection de fond (couleur "#rrggbb").
+ pub fn set_param_str(&self, key: &str, value: &str) {
+ if key == "backgroundColor" {
+ if let Some(c) = parse_hex_color(value) {
+ if let Ok(mut p) = self.shared.inspector.lock() {
+ p.bg_color = c;
+ }
+ }
}
}
@@ -284,7 +346,17 @@ unsafe fn render_thread(
let mut last_screen = [i32::MIN; 4];
while !shared.stop.load(Ordering::SeqCst) {
- cfg.bg_blur = shared.bg_blur.load(Ordering::Relaxed);
+ // params inspector : booléens/taps → cfg ; valeurs continues → live_params
+ {
+ let ip = *shared.inspector.lock().unwrap();
+ cfg.bg_blur = ip.bg_blur;
+ cfg.mblur_n = ip.mblur_taps;
+ comp.set_live_params(LiveParams {
+ bg_color: ip.bg_color,
+ shadow_scale: ip.shadow_scale,
+ radius_scale: ip.radius_scale,
+ });
+ }
// rect viewport → coords écran : suit le rect DOM (set_rect) ET le déplacement du parent
let [vx, vy, vw, vh] = *shared.rect.lock().unwrap();
@@ -454,7 +526,7 @@ pub fn run_standalone(screen: &str, webcam: &str, cursor_json: &str) -> Result<(
0x42 => {
// 'B' : bascule le fond flouté via set_param — chemin param → D3D
blur = !blur;
- view.set_param("backgroundBlur", blur);
+ view.set_param_bool("backgroundBlur", blur);
set_title(blur, playing);
}
0x20 => {
diff --git a/src/components/ai-edition/NativeCompositorOverlay.tsx b/src/components/ai-edition/NativeCompositorOverlay.tsx
index faa8e10df..7195ecec0 100644
--- a/src/components/ai-edition/NativeCompositorOverlay.tsx
+++ b/src/components/ai-edition/NativeCompositorOverlay.tsx
@@ -1,5 +1,5 @@
-import { useRef, useState } from "react";
-import { exportNative, useNativeCompositorView } from "@/native";
+import { useEffect, useRef, useState } from "react";
+import { exportNative, setCurrentNativeViewId, useNativeCompositorView } from "@/native";
/**
* POC Option A — monte une fenêtre D3D11 native (compositeur poc-d3d, via
@@ -13,8 +13,15 @@ import { exportNative, useNativeCompositorView } from "@/native";
*/
export function NativeCompositorOverlay({ enabled }: { enabled: boolean }) {
const mountRef = useRef<HTMLDivElement>(null);
- const { setParam } = useNativeCompositorView(mountRef, { enabled });
+ const { setParam, viewId } = useNativeCompositorView(mountRef, { enabled });
const [blur, setBlur] = useState(false);
+
+ // publie l'id de la vue active dans le store → l'inspector (autre composant) peut
+ // pousser des params via setNativeParam sans connaître cet overlay.
+ useEffect(() => {
+ setCurrentNativeViewId(viewId);
+ return () => setCurrentNativeViewId(null);
+ }, [viewId]);
const [exporting, setExporting] = useState(false);
const [exportStatus, setExportStatus] = useState("");
diff --git a/src/components/ai-edition/RightPanes.tsx b/src/components/ai-edition/RightPanes.tsx
index e82893463..561c7b255 100644
--- a/src/components/ai-edition/RightPanes.tsx
+++ b/src/components/ai-edition/RightPanes.tsx
@@ -55,6 +55,7 @@ import { getAssetPath } from "@/lib/assetPath";
import { CURSOR_THEMES, DEFAULT_CURSOR_THEME_ID } from "@/lib/cursor/cursorThemes";
import { buildGradientFromEditor } from "@/lib/gradientBuilder";
import { resolveImageWallpaperUrl, WALLPAPER_PATHS } from "@/lib/wallpaper";
+import { isNativeCompositorActive, setNativeParam, subscribeNativeCompositor } from "@/native";
import styles from "./NewEditorShell.module.css";
export type RightPaneId =
@@ -123,7 +124,7 @@ function Pane({ title, icon, helpLabel, helpText, children }: PaneProps) {
// ─── Background ────────────────────────────────────────────────────
-// ponytail: keep the gradient palette small and curated — every block renders
+// keep the gradient palette small and curated — every block renders
// in the picker and gets serialized to legacyEditor on save.
const GRAD_PRESETS: readonly string[] = [
"linear-gradient(135deg, #eaebed, #bcc0c6)",
@@ -331,7 +332,7 @@ export function BackgroundPane() {
);
}
-// ponytail: keep the user's last data: URL after they switch tabs so the Image
+// keep the user's last data: URL after they switch tabs so the Image
// tab can keep showing it without immediately pushing it back through `set`.
function useMemoCustomWallpapers(current: string): string[] {
const [cached, setCached] = useState<string[]>([]);
@@ -365,7 +366,12 @@ function BackgroundColorTab({
}, [value]);
const commitHex = () => {
const next = normaliseHex(hexDraft);
- if (next) onPick(next);
+ if (next) {
+ onPick(next);
+ if (isNativeCompositorActive()) {
+ setNativeParam("backgroundColor", next);
+ }
+ }
};
return (
<>
@@ -378,7 +384,12 @@ function BackgroundColorTab({
style={{ background: c }}
aria-label={`Color ${c}`}
disabled={!hasDocument}
- onClick={() => onPick(c)}
+ onClick={() => {
+ onPick(c);
+ if (isNativeCompositorActive()) {
+ setNativeParam("backgroundColor", c);
+ }
+ }}
/>
))}
</div>
@@ -485,7 +496,7 @@ export function TranscriptPane({
[clips, transcripts, assets, trimRanges],
);
- // ponytail: the cue position is the playback head's location in the
+ // the cue position is the playback head's location in the
// current clip's source time. `locateVirtualPosition` already accounts
// for skip ranges and clipped durations — the cue word naturally
// jumps over gaps the user has trimmed.
@@ -598,7 +609,7 @@ function TranscriptClipBlock({
const editorRef = useRef<HTMLDivElement | null>(null);
const pendingCaretWordIdRef = useRef<string | null>(null);
- // ponytail: auto-scroll the cue word into view as the playback head
+ // auto-scroll the cue word into view as the playback head
// moves. The right pane has ONE scroll container (paneBody, which
// already has overflow-y: auto) — the per-clip editor itself is not
// scrollable, so the cue scroll always lands on the paneBody.
@@ -610,7 +621,7 @@ function TranscriptClipBlock({
if (!editor || !cueWordId) return;
const wordElement = editor.querySelector<HTMLElement>(`[data-word-id="${cueWordId}"]`);
if (!wordElement) return;
- // ponytail: walk up to the first scrollable ancestor (paneBody)
+ // walk up to the first scrollable ancestor (paneBody)
// and scroll so the word element lands inside its viewport.
let ancestor: HTMLElement | null = wordElement.parentElement;
while (ancestor && ancestor !== document.body) {
@@ -636,7 +647,7 @@ function TranscriptClipBlock({
}
}, [cueWordId]);
- // ponytail: keep the caret anchored to the next kept word after a
+ // keep the caret anchored to the next kept word after a
// trimRange is added (so the user can keep deleting without the caret
// jumping to the start of the block).
useLayoutEffect(() => {
@@ -695,7 +706,7 @@ function TranscriptClipBlock({
skipWordRange([cw]);
return true;
}
- // ponytail: for a non-collapsed selection, the anchor/focus
+ // for a non-collapsed selection, the anchor/focus
// already identify the endpoints — no need to apply the
// "Backspace at start of word" / "Delete at end of word"
// boundary heuristic (that fallback is for collapsed carets
@@ -735,7 +746,7 @@ function TranscriptClipBlock({
);
return;
}
- // ponytail: typing/pasting free text is non-destructive by design
+ // typing/pasting free text is non-destructive by design
// (the user's transcript edits come via the Source Transcript
// modal, not here). Block inserts to keep the projection stable.
if (inputEvent.inputType === "insertText" || inputEvent.inputType === "insertFromPaste") {
@@ -752,7 +763,7 @@ function TranscriptClipBlock({
const handlePointerUp = useCallback(
(event: ReactPointerEvent<HTMLDivElement>) => {
if (event.button !== 0) return;
- // ponytail: a click on the trim-pill button (bin) bubbles up here
+ // a click on the trim-pill button (bin) bubbles up here
// before the button's onClick fires. Skip those — the bin's own
// handler is responsible for restoring the skip range.
if (event.target instanceof Element && event.target.closest("button")) return;
@@ -761,7 +772,7 @@ function TranscriptClipBlock({
const selection = globalThis.getSelection();
if (selection && !selection.isCollapsed) return; // user is selecting text — let them
- // ponytail: clicks land on the deepest element under the cursor,
+ // clicks land on the deepest element under the cursor,
// which is usually the text node inside a word span. Text nodes
// don't have `closest`, and a non-filler word's text is rendered
// as a bare text node (no inner span). Walk up to an Element
@@ -873,7 +884,7 @@ function TranscriptClipBlock({
textWrap: "pretty",
cursor: "text",
outline: "none",
- // ponytail: no overflow on the per-clip editor — the
+ // no overflow on the per-clip editor — the
// parent paneBody (already overflow-y: auto) is the
// single scroll container for the whole transcript.
// Scrolling within the editor would create a nested
@@ -1011,7 +1022,7 @@ function TranscriptWord({
onMouseEnter={() => setHover(true)}
onMouseLeave={() => setHover(false)}
>
- {/* ponytail: no filler chip. axcut renders every word the same way;
+ {/* no filler chip. axcut renders every word the same way;
the LLM is the only place that names a word a filler (via the
filler_or_hesitation reason when generating suggestions). */}
{cw.word.text}{" "}
@@ -1023,7 +1034,7 @@ function TranscriptWord({
aria-label={`Restore "${cw.word.text}"`}
onClick={(e) => {
e.stopPropagation();
- // ponytail: build a minimal TrimRun stub — only trimId is
+ // build a minimal TrimRun stub — only trimId is
// read by onRestore.
onRestore({
trimId: cw.trimId ?? "",
@@ -1073,7 +1084,7 @@ function findCollapsedDeletionWordId(
direction: "backward" | "forward",
words: ClipWord[],
): string | null {
- // ponytail: read the kept/skip state from the words array, not the
+ // read the kept/skip state from the words array, not the
// DOM's data-skip-id. The DOM may be lagging a render behind (its
// trimId is only set on the next React commit), so a DOM check would
// re-trim an already-trimmed word. The words array is the React state
@@ -1085,7 +1096,7 @@ function findCollapsedDeletionWordId(
const textLength = node?.textContent?.length ?? 0;
if (node?.nodeType === Node.TEXT_NODE) {
if (direction === "backward" && offset <= 0) {
- // ponytail: clicking at the start of a word normally deletes
+ // clicking at the start of a word normally deletes
// the previous word, but when the previous word is already
// trimmed, that would be a no-op. Fall back to the current
// word so Backspace always does something.
@@ -1112,7 +1123,7 @@ function findCollapsedDeletionWordId(
if (!boundaryNode) return null;
const childNodes = Array.from(boundaryNode.childNodes);
- // ponytail: when restoreCaretBeforeWord places the caret before word W
+ // when restoreCaretBeforeWord places the caret before word W
// (via setStartBefore), `anchorNode` becomes the parent div and
// `anchorOffset` is W's index. The naive "previous sibling" lookup
// below would always return the word that was *just* trimmed, which
@@ -1194,6 +1205,37 @@ export type { AxcutWord };
export function VideoEffectsPane() {
const { settings, set, setLive, commit, hasDocument } = useEditorSettings();
+
+ // Push the current frame-styling settings into the native D3D compositor
+ // view whenever it becomes active (or the settings change while it's up).
+ // The onChange handlers above already push per-control diffs; this effect
+ // also covers the "user tweaked a setting before the native view was
+ // mounted" case so the view doesn't render with stale defaults.
+ const ROUNDNESS_MAX = 64;
+ useEffect(() => {
+ const syncToNative = () => {
+ // pas de garde `isNativeCompositorActive` : setNativeParam mémorise les valeurs
+ // même sans vue active, et le store les rejoue quand une vue s'active (fix du
+ // démarrage sur les défauts, indépendant de l'ordre de montage).
+ setNativeParam("backgroundBlur", settings.showBlur);
+ setNativeParam("motionBlur", settings.motionBlurAmount);
+ setNativeParam("shadow", settings.shadowIntensity);
+ setNativeParam("roundness", settings.borderRadius / ROUNDNESS_MAX);
+ const bg = settings.wallpaper;
+ if (bg.startsWith("#")) {
+ setNativeParam("backgroundColor", bg);
+ }
+ };
+ syncToNative();
+ return subscribeNativeCompositor(syncToNative);
+ }, [
+ settings.showBlur,
+ settings.motionBlurAmount,
+ settings.shadowIntensity,
+ settings.borderRadius,
+ settings.wallpaper,
+ ]);
+
return (
<Pane
title="Video effects"
@@ -1205,7 +1247,12 @@ export function VideoEffectsPane() {
<Toggle
checked={settings.showBlur}
disabled={!hasDocument}
- onChange={(v) => void set({ showBlur: v })}
+ onChange={(v) => {
+ void set({ showBlur: v });
+ if (isNativeCompositorActive()) {
+ setNativeParam("backgroundBlur", v);
+ }
+ }}
/>
</div>
<div className={styles.sliderGrid}>
@@ -1216,7 +1263,12 @@ export function VideoEffectsPane() {
max={100}
suffix="%"
disabled={!hasDocument}
- onChange={(v) => setLive({ motionBlurAmount: v / 100 })}
+ onChange={(v) => {
+ setLive({ motionBlurAmount: v / 100 });
+ if (isNativeCompositorActive()) {
+ setNativeParam("motionBlur", v / 100);
+ }
+ }}
onCommit={() => void commit()}
/>
<SliderCell
@@ -1226,7 +1278,12 @@ export function VideoEffectsPane() {
max={100}
suffix="%"
disabled={!hasDocument}
- onChange={(v) => setLive({ shadowIntensity: v / 100 })}
+ onChange={(v) => {
+ setLive({ shadowIntensity: v / 100 });
+ if (isNativeCompositorActive()) {
+ setNativeParam("shadow", v / 100);
+ }
+ }}
onCommit={() => void commit()}
/>
<SliderCell
@@ -1237,9 +1294,15 @@ export function VideoEffectsPane() {
step={0.5}
suffix="px"
disabled={!hasDocument}
- onChange={(v) => setLive({ borderRadius: v })}
+ onChange={(v) => {
+ setLive({ borderRadius: v });
+ if (isNativeCompositorActive()) {
+ setNativeParam("roundness", v / ROUNDNESS_MAX);
+ }
+ }}
onCommit={() => void commit()}
/>
+ {/* TODO: native padding */}
<SliderCell
label="Padding"
value={settings.padding}
@@ -1278,7 +1341,7 @@ const CAMERA_SHAPES: Array<{
export function LayoutPane() {
const { settings, set, setLive, commit, hasDocument } = useEditorSettings();
const document = useProjectStore((s) => s.document);
- // ponytail: the mask shape picker only makes sense for Picture-in-Picture.
+ // the mask shape picker only makes sense for Picture-in-Picture.
// Dual-frame (side-by-side) and vertical-stack (top/bottom) hardcode a
// rectangle in the legacy layout math, so we hide those controls when the
// preset isn't PiP.
@@ -1625,6 +1688,6 @@ function SliderCell({
);
}
-// ponytail: legacy color wheel / hue track styling was a cosmetic placeholder —
+// legacy color wheel / hue track styling was a cosmetic placeholder —
// the active BackgroundColorTab uses real pickers (color input + hex text) so
// the static style helpers are no longer needed.
diff --git a/src/native/index.ts b/src/native/index.ts
index 06d5a52c1..fb858d1d0 100644
--- a/src/native/index.ts
+++ b/src/native/index.ts
@@ -4,4 +4,5 @@ export * from "./contracts";
export * from "./hooks/useCursorRecordingData";
export * from "./hooks/useCursorTelemetry";
export * from "./hooks/useNativeCompositorView";
+export * from "./nativeCompositorStore";
export * from "./nativeViewRect";
diff --git a/src/native/nativeCompositorStore.ts b/src/native/nativeCompositorStore.ts
new file mode 100644
index 000000000..a336bf862
--- /dev/null
+++ b/src/native/nativeCompositorStore.ts
@@ -0,0 +1,61 @@
+/**
+ * Petit store global de la vue native active. `NativeCompositorOverlay` crée la vue et
+ * enregistre son id ici ; n'importe quel contrôle (inspector, transport…) peut alors
+ * pousser un paramètre via `setNativeParam` sans connaître l'overlay. No-op tant qu'aucune
+ * vue n'est active (flag `VITE_NATIVE_COMPOSITOR` off ou addon absent).
+ */
+import { setCompositorParam } from "./compositorViewClient";
+import type { CompositorParamValue } from "./contracts";
+
+let currentViewId: number | null = null;
+const listeners = new Set<() => void>();
+/** Derniers params poussés, par clé — rejoués à l'activation d'une vue (voir plus bas). */
+const lastParams = new Map<string, CompositorParamValue>();
+
+/** Appelé par l'overlay quand la vue native est créée (id) ou détruite (null). */
+export function setCurrentNativeViewId(id: number | null): void {
+ if (currentViewId === id) {
+ return;
+ }
+ currentViewId = id;
+ // Rejoue les params connus sur la vue qui vient de s'activer. Rend la synchro
+ // indépendante de l'ordre de montage : une valeur poussée avant l'existence de la vue
+ // (memoïsée par setNativeParam) est appliquée ici, pas seulement les changements futurs.
+ if (id !== null) {
+ for (const [key, value] of lastParams) {
+ setCompositorParam(id, key, value).catch(() => {});
+ }
+ }
+ for (const l of listeners) {
+ l();
+ }
+}
+
+export function getCurrentNativeViewId(): number | null {
+ return currentViewId;
+}
+
+/** True quand une vue native est montée — pour n'appeler `setNativeParam` que si utile. */
+export function isNativeCompositorActive(): boolean {
+ return currentViewId !== null;
+}
+
+/** Pousse un paramètre à la vue native active, ET le mémorise pour rejeu à l'activation
+ * d'une (nouvelle) vue. No-op sur l'envoi si aucune vue ; la valeur reste mémorisée. */
+export function setNativeParam(key: string, value: CompositorParamValue): void {
+ lastParams.set(key, value);
+ if (currentViewId === null) {
+ return;
+ }
+ setCompositorParam(currentViewId, key, value).catch((error: unknown) => {
+ console.warn(`[compositor-view] setNativeParam(${key}) failed:`, error);
+ });
+}
+
+/** S'abonner à l'activité de la vue native (React: via useSyncExternalStore). */
+export function subscribeNativeCompositor(listener: () => void): () => void {
+ listeners.add(listener);
+ return () => {
+ listeners.delete(listener);
+ };
+}