app: draw champion portraits, a 16:9 player and draggable scroll bars
Cards and the review header showed two initials where a champion portrait belongs. Data Dragon is fetched from a worker thread and cached under the user's cache directory, so the first sight of a champion puts its face on the card and later runs read it from disk; offline, the tile keeps its initials on the champion's colour. The review screen put the clip in a small box above two list columns. The clip now fills the window at 16:9 and the highlights and timeline open beside it on demand, so nothing shrinks the video by default and every event still marks the scrubber. Scroll bars were a thumb drawn over the cards that could not be dragged. They now sit in a strip the content leaves free, stay visible while the list overflows, and scroll the viewport when dragged.
This commit is contained in:
1 parent
3d0cad3312
commit
227aecb8f6
10 files changed
+500
-181
No files matched your search
+13
-47
@@ -1,7 +1,7 @@
|
||||
//! Match history: the timelines on disk, newest first, filtered by queue.
|
||||
//!
|
||||
//! The card reads like `GameHistory.vue`: result banner, champion, queue, KDA, per-minute
|
||||
//! stats, items are not shown because the app has no Data Dragon image cache yet.
|
||||
//! The card reads like `GameHistory.vue`: result banner, champion portrait, queue, KDA and
|
||||
//! per-minute stats. Items are not shown: the timeline does not carry them.
|
||||
|
||||
use rune::tok::{radius, space, type_};
|
||||
use rune::{Color, El, col, el, row, text};
|
||||
@@ -41,7 +41,8 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
.filter(|(_, g)| app.filter.is_none_or(|f| g.category() == f))
|
||||
.collect();
|
||||
|
||||
let mut list = col().key("games").w_full().gap(space::S2);
|
||||
// The scroll bar gets its own strip at the end, clear of the cards.
|
||||
let mut list = col().key("games").w_full().gap(space::S2).pr(14.0);
|
||||
if !app.games_loaded {
|
||||
list = list.child(
|
||||
text("Loading match history…")
|
||||
@@ -64,7 +65,7 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
));
|
||||
} else {
|
||||
for (index, game) in filtered {
|
||||
list = list.child(game_card(p, game, index));
|
||||
list = list.child(game_card(app, p, game, index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,8 +114,8 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
)
|
||||
.child(
|
||||
app.scroll.follow(
|
||||
"list-scroller",
|
||||
col()
|
||||
.key("list-scroller")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
@@ -147,7 +148,7 @@ fn empty(p: Paint, title: &str, detail: &str) -> El {
|
||||
)
|
||||
}
|
||||
|
||||
fn game_card(p: Paint, game: &Timeline, index: usize) -> El {
|
||||
fn game_card(app: &App, p: Paint, game: &Timeline, index: usize) -> El {
|
||||
let outcome = game.outcome();
|
||||
let ink = outcome_color(p, outcome);
|
||||
let champion = game.champion().unwrap_or_else(|| "Unknown champion".into());
|
||||
@@ -242,7 +243,12 @@ fn game_card(p: Paint, game: &Timeline, index: usize) -> El {
|
||||
.key("identity")
|
||||
.gap(space::S3)
|
||||
.center_y()
|
||||
.child(portrait(p, game.champion().as_deref()))
|
||||
.child(ui::champion_portrait(
|
||||
app,
|
||||
p,
|
||||
game.champion().as_deref(),
|
||||
52.0,
|
||||
))
|
||||
.child(
|
||||
col()
|
||||
.key("identity-labels")
|
||||
@@ -312,43 +318,3 @@ 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, ink) = if name.is_empty() {
|
||||
(p.t.control_off, p.muted())
|
||||
} else {
|
||||
(rune::oklch(0.36, 0.075, hue), 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()
|
||||
}
|
||||
}
|
||||
+139
-104
@@ -18,6 +18,7 @@ pub struct Review {
|
||||
pub time: f64,
|
||||
pub duration: f64,
|
||||
pub scrubber_width: f32,
|
||||
pub show_details: bool,
|
||||
pub highlights: Vec<Highlight>,
|
||||
pub export: Option<Receiver<Result<String, String>>>,
|
||||
pub export_note: Option<String>,
|
||||
@@ -169,6 +170,12 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
app.screen = Screen::History;
|
||||
},
|
||||
))
|
||||
.child(ui::champion_portrait(
|
||||
app,
|
||||
p,
|
||||
game.champion().as_deref(),
|
||||
26.0,
|
||||
))
|
||||
.child(
|
||||
text(game.champion().unwrap_or_else(|| "Unknown champion".into()))
|
||||
.key("champion")
|
||||
@@ -199,6 +206,41 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
.color(p.muted()),
|
||||
);
|
||||
|
||||
// The player takes the window: the clip is why the screen exists. The details column
|
||||
// opens beside it on demand, so a closed panel leaves the clip the whole width.
|
||||
let body = row()
|
||||
.key("review-body")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.gap(space::S3)
|
||||
.child(
|
||||
col()
|
||||
.key("player")
|
||||
.grow(1.0)
|
||||
.min_w(0.0)
|
||||
.min_h(0.0)
|
||||
.gap(space::S2)
|
||||
.child(video_stage(app, p))
|
||||
.child(transport(app, p))
|
||||
.child(scrubber(app, p, game)),
|
||||
);
|
||||
let body = if app.review.show_details {
|
||||
body.child(
|
||||
col()
|
||||
.key("details")
|
||||
.w(380.0)
|
||||
.min_w(320.0)
|
||||
.h_full()
|
||||
.min_h(0.0)
|
||||
.gap(space::S2)
|
||||
.child(highlights(app, p, game))
|
||||
.child(events(app, p, game)),
|
||||
)
|
||||
} else {
|
||||
body
|
||||
};
|
||||
|
||||
col()
|
||||
.key("review")
|
||||
.w_full()
|
||||
@@ -206,111 +248,103 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
.padding(space::S6)
|
||||
.gap(space::S3)
|
||||
.child(header)
|
||||
.child(video_stage(app, p))
|
||||
.child(scrubber(app, p, game))
|
||||
.child(
|
||||
row()
|
||||
.key("review-body")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.gap(space::S3)
|
||||
.child(highlights(app, p, game))
|
||||
.child(events(app, p, game)),
|
||||
)
|
||||
.child(body)
|
||||
}
|
||||
|
||||
/// The clip itself: the largest 16:9 box that fits, on black, with a message when there is no
|
||||
/// file to play.
|
||||
fn video_stage(app: &App, p: Paint) -> El {
|
||||
let mut stage = el()
|
||||
let stage = el()
|
||||
.key("stage")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.radius(radius::LG)
|
||||
.fill(rune::Color::BLACK)
|
||||
.clip_soft(radius::LG);
|
||||
.radius(radius::LG)
|
||||
.clip_soft(radius::LG)
|
||||
.center();
|
||||
|
||||
if let Some(player) = &app.review.player {
|
||||
stage = stage.child(
|
||||
match &app.review.player {
|
||||
Some(player) => stage.child(
|
||||
el().key("video")
|
||||
.w_full()
|
||||
.h_full()
|
||||
.video(player, SurfaceFit::Fit),
|
||||
);
|
||||
} else {
|
||||
stage = stage.child(
|
||||
col()
|
||||
.key("stage-empty")
|
||||
.w_full()
|
||||
.h_full()
|
||||
.center()
|
||||
.gap(6.0)
|
||||
.child(
|
||||
text(
|
||||
app.review
|
||||
.error
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Loading the clip…".into()),
|
||||
)
|
||||
.key("stage-message")
|
||||
.font(body(13.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
col()
|
||||
.key("stage-column")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.gap(space::S2)
|
||||
.child(stage)
|
||||
.child(
|
||||
row()
|
||||
.key("transport")
|
||||
.w_full()
|
||||
.center_y()
|
||||
.gap(space::S3)
|
||||
.child(ui::button(
|
||||
p,
|
||||
"play-pause",
|
||||
if playing(app) { "Pause" } else { "Play" },
|
||||
false,
|
||||
|app: &mut App| {
|
||||
app.review.playback();
|
||||
},
|
||||
))
|
||||
.child(ui::button(p, "rewind", "-10 s", false, |app: &mut App| {
|
||||
let at = app.review.time - 10.0;
|
||||
app.review.seek(at);
|
||||
}))
|
||||
.child(ui::button(p, "advance", "+10 s", false, |app: &mut App| {
|
||||
let at = app.review.time + 10.0;
|
||||
app.review.seek(at);
|
||||
}))
|
||||
.child(
|
||||
text(format!(
|
||||
"{} / {}",
|
||||
format::clock(app.review.time),
|
||||
format::clock(app.review.duration)
|
||||
))
|
||||
.key("time")
|
||||
.font(type_::MONO_CAPTION)
|
||||
.color(p.muted()),
|
||||
.aspect_fit(16.0 / 9.0)
|
||||
.video(player, SurfaceFit::Fill),
|
||||
),
|
||||
None => stage.child(
|
||||
col().key("stage-empty").center().gap(6.0).child(
|
||||
text(
|
||||
app.review
|
||||
.error
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Loading the clip…".into()),
|
||||
)
|
||||
.child(el().grow(1.0))
|
||||
.child(
|
||||
text(
|
||||
app.review.export_note.clone().unwrap_or_else(|| {
|
||||
format!("{} highlights", app.review.highlights.len())
|
||||
}),
|
||||
)
|
||||
.key("export-note")
|
||||
.font(body(11.5))
|
||||
.color(p.muted()),
|
||||
),
|
||||
.key("stage-message")
|
||||
.font(body(13.0))
|
||||
.color(p.muted()),
|
||||
),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Play/pause, the ten-second steps and the clock, with the highlights toggle on the other
|
||||
/// side: the list is one press away, not a column that always takes the clip's width.
|
||||
fn transport(app: &App, p: Paint) -> El {
|
||||
let count = app.review.highlights.len();
|
||||
let bar = row()
|
||||
.key("transport")
|
||||
.w_full()
|
||||
.center_y()
|
||||
.gap(space::S2)
|
||||
.child(ui::button(
|
||||
p,
|
||||
"play-pause",
|
||||
if playing(app) { "Pause" } else { "Play" },
|
||||
false,
|
||||
|app: &mut App| {
|
||||
app.review.playback();
|
||||
},
|
||||
))
|
||||
.child(ui::button(p, "rewind", "-10 s", false, |app: &mut App| {
|
||||
let at = app.review.time - 10.0;
|
||||
app.review.seek(at);
|
||||
}))
|
||||
.child(ui::button(p, "advance", "+10 s", false, |app: &mut App| {
|
||||
let at = app.review.time + 10.0;
|
||||
app.review.seek(at);
|
||||
}))
|
||||
.child(
|
||||
text(format!(
|
||||
"{} / {}",
|
||||
format::clock(app.review.time),
|
||||
format::clock(app.review.duration)
|
||||
))
|
||||
.key("time")
|
||||
.font(type_::MONO_CAPTION)
|
||||
.color(p.muted()),
|
||||
)
|
||||
.child(el().grow(1.0));
|
||||
let bar = match &app.review.export_note {
|
||||
Some(note) => bar.child(
|
||||
text(note.clone())
|
||||
.key("export-note")
|
||||
.font(body(11.5))
|
||||
.color(p.muted()),
|
||||
),
|
||||
None => bar,
|
||||
};
|
||||
bar.child(ui::button(
|
||||
p,
|
||||
"toggle-details",
|
||||
&if app.review.show_details {
|
||||
"Hide details".to_string()
|
||||
} else {
|
||||
format!("Highlights · {count}")
|
||||
},
|
||||
false,
|
||||
|app: &mut App| {
|
||||
app.review.show_details = !app.review.show_details;
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
fn playing(app: &App) -> bool {
|
||||
@@ -551,8 +585,9 @@ fn highlights(app: &App, p: Paint, game: &Timeline) -> El {
|
||||
|
||||
col()
|
||||
.key("highlights-panel")
|
||||
.w(360.0)
|
||||
.h_full()
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.gap(space::S2)
|
||||
.child(
|
||||
text("Highlights")
|
||||
@@ -562,20 +597,20 @@ fn highlights(app: &App, p: Paint, game: &Timeline) -> El {
|
||||
)
|
||||
.child(
|
||||
app.highlights_scroll.follow(
|
||||
"highlight-scroller",
|
||||
col()
|
||||
.key("highlight-scroller")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.scroll(rune::ScrollSpec {
|
||||
stick_bottom: false,
|
||||
})
|
||||
.child(list),
|
||||
.child(list.pr(14.0)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn events(app: &App, p: Paint, game: &Timeline) -> El {
|
||||
fn events(_app: &App, p: Paint, game: &Timeline) -> El {
|
||||
let interesting = |kind: &str| {
|
||||
matches!(
|
||||
kind,
|
||||
@@ -640,9 +675,9 @@ fn events(app: &App, p: Paint, game: &Timeline) -> El {
|
||||
|
||||
col()
|
||||
.key("events-panel")
|
||||
.grow(1.0)
|
||||
.min_w(240.0)
|
||||
.h_full()
|
||||
.w_full()
|
||||
.grow(1.5)
|
||||
.min_h(0.0)
|
||||
.gap(space::S2)
|
||||
.child(
|
||||
text("Timeline")
|
||||
@@ -651,16 +686,16 @@ fn events(app: &App, p: Paint, game: &Timeline) -> El {
|
||||
.color(p.muted()),
|
||||
)
|
||||
.child(
|
||||
app.events_scroll.follow(
|
||||
_app.events_scroll.follow(
|
||||
"event-scroller",
|
||||
col()
|
||||
.key("event-scroller")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
.scroll(rune::ScrollSpec {
|
||||
stick_bottom: false,
|
||||
})
|
||||
.child(list),
|
||||
.child(list.pr(14.0)),
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -222,11 +222,13 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
let kit = rune_kit::Kit::neutral(app.dark);
|
||||
let mut layer = Vec::new();
|
||||
|
||||
// The scroll bar gets its own strip at the end, clear of the cards.
|
||||
let content = col()
|
||||
.key("tab-content")
|
||||
.w_full()
|
||||
.gap(space::S6)
|
||||
.pb(space::S6);
|
||||
.pb(space::S6)
|
||||
.pr(14.0);
|
||||
let content = match app.settings_tab {
|
||||
SettingsTab::General => general(app, p, &kit, &mut layer, content),
|
||||
SettingsTab::Recording => recording(app, p, &kit, &mut layer, content),
|
||||
@@ -288,8 +290,8 @@ pub fn view(app: &App, p: Paint) -> El {
|
||||
.child(tabs(p, app))
|
||||
.child(
|
||||
app.scroll.follow(
|
||||
"scroller",
|
||||
col()
|
||||
.key("scroller")
|
||||
.w_full()
|
||||
.grow(1.0)
|
||||
.min_h(0.0)
|
||||
|
||||
Reference in new issue
Block a user