app: put automatic recording at the center of the window

The titlebar offered "Start recording" although the recorder starts with a
game; Settings takes that button's place. The two-tab sidebar becomes a
status bar that also names the encoder, and the blue square beside the name
is gone.

Match cards show a champion tile: initials on a colour derived from the
name until there is an image cache. History, review and settings lists get
a scrollbar that follows the viewport in the same frame.

Settings keeps the one switch a player can act on, launch at startup, and
says in plain words that recording starts with a game. The recorder's own
toggles and the client poll interval move to Advanced.
This commit is contained in:
vhaudiquet committed 2026-11-15 23:34:12 +01:00
1 parent 01a92f1edf
commit e7a36c3129
6 files changed
+328 -265

No files matched your search

+77 -32
View File
@@ -112,15 +112,17 @@ pub fn view(app: &App, p: Paint) -> El {
.child(filters),
)
.child(
col()
.key("list-scroller")
.w_full()
.grow(1.0)
.min_h(0.0)
.scroll(rune::ScrollSpec {
stick_bottom: false,
})
.child(list),
app.scroll.follow(
col()
.key("list-scroller")
.w_full()
.grow(1.0)
.min_h(0.0)
.scroll(rune::ScrollSpec {
stick_bottom: false,
})
.child(list),
),
)
}
@@ -236,30 +238,37 @@ fn game_card(p: Paint, game: &Timeline, index: usize) -> El {
.center_y()
.justify_between()
.child(
col()
row()
.key("identity")
.gap(2.0)
.gap(space::S3)
.center_y()
.child(portrait(p, game.champion().as_deref()))
.child(
text(champion)
.key("champion")
.font(heading(16.0))
.color(p.t.text),
)
.child(
text(format!(
"{} · {}",
game.queue_label(),
format::duration(duration)
))
.key("queue")
.font(body(11.5))
.color(p.muted()),
)
.child(
text(format::relative_time(game.start_time))
.key("when")
.font(body(11.0))
.color(p.muted()),
col()
.key("identity-labels")
.gap(2.0)
.child(
text(champion)
.key("champion")
.font(heading(16.0))
.color(p.t.text),
)
.child(
text(format!(
"{} · {}",
game.queue_label(),
format::duration(duration)
))
.key("queue")
.font(body(11.5))
.color(p.muted()),
)
.child(
text(format::relative_time(game.start_time))
.key("when")
.font(body(11.0))
.color(p.muted()),
),
),
)
.child(
@@ -290,7 +299,6 @@ fn game_card(p: Paint, game: &Timeline, index: usize) -> El {
),
)
}
fn stat(p: Paint, value: &str, label: &str) -> El {
col()
.key(format!("stat-{label}"))
@@ -304,3 +312,40 @@ fn stat(p: Paint, value: &str, label: &str) -> El {
)
.child(text(label).key("label").font(body(10.5)).color(p.muted()))
}
/// A square champion tile. There is no Data Dragon image cache yet, so the tile carries the
/// champion's initials on a colour derived from the name: the same champion always gets the
/// same tile.
fn portrait(p: Paint, champion: Option<&str>) -> El {
let name = champion.unwrap_or_default();
let hue = name
.bytes()
.fold(2166136261u32, |hash, byte| {
hash.wrapping_mul(16777619) ^ byte as u32
})
.rem_euclid(360) as f32;
let fill = rune::oklch(0.36, 0.075, hue);
let ink = rune::oklch(0.94, 0.02, hue);
el().key("portrait")
.size(52.0, 52.0)
.radius(radius::MD)
.fill(fill)
.border(p.hair, ink.alpha(0.18))
.a11y_hidden()
.child(text(initials(name)).font(heading(17.0)).color(ink).center())
}
/// Up to two letters from the champion's name: `Kai'Sa` is KS, `Jinx` is J.
fn initials(name: &str) -> String {
let letters: Vec<char> = name
.split(|c: char| !c.is_alphanumeric())
.filter(|word| !word.is_empty())
.filter_map(|word| word.chars().next())
.take(2)
.collect();
if letters.is_empty() {
"?".into()
} else {
letters.into_iter().collect()
}
}
+63 -108
View File
@@ -5,7 +5,7 @@ use rune::{El, TextEdit, col, row, text};
use rune_kit::Select;
use crate::app::{App, SettingsTab};
use crate::settings::{AudioSource, AudioSourceType, EncoderPreset, Quality, Settings};
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.
@@ -132,14 +132,6 @@ impl Form {
}
}
fn encoder_label(preset: &EncoderPreset) -> &'static str {
match preset {
EncoderPreset::Nvenc { .. } => "NVIDIA NVENC",
EncoderPreset::Amf { .. } => "AMD AMF",
EncoderPreset::X264 { .. } => "x264 (Software)",
}
}
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"];
@@ -210,7 +202,7 @@ fn tabs(p: Paint, app: &App) -> El {
(SettingsTab::General, "General"),
(SettingsTab::Recording, "Recording"),
(SettingsTab::Audio, "Audio"),
(SettingsTab::Daemon, "Daemon"),
(SettingsTab::Daemon, "Advanced"),
] {
row = row.child(ui::tab(
p,
@@ -239,7 +231,7 @@ pub fn view(app: &App, p: Paint) -> El {
SettingsTab::General => general(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, content),
SettingsTab::Daemon => daemon_tab(app, p, &kit, &mut layer, content),
};
let body = col()
@@ -295,15 +287,17 @@ pub fn view(app: &App, p: Paint) -> El {
)
.child(tabs(p, app))
.child(
col()
.key("scroller")
.w_full()
.grow(1.0)
.min_h(0.0)
.scroll(rune::ScrollSpec {
stick_bottom: false,
})
.child(content),
app.scroll.follow(
col()
.key("scroller")
.w_full()
.grow(1.0)
.min_h(0.0)
.scroll(rune::ScrollSpec {
stick_bottom: false,
})
.child(content),
),
)
.child(save_footer(p, app));
@@ -323,71 +317,33 @@ fn save_label(app: &App) -> String {
}
/// 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()
.justify_between()
.child(
text("Settings are stored by the record-daemon and survive its restart.")
.key("footer-note")
.font(body(11.5))
.color(p.muted()),
)
.child(
text(format!(
"Log level: {} · encoder: {}",
app.form.draft.daemon.log_level,
if app.encoders.current.is_empty() {
"auto"
} else {
&app.encoders.current
},
))
.key("log-level-note")
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()),
)
)
}
fn general(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
let d = &app.form.draft.daemon;
fn general(_app: &App, p: Paint, _kit: &rune_kit::Kit, _layer: &mut Vec<El>, content: El) -> El {
content
.child(ui::card(
p,
Some("Recording"),
vec![
ui::toggle_row(
p,
"auto-record",
"Start recording automatically",
d.auto_record,
|app: &mut App| {
app.form.draft.daemon.auto_record ^= true;
app.form.dirty = true;
},
),
ui::toggle_row(
p,
"monitor-client",
"Watch for the League Client",
d.monitor_client,
|app: &mut App| {
app.form.draft.daemon.monitor_client ^= true;
app.form.dirty = true;
},
),
ui::toggle_row(
p,
"save-timeline",
"Keep the event timeline",
d.save_timeline,
|app: &mut App| {
app.form.draft.daemon.save_timeline ^= true;
app.form.dirty = true;
},
),
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),
],
))
.child(ui::card(
@@ -396,8 +352,8 @@ fn general(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, conten
vec![ui::toggle_row(
p,
"autostart",
"Launch at login",
app.autostart,
"Launch League Recorder at startup",
_app.autostart,
|app: &mut App| {
let next = !app.autostart;
match crate::os::set_autostart(next) {
@@ -414,35 +370,9 @@ fn general(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, conten
},
)],
))
.child(ui::card(
p,
Some("League Client"),
vec![
text_row(
p,
kit,
"poll-interval",
"Client poll interval",
"How often the daemon 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 daemon writes to its log",
&LOG_LEVELS,
Some(d.log_level.clone()),
app,
),
],
))
.child(
row()
.key("general-danger")
.key("general-actions")
.gap(8.0)
.center_y()
.child(ui::button(
@@ -465,7 +395,6 @@ fn general(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, conten
)),
)
}
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;
@@ -496,7 +425,7 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
"Encoder",
"Hardware encoding is faster; x264 uses the CPU",
&ENCODERS,
Some(encoder_label(&v.encoder_preset).to_string()),
Some(v.encoder_preset.label().to_string()),
app,
),
select_row(
@@ -937,7 +866,7 @@ fn audio(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
))
}
fn daemon_tab(app: &App, p: Paint, content: El) -> El {
fn daemon_tab(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)
@@ -991,6 +920,32 @@ fn daemon_tab(app: &App, p: Paint, content: El) -> El {
status_row("daemon-log", "Log file", crate::daemon::log_path()),
],
))
.child(ui::card(
p,
Some("Recorder"),
vec![
text_row(
p,
kit,
"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(
row()
.key("daemon-actions")