From 397f10bc21e00ed39f3bdfe74f9e1d76bec5968b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 28 Nov 2026 02:14:09 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20style:=20drop=20mic/speaker=20po?= =?UTF-8?q?povers;=20spectrum=20without=20high=20tilt=20and=20floor=20-48?= =?UTF-8?q?=20dB=20so=20quiet=20highs=20stay=20flat,=20half=20the=20stroke?= =?UTF-8?q?s;=20voice=20and=20share=20lines=20split=20the=20bar=20equally;?= =?UTF-8?q?=20ping=20has=20a=20fixed=20slot=20so=20the=20bar=20stops=20mov?= =?UTF-8?q?ing;=20=E2=9C=A8=20feat:=20ping=20history=20line=20next=20to=20?= =?UTF-8?q?the=20ping?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/gui/call_bar.rs | 63 ++++++++++++++++--------- crates/client/src/gui/dock.rs | 14 +++--- crates/client/src/gui/gallery.rs | 10 ++-- crates/client/src/gui/parts.rs | 4 +- crates/client/src/gui/voice_settings.rs | 63 ++----------------------- crates/client/src/gui/voice_stats.rs | 2 +- crates/spectrum/src/lib.rs | 17 ++----- 7 files changed, 64 insertions(+), 109 deletions(-) diff --git a/crates/client/src/gui/call_bar.rs b/crates/client/src/gui/call_bar.rs index 3718dd1..ea1d153 100644 --- a/crates/client/src/gui/call_bar.rs +++ b/crates/client/src/gui/call_bar.rs @@ -18,7 +18,7 @@ pub struct CallBar { pub place: SharedString, pub bands: Option>, pub voice: Voice, - pub ping: Option, + pub pings: Vec, pub muted: bool, pub deafened: bool, pub camera: bool, @@ -36,8 +36,6 @@ pub struct CallActions { pub screen: Action, pub leave: Action, pub stats: Action, - pub mic_more: AnyElement, - pub speaker_more: AnyElement, pub camera_more: AnyElement, pub screen_more: AnyElement, } @@ -57,8 +55,14 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { } else { Ink::Faint }; + let pings = bar + .pings + .iter() + .map(|ping| (ping / super::voice_stats::PING_SCALE).clamp(0., 1.)) + .collect(); let ping = bar - .ping + .pings + .last() .map_or_else(|| "–".to_string(), |ping| format!("{ping:.0} ms")); let stats = run(&actions.stats); let controls = band(space::XS) @@ -75,7 +79,6 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { t, run(&actions.mute), )) - .child(actions.mic_more) .child(icon_button( format!("bar_deafen_{}", bar.deafened), if bar.deafened { @@ -88,7 +91,6 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { t, run(&actions.deafen), )) - .child(actions.speaker_more) .when(!bar.ghost, |row| { row.child(icon_button( format!("bar_camera_{}", bar.camera), @@ -173,16 +175,33 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { ) .child( div() - .id("bar_ping") - .tip("Connection stats") - .cursor_pointer() .flex_none() - .when(bar.stats, |ping| { - ping.border_b(px(super::style::stroke::LINE)) - .border_color(t.paper()) - }) - .on_click(move |_, window, cx| stats(window, cx)) - .child(words(ping, Text::Label, ping_ink, t)), + .w(px(size::ROW)) + .h(px(size::ICON)) + .child(super::parts::spark( + pings, + super::voice_stats::SAMPLE_HISTORY, + ping_ink.color(t), + )), + ) + .child( + div() + .flex_none() + .w(px(size::ROW)) + .flex() + .justify_end() + .child( + div() + .id("bar_ping") + .tip("Connection stats") + .cursor_pointer() + .when(bar.stats, |ping| { + ping.border_b(px(super::style::stroke::LINE)) + .border_color(t.paper()) + }) + .on_click(move |_, window, cx| stats(window, cx)) + .child(words(ping, Text::Label, ping_ink, t)), + ), ) .child(controls), ) @@ -190,15 +209,17 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { pub fn share_meter(bands: Option<&VecDeque>, color: gpui_kit::Hsla, t: Tokens) -> Div { band(space::XS) - .flex_none() + .flex_1() + .min_w(px(size::CONTROL)) .child( gpui_kit::component::Icon::new(IconName::ScreenShare) .size(px(size::ICON_SM)) .text_color(t.faint()), ) - .child(div().w(px(size::THUMB)).h(px(size::ICON)).child(voice_line( - bands, - Voice::Live(color), - t, - ))) + .child( + div() + .flex_1() + .h(px(size::ICON)) + .child(voice_line(bands, Voice::Live(color), t)), + ) } diff --git a/crates/client/src/gui/dock.rs b/crates/client/src/gui/dock.rs index 1c8aed6..8a4c0db 100644 --- a/crates/client/src/gui/dock.rs +++ b/crates/client/src/gui/dock.rs @@ -40,7 +40,13 @@ impl Yumush { place: super::community_name(community).to_string().into(), bands: self.chat.waves.voice(me).cloned(), voice, - ping: self.chat.stats.voice.back().map(|sample| sample.ping_ms), + pings: self + .chat + .stats + .voice + .iter() + .map(|sample| sample.ping_ms) + .collect(), muted, deafened, camera: self.network.share_source(Kind::Camera).is_some(), @@ -78,12 +84,6 @@ impl Yumush { yumush.toggle_stats(super::chat::StatsAt::Dock); cx.notify(); })), - mic_more: self - .audio_button(entity, palette, super::voice_settings::Side::Input, cx) - .into_any_element(), - speaker_more: self - .audio_button(entity, palette, super::voice_settings::Side::Output, cx) - .into_any_element(), camera_more: self .share_settings_button(entity, palette, Kind::Camera, cx) .into_any_element(), diff --git a/crates/client/src/gui/gallery.rs b/crates/client/src/gui/gallery.rs index 4aff14a..b462692 100644 --- a/crates/client/src/gui/gallery.rs +++ b/crates/client/src/gui/gallery.rs @@ -325,10 +325,10 @@ fn call_page(state: State, t: Tokens) -> impl IntoElement { State::Empty => Voice::Quiet, _ => Voice::Live(t.hue(Hue::Amber)), }, - ping: match state { - State::Empty => None, - State::Bad => Some(212.), - _ => Some(24.), + pings: match state { + State::Empty => Vec::new(), + State::Bad => vec![40., 90., 160., 212.], + _ => vec![22., 30., 24., 26., 24.], }, muted: bad, deafened: false, @@ -347,8 +347,6 @@ fn call_page(state: State, t: Tokens) -> impl IntoElement { screen: none(), leave: none(), stats: none(), - mic_more: super::parts::chevron_face(false, t).into_any_element(), - speaker_more: super::parts::chevron_face(false, t).into_any_element(), camera_more: super::parts::chevron_face(false, t).into_any_element(), screen_more: super::parts::chevron_face(false, t).into_any_element(), }; diff --git a/crates/client/src/gui/parts.rs b/crates/client/src/gui/parts.rs index 3a84c40..cef1274 100644 --- a/crates/client/src/gui/parts.rs +++ b/crates/client/src/gui/parts.rs @@ -41,7 +41,7 @@ pub enum Ink { } impl Ink { - fn color(self, t: Tokens) -> Hsla { + pub fn color(self, t: Tokens) -> Hsla { match self { Ink::Paper => t.paper(), Ink::Dim => t.dim(), @@ -368,7 +368,7 @@ pub enum Voice { const STILL: f32 = 0.02; const EDGE: f32 = 16.; -const PEAK_SPACING: f32 = 5.; +const PEAK_SPACING: f32 = 10.; const MIN_PEAKS: usize = 6; pub fn voice_line(bands: Option<&VecDeque>, voice: Voice, t: Tokens) -> AnyElement { diff --git a/crates/client/src/gui/voice_settings.rs b/crates/client/src/gui/voice_settings.rs index eba7c10..0a4a4a3 100644 --- a/crates/client/src/gui/voice_settings.rs +++ b/crates/client/src/gui/voice_settings.rs @@ -1,14 +1,13 @@ use std::time::Duration; use gpui_kit::{ - Anchor, App, AppContext, Context, Div, Entity, InteractiveElement, IntoElement, KeyDownEvent, - KeyUpEvent, Keystroke, ModifiersChangedEvent, MouseButton, ParentElement, SharedString, - Stateful, Styled, Subscription, Task, Window, + App, AppContext, Context, Div, Entity, IntoElement, KeyDownEvent, KeyUpEvent, Keystroke, + ModifiersChangedEvent, ParentElement, SharedString, Stateful, Styled, Subscription, Task, + Window, assets::IconName, component::{ Icon, IndexPath, kbd::Kbd, - popover::Popover, searchable_list::{SearchableListItem, SearchableVec}, select::{Select, SelectEvent, SelectState}, slider::{SliderEvent, SliderState}, @@ -17,7 +16,7 @@ use gpui_kit::{ }; use super::{ - Palette, Tooltip as _, Trigger, Yumush, clickable, + Palette, Yumush, clickable, settings_page::{row, segmented}, style::{radius, size, space}, }; @@ -517,7 +516,7 @@ impl Yumush { })); } - pub(super) fn load_audio_devices(&self, window: &mut Window, cx: &mut Context) { + fn load_audio_devices(&self, window: &mut Window, cx: &mut Context) { cx.spawn_in(window, async move |this, cx| { let devices = cx .background_executor() @@ -560,55 +559,3 @@ fn test_button( .font_weight(gpui_kit::FontWeight::MEDIUM) .text_color(if active { palette.text } else { palette.muted }) } - -impl Yumush { - pub(super) fn audio_button( - &self, - entity: &Entity, - palette: Palette, - side: Side, - cx: &App, - ) -> impl IntoElement { - let (id, button, tip) = match side { - Side::Input => ("mic_settings", "mic_settings_button", "Microphone"), - Side::Output => ("speaker_settings", "speaker_settings_button", "Speaker"), - }; - let refresh = entity.clone(); - let content = entity.clone(); - Popover::new(id) - .anchor(Anchor::BottomRight) - .appearance(false) - .trigger(Trigger::new( - super::parts::chevron_face(false, super::style::Tokens::of(cx)) - .id(button) - .on_mouse_down(MouseButton::Left, move |_, window, cx| { - refresh.update(cx, |yumush, cx| yumush.load_audio_devices(window, cx)); - }) - .tip(tip), - )) - .content(move |_, _, cx| audio_card(content.read(cx), side, palette)) - } -} - -fn audio_card(yumush: &Yumush, side: Side, palette: Palette) -> Div { - let voice = &yumush.settings.voice; - let controls = &yumush.voice; - let (devices, volume, value) = match side { - Side::Input => (&controls.inputs, &controls.input_volume, voice.input_volume), - Side::Output => ( - &controls.outputs, - &controls.output_volume, - voice.output_volume, - ), - }; - div() - .w(px(size::POPOVER)) - .p(px(space::MD)) - .flex() - .flex_col() - .gap(px(space::MD)) - .rounded(px(radius::LG)) - .bg(palette.field) - .child(Select::new(devices).appearance(false).w_full()) - .child(volume_control(volume, value, palette)) -} diff --git a/crates/client/src/gui/voice_stats.rs b/crates/client/src/gui/voice_stats.rs index 81709bd..d3afd74 100644 --- a/crates/client/src/gui/voice_stats.rs +++ b/crates/client/src/gui/voice_stats.rs @@ -24,7 +24,7 @@ pub const SAMPLE_HISTORY: usize = 60; const LABEL_W: f32 = size::ROW * 2.; const VALUE_W: f32 = size::THUMB; const COLUMN_W: f32 = size::TALK + size::ROW * 2.; -const PING_SCALE: f32 = 150.; +pub const PING_SCALE: f32 = 150.; pub(super) const GOOD_LOSS: f32 = 2.; const FAIR_LOSS: f32 = 8.; diff --git a/crates/spectrum/src/lib.rs b/crates/spectrum/src/lib.rs index 691fd22..2130b07 100644 --- a/crates/spectrum/src/lib.rs +++ b/crates/spectrum/src/lib.rs @@ -7,9 +7,7 @@ pub const BANDS: usize = 32; pub const WINDOW: usize = 2048; const LOW_HZ: f32 = 60.0; const HIGH_HZ: f32 = 12000.0; -const TILT_DB_PER_OCTAVE: f32 = 3.0; -const TILT_PIVOT_HZ: f32 = 1000.0; -const FLOOR_DB: f32 = -60.0; +const FLOOR_DB: f32 = -48.0; const CEIL_DB: f32 = -12.0; pub struct Analyzer { @@ -17,7 +15,6 @@ pub struct Analyzer { hann: Vec, gain: f32, edges: Vec, - tilts: Vec, } impl Analyzer { @@ -33,14 +30,7 @@ impl Analyzer { let previous = edges.last().map_or(0, |edge| edge + 1); edges.push(bin(hz).max(previous).min(WINDOW / 2)); } - let tilts = (0..BANDS) - .map(|band| { - let hz = LOW_HZ * (HIGH_HZ / LOW_HZ).powf((band as f32 + 0.5) / BANDS as f32); - TILT_DB_PER_OCTAVE * (hz / TILT_PIVOT_HZ).log2() - }) - .collect(); Self { - tilts, fft: FftPlanner::new().plan_fft_forward(WINDOW), hann, gain, @@ -58,13 +48,12 @@ impl Analyzer { self.fft.process(&mut buffer); self.edges .windows(2) - .zip(&self.tilts) - .map(|(edge, tilt)| { + .map(|edge| { let peak = buffer[edge[0]..edge[1].max(edge[0] + 1)] .iter() .map(|value| value.norm() * self.gain) .fold(0.0, f32::max); - let db = 20.0 * peak.max(1e-6).log10() + tilt; + let db = 20.0 * peak.max(1e-6).log10(); ((db - FLOOR_DB) / (CEIL_DB - FLOOR_DB)).clamp(0.0, 1.0) }) .collect()