Skip to content

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

feat(timeline): the tray's Captions, Text to speech and Voiceover buttons toggle their panels

Jareer43006bfaa66e
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 1cbd1f51..8261ba0c 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -1828,8 +1828,15 @@ fn start(project: Option<std::path::PathBuf>, smoke: bool) -> Result<(), slint::
}));
// ── the tray's sound and word tools ──
+ // The tray's panel buttons are toggles: a press opens the panel, or
+ // puts it away when it is up.
editor.on_captions(on_window!(|state| {
- state.handle(Msg::Captions(CaptionsMsg::Open));
+ let msg = if state.captions.open {
+ CaptionsMsg::Close
+ } else {
+ CaptionsMsg::Open
+ };
+ state.handle(Msg::Captions(msg));
}));
editor.on_record_voiceover(on_window!(|state| {
state.handle(Msg::Voiceover(VoiceoverMsg::Toggle));
@@ -1871,7 +1878,12 @@ fn start(project: Option<std::path::PathBuf>, smoke: bool) -> Result<(), slint::
state.handle(Msg::Voiceover(VoiceoverMsg::PromptSpeed(index)));
}));
editor.on_speak(on_window!(|state| {
- state.handle(Msg::Speech(SpeechMsg::Open));
+ let msg = if state.speech.open {
+ SpeechMsg::Close
+ } else {
+ SpeechMsg::Open
+ };
+ state.handle(Msg::Speech(msg));
}));
app.on_captions_closed(on_window!(|state| {
diff --git a/src/crates/concat/src/panes/voiceover.rs b/src/crates/concat/src/panes/voiceover.rs
index b927692d..823d888d 100644
--- a/src/crates/concat/src/panes/voiceover.rs
+++ b/src/crates/concat/src/panes/voiceover.rs
@@ -242,6 +242,11 @@ pub struct VoiceoverPane {
impl VoiceoverPane {
/// Whether a take is under way, counted in or paused: the tray's
/// button reads Stop.
+ /// Whether the panel is up, for the tray button that opens and closes it.
+ pub fn is_open(&self) -> bool {
+ self.open
+ }
+
pub fn recording(&self) -> bool {
self.phase != Phase::Ready
}
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 19e72172..6fa8e670 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -10432,6 +10432,9 @@ impl Studio {
sync(&models.voiceover_devices, self.voiceover.device_rows());
app.set_voiceover(self.voiceover.data(self));
editor.set_recording(self.voiceover.recording());
+ editor.set_captions_open(self.captions.open);
+ editor.set_speech_open(self.speech.open);
+ editor.set_voiceover_open(self.voiceover.is_open());
let bar = self.menu_bar();
app.set_app_menu_height(Self::menu_height(&bar));
diff --git a/src/crates/concat/ui/editor.slint b/src/crates/concat/ui/editor.slint
index 56dc4978..355f94ad 100644
--- a/src/crates/concat/ui/editor.slint
+++ b/src/crates/concat/ui/editor.slint
@@ -376,6 +376,10 @@ export global Editor {
callback record-voiceover();
/// A voiceover take is under way: counting in, recording or paused.
in-out property <bool> recording;
+ /// Which of the tray's panels are up, so their buttons read as on.
+ in-out property <bool> captions-open;
+ in-out property <bool> speech-open;
+ in-out property <bool> voiceover-open;
/// The microphone while the voiceover panel is open, as positions
/// along a meter, `0..1`: the peak (beside the tray's button too) and
/// the power. Set by a timer thirty times a second, not by a publish.
diff --git a/src/crates/concat/ui/timeline/tray.slint b/src/crates/concat/ui/timeline/tray.slint
index 25a88c89..cf863eb3 100644
--- a/src/crates/concat/ui/timeline/tray.slint
+++ b/src/crates/concat/ui/timeline/tray.slint
@@ -397,12 +397,15 @@ export component TimelineTray inherits Rectangle {
glyph: Glyph.text-mark;
label: I18n.t("tray.generateCaptions");
icon-size: 16px;
+ // On while the panel is up; a second press puts it away.
+ checked: Editor.captions-open;
clicked => { root.captions(); }
}
TrayButton {
glyph: Glyph.volume;
label: I18n.t("tray.textToSpeech");
icon-size: 16px;
+ checked: Editor.speech-open;
clicked => { root.speak(); }
}
// A voiceover: the picture rolls from the playhead and the words go
@@ -412,6 +415,7 @@ export component TimelineTray inherits Rectangle {
label: root.recording ? I18n.t("tray.stopRecording") : I18n.t("tray.recordVoiceover");
icon-size: 16px;
idle: root.recording ? Theme.danger : Theme.fg;
+ checked: Editor.voiceover-open && !root.recording;
clicked => { root.record-voiceover(); }
}
if root.recording: LevelMeter {