app: give the window a palette and the settings a quick tab
The colours were rune's neutral defaults, so nothing tied the screens together. app/src/theme.rs now holds the palette: near-black surfaces tinted blue, brass for what the user acts on, mint and coral kept for results so champion art stays the loudest thing on screen. A test fails the build if a colour that carries text drops under 4.5:1 in either appearance. Settings lose the empty General tab: Quick holds quality, the audio and microphone switches, startup and the recordings folder; Recording keeps the encoder and output; Audio is three cards instead of five; Advanced absorbs the audio bitrate and reset. The back button moves to the left of the title bar, where window navigation belongs, and text fields right-align their value like every other control on the row. The microphone picker lists the devices with "System default" first, naming the default endpoint under the row. Two smaller repairs found on the way: the app picked record-daemon/target/release before debug, so it talked to a stale daemon after a debug build (the newest build now wins), and --snap forwarded its arguments to a running window instead of rendering.
This commit is contained in:
1 parent
b82225ce08
commit
3dfef1961d
8 files changed
+628
-368
No files matched your search
@@ -27,8 +27,8 @@ fn filter_label(filter: Option<QueueCategory>) -> &'static str {
|
||||
|
||||
fn outcome_color(p: Paint, outcome: Outcome) -> Color {
|
||||
match outcome {
|
||||
Outcome::Victory => p.success(),
|
||||
Outcome::Defeat => p.danger(),
|
||||
Outcome::Victory => p.success,
|
||||
Outcome::Defeat => p.danger,
|
||||
Outcome::Terminated => p.muted(),
|
||||
}
|
||||
}
|
||||
@@ -183,11 +183,7 @@ fn game_card(app: &App, p: Paint, game: &Timeline, index: usize) -> El {
|
||||
),
|
||||
);
|
||||
if let Some(lp) = &lp {
|
||||
let lp_ink = if lp.delta >= 0 {
|
||||
p.success()
|
||||
} else {
|
||||
p.danger()
|
||||
};
|
||||
let lp_ink = if lp.delta >= 0 { p.success } else { p.danger };
|
||||
banner = banner.child(
|
||||
text(format!(
|
||||
"{} LP · {}",
|
||||
|
||||
@@ -145,8 +145,8 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
};
|
||||
let outcome = game.outcome();
|
||||
let ink = match outcome {
|
||||
Outcome::Victory => p.success(),
|
||||
Outcome::Defeat => p.danger(),
|
||||
Outcome::Victory => p.success,
|
||||
Outcome::Defeat => p.danger,
|
||||
Outcome::Terminated => p.muted(),
|
||||
};
|
||||
|
||||
@@ -397,9 +397,9 @@ fn scrubber(app: &App, p: Paint, game: &Timeline) -> El {
|
||||
let x = (clip.start / duration).clamp(0.0, 1.0) as f32 * width;
|
||||
let end = (clip.end / duration).clamp(0.0, 1.0) as f32 * width;
|
||||
let ink = match clip.kind {
|
||||
highlight::Kind::Death => p.danger(),
|
||||
highlight::Kind::Death => p.danger,
|
||||
highlight::Kind::Assist => p.muted(),
|
||||
_ => p.success(),
|
||||
_ => p.success,
|
||||
};
|
||||
bar = bar.child(
|
||||
el().key(format!("clip-{index}"))
|
||||
@@ -435,8 +435,8 @@ fn scrubber(app: &App, p: Paint, game: &Timeline) -> El {
|
||||
.and_then(|name| highlight::involvement(event, name));
|
||||
let ink = match event.event_type.as_str() {
|
||||
"kill" => match involvement {
|
||||
Some(highlight::Kind::Death) => p.danger(),
|
||||
Some(_) => p.success(),
|
||||
Some(highlight::Kind::Death) => p.danger,
|
||||
Some(_) => p.success,
|
||||
None => p.muted().alpha(0.75),
|
||||
},
|
||||
"objective" | "lp_change" => p.accent,
|
||||
@@ -494,10 +494,10 @@ fn highlights(app: &App, p: Paint, game: &Timeline) -> El {
|
||||
let video = game.video_path().map(|path| path.display().to_string());
|
||||
let name = format!("{}-highlight-{}", game.recording_id, index);
|
||||
let kind_ink = match clip.kind {
|
||||
highlight::Kind::Death => p.danger(),
|
||||
highlight::Kind::Death => p.danger,
|
||||
highlight::Kind::Assist => p.muted(),
|
||||
highlight::Kind::MultiKill | highlight::Kind::TradeKill => p.accent,
|
||||
highlight::Kind::Kill => p.success(),
|
||||
highlight::Kind::Kill => p.success,
|
||||
};
|
||||
let mut actions = row().key("actions").gap(6.0).center_y().child(ui::button(
|
||||
p,
|
||||
|
||||
+311
-260
@@ -1,4 +1,4 @@
|
||||
//! Settings: general, recording, audio and daemon tabs, saved through `updateSettings`.
|
||||
//! Settings: a quick tab of everyday choices, then recording, audio and the daemon.
|
||||
|
||||
use rune::tok::{radius, space, type_};
|
||||
use rune::{El, TextEdit, col, row, text};
|
||||
@@ -141,25 +141,13 @@ const SOURCE_TYPES: [&str; 3] = ["Application", "Output device", "Input device"]
|
||||
/// A row with a single-line field on the right.
|
||||
fn text_row(
|
||||
p: Paint,
|
||||
kit: &rune_kit::Kit,
|
||||
key: &'static str,
|
||||
label: &str,
|
||||
hint: &str,
|
||||
edit: &TextEdit,
|
||||
to: fn(&mut App) -> &mut TextEdit,
|
||||
) -> El {
|
||||
ui::setting_row_with(
|
||||
p,
|
||||
key,
|
||||
label,
|
||||
hint,
|
||||
rune_kit::TextInput::new(edit)
|
||||
.label(label)
|
||||
.on_edit(to)
|
||||
.width(Some(220.0))
|
||||
.on_change(|app: &mut App, _| app.form.dirty = true)
|
||||
.build(kit),
|
||||
)
|
||||
ui::setting_row_with(p, key, label, hint, ui::text_field(p, key, label, edit, to))
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)] // the columns of a settings row
|
||||
@@ -199,10 +187,10 @@ fn select_row(
|
||||
fn tabs(p: Paint, app: &App) -> El {
|
||||
let mut row = row().key("tabs").gap(4.0).center_y();
|
||||
for (tab, label) in [
|
||||
(SettingsTab::General, "General"),
|
||||
(SettingsTab::Quick, "Quick"),
|
||||
(SettingsTab::Recording, "Recording"),
|
||||
(SettingsTab::Audio, "Audio"),
|
||||
(SettingsTab::Daemon, "Advanced"),
|
||||
(SettingsTab::Advanced, "Advanced"),
|
||||
] {
|
||||
row = row.child(ui::tab(
|
||||
p,
|
||||
@@ -221,19 +209,20 @@ fn tabs(p: Paint, app: &App) -> El {
|
||||
pub fn view(app: &App, p: Paint) -> El {
|
||||
let kit = rune_kit::Kit::neutral(app.dark);
|
||||
let mut layer = Vec::new();
|
||||
let (save_text, save_ink) = save_label(app, p);
|
||||
|
||||
// The scroll bar gets its own strip at the end, clear of the cards.
|
||||
let content = col()
|
||||
.key("tab-content")
|
||||
.w_full()
|
||||
.gap(space::S6)
|
||||
.gap(20.0)
|
||||
.pb(space::S6)
|
||||
.pr(14.0);
|
||||
let content = match app.settings_tab {
|
||||
SettingsTab::General => general(app, p, &kit, &mut layer, content),
|
||||
SettingsTab::Quick => quick(app, p, &kit, &mut layer, content),
|
||||
SettingsTab::Recording => recording(app, p, &kit, &mut layer, content),
|
||||
SettingsTab::Audio => audio(app, p, &kit, &mut layer, content),
|
||||
SettingsTab::Daemon => daemon_tab(app, p, &kit, &mut layer, content),
|
||||
SettingsTab::Advanced => advanced(app, p, &kit, &mut layer, content),
|
||||
};
|
||||
|
||||
let body = col()
|
||||
@@ -261,10 +250,10 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
.center_y()
|
||||
.child(
|
||||
row().key("save-state").mr(4.0).center_y().child(
|
||||
text(save_label(app))
|
||||
text(save_text)
|
||||
.key("save-label")
|
||||
.font(body(11.5))
|
||||
.color(p.muted()),
|
||||
.color(save_ink),
|
||||
),
|
||||
)
|
||||
.child(ui::button(p, "revert", "Revert", false, |app: &mut App| {
|
||||
@@ -306,15 +295,15 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
rune_kit::root(body, layer)
|
||||
}
|
||||
|
||||
fn save_label(app: &App) -> String {
|
||||
fn save_label(app: &App, p: Paint) -> (String, rune::Color) {
|
||||
if !app.connected {
|
||||
"Daemon offline".into()
|
||||
("Daemon offline".into(), p.danger)
|
||||
} else if app.form.dirty {
|
||||
"Unsaved changes".into()
|
||||
("Unsaved changes".into(), p.warning)
|
||||
} else if app.form.loaded {
|
||||
"Saved".into()
|
||||
("Saved".into(), p.muted())
|
||||
} else {
|
||||
"Loading".into()
|
||||
("Loading".into(), p.muted())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,24 +317,55 @@ fn save_footer(p: Paint, _app: &App) -> El {
|
||||
)
|
||||
}
|
||||
|
||||
fn general(_app: &App, p: Paint, _kit: &rune_kit::Kit, _layer: &mut Vec<El>, content: El) -> El {
|
||||
/// The settings most people touch: how a clip looks, whether it has sound, and where it lands.
|
||||
fn quick(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
||||
let v = &app.form.draft.video;
|
||||
let a = &app.form.draft.audio;
|
||||
content
|
||||
.child(
|
||||
text("Recording starts on its own when a game begins, and the game shows up here when it ends.")
|
||||
.key("quick-note")
|
||||
.font(body(12.5))
|
||||
.color(p.muted()),
|
||||
)
|
||||
.child(ui::card(
|
||||
p,
|
||||
Some("Recording"),
|
||||
vec![
|
||||
text("Recording starts by itself when a game begins and stops when the game ends.")
|
||||
.key("auto-note")
|
||||
.font(body(12.5))
|
||||
.color(p.muted())
|
||||
.px(space::S3)
|
||||
.py(space::S3),
|
||||
text("A finished game shows up in the match history on its own.")
|
||||
.key("history-note")
|
||||
.font(body(12.5))
|
||||
.color(p.muted())
|
||||
.px(space::S3)
|
||||
.pb(space::S3),
|
||||
select_row(
|
||||
p,
|
||||
kit,
|
||||
layer,
|
||||
"quality",
|
||||
"Quality",
|
||||
v.quality.detail(),
|
||||
&QUALITIES,
|
||||
Some(v.quality.label().to_string()),
|
||||
app,
|
||||
),
|
||||
ui::toggle_row(
|
||||
p,
|
||||
"quick-audio",
|
||||
"Record game audio",
|
||||
a.enabled && a.capture_game,
|
||||
|app: &mut App| {
|
||||
let on = !(app.form.draft.audio.enabled && app.form.draft.audio.capture_game);
|
||||
app.form.draft.audio.enabled = on;
|
||||
app.form.draft.audio.capture_game = on;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
ui::toggle_row(
|
||||
p,
|
||||
"quick-mic",
|
||||
"Record my microphone",
|
||||
a.capture_mic,
|
||||
|app: &mut App| {
|
||||
app.form.draft.audio.capture_mic ^= true;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
mic_row(p, kit, layer, app, "quick-mic-device"),
|
||||
],
|
||||
))
|
||||
.child(ui::card(
|
||||
@@ -355,7 +375,7 @@ fn general(_app: &App, p: Paint, _kit: &rune_kit::Kit, _layer: &mut Vec<El>, con
|
||||
p,
|
||||
"autostart",
|
||||
"Launch League Recorder at startup",
|
||||
_app.autostart,
|
||||
app.autostart,
|
||||
|app: &mut App| {
|
||||
let next = !app.autostart;
|
||||
match crate::os::set_autostart(next) {
|
||||
@@ -372,31 +392,49 @@ fn general(_app: &App, p: Paint, _kit: &rune_kit::Kit, _layer: &mut Vec<El>, con
|
||||
},
|
||||
)],
|
||||
))
|
||||
.child(
|
||||
row()
|
||||
.key("general-actions")
|
||||
.gap(8.0)
|
||||
.center_y()
|
||||
.child(ui::button(
|
||||
.child(ui::card(
|
||||
p,
|
||||
Some("Files"),
|
||||
vec![
|
||||
ui::setting_row(
|
||||
p,
|
||||
"open-recordings",
|
||||
"Open recordings folder",
|
||||
false,
|
||||
|_app: &mut App| {
|
||||
crate::daemon::open_folder(&crate::daemon::recordings_dir());
|
||||
},
|
||||
))
|
||||
.child(ui::button(
|
||||
p,
|
||||
"reset-settings",
|
||||
"Reset to defaults",
|
||||
false,
|
||||
|app: &mut App| {
|
||||
app.daemon.reset_settings();
|
||||
},
|
||||
)),
|
||||
)
|
||||
"recordings-folder",
|
||||
"Recordings folder",
|
||||
text(short_path(&app.form.draft.output.path))
|
||||
.key("path")
|
||||
.font(body(12.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
row()
|
||||
.key("files-actions")
|
||||
.px(space::S3)
|
||||
.pb(space::S2)
|
||||
.child(ui::button(
|
||||
p,
|
||||
"open-recordings",
|
||||
"Open folder",
|
||||
false,
|
||||
|_app: &mut App| {
|
||||
crate::daemon::open_folder(&crate::daemon::recordings_dir());
|
||||
},
|
||||
)),
|
||||
],
|
||||
))
|
||||
}
|
||||
|
||||
/// A path as it fits on a row: the last two segments, with the rest elided.
|
||||
/// A path as it fits on a row: the last two segments, with the rest elided.
|
||||
fn short_path(path: &str) -> String {
|
||||
let sep = std::path::MAIN_SEPARATOR;
|
||||
let normalized = path.replace(sep, "/");
|
||||
let parts: Vec<&str> = normalized.split('/').filter(|p| !p.is_empty()).collect();
|
||||
match parts.len() {
|
||||
0 => path.to_string(),
|
||||
1 | 2 => parts.join(&sep.to_string()),
|
||||
n => format!("…{sep}{}{sep}{}", parts[n - 2], parts[n - 1]),
|
||||
}
|
||||
}
|
||||
|
||||
fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
||||
let v = &app.form.draft.video;
|
||||
let o = &app.form.draft.output;
|
||||
@@ -443,7 +481,6 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
|
||||
),
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"frame-rate",
|
||||
"Frame rate",
|
||||
"Frames per second the daemon records",
|
||||
@@ -480,7 +517,6 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
|
||||
vec![
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"output-path",
|
||||
"Folder",
|
||||
"Where finished recordings are written",
|
||||
@@ -489,7 +525,6 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
|
||||
),
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"naming",
|
||||
"File name",
|
||||
"{date}, {time}, {champion} and {queue_type} are filled in",
|
||||
@@ -509,7 +544,6 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
|
||||
),
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"split-size",
|
||||
"Split at size",
|
||||
"Start a new file past this many MB (0 for never)",
|
||||
@@ -518,7 +552,6 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
|
||||
),
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"split-time",
|
||||
"Split at time",
|
||||
"Start a new file after this many minutes (0 for never)",
|
||||
@@ -538,59 +571,63 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
|
||||
)))
|
||||
}
|
||||
|
||||
fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
||||
let a = &app.form.draft.audio;
|
||||
let mic_name = a
|
||||
/// The microphone picker: the system default plus every input device the daemon reports.
|
||||
fn mic_row(p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, app: &App, key: &'static str) -> El {
|
||||
let devices = &app.devices.input_devices;
|
||||
let current = app
|
||||
.form
|
||||
.draft
|
||||
.audio
|
||||
.mic_device
|
||||
.as_ref()
|
||||
.and_then(|id| app.devices.input_devices.iter().find(|d| &d.id == id))
|
||||
.and_then(|id| devices.iter().find(|d| &d.id == id))
|
||||
.map(|d| d.name.clone())
|
||||
.or_else(|| {
|
||||
app.devices
|
||||
.input_devices
|
||||
.iter()
|
||||
.find(|d| d.is_default)
|
||||
.map(|d| d.name.clone())
|
||||
});
|
||||
let mic_options: Vec<String> = app
|
||||
.devices
|
||||
.input_devices
|
||||
.iter()
|
||||
.map(|d| d.name.clone())
|
||||
.collect();
|
||||
let mic_refs: Vec<&str> = mic_options.iter().map(String::as_str).collect();
|
||||
let open = app.form.open_select == Some("mic-device");
|
||||
let mic_select = Select::new("mic-device", &mic_refs)
|
||||
.current(mic_name.as_deref())
|
||||
.unwrap_or_else(|| "System default".to_string());
|
||||
let mut options = vec!["System default".to_string()];
|
||||
options.extend(devices.iter().map(|d| d.name.clone()));
|
||||
let names: Vec<&str> = options.iter().map(String::as_str).collect();
|
||||
let open = app.form.open_select == Some(key);
|
||||
let select = Select::new(key, &names)
|
||||
.current(Some(¤t))
|
||||
.open(open)
|
||||
.label("Microphone")
|
||||
.width(220.0)
|
||||
.on_toggle(|app: &mut App| {
|
||||
app.form.open_select = if app.form.open_select == Some("mic-device") {
|
||||
.on_toggle(move |app: &mut App| {
|
||||
app.form.open_select = if app.form.open_select == Some(key) {
|
||||
None
|
||||
} else {
|
||||
Some("mic-device")
|
||||
Some(key)
|
||||
};
|
||||
})
|
||||
.on_close(|app: &mut App| app.form.open_select = None)
|
||||
.on_choose(|app: &mut App, value: &str, _: &mut rune::Tx| {
|
||||
let id = app
|
||||
.devices
|
||||
.input_devices
|
||||
.iter()
|
||||
.find(|d| d.name == value)
|
||||
.map(|d| d.id.clone())
|
||||
.unwrap_or_else(|| value.to_string());
|
||||
app.form.draft.audio.mic_device = Some(id);
|
||||
app.form.draft.audio.mic_device = if value == "System default" {
|
||||
None
|
||||
} else {
|
||||
app.devices
|
||||
.input_devices
|
||||
.iter()
|
||||
.find(|d| d.name == value)
|
||||
.map(|d| d.id.clone())
|
||||
};
|
||||
app.form.dirty = true;
|
||||
app.form.open_select = None;
|
||||
})
|
||||
.build(kit, layer);
|
||||
let hint = match devices.iter().find(|d| d.is_default) {
|
||||
_ if devices.is_empty() => "The recorder sees no microphone".to_string(),
|
||||
Some(d) => format!("System default is {}", d.name),
|
||||
None => "What the recorder captures when the microphone is on".to_string(),
|
||||
};
|
||||
ui::setting_row_with(p, key, "Microphone", &hint, select)
|
||||
}
|
||||
|
||||
fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
||||
let a = &app.form.draft.audio;
|
||||
let mut sources = col().key("sources").gap(2.0);
|
||||
if a.capture_apps.is_empty() {
|
||||
sources = sources.child(
|
||||
text("No application sources yet.")
|
||||
text("No applications yet. Add one below and its audio joins the clip.")
|
||||
.key("sources-empty")
|
||||
.font(body(12.0))
|
||||
.color(p.muted())
|
||||
@@ -670,47 +707,12 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
|
||||
)),
|
||||
);
|
||||
}
|
||||
let source_type = app.form.source_type;
|
||||
|
||||
content
|
||||
.child(ui::card(
|
||||
p,
|
||||
Some("Audio"),
|
||||
Some("Levels"),
|
||||
vec![
|
||||
ui::toggle_row(
|
||||
p,
|
||||
"audio-enabled",
|
||||
"Record audio",
|
||||
a.enabled,
|
||||
|app: &mut App| {
|
||||
app.form.draft.audio.enabled ^= true;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"audio-bitrate",
|
||||
"Bitrate",
|
||||
"Audio bitrate in kbps",
|
||||
&app.form.bitrate,
|
||||
|app| &mut app.form.bitrate,
|
||||
),
|
||||
],
|
||||
))
|
||||
.child(ui::card(
|
||||
p,
|
||||
Some("Game audio"),
|
||||
vec![
|
||||
ui::toggle_row(
|
||||
p,
|
||||
"capture-game",
|
||||
"Capture desktop audio",
|
||||
a.capture_game,
|
||||
|app: &mut App| {
|
||||
app.form.draft.audio.capture_game ^= true;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
ui::setting_row(
|
||||
p,
|
||||
"game-volume",
|
||||
@@ -720,12 +722,42 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
|
||||
"game-volume",
|
||||
"Game volume",
|
||||
a.game_volume,
|
||||
|app: &mut App, value| {
|
||||
|app, value| {
|
||||
app.form.draft.audio.game_volume = value;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
ui::setting_row(
|
||||
p,
|
||||
"mic-volume",
|
||||
"Microphone volume",
|
||||
ui::slider(
|
||||
p,
|
||||
"mic-volume",
|
||||
"Microphone volume",
|
||||
a.mic_volume,
|
||||
|app, value| {
|
||||
app.form.draft.audio.mic_volume = value;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
ui::setting_row(
|
||||
p,
|
||||
"apps-volume",
|
||||
"Applications volume",
|
||||
ui::slider(
|
||||
p,
|
||||
"apps-volume",
|
||||
"Applications volume",
|
||||
a.apps_volume,
|
||||
|app, value| {
|
||||
app.form.draft.audio.apps_volume = value;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
))
|
||||
.child(ui::card(
|
||||
@@ -742,133 +774,117 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
ui::setting_row_with(
|
||||
p,
|
||||
"mic-device",
|
||||
"Device",
|
||||
"The microphone the daemon records",
|
||||
mic_select,
|
||||
),
|
||||
ui::setting_row(
|
||||
p,
|
||||
"mic-volume",
|
||||
"Microphone volume",
|
||||
ui::slider(
|
||||
p,
|
||||
"mic-volume",
|
||||
"Microphone volume",
|
||||
a.mic_volume,
|
||||
|app: &mut App, value| {
|
||||
app.form.draft.audio.mic_volume = value;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
mic_row(p, kit, layer, app, "mic-device"),
|
||||
],
|
||||
))
|
||||
.child(ui::card(
|
||||
p,
|
||||
Some("Applications"),
|
||||
vec![
|
||||
ui::setting_row(
|
||||
p,
|
||||
"apps-volume",
|
||||
"Application volume",
|
||||
ui::slider(
|
||||
p,
|
||||
"apps-volume",
|
||||
"Application volume",
|
||||
a.apps_volume,
|
||||
|app: &mut App, value| {
|
||||
app.form.draft.audio.apps_volume = value;
|
||||
app.form.dirty = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
sources,
|
||||
text(format!(
|
||||
"{} output devices are visible to the daemon.",
|
||||
app.devices.output_devices.len()
|
||||
))
|
||||
.key("output-devices")
|
||||
.font(body(11.0))
|
||||
.color(p.muted())
|
||||
.ml(space::S3)
|
||||
.pb(space::S2),
|
||||
],
|
||||
))
|
||||
.child(ui::card(
|
||||
p,
|
||||
Some("Add an application"),
|
||||
vec![
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"source-name",
|
||||
"Name",
|
||||
"What the source is called in this list",
|
||||
&app.form.source_name,
|
||||
|app| &mut app.form.source_name,
|
||||
),
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"source-device",
|
||||
"Process or device",
|
||||
"Discord.exe for an application, or a device id",
|
||||
&app.form.source_device,
|
||||
|app| &mut app.form.source_device,
|
||||
),
|
||||
select_row(
|
||||
p,
|
||||
kit,
|
||||
layer,
|
||||
"source-type",
|
||||
"Type",
|
||||
"Application audio, an output device or an input device",
|
||||
&SOURCE_TYPES,
|
||||
Some(source_type.label().to_string()),
|
||||
app,
|
||||
),
|
||||
row()
|
||||
.key("add-source")
|
||||
.px(space::S3)
|
||||
.pb(space::S2)
|
||||
.child(ui::button(
|
||||
p,
|
||||
"add-source-button",
|
||||
"Add source",
|
||||
true,
|
||||
|app: &mut App| {
|
||||
let name = app.form.source_name.text.trim().to_string();
|
||||
let device = app.form.source_device.text.trim().to_string();
|
||||
if name.is_empty() || device.is_empty() {
|
||||
app.notify_error(
|
||||
"An audio source needs a name and a process or device",
|
||||
);
|
||||
return;
|
||||
}
|
||||
let source = AudioSource {
|
||||
id: String::new(),
|
||||
name,
|
||||
source_type: app.form.source_type,
|
||||
device,
|
||||
enabled: true,
|
||||
volume: None,
|
||||
};
|
||||
match serde_json::to_value(&source) {
|
||||
Ok(value) => app.daemon.add_audio_source(value),
|
||||
Err(e) => {
|
||||
app.notify_error(format!("audio source did not serialize: {e}"))
|
||||
}
|
||||
}
|
||||
},
|
||||
)),
|
||||
],
|
||||
vec![sources, add_source(app, p, kit, layer)],
|
||||
))
|
||||
}
|
||||
|
||||
fn daemon_tab(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
||||
/// The row that adds an application source: a name, the process or device, and its kind.
|
||||
fn add_source(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>) -> El {
|
||||
let open = app.form.open_select == Some("source-type");
|
||||
let kind = Select::new("source-type", &SOURCE_TYPES)
|
||||
.current(Some(app.form.source_type.label()))
|
||||
.open(open)
|
||||
.label("Type")
|
||||
.width(170.0)
|
||||
.on_toggle(|app: &mut App| {
|
||||
app.form.open_select = if app.form.open_select == Some("source-type") {
|
||||
None
|
||||
} else {
|
||||
Some("source-type")
|
||||
};
|
||||
})
|
||||
.on_close(|app: &mut App| app.form.open_select = None)
|
||||
.on_choose(|app: &mut App, value: &str, _: &mut rune::Tx| {
|
||||
app.form.choose("source-type", value);
|
||||
app.form.open_select = None;
|
||||
})
|
||||
.build(kit, layer);
|
||||
col()
|
||||
.key("add-source")
|
||||
.gap(space::S2)
|
||||
.px(space::S3)
|
||||
.pb(space::S3)
|
||||
.child(
|
||||
text("Add an application")
|
||||
.key("add-title")
|
||||
.font(type_::SECTION)
|
||||
.color(p.muted()),
|
||||
)
|
||||
.child(
|
||||
row()
|
||||
.key("add-fields")
|
||||
.gap(space::S3)
|
||||
.center_y()
|
||||
.child(labelled_field(
|
||||
p,
|
||||
"Name",
|
||||
"source-name",
|
||||
&app.form.source_name,
|
||||
|app| &mut app.form.source_name,
|
||||
))
|
||||
.child(labelled_field(
|
||||
p,
|
||||
"Process or device",
|
||||
"source-device",
|
||||
&app.form.source_device,
|
||||
|app| &mut app.form.source_device,
|
||||
))
|
||||
.child(kind)
|
||||
.child(ui::button(
|
||||
p,
|
||||
"add-source-button",
|
||||
"Add",
|
||||
true,
|
||||
|app: &mut App| {
|
||||
let name = app.form.source_name.text.trim().to_string();
|
||||
let device = app.form.source_device.text.trim().to_string();
|
||||
if name.is_empty() || device.is_empty() {
|
||||
app.notify_error(
|
||||
"An audio source needs a name and a process or device",
|
||||
);
|
||||
return;
|
||||
}
|
||||
let source = AudioSource {
|
||||
id: String::new(),
|
||||
name,
|
||||
source_type: app.form.source_type,
|
||||
device,
|
||||
enabled: true,
|
||||
volume: None,
|
||||
};
|
||||
match serde_json::to_value(&source) {
|
||||
Ok(value) => app.daemon.add_audio_source(value),
|
||||
Err(e) => {
|
||||
app.notify_error(format!("audio source did not serialize: {e}"))
|
||||
}
|
||||
}
|
||||
},
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
/// A field with its name above it, for a row of controls that has no room for setting labels.
|
||||
fn labelled_field(
|
||||
p: Paint,
|
||||
label: &'static str,
|
||||
key: &'static str,
|
||||
edit: &TextEdit,
|
||||
to: fn(&mut App) -> &mut TextEdit,
|
||||
) -> El {
|
||||
col()
|
||||
.key(key)
|
||||
.gap(space::S1)
|
||||
.child(text(label).key("caption").font(body(11.0)).color(p.muted()))
|
||||
.child(ui::text_field(p, key, label, edit, to))
|
||||
}
|
||||
|
||||
fn advanced(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
||||
let status_row = |key: &str, label: &'static str, value: String| {
|
||||
row()
|
||||
.key(key)
|
||||
@@ -919,7 +935,11 @@ fn daemon_tab(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, con
|
||||
.map(|id| id.to_string())
|
||||
.unwrap_or_else(|| "none".into()),
|
||||
),
|
||||
status_row("daemon-log", "Log file", crate::daemon::log_path()),
|
||||
status_row(
|
||||
"daemon-log",
|
||||
"Log file",
|
||||
short_path(&crate::daemon::log_path()),
|
||||
),
|
||||
],
|
||||
))
|
||||
.child(ui::card(
|
||||
@@ -928,7 +948,6 @@ fn daemon_tab(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, con
|
||||
vec![
|
||||
text_row(
|
||||
p,
|
||||
kit,
|
||||
"poll-interval",
|
||||
"Client poll interval",
|
||||
"How often the recorder checks the League Client, in milliseconds",
|
||||
@@ -948,6 +967,29 @@ fn daemon_tab(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, con
|
||||
),
|
||||
],
|
||||
))
|
||||
.child(ui::card(
|
||||
p,
|
||||
Some("Audio"),
|
||||
vec![
|
||||
status_row(
|
||||
"audio-devices",
|
||||
"Devices",
|
||||
format!(
|
||||
"{} in · {} out",
|
||||
app.devices.input_devices.len(),
|
||||
app.devices.output_devices.len()
|
||||
),
|
||||
),
|
||||
text_row(
|
||||
p,
|
||||
"audio-bitrate",
|
||||
"Bitrate",
|
||||
"Audio bitrate in kbps",
|
||||
&app.form.bitrate,
|
||||
|app| &mut app.form.bitrate,
|
||||
),
|
||||
],
|
||||
))
|
||||
.child(
|
||||
row()
|
||||
.key("daemon-actions")
|
||||
@@ -979,6 +1021,15 @@ fn daemon_tab(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, con
|
||||
|app: &mut App| {
|
||||
app.daemon.shutdown();
|
||||
},
|
||||
))
|
||||
.child(ui::button(
|
||||
p,
|
||||
"reset-settings",
|
||||
"Reset to defaults",
|
||||
false,
|
||||
|app: &mut App| {
|
||||
app.daemon.reset_settings();
|
||||
},
|
||||
)),
|
||||
)
|
||||
.child(ui::card(
|
||||
|
||||
Reference in new issue
Block a user