//! Settings: a quick tab of everyday choices, then recording, audio and the daemon. use rune::tok::{radius, space, type_}; use rune::{Color, El, TextEdit, col, el, row, text}; use rune_kit::Select; use crate::app::{App, SettingsTab}; use crate::settings::{AudioSource, AudioSourceType, Quality, Settings}; use crate::ui::{self, Paint, body, heading}; /// The daemon's settings plus the text fields the user is typing into. pub struct Form { pub draft: Settings, pub loaded: bool, pub dirty: bool, pub saving: bool, pub open_select: Option<&'static str>, pub naming: TextEdit, pub poll_interval: TextEdit, pub bitrate: TextEdit, pub source_name: TextEdit, pub source_device: TextEdit, pub add_open: bool, } impl Form { pub fn empty() -> Self { let draft = Settings::default(); Self { naming: TextEdit::new(&draft.output.naming_pattern), poll_interval: TextEdit::new(draft.daemon.poll_interval_ms.to_string()), bitrate: TextEdit::new(draft.audio.bitrate.to_string()), source_name: TextEdit::new(""), source_device: TextEdit::new(""), add_open: false, draft, loaded: false, dirty: false, saving: false, open_select: None, } } /// Take the daemon's copy. Unsaved edits are kept unless `force`. pub fn apply(&mut self, settings: &Settings) { if self.dirty && self.loaded { return; } self.draft = settings.clone(); self.naming.replace_text(&settings.output.naming_pattern); self.poll_interval .replace_text(settings.daemon.poll_interval_ms.to_string()); self.bitrate .replace_text(settings.audio.bitrate.to_string()); self.loaded = true; self.dirty = false; self.saving = false; } /// Pull the text fields into the draft and hand it to `updateSettings`. pub fn settings(&mut self) -> Settings { let mut out = self.draft.clone(); out.output.naming_pattern = self.naming.text.trim().to_string(); out.daemon.poll_interval_ms = self .poll_interval .text .trim() .parse() .unwrap_or(1000) .max(100); out.audio.bitrate = self .bitrate .text .trim() .parse() .unwrap_or(160) .clamp(32, 320); out } /// Open the add-application dialog on empty fields. pub fn open_add(&mut self) { self.add_open = true; self.open_select = None; self.source_name = TextEdit::new(""); self.source_device = TextEdit::new(""); } /// Close the add-application dialog, whatever was typed. pub fn close_add(&mut self) { self.add_open = false; } pub fn choose(&mut self, key: &str, value: &str) { match key { "encoder" => { self.draft.video.encoder_preset = self.draft.video.encoder_preset.with_kind(value) } "quality" => { self.draft.video.quality = match value { "Low" => Quality::Low, "Medium" => Quality::Medium, "Ultra" => Quality::Ultra, _ => Quality::High, } } "container" => self.draft.output.container = value.to_ascii_lowercase(), "log-level" => self.draft.daemon.log_level = value.to_ascii_lowercase(), "mic-device" => self.draft.audio.mic_device = Some(value.to_string()), _ => {} } self.dirty = true; } } const ENCODERS: [&str; 3] = ["NVIDIA NVENC", "AMD AMF", "x264 (Software)"]; const QUALITIES: [&str; 4] = ["Low", "Medium", "High", "Ultra"]; const CONTAINERS: [&str; 4] = ["mp4", "mkv", "mov", "flv"]; const LOG_LEVELS: [&str; 5] = ["trace", "debug", "info", "warn", "error"]; /// A row with a single-line field on the right. fn text_row( p: Paint, key: &'static str, label: &str, hint: &str, edit: &TextEdit, to: fn(&mut App) -> &mut TextEdit, ) -> El { ui::setting_row_with(p, key, label, hint, ui::text_field(p, key, label, edit, to)) } /// The folder recordings land in, as the settings hold it, and the button that replaces it with /// one the system's dialog picks. The path is read back, not typed: a folder is a thing you find. fn path_row(p: Paint, app: &App, key: &'static str, label: &'static str, hint: &'static str) -> El { // The whole path, not the last folders. It gets what the labels and the button leave, and a // middle "…" when that is not enough, so the window's width picks the cut and no character // count does. The margin holds it off the labels once the row is tight. let shown = text(&app.form.draft.output.path) .key("path") .font(body(12.0)) .color(p.muted()) .ml(space::S2) .truncate_middle(); let pick = ui::button_tx( p, "pick-folder", "Select folder", false, move |app: &mut App, tx: &mut rune::Tx| { let options = rune::FileDialogOptions { title: hint.to_string(), directory: Some(app.output_dir()), ..Default::default() }; tx.open_folder(options, |app: &mut App, result, _| match result { Ok(Some(path)) => { app.form.draft.output.path = path.display().to_string(); app.form.dirty = true; } Ok(None) => {} Err(e) => app.notify_error(format!("No folder dialog: {e}")), }); }, ); ui::setting_row_with( p, key, label, hint, // Growing the control and letting itself be small give the text a bounded width to elide // inside; content-sized, the row would run off the card. row() .gap(space::S2) .center_y() .grow(1.0) .min_w(0.0) .justify_end() .child(shown) .child(pick), ) } #[allow(clippy::too_many_arguments)] // the columns of a settings row fn select_row( p: Paint, kit: &rune_kit::Kit, layer: &mut Vec, key: &'static str, label: &str, hint: &str, options: &[&str], current: Option, app: &App, ) -> El { let open = app.form.open_select == Some(key); let control = Select::new(key, options) .current(current.as_deref()) .open(open) .label(label) .width(220.0) .on_toggle(move |app: &mut App| { app.form.open_select = if app.form.open_select == Some(key) { None } else { Some(key) }; }) .on_close(move |app: &mut App| app.form.open_select = None) .on_choose(move |app: &mut App, value: &str, _: &mut rune::Tx| { app.form.choose(key, value); app.form.open_select = None; }) .build(kit, layer); ui::setting_row_with(p, key, label, hint, control) } fn tabs(p: Paint, app: &App) -> El { let mut row = row().key("tabs").gap(4.0).center_y(); for (tab, label) in [ (SettingsTab::Quick, "Quick"), (SettingsTab::Recording, "Recording"), (SettingsTab::Audio, "Audio"), (SettingsTab::Advanced, "Advanced"), ] { row = row.child(ui::tab( p, label, label, app.settings_tab == tab, move |app: &mut App| { app.settings_tab = tab; app.form.open_select = None; }, )); } row } 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(20.0) .pb(space::S6) .pr(14.0); let content = match app.settings_tab { 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::Advanced => advanced(app, p, &kit, &mut layer, content), }; let body = col() .key("settings") .w_full() .h_full() .padding(space::S6) .gap(16.0) .child( row() .key("header") .w_full() .justify_between() .center_y() .child( text("Settings") .key("title") .font(heading(20.0)) .color(p.t.text), ) .child( row() .key("save-actions") .gap(8.0) .center_y() .child( row().key("save-state").mr(4.0).center_y().child( text(save_text) .key("save-label") .font(body(11.5)) .color(save_ink), ), ) .child(ui::button(p, "revert", "Revert", false, |app: &mut App| { if let Some(settings) = app.settings.clone() { app.form.dirty = false; app.form.apply(&settings); } })) .child(ui::button(p, "save", "Save", true, |app: &mut App| { if !app.form.loaded { return; } app.form.saving = true; let settings = app.form.settings(); match serde_json::to_value(&settings) { Ok(value) => app.daemon.save_settings(value), Err(e) => { app.notify_error(format!("settings did not serialize: {e}")) } } })), ), ) .child(tabs(p, app)) .child( app.scroll.follow( "scroller", col() .w_full() .grow(1.0) .min_h(0.0) .scroll(rune::ScrollSpec { stick_bottom: false, }) .child(content), ), ) .child(save_footer(p, app)); rune_kit::root(body, layer) } fn save_label(app: &App, p: Paint) -> (String, rune::Color) { if !app.connected { ("Daemon offline".into(), p.danger) } else if app.form.saving { ("Saving\u{2026}".into(), p.muted()) } else if app.form.dirty { ("Unsaved changes".into(), p.warning) } else if app.form.loaded { ("Saved".into(), p.muted()) } else { ("Loading".into(), p.muted()) } } /// The last line: where settings are written and when they take effect. fn save_footer(p: Paint, _app: &App) -> El { row().key("footer").w_full().center_y().child( text("Settings are stored by the recorder and survive its restart.") .key("footer-note") .font(body(11.5)) .color(p.muted()), ) } /// 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, 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![ 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( p, Some("Startup"), vec![ui::toggle_row( p, "autostart", "Launch League Recorder at startup", app.autostart, |app: &mut App| { let next = !app.autostart; match crate::os::set_autostart(next) { Ok(()) => { app.autostart = next; app.notify(if next { "League Recorder will start with Windows" } else { "League Recorder will no longer start with Windows" }); } Err(e) => app.notify_error(e), } }, )], )) .child(ui::card_action( p, Some("Files"), Some(ui::button( p, "open-recordings", "Open folder", false, |app: &mut App| { crate::daemon::open_folder(&app.output_dir()); }, )), vec![path_row( p, app, "recordings-folder", "Recordings folder", "Where finished recordings are written", )], )) } fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec, content: El) -> El { let v = &app.form.draft.video; let o = &app.form.draft.output; // Only the encoders this machine reports are offered. The static list stands in until the // daemon has answered. let offered = app.runnable_encoders(); let encoders: Vec<&str> = if offered.is_empty() { ENCODERS.to_vec() } else { offered }; // The stored encoder is shown as it is, even when this machine cannot run it, so the row // never claims something the daemon does not hold. let encoder = Some(v.encoder_preset.label().to_string()); content .child(ui::card( p, Some("Video"), vec![ select_row( p, kit, layer, "encoder", "Encoder", "The encoders this machine can run", &encoders, encoder, app, ), select_row( p, kit, layer, "quality", "Quality", v.quality.detail(), &QUALITIES, Some(v.quality.label().to_string()), app, ), ], )) .child(ui::card_action( p, Some("Output"), Some(ui::button( p, "open-output", "Open folder", false, |app: &mut App| { crate::daemon::open_folder(&app.output_dir()); }, )), vec![ path_row( p, app, "output-path", "Folder", "Where finished recordings are written", ), text_row( p, "naming", "File name", "{date}, {time}, {champion} and {queue_type} are filled in", &app.form.naming, |app| &mut app.form.naming, ), select_row( p, kit, layer, "container", "Container", "The file type recordings are saved as", &CONTAINERS, Some(o.container.clone()), app, ), ], )) } /// 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, 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| devices.iter().find(|d| &d.id == id)) .map(|d| d.name.clone()) .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(move |app: &mut App| { app.form.open_select = if app.form.open_select == Some(key) { None } else { Some(key) }; }) .on_close(|app: &mut App| app.form.open_select = None) .on_choose(|app: &mut App, value: &str, _: &mut rune::Tx| { 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, 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 applications yet. Add one and its audio joins the clip.") .key("sources-empty") .font(body(12.0)) .color(p.muted()) .ml(space::S3) .h(36.0), ); } for (index, source) in a.capture_apps.iter().enumerate() { sources = sources.child(source_row(app, p, index, source)); } content .child(ui::card( p, Some("Game"), vec![ ui::toggle_row( p, "game-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::setting_row( p, "game-volume", "Game volume", ui::slider( p, "game-volume", "Game volume", a.game_volume, |app, value| { app.form.draft.audio.game_volume = value; app.form.dirty = true; }, ), ), ], )) .child(ui::card( p, Some("Microphone"), vec![ ui::toggle_row( p, "capture-mic", "Capture microphone", a.capture_mic, |app: &mut App| { app.form.draft.audio.capture_mic ^= true; app.form.dirty = true; }, ), mic_row(p, kit, layer, app, "mic-device"), 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; }, ), ), ], )) .child(ui::card_action( p, Some("Applications"), Some(ui::icon_button( p, "add-source", "+", "Add an application", true, |app: &mut App| app.form.open_add(), )), vec![sources], )) } /// One captured application: its icon, name, whether it is running, its volume and Remove. fn source_row(app: &App, p: Paint, index: usize, source: &AudioSource) -> El { let id = source.id.clone(); let volume = source.volume.unwrap_or(100); let mut row = row() .key(format!("source-{}", source.id)) .h(52.0) .px(space::S3) .center_y() .gap(space::S3) .child(ui::process_icon(app, p, &source.device, 24.0)) .child( col() .key("source-labels") .grow(1.0) .min_w(0.0) .gap(1.0) .child( text(source.name.clone()) .key("name") .font(type_::BODY) .color(p.t.text) .truncate(), ) .child( text(source_detail(source)) .key("detail") .font(body(11.0)) .color(p.muted()) .truncate(), ), ); // Only a process source can be looked up; a device source names a device instead. if source.source_type == AudioSourceType::Application && let Some(found) = app .processes .get(&crate::process::normalize(&source.device)) { row = row.child(ui::process_state(p, found.running, 88.0)); } row.radius(radius::MD) .child(ui::slider( p, format!("volume-{}", source.id), "Application volume", volume, move |app: &mut App, value| { let payload = { let Some(source) = app.form.draft.audio.capture_apps.get_mut(index) else { return; }; source.volume = Some(value); serde_json::to_value(&*source).ok() }; app.form.dirty = true; if let Some(payload) = payload { app.daemon.update_audio_source(payload); } }, )) .child(ui::button( p, &format!("remove-{}", source.id), "Remove", false, move |app: &mut App| { app.daemon.remove_audio_source(&id); }, )) } /// What a source captures, under its name in the list. fn source_detail(source: &AudioSource) -> String { match source.source_type { AudioSourceType::Application => source.device.clone(), other => format!("{} · {}", other.label(), source.device), } } /// Send the dialog's name and process to the daemon as a new application source. fn submit_source(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() { return; } let source = AudioSource { id: String::new(), name, source_type: AudioSourceType::Application, 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}")), } app.form.close_add(); app.refresh_processes(); } /// The dialog the card's plus opens: what to call the application, and the process to listen /// to. `app::view` draws it over the whole window, title bar included. pub fn add_dialog(app: &App, p: Paint, layer: &mut Vec) { let typed = app.form.source_device.text.trim(); let found = app .processes .get(&crate::process::normalize(typed)) .filter(|_| !typed.is_empty()); let hint = match found { Some(found) if found.running => "That process is running.".to_string(), Some(_) => "That process is not running right now.".to_string(), None => "The name Windows gives the program, for example Discord.exe.".to_string(), }; let valid = !app.form.source_name.text.trim().is_empty() && !typed.is_empty(); let actions = row() .key("dialog-actions") .w_full() .gap(space::S2) .justify_end() .child(ui::button( p, "add-cancel", "Cancel", false, |app: &mut App| { app.form.close_add(); }, )) .child(if valid { ui::button(p, "add-confirm", "Add", true, |app: &mut App| { submit_source(app); }) } else { ui::button_muted(p, "add-confirm", "Add") }); let panel = col() .key("add-dialog") .role("dialog") .label("Add an application") .w(400.0) .padding(space::S6) .gap(space::S3) .radius(radius::LG) .fill(p.t.card) .border(p.hair, p.t.card_border) .shadow(4.0, 12.0, p.t.shadow) .shadow(24.0, 48.0, p.t.shadow_soft) .modal(true, |app: &mut App| app.form.close_add()) .child( row() .key("dialog-header") .w_full() .justify_between() .center_y() .child( text("Add an application") .key("dialog-title") .font(heading(15.0)) .color(p.t.text), ) .child(ui::icon_button( p, "add-close", "×", "Close", false, |app: &mut App| app.form.close_add(), )), ) .child( text("Its audio is mixed into the clip beside the game's.") .key("dialog-note") .font(body(12.0)) .color(p.muted()), ) .child(captioned_field( p, "Name", "add-name", &app.form.source_name, |app| &mut app.form.source_name, )) .child(captioned_field( p, "Process", "add-process", &app.form.source_device, |app| &mut app.form.source_device, )) .child( text(hint) .key("dialog-hint") .font(body(11.0)) .color(p.muted()), ) .child(actions); layer.push( el().key("add-scrim") .absolute(0.0, 0.0) .w_full() .h_full() .fill(Color::BLACK.alpha(if app.dark { 0.55 } else { 0.28 })) .a11y_hidden(), ); layer.push( el().key("add-layer") .absolute(0.0, 0.0) .w_full() .h_full() .padding(16.0) .center() .child(panel), ); } /// A wide field under its own caption, for a dialog where labels do not fit beside it. fn captioned_field( p: Paint, label: &'static str, key: &'static str, edit: &TextEdit, to: fn(&mut App) -> &mut TextEdit, ) -> El { col() .key(key) .w_full() .gap(space::S1) .child(text(label).key("caption").font(body(11.0)).color(p.muted())) .child(ui::text_field_width( p, key, label, 352.0, rune::Align::Start, edit, to, |_app| {}, )) } /// The first lines of a release note, enough to say what changed without turning the card /// into a document. fn notes_excerpt(notes: &str) -> String { let mut text = notes.lines().take(6).collect::>().join("\n"); if let Some((cut, _)) = text.char_indices().nth(700) { text.truncate(cut); text.push_str("..."); } text } fn advanced(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec, content: El) -> El { let status_row = |key: &str, label: &'static str, value: String| { row() .key(key) .h(36.0) .px(space::S3) .center_y() .justify_between() .child(text(label).key("label").font(type_::BODY).color(p.t.text)) .child( text(value) .key("value") .font(type_::MONO_CAPTION) .color(p.muted()) .ml(space::S2) // A long value, the log path most of all, is cut to the row's width. .truncate_middle(), ) }; let recording = if app.status.is_recording { "yes" } else { "no" }; let mut update_rows = vec![ status_row("app-version", "Version", app.update.current.to_string()), status_row("update-status", "Status", app.update.status_text()), ]; if let Some(available) = &app.update.available { if let Some(published) = available.published.as_deref() { let shown = chrono::DateTime::parse_from_rfc3339(published) .map(|at| crate::format::relative_time(at.with_timezone(&chrono::Utc))) .unwrap_or_else(|_| published.to_string()); update_rows.push(status_row("update-published", "Published", shown)); } if !available.notes.trim().is_empty() { update_rows.push( row() .key("update-notes") .w_full() .px(space::S3) .py(space::S2) .child( text(notes_excerpt(&available.notes)) .key("notes") .font(body(11.5)) .color(p.muted()) .w_full(), ), ); } } if app.update.can_check() || app.update.can_download() || app.update.can_install() { let mut actions = row() .key("update-actions") .w_full() .gap(8.0) .px(space::S3) .py(space::S2) .center_y(); if app.update.can_check() { actions = actions.child(ui::button( p, "update-check", "Check now", false, |app: &mut App| app.update.check(true), )); } if app.update.can_download() { let available = app.update.available.as_ref(); let version = available .map(|available| available.version.to_string()) .unwrap_or_default(); let size = available .map(|available| format!(" ({})", crate::format::bytes(available.size))) .unwrap_or_default(); actions = actions.child(ui::button( p, "update-download", &format!("Download {version}{size}"), true, |app: &mut App| app.update.download(), )); } if app.update.can_install() { actions = actions.child(ui::button_tx( p, "update-install", "Restart and install", true, |app: &mut App, tx: &mut rune::Tx| app.install_update(tx), )); } actions = actions.child(ui::button( p, "update-folder", "Open update folder", false, |_app: &mut App| crate::daemon::open_folder(&crate::update::updates_dir()), )); update_rows.push(actions); } content .child(ui::card(p, Some("Updates"), update_rows)) .child(ui::card( p, Some("Daemon"), vec![ status_row("daemon-status", "Status", app.status.label()), status_row( "daemon-connection", "Pipe", if app.connected { "connected".into() } else { "not connected".into() }, ), status_row( "daemon-client", "League Client", if app.status.client_connected { "connected".into() } else { "not running".into() }, ), status_row("daemon-recording", "Recording", recording.into()), status_row( "daemon-game", "Current game", app.status .current_game_id .map(|id| id.to_string()) .unwrap_or_else(|| "none".into()), ), status_row("daemon-log", "Log file", crate::daemon::log_path()), ], )) .child(ui::card( p, Some("Recorder"), vec![ text_row( p, "poll-interval", "Client poll interval", "How often the recorder checks the League Client, in milliseconds", &app.form.poll_interval, |app| &mut app.form.poll_interval, ), select_row( p, kit, layer, "log-level", "Log level", "How much the recorder writes to its log", &LOG_LEVELS, Some(app.form.draft.daemon.log_level.clone()), app, ), ], )) .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") .gap(8.0) .child(ui::button( p, "daemon-check", "Check connection", false, |app: &mut App| { app.daemon.ensure_running(); app.daemon.get_status(); }, )) .child(ui::button( p, "daemon-logs", "Reload log", false, |app: &mut App| { app.daemon.logs(); }, )) .child(ui::button( p, "daemon-shutdown", "Stop daemon", false, |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( p, Some("Log"), vec![ app.log_scroll.follow( "log-scroller", col() .key("log") .padding(space::S3) // Room for the scroll bar the box draws at the viewport's end edge. .pr(14.0) .h(440.0) .gap(0.0) .scroll(rune::ScrollSpec { stick_bottom: true }) .child( text(if app.logs.is_empty() { "No log loaded. Press Reload log." } else { &app.logs }) .key("log-text") .font(type_::MONO_CAPTION) .color(p.muted()) .w_full(), ), ), ], )) }