diff --git a/Cargo.lock b/Cargo.lock index c6680dc..3b2d5f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6550,7 +6550,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" [[package]] name = "yandex-music-rs" -version = "0.1.7" +version = "0.1.6" dependencies = [ "aes", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 4ab709c..4d113ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "yandex-music-rs" -version = "0.1.7" +version = "0.1.6" edition = "2021" description = "Native high-performance, ultra-low-RAM Yandex Music desktop client in Rust + ash Vulkan SDF + taffy + cosmic-text" diff --git a/README.md b/README.md index 206a239..f915417 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ Готовые сборки доступны на странице [Releases](https://git.tatar/marwy/yandex-music-rs/releases): -- **Windows (x64)**: скачайте `yandex-music-rs-v0.1.7-windows-x86_64.exe` и запустите (переносной файл, установка не требуется). -- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.7-1_amd64.deb` и установите: +- **Windows (x64)**: скачайте `yandex-music-rs-v0.1.6-windows-x86_64.exe` и запустите (переносной файл, установка не требуется). +- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.6-1_amd64.deb` и установите: ```bash - sudo apt install ./yandex-music-rs_0.1.7-1_amd64.deb + sudo apt install ./yandex-music-rs_0.1.6-1_amd64.deb ``` -- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.7-linux-x86_64.tar.gz` с готовыми бинарниками (`yandex-music-rs` + `yandex-music-auth`). +- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.6-linux-x86_64.tar.gz` с готовыми бинарниками (`yandex-music-rs` + `yandex-music-auth`). ## Стек и возможности diff --git a/src/app/state.rs b/src/app/state.rs index 6e69f38..1c10953 100644 --- a/src/app/state.rs +++ b/src/app/state.rs @@ -380,7 +380,6 @@ pub enum AppAction { SetCloseToTray(bool), UpdateEq { enabled: bool, - preamp: f32, bands: [f32; 10], }, SetMaxCoverCache(usize), @@ -630,7 +629,6 @@ impl AppState { config.volume, config.muted, config.eq_enabled, - config.eq_preamp, config.eq_bands_db, config.normalize_loudness, config.crossfade_enabled, @@ -805,7 +803,6 @@ impl AppState { config.volume, config.muted, config.eq_enabled, - config.eq_preamp, config.eq_bands_db, ); audio.state.position_ms.store(position_ms, Ordering::SeqCst); @@ -3130,16 +3127,10 @@ impl AppState { self.config.close_to_tray = v; self.save_config(); } - AppAction::UpdateEq { - enabled, - preamp, - bands, - } => { - let preamp = preamp.clamp(0.5, 1.5); + AppAction::UpdateEq { enabled, bands } => { self.config.eq_enabled = enabled; - self.config.eq_preamp = preamp; self.config.eq_bands_db = bands; - self.audio.set_eq(enabled, preamp, bands); + self.audio.set_eq(enabled, bands); self.save_config(); } AppAction::SetMaxCoverCache(cap) => { diff --git a/src/audio/dsp.rs b/src/audio/dsp.rs index 66d8a34..776656c 100644 --- a/src/audio/dsp.rs +++ b/src/audio/dsp.rs @@ -38,12 +38,12 @@ pub const EQ_PRESETS: &[EqPreset] = &[ }, EqPreset { name_ru: "Клубная музыка", - name_en: "Club music", + name_en: "Club Music", gains: [-0.5, -0.5, 4.0, 2.5, 2.5, 2.5, 1.5, -0.5, -0.5, -0.5], }, EqPreset { name_ru: "Танцевальная музыка", - name_en: "Dance music", + name_en: "Dance Music", gains: [4.5, 3.5, 1.0, -0.5, -0.5, -2.5, -3.5, -3.5, -0.5, -0.5], }, EqPreset { @@ -62,8 +62,8 @@ pub const EQ_PRESETS: &[EqPreset] = &[ gains: [-4.5, -4.5, -4.5, -2.0, 1.0, 5.5, 8.0, 8.0, 8.0, 8.0], }, EqPreset { - name_ru: "Колонки ноутбука", - name_en: "Laptop speakers", + name_ru: "Колонки", + name_en: "Speakers", gains: [2.0, 5.5, 2.5, -1.5, -1.0, 0.5, 2.0, 4.5, 6.0, 7.0], }, EqPreset { @@ -73,12 +73,12 @@ pub const EQ_PRESETS: &[EqPreset] = &[ }, EqPreset { name_ru: "Концерт", - name_en: "Live", + name_en: "Concert", gains: [-2.0, -0.5, 2.0, 2.5, 2.5, 2.5, 2.0, 1.0, 1.0, 1.0], }, EqPreset { name_ru: "Вечеринка", - name_en: "Partying", + name_en: "Party", gains: [3.5, 3.5, -0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 3.5, 3.5], }, EqPreset { @@ -102,13 +102,13 @@ pub const EQ_PRESETS: &[EqPreset] = &[ gains: [-1.0, -2.0, -2.0, -0.5, 2.0, 2.5, 4.0, 4.5, 5.5, 4.5], }, EqPreset { - name_ru: "Мягкое звучание", - name_en: "Soft", + name_ru: "Мягкая музыка", + name_en: "Soft Music", gains: [2.0, 0.5, -0.5, -1.0, -0.5, 2.0, 4.0, 4.5, 5.5, 6.0], }, EqPreset { name_ru: "Софт-рок", - name_en: "Soft rock", + name_en: "Soft Rock", gains: [2.0, 2.0, 1.0, -0.5, -2.0, -2.5, -1.5, -0.5, 1.0, 4.0], }, EqPreset { @@ -129,9 +129,9 @@ pub fn active_eq_preset_name(bands: &[f32; 10], ru: bool) -> &'static str { } } if ru { - "Своя настройка" + "Свой" } else { - "Custom settings" + "Custom" } } @@ -264,7 +264,6 @@ impl Biquad { pub struct Equalizer10Band { bands: [Biquad; 10], enabled: bool, - preamp: f32, sample_rate: f32, gains_db: [f32; 10], } @@ -274,15 +273,13 @@ impl Equalizer10Band { Self { bands: [Biquad::identity(); 10], enabled: false, - preamp: 1.0, sample_rate, gains_db: [0.0; 10], } } - pub fn update(&mut self, enabled: bool, preamp: f32, gains_db: [f32; 10]) { + pub fn update(&mut self, enabled: bool, gains_db: [f32; 10]) { self.enabled = enabled; - self.preamp = preamp.clamp(0.5, 1.5); if self.gains_db != gains_db { self.gains_db = gains_db; for i in 0..10 { @@ -302,8 +299,6 @@ impl Equalizer10Band { if !self.enabled { return (l, r); } - l *= self.preamp; - r *= self.preamp; for band in &mut self.bands { (l, r) = band.process_stereo(l, r); } @@ -369,19 +364,14 @@ mod tests { assert_eq!(EQ_FREQS[9], 16000.0); assert_eq!(active_eq_preset_name(&EQ_PRESETS[0].gains, true), "По умолчанию"); assert_eq!(active_eq_preset_name(&EQ_PRESETS[13].gains, false), "Rock"); - assert_eq!(active_eq_preset_name(&[1.2; 10], true), "Своя настройка"); - assert_eq!(active_eq_preset_name(&[1.2; 10], false), "Custom settings"); + assert_eq!(active_eq_preset_name(&[1.2; 10], true), "Свой"); let mut eq = Equalizer10Band::new(48_000.0); - eq.update(true, 1.25, EQ_PRESETS[5].gains); + eq.update(true, EQ_PRESETS[5].gains); for i in 0..1024 { let s = (i as f32 * 0.1).sin() * 0.5; let (l, r) = eq.process(s, -s); assert!(l.is_finite() && r.is_finite()); } - let mut eq_pre = Equalizer10Band::new(48_000.0); - eq_pre.update(true, 0.5, [0.0; 10]); - let (pl, pr) = eq_pre.process(0.4, -0.4); - assert!((pl - 0.2).abs() < 1e-4 && (pr + 0.2).abs() < 1e-4); } } diff --git a/src/audio/mod.rs b/src/audio/mod.rs index bf28cdd..0c68225 100644 --- a/src/audio/mod.rs +++ b/src/audio/mod.rs @@ -71,7 +71,6 @@ pub struct SharedAudioState { pub energy_bits: AtomicU32, pub bass_bits: AtomicU32, pub eq_enabled: AtomicBool, - pub eq_preamp_bits: AtomicU32, pub eq_bands: Mutex<[f32; 10]>, pub active_codec: Mutex, pub output_device_name: Mutex, @@ -84,7 +83,6 @@ impl SharedAudioState { volume: f32, muted: bool, eq_enabled: bool, - eq_preamp: f32, eq_bands: [f32; 10], normalize_loudness: bool, crossfade_enabled: bool, @@ -107,7 +105,6 @@ impl SharedAudioState { energy_bits: AtomicU32::new(0.0f32.to_bits()), bass_bits: AtomicU32::new(0.0f32.to_bits()), eq_enabled: AtomicBool::new(eq_enabled), - eq_preamp_bits: AtomicU32::new(eq_preamp.clamp(0.5, 1.5).to_bits()), eq_bands: Mutex::new(eq_bands), active_codec: Mutex::new("FLAC / WASAPI".into()), output_device_name: Mutex::new("Системное устройство (WASAPI)".into()), @@ -173,7 +170,6 @@ impl AudioEngine { volume: f32, muted: bool, eq_enabled: bool, - eq_preamp: f32, eq_bands: [f32; 10], normalize_loudness: bool, crossfade_enabled: bool, @@ -183,7 +179,6 @@ impl AudioEngine { volume, muted, eq_enabled, - eq_preamp, eq_bands, normalize_loudness, crossfade_enabled, @@ -205,15 +200,9 @@ impl AudioEngine { } /// Silent, thread-free audio engine for deterministic headless visual tests. - pub fn new_headless( - volume: f32, - muted: bool, - eq_enabled: bool, - eq_preamp: f32, - eq_bands: [f32; 10], - ) -> Self { + pub fn new_headless(volume: f32, muted: bool, eq_enabled: bool, eq_bands: [f32; 10]) -> Self { let state = Arc::new(SharedAudioState::new( - volume, muted, eq_enabled, eq_preamp, eq_bands, true, false, 0.0, + volume, muted, eq_enabled, eq_bands, true, false, 0.0, )); let (tx_cmd, _rx_cmd) = unbounded(); Self { @@ -369,11 +358,8 @@ impl AudioEngine { .store(secs.clamp(0.0, 12.0).to_bits(), Ordering::Relaxed); } - pub fn set_eq(&self, enabled: bool, preamp: f32, bands: [f32; 10]) { + pub fn set_eq(&self, enabled: bool, bands: [f32; 10]) { self.state.eq_enabled.store(enabled, Ordering::Relaxed); - self.state - .eq_preamp_bits - .store(preamp.clamp(0.5, 1.5).to_bits(), Ordering::Relaxed); *self.state.eq_bands.lock() = bands; } @@ -1039,10 +1025,8 @@ fn run_audio_worker(rx_cmd: Receiver, state: Arc let gain = vol; let eq_on = state_cb.eq_enabled.load(Ordering::Relaxed); - let preamp = f32::from_bits(state_cb.eq_preamp_bits.load(Ordering::Relaxed)) - .clamp(0.5, 1.5); if let Some(bands) = state_cb.eq_bands.try_lock() { - eq.update(eq_on, preamp, *bands); + eq.update(eq_on, *bands); } if !playing { @@ -1481,7 +1465,7 @@ mod tests { #[test] fn seek_seq_prevents_stale_decoder_position_overwrite() { - let engine = AudioEngine::new_headless(0.8, false, false, 1.0, [0.0; 10]); + let engine = AudioEngine::new_headless(0.8, false, false, [0.0; 10]); // Initial playback at seq 0 publishes normally. assert!(publish_decoder_position_ms(&engine.state, 0, 30_000)); @@ -1540,7 +1524,7 @@ mod tests { #[test] fn stop_bumps_seek_seq_preventing_old_decoder_overwrite() { - let engine = AudioEngine::new_headless(0.8, false, false, 1.0, [0.0; 10]); + let engine = AudioEngine::new_headless(0.8, false, false, [0.0; 10]); assert!(publish_decoder_position_ms(&engine.state, 0, 45_000)); engine.stop(); assert_eq!(engine.state.position_ms.load(Ordering::Acquire), 0); diff --git a/src/config.rs b/src/config.rs index 02bda70..eee290f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -152,9 +152,7 @@ pub struct AppConfig { pub muted: bool, pub sidebar_collapsed: bool, pub eq_enabled: bool, - #[serde(default = "default_eq_preamp")] - pub eq_preamp: f32, - pub eq_bands_db: [f32; 10], // 60, 170, 310, 600, 1k, 3k, 6k, 12k, 14k, 16k Hz + pub eq_bands_db: [f32; 10], // 32, 64, 125, 250, 500, 1k, 2k, 4k, 8k, 16k Hz pub normalize_loudness: bool, #[serde(default = "default_true")] pub crossfade_enabled: bool, @@ -197,10 +195,6 @@ fn default_true() -> bool { true } -fn default_eq_preamp() -> f32 { - 1.0 -} - impl Default for AppConfig { fn default() -> Self { Self { @@ -212,7 +206,6 @@ impl Default for AppConfig { muted: false, sidebar_collapsed: false, eq_enabled: false, - eq_preamp: 1.0, eq_bands_db: [0.0; 10], normalize_loudness: true, crossfade_enabled: true, diff --git a/src/engine/input.rs b/src/engine/input.rs index 6018b59..659dac3 100644 --- a/src/engine/input.rs +++ b/src/engine/input.rs @@ -554,36 +554,6 @@ impl InputState { } } - /// Consume the current pointer press (`active_id = None`, `left_pressed = false`, - /// `right_pressed = false`) so releasing over an underlying widget cannot trigger a click/drag. - pub fn consume_pointer_press(&mut self) { - self.active_id = None; - self.left_pressed = false; - self.right_pressed = false; - } - - /// Like `clicked_outside`, but also consumes the dismissing press (`active_id = None`, - /// `left_pressed = false`, `right_pressed = false`) so releasing over an underlying - /// toggle trigger button (e.g. PlayerBar EQ button) can NEVER re-open the overlay. - pub fn consume_clicked_outside(&mut self, rect: Rect) -> bool { - if self.clicked_outside(rect) { - self.consume_pointer_press(); - true - } else { - false - } - } - - /// Multi-rect variant of `consume_clicked_outside`. - pub fn consume_clicked_outside_any(&mut self, rects: &[Rect]) -> bool { - if self.clicked_outside_any(rects) { - self.consume_pointer_press(); - true - } else { - false - } - } - pub fn key_pressed(&self, key: Key) -> bool { self.key_events.iter().any(|e| e.key == key) } @@ -724,47 +694,3 @@ impl Animator { self.values.clear(); } } - -#[cfg(test)] -mod tests { - use super::*; - use winit::dpi::PhysicalPosition; - - #[test] - fn test_consume_clicked_outside_prevents_trigger_reopen_on_release() { - let mut input = InputState::new(); - let screen = Vec2::new(1280.0, 800.0); - let trigger_id = WidgetId::new("pb_r_eq"); - let trigger_r = Rect::from_xywh(1000.0, 740.0, 36.0, 36.0); - let pop_r = Rect::from_xywh(800.0, 400.0, 430.0, 300.0); - - // Frame 1: Mouse down on the underlying trigger button while popover is open. - input.begin_frame(screen, 1.0, 1.0); - input.handle_winit_event(&WindowEvent::CursorMoved { - device_id: unsafe { std::mem::zeroed() }, - position: PhysicalPosition::new(1018.0, 758.0), - }); - input.handle_winit_event(&WindowEvent::MouseInput { - device_id: unsafe { std::mem::zeroed() }, - state: ElementState::Pressed, - button: MouseButton::Left, - }); - - let press_resp = input.interact(trigger_id, ZLayer::Base, trigger_r, None); - assert!(!press_resp.clicked); - assert!(input.consume_clicked_outside(pop_r)); - assert!(input.active_id.is_none()); - input.end_frame(); - - // Frame 2: Mouse up over the same trigger button — MUST NOT fire clicked! - input.begin_frame(screen, 1.0, 1.05); - input.handle_winit_event(&WindowEvent::MouseInput { - device_id: unsafe { std::mem::zeroed() }, - state: ElementState::Released, - button: MouseButton::Left, - }); - let rel_resp = input.interact(trigger_id, ZLayer::Base, trigger_r, None); - assert!(!rel_resp.clicked); - input.end_frame(); - } -} diff --git a/src/views/mod.rs b/src/views/mod.rs index 9c67299..b98ef1f 100644 --- a/src/views/mod.rs +++ b/src/views/mod.rs @@ -539,38 +539,8 @@ impl YandexMusicShell { } // 6. Floating Popovers & Context Menus (ZLayer::Popover) - let ease_out = |t: f32| -> f32 { - let u = 1.0 - t.clamp(0.0, 1.0); - 1.0 - u * u * u - }; - let eq_pop_t = if self.app.fixed_vibe_time.is_some() { - if self.app.eq_popover_open { 1.0 } else { 0.0 } - } else { - ease_out(self.ui.animate_bool( - WidgetId::new("ym_quality_popover_anim"), - self.app.eq_popover_open, - 0.18, - )) - }; - let eq_expand_t = if self.app.fixed_vibe_time.is_some() { - if self.app.config.eq_enabled { 1.0 } else { 0.0 } - } else { - ease_out(self.ui.animate_bool( - WidgetId::new("ym_quality_eq_expand"), - self.app.config.eq_enabled, - 0.20, - )) - }; - if eq_pop_t > 0.01 { - render_eq_popover( - &mut self.ui, - &pal, - &self.app, - &mut self.shell, - eq_pop_t, - eq_expand_t, - &mut actions, - ); + if self.app.eq_popover_open { + render_eq_popover(&mut self.ui, &pal, &self.app, &mut self.shell, &mut actions); } render_track_context_menu(&mut self.ui, &pal, &self.app, &mut self.shell, &mut actions); render_entity_context_menu(&mut self.ui, &pal, &self.app, &mut self.shell, &mut actions); @@ -593,48 +563,14 @@ impl YandexMusicShell { if self.app.track_detail_modal.is_some() { render_track_detail_modal(&mut self.ui, &pal, &mut self.covers, &self.app, &mut actions); } - let rn_mod_t = if self.app.fixed_vibe_time.is_some() { - if self.app.release_notes_modal_open { 1.0 } else { 0.0 } - } else { - ease_out(self.ui.animate_bool( - WidgetId::new("ym_release_notes_modal_anim"), - self.app.release_notes_modal_open, - 0.18, - )) - }; - if rn_mod_t > 0.01 { - render_release_notes_modal(&mut self.ui, &pal, &self.app, rn_mod_t, &mut actions); + if self.app.release_notes_modal_open { + render_release_notes_modal(&mut self.ui, &pal, &self.app, &mut actions); } - let eq_mod_t = if self.app.fixed_vibe_time.is_some() { - if self.app.equalizer_modal_open { 1.0 } else { 0.0 } - } else { - ease_out(self.ui.animate_bool( - WidgetId::new("ym_eq_modal_anim"), - self.app.equalizer_modal_open, - 0.18, - )) - }; - if eq_mod_t > 0.01 { - render_equalizer_modal( - &mut self.ui, - &pal, - &self.app, - &mut self.shell, - eq_mod_t, - &mut actions, - ); + if self.app.equalizer_modal_open { + render_equalizer_modal(&mut self.ui, &pal, &self.app, &mut self.shell, &mut actions); } - let sc_mod_t = if self.app.fixed_vibe_time.is_some() { - if self.app.shortcuts_modal_open { 1.0 } else { 0.0 } - } else { - ease_out(self.ui.animate_bool( - WidgetId::new("ym_shortcuts_modal_anim"), - self.app.shortcuts_modal_open, - 0.18, - )) - }; - if sc_mod_t > 0.01 { - render_shortcuts_modal(&mut self.ui, &pal, &self.app, sc_mod_t, &mut actions); + if self.app.shortcuts_modal_open { + render_shortcuts_modal(&mut self.ui, &pal, &self.app, &mut actions); } // 8. Transparent 32px Floating TitleBar (ZLayer::Titlebar) diff --git a/src/views/overlays.rs b/src/views/overlays.rs index c1fd5d1..a43e08c 100644 --- a/src/views/overlays.rs +++ b/src/views/overlays.rs @@ -14,7 +14,7 @@ use crate::engine::textures::{premultiply_rgba_srgb, TextureRegistry}; use crate::engine::widgets::{ draw_cover_art, draw_downloading_progress, icon_button, secondary_pill_button, separated_artists, text_input_widget, yellow_pill_button, ym_menu_frame, ym_menu_item, - ym_menu_item_ex, ym_volume_capsule, SliderResponse, TextInputOptions, + ym_menu_item_ex, ym_vertical_slider, ym_volume_capsule, TextInputOptions, }; use crate::engine::{ css_rgba, Color, CornerRadii, CursorKind, Pos2, Rect, TextAlign, TextStyle, TextureId, @@ -2155,7 +2155,7 @@ pub fn render_track_context_menu( if !sub_rect.is_empty() { keep.push(sub_rect); } - if ctx.input.consume_clicked_outside_any(&keep) { + if ctx.input.clicked_outside_any(&keep) { close_menu = true; } }); @@ -2485,7 +2485,7 @@ pub fn render_entity_context_menu( if !sub_rect.is_empty() { keep.push(sub_rect); } - if ctx.input.consume_clicked_outside_any(&keep) { + if ctx.input.clicked_outside_any(&keep) { close_menu = true; } }); @@ -2691,7 +2691,7 @@ pub fn render_vibe_settings_modal( 36.0, false, ); - if done_resp.clicked || ctx.input.consume_clicked_outside(modal_r) { + if done_resp.clicked || ctx.input.clicked_outside(modal_r) { actions.push(AppAction::SetVibeModalOpen(false)); } }); @@ -2917,7 +2917,7 @@ pub fn render_playlist_modal( submit = true; } - if ctx.input.consume_clicked_outside(modal_r) { + if ctx.input.clicked_outside(modal_r) { close_modal = true; } }); @@ -3070,7 +3070,7 @@ pub fn render_delete_playlist_confirm_modal( confirm = true; } - if ctx.input.consume_clicked_outside(modal_r) { + if ctx.input.clicked_outside(modal_r) { close_modal = true; } }); @@ -3214,7 +3214,7 @@ pub fn render_login_modal( actions.push(AppAction::SubmitOAuthToken(app.token_input.clone())); } - if ctx.input.consume_clicked_outside(modal_r) { + if ctx.input.clicked_outside(modal_r) { actions.push(AppAction::SetLoginModalOpen(false)); } }); @@ -3640,7 +3640,7 @@ pub fn render_track_detail_modal( let total_h = (y - (body_viewport.top() - scroll_y)).max(0.0); ctx.end_scroll_v(scroll_id, pal, total_h, true); - if ctx.input.consume_clicked_outside(panel_r) { + if ctx.input.clicked_outside(panel_r) { actions.push(AppAction::CloseTrackDetailModal); } }); @@ -3655,122 +3655,74 @@ pub fn render_eq_popover( pal: &YmPalette, app: &AppState, shell: &mut ShellUiState, - anim_t: f32, - eq_expand_t: f32, actions: &mut Vec, ) { let i18n = app.i18n(); let ru = i18n.is_ru(); let screen = ctx.screen_rect(); - let open = app.eq_popover_open; - let alpha = anim_t.clamp(0.0, 1.0); - let expand_t = eq_expand_t.clamp(0.0, 1.0); + let anim_t = if app.fixed_vibe_time.is_some() { + 1.0 + } else { + let raw = ctx.animate_bool(WidgetId::new("ym_quality_popover_anim"), true, 0.16); + let u = 1.0 - raw; + 1.0 - u * u * u + }; + let eq_expand_t = if app.fixed_vibe_time.is_some() { + if app.config.eq_enabled { 1.0 } else { 0.0 } + } else { + ctx.animate_bool(WidgetId::new("ym_quality_eq_expand"), app.config.eq_enabled, 0.18) + }; let pop_w = (screen.width() - 32.0).clamp(320.0, 430.0); - let qualities = [ - ( - AudioQuality::Lossless, - if ru { "Превосходное" } else { "Superb" }, - if ru { - "Музыка в lossless и других высококачественных форматах для быстрого интернета и хорошей акустики" - } else { - "Music in lossless and other high-quality formats for fast internet connections and superior acoustic systems" - }, - ), - ( - AudioQuality::High, - if ru { "Оптимальное" } else { "Balanced" }, - if ru { - "Сбалансированный звук для большинства устройств" - } else { - "Balanced sound for most devices" - }, - ), - ( - AudioQuality::Standard, - if ru { "Экономичное" } else { "Efficient" }, - if ru { - "Стабильное звучание при медленном интернете" - } else { - "Stable sound with a slow internet connection" - }, - ), - ]; - - let txt_w = (pop_w - 72.0).max(120.0); - let mut row_heights = [0.0f32; 3]; - let mut total_rows_h = 0.0f32; - for (idx, (_, _, sub)) in qualities.iter().enumerate() { - let sub_h = ctx - .measure_text(sub, TextStyle::regular(12.0, pal.text_secondary), Some(txt_w)) - .y - .max(16.0); - let rh = 10.0 + 19.0 + 3.0 + sub_h + 10.0; - row_heights[idx] = rh; - 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; + let base_h = 286.0; + let eq_extra_h = 256.0 * eq_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; + let slide_dy = (1.0 - anim_t) * 14.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.bottom() - PLAYER_BAR_HEIGHT - pop_h - 22.0 + slide_dy).max(40.0), pop_w, pop_h, ); let mut enabled = app.config.eq_enabled; - let mut preamp = app.config.eq_preamp; let mut bands = app.config.eq_bands_db; let mut changed = false; + let mut dropdown_rect: Option = None; ctx.with_layer(ZLayer::Popover, |ctx| { - if open { - ctx.register_blocker(pop_r); - } - ctx.dl().push_shadow( - pop_r, - 16.0, - 24.0, - 0.0, - Vec2::new(0.0, 6.0), - pal.shadow_menu.with_alpha_f32(alpha), - ); + ctx.register_blocker(pop_r); + ctx.dl() + .push_shadow(pop_r, 16.0, 24.0, 0.0, Vec2::new(0.0, 6.0), pal.shadow_menu); ctx.dl().push_rect_bordered( pop_r, 16.0, - pal.bg_popover.with_alpha_f32(alpha), + pal.bg_popover, 1.0, - pal.border_subtle.with_alpha_f32(alpha), + pal.border_subtle, ); - 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); ctx.draw_text_ellipsis( i18n.sound_settings(), - TextStyle::headline(18.0, pal.text_bright.with_alpha_f32(alpha)), + TextStyle::headline(18.0, pal.text_bright), Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 36.0, hdr_r.height()), TextAlign::Left, ); - 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), - Icon::Close, - 13.0, - pal.text_secondary, - pal.text_bright, - pal.surface_hover, - false, - i18n.close(), - ) - .clicked + if 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), + Icon::Close, + 13.0, + pal.text_secondary, + pal.text_bright, + pal.surface_hover, + false, + i18n.close(), + ) + .clicked { shell.eq_presets_dropdown_open = false; actions.push(AppAction::SetEqPopoverOpen(false)); @@ -3778,33 +3730,56 @@ pub fn render_eq_popover( // 3 Official Quality Options (`QualitySettings_item`) let mut y = hdr_r.bottom() + 10.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); - let resp = if open { - ctx.interact(WidgetId::from_pair("qs_qual", *q as u8), row_r) - } else { - Default::default() - }; - let active = app.config.audio_quality == *q; + let qualities = [ + ( + AudioQuality::Lossless, + if ru { "Максимальное" } else { "Maximum" }, + if ru { + "Звук без потерь в формате FLAC (если доступно)" + } else { + "Lossless FLAC audio when available" + }, + ), + ( + AudioQuality::High, + if ru { "Оптимальное" } else { "Optimal" }, + if ru { + "Высокое качество звука (320 кбит/с)" + } else { + "High audio quality (320 kbps)" + }, + ), + ( + AudioQuality::Standard, + if ru { "Экономичное" } else { "Efficient" }, + if ru { + "Стабильное звучание при медленном интернете" + } else { + "Stable playback on slower connections" + }, + ), + ]; + + for (q, title, sub) in qualities { + let row_r = Rect::from_xywh(pop_r.left() + 10.0, y, pop_w - 20.0, 54.0); + let resp = ctx.interact(WidgetId::from_pair("qs_qual", q as u8), row_r); + 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)); + ctx.dl().push_rect(row_r, 10.0, pal.surface_hover); 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); + let txt_x = row_r.left() + 12.0; + let txt_w = (row_r.width() - 46.0).max(80.0); ctx.draw_text_ellipsis( title, - TextStyle::bold(14.5, pal.text_bright.with_alpha_f32(alpha)), - Rect::from_xywh(row_txt_x, row_r.top() + 9.0, row_txt_w, 19.0), + TextStyle::bold(14.5, pal.text_bright), + Rect::from_xywh(txt_x, row_r.top() + 8.0, txt_w, 19.0), TextAlign::Left, ); - ctx.draw_text_wrapped( + ctx.draw_text_ellipsis( sub, - TextStyle::regular(12.0, pal.text_secondary.with_alpha_f32(alpha)), - Rect::from_xywh(row_txt_x, row_r.top() + 31.0, row_txt_w, rh - 36.0), - None, + TextStyle::regular(12.0, pal.text_secondary), + Rect::from_xywh(txt_x, row_r.top() + 28.0, txt_w, 17.0), TextAlign::Left, ); if active { @@ -3814,13 +3789,13 @@ 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, ); } if resp.clicked && !active { - actions.push(AppAction::SetAudioQuality(*q)); + actions.push(AppAction::SetAudioQuality(q)); } - y += rh + 4.0; + y += 56.0; } // Hairline divider before Equalizer section @@ -3828,74 +3803,40 @@ pub fn render_eq_popover( 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), + pal.border_subtle, ); y += 14.0; - // Inline Official Equalizer (`Equalizer_header` + animated expandable Preamp + 10 bands + Presets) + // Inline Official Equalizer (`Equalizer_header` + expandable `EqualizerPresets` & 10 bands) 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), ); - let dd_anchor = render_equalizer_body( + dropdown_rect = render_equalizer_body( ctx, pal, eq_area, if ru { "Эквалайзер" } else { "Equalizer" }, ru, &mut enabled, - &mut preamp, &mut bands, &mut changed, &mut shell.eq_presets_dropdown_open, - alpha, - expand_t, - false, - open, + eq_expand_t > 0.15, "qs_eq", ); - ctx.pop_clip(); - - // Render floating presets dropdown OUTSIDE popover clip so `placement: "top"` is never cut off! - let mut dd_rect: Option = None; - if open && shell.eq_presets_dropdown_open { - if let Some((sel_r, sel_clicked)) = dd_anchor { - dd_rect = render_eq_presets_dropdown( - ctx, - pal, - sel_r, - pop_r, - ru, - &mut enabled, - &mut preamp, - &mut bands, - &mut changed, - &mut shell.eq_presets_dropdown_open, - sel_clicked, - "qs_eq", - ); - } - } - - if open { - let mut keep = vec![pop_r]; - if let Some(dr) = dd_rect { - keep.push(dr); - } - if ctx.input.consume_clicked_outside_any(&keep) { - shell.eq_presets_dropdown_open = false; - actions.push(AppAction::SetEqPopoverOpen(false)); - } + let clicked_in_dd = dropdown_rect + .and_then(|dr| ctx.input.pointer_pos.map(|p| dr.contains(p))) + .unwrap_or(false); + if ctx.input.clicked_outside(pop_r) && !clicked_in_dd { + shell.eq_presets_dropdown_open = false; + actions.push(AppAction::SetEqPopoverOpen(false)); } }); if changed { - actions.push(AppAction::UpdateEq { - enabled, - preamp, - bands, - }); + actions.push(AppAction::UpdateEq { enabled, bands }); } } @@ -3905,216 +3846,105 @@ pub fn render_equalizer_modal( pal: &YmPalette, app: &AppState, shell: &mut ShellUiState, - anim_t: f32, actions: &mut Vec, ) { let i18n = app.i18n(); let ru = i18n.is_ru(); - let open = app.equalizer_modal_open; - let alpha = anim_t.clamp(0.0, 1.0); + let anim_t = if app.fixed_vibe_time.is_some() { + 1.0 + } else { + let raw = ctx.animate_bool(WidgetId::new("ym_eq_modal_anim"), true, 0.18); + let u = 1.0 - raw; + 1.0 - u * u * u + }; 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 slide_dy = (1.0 - anim_t) * 14.0; let modal_r = Rect::from_center_size( Pos2::new(screen.center_x(), screen.center_y() + slide_dy), Vec2::new(modal_w, modal_h), ); let mut enabled = app.config.eq_enabled; - let mut preamp = app.config.eq_preamp; let mut bands = app.config.eq_bands_db; let mut changed = false; ctx.with_layer(ZLayer::Modal, |ctx| { - if open { - ctx.register_blocker(screen); - } + ctx.register_blocker(screen); ctx.dl().push_rect( screen, 0.0, - Color::rgba(0, 0, 0, (150.0 * alpha).round() as u8), - ); - ctx.dl().push_shadow( - modal_r, - 16.0, - 32.0, - 0.0, - Vec2::new(0.0, 8.0), - pal.shadow_modal.with_alpha_f32(alpha), - ); - ctx.dl().push_rect_bordered( - modal_r, - 16.0, - pal.bg_popover.with_alpha_f32(alpha), - 1.0, - pal.border_subtle.with_alpha_f32(alpha), + Color::rgba(0, 0, 0, (150.0 * anim_t).round() as u8), ); + ctx.dl() + .push_shadow(modal_r, 16.0, 32.0, 0.0, Vec2::new(0.0, 8.0), pal.shadow_modal); + ctx.dl() + .push_rect_bordered(modal_r, 16.0, pal.bg_popover, 1.0, pal.border_subtle); 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 { "Equalizer" }, - TextStyle::headline(20.0, pal.text_bright.with_alpha_f32(alpha)), + TextStyle::headline(20.0, pal.text_bright), Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 36.0, hdr_r.height()), TextAlign::Left, ); - 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), - Icon::Close, - 15.0, - pal.text_secondary, - pal.text_bright, - pal.surface_hover, - false, - i18n.close(), - ) - .clicked + if 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), + Icon::Close, + 15.0, + pal.text_secondary, + pal.text_bright, + pal.surface_hover, + false, + i18n.close(), + ) + .clicked { shell.eq_presets_dropdown_open = false; actions.push(AppAction::SetEqualizerModalOpen(false)); } let eq_area = Rect::from_min_max( - Pos2::new(modal_r.left() + 20.0, hdr_r.bottom() + 24.0), + Pos2::new(modal_r.left() + 20.0, hdr_r.bottom() + 18.0), Pos2::new(modal_r.right() - 20.0, modal_r.bottom() - 20.0), ); - let is_disabled = !enabled; - let dd_anchor = render_equalizer_body( + let dd_rect = render_equalizer_body( ctx, pal, eq_area, - if ru { "Включить" } else { "Turn on" }, + if ru { + "Включить эквалайзер" + } else { + "Enable equalizer" + }, ru, &mut enabled, - &mut preamp, &mut bands, &mut changed, &mut shell.eq_presets_dropdown_open, - alpha, - 1.0, - is_disabled, - open, + true, "em_eq", ); - let mut dd_rect: Option = None; - if open && shell.eq_presets_dropdown_open { - if let Some((sel_r, sel_clicked)) = dd_anchor { - dd_rect = render_eq_presets_dropdown( - ctx, - pal, - sel_r, - modal_r, - ru, - &mut enabled, - &mut preamp, - &mut bands, - &mut changed, - &mut shell.eq_presets_dropdown_open, - sel_clicked, - "em_eq", - ); - } - } - - if open { - let mut keep = vec![modal_r]; - if let Some(dr) = dd_rect { - keep.push(dr); - } - if ctx.input.consume_clicked_outside_any(&keep) { - shell.eq_presets_dropdown_open = false; - actions.push(AppAction::SetEqualizerModalOpen(false)); - } + let clicked_in_dd = dd_rect + .and_then(|dr| ctx.input.pointer_pos.map(|p| dr.contains(p))) + .unwrap_or(false); + if ctx.input.clicked_outside(modal_r) && !clicked_in_dd { + shell.eq_presets_dropdown_open = false; + actions.push(AppAction::SetEqualizerModalOpen(false)); } }); if changed { - actions.push(AppAction::UpdateEq { - enabled, - preamp, - bands, - }); + actions.push(AppAction::UpdateEq { enabled, bands }); } } -/// Official `EqualizerSlider` (`8711fa44496b8e09.css:340-416`): -/// - Thin `2px` 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) -fn eq_vertical_slider( - ctx: &mut UiContext, - pal: &YmPalette, - id: WidgetId, - rect: Rect, - norm_val: f32, - disabled: bool, - interactive: bool, - alpha: f32, -) -> SliderResponse { - let resp = if !disabled && interactive { - ctx.interact(id, rect) - } else { - Default::default() - }; - let active = !disabled && (resp.hovered || resp.pressed || resp.dragged); - let cx = rect.center_x(); - let top = rect.top() + 7.0; - 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); - ctx.dl() - .push_rect(Rect::from_xywh(cx - 1.0, top, 2.0, track_h), 1.0, track_col); - - // Centered 8×1px horizontal serif tick at midpoint (`EqualizerSlider_serif`) - ctx.dl().push_rect( - Rect::from_xywh((cx - 4.0).round(), (top + track_h * 0.5).round(), 8.0, 1.0), - 0.0, - track_col, - ); - - // Hollow circular thumb (`14px` diameter, `1.5px` yellow/muted 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) - } else { - pal.yellow.with_alpha_f32(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), - 1.5, - border_col, - ); - - if active { - ctx.set_cursor(CursorKind::Pointer); - } - - let mut new_val = None; - if !disabled && interactive && (resp.pressed || resp.dragged || resp.clicked) { - if let Some(p) = ctx.input.pointer_pos { - new_val = Some((1.0 - (p.y - top) / track_h).clamp(0.0, 1.0)); - } - } - - SliderResponse { - value: new_val, - hovered: resp.hovered, - dragging: resp.pressed || resp.dragged, - } -} - -/// 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. +/// Shared official Yandex Music 5.129.0 Equalizer UI (`8711fa44496b8e09.css:136-299`): +/// Toggle header + Preset selector dropdown (18 presets) + `+12 / 0 / -12 dB` scale + 10 bands (`60`..`16k`). #[allow(clippy::too_many_arguments)] fn render_equalizer_body( ctx: &mut UiContext, @@ -4123,44 +3953,37 @@ fn render_equalizer_body( toggle_title: &str, ru: bool, enabled: &mut bool, - preamp: &mut f32, bands: &mut [f32; 10], changed: &mut bool, dropdown_open: &mut bool, - anim_alpha: f32, - expand_t: f32, - is_disabled: bool, - interactive: bool, + show_sliders: bool, salt: &str, -) -> Option<(Rect, bool)> { - // 1. Header row: Title + official Pill Toggle (`44×24`, smoothly animated) +) -> Option { + // 1. Header row: Title + official Pill Toggle (`40×22`) let hdr_r = Rect::from_xywh(area.left(), area.top(), area.width(), 28.0); ctx.draw_text_ellipsis( toggle_title, - TextStyle::medium(16.0, pal.text_bright.with_alpha_f32(anim_alpha)), + TextStyle::bold(15.0, pal.text_bright), Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 56.0, hdr_r.height()), TextAlign::Left, ); - let sw_w = 44.0; - let sw_h = 24.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 { - ctx.interact(sw_id, sw_r) - } else { - 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); - 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_col = if tog_t > 0.5 { - pal.on_yellow - } else { - pal.text_bright - }; - ctx.dl() - .push_circle(Pos2::new(knob_x, sw_r.center_y()), 9.0, knob_col.with_alpha_f32(anim_alpha)); + let sw_r = Rect::from_xywh(hdr_r.right() - 42.0, hdr_r.center_y() - 11.0, 42.0, 22.0); + let sw_resp = ctx.interact(WidgetId::new(salt).with("toggle"), sw_r); + ctx.dl().push_rect( + sw_r, + 11.0, + if *enabled { + pal.yellow + } else { + pal.surface_hover + }, + ); + let knob_x = if *enabled { sw_r.right() - 11.0 } else { sw_r.left() + 11.0 }; + ctx.dl().push_circle( + Pos2::new(knob_x, sw_r.center_y()), + 8.5, + if *enabled { Color::rgb(0x19, 0x19, 0x19) } else { pal.text_bright }, + ); if sw_resp.hovered { ctx.set_cursor(CursorKind::Pointer); } @@ -4172,96 +3995,145 @@ fn render_equalizer_body( } } - if expand_t <= 0.01 { + if !show_sliders { return None; } - let content_alpha = (anim_alpha * expand_t).clamp(0.0, 1.0); - let clip_h = (242.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, - ); + let mut y = hdr_r.bottom() + 14.0; + let is_custom_or_modified = bands.iter().any(|&b| b.abs() >= 0.15); - let y = hdr_r.bottom() + 16.0; - let sliders_h = 144.0; // `9rem` - let lbl_col = if is_disabled { - pal.text_disabled + // 2. Preset selector button (`EqualizerPresets_root`) + optional Reset button + let reset_w = if is_custom_or_modified { 86.0 } else { 0.0 }; + let sel_w = (area.width() - if is_custom_or_modified { reset_w + 8.0 } else { 0.0 }).max(140.0); + let sel_r = Rect::from_xywh(area.left(), y, sel_w, 38.0); + let sel_resp = ctx.interact(WidgetId::new(salt).with("preset_sel"), sel_r); + ctx.dl().push_rect_bordered( + sel_r, + 12.0, + if sel_resp.hovered { + pal.surface_hover + } else { + pal.surface_secondary + }, + 1.0, + if *dropdown_open { + pal.border_control + } else { + pal.border_subtle + }, + ); + let preset_lbl = active_eq_preset_name(bands, ru); + let label_col = if *enabled { + pal.text_bright } else { - pal.text_secondary - } - .with_alpha_f32(content_alpha); - - // 2. Left Preamp column (`Equalizer_preamp`) + amp labels (`12dB / 0dB / -12dB`) - let preamp_w = 42.0; - let preamp_r = Rect::from_xywh(area.left(), y, preamp_w, sliders_h); - let preamp_norm = ((*preamp - 0.5) / 1.0).clamp(0.0, 1.0); - let presp = eq_vertical_slider( - ctx, - pal, - WidgetId::new(salt).with("preamp"), - preamp_r, - preamp_norm, - is_disabled, - interactive && expand_t > 0.85, - content_alpha, + pal.text_disabled + }; + ctx.draw_text_ellipsis( + preset_lbl, + TextStyle::medium(13.5, label_col), + Rect::from_xywh(sel_r.left() + 14.0, sel_r.top(), sel_r.width() - 42.0, sel_r.height()), + TextAlign::Left, ); - if presp.hovered || presp.dragging { - ctx.show_tooltip(preamp_r, format!("{:.2}×", *preamp)); + ctx.draw_icon( + Icon::ArrowDown, + Rect::from_center_size(Pos2::new(sel_r.right() - 18.0, sel_r.center_y()), Vec2::splat(16.0)), + if *enabled { + pal.text_secondary + } else { + pal.text_disabled + }, + ); + if sel_resp.hovered { + ctx.set_cursor(CursorKind::Pointer); } - if let Some(v) = presp.value { - let next = ((0.5 + v * 1.0) * 20.0).round() / 20.0; - let clamped = next.clamp(0.5, 1.5); - if (clamped - *preamp).abs() >= 0.025 { - *preamp = clamped; + if sel_resp.clicked { + *dropdown_open = !*dropdown_open; + } + + if is_custom_or_modified { + let rst_r = Rect::from_xywh(sel_r.right() + 8.0, y, reset_w, 38.0); + let rst_resp = ctx.interact(WidgetId::new(salt).with("preset_rst"), rst_r); + ctx.dl().push_rect( + rst_r, + 12.0, + if rst_resp.hovered { + pal.surface_hover + } else { + pal.surface_secondary + }, + ); + ctx.draw_text_ellipsis( + if ru { "Сбросить" } else { "Reset" }, + TextStyle::medium(12.5, pal.text_primary), + rst_r, + TextAlign::Center, + ); + if rst_resp.hovered { + ctx.set_cursor(CursorKind::Pointer); + } + if rst_resp.clicked { + *bands = [0.0; 10]; *changed = true; + *dropdown_open = false; } } - ctx.draw_text_ellipsis( - if ru { "уровень" } else { "level" }, - TextStyle::regular(11.5, lbl_col), - Rect::from_xywh(area.left() - 4.0, y + sliders_h + 8.0, preamp_w + 8.0, 16.0), - TextAlign::Center, - ); - let scale_x = area.left() + preamp_w + 2.0; - let scale_w = 34.0; + y += 50.0; + + // 3. Left dB Scale (`+12 dB`, `0 dB`, `-12 dB`) + 10 Vertical Band Sliders (`9rem` = `144px`) + let scale_w = 42.0; + let sliders_h = 136.0; + let lbl_col = if *enabled { + pal.text_secondary + } else { + pal.text_disabled + }; ctx.draw_text_ellipsis( - "12dB", + "+12 dB", TextStyle::regular(11.0, lbl_col), - Rect::from_xywh(scale_x, y, scale_w, 16.0), + Rect::from_xywh(area.left(), y, scale_w, 16.0), TextAlign::Left, ); ctx.draw_text_ellipsis( - "0dB", + "0 dB", TextStyle::regular(11.0, lbl_col), - Rect::from_xywh(scale_x, y + sliders_h * 0.5 - 8.0, scale_w, 16.0), + Rect::from_xywh(area.left(), y + sliders_h * 0.5 - 8.0, scale_w, 16.0), TextAlign::Left, ); ctx.draw_text_ellipsis( - "-12dB", + "-12 dB", TextStyle::regular(11.0, lbl_col), - Rect::from_xywh(scale_x, y + sliders_h - 16.0, scale_w, 16.0), + Rect::from_xywh(area.left(), y + sliders_h - 16.0, scale_w, 16.0), TextAlign::Left, ); - // 3. 10 Frequency Sliders (`60`..`16k`) - let grid_x = scale_x + scale_w + 4.0; - let grid_w = (area.right() - grid_x).max(160.0); + let grid_x = area.left() + scale_w + 4.0; + let grid_w = (area.width() - scale_w - 4.0).max(160.0); + // Subtle 0 dB center reference line + ctx.dl().push_rect( + Rect::from_xywh(grid_x, (y + sliders_h * 0.5).round(), grid_w, 1.0), + 0.0, + pal.border_subtle, + ); + let col_w = grid_w / 10.0; + let fill_col = if *enabled { + pal.yellow + } else { + pal.text_disabled + }; for i in 0..10 { let bx = grid_x + i as f32 * col_w; - let sr = Rect::from_xywh(bx + 1.0, y, (col_w - 2.0).max(18.0), sliders_h); + let sr = Rect::from_xywh(bx + 2.0, y, (col_w - 4.0).max(18.0), sliders_h); let norm = ((bands[i] + 12.0) / 24.0).clamp(0.0, 1.0); - let sresp = eq_vertical_slider( + let sresp = ym_vertical_slider( ctx, pal, WidgetId::new(salt).with("band").with(i), sr, norm, - is_disabled, - interactive && expand_t > 0.85, - content_alpha, + false, + fill_col, ); if sresp.hovered || sresp.dragging { ctx.show_tooltip(sr, format!("{:+.1} dB", bands[i])); @@ -4271,148 +4143,75 @@ fn render_equalizer_body( let clamped = db.clamp(-12.0, 12.0); if (clamped - bands[i]).abs() >= 0.25 { bands[i] = clamped; + *enabled = true; *changed = true; } } ctx.draw_text_ellipsis( EQ_LABELS[i], - TextStyle::regular(11.5, lbl_col), - Rect::from_xywh(bx, y + sliders_h + 8.0, col_w, 16.0), + TextStyle::medium(11.0, lbl_col), + Rect::from_xywh(bx, y + sliders_h + 6.0, col_w, 16.0), TextAlign::Center, ); } - // 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; - 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) - } else { - Default::default() - }; - let sel_bg = if sel_resp.hovered { - pal.surface_hover - } else { - pal.surface_secondary - } - .with_alpha_f32(content_alpha); - ctx.dl().push_rect(sel_r, sel_h * 0.5, sel_bg); - 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); - 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()), - TextAlign::Left, - ); - ctx.draw_icon( - Icon::ArrowDown, - Rect::from_center_size(Pos2::new(sel_r.right() - 20.0, sel_r.center_y()), Vec2::splat(16.0)), - if is_disabled { - pal.text_disabled - } else { - pal.text_bright - } - .with_alpha_f32(content_alpha), - ); - if sel_resp.hovered { - ctx.set_cursor(CursorKind::Pointer); - } - if sel_resp.clicked { - *dropdown_open = !*dropdown_open; - } - - ctx.pop_clip(); - + // 4. Floating Presets Dropdown (`EqualizerPresets_container`) rendered ON TOP of sliders! if *dropdown_open { - Some((sel_r, sel_resp.clicked)) - } else { - None - } -} + let dd_h = 240.0f32.min((ctx.screen_rect().bottom() - sel_r.bottom() - 20.0).max(140.0)); + let dd_r = Rect::from_xywh(sel_r.left(), sel_r.bottom() + 6.0, sel_r.width(), dd_h); + ctx.register_blocker(dd_r); + ctx.dl() + .push_shadow(dd_r, 12.0, 20.0, 0.0, Vec2::new(0.0, 6.0), pal.shadow_menu); + ctx.dl() + .push_rect_bordered(dd_r, 12.0, pal.bg_popover, 1.0, pal.border_control); -/// Floating upward Equalizer Presets dropdown (`EqualizerPresets_container`, `placement: "top"`). -#[allow(clippy::too_many_arguments)] -fn render_eq_presets_dropdown( - ctx: &mut UiContext, - pal: &YmPalette, - sel_r: Rect, - parent_r: Rect, - ru: bool, - enabled: &mut bool, - preamp: &mut f32, - bands: &mut [f32; 10], - changed: &mut bool, - dropdown_open: &mut bool, - sel_clicked: bool, - salt: &str, -) -> Option { - let screen = ctx.screen_rect(); - let max_above = (sel_r.top() - screen.top() - 24.0).max(140.0); - let dd_h = 260.0f32.min(max_above); - let dd_r = Rect::from_xywh(sel_r.left(), (sel_r.top() - dd_h - 6.0).max(screen.top() + 12.0), sel_r.width(), dd_h); - ctx.register_blocker(dd_r); - ctx.dl() - .push_shadow(dd_r, 14.0, 20.0, 0.0, Vec2::new(0.0, 6.0), pal.shadow_menu); - ctx.dl() - .push_rect_bordered(dd_r, 14.0, pal.bg_popover, 1.0, pal.border_control); + let dd_scroll_id = WidgetId::new(salt).with("dd_scroll"); + let dd_inner = dd_r.shrink2(Vec2::new(6.0, 6.0)); + let scroll_y = ctx.begin_scroll_v(dd_scroll_id, dd_inner, 0.0); + let mut dy = dd_inner.top() - scroll_y; + let row_h = 36.0; + let cur_name = active_eq_preset_name(bands, ru); - let dd_scroll_id = WidgetId::new(salt).with("dd_scroll"); - let dd_inner = dd_r.shrink2(Vec2::new(6.0, 6.0)); - let scroll_y = ctx.begin_scroll_v(dd_scroll_id, dd_inner, 0.0); - let mut dy = dd_inner.top() - scroll_y; - let row_h = 36.0; - let cur_name = active_eq_preset_name(bands, ru); - - for (pi, preset) in EQ_PRESETS.iter().enumerate() { - let pname = preset.name(ru); - let rr = Rect::from_xywh(dd_inner.left(), dy, dd_inner.width() - 8.0, row_h); - let rresp = ctx.interact(WidgetId::new(salt).with("dd_item").with(pi), rr); - let is_cur = pname == cur_name; - if rresp.hovered { - ctx.dl().push_rect(rr, 8.0, pal.surface_hover); - ctx.set_cursor(CursorKind::Pointer); - } - ctx.draw_text_ellipsis( - pname, - TextStyle::medium(13.5, if is_cur { pal.text_bright } else { pal.text_primary }), - Rect::from_xywh(rr.left() + 12.0, rr.top(), rr.width() - 36.0, rr.height()), - TextAlign::Left, - ); - if is_cur { - ctx.draw_icon( - Icon::CheckXxs, - Rect::from_center_size(Pos2::new(rr.right() - 14.0, rr.center_y()), Vec2::splat(15.0)), - pal.yellow, - ); - } - if rresp.clicked { - *bands = preset.gains; - if pi == 0 { - *preamp = 1.0; + for (pi, preset) in EQ_PRESETS.iter().enumerate() { + let pname = preset.name(ru); + let rr = Rect::from_xywh(dd_inner.left(), dy, dd_inner.width() - 8.0, row_h); + let rresp = ctx.interact(WidgetId::new(salt).with("dd_item").with(pi), rr); + let is_cur = pname == cur_name; + if rresp.hovered { + ctx.dl().push_rect(rr, 8.0, pal.surface_hover); + ctx.set_cursor(CursorKind::Pointer); } - *enabled = true; - *changed = true; + ctx.draw_text_ellipsis( + pname, + TextStyle::medium(13.5, if is_cur { pal.text_bright } else { pal.text_primary }), + Rect::from_xywh(rr.left() + 10.0, rr.top(), rr.width() - 36.0, rr.height()), + TextAlign::Left, + ); + if is_cur { + ctx.draw_icon( + Icon::CheckXxs, + Rect::from_center_size(Pos2::new(rr.right() - 14.0, rr.center_y()), Vec2::splat(15.0)), + pal.yellow, + ); + } + if rresp.clicked { + *bands = preset.gains; + *enabled = true; + *changed = true; + *dropdown_open = false; + } + dy += row_h; + } + let total_dd_h = dy - (dd_inner.top() - scroll_y); + ctx.end_scroll_v(dd_scroll_id, pal, total_dd_h, true); + + if ctx.input.clicked_outside(dd_r) && !sel_resp.clicked { *dropdown_open = false; } - dy += row_h; + return Some(dd_r); } - let total_dd_h = dy - (dd_inner.top() - scroll_y); - ctx.end_scroll_v(dd_scroll_id, pal, total_dd_h, true); - if ctx.input.clicked_outside(dd_r) && !sel_clicked { - *dropdown_open = false; - if ctx.input.pointer_pos.map_or(false, |p| parent_r.contains(p)) { - ctx.input.consume_pointer_press(); - } - } - Some(dd_r) + None } /// 1-to-1 Official `ShortcutsModal` (`29c95960ed6ac633.css:137-238`, `settings/page.js:1076-1175`). @@ -4420,51 +4219,42 @@ pub fn render_shortcuts_modal( ctx: &mut UiContext, pal: &YmPalette, app: &AppState, - anim_t: f32, actions: &mut Vec, ) { let i18n = app.i18n(); let ru = i18n.is_ru(); - let open = app.shortcuts_modal_open; - let alpha = anim_t.clamp(0.0, 1.0); + let anim_t = if app.fixed_vibe_time.is_some() { + 1.0 + } else { + let raw = ctx.animate_bool(WidgetId::new("ym_shortcuts_modal_anim"), true, 0.18); + let u = 1.0 - raw; + 1.0 - u * u * u + }; let screen = ctx.screen_rect(); let modal_w = (screen.width() - 48.0).clamp(320.0, 430.0); let modal_h = (screen.height() - 84.0).clamp(320.0, 560.0); - let slide_dy = (1.0 - alpha) * 14.0; + let slide_dy = (1.0 - anim_t) * 14.0; let modal_r = Rect::from_center_size( Pos2::new(screen.center_x(), screen.center_y() + slide_dy), Vec2::new(modal_w, modal_h), ); ctx.with_layer(ZLayer::Modal, |ctx| { - if open { - ctx.register_blocker(screen); - } + ctx.register_blocker(screen); ctx.dl().push_rect( screen, 0.0, - Color::rgba(0, 0, 0, (150.0 * alpha).round() as u8), - ); - ctx.dl().push_shadow( - modal_r, - 16.0, - 32.0, - 0.0, - Vec2::new(0.0, 8.0), - pal.shadow_modal.with_alpha_f32(alpha), - ); - ctx.dl().push_rect_bordered( - modal_r, - 16.0, - pal.bg_popover.with_alpha_f32(alpha), - 1.0, - pal.border_subtle.with_alpha_f32(alpha), + Color::rgba(0, 0, 0, (150.0 * anim_t).round() as u8), ); + ctx.dl() + .push_shadow(modal_r, 16.0, 32.0, 0.0, Vec2::new(0.0, 8.0), pal.shadow_modal); + ctx.dl() + .push_rect_bordered(modal_r, 16.0, pal.bg_popover, 1.0, pal.border_subtle); 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)), + if ru { "Горячие клавиши" } else { "Keyboard shortcuts" }, + TextStyle::headline(20.0, pal.text_bright), Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 36.0, hdr_r.height()), TextAlign::Left, ); @@ -4562,7 +4352,7 @@ pub fn render_shortcuts_modal( let total_h = y - (scroll_r.top() - scroll_y); ctx.end_scroll_v(scroll_id, pal, total_h, true); - if open && ctx.input.consume_clicked_outside(modal_r) { + if ctx.input.clicked_outside(modal_r) { actions.push(AppAction::SetShortcutsModalOpen(false)); } }); @@ -4763,70 +4553,60 @@ pub fn render_release_notes_modal( ctx: &mut UiContext, pal: &YmPalette, app: &AppState, - anim_t: f32, actions: &mut Vec, ) { let i18n = app.i18n(); let ru = i18n.is_ru(); - let open = app.release_notes_modal_open; - let alpha = anim_t.clamp(0.0, 1.0); + let anim_t = if app.fixed_vibe_time.is_some() { + 1.0 + } else { + let raw = ctx.animate_bool(WidgetId::new("ym_release_notes_modal_anim"), true, 0.18); + let u = 1.0 - raw; + 1.0 - u * u * u + }; let screen = ctx.screen_rect(); let modal_w = (screen.width() - 48.0).clamp(320.0, 460.0); let modal_h = (screen.height() - 84.0).clamp(320.0, 500.0); - let slide_dy = (1.0 - alpha) * 14.0; + let slide_dy = (1.0 - anim_t) * 14.0; let modal_r = Rect::from_center_size( Pos2::new(screen.center_x(), screen.center_y() + slide_dy), Vec2::new(modal_w, modal_h), ); ctx.with_layer(ZLayer::Modal, |ctx| { - if open { - ctx.register_blocker(screen); - } + ctx.register_blocker(screen); ctx.dl().push_rect( screen, 0.0, - Color::rgba(0, 0, 0, (150.0 * alpha).round() as u8), - ); - ctx.dl().push_shadow( - modal_r, - 16.0, - 32.0, - 0.0, - Vec2::new(0.0, 8.0), - pal.shadow_modal.with_alpha_f32(alpha), - ); - ctx.dl().push_rect_bordered( - modal_r, - 16.0, - pal.bg_popover.with_alpha_f32(alpha), - 1.0, - pal.border_subtle.with_alpha_f32(alpha), + Color::rgba(0, 0, 0, (150.0 * anim_t).round() as u8), ); + ctx.dl() + .push_shadow(modal_r, 16.0, 32.0, 0.0, Vec2::new(0.0, 8.0), pal.shadow_modal); + ctx.dl() + .push_rect_bordered(modal_r, 16.0, pal.bg_popover, 1.0, pal.border_subtle); // 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), Rect::from_xywh(hdr_r.left(), hdr_r.top(), hdr_r.width() - 36.0, hdr_r.height()), TextAlign::Left, ); let close_r = Rect::from_xywh(hdr_r.right() - 32.0, hdr_r.top() + 1.0, 32.0, 32.0); - if open - && icon_button( - ctx, - WidgetId::new("rn_modal_close"), - close_r, - Icon::Close, - 16.0, - pal.text_secondary, - pal.text_bright, - pal.surface_hover, - false, - "", - ) - .clicked + if icon_button( + ctx, + WidgetId::new("rn_modal_close"), + close_r, + Icon::Close, + 16.0, + pal.text_secondary, + pal.text_bright, + pal.surface_hover, + false, + "", + ) + .clicked { actions.push(AppAction::CloseReleaseNotesModal); } @@ -5048,7 +4828,7 @@ pub fn render_release_notes_modal( let total_h = y - (scroll_r.top() - scroll_y); ctx.end_scroll_v(scroll_id, pal, total_h, true); - if open && ctx.input.consume_clicked_outside(modal_r) { + if ctx.input.clicked_outside(modal_r) { actions.push(AppAction::CloseReleaseNotesModal); } }); diff --git a/src/views/settings.rs b/src/views/settings.rs index 66b4b09..97b18aa 100644 --- a/src/views/settings.rs +++ b/src/views/settings.rs @@ -1,5 +1,6 @@ use crate::app::i18n::APP_VERSION; use crate::app::state::{AppAction, AppState}; +use crate::audio::dsp::active_eq_preset_name; use crate::config::{AudioQuality, Language, ThemeMode}; use crate::covers::CoverCache; use crate::engine::input::WidgetId; @@ -33,7 +34,7 @@ pub fn render_settings( // `views/mod.rs` already insets `inner_r` by (25, 12, 25, 0) let x = rect.left(); - let col_w = (rect.width() - 12.0).clamp(320.0, 482.0); + let col_w = (rect.width() - 12.0).clamp(320.0, 520.0); let mut y = rect.top() + 8.0 - scroll_y; // Page Heading @@ -175,53 +176,31 @@ pub fn render_settings( y += 18.0; // ------------------------------------------------------------------------- - // 2. Official Settings List (`Settings_root`, 32px vertical spacing) + // 2. Official Settings List (`Settings_root`, 24px vertical spacing) // ------------------------------------------------------------------------- - // 2a. Clear memory (`offline.clear-memory`) - if settings_button_item( - ctx, - pal, - WidgetId::new("set_clear_cache"), - x, - &mut y, - col_w, - if ru { "Очистить память" } else { "Clear cache" }, - Some(if ru { - "Удалим только скачанное и кэш. Это не повлияет на ваши рекомендации и лайки" - } else { - "We'll only delete downloaded content and cache. This won't affect your recommendations or likes" - }), - None, - ) { - actions.push(AppAction::ClearCoverCache); - } - - // 2b. Equalizer (`EqualizerModal` trigger — clean row, no status subtitle) - if settings_button_item( - ctx, - pal, - WidgetId::new("set_eq_btn"), - x, - &mut y, - col_w, - if ru { "Эквалайзер" } else { "Equalizer" }, - None, - None, - ) { - actions.push(AppAction::SetEqualizerModalOpen(true)); - } - - // 2c. Sound settings (`QualitySettingsModal` trigger) + // 2a. Sound quality (`QualitySettingsModal` trigger) let qual_sub = match app.config.audio_quality { AudioQuality::Lossless => { - if ru { "Превосходное" } else { "Superb" } + if ru { + "Максимальное · FLAC без потерь" + } else { + "Maximum · Lossless FLAC" + } } AudioQuality::High => { - if ru { "Оптимальное" } else { "Balanced" } + if ru { + "Оптимальное · 320 кбит/с" + } else { + "Optimal · 320 kbps" + } } AudioQuality::Standard => { - if ru { "Экономичное" } else { "Efficient" } + if ru { + "Экономичное" + } else { + "Efficient" + } } }; if settings_button_item( @@ -238,7 +217,34 @@ pub fn render_settings( actions.push(AppAction::SetEqPopoverOpen(true)); } - // 2d. Crossfade between tracks (toggle + optional duration override) + // 2b. Equalizer (`EqualizerModal` trigger) + let eq_sub = if app.config.eq_enabled { + let preset_name = active_eq_preset_name(&app.config.eq_bands_db, ru); + if ru { + format!("Включён · {}", preset_name) + } else { + format!("Enabled · {}", preset_name) + } + } else if ru { + "Выключен".to_string() + } else { + "Disabled".to_string() + }; + if settings_button_item( + ctx, + pal, + WidgetId::new("set_eq_btn"), + x, + &mut y, + col_w, + if ru { "Эквалайзер" } else { "Equalizer" }, + Some(&eq_sub), + None, + ) { + actions.push(AppAction::SetEqualizerModalOpen(true)); + } + + // 2c. Crossfade between tracks (toggle + optional duration override) let cf_sub = if app.config.crossfade_enabled { if app.config.crossfade_secs < 0.1 { if ru { @@ -386,6 +392,30 @@ pub fn render_settings( actions.push(AppAction::SetCloseToTray(next)); } + // 2h. Clear cover cache + let cache_sub = if ru { + format!("В кэше: {} обложек", covers.len()) + } else { + format!("Cached items: {}", covers.len()) + }; + if settings_button_item( + ctx, + pal, + WidgetId::new("set_clear_cache"), + x, + &mut y, + col_w, + if ru { + "Очистить кэш обложек" + } else { + "Clear cover cache" + }, + Some(&cache_sub), + None, + ) { + actions.push(AppAction::ClearCoverCache); + } + // 2i. Keyboard shortcuts (`ShortcutsModal` trigger) if settings_button_item( ctx, @@ -394,38 +424,17 @@ pub fn render_settings( x, &mut y, col_w, - if ru { "Горячие клавиши" } else { "Hot keys" }, + if ru { + "Горячие клавиши" + } else { + "Keyboard shortcuts" + }, None, None, ) { actions.push(AppAction::SetShortcutsModalOpen(true)); } - // 2j. About (`ReleaseNotesModal` trigger) - let about_sub = if let Some(ref upd) = app.available_update { - format!("v{} · {}", APP_VERSION, t.update_available_banner(&upd.version)) - } else { - format!("v{}", APP_VERSION) - }; - let about_badge_col = if app.available_update.is_some() { - Some(pal.yellow) - } else { - None - }; - if settings_button_item( - ctx, - pal, - WidgetId::new("set_about_btn"), - x, - &mut y, - col_w, - if ru { "О приложении" } else { "About the app" }, - Some(&about_sub), - about_badge_col, - ) { - actions.push(AppAction::OpenReleaseNotesModal); - } - // 2j. Appearance & Language (compact official pill selectors) ctx.draw_text_ellipsis( t.appearance(), @@ -487,9 +496,34 @@ pub fn render_settings( .push_rect(Rect::from_xywh(x, y, col_w, 1.0), 0.0, pal.border_subtle); y += 18.0; - ctx.dl() - .push_rect(Rect::from_xywh(x, y, col_w, 1.0), 0.0, pal.border_subtle); - y += 18.0; + // ------------------------------------------------------------------------- + // 3. About & Updates (`ReleaseNotesModal` + Update CTA) + // ------------------------------------------------------------------------- + let about_sub = if let Some(ref upd) = app.available_update { + format!("v{} · {}", APP_VERSION, t.update_available_banner(&upd.version)) + } else if ru { + format!("Версия {} · {}", APP_VERSION, t.up_to_date_badge()) + } else { + format!("Version {} · {}", APP_VERSION, t.up_to_date_badge()) + }; + let about_badge_col = if app.available_update.is_some() { + Some(pal.yellow) + } else { + None + }; + if settings_button_item( + ctx, + pal, + WidgetId::new("set_about_btn"), + x, + &mut y, + col_w, + if ru { "О приложении" } else { "About" }, + Some(&about_sub), + about_badge_col, + ) { + actions.push(AppAction::OpenReleaseNotesModal); + } if let Some(ref upd) = app.available_update { let banner_r = Rect::from_xywh(x, y - 6.0, col_w, 54.0); @@ -604,8 +638,8 @@ pub fn render_settings( } /// Official `SettingsListButtonItem` (`29c95960ed6ac633.css:74-119`): -/// Borderless row with NO hover background fill — 16px title, optional wrapped 14px description, -/// and right-aligned `arrowRight` chevron that glides +6px right on hover. +/// Borderless row with bold 16px title, optional 13px subtitle, and right-aligned `arrowRight` chevron +/// that glides +4px right on hover. #[allow(clippy::too_many_arguments)] fn settings_button_item( ctx: &mut UiContext, @@ -618,47 +652,44 @@ fn settings_button_item( description: Option<&str>, dot_color: Option, ) -> bool { - let text_w = (w - 36.0).max(100.0); - let desc_h = description.map_or(0.0, |d| { - ctx.measure_text(d, TextStyle::regular(14.0, pal.text_secondary), Some(text_w)) - .y - .max(18.0) - + 4.0 - }); - let row_h = (22.0 + desc_h).max(26.0); - let hit_r = Rect::from_xywh(x, *y - 2.0, w, row_h + 4.0); + let row_h = if description.is_some() { 44.0 } else { 28.0 }; + let hit_r = Rect::from_xywh(x - 8.0, *y - 4.0, w + 16.0, row_h + 8.0); let resp = ctx.interact(id, hit_r); - let hover_t = ctx.animate_bool(id.with("hov"), resp.hovered, 0.16); + let hover_t = ctx.animate_bool(id.with("hov"), resp.hovered, 0.14); if resp.hovered { ctx.set_cursor(CursorKind::Pointer); } + if hover_t > 0.01 { + ctx.dl() + .push_rect(hit_r, 10.0, pal.surface_hover.with_alpha_f32(hover_t * 0.5)); + } + let text_w = (w - 32.0).max(80.0); ctx.draw_text_ellipsis( title, - TextStyle::medium(16.0, pal.text_bright), + TextStyle::bold(16.0, pal.text_bright), Rect::from_xywh(x, *y, text_w, 22.0), TextAlign::Left, ); if let Some(desc) = description { - ctx.draw_text_wrapped( + ctx.draw_text_ellipsis( desc, - TextStyle::regular(14.0, pal.text_secondary), - Rect::from_xywh(x, *y + 24.0, text_w, desc_h), - None, + TextStyle::medium(13.0, pal.text_secondary), + Rect::from_xywh(x, *y + 23.0, text_w, 18.0), TextAlign::Left, ); } if let Some(dc) = dot_color { ctx.dl() - .push_circle(Pos2::new(x + w - 34.0, *y + 11.0), 4.0, dc); + .push_circle(Pos2::new(x + w - 34.0, *y + row_h * 0.5), 4.0, dc); } - let chev_x = x + w - 12.0 + hover_t * 6.0; + let chev_x = x + w - 12.0 + hover_t * 4.0; ctx.draw_icon( Icon::MenuArrowXxs, - Rect::from_center_size(Pos2::new(chev_x, *y + 11.0), Vec2::splat(16.0)), + Rect::from_center_size(Pos2::new(chev_x, *y + row_h * 0.5), Vec2::splat(16.0)), if resp.hovered { pal.text_bright } else { @@ -666,12 +697,12 @@ fn settings_button_item( }, ); - *y += row_h + 28.0; + *y += row_h + 20.0; resp.clicked } /// Official `SettingsListToggleItem` (`29c95960ed6ac633.css:120-136`): -/// Borderless row with 16px title, optional wrapped 14px description, and right-aligned pill toggle. +/// Borderless row with bold 16px title, optional wrapped 13px subtitle, and right-aligned pill toggle. #[allow(clippy::too_many_arguments)] fn settings_toggle_item( ctx: &mut UiContext, @@ -686,37 +717,37 @@ fn settings_toggle_item( ) -> Option { let text_w = (w - 60.0).max(100.0); let desc_h = description.map_or(0.0, |d| { - ctx.measure_text(d, TextStyle::regular(14.0, pal.text_secondary), Some(text_w)) + ctx.measure_text(d, TextStyle::medium(13.0, pal.text_secondary), Some(text_w)) .y .max(18.0) + 4.0 }); - let row_h = (22.0 + desc_h).max(26.0); - let hit_r = Rect::from_xywh(x, *y - 2.0, w, row_h + 4.0); + let row_h = (22.0 + desc_h).max(28.0); + let hit_r = Rect::from_xywh(x - 8.0, *y - 4.0, w + 16.0, row_h + 8.0); let resp = ctx.interact(id, hit_r); - let anim = ctx.animate_bool(id.with("tog"), checked, 0.16); + let anim = ctx.animate_bool(id.with("tog"), checked, 0.18); ctx.draw_text_ellipsis( title, - TextStyle::medium(16.0, pal.text_bright), + TextStyle::bold(16.0, pal.text_bright), Rect::from_xywh(x, *y, text_w, 22.0), TextAlign::Left, ); if let Some(desc) = description { ctx.draw_text_wrapped( desc, - TextStyle::regular(14.0, pal.text_secondary), + TextStyle::medium(13.0, pal.text_secondary), Rect::from_xywh(x, *y + 24.0, text_w, desc_h), None, TextAlign::Left, ); } - let sw_w = 44.0; + let sw_w = 42.0; let sw_h = 24.0; let sw_r = Rect::from_xywh( x + w - sw_w, - *y + (row_h - sw_h) * 0.5, + *y + 11.0 - sw_h * 0.5, sw_w, sw_h, ); @@ -730,12 +761,12 @@ fn settings_toggle_item( pal.text_bright }; ctx.dl() - .push_circle(Pos2::new(knob_x, sw_r.center_y()), 9.0, knob_col); + .push_circle(Pos2::new(knob_x, sw_r.center_y()), 8.5, knob_col); if resp.hovered { ctx.set_cursor(CursorKind::Pointer); } - *y += row_h + 28.0; + *y += row_h + 20.0; if resp.clicked { Some(!checked) } else { diff --git a/tests/parity_extended.rs b/tests/parity_extended.rs index aee1250..ea89e0c 100644 --- a/tests/parity_extended.rs +++ b/tests/parity_extended.rs @@ -2568,13 +2568,11 @@ fn test_ext_19_official_settings_sound_quality_equalizer_and_shortcuts_modals() 0.0, ); shell.app.config.eq_enabled = true; - shell.app.config.eq_preamp = 1.15; shell.app.eq_popover_open = true; let _ = render_single_frame(&mut vk, &mut shell, 0.0); let img_qs = render_single_frame(&mut vk, &mut shell, 0.016); assert!(img_qs.width() == NATIVE_W && img_qs.height() == NATIVE_H); - shell.app.config.eq_enabled = false; shell.app.eq_popover_open = false; shell.app.equalizer_modal_open = true; let img_eq = render_single_frame(&mut vk, &mut shell, 0.032);