feat: official sound settings right-slide, player view skins, and UI polish

This commit is contained in:
marwy 2026-11-27 23:32:38 +03:00
parent 5c6a8557b3
commit 8bdb32623f
16 changed files with 850 additions and 203 deletions

View file

@ -849,11 +849,7 @@ pub fn render_fullscreen_player(
"fs_ov_like",
if is_liked { Icon::Liked } else { Icon::Like },
30.0,
if is_liked {
pal.accent_coral
} else {
Color::WHITE
},
Color::WHITE,
i18n.like(),
) {
actions.push(AppAction::ToggleLike(tr.clone()));
@ -3413,8 +3409,8 @@ pub fn render_track_detail_modal(
like_r,
if is_liked { Icon::Liked } else { Icon::Like },
22.0,
if is_liked { pal.accent_coral } else { pal.text_primary },
if is_liked { pal.accent_coral_hover } else { pal.text_bright },
if is_liked { pal.text_bright } else { pal.text_primary },
pal.text_bright,
pal.surface_hover,
false,
i18n.like(),
@ -3710,14 +3706,15 @@ pub fn render_eq_popover(
total_rows_h += rh + 4.0;
}
// Header (16+32+10) + Quality rows + Divider (6+1+14) + EQ header (28) + Bottom pad (18)
let base_h = 58.0 + total_rows_h + 21.0 + 28.0 + 18.0;
let eq_extra_h = 242.0 * expand_t;
// Header (20+32+18) + Quality rows + Gap (20) + EQ header (28) + Bottom pad (22)
let base_h = 70.0 + total_rows_h + 20.0 + 28.0 + 22.0;
let eq_extra_h = 246.0 * expand_t;
let pop_h = (base_h + eq_extra_h).min((screen.height() - PLAYER_BAR_HEIGHT - 56.0).max(280.0));
let slide_dy = (1.0 - alpha) * 12.0;
// Official `Modal` (`placement="right"`, `1372-8bc732062b5d53ca.js`): glides smoothly in from right edge!
let slide_dx = (1.0 - alpha) * 32.0;
let pop_r = Rect::from_xywh(
(screen.right() - pop_w - 20.0).max(16.0),
(screen.bottom() - PLAYER_BAR_HEIGHT - pop_h - 20.0 + slide_dy).max(40.0),
(screen.right() - pop_w - 16.0).max(16.0) + slide_dx,
(screen.bottom() - PLAYER_BAR_HEIGHT - pop_h - 18.0).max(40.0),
pop_w,
pop_h,
);
@ -3737,36 +3734,39 @@ pub fn render_eq_popover(
24.0,
0.0,
Vec2::new(0.0, 6.0),
pal.shadow_menu.with_alpha_f32(alpha),
pal.shadow_menu.scale_alpha(alpha),
);
ctx.dl().push_rect_bordered(
pop_r,
16.0,
pal.bg_popover.with_alpha_f32(alpha),
pal.bg_popover.scale_alpha(alpha),
1.0,
pal.border_subtle.with_alpha_f32(alpha),
pal.border_subtle.scale_alpha(alpha),
);
ctx.push_clip(pop_r, 16.0);
// Header: `"Настройки звука"` + circular Close `×` (`QualitySettings_headerWithCloseButton`)
let hdr_r = Rect::from_xywh(pop_r.left() + 20.0, pop_r.top() + 16.0, pop_w - 40.0, 32.0);
// Header: `"Настройки звука"` + filled circular Close `×` (`radius="round" color="secondary"`)
let hdr_r = Rect::from_xywh(pop_r.left() + 24.0, pop_r.top() + 20.0, pop_w - 48.0, 32.0);
ctx.draw_text_ellipsis(
i18n.sound_settings(),
TextStyle::headline(18.0, pal.text_bright.with_alpha_f32(alpha)),
Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 36.0, hdr_r.height()),
TextStyle::headline(20.0, pal.text_bright.scale_alpha(alpha)),
Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 40.0, hdr_r.height()),
TextAlign::Left,
);
let close_r = Rect::from_xywh(hdr_r.right() - 32.0, hdr_r.top(), 32.0, 32.0);
ctx.dl()
.push_circle(close_r.center(), 16.0, pal.surface_hover.scale_alpha(alpha));
if open
&& icon_button(
ctx,
WidgetId::new("qs_close_btn"),
Rect::from_xywh(hdr_r.right() - 28.0, hdr_r.top() + 2.0, 28.0, 28.0),
close_r,
Icon::Close,
13.0,
pal.text_secondary,
pal.text_bright,
pal.surface_hover,
14.0,
pal.text_bright.scale_alpha(alpha),
pal.text_bright.scale_alpha(alpha),
pal.surface_hover.scale_alpha(alpha),
false,
i18n.close(),
)
@ -3777,7 +3777,7 @@ pub fn render_eq_popover(
}
// 3 Official Quality Options (`QualitySettings_item`)
let mut y = hdr_r.bottom() + 10.0;
let mut y = hdr_r.bottom() + 18.0;
for (idx, (q, title, sub)) in qualities.iter().enumerate() {
let rh = row_heights[idx];
let row_r = Rect::from_xywh(pop_r.left() + 10.0, y, pop_w - 20.0, rh);
@ -3789,20 +3789,20 @@ pub fn render_eq_popover(
let active = app.config.audio_quality == *q;
if resp.hovered {
ctx.dl()
.push_rect(row_r, 10.0, pal.surface_hover.with_alpha_f32(alpha));
.push_rect(row_r, 10.0, pal.surface_hover.scale_alpha(alpha));
ctx.set_cursor(CursorKind::Pointer);
}
let row_txt_x = row_r.left() + 14.0;
let row_txt_w = (row_r.width() - 48.0).max(80.0);
ctx.draw_text_ellipsis(
title,
TextStyle::bold(14.5, pal.text_bright.with_alpha_f32(alpha)),
TextStyle::bold(14.5, pal.text_bright.scale_alpha(alpha)),
Rect::from_xywh(row_txt_x, row_r.top() + 9.0, row_txt_w, 19.0),
TextAlign::Left,
);
ctx.draw_text_wrapped(
sub,
TextStyle::regular(12.0, pal.text_secondary.with_alpha_f32(alpha)),
TextStyle::regular(12.0, pal.text_secondary.scale_alpha(alpha)),
Rect::from_xywh(row_txt_x, row_r.top() + 31.0, row_txt_w, rh - 36.0),
None,
TextAlign::Left,
@ -3814,7 +3814,7 @@ pub fn render_eq_popover(
Pos2::new(row_r.right() - 18.0, row_r.center_y()),
Vec2::splat(16.0),
),
pal.text_bright.with_alpha_f32(alpha),
pal.text_bright.scale_alpha(alpha),
);
}
if resp.clicked && !active {
@ -3823,19 +3823,13 @@ pub fn render_eq_popover(
y += rh + 4.0;
}
// Hairline divider before Equalizer section
y += 6.0;
ctx.dl().push_rect(
Rect::from_xywh(pop_r.left() + 20.0, y, pop_w - 40.0, 1.0),
0.0,
pal.border_subtle.with_alpha_f32(alpha),
);
y += 14.0;
// Clean official vertical spacing before Equalizer section (no extra divider line)
y += 20.0;
// Inline Official Equalizer (`Equalizer_header` + animated expandable Preamp + 10 bands + Presets)
let eq_area = Rect::from_min_max(
Pos2::new(pop_r.left() + 20.0, y),
Pos2::new(pop_r.right() - 20.0, pop_r.bottom() - 16.0),
Pos2::new(pop_r.left() + 24.0, y),
Pos2::new(pop_r.right() - 24.0, pop_r.bottom() - 20.0),
);
let dd_anchor = render_equalizer_body(
ctx,
@ -3914,10 +3908,9 @@ pub fn render_equalizer_modal(
let alpha = anim_t.clamp(0.0, 1.0);
let screen = ctx.screen_rect();
let modal_w = (screen.width() - 48.0).clamp(320.0, 430.0);
let modal_h = 376.0;
let slide_dy = (1.0 - alpha) * 14.0;
let modal_h = 370.0;
let modal_r = Rect::from_center_size(
Pos2::new(screen.center_x(), screen.center_y() + slide_dy),
Pos2::new(screen.center_x(), screen.center_y()),
Vec2::new(modal_w, modal_h),
);
@ -3941,33 +3934,36 @@ pub fn render_equalizer_modal(
32.0,
0.0,
Vec2::new(0.0, 8.0),
pal.shadow_modal.with_alpha_f32(alpha),
pal.shadow_modal.scale_alpha(alpha),
);
ctx.dl().push_rect_bordered(
modal_r,
16.0,
pal.bg_popover.with_alpha_f32(alpha),
pal.bg_popover.scale_alpha(alpha),
1.0,
pal.border_subtle.with_alpha_f32(alpha),
pal.border_subtle.scale_alpha(alpha),
);
let hdr_r = Rect::from_xywh(modal_r.left() + 20.0, modal_r.top() + 18.0, modal_w - 40.0, 32.0);
let hdr_r = Rect::from_xywh(modal_r.left() + 24.0, modal_r.top() + 20.0, modal_w - 48.0, 32.0);
ctx.draw_text_ellipsis(
if ru { "Эквалайзер" } else { "Equalizer" },
TextStyle::headline(20.0, pal.text_bright.with_alpha_f32(alpha)),
Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 36.0, hdr_r.height()),
TextStyle::headline(20.0, pal.text_bright.scale_alpha(alpha)),
Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 40.0, hdr_r.height()),
TextAlign::Left,
);
let eq_close_r = Rect::from_xywh(hdr_r.right() - 32.0, hdr_r.top(), 32.0, 32.0);
ctx.dl()
.push_circle(eq_close_r.center(), 16.0, pal.surface_hover.scale_alpha(alpha));
if open
&& icon_button(
ctx,
WidgetId::new("eq_modal_close"),
Rect::from_xywh(hdr_r.right() - 30.0, hdr_r.top() + 1.0, 30.0, 30.0),
eq_close_r,
Icon::Close,
15.0,
pal.text_secondary,
pal.text_bright,
pal.surface_hover,
14.0,
pal.text_bright.scale_alpha(alpha),
pal.text_bright.scale_alpha(alpha),
pal.surface_hover.scale_alpha(alpha),
false,
i18n.close(),
)
@ -4041,10 +4037,10 @@ pub fn render_equalizer_modal(
}
}
/// Official `EqualizerSlider` (`8711fa44496b8e09.css:340-416`):
/// - Thin `2px` muted vertical track (NO yellow fill from bottom)
/// Official `EqualizerSlider` (`8711fa44496b8e09.css:340-416` + `.d6VuG0HnwpGO47uPjPeb` + `.P8_ABi1YnAOS8p8EY87f`):
/// - Thin `1px` (`0.0625rem`) muted vertical track (NO yellow fill from bottom)
/// - Centered `8×1px` `0 dB` serif tick
/// - Always-visible `14px` hollow dark-filled circular thumb with `1.5px` yellow border (`border_control` when disabled)
/// - Always-visible `13px` (`0.8125rem`) hollow dark-filled circular thumb with `1.5px` yellow border (`border_control` when disabled)
fn eq_vertical_slider(
ctx: &mut UiContext,
pal: &YmPalette,
@ -4066,10 +4062,10 @@ fn eq_vertical_slider(
let bot = rect.bottom() - 7.0;
let track_h = (bot - top).max(20.0);
// Thin 2px muted vertical track
let track_col = pal.border_control.with_alpha_f32(alpha);
// Thin 1.5px muted vertical track (`trackSize_xxs`)
let track_col = pal.border_control.scale_alpha(alpha);
ctx.dl()
.push_rect(Rect::from_xywh(cx - 1.0, top, 2.0, track_h), 1.0, track_col);
.push_rect(Rect::from_xywh(cx - 0.75, top, 1.5, track_h), 0.75, track_col);
// Centered 8×1px horizontal serif tick at midpoint (`EqualizerSlider_serif`)
ctx.dl().push_rect(
@ -4078,19 +4074,25 @@ fn eq_vertical_slider(
track_col,
);
// Hollow circular thumb (`14px` diameter, `1.5px` yellow/muted ring)
// Official circular thumb (`14px` diameter, medium-gray interior + crisp `1.5px` yellow ring)
let frac = norm_val.clamp(0.0, 1.0);
let thumb_y = bot - frac * track_h;
let thumb_r = if active { 7.5 } else { 7.0 };
let border_col = if disabled {
pal.border_control.with_alpha_f32(alpha)
let thumb_fill = if pal.is_dark {
Color::rgb(0x42, 0x42, 0x42)
} else {
pal.yellow.with_alpha_f32(alpha)
Color::rgb(0xE0, 0xE0, 0xE0)
}
.scale_alpha(alpha);
let border_col = if disabled {
pal.border_control.scale_alpha(alpha)
} else {
pal.yellow.scale_alpha(alpha)
};
ctx.dl().push_rect_bordered(
Rect::from_center_size(Pos2::new(cx, thumb_y), Vec2::splat(thumb_r * 2.0)),
thumb_r,
pal.bg_popover.with_alpha_f32(alpha),
thumb_fill,
1.5,
border_col,
);
@ -4114,7 +4116,7 @@ fn eq_vertical_slider(
}
/// Shared official Yandex Music 5.129.0 Equalizer UI (module `31051`, `8711fa44496b8e09.css:136-422`):
/// Header + Toggle -> Expandable (Preamp + `+12dB/0dB/-12dB` labels + 10 frequency bands) -> Full-width Pill Preset Selector.
/// Header + Toggle -> Expandable (Preamp + `12dB/0dB/-12dB` labels + 10 frequency bands) -> Full-width Pill Preset Selector.
#[allow(clippy::too_many_arguments)]
fn render_equalizer_body(
ctx: &mut UiContext,
@ -4133,16 +4135,16 @@ fn render_equalizer_body(
interactive: bool,
salt: &str,
) -> Option<(Rect, bool)> {
// 1. Header row: Title + official Pill Toggle (`44×24`, smoothly animated)
let hdr_r = Rect::from_xywh(area.left(), area.top(), area.width(), 28.0);
// 1. Header row: Title + official Toggle (`32×20px`, `16px` knob, `rqUESGQ8jp3tbDawOzuG`)
let hdr_r = Rect::from_xywh(area.left(), area.top(), area.width(), 24.0);
ctx.draw_text_ellipsis(
toggle_title,
TextStyle::medium(16.0, pal.text_bright.with_alpha_f32(anim_alpha)),
Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 56.0, hdr_r.height()),
TextStyle::medium(16.0, pal.text_bright.scale_alpha(anim_alpha)),
Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 44.0, hdr_r.height()),
TextAlign::Left,
);
let sw_w = 44.0;
let sw_h = 24.0;
let sw_w = 32.0;
let sw_h = 20.0;
let sw_r = Rect::from_xywh(hdr_r.right() - sw_w, hdr_r.center_y() - sw_h * 0.5, sw_w, sw_h);
let sw_id = WidgetId::new(salt).with("toggle");
let sw_resp = if interactive {
@ -4151,16 +4153,18 @@ fn render_equalizer_body(
Default::default()
};
let tog_t = ctx.animate_bool(sw_id.with("anim"), *enabled, 0.16);
let track_col = pal.border_control.lerp(pal.yellow, tog_t).with_alpha_f32(anim_alpha);
let track_col = pal.surface_hover.lerp(pal.yellow, tog_t).scale_alpha(anim_alpha);
ctx.dl().push_rect(sw_r, sw_h * 0.5, track_col);
let knob_x = sw_r.left() + 12.0 + tog_t * (sw_w - 24.0);
let knob_x = sw_r.left() + 10.0 + tog_t * 12.0;
let knob_col = if tog_t > 0.5 {
pal.on_yellow
} else {
} else if sw_resp.hovered {
pal.text_bright
} else {
pal.text_secondary
};
ctx.dl()
.push_circle(Pos2::new(knob_x, sw_r.center_y()), 9.0, knob_col.with_alpha_f32(anim_alpha));
.push_circle(Pos2::new(knob_x, sw_r.center_y()), 8.0, knob_col.scale_alpha(anim_alpha));
if sw_resp.hovered {
ctx.set_cursor(CursorKind::Pointer);
}
@ -4177,7 +4181,7 @@ fn render_equalizer_body(
}
let content_alpha = (anim_alpha * expand_t).clamp(0.0, 1.0);
let clip_h = (242.0 * expand_t).max(0.0);
let clip_h = (246.0 * expand_t).max(0.0);
ctx.push_clip(
Rect::from_xywh(area.left() - 4.0, hdr_r.bottom(), area.width() + 8.0, clip_h),
0.0,
@ -4190,7 +4194,7 @@ fn render_equalizer_body(
} else {
pal.text_secondary
}
.with_alpha_f32(content_alpha);
.scale_alpha(content_alpha);
// 2. Left Preamp column (`Equalizer_preamp`) + amp labels (`12dB / 0dB / -12dB`)
let preamp_w = 42.0;
@ -4282,9 +4286,9 @@ fn render_equalizer_body(
);
}
// 4. Full-width Pill Preset Selector BELOW sliders (`EqualizerPresets_button`, `radius = h/2`)
let sel_y = y + sliders_h + 8.0 + 16.0 + 16.0;
let sel_h = 42.0;
// 4. Full-width Outlined Pill Preset Selector BELOW sliders (`EqualizerPresets_button`, `radius = h/2`)
let sel_y = y + sliders_h + 8.0 + 16.0 + 18.0;
let sel_h = 44.0;
let sel_r = Rect::from_xywh(area.left(), sel_y, area.width(), sel_h);
let sel_resp = if !is_disabled && interactive && expand_t > 0.85 {
ctx.interact(WidgetId::new(salt).with("preset_sel"), sel_r)
@ -4292,23 +4296,28 @@ fn render_equalizer_body(
Default::default()
};
let sel_bg = if sel_resp.hovered {
pal.surface_hover
pal.surface_hover.scale_alpha(content_alpha)
} else {
pal.surface_secondary
}
.with_alpha_f32(content_alpha);
ctx.dl().push_rect(sel_r, sel_h * 0.5, sel_bg);
Color::TRANSPARENT
};
let sel_border = if is_disabled {
pal.border_subtle.scale_alpha(content_alpha)
} else {
pal.border_control.scale_alpha(content_alpha)
};
ctx.dl()
.push_rect_bordered(sel_r, sel_h * 0.5, sel_bg, 1.0, sel_border);
let preset_lbl = active_eq_preset_name(bands, ru);
let label_col = if is_disabled {
pal.text_disabled
} else {
pal.text_bright
}
.with_alpha_f32(content_alpha);
.scale_alpha(content_alpha);
ctx.draw_text_ellipsis(
preset_lbl,
TextStyle::medium(13.5, label_col),
Rect::from_xywh(sel_r.left() + 18.0, sel_r.top(), sel_r.width() - 48.0, sel_r.height()),
TextStyle::bold(13.5, label_col),
Rect::from_xywh(sel_r.left() + 18.0, sel_r.top(), sel_r.width() - 46.0, sel_r.height()),
TextAlign::Left,
);
ctx.draw_icon(
@ -4319,7 +4328,7 @@ fn render_equalizer_body(
} else {
pal.text_bright
}
.with_alpha_f32(content_alpha),
.scale_alpha(content_alpha),
);
if sel_resp.hovered {
ctx.set_cursor(CursorKind::Pointer);
@ -4451,20 +4460,20 @@ pub fn render_shortcuts_modal(
32.0,
0.0,
Vec2::new(0.0, 8.0),
pal.shadow_modal.with_alpha_f32(alpha),
pal.shadow_modal.scale_alpha(alpha),
);
ctx.dl().push_rect_bordered(
modal_r,
16.0,
pal.bg_popover.with_alpha_f32(alpha),
pal.bg_popover.scale_alpha(alpha),
1.0,
pal.border_subtle.with_alpha_f32(alpha),
pal.border_subtle.scale_alpha(alpha),
);
let hdr_r = Rect::from_xywh(modal_r.left() + 20.0, modal_r.top() + 18.0, modal_w - 40.0, 32.0);
ctx.draw_text_ellipsis(
if ru { "Горячие клавиши" } else { "Hot keys" },
TextStyle::headline(20.0, pal.text_bright.with_alpha_f32(alpha)),
TextStyle::headline(20.0, pal.text_bright.scale_alpha(alpha)),
Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 36.0, hdr_r.height()),
TextAlign::Left,
);
@ -4794,21 +4803,21 @@ pub fn render_release_notes_modal(
32.0,
0.0,
Vec2::new(0.0, 8.0),
pal.shadow_modal.with_alpha_f32(alpha),
pal.shadow_modal.scale_alpha(alpha),
);
ctx.dl().push_rect_bordered(
modal_r,
16.0,
pal.bg_popover.with_alpha_f32(alpha),
pal.bg_popover.scale_alpha(alpha),
1.0,
pal.border_subtle.with_alpha_f32(alpha),
pal.border_subtle.scale_alpha(alpha),
);
// Header (`padding: 16px`, title + circular close ×)
let hdr_r = Rect::from_xywh(modal_r.left() + 20.0, modal_r.top() + 14.0, modal_w - 40.0, 34.0);
ctx.draw_text_ellipsis(
i18n.whats_new(),
TextStyle::headline(20.0, pal.text_bright.with_alpha_f32(alpha)),
TextStyle::headline(20.0, pal.text_bright.scale_alpha(alpha)),
Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 36.0, hdr_r.height()),
TextAlign::Left,
);