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
+328
-265
No files matched your search
@@ -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