yandex-music-rs/src/views/settings.rs

807 lines
27 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use crate::app::i18n::APP_VERSION;
use crate::app::state::{AppAction, AppState};
use crate::audio::dsp::{EQ_LABELS, EQ_PRESETS};
use crate::config::{AudioQuality, Language, ThemeMode};
use crate::covers::CoverCache;
use crate::engine::input::WidgetId;
use crate::engine::text::{TextAlign, TextStyle};
use crate::engine::theme::YmPalette;
use crate::engine::types::{CursorKind, Pos2, Rect};
use crate::engine::widgets::{
secondary_pill_button, text_input_widget, yellow_pill_button, ym_slider, ym_vertical_slider,
TextInputOptions,
};
use crate::engine::UiContext;
use crate::icons::Icon;
use crate::views::overlays::ShellUiState;
/// Authentic Yandex Music Desktop 5.129.0 Settings Page:
/// - Account (Yandex ID / OAuth)
/// - Appearance & Language (3-way System / Dark / Light theme selector + RU/EN + Close to tray)
/// - Sound (Audio quality, Loudness normalization, Crossfade)
/// - 10-band Equalizer (Enable, Presets, 10 vertical band sliders)
/// - Recommendations & Content (Less AI, Show Kids section)
/// - Keyboard shortcuts
/// - About 5.129.0 (Update check & Clear cover cache)
/// 100% `YmPalette` theme-aware & 100% localized RU/EN!
pub fn render_settings(
ctx: &mut UiContext,
pal: &YmPalette,
covers: &mut CoverCache,
app: &mut AppState,
_shell: &mut ShellUiState,
rect: Rect,
actions: &mut Vec<AppAction>,
) {
let t = app.i18n();
let ru = t.is_ru();
let scroll_id = WidgetId::new("settings_scroll");
let scroll_y = ctx.begin_scroll_v(scroll_id, rect, 0.0);
// `views/mod.rs` already insets `inner_r` by (25, 13, 25, 0)
let content_x = rect.left();
let content_w = (rect.width() - 8.0).clamp(320.0, 960.0);
let mut y = rect.top() + 8.0 - scroll_y;
// Page Heading
ctx.draw_text_ellipsis(
t.settings(),
TextStyle::headline(34.0, pal.text_bright),
Rect::from_xywh(content_x, y, content_w, 42.0),
TextAlign::Left,
);
y += 58.0;
// -------------------------------------------------------------------------
// 1. Account (Yandex ID)
// -------------------------------------------------------------------------
let acc_h = if app.account.is_some() { 112.0 } else { 196.0 };
let acc_inner = draw_settings_card(
ctx,
pal,
Rect::from_xywh(content_x, y, content_w, acc_h),
if ru {
"Аккаунт Яндекс ID"
} else {
"Yandex ID Account"
},
);
if let Some(ref acc) = app.account {
let sign_out_lbl = t.sign_out();
let measured_w = ctx
.measure_text(sign_out_lbl, TextStyle::bold(14.0, pal.text_primary), None)
.x;
let btn_w = (measured_w + 54.0).max(112.0).ceil();
let text_w = (acc_inner.width() - btn_w - 16.0).max(120.0);
let row_y = acc_inner.top();
ctx.draw_text_ellipsis(
&acc.display_name,
TextStyle::bold(16.0, pal.text_bright),
Rect::from_xywh(acc_inner.left(), row_y, text_w, 22.0),
TextAlign::Left,
);
let plan = if acc.has_plus {
if ru {
"Яндекс Плюс активен"
} else {
"Yandex Plus active"
}
} else if ru {
"Базовый тариф"
} else {
"Free plan"
};
let meta = format!("@{} · UID {} · {}", acc.login, acc.uid, plan);
ctx.draw_text_ellipsis(
&meta,
TextStyle::regular(13.0, pal.text_secondary),
Rect::from_xywh(acc_inner.left(), row_y + 24.0, text_w, 20.0),
TextAlign::Left,
);
let logout_r = Rect::from_xywh(acc_inner.right() - btn_w, row_y + 4.0, btn_w, 38.0);
let resp = crate::engine::widgets::secondary_pill_button_in(
ctx,
pal,
WidgetId::new("set_logout"),
logout_r,
Some(Icon::ProfileLogoutXxs),
sign_out_lbl,
false,
);
if resp.clicked {
actions.push(AppAction::Logout);
}
} else {
let mut cy = acc_inner.top();
ctx.draw_text_wrapped(
if ru {
"Войдите через Яндекс ID, чтобы слушать свою коллекцию, «Мою волну» и Lossless FLAC."
} else {
"Sign in with Yandex ID to access your collection, My Vibe, and Lossless FLAC."
},
TextStyle::regular(13.5, pal.text_secondary),
Rect::from_xywh(acc_inner.left(), cy, acc_inner.width(), 36.0),
Some(2),
TextAlign::Left,
);
cy += 36.0;
let (oauth_resp, _) = yellow_pill_button(
ctx,
pal,
WidgetId::new("set_oauth_btn"),
Pos2::new(acc_inner.left(), cy),
Some(Icon::Plus),
if ru {
"Войти через Яндекс ID"
} else {
"Sign in with Yandex ID"
},
38.0,
false,
);
if oauth_resp.clicked {
actions.push(AppAction::OpenOAuthBrowser);
}
cy += 50.0;
let input_w = (acc_inner.width() - 130.0).clamp(180.0, 420.0);
let input_r = Rect::from_xywh(acc_inner.left(), cy, input_w, 38.0);
let mut token_copy = app.token_input.clone();
let ti = text_input_widget(
ctx,
pal,
WidgetId::new("set_token_input"),
input_r,
&mut token_copy,
TextInputOptions {
placeholder: if ru {
"Вставьте OAuth-токен (y0_...) или URL"
} else {
"Paste OAuth token (y0_...) or redirect URL"
},
leading_icon: None,
show_clear_button: true,
hide_placeholder_when_unfocused: false,
transparent_bg: false,
font_size: 13.5,
pill: true,
},
);
if ti.changed {
app.token_input = token_copy.clone();
}
let (sub_resp, _) = secondary_pill_button(
ctx,
pal,
WidgetId::new("set_token_submit"),
Pos2::new(input_r.right() + 10.0, cy),
Some(Icon::CheckXxs),
t.log_in(),
38.0,
!token_copy.trim().is_empty(),
);
if (sub_resp.clicked || ti.submitted) && !token_copy.trim().is_empty() {
actions.push(AppAction::SubmitOAuthToken(token_copy));
}
}
y += acc_h + 14.0;
// -------------------------------------------------------------------------
// 2. Appearance & Language (3-way System / Dark / Light + RU/EN + Tray)
// -------------------------------------------------------------------------
let app_h = 204.0;
let app_inner = draw_settings_card(
ctx,
pal,
Rect::from_xywh(content_x, y, content_w, app_h),
if ru {
"Оформление и интерфейс"
} else {
"Appearance & Language"
},
);
{
let mut cy = app_inner.top();
ctx.draw_text_ellipsis(
t.appearance(),
TextStyle::medium(13.0, pal.text_secondary),
Rect::from_xywh(app_inner.left(), cy, app_inner.width(), 18.0),
TextAlign::Left,
);
cy += 24.0;
let mut tx = app_inner.left();
for (mode, icon, label) in [
(ThemeMode::System, Icon::ThemeSystemXxs, t.theme_system()),
(ThemeMode::Dark, Icon::ThemeDarkXxs, t.theme_dark()),
(ThemeMode::Light, Icon::ThemeLightXxs, t.theme_light()),
] {
let (resp, r) = secondary_pill_button(
ctx,
pal,
WidgetId::from_pair("set_theme", mode as u8),
Pos2::new(tx, cy),
Some(icon),
label,
38.0,
app.config.theme == mode,
);
if resp.clicked {
actions.push(AppAction::SetTheme(mode));
}
tx = r.right() + 10.0;
}
cy += 50.0;
// Language selector
let mut lx = app_inner.left();
for (lang, label) in [(Language::Ru, "Русский"), (Language::En, "English")] {
let (resp, r) = secondary_pill_button(
ctx,
pal,
WidgetId::from_pair("set_lang", lang as u8),
Pos2::new(lx, cy),
Some(Icon::ProfileGlobeXxs),
label,
36.0,
app.config.language == lang,
);
if resp.clicked {
actions.push(AppAction::SetLanguage(lang));
}
lx = r.right() + 10.0;
}
cy += 48.0;
// Close to tray toggle
if let Some(next) = settings_toggle_row(
ctx,
pal,
WidgetId::new("set_close_to_tray"),
Rect::from_xywh(app_inner.left(), cy, app_inner.width(), 32.0),
if ru {
"Сворачивать в системный трей при закрытии окна"
} else {
"Minimize to system tray on close"
},
app.config.close_to_tray,
) {
actions.push(AppAction::SetCloseToTray(next));
}
}
y += app_h + 14.0;
// -------------------------------------------------------------------------
// 3. Sound (Audio quality, Loudness normalization, Crossfade)
// -------------------------------------------------------------------------
let sound_inner_w = (content_w - 36.0).max(100.0);
let mut q_rows = 1usize;
let mut sim_qx = 0.0_f32;
for q in [
AudioQuality::Lossless,
AudioQuality::High,
AudioQuality::Standard,
] {
let lbl = q.label_for(app.config.language);
let btn_w = (ctx
.measure_text(lbl, TextStyle::bold(14.0, pal.text_primary), None)
.x
+ 36.0)
.min(260.0);
if sim_qx + btn_w > sound_inner_w && sim_qx > 0.0 {
q_rows += 1;
sim_qx = 0.0;
}
sim_qx += btn_w + 8.0;
}
let sound_h = 196.0 + (q_rows.saturating_sub(1) as f32) * 44.0;
let sound_inner = draw_settings_card(
ctx,
pal,
Rect::from_xywh(content_x, y, content_w, sound_h),
if ru { "Звук" } else { "Sound" },
);
{
let mut cy = sound_inner.top();
ctx.draw_text_ellipsis(
if ru {
"Качество звука"
} else {
"Audio quality"
},
TextStyle::medium(13.0, pal.text_secondary),
Rect::from_xywh(sound_inner.left(), cy, sound_inner.width(), 18.0),
TextAlign::Left,
);
cy += 24.0;
let mut qx = sound_inner.left();
for q in [
AudioQuality::Lossless,
AudioQuality::High,
AudioQuality::Standard,
] {
let lbl = q.label_for(app.config.language);
let measured = ctx
.measure_text(lbl, TextStyle::bold(14.0, pal.text_primary), None)
.x
+ 36.0;
let btn_w = measured.min(260.0);
if qx + btn_w > sound_inner.right() && qx > sound_inner.left() {
qx = sound_inner.left();
cy += 44.0;
}
let r = Rect::from_xywh(qx, cy, btn_w, 38.0);
let resp = crate::engine::widgets::secondary_pill_button_in(
ctx,
pal,
WidgetId::from_pair("set_quality", q as u8),
r,
None,
lbl,
app.config.audio_quality == q,
);
if resp.clicked {
actions.push(AppAction::SetAudioQuality(q));
}
qx = r.right() + 8.0;
}
cy += 50.0;
if let Some(next) = settings_toggle_row(
ctx,
pal,
WidgetId::new("set_loudness"),
Rect::from_xywh(sound_inner.left(), cy, sound_inner.width(), 32.0),
if ru {
"Выравнивание громкости (EBU R128)"
} else {
"Loudness normalization (EBU R128)"
},
app.config.normalize_loudness,
) {
actions.push(AppAction::SetNormalizeLoudness(next));
}
cy += 40.0;
let cf_label = if ru {
format!("Плавные переходы между треками: {:.0} с", app.config.crossfade_secs)
} else {
format!("Crossfade between tracks: {:.0} s", app.config.crossfade_secs)
};
ctx.draw_text_ellipsis(
&cf_label,
TextStyle::regular(14.0, pal.text_primary),
Rect::from_xywh(sound_inner.left(), cy, 310.0, 26.0),
TextAlign::Left,
);
let slider_r = Rect::from_xywh(
sound_inner.left() + 320.0,
cy,
(sound_inner.width() - 330.0).clamp(120.0, 280.0),
26.0,
);
let sr = ym_slider(
ctx,
pal,
WidgetId::new("set_crossfade_slider"),
slider_r,
(app.config.crossfade_secs / 12.0).clamp(0.0, 1.0),
0.0,
true,
true,
);
if let Some(v) = sr.value {
let secs = (v * 12.0).round();
if (secs - app.config.crossfade_secs).abs() >= 0.5 {
actions.push(AppAction::SetCrossfadeSecs(secs));
}
}
}
y += sound_h + 14.0;
// -------------------------------------------------------------------------
// 4. 10-Band Equalizer (dynamic height so wrapped EQ presets never clip or break)
// -------------------------------------------------------------------------
let eq_inner_w = (content_w - 36.0).max(100.0);
let mut eq_preset_rows = 1usize;
let mut sim_px = 0.0_f32;
for preset in EQ_PRESETS.iter() {
let pw = (ctx
.measure_text(preset.name, TextStyle::bold(14.0, pal.text_primary), None)
.x
+ 32.0)
.max(54.0);
if sim_px + pw > eq_inner_w && sim_px > 0.0 {
eq_preset_rows += 1;
sim_px = 0.0;
}
sim_px += pw + 6.0;
}
let eq_h = 266.0 + (eq_preset_rows.saturating_sub(1) as f32) * 38.0;
let eq_inner = draw_settings_card(
ctx,
pal,
Rect::from_xywh(content_x, y, content_w, eq_h),
if ru { "Эквалайзер" } else { "Equalizer" },
);
{
let mut enabled = app.config.eq_enabled;
let mut bands = app.config.eq_bands_db;
let mut changed = false;
let mut cy = eq_inner.top();
if let Some(next) = settings_toggle_row(
ctx,
pal,
WidgetId::new("set_eq_enable"),
Rect::from_xywh(eq_inner.left(), cy, eq_inner.width(), 30.0),
if ru {
"Включить 10-полосный эквалайзер"
} else {
"Enable 10-band equalizer"
},
enabled,
) {
enabled = next;
changed = true;
}
cy += 38.0;
// Presets rows (wrap cleanly across multiple lines — NO truncation!)
let mut px = eq_inner.left();
for (idx, preset) in EQ_PRESETS.iter().enumerate() {
let pw = (ctx
.measure_text(preset.name, TextStyle::bold(14.0, pal.text_primary), None)
.x
+ 32.0)
.max(54.0);
if px + pw > eq_inner.right() && px > eq_inner.left() {
px = eq_inner.left();
cy += 38.0;
}
let is_match = enabled
&& bands
.iter()
.zip(preset.gains.iter())
.all(|(a, b)| (a - b).abs() < 0.2);
let r = Rect::from_xywh(px, cy, pw, 30.0);
let resp = crate::engine::widgets::secondary_pill_button_in(
ctx,
pal,
WidgetId::from_pair("set_eq_preset", idx),
r,
None,
preset.name,
is_match,
);
if resp.clicked {
enabled = true;
bands = preset.gains;
changed = true;
}
px = r.right() + 6.0;
}
cy += 42.0;
// 10 vertical band sliders
let col_w = (eq_inner.width() / 10.0).min(64.0);
for i in 0..10 {
let bx = eq_inner.left() + i as f32 * col_w;
ctx.draw_text_ellipsis(
&format!("{:+.0}", bands[i]),
TextStyle::regular(11.5, pal.text_secondary),
Rect::from_xywh(bx, cy, col_w, 16.0),
TextAlign::Center,
);
let sl_r = Rect::from_xywh(bx + col_w * 0.5 - 14.0, cy + 20.0, 28.0, 96.0);
let norm = ((bands[i] + 12.0) / 24.0).clamp(0.0, 1.0);
let sr = ym_vertical_slider(
ctx,
pal,
WidgetId::from_pair("set_eq_band", i),
sl_r,
norm,
false,
if enabled { pal.yellow } else { pal.text_primary },
);
if let Some(v) = sr.value {
let db = ((v * 24.0) - 12.0).round().clamp(-12.0, 12.0);
if (db - bands[i]).abs() >= 0.5 {
bands[i] = db;
enabled = true;
changed = true;
}
}
ctx.draw_text_ellipsis(
EQ_LABELS[i],
TextStyle::bold(11.5, pal.text_primary),
Rect::from_xywh(bx, cy + 120.0, col_w, 16.0),
TextAlign::Center,
);
}
if changed {
actions.push(AppAction::UpdateEq { enabled, bands });
}
}
y += eq_h + 14.0;
// -------------------------------------------------------------------------
// 5. Recommendations & Content (Less AI, Kids toggle)
// -------------------------------------------------------------------------
let rec_h = 132.0;
let rec_inner = draw_settings_card(
ctx,
pal,
Rect::from_xywh(content_x, y, content_w, rec_h),
if ru {
"Рекомендации и разделы"
} else {
"Recommendations & Content"
},
);
{
let mut cy = rec_inner.top();
if let Some(next) = settings_toggle_row(
ctx,
pal,
WidgetId::new("set_ai_red"),
Rect::from_xywh(rec_inner.left(), cy, rec_inner.width(), 32.0),
if ru {
"Меньше ИИ — реже показывать музыку, созданную с помощью ИИ"
} else {
"Less AI — reduce AI-generated music in recommendations"
},
app.config.ai_content_reduction,
) {
actions.push(AppAction::SetAiContentReduction(next));
}
cy += 40.0;
if let Some(next) = settings_toggle_row(
ctx,
pal,
WidgetId::new("set_child_mode"),
Rect::from_xywh(rec_inner.left(), cy, rec_inner.width(), 32.0),
if ru {
"Показывать раздел «Детям»"
} else {
"Show «For Kids» section"
},
app.config.child_mode,
) {
actions.push(AppAction::SetChildMode(next));
}
}
y += rec_h + 14.0;
// -------------------------------------------------------------------------
// 6. Keyboard Shortcuts
// -------------------------------------------------------------------------
let shortcuts: &[(&str, &str, &str)] = &[
("Space / K", "Пауза / Воспроизведение", "Play / Pause"),
("N / P", "Следующий / Предыдущий трек", "Next / Previous track"),
("← / → (J / L)", "Перемотка ±2 сек", "Seek ±2 sec"),
("↑ / ↓", "Громкость ±5%", "Volume ±5%"),
("M", "Выключить / включить звук", "Mute / Unmute"),
("F / D", "Нравится / Не нравится", "Like / Dislike"),
("R / S", "Повтор / Перемешать", "Repeat / Shuffle"),
("W", "Полноэкранный плеер", "Fullscreen player"),
("Ctrl + F / Ctrl + L", "Поиск / Текст песни", "Search / Lyrics"),
];
let sc_h = 62.0 + shortcuts.len() as f32 * 26.0;
let sc_inner = draw_settings_card(
ctx,
pal,
Rect::from_xywh(content_x, y, content_w, sc_h),
if ru {
"Горячие клавиши"
} else {
"Keyboard shortcuts"
},
);
{
let mut cy = sc_inner.top();
for (keys, desc_ru, desc_en) in shortcuts {
ctx.draw_text_ellipsis(
keys,
TextStyle::bold(13.0, pal.text_bright),
Rect::from_xywh(sc_inner.left(), cy, 175.0, 22.0),
TextAlign::Left,
);
ctx.draw_text_ellipsis(
if ru { *desc_ru } else { *desc_en },
TextStyle::regular(13.0, pal.text_secondary),
Rect::from_xywh(sc_inner.left() + 185.0, cy, sc_inner.width() - 185.0, 22.0),
TextAlign::Left,
);
cy += 26.0;
}
}
y += sc_h + 14.0;
// -------------------------------------------------------------------------
// 7. About & Updates (`git.tatar/marwy/yandex-music-rs`) & Cache
// -------------------------------------------------------------------------
let about_h = 172.0;
let about_inner = draw_settings_card(
ctx,
pal,
Rect::from_xywh(content_x, y, content_w, about_h),
if ru { "О приложении" } else { "About" },
);
{
let mut cy = about_inner.top();
let ver_str = if ru {
format!("yandex-music-rs · Версия {}", APP_VERSION)
} else {
format!("yandex-music-rs · Version {}", APP_VERSION)
};
ctx.draw_text_ellipsis(
&ver_str,
TextStyle::medium(14.0, pal.text_primary),
Rect::from_xywh(about_inner.left(), cy, about_inner.width(), 22.0),
TextAlign::Left,
);
cy += 24.0;
let repo_label = "git.tatar/marwy/yandex-music-rs";
let repo_w = ctx
.measure_text(repo_label, TextStyle::medium(13.0, pal.text_secondary), None)
.x
+ 8.0;
let repo_r = Rect::from_xywh(about_inner.left(), cy, repo_w.min(about_inner.width()), 20.0);
let repo_resp = ctx.interact(WidgetId::new("set_repo_link"), repo_r);
ctx.draw_text_ellipsis(
repo_label,
TextStyle::medium(
13.0,
if repo_resp.hovered {
pal.text_bright
} else if pal.is_dark {
pal.yellow
} else {
pal.outline_selected
},
),
repo_r,
TextAlign::Left,
);
if repo_resp.hovered {
ctx.set_cursor(CursorKind::Pointer);
}
if repo_resp.clicked {
actions.push(AppAction::OpenUrl(
"https://git.tatar/marwy/yandex-music-rs".into(),
));
}
cy += 22.0;
let cache_str = if ru {
format!("Кэш обложек: {} шт.", covers.len())
} else {
format!("Cover cache: {} items", covers.len())
};
ctx.draw_text_ellipsis(
&cache_str,
TextStyle::regular(12.5, pal.text_secondary),
Rect::from_xywh(about_inner.left(), cy, about_inner.width(), 20.0),
TextAlign::Left,
);
cy += 28.0;
let upd_label = if let Some((ref new_ver, _)) = app.available_update {
if ru {
format!("Обновить до {}", new_ver)
} else {
format!("Update to {}", new_ver)
}
} else if ru {
"Проверить обновления".to_string()
} else {
"Check for updates".to_string()
};
let (upd_resp, upd_r) = secondary_pill_button(
ctx,
pal,
WidgetId::new("set_check_updates"),
Pos2::new(about_inner.left(), cy),
None,
&upd_label,
36.0,
app.available_update.is_some(),
);
if upd_resp.clicked {
actions.push(AppAction::CheckForUpdates);
}
let (clr_resp, _) = secondary_pill_button(
ctx,
pal,
WidgetId::new("set_clear_cache"),
Pos2::new(upd_r.right() + 10.0, cy),
None,
if ru {
"Очистить кэш обложек"
} else {
"Clear cover cache"
},
36.0,
false,
);
if clr_resp.clicked {
actions.push(AppAction::ClearCoverCache);
}
}
y += about_h + 28.0;
let total_content_h = y - (rect.top() - scroll_y);
ctx.end_scroll_v(scroll_id, pal, total_content_h, true);
}
/// Renders a theme-aware settings section card and returns its inner body `Rect` below the heading.
fn draw_settings_card(ctx: &mut UiContext, pal: &YmPalette, rect: Rect, heading: &str) -> Rect {
ctx.dl()
.push_rect_bordered(rect, 14.0, pal.surface_secondary, 1.0, pal.border_subtle);
let inner_x = rect.left() + 18.0;
let inner_w = (rect.width() - 36.0).max(100.0);
ctx.draw_text_ellipsis(
heading,
TextStyle::bold(16.0, pal.text_bright),
Rect::from_xywh(inner_x, rect.top() + 16.0, inner_w, 22.0),
TextAlign::Left,
);
Rect::from_xywh(
inner_x,
rect.top() + 46.0,
inner_w,
(rect.height() - 62.0).max(0.0),
)
}
/// Interactive pill toggle switch row (100% theme-aware). Returns `Some(new_val)` when toggled.
fn settings_toggle_row(
ctx: &mut UiContext,
pal: &YmPalette,
id: WidgetId,
rect: Rect,
label: &str,
checked: bool,
) -> Option<bool> {
let resp = ctx.interact(id, rect);
let anim = ctx.animate_bool(id.with("tog"), checked, 0.18);
ctx.draw_text_ellipsis(
label,
TextStyle::regular(14.0, pal.text_primary),
Rect::from_xywh(rect.left(), rect.top(), (rect.width() - 56.0).max(40.0), rect.height()),
TextAlign::Left,
);
let sw_w = 42.0;
let sw_h = 24.0;
let sw_r = Rect::from_xywh(
rect.right() - sw_w,
rect.center_y() - sw_h * 0.5,
sw_w,
sw_h,
);
let track_col = pal.border_control.lerp(pal.yellow, anim);
ctx.dl().push_rect(sw_r, sw_h * 0.5, track_col);
let knob_x = sw_r.left() + 12.0 + anim * (sw_w - 24.0);
let knob_col = if anim > 0.5 {
pal.on_yellow
} else {
pal.text_bright
};
ctx.dl()
.push_circle(Pos2::new(knob_x, sw_r.center_y()), 8.5, knob_col);
if resp.hovered {
ctx.set_cursor(CursorKind::Pointer);
}
if resp.clicked {
Some(!checked)
} else {
None
}
}