forge
Explore
Log in

Don't you dare go Hollow

Mic and speaker chevrons in the call bar open device select and volume (up to 200%) popovers

Browse files at this commit

31ab094d6cc3dd5d69cc4937dba8cc7492690e4aAhmet Kaan GümüşParent: 776d19a
  • feat
    • mic and speaker chevrons in the call bar open device select and volume (up to 200%) popovers
Show full message
✨ feat: mic and speaker chevrons in the call bar open device select and volume (up to 200%) popovers
crates/client/src/gui/call_bar.rsmodified+4 -0
@@ -36,6 +36,8 @@ pub struct CallActions {
36 pub screen: Action,36 pub screen: Action,
37 pub leave: Action,37 pub leave: Action,
38 pub stats: Action,38 pub stats: Action,
39+ pub mic_more: AnyElement,
40+ pub speaker_more: AnyElement,
39 pub camera_more: AnyElement,41 pub camera_more: AnyElement,
40 pub screen_more: AnyElement,42 pub screen_more: AnyElement,
41 }43 }
@@ -73,6 +75,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div {
73 t,75 t,
74 run(&actions.mute),76 run(&actions.mute),
75 ))77 ))
78+ .child(actions.mic_more)
76 .child(icon_button(79 .child(icon_button(
77 format!("bar_deafen_{}", bar.deafened),80 format!("bar_deafen_{}", bar.deafened),
78 if bar.deafened {81 if bar.deafened {
@@ -85,6 +88,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div {
85 t,88 t,
86 run(&actions.deafen),89 run(&actions.deafen),
87 ))90 ))
91+ .child(actions.speaker_more)
88 .when(!bar.ghost, |row| {92 .when(!bar.ghost, |row| {
89 row.child(icon_button(93 row.child(icon_button(
90 format!("bar_camera_{}", bar.camera),94 format!("bar_camera_{}", bar.camera),
crates/client/src/gui/dock.rsmodified+6 -0
@@ -78,6 +78,12 @@ impl Yumush {
78 yumush.toggle_stats(super::chat::StatsAt::Dock);78 yumush.toggle_stats(super::chat::StatsAt::Dock);
79 cx.notify();79 cx.notify();
80 })),80 })),
81+ mic_more: self
82+ .audio_button(entity, palette, super::voice_settings::Side::Input, cx)
83+ .into_any_element(),
84+ speaker_more: self
85+ .audio_button(entity, palette, super::voice_settings::Side::Output, cx)
86+ .into_any_element(),
81 camera_more: self87 camera_more: self
82 .share_settings_button(entity, palette, Kind::Camera, cx)88 .share_settings_button(entity, palette, Kind::Camera, cx)
83 .into_any_element(),89 .into_any_element(),
crates/client/src/gui/gallery.rsmodified+2 -0
@@ -347,6 +347,8 @@ fn call_page(state: State, t: Tokens) -> impl IntoElement {
347 screen: none(),347 screen: none(),
348 leave: none(),348 leave: none(),
349 stats: none(),349 stats: none(),
350+ mic_more: super::parts::chevron_face(false, t).into_any_element(),
351+ speaker_more: super::parts::chevron_face(false, t).into_any_element(),
350 camera_more: super::parts::chevron_face(false, t).into_any_element(),352 camera_more: super::parts::chevron_face(false, t).into_any_element(),
351 screen_more: super::parts::chevron_face(false, t).into_any_element(),353 screen_more: super::parts::chevron_face(false, t).into_any_element(),
352 };354 };
crates/client/src/gui/parts.rsmodified+6 -2
@@ -426,8 +426,12 @@ fn merge(levels: &[f32], count: usize) -> Vec<f32> {
426 (0..count)426 (0..count)
427 .map(|index| {427 .map(|index| {
428 let from = index * levels.len() / count;428 let from = index * levels.len() / count;
429- let to = ((index + 1) * levels.len() / count).max(from + 1).min(levels.len());429+ let to = ((index + 1) * levels.len() / count)
430- levels.get(from..to).map_or(0., |part| part.iter().copied().fold(0., f32::max))430+ .max(from + 1)
431+ .min(levels.len());
432+ levels
433+ .get(from..to)
434+ .map_or(0., |part| part.iter().copied().fold(0., f32::max))
431 })435 })
432 .collect()436 .collect()
433 }437 }
crates/client/src/gui/voice_settings.rsmodified+58 -5
@@ -1,13 +1,14 @@
1 use std::time::Duration;1 use std::time::Duration;
2 2
3 use gpui_kit::{3 use gpui_kit::{
4- App, AppContext, Context, Div, Entity, IntoElement, KeyDownEvent, KeyUpEvent, Keystroke,4+ Anchor, App, AppContext, Context, Div, Entity, InteractiveElement, IntoElement, KeyDownEvent,
5- ModifiersChangedEvent, ParentElement, SharedString, Stateful, Styled, Subscription, Task,5+ KeyUpEvent, Keystroke, ModifiersChangedEvent, MouseButton, ParentElement, SharedString,
6- Window,6+ Stateful, Styled, Subscription, Task, Window,
7 assets::IconName,7 assets::IconName,
8 component::{8 component::{
9 Icon, IndexPath,9 Icon, IndexPath,
10 kbd::Kbd,10 kbd::Kbd,
11+ popover::Popover,
11 searchable_list::{SearchableListItem, SearchableVec},12 searchable_list::{SearchableListItem, SearchableVec},
12 select::{Select, SelectEvent, SelectState},13 select::{Select, SelectEvent, SelectState},
13 slider::{SliderEvent, SliderState},14 slider::{SliderEvent, SliderState},
@@ -16,7 +17,7 @@ use gpui_kit::{
16 };17 };
17 18
18 use super::{19 use super::{
19- Palette, Yumush, clickable,20+ Palette, Tooltip as _, Trigger, Yumush, clickable,
20 settings_page::{row, segmented},21 settings_page::{row, segmented},
21 style::{radius, size, space},22 style::{radius, size, space},
22 };23 };
@@ -516,7 +517,7 @@ impl Yumush {
516 }));517 }));
517 }518 }
518 519
519- fn load_audio_devices(&self, window: &mut Window, cx: &mut Context<Self>) {520+ pub(super) fn load_audio_devices(&self, window: &mut Window, cx: &mut Context<Self>) {
520 cx.spawn_in(window, async move |this, cx| {521 cx.spawn_in(window, async move |this, cx| {
521 let devices = cx522 let devices = cx
522 .background_executor()523 .background_executor()
@@ -559,3 +560,55 @@ fn test_button(
559 .font_weight(gpui_kit::FontWeight::MEDIUM)560 .font_weight(gpui_kit::FontWeight::MEDIUM)
560 .text_color(if active { palette.text } else { palette.muted })561 .text_color(if active { palette.text } else { palette.muted })
561 }562 }
563+
564+impl Yumush {
565+ pub(super) fn audio_button(
566+ &self,
567+ entity: &Entity<Self>,
568+ palette: Palette,
569+ side: Side,
570+ cx: &App,
571+ ) -> impl IntoElement {
572+ let (id, button, tip) = match side {
573+ Side::Input => ("mic_settings", "mic_settings_button", "Microphone"),
574+ Side::Output => ("speaker_settings", "speaker_settings_button", "Speaker"),
575+ };
576+ let refresh = entity.clone();
577+ let content = entity.clone();
578+ Popover::new(id)
579+ .anchor(Anchor::BottomRight)
580+ .appearance(false)
581+ .trigger(Trigger::new(
582+ super::parts::chevron_face(false, super::style::Tokens::of(cx))
583+ .id(button)
584+ .on_mouse_down(MouseButton::Left, move |_, window, cx| {
585+ refresh.update(cx, |yumush, cx| yumush.load_audio_devices(window, cx));
586+ })
587+ .tip(tip),
588+ ))
589+ .content(move |_, _, cx| audio_card(content.read(cx), side, palette))
590+ }
591+}
592+
593+fn audio_card(yumush: &Yumush, side: Side, palette: Palette) -> Div {
594+ let voice = &yumush.settings.voice;
595+ let controls = &yumush.voice;
596+ let (devices, volume, value) = match side {
597+ Side::Input => (&controls.inputs, &controls.input_volume, voice.input_volume),
598+ Side::Output => (
599+ &controls.outputs,
600+ &controls.output_volume,
601+ voice.output_volume,
602+ ),
603+ };
604+ div()
605+ .w(px(size::POPOVER))
606+ .p(px(space::MD))
607+ .flex()
608+ .flex_col()
609+ .gap(px(space::MD))
610+ .rounded(px(radius::LG))
611+ .bg(palette.field)
612+ .child(Select::new(devices).appearance(false).w_full())
613+ .child(volume_control(volume, value, palette))
614+}
crates/client/src/lib.rsmodified+2 -2
@@ -77,8 +77,8 @@ impl Server {
77 .and_then(|config| config.get("server_address"))77 .and_then(|config| config.get("server_address"))
78 .expect("client config server_address")78 .expect("client config server_address")
79 });79 });
80- let any_cert = std::env::var_os("YUMUSH_ANY_CERT").is_some()80+ let any_cert =
81- || lines.next() == Some("any_cert");81+ std::env::var_os("YUMUSH_ANY_CERT").is_some() || lines.next() == Some("any_cert");
82 Self { address, any_cert }82 Self { address, any_cert }
83 }83 }
84 84