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

+98 -125
View File
@@ -3,7 +3,7 @@
use std::sync::mpsc::{Receiver, TryRecvError, channel};
use std::time::Duration;
use rune::tok::{radius, type_};
use rune::tok::type_;
use rune::{Cx, El, Key, KeyEvent, Tx, col, el, row, text};
use crate::history::{self, QueueCategory, Timeline};
@@ -114,6 +114,9 @@ pub struct App {
pub games_loaded: bool,
pub filter: Option<QueueCategory>,
pub review: screens::review::Review,
pub scroll: ui::ScrollBar,
pub highlights_scroll: ui::ScrollBar,
pub events_scroll: ui::ScrollBar,
pub notice: Option<Notice>,
pub autostart: bool,
pub logs: String,
@@ -146,6 +149,9 @@ impl App {
games_loaded: false,
filter: None,
review: screens::review::Review::default(),
scroll: ui::ScrollBar::new(),
highlights_scroll: ui::ScrollBar::new(),
events_scroll: ui::ScrollBar::new(),
notice: None,
autostart,
logs: String::new(),
@@ -248,7 +254,8 @@ impl App {
}
let (tx, rx) = channel();
std::thread::spawn(move || {
let _ = tx.send(history::load_all());
let games = history::load_all();
let _ = tx.send(games);
});
self.games_rx = Some(rx);
}
@@ -509,6 +516,10 @@ pub fn on_key(app: &mut App, event: &KeyEvent, _tx: &mut Tx) -> bool {
app.screen = Screen::History;
true
}
(Key::Escape, _) if app.screen == Screen::Settings => {
app.screen = Screen::History;
true
}
(Key::Text(t), true) if t.eq_ignore_ascii_case("r") => {
app.refresh_games();
app.daemon.get_status();
@@ -534,86 +545,83 @@ fn status_color(p: Paint, app: &App) -> (rune::Color, String) {
(p.muted(), app.status.label())
}
fn nav(p: Paint, label: &str, key: &str, active: bool, to: Screen) -> El {
el().key(key)
.role("tab")
.label(label)
.checked(active)
.focusable(true)
.w_full()
.h(32.0)
.px(10.0)
.center_y()
.radius(radius::MD)
.fill(if active {
p.t.indicator.alpha(0.5)
} else {
rune::Color::TRANSPARENT
})
.hover(p.t.hover)
.press(p.t.press)
.on_press(move |app: &mut App| {
if to != Screen::Review {
screens::review::leave(app);
}
app.screen = to;
})
.child(
text(label)
.key("label")
.font(type_::BODY)
.color(if active { p.t.text } else { p.t.text_secondary })
.a11y_hidden(),
)
}
fn sidebar(p: Paint, app: &App) -> El {
/// The thin bar under the screens: daemon state on the left, the encoder on the right.
fn statusbar(p: Paint, app: &App) -> El {
let (dot_color, status) = status_color(p, app);
col()
.key("sidebar")
.w(196.0)
.h_full()
.padding(10.0)
.gap(4.0)
let name = crate::settings::EncoderPreset::encoder_name(&app.encoders.current)
.map(str::to_string)
.or_else(|| {
app.settings
.as_ref()
.map(|settings| settings.video.encoder_preset.label().to_string())
});
let recording = match (name, app.settings.as_ref().map(|s| s.video.frame_rate)) {
(Some(name), Some(fps)) => Some(format!("{name} · {fps} fps")),
(Some(name), None) => Some(name),
_ => None,
};
let mut bar = row()
.key("statusbar")
.h(30.0)
.w_full()
.px(14.0)
.gap(8.0)
.center_y()
.fill(p.t.bg)
.border_sides([0.0, p.hair, 0.0, 0.0], p.t.separator)
.child(nav(
p,
"Match history",
"nav-history",
app.screen != Screen::Settings,
Screen::History,
))
.child(nav(
p,
"Settings",
"nav-settings",
app.screen == Screen::Settings,
Screen::Settings,
))
.child(el().grow(1.0))
.border_sides([p.hair, 0.0, 0.0, 0.0], p.t.separator)
.child(ui::dot(dot_color))
.child(
row()
.key("connection")
.gap(7.0)
.center_y()
.padding(6.0)
.child(ui::dot(dot_color))
.child(
text(status)
.key("status-text")
.font(body(11.5))
.color(p.muted()),
),
text(status)
.key("status-text")
.font(body(11.5))
.color(p.muted()),
)
.child(el().grow(1.0));
if let Some(note) = recording {
bar = bar.child(
text(note)
.key("encoder-note")
.font(body(11.0))
.color(p.muted()),
);
}
bar
}
fn titlebar(p: Paint, app: &App) -> El {
let recording = app.status.is_recording;
let label = if recording {
"Stop recording"
let actions = if app.screen == Screen::Settings {
row().key("actions").gap(8.0).center_y().child(ui::button(
p,
"back",
"← Match history",
false,
|app: &mut App| app.screen = Screen::History,
))
} else {
"Start recording"
row()
.key("actions")
.gap(8.0)
.center_y()
.child(ui::button(
p,
"refresh",
"Refresh",
false,
|app: &mut App| {
app.refresh_games();
app.daemon.get_status();
},
))
.child(ui::button(
p,
"open-settings",
"Settings",
false,
|app: &mut App| {
screens::review::leave(app);
app.screen = Screen::Settings;
},
))
};
row()
.key("titlebar")
@@ -625,47 +633,12 @@ fn titlebar(p: Paint, app: &App) -> El {
.justify_between()
.window_drag()
.child(
row()
.key("brand")
.gap(8.0)
.center_y()
.child(el().key("mark").size(18.0, 18.0).radius(5.0).fill(p.accent))
.child(
text("League Recorder")
.key("title")
.font(heading(13.0))
.color(p.t.text),
),
)
.child(
row()
.key("actions")
.gap(8.0)
.center_y()
.child(ui::button(
p,
"record-toggle",
label,
!recording,
|app: &mut App| {
if app.status.is_recording {
app.daemon.stop_recording();
} else {
app.daemon.start_recording();
}
},
))
.child(ui::button(
p,
"refresh",
"Refresh",
false,
|app: &mut App| {
app.refresh_games();
app.daemon.get_status();
},
)),
text("League Recorder")
.key("title")
.font(heading(13.0))
.color(p.t.text),
)
.child(actions)
}
fn notice(p: Paint, notice: &Notice) -> El {
@@ -715,26 +688,26 @@ pub fn view(app: &App, cx: &mut Cx<App>) -> El {
Screen::History => screens::history::view(app, p),
Screen::Review => screens::review::view(app, p),
};
let mut main = col().key("main").grow(1.0).min_h(0.0).h_full().fill(p.t.bg);
let mut main = col().key("main").grow(1.0).min_h(0.0).w_full().fill(p.t.bg);
if let Some(banner) = &app.notice {
main = main.child(notice(p, banner));
}
main = main.child(content);
col()
let mut window = col()
.key("window")
.w_full()
.h_full()
.fill(p.t.bg)
.child(titlebar(p, app))
.child(
row()
.key("body")
.grow(1.0)
.min_h(0.0)
.w_full()
.child(sidebar(p, app))
.child(main),
)
.child(main)
.child(statusbar(p, app));
window = match app.screen {
Screen::Review => window
.child(app.highlights_scroll.thumb(p, "highlights-thumb"))
.child(app.events_scroll.thumb(p, "events-thumb")),
_ => window.child(app.scroll.thumb(p, "scroll-thumb")),
};
window
}
/// Whether this is a headless run (`--snap out.png`, `--tree`, …) rather than a window.