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:
1 parent
01a92f1edf
commit
e7a36c3129
6 files changed
+278
-215
No files matched your search
+89
-116
@@ -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)
|
||||
.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))
|
||||
.child(
|
||||
row()
|
||||
.key("connection")
|
||||
.gap(7.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()
|
||||
.padding(6.0)
|
||||
.fill(p.t.bg)
|
||||
.border_sides([p.hair, 0.0, 0.0, 0.0], p.t.separator)
|
||||
.child(ui::dot(dot_color))
|
||||
.child(
|
||||
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")
|
||||
@@ -624,48 +632,13 @@ fn titlebar(p: Paint, app: &App) -> El {
|
||||
.center_y()
|
||||
.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();
|
||||
},
|
||||
)),
|
||||
)
|
||||
.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.
|
||||
|
||||
@@ -62,6 +62,11 @@ fn main() {
|
||||
app.settings_tab = app::SettingsTab::Daemon;
|
||||
}),
|
||||
("review", |app| app::demo_review(app)),
|
||||
("many", |app| {
|
||||
app.screen = app::Screen::History;
|
||||
app.games = (0..30).flat_map(|_| crate::history::sample()).collect();
|
||||
app.games_loaded = true;
|
||||
}),
|
||||
],
|
||||
setup: Some(app::setup),
|
||||
poll: Some(app::poll),
|
||||
|
||||
@@ -112,6 +112,7 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
.child(filters),
|
||||
)
|
||||
.child(
|
||||
app.scroll.follow(
|
||||
col()
|
||||
.key("list-scroller")
|
||||
.w_full()
|
||||
@@ -121,6 +122,7 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
stick_bottom: false,
|
||||
})
|
||||
.child(list),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -236,8 +238,14 @@ fn game_card(p: Paint, game: &Timeline, index: usize) -> El {
|
||||
.center_y()
|
||||
.justify_between()
|
||||
.child(
|
||||
col()
|
||||
row()
|
||||
.key("identity")
|
||||
.gap(space::S3)
|
||||
.center_y()
|
||||
.child(portrait(p, game.champion().as_deref()))
|
||||
.child(
|
||||
col()
|
||||
.key("identity-labels")
|
||||
.gap(2.0)
|
||||
.child(
|
||||
text(champion)
|
||||
@@ -261,6 +269,7 @@ fn game_card(p: Paint, game: &Timeline, index: usize) -> El {
|
||||
.font(body(11.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
col()
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
+52
-97
@@ -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,6 +287,7 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
)
|
||||
.child(tabs(p, app))
|
||||
.child(
|
||||
app.scroll.follow(
|
||||
col()
|
||||
.key("scroller")
|
||||
.w_full()
|
||||
@@ -304,6 +297,7 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
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.")
|
||||
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()),
|
||||
)
|
||||
.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")
|
||||
.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")
|
||||
|
||||
@@ -90,6 +90,24 @@ impl EncoderPreset {
|
||||
}
|
||||
}
|
||||
|
||||
/// The name a daemon-reported encoder id (`.current`) stands for.
|
||||
pub fn encoder_name(id: &str) -> Option<&'static str> {
|
||||
match id {
|
||||
"jim_nvenc" => Some("NVIDIA NVENC"),
|
||||
"amd_amf_h264" => Some("AMD AMF"),
|
||||
"x264" => Some("x264 (Software)"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(&self) -> &'static str {
|
||||
match self {
|
||||
EncoderPreset::Nvenc { .. } => "NVIDIA NVENC",
|
||||
EncoderPreset::Amf { .. } => "AMD AMF",
|
||||
EncoderPreset::X264 { .. } => "x264 (Software)",
|
||||
}
|
||||
}
|
||||
|
||||
/// This preset with the encoder changed, keeping the bitrate where both have one.
|
||||
pub fn with_kind(&self, kind: &str) -> EncoderPreset {
|
||||
let bitrate = match self {
|
||||
|
||||
@@ -345,3 +345,70 @@ pub fn dot(color: Color) -> El {
|
||||
.fill(color)
|
||||
.a11y_hidden()
|
||||
}
|
||||
|
||||
/// A scroll viewport's scrollbar. The viewport reports where it is; the thumb follows in the
|
||||
/// same frame, so a drag scrolls the list and the bar together.
|
||||
pub struct ScrollBar {
|
||||
area: rune::Live<[f32; 4]>,
|
||||
thumb: rune::Live<[f32; 4]>,
|
||||
last: std::rc::Rc<std::cell::Cell<rune::ScrollPos>>,
|
||||
}
|
||||
|
||||
impl Default for ScrollBar {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl ScrollBar {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
area: rune::Live::new([0.0; 4]),
|
||||
thumb: rune::Live::new([0.0; 4]),
|
||||
last: std::rc::Rc::new(std::cell::Cell::new(rune::ScrollPos::default())),
|
||||
}
|
||||
}
|
||||
|
||||
/// Make this viewport's scrolling move the thumb.
|
||||
pub fn follow(&self, viewport: El) -> El {
|
||||
let reported = self.area.clone();
|
||||
let area = self.area.clone();
|
||||
let last = self.last.clone();
|
||||
let on_layout_last = self.last.clone();
|
||||
let on_layout_thumb = self.thumb.clone();
|
||||
let thumb = self.thumb.clone();
|
||||
viewport
|
||||
.on_layout_tx(move |_app: &mut App, rect, tx| {
|
||||
reported.set(rect);
|
||||
place(&on_layout_thumb, rect, on_layout_last.get());
|
||||
tx.live_only();
|
||||
})
|
||||
.on_scroll_offset(move |at: rune::ScrollPos| {
|
||||
last.set(at);
|
||||
place(&thumb, area.get(), at);
|
||||
})
|
||||
}
|
||||
|
||||
/// The thumb, drawn over the window. `key` must differ per bar on one screen.
|
||||
pub fn thumb(&self, p: Paint, key: &str) -> El {
|
||||
el().key(key)
|
||||
.absolute(0.0, 0.0)
|
||||
.size(6.0, 0.0)
|
||||
.radius(3.0)
|
||||
.fill(p.t.text_secondary.alpha(0.5))
|
||||
.live_rect(&self.thumb)
|
||||
.a11y_hidden()
|
||||
}
|
||||
}
|
||||
|
||||
/// Put the thumb where `at` says the viewport is, inside `area`'s window rect.
|
||||
fn place(thumb: &rune::Live<[f32; 4]>, [x, y, w, h]: [f32; 4], at: rune::ScrollPos) {
|
||||
let content = at.viewport[1] + at.max[1];
|
||||
if h <= 1.0 || w <= 1.0 || at.max[1] <= 0.5 || content <= 0.0 {
|
||||
thumb.set([0.0, 0.0, 0.0, 0.0]);
|
||||
return;
|
||||
}
|
||||
let height = (h * at.viewport[1] / content).clamp(28.0, h);
|
||||
let progress = (at.offset[1] / at.max[1]).clamp(0.0, 1.0);
|
||||
thumb.set([x + w - 9.0, y + progress * (h - height), 6.0, height]);
|
||||
}
|
||||
Reference in new issue
Block a user