diff --git a/crates/client/src/gui/call_bar.rs b/crates/client/src/gui/call_bar.rs index 68f768a..7e22dae 100644 --- a/crates/client/src/gui/call_bar.rs +++ b/crates/client/src/gui/call_bar.rs @@ -37,6 +37,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, } @@ -80,6 +82,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 { @@ -92,6 +95,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 5295e08..ff7a7d9 100644 --- a/crates/client/src/gui/dock.rs +++ b/crates/client/src/gui/dock.rs @@ -85,6 +85,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 971136f..92cf7a7 100644 --- a/crates/client/src/gui/gallery.rs +++ b/crates/client/src/gui/gallery.rs @@ -352,6 +352,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 cef1274..a55de7c 100644 --- a/crates/client/src/gui/parts.rs +++ b/crates/client/src/gui/parts.rs @@ -323,6 +323,21 @@ pub fn popover(t: Tokens) -> Div { .py(px(space::LG + 2.)) } +pub fn quick(t: Tokens) -> Div { + popover(t).w(px(size::SHEET)).gap(px(space::SM)) +} + +pub fn quick_row(label: &'static str, control: impl IntoElement, t: Tokens) -> Div { + band(space::MD) + .min_h(px(size::CONTROL)) + .child( + words(label, Text::Label, Ink::Faint, t) + .w(px(size::ROW + space::XL)) + .flex_none(), + ) + .child(div().flex_1().min_w_0().child(control)) +} + pub fn scrim(t: Tokens) -> Div { band(space::SM) .h(px(size::CONTROL_SM)) diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index fe7a238..4c42129 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -886,16 +886,9 @@ fn settings_card(entity: &Entity, yumush: &Yumush, palette: Palette) -> let (resolutions, fps) = options(&modes, top.resolution, max_height); let screen = kind == Kind::Screen; - div() - .w(px(size::POPOVER)) - .p(px(space::MD)) - .flex() - .flex_col() - .gap(px(space::MD)) - .text_size(text(text::CAPTION)) - .rounded(px(radius::LG)) - .bg(palette.field) - .child(field( + let t = palette.tokens; + super::parts::quick(t) + .child(super::parts::quick_row( "Resolution", segmented( RESOLUTIONS @@ -906,9 +899,9 @@ fn settings_card(entity: &Entity, yumush: &Yumush, palette: Palette) -> palette, Yumush::set_share_resolution, ), - palette, + t, )) - .child(field( + .child(super::parts::quick_row( "FPS", segmented( FPS.into_iter().filter(|(value, _)| fps.contains(value)), @@ -917,9 +910,9 @@ fn settings_card(entity: &Entity, yumush: &Yumush, palette: Palette) -> palette, Yumush::set_share_fps, ), - palette, + t, )) - .child(field( + .child(super::parts::quick_row( "Codec", segmented( CODECS.into_iter().filter(|(codec, _)| match codec { @@ -931,10 +924,10 @@ fn settings_card(entity: &Entity, yumush: &Yumush, palette: Palette) -> palette, Yumush::set_share_codec, ), - palette, + t, )) .when(screen, |this| { - this.child(field( + this.child(super::parts::quick_row( "Audio", segmented( AudioMode::ALL, @@ -943,7 +936,7 @@ fn settings_card(entity: &Entity, yumush: &Yumush, palette: Palette) -> palette, Yumush::set_share_audio_mode, ), - palette, + t, )) .children(audio_list(entity, yumush, palette)) }) diff --git a/crates/client/src/gui/voice_settings.rs b/crates/client/src/gui/voice_settings.rs index 0a4a4a3..1870e07 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,87 @@ 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 t = palette.tokens; + 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, + ), + }; + super::parts::quick(t) + .child(audio_line(yumush, side, t)) + .child(super::parts::quick_row( + "Device", + Select::new(devices).appearance(false).w_full(), + t, + )) + .child(super::parts::quick_row( + "Volume", + volume_control(volume, value, palette), + t, + )) +} + +fn audio_line(yumush: &Yumush, side: Side, t: super::style::Tokens) -> Div { + let me = yumush.user.as_ref().map(|user| user.id); + let heard: Vec = yumush + .chat + .voice_community() + .map(|community_id| yumush.chat.voice_ids(community_id).to_vec()) + .unwrap_or_default() + .into_iter() + .filter(|id| (Some(*id) == me) == (side == Side::Input)) + .collect(); + let speaking = heard + .iter() + .any(|id| yumush.chat.waves.speaking.contains(id)); + let hue = match (side, me) { + (Side::Input, Some(me)) => t.person(me), + _ => t.paper(), + }; + let voice = if speaking { + super::parts::Voice::Live(hue) + } else { + super::parts::Voice::Quiet + }; + div().h(px(size::ICON)).child(super::parts::voice_line( + yumush.chat.waves.total(&heard).as_ref(), + voice, + t, + )) +}