mirror of
https://github.com/storytold/soundcraft.git
synced 2026-12-02 15:01:21 -05:00
Send menu: a new bus asks mono or stereo (#1547)
* Send menu: new bus asks mono or stereo (#1388) Co-Authored-By: Patrick Istefanidis <smallroomproductionsfl@gmail.com> * send menu: complete new-bus labels --------- Co-authored-by: Patrick Istefanidis <smallroomproductionsfl@gmail.com> Co-authored-by: Stefan Pantic <stefpantic@gmail.com>
This commit is contained in:
@@ -154,6 +154,8 @@ pub(super) fn translate(source: &str) -> Option<&'static str> {
|
||||
"new" => "novo",
|
||||
"New Bus" => "Novo bus",
|
||||
"new bus..." => "novo bus...",
|
||||
"new mono bus" => "novo bus mono",
|
||||
"new stereo bus" => "novo bus estéreo",
|
||||
"New Configuration…" => "Nova configuração…",
|
||||
"New Group…" => "Novo grupo…",
|
||||
"New..." => "Novo...",
|
||||
|
||||
@@ -1285,6 +1285,8 @@ pub(super) fn translate(source: &str) -> Option<&'static str> {
|
||||
"mute" => "静音",
|
||||
"new" => "个新",
|
||||
"new bus..." => "新建总线...",
|
||||
"new mono bus" => "新建单声道总线",
|
||||
"new stereo bus" => "新建立体声总线",
|
||||
"no audio engine" => "无音频引擎",
|
||||
"no audio input device" => "没有音频输入设备",
|
||||
"no audio track is record-enabled" => "没有已启用录音的音频轨道",
|
||||
|
||||
@@ -865,6 +865,8 @@ automation trim 微调
|
||||
bpm BPM
|
||||
no insert 无插入
|
||||
new bus... 新建总线...
|
||||
new mono bus 新建单声道总线
|
||||
new stereo bus 新建立体声总线
|
||||
OK 确定
|
||||
Replace 替换
|
||||
Revert “{name}” to its last saved version? Your changes will be lost. 将“{name}”恢复到上次保存的版本?你的更改将丢失。
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 796 and column 11.
|
@@ -394,12 +394,13 @@ fn header_footer_menu<H, R, F>(
|
||||
|
||||
/// What the send menu's footer was used for.
|
||||
enum SendFooter {
|
||||
NewBus,
|
||||
/// A new bus in this format (`mono` or `stereo`), with the send going to it.
|
||||
NewBus(&'static str),
|
||||
RemoveSend,
|
||||
}
|
||||
|
||||
/// The send's destination menu: a title and the bus search on top, the matching buses in a list
|
||||
/// that scrolls, "new bus..." (and "Remove send" for an existing send) fixed under it.
|
||||
/// that scrolls, "new mono bus" / "new stereo bus" (and "Remove send" for an existing send) fixed under it.
|
||||
/// `current` is the send's destination and its name, if the slot has a send.
|
||||
fn send_route_menu(app: &mut SoundApp, ui: &Ui, field: &egui::Response, id: TrackId, slot: usize, current: Option<(Route, String)>) {
|
||||
let which = (b'A' + slot as u8) as char;
|
||||
@@ -445,9 +446,11 @@ fn send_route_menu(app: &mut SoundApp, ui: &Ui, field: &egui::Response, id: Trac
|
||||
})
|
||||
},
|
||||
|ui| {
|
||||
if ui.button(crate::localization::text("new bus...")).clicked() {
|
||||
ui.close();
|
||||
return Some(SendFooter::NewBus);
|
||||
for (label, format) in [(crate::localization::text("new mono bus"), "mono"), (crate::localization::text("new stereo bus"), "stereo")] {
|
||||
if ui.button(label).clicked() {
|
||||
ui.close();
|
||||
return Some(SendFooter::NewBus(format));
|
||||
}
|
||||
}
|
||||
if has_send && ui.button(crate::localization::text("Remove send")).clicked() {
|
||||
ui.close();
|
||||
@@ -478,7 +481,7 @@ fn send_route_menu(app: &mut SoundApp, ui: &Ui, field: &egui::Response, id: Trac
|
||||
show_new_send(app);
|
||||
}
|
||||
match footer {
|
||||
Some(SendFooter::NewBus) => {
|
||||
Some(SendFooter::NewBus(format)) => {
|
||||
let busses = &app.engine.session().busses;
|
||||
let mut n = busses.len() + 1;
|
||||
while busses.iter().any(|bus| bus.name.eq_ignore_ascii_case(&format!("Bus {n}")))
|
||||
@@ -486,7 +489,7 @@ fn send_route_menu(app: &mut SoundApp, ui: &Ui, field: &egui::Response, id: Trac
|
||||
{
|
||||
n += 1;
|
||||
}
|
||||
if app.run("mix.new_bus", json!({"name": format!("Bus {n}")})).is_ok()
|
||||
if app.run("mix.new_bus", json!({"name": format!("Bus {n}"), "format": format})).is_ok()
|
||||
&& app.run("mix.send", send_params(app, &format!("Bus {n}"))).is_ok()
|
||||
{
|
||||
show_new_send(app);
|
||||
@@ -505,6 +508,7 @@ mod tests {
|
||||
use crate::Services;
|
||||
use crate::preferences::SendsDefault;
|
||||
use egui_kittest::{Harness, kittest::Queryable};
|
||||
use soundcraft_model::ChannelFormat;
|
||||
|
||||
/// Filtering the destination list to nothing shrinks the menu; clearing the filter grows it
|
||||
/// back, with the search field in the same place and the footer under the list.
|
||||
@@ -538,7 +542,7 @@ mod tests {
|
||||
let field = |h: &Harness<'_, (SoundApp, TrackId)>| h.get_by_role(egui::accesskit::Role::TextInput).rect();
|
||||
let footer = |h: &Harness<'_, (SoundApp, TrackId)>| h.get_by_label("Remove send").rect();
|
||||
let (search, full) = (field(&h), footer(&h));
|
||||
assert!(h.query_by_label("new bus...").is_some(), "the footer lists new bus...");
|
||||
assert!(h.query_by_label("new stereo bus").is_some(), "the footer offers a new stereo bus");
|
||||
assert!(full.top() > search.bottom() + 150.0, "the list sits between the search and the footer: {search:?} {full:?}");
|
||||
|
||||
h.get_by_role(egui::accesskit::Role::TextInput).type_text("zzzz");
|
||||
@@ -599,7 +603,7 @@ mod tests {
|
||||
assert_eq!(app.ui.send_window, Some((kick, 0)), "the new send's window is open");
|
||||
}
|
||||
|
||||
/// So does a send made with "new bus...".
|
||||
/// So does a send made with "new stereo bus".
|
||||
#[test]
|
||||
fn a_send_to_a_new_bus_opens_its_send_window() {
|
||||
let _palette = crate::theme::lock_test_palette();
|
||||
@@ -607,13 +611,32 @@ mod tests {
|
||||
h.run();
|
||||
h.get_by_label("Send A for Kick").click();
|
||||
h.run();
|
||||
h.get_by_label("new bus...").click();
|
||||
h.get_by_label("new stereo bus").click();
|
||||
h.run();
|
||||
let (app, _) = h.state();
|
||||
assert!(app.engine.session().track(kick).and_then(|t| t.mixer.sends.first().cloned().flatten()).is_some(), "the send was created");
|
||||
assert_eq!(app.ui.send_window, Some((kick, 0)), "the new send's window is open");
|
||||
}
|
||||
|
||||
/// #1388: the send menu asks for mono or stereo, and the new bus has the format picked.
|
||||
#[test]
|
||||
fn a_new_bus_from_the_send_menu_is_mono_or_stereo_as_picked() {
|
||||
let _palette = crate::theme::lock_test_palette();
|
||||
for (label, format) in [("new mono bus", ChannelFormat::Mono), ("new stereo bus", ChannelFormat::Stereo)] {
|
||||
let (mut h, kick) = kick_send_harness(false);
|
||||
h.run();
|
||||
h.get_by_label("Send A for Kick").click();
|
||||
h.run();
|
||||
h.get_by_label(label).click();
|
||||
h.run();
|
||||
let (app, _) = h.state();
|
||||
let s = app.engine.session();
|
||||
let send = s.track(kick).and_then(|t| t.mixer.sends.first().cloned().flatten()).unwrap();
|
||||
let bus = s.busses.iter().find(|b| Route::Bus(b.id) == send.target).unwrap();
|
||||
assert_eq!(bus.format, format, "{label} makes a bus in that format");
|
||||
}
|
||||
}
|
||||
|
||||
/// Moving an existing send to another bus keeps the Send window as it was.
|
||||
#[test]
|
||||
fn changing_a_sends_destination_leaves_the_send_window_alone() {
|
||||
@@ -653,7 +676,7 @@ mod tests {
|
||||
let _palette = crate::theme::lock_test_palette();
|
||||
assert_eq!(level_after_picking(false, SendsDefault::NegativeInfinity, "Aux"), Some(-144.0));
|
||||
assert_eq!(level_after_picking(false, SendsDefault::Unity, "Aux"), Some(0.0));
|
||||
assert_eq!(level_after_picking(false, SendsDefault::Unity, "new bus..."), Some(0.0));
|
||||
assert_eq!(level_after_picking(false, SendsDefault::Unity, "new stereo bus"), Some(0.0));
|
||||
}
|
||||
|
||||
/// Moving an existing send to another bus keeps its level, whatever the preference says.
|
||||
|
||||
Reference in New Issue
Block a user