feat: official crossfade, concurrent downloads, changelog, and 1-to-1 settings/EQ
This commit is contained in:
parent
ee65d23b2a
commit
41c30f9c35
22 changed files with 3572 additions and 864 deletions
|
|
@ -512,6 +512,8 @@ pub struct TrackRowOptions {
|
|||
pub is_liked: bool,
|
||||
pub is_disliked: bool,
|
||||
pub is_downloaded: bool,
|
||||
pub is_downloading: bool,
|
||||
pub download_progress: f32,
|
||||
pub menu_open: bool,
|
||||
}
|
||||
|
||||
|
|
@ -526,6 +528,8 @@ impl Default for TrackRowOptions {
|
|||
is_liked: false,
|
||||
is_disliked: false,
|
||||
is_downloaded: false,
|
||||
is_downloading: false,
|
||||
download_progress: 0.0,
|
||||
menu_open: false,
|
||||
}
|
||||
}
|
||||
|
|
@ -694,8 +698,13 @@ pub fn track_row(
|
|||
pal.text_secondary
|
||||
};
|
||||
|
||||
// Title + optional version + explicit badge + downloaded badge
|
||||
let badge_w = if track.is_explicit { 22.0 } else { 0.0 } + if opts.is_downloaded { 20.0 } else { 0.0 };
|
||||
// Title + optional version + explicit badge + downloaded/downloading badge
|
||||
let badge_w = if track.is_explicit { 22.0 } else { 0.0 }
|
||||
+ if opts.is_downloaded || opts.is_downloading {
|
||||
20.0
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let title_rect = Rect::from_xywh(x, rect.top() + 9.5, (title_col_w - badge_w).max(40.0), 20.0);
|
||||
let version_text = track
|
||||
.version
|
||||
|
|
@ -729,7 +738,17 @@ pub fn track_row(
|
|||
);
|
||||
badge_x += 22.0;
|
||||
}
|
||||
if opts.is_downloaded {
|
||||
if opts.is_downloading {
|
||||
draw_downloading_progress(
|
||||
ctx,
|
||||
pal,
|
||||
Pos2::new(badge_x + 8.0, title_rect.center_y()),
|
||||
16.0,
|
||||
opts.download_progress,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
} else if opts.is_downloaded {
|
||||
ctx.draw_icon(
|
||||
Icon::Downloaded,
|
||||
Rect::from_center_size(Pos2::new(badge_x + 8.0, title_rect.center_y()), Vec2::splat(16.0)),
|
||||
|
|
@ -1799,3 +1818,76 @@ pub fn draw_playing_eq_bars(
|
|||
ctx.request_repaint_after(std::time::Duration::from_millis(40));
|
||||
}
|
||||
}
|
||||
|
||||
/// Smooth circular progress ring matching official Yandex Music 5.129.0 `CircleProgress` (`68254`).
|
||||
pub fn draw_circular_progress_ring(
|
||||
ctx: &mut UiContext,
|
||||
center: Pos2,
|
||||
radius: f32,
|
||||
stroke_w: f32,
|
||||
progress: f32,
|
||||
track_color: Color,
|
||||
progress_color: Color,
|
||||
) {
|
||||
use std::f32::consts::{FRAC_PI_2, TAU};
|
||||
|
||||
ctx.dl()
|
||||
.push_circle_stroke(center, radius, stroke_w, track_color);
|
||||
|
||||
let frac = progress.clamp(0.0, 1.0);
|
||||
let (start_angle, sweep) = if frac < 0.03 {
|
||||
if ctx.input.time > 0.001 {
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(24));
|
||||
}
|
||||
((ctx.input.time as f32 * 3.2) - FRAC_PI_2, 0.24 * TAU)
|
||||
} else {
|
||||
(-FRAC_PI_2, frac * TAU)
|
||||
};
|
||||
|
||||
let segments = ((sweep / TAU) * 32.0).ceil().max(4.0) as usize;
|
||||
let step = sweep / segments as f32;
|
||||
for i in 0..segments {
|
||||
let a0 = start_angle + i as f32 * step;
|
||||
let a1 = start_angle + (i + 1) as f32 * step;
|
||||
let p0 = Pos2::new(center.x + radius * a0.cos(), center.y + radius * a0.sin());
|
||||
let p1 = Pos2::new(center.x + radius * a1.cos(), center.y + radius * a1.sin());
|
||||
ctx.dl().push_line(p0, p1, stroke_w, progress_color);
|
||||
}
|
||||
}
|
||||
|
||||
/// Official Yandex Music 5.129.0 `DownloadingProgress` (`79262` / `63298c27abf81dc6.css:210-218`):
|
||||
/// yellow circular progress ring with optional centered `close` (`×`) cancel icon.
|
||||
pub fn draw_downloading_progress(
|
||||
ctx: &mut UiContext,
|
||||
pal: &YmPalette,
|
||||
center: Pos2,
|
||||
size: f32,
|
||||
progress: f32,
|
||||
with_cancel_icon: bool,
|
||||
hovered: bool,
|
||||
) {
|
||||
let stroke_w = if size >= 22.0 { 2.2 } else { 1.8 };
|
||||
let radius = ((size - stroke_w) * 0.5).max(3.0);
|
||||
draw_circular_progress_ring(
|
||||
ctx,
|
||||
center,
|
||||
radius,
|
||||
stroke_w,
|
||||
progress,
|
||||
pal.border_control,
|
||||
pal.yellow,
|
||||
);
|
||||
if with_cancel_icon {
|
||||
let icon_sz = (size * 0.42).clamp(8.0, 12.0);
|
||||
let tint = if hovered {
|
||||
pal.text_bright
|
||||
} else {
|
||||
pal.text_primary
|
||||
};
|
||||
ctx.draw_icon(
|
||||
Icon::Close,
|
||||
Rect::from_center_size(center, Vec2::splat(icon_sz)),
|
||||
tint,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue