Mic/speaker popovers are back
Browse files at this commitd4085664ec84c85b30c2e0079f2b19d7ca003170Parent: e02f563- style
- mic/speaker popovers are back
- all four call bar popovers share one card: live line on top (your voice / the call), label-left rows for device, volume, resolution, fps, codec, audio
6 changed files +127 -22
- crates/client/src/gui/call_bar.rs +4 -0
- crates/client/src/gui/dock.rs +6 -0
- crates/client/src/gui/gallery.rs +2 -0
- crates/client/src/gui/parts.rs +15 -0
- crates/client/src/gui/share_view.rs +10 -17
- crates/client/src/gui/voice_settings.rs +90 -5
crates/client/src/gui/call_bar.rsmodified+4 -0
| @@ -37,6 +37,8 @@ pub struct CallActions { | |||
| 37 | pub screen: Action, | 37 | pub screen: Action, |
| 38 | pub leave: Action, | 38 | pub leave: Action, |
| 39 | pub stats: Action, | 39 | pub stats: Action, |
| 40 | + pub mic_more: AnyElement, | ||
| 41 | + pub speaker_more: AnyElement, | ||
| 40 | pub camera_more: AnyElement, | 42 | pub camera_more: AnyElement, |
| 41 | pub screen_more: AnyElement, | 43 | pub screen_more: AnyElement, |
| 42 | } | 44 | } |
| @@ -80,6 +82,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { | |||
| 80 | t, | 82 | t, |
| 81 | run(&actions.mute), | 83 | run(&actions.mute), |
| 82 | )) | 84 | )) |
| 85 | + .child(actions.mic_more) | ||
| 83 | .child(icon_button( | 86 | .child(icon_button( |
| 84 | format!("bar_deafen_{}", bar.deafened), | 87 | format!("bar_deafen_{}", bar.deafened), |
| 85 | if bar.deafened { | 88 | if bar.deafened { |
| @@ -92,6 +95,7 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { | |||
| 92 | t, | 95 | t, |
| 93 | run(&actions.deafen), | 96 | run(&actions.deafen), |
| 94 | )) | 97 | )) |
| 98 | + .child(actions.speaker_more) | ||
| 95 | .when(!bar.ghost, |row| { | 99 | .when(!bar.ghost, |row| { |
| 96 | row.child(icon_button( | 100 | row.child(icon_button( |
| 97 | format!("bar_camera_{}", bar.camera), | 101 | format!("bar_camera_{}", bar.camera), |
crates/client/src/gui/dock.rsmodified+6 -0
| @@ -85,6 +85,12 @@ impl Yumush { | |||
| 85 | yumush.toggle_stats(super::chat::StatsAt::Dock); | 85 | yumush.toggle_stats(super::chat::StatsAt::Dock); |
| 86 | cx.notify(); | 86 | cx.notify(); |
| 87 | })), | 87 | })), |
| 88 | + mic_more: self | ||
| 89 | + .audio_button(entity, palette, super::voice_settings::Side::Input, cx) | ||
| 90 | + .into_any_element(), | ||
| 91 | + speaker_more: self | ||
| 92 | + .audio_button(entity, palette, super::voice_settings::Side::Output, cx) | ||
| 93 | + .into_any_element(), | ||
| 88 | camera_more: self | 94 | camera_more: self |
| 89 | .share_settings_button(entity, palette, Kind::Camera, cx) | 95 | .share_settings_button(entity, palette, Kind::Camera, cx) |
| 90 | .into_any_element(), | 96 | .into_any_element(), |
crates/client/src/gui/gallery.rsmodified+2 -0
| @@ -352,6 +352,8 @@ fn call_page(state: State, t: Tokens) -> impl IntoElement { | |||
| 352 | screen: none(), | 352 | screen: none(), |
| 353 | leave: none(), | 353 | leave: none(), |
| 354 | stats: none(), | 354 | stats: none(), |
| 355 | + mic_more: super::parts::chevron_face(false, t).into_any_element(), | ||
| 356 | + speaker_more: super::parts::chevron_face(false, t).into_any_element(), | ||
| 355 | camera_more: super::parts::chevron_face(false, t).into_any_element(), | 357 | camera_more: super::parts::chevron_face(false, t).into_any_element(), |
| 356 | screen_more: super::parts::chevron_face(false, t).into_any_element(), | 358 | screen_more: super::parts::chevron_face(false, t).into_any_element(), |
| 357 | }; | 359 | }; |
crates/client/src/gui/parts.rsmodified+15 -0
| @@ -323,6 +323,21 @@ pub fn popover(t: Tokens) -> Div { | |||
| 323 | .py(px(space::LG + 2.)) | 323 | .py(px(space::LG + 2.)) |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | +pub fn quick(t: Tokens) -> Div { | ||
| 327 | + popover(t).w(px(size::SHEET)).gap(px(space::SM)) | ||
| 328 | +} | ||
| 329 | + | ||
| 330 | +pub fn quick_row(label: &'static str, control: impl IntoElement, t: Tokens) -> Div { | ||
| 331 | + band(space::MD) | ||
| 332 | + .min_h(px(size::CONTROL)) | ||
| 333 | + .child( | ||
| 334 | + words(label, Text::Label, Ink::Faint, t) | ||
| 335 | + .w(px(size::ROW + space::XL)) | ||
| 336 | + .flex_none(), | ||
| 337 | + ) | ||
| 338 | + .child(div().flex_1().min_w_0().child(control)) | ||
| 339 | +} | ||
| 340 | + | ||
| 326 | pub fn scrim(t: Tokens) -> Div { | 341 | pub fn scrim(t: Tokens) -> Div { |
| 327 | band(space::SM) | 342 | band(space::SM) |
| 328 | .h(px(size::CONTROL_SM)) | 343 | .h(px(size::CONTROL_SM)) |
crates/client/src/gui/share_view.rsmodified+10 -17
| @@ -886,16 +886,9 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> | |||
| 886 | let (resolutions, fps) = options(&modes, top.resolution, max_height); | 886 | let (resolutions, fps) = options(&modes, top.resolution, max_height); |
| 887 | let screen = kind == Kind::Screen; | 887 | let screen = kind == Kind::Screen; |
| 888 | 888 | ||
| 889 | - div() | 889 | + let t = palette.tokens; |
| 890 | - .w(px(size::POPOVER)) | 890 | + super::parts::quick(t) |
| 891 | - .p(px(space::MD)) | 891 | + .child(super::parts::quick_row( |
| 892 | - .flex() | ||
| 893 | - .flex_col() | ||
| 894 | - .gap(px(space::MD)) | ||
| 895 | - .text_size(text(text::CAPTION)) | ||
| 896 | - .rounded(px(radius::LG)) | ||
| 897 | - .bg(palette.field) | ||
| 898 | - .child(field( | ||
| 899 | "Resolution", | 892 | "Resolution", |
| 900 | segmented( | 893 | segmented( |
| 901 | RESOLUTIONS | 894 | RESOLUTIONS |
| @@ -906,9 +899,9 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> | |||
| 906 | palette, | 899 | palette, |
| 907 | Yumush::set_share_resolution, | 900 | Yumush::set_share_resolution, |
| 908 | ), | 901 | ), |
| 909 | - palette, | 902 | + t, |
| 910 | )) | 903 | )) |
| 911 | - .child(field( | 904 | + .child(super::parts::quick_row( |
| 912 | "FPS", | 905 | "FPS", |
| 913 | segmented( | 906 | segmented( |
| 914 | FPS.into_iter().filter(|(value, _)| fps.contains(value)), | 907 | FPS.into_iter().filter(|(value, _)| fps.contains(value)), |
| @@ -917,9 +910,9 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> | |||
| 917 | palette, | 910 | palette, |
| 918 | Yumush::set_share_fps, | 911 | Yumush::set_share_fps, |
| 919 | ), | 912 | ), |
| 920 | - palette, | 913 | + t, |
| 921 | )) | 914 | )) |
| 922 | - .child(field( | 915 | + .child(super::parts::quick_row( |
| 923 | "Codec", | 916 | "Codec", |
| 924 | segmented( | 917 | segmented( |
| 925 | CODECS.into_iter().filter(|(codec, _)| match codec { | 918 | CODECS.into_iter().filter(|(codec, _)| match codec { |
| @@ -931,10 +924,10 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> | |||
| 931 | palette, | 924 | palette, |
| 932 | Yumush::set_share_codec, | 925 | Yumush::set_share_codec, |
| 933 | ), | 926 | ), |
| 934 | - palette, | 927 | + t, |
| 935 | )) | 928 | )) |
| 936 | .when(screen, |this| { | 929 | .when(screen, |this| { |
| 937 | - this.child(field( | 930 | + this.child(super::parts::quick_row( |
| 938 | "Audio", | 931 | "Audio", |
| 939 | segmented( | 932 | segmented( |
| 940 | AudioMode::ALL, | 933 | AudioMode::ALL, |
| @@ -943,7 +936,7 @@ fn settings_card(entity: &Entity<Yumush>, yumush: &Yumush, palette: Palette) -> | |||
| 943 | palette, | 936 | palette, |
| 944 | Yumush::set_share_audio_mode, | 937 | Yumush::set_share_audio_mode, |
| 945 | ), | 938 | ), |
| 946 | - palette, | 939 | + t, |
| 947 | )) | 940 | )) |
| 948 | .children(audio_list(entity, yumush, palette)) | 941 | .children(audio_list(entity, yumush, palette)) |
| 949 | }) | 942 | }) |
crates/client/src/gui/voice_settings.rsmodified+90 -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 = cx | 522 | let devices = cx |
| 522 | .background_executor() | 523 | .background_executor() |
| @@ -559,3 +560,87 @@ 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 t = palette.tokens; | ||
| 595 | + let voice = &yumush.settings.voice; | ||
| 596 | + let controls = &yumush.voice; | ||
| 597 | + let (devices, volume, value) = match side { | ||
| 598 | + Side::Input => (&controls.inputs, &controls.input_volume, voice.input_volume), | ||
| 599 | + Side::Output => ( | ||
| 600 | + &controls.outputs, | ||
| 601 | + &controls.output_volume, | ||
| 602 | + voice.output_volume, | ||
| 603 | + ), | ||
| 604 | + }; | ||
| 605 | + super::parts::quick(t) | ||
| 606 | + .child(audio_line(yumush, side, t)) | ||
| 607 | + .child(super::parts::quick_row( | ||
| 608 | + "Device", | ||
| 609 | + Select::new(devices).appearance(false).w_full(), | ||
| 610 | + t, | ||
| 611 | + )) | ||
| 612 | + .child(super::parts::quick_row( | ||
| 613 | + "Volume", | ||
| 614 | + volume_control(volume, value, palette), | ||
| 615 | + t, | ||
| 616 | + )) | ||
| 617 | +} | ||
| 618 | + | ||
| 619 | +fn audio_line(yumush: &Yumush, side: Side, t: super::style::Tokens) -> Div { | ||
| 620 | + let me = yumush.user.as_ref().map(|user| user.id); | ||
| 621 | + let heard: Vec<common::model::Id> = yumush | ||
| 622 | + .chat | ||
| 623 | + .voice_community() | ||
| 624 | + .map(|community_id| yumush.chat.voice_ids(community_id).to_vec()) | ||
| 625 | + .unwrap_or_default() | ||
| 626 | + .into_iter() | ||
| 627 | + .filter(|id| (Some(*id) == me) == (side == Side::Input)) | ||
| 628 | + .collect(); | ||
| 629 | + let speaking = heard | ||
| 630 | + .iter() | ||
| 631 | + .any(|id| yumush.chat.waves.speaking.contains(id)); | ||
| 632 | + let hue = match (side, me) { | ||
| 633 | + (Side::Input, Some(me)) => t.person(me), | ||
| 634 | + _ => t.paper(), | ||
| 635 | + }; | ||
| 636 | + let voice = if speaking { | ||
| 637 | + super::parts::Voice::Live(hue) | ||
| 638 | + } else { | ||
| 639 | + super::parts::Voice::Quiet | ||
| 640 | + }; | ||
| 641 | + div().h(px(size::ICON)).child(super::parts::voice_line( | ||
| 642 | + yumush.chat.waves.total(&heard).as_ref(), | ||
| 643 | + voice, | ||
| 644 | + t, | ||
| 645 | + )) | ||
| 646 | +} | ||