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
+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)),
|
||||
),
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user