From 31ab094d6cc3dd5d69cc4937dba8cc7492690e4a 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:07:35 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20mic=20and=20speaker=20chevr?= =?UTF-8?q?ons=20in=20the=20call=20bar=20open=20device=20select=20and=20vo?= =?UTF-8?q?lume=20(up=20to=20200%)=20popovers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/gui/call_bar.rs | 4 ++ crates/client/src/gui/dock.rs | 6 +++ crates/client/src/gui/gallery.rs | 2 + crates/client/src/gui/parts.rs | 8 +++- crates/client/src/gui/voice_settings.rs | 63 +++++++++++++++++++++++-- crates/client/src/lib.rs | 4 +- 6 files changed, 78 insertions(+), 9 deletions(-) diff --git a/crates/client/src/gui/call_bar.rs b/crates/client/src/gui/call_bar.rs index f33542a..3718dd1 100644 --- a/crates/client/src/gui/call_bar.rs +++ b/crates/client/src/gui/call_bar.rs @@ -36,6 +36,8 @@ 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, } @@ -73,6 +75,7 @@ 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 { @@ -85,6 +88,7 @@ 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), diff --git a/crates/client/src/gui/dock.rs b/crates/client/src/gui/dock.rs index 31e4ffd..1c8aed6 100644 --- a/crates/client/src/gui/dock.rs +++ b/crates/client/src/gui/dock.rs @@ -78,6 +78,12 @@ 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 fb4e7dc..4aff14a 100644 --- a/crates/client/src/gui/gallery.rs +++ b/crates/client/src/gui/gallery.rs @@ -347,6 +347,8 @@ 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 ddbce1f..3a84c40 100644 --- a/crates/client/src/gui/parts.rs +++ b/crates/client/src/gui/parts.rs @@ -426,8 +426,12 @@ fn merge(levels: &[f32], count: usize) -> Vec { (0..count) .map(|index| { let from = index * levels.len() / count; - let to = ((index + 1) * levels.len() / count).max(from + 1).min(levels.len()); - levels.get(from..to).map_or(0., |part| part.iter().copied().fold(0., f32::max)) + let to = ((index + 1) * levels.len() / count) + .max(from + 1) + .min(levels.len()); + levels + .get(from..to) + .map_or(0., |part| part.iter().copied().fold(0., f32::max)) }) .collect() } diff --git a/crates/client/src/gui/voice_settings.rs b/crates/client/src/gui/voice_settings.rs index 0a4a4a3..eba7c10 100644 --- a/crates/client/src/gui/voice_settings.rs +++ b/crates/client/src/gui/voice_settings.rs @@ -1,13 +1,14 @@ use std::time::Duration; use gpui_kit::{ - App, AppContext, Context, Div, Entity, IntoElement, KeyDownEvent, KeyUpEvent, Keystroke, - ModifiersChangedEvent, ParentElement, SharedString, Stateful, Styled, Subscription, Task, - Window, + Anchor, App, AppContext, Context, Div, Entity, InteractiveElement, IntoElement, KeyDownEvent, + KeyUpEvent, Keystroke, ModifiersChangedEvent, MouseButton, 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}, @@ -16,7 +17,7 @@ use gpui_kit::{ }; use super::{ - Palette, Yumush, clickable, + Palette, Tooltip as _, Trigger, Yumush, clickable, settings_page::{row, segmented}, style::{radius, size, space}, }; @@ -516,7 +517,7 @@ impl Yumush { })); } - fn load_audio_devices(&self, window: &mut Window, cx: &mut Context) { + pub(super) fn load_audio_devices(&self, window: &mut Window, cx: &mut Context) { cx.spawn_in(window, async move |this, cx| { let devices = cx .background_executor() @@ -559,3 +560,55 @@ 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/lib.rs b/crates/client/src/lib.rs index d935aaf..b37f533 100644 --- a/crates/client/src/lib.rs +++ b/crates/client/src/lib.rs @@ -77,8 +77,8 @@ impl Server { .and_then(|config| config.get("server_address")) .expect("client config server_address") }); - let any_cert = std::env::var_os("YUMUSH_ANY_CERT").is_some() - || lines.next() == Some("any_cert"); + let any_cert = + std::env::var_os("YUMUSH_ANY_CERT").is_some() || lines.next() == Some("any_cert"); Self { address, any_cert } }