Call members as a tree under the call community (voice spectrum by name, camera/screen watch pills), new voice dock (timer, ping graph, mic spectrum group, per-device share rows), screen/camera palette colours
Browse files at this commit492d84d0f9873b04701a61b144889aabf5c7743fParent: a5b0c2c- ui
- call members as a tree under the call community (voice spectrum by name, camera/screen watch pills), new voice dock (timer, ping graph, mic spectrum group, per-device share rows), screen/camera palette colours
7 changed files +585 -378
- crates/client/src/gui.rs +5 -0
- crates/client/src/gui/camera_view.rs +2 -33
- crates/client/src/gui/chat.rs +6 -73
- crates/client/src/gui/dock.rs +381 -0
- crates/client/src/gui/share_view.rs +25 -62
- crates/client/src/gui/sidebar.rs +140 -206
- crates/client/src/gui/wave.rs +26 -4
crates/client/src/gui.rsmodified+5 -0
| @@ -48,6 +48,7 @@ mod camera_view; | |||
| 48 | mod chat; | 48 | mod chat; |
| 49 | mod community_settings; | 49 | mod community_settings; |
| 50 | mod composer; | 50 | mod composer; |
| 51 | +mod dock; | ||
| 51 | mod forward; | 52 | mod forward; |
| 52 | mod media_view; | 53 | mod media_view; |
| 53 | mod message_actions; | 54 | mod message_actions; |
| @@ -97,6 +98,8 @@ pub struct Palette { | |||
| 97 | pub ok: Hsla, | 98 | pub ok: Hsla, |
| 98 | pub danger: Hsla, | 99 | pub danger: Hsla, |
| 99 | pub alert: Hsla, | 100 | pub alert: Hsla, |
| 101 | + pub screen: Hsla, | ||
| 102 | + pub camera: Hsla, | ||
| 100 | pub dark: bool, | 103 | pub dark: bool, |
| 101 | } | 104 | } |
| 102 | 105 | ||
| @@ -163,6 +166,8 @@ pub fn palette(cx: &App) -> Palette { | |||
| 163 | ok: rgb(0x3fb950).into(), | 166 | ok: rgb(0x3fb950).into(), |
| 164 | danger: rgb(0xd1483f).into(), | 167 | danger: rgb(0xd1483f).into(), |
| 165 | alert: rgb(alert).into(), | 168 | alert: rgb(alert).into(), |
| 169 | + screen: rgb(if dark { 0x60a5fa } else { 0x2563eb }).into(), | ||
| 170 | + camera: rgb(if dark { 0xf5a524 } else { 0xc2410c }).into(), | ||
| 166 | dark, | 171 | dark, |
| 167 | } | 172 | } |
| 168 | } | 173 | } |
crates/client/src/gui/camera_view.rsmodified+2 -33
| @@ -3,7 +3,7 @@ use common::model::Id; | |||
| 3 | use common::share::{Fps, Kind, Quality, Resolution}; | 3 | use common::share::{Fps, Kind, Quality, Resolution}; |
| 4 | use gpui_kit::{ | 4 | use gpui_kit::{ |
| 5 | AnyElement, AppContext as _, Context, Entity, InteractiveElement, IntoElement, ParentElement, | 5 | AnyElement, AppContext as _, Context, Entity, InteractiveElement, IntoElement, ParentElement, |
| 6 | - StatefulInteractiveElement, Styled, Task, Window, assets::IconName, component::Icon, div, px, | 6 | + StatefulInteractiveElement, Styled, Task, Window, component::Icon, div, px, |
| 7 | }; | 7 | }; |
| 8 | 8 | ||
| 9 | use super::{ | 9 | use super::{ |
| @@ -13,7 +13,7 @@ use super::{ | |||
| 13 | share_view::{self, FRAME_TICK}, | 13 | share_view::{self, FRAME_TICK}, |
| 14 | surface::Surface, | 14 | surface::Surface, |
| 15 | text, | 15 | text, |
| 16 | - widget::{icon_button, spawn_warn}, | 16 | + widget::spawn_warn, |
| 17 | }; | 17 | }; |
| 18 | use crate::share::session::WatchQuality; | 18 | use crate::share::session::WatchQuality; |
| 19 | 19 | ||
| @@ -296,37 +296,6 @@ pub(super) fn ticker(cx: &mut Context<Yumush>) -> Task<()> { | |||
| 296 | }) | 296 | }) |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | -pub(super) fn camera_toggle( | ||
| 300 | - entity: &Entity<Yumush>, | ||
| 301 | - on: bool, | ||
| 302 | - palette: Palette, | ||
| 303 | -) -> impl IntoElement { | ||
| 304 | - let entity = entity.clone(); | ||
| 305 | - | ||
| 306 | - icon_button( | ||
| 307 | - if on { | ||
| 308 | - "camera_toggle_on" | ||
| 309 | - } else { | ||
| 310 | - "camera_toggle_off" | ||
| 311 | - }, | ||
| 312 | - palette, | ||
| 313 | - if on { | ||
| 314 | - IconName::VideoOff | ||
| 315 | - } else { | ||
| 316 | - IconName::Video | ||
| 317 | - }, | ||
| 318 | - if on { | ||
| 319 | - "Turn off camera" | ||
| 320 | - } else { | ||
| 321 | - "Turn on camera" | ||
| 322 | - }, | ||
| 323 | - move |window, cx| { | ||
| 324 | - entity.update(cx, |yumush, cx| yumush.toggle_camera(window, cx)); | ||
| 325 | - }, | ||
| 326 | - ) | ||
| 327 | - .text_color(if on { palette.ok } else { palette.muted }) | ||
| 328 | -} | ||
| 329 | - | ||
| 330 | fn stage_tile( | 299 | fn stage_tile( |
| 331 | entity: &Entity<Yumush>, | 300 | entity: &Entity<Yumush>, |
| 332 | yumush: &Yumush, | 301 | yumush: &Yumush, |
crates/client/src/gui/chat.rsmodified+6 -73
| @@ -26,7 +26,7 @@ use crate::gui::{ | |||
| 26 | sidebar::{SidebarTab, unread_badge}, | 26 | sidebar::{SidebarTab, unread_badge}, |
| 27 | snippet, | 27 | snippet, |
| 28 | voice_note::{self, VoiceNote}, | 28 | voice_note::{self, VoiceNote}, |
| 29 | - widget::{icon_button, ok_or_notify, search_text, spawn_done}, | 29 | + widget::{ok_or_notify, search_text, spawn_done}, |
| 30 | }; | 30 | }; |
| 31 | use crate::net::Levels; | 31 | use crate::net::Levels; |
| 32 | use crate::settings::VOLUME; | 32 | use crate::settings::VOLUME; |
| @@ -90,6 +90,7 @@ pub enum VoiceState { | |||
| 90 | community_id: Id, | 90 | community_id: Id, |
| 91 | muted: bool, | 91 | muted: bool, |
| 92 | deafened: bool, | 92 | deafened: bool, |
| 93 | + since: Instant, | ||
| 93 | }, | 94 | }, |
| 94 | } | 95 | } |
| 95 | 96 | ||
| @@ -2070,6 +2071,7 @@ impl Yumush { | |||
| 2070 | community_id, | 2071 | community_id, |
| 2071 | muted, | 2072 | muted, |
| 2072 | deafened, | 2073 | deafened, |
| 2074 | + since: Instant::now(), | ||
| 2073 | }; | 2075 | }; |
| 2074 | yumush.start_voice_poll(cx); | 2076 | yumush.start_voice_poll(cx); |
| 2075 | cx.notify(); | 2077 | cx.notify(); |
| @@ -2124,13 +2126,13 @@ impl Yumush { | |||
| 2124 | self.chat.ghost || !self.chat.joined(community_id) | 2126 | self.chat.ghost || !self.chat.joined(community_id) |
| 2125 | } | 2127 | } |
| 2126 | 2128 | ||
| 2127 | - fn hidden_in_voice(&self) -> bool { | 2129 | + pub(super) fn hidden_in_voice(&self) -> bool { |
| 2128 | self.chat | 2130 | self.chat |
| 2129 | .voice_community() | 2131 | .voice_community() |
| 2130 | .is_some_and(|community_id| self.hidden_in(community_id)) | 2132 | .is_some_and(|community_id| self.hidden_in(community_id)) |
| 2131 | } | 2133 | } |
| 2132 | 2134 | ||
| 2133 | - fn toggle_mute(&mut self, window: &mut Window, cx: &mut Context<Self>) { | 2135 | + pub(super) fn toggle_mute(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 2134 | if self.is_server_muted() { | 2136 | if self.is_server_muted() { |
| 2135 | return; | 2137 | return; |
| 2136 | } | 2138 | } |
| @@ -2207,7 +2209,7 @@ impl Yumush { | |||
| 2207 | }); | 2209 | }); |
| 2208 | } | 2210 | } |
| 2209 | 2211 | ||
| 2210 | - fn toggle_deafen(&mut self, cx: &mut Context<Self>) { | 2212 | + pub(super) fn toggle_deafen(&mut self, cx: &mut Context<Self>) { |
| 2211 | if let VoiceState::In { deafened, .. } = &mut self.chat.voice_state { | 2213 | if let VoiceState::In { deafened, .. } = &mut self.chat.voice_state { |
| 2212 | *deafened = !*deafened; | 2214 | *deafened = !*deafened; |
| 2213 | self.network.set_deafened(*deafened); | 2215 | self.network.set_deafened(*deafened); |
| @@ -2569,75 +2571,6 @@ impl Yumush { | |||
| 2569 | })), | 2571 | })), |
| 2570 | ) | 2572 | ) |
| 2571 | } | 2573 | } |
| 2572 | - | ||
| 2573 | - pub(super) fn voice_controls( | ||
| 2574 | - &self, | ||
| 2575 | - entity: &Entity<Self>, | ||
| 2576 | - palette: Palette, | ||
| 2577 | - ) -> Option<impl IntoElement> { | ||
| 2578 | - let (muted, deafened) = self.chat.voice_flags()?; | ||
| 2579 | - let mic_entity = entity.clone(); | ||
| 2580 | - let deafen_entity = entity.clone(); | ||
| 2581 | - let mic_icon = if muted { | ||
| 2582 | - IconName::MicOff | ||
| 2583 | - } else { | ||
| 2584 | - IconName::Mic | ||
| 2585 | - }; | ||
| 2586 | - let deafen_icon = if deafened { | ||
| 2587 | - IconName::HeadphoneOff | ||
| 2588 | - } else { | ||
| 2589 | - IconName::Headphones | ||
| 2590 | - }; | ||
| 2591 | - | ||
| 2592 | - Some( | ||
| 2593 | - div() | ||
| 2594 | - .flex() | ||
| 2595 | - .items_center() | ||
| 2596 | - .child( | ||
| 2597 | - icon_button( | ||
| 2598 | - format!("mic_button_{muted}_{}", self.hidden_in_voice()), | ||
| 2599 | - palette, | ||
| 2600 | - mic_icon, | ||
| 2601 | - match (muted, self.hidden_in_voice()) { | ||
| 2602 | - (true, true) => "Speak as ghost", | ||
| 2603 | - (true, false) => "Unmute", | ||
| 2604 | - (false, _) => "Mute", | ||
| 2605 | - }, | ||
| 2606 | - move |window, cx| { | ||
| 2607 | - mic_entity.update(cx, |yumush, cx| yumush.toggle_mute(window, cx)) | ||
| 2608 | - }, | ||
| 2609 | - ) | ||
| 2610 | - .text_color(if muted || deafened { | ||
| 2611 | - palette.danger | ||
| 2612 | - } else { | ||
| 2613 | - palette.muted | ||
| 2614 | - }), | ||
| 2615 | - ) | ||
| 2616 | - .child( | ||
| 2617 | - icon_button( | ||
| 2618 | - format!("deafen_button_{deafened}"), | ||
| 2619 | - palette, | ||
| 2620 | - deafen_icon, | ||
| 2621 | - if deafened { "Undeafen" } else { "Deafen" }, | ||
| 2622 | - move |_, cx| { | ||
| 2623 | - deafen_entity.update(cx, |yumush, cx| yumush.toggle_deafen(cx)) | ||
| 2624 | - }, | ||
| 2625 | - ) | ||
| 2626 | - .text_color(if deafened { | ||
| 2627 | - palette.danger | ||
| 2628 | - } else { | ||
| 2629 | - palette.muted | ||
| 2630 | - }), | ||
| 2631 | - ) | ||
| 2632 | - .children(self.chat.ghost.then(|| { | ||
| 2633 | - div() | ||
| 2634 | - .ml(px(4.)) | ||
| 2635 | - .text_size(text(11.)) | ||
| 2636 | - .text_color(palette.muted) | ||
| 2637 | - .child("Ghost") | ||
| 2638 | - })), | ||
| 2639 | - ) | ||
| 2640 | - } | ||
| 2641 | } | 2574 | } |
| 2642 | 2575 | ||
| 2643 | struct MemberRow { | 2576 | struct MemberRow { |
crates/client/src/gui/dock.rsadded+381 -0
| @@ -0,0 +1,381 @@ | |||
| 1 | +use std::time::Instant; | ||
| 2 | + | ||
| 3 | +use common::{ | ||
| 4 | + model::{Community, Id}, | ||
| 5 | + share::Kind, | ||
| 6 | +}; | ||
| 7 | +use gpui_kit::{ | ||
| 8 | + Anchor, App, Div, Entity, FontWeight, Hsla, IntoElement, MouseButton, ParentElement, Stateful, | ||
| 9 | + Styled, Window, | ||
| 10 | + assets::IconName, | ||
| 11 | + component::{Icon, popover::Popover}, | ||
| 12 | + div, px, | ||
| 13 | +}; | ||
| 14 | + | ||
| 15 | +use super::{ | ||
| 16 | + Palette, Tooltip as _, Trigger, Yumush, chat::VoiceState, clickable, community_name, | ||
| 17 | + entity_action, pop_in, share_view::kind_icon, text, voice_stats, wave, widget::icon_button, | ||
| 18 | +}; | ||
| 19 | + | ||
| 20 | +const PING_BARS: usize = 12; | ||
| 21 | + | ||
| 22 | +impl Yumush { | ||
| 23 | + pub(super) fn dock(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> { | ||
| 24 | + let community = self.chat.voice_room()?; | ||
| 25 | + let VoiceState::In { since, .. } = &self.chat.voice_state else { | ||
| 26 | + return None; | ||
| 27 | + }; | ||
| 28 | + let (muted, deafened) = self.chat.voice_flags()?; | ||
| 29 | + let me = self.user.as_ref()?.id; | ||
| 30 | + let tone = voice_stats::quality(&self.chat.voice_samples) | ||
| 31 | + .map_or(palette.ok, |quality| quality.color(palette)); | ||
| 32 | + let stats_entity = entity.clone(); | ||
| 33 | + | ||
| 34 | + let panel = div() | ||
| 35 | + .bg(tone.opacity(0.08)) | ||
| 36 | + .border_1() | ||
| 37 | + .border_color(tone.opacity(0.2)) | ||
| 38 | + .rounded(px(10.)) | ||
| 39 | + .p(px(8.)) | ||
| 40 | + .flex() | ||
| 41 | + .flex_col() | ||
| 42 | + .gap(px(6.)) | ||
| 43 | + .child(self.dock_header(entity, community, *since, tone, palette)) | ||
| 44 | + .child(self.dock_voice(entity, me, muted, deafened, palette)) | ||
| 45 | + .child(self.dock_devices(entity, me, palette)); | ||
| 46 | + | ||
| 47 | + Some( | ||
| 48 | + Popover::new("voice_stats") | ||
| 49 | + .anchor(Anchor::BottomLeft) | ||
| 50 | + .mouse_button(MouseButton::Right) | ||
| 51 | + .appearance(false) | ||
| 52 | + .trigger(Trigger::new(panel)) | ||
| 53 | + .content(move |_, _, cx| { | ||
| 54 | + let chat = &stats_entity.read(cx).chat; | ||
| 55 | + pop_in( | ||
| 56 | + "voice_stats_card", | ||
| 57 | + voice_stats::stats_card(chat, &stats_entity, palette), | ||
| 58 | + Anchor::BottomLeft, | ||
| 59 | + ) | ||
| 60 | + }), | ||
| 61 | + ) | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + fn dock_header( | ||
| 65 | + &self, | ||
| 66 | + entity: &Entity<Self>, | ||
| 67 | + community: &Community, | ||
| 68 | + since: Instant, | ||
| 69 | + tone: Hsla, | ||
| 70 | + palette: Palette, | ||
| 71 | + ) -> Div { | ||
| 72 | + let direct = community.kind.is_direct(); | ||
| 73 | + let go_id = community.id; | ||
| 74 | + let go = entity_action(entity, move |yumush, window, cx| { | ||
| 75 | + yumush.go_to_community(go_id, direct, window, cx) | ||
| 76 | + }); | ||
| 77 | + | ||
| 78 | + let ping = self | ||
| 79 | + .chat | ||
| 80 | + .voice_samples | ||
| 81 | + .back() | ||
| 82 | + .map_or(0., |sample| sample.ping_ms); | ||
| 83 | + let start = self.chat.voice_samples.len().saturating_sub(PING_BARS); | ||
| 84 | + let pings: Vec<f32> = self | ||
| 85 | + .chat | ||
| 86 | + .voice_samples | ||
| 87 | + .iter() | ||
| 88 | + .skip(start) | ||
| 89 | + .map(|sample| sample.ping_ms) | ||
| 90 | + .collect(); | ||
| 91 | + let peak = pings.iter().copied().fold(1., f32::max); | ||
| 92 | + let bars = div() | ||
| 93 | + .flex() | ||
| 94 | + .items_end() | ||
| 95 | + .gap(px(1.)) | ||
| 96 | + .h(px(12.)) | ||
| 97 | + .children(pings.iter().map(|ping| { | ||
| 98 | + div() | ||
| 99 | + .w(px(2.)) | ||
| 100 | + .h(px((12. * ping / peak).max(1.))) | ||
| 101 | + .rounded(px(1.)) | ||
| 102 | + .bg(tone) | ||
| 103 | + })); | ||
| 104 | + | ||
| 105 | + div() | ||
| 106 | + .flex() | ||
| 107 | + .items_center() | ||
| 108 | + .gap(px(7.)) | ||
| 109 | + .child( | ||
| 110 | + clickable("dock_go", palette, go) | ||
| 111 | + .tip("Go to call") | ||
| 112 | + .min_w_0() | ||
| 113 | + .truncate() | ||
| 114 | + .text_size(text(12.)) | ||
| 115 | + .font_weight(FontWeight::SEMIBOLD) | ||
| 116 | + .text_color(tone) | ||
| 117 | + .child(community_name(community).to_string()), | ||
| 118 | + ) | ||
| 119 | + .child( | ||
| 120 | + div() | ||
| 121 | + .text_size(text(11.)) | ||
| 122 | + .text_color(palette.muted) | ||
| 123 | + .child(elapsed_text(since)), | ||
| 124 | + ) | ||
| 125 | + .child(div().flex_1()) | ||
| 126 | + .child( | ||
| 127 | + div() | ||
| 128 | + .flex_shrink_0() | ||
| 129 | + .h(px(22.)) | ||
| 130 | + .px(px(7.)) | ||
| 131 | + .rounded(px(6.)) | ||
| 132 | + .bg(tone.opacity(0.12)) | ||
| 133 | + .flex() | ||
| 134 | + .items_center() | ||
| 135 | + .gap(px(6.)) | ||
| 136 | + .child(bars) | ||
| 137 | + .child( | ||
| 138 | + div() | ||
| 139 | + .text_size(text(11.)) | ||
| 140 | + .text_color(tone) | ||
| 141 | + .child(format!("{ping:.0} ms")), | ||
| 142 | + ), | ||
| 143 | + ) | ||
| 144 | + .child( | ||
| 145 | + icon_button( | ||
| 146 | + "dock_leave", | ||
| 147 | + palette, | ||
| 148 | + IconName::PhoneOff, | ||
| 149 | + "Leave call", | ||
| 150 | + entity_action(entity, |yumush, _, cx| { | ||
| 151 | + yumush.end_voice(cx); | ||
| 152 | + cx.notify(); | ||
| 153 | + }), | ||
| 154 | + ) | ||
| 155 | + .bg(palette.danger.opacity(0.13)) | ||
| 156 | + .text_color(palette.danger), | ||
| 157 | + ) | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + fn dock_voice( | ||
| 161 | + &self, | ||
| 162 | + entity: &Entity<Self>, | ||
| 163 | + me: Id, | ||
| 164 | + muted: bool, | ||
| 165 | + deafened: bool, | ||
| 166 | + palette: Palette, | ||
| 167 | + ) -> Div { | ||
| 168 | + let tone = if muted || deafened { | ||
| 169 | + palette.danger | ||
| 170 | + } else { | ||
| 171 | + palette.ok | ||
| 172 | + }; | ||
| 173 | + let mic_entity = entity.clone(); | ||
| 174 | + let deafen_entity = entity.clone(); | ||
| 175 | + let ghost = self.hidden_in_voice(); | ||
| 176 | + let mic_icon = if muted { | ||
| 177 | + IconName::MicOff | ||
| 178 | + } else { | ||
| 179 | + IconName::Mic | ||
| 180 | + }; | ||
| 181 | + let mic_tip = match (muted, ghost) { | ||
| 182 | + (true, true) => "Speak as ghost", | ||
| 183 | + (true, false) => "Unmute", | ||
| 184 | + (false, _) => "Mute", | ||
| 185 | + }; | ||
| 186 | + let deafen_icon = if deafened { | ||
| 187 | + IconName::HeadphoneOff | ||
| 188 | + } else { | ||
| 189 | + IconName::Headphones | ||
| 190 | + }; | ||
| 191 | + let (deafen_bg, deafen_tone) = if deafened { | ||
| 192 | + (palette.danger.opacity(0.13), palette.danger) | ||
| 193 | + } else { | ||
| 194 | + (palette.hover, palette.text) | ||
| 195 | + }; | ||
| 196 | + | ||
| 197 | + let mic = icon_button( | ||
| 198 | + format!("dock_mic_{muted}_{ghost}"), | ||
| 199 | + palette, | ||
| 200 | + mic_icon, | ||
| 201 | + mic_tip, | ||
| 202 | + move |window, cx| mic_entity.update(cx, |yumush, cx| yumush.toggle_mute(window, cx)), | ||
| 203 | + ) | ||
| 204 | + .text_color(tone); | ||
| 205 | + let voice = div() | ||
| 206 | + .flex_1() | ||
| 207 | + .flex() | ||
| 208 | + .justify_center() | ||
| 209 | + .child(wave::wave_slot(self.chat.waves.voice(me), 14., tone)); | ||
| 210 | + let group = div() | ||
| 211 | + .flex_1() | ||
| 212 | + .h(px(30.)) | ||
| 213 | + .px(px(8.)) | ||
| 214 | + .rounded(px(7.)) | ||
| 215 | + .bg(tone.opacity(0.12)) | ||
| 216 | + .flex() | ||
| 217 | + .items_center() | ||
| 218 | + .gap(px(4.)) | ||
| 219 | + .child(mic) | ||
| 220 | + .child(voice); | ||
| 221 | + let deafen = icon_button( | ||
| 222 | + format!("dock_deafen_{deafened}"), | ||
| 223 | + palette, | ||
| 224 | + deafen_icon, | ||
| 225 | + if deafened { "Undeafen" } else { "Deafen" }, | ||
| 226 | + move |_, cx| deafen_entity.update(cx, |yumush, cx| yumush.toggle_deafen(cx)), | ||
| 227 | + ) | ||
| 228 | + .w(px(34.)) | ||
| 229 | + .h(px(30.)) | ||
| 230 | + .rounded(px(7.)) | ||
| 231 | + .bg(deafen_bg) | ||
| 232 | + .text_color(deafen_tone); | ||
| 233 | + | ||
| 234 | + div() | ||
| 235 | + .flex() | ||
| 236 | + .items_center() | ||
| 237 | + .gap(px(4.)) | ||
| 238 | + .child(group) | ||
| 239 | + .child(deafen) | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + fn dock_devices(&self, entity: &Entity<Self>, me: Id, palette: Palette) -> Div { | ||
| 243 | + let (on, off): (Vec<Kind>, Vec<Kind>) = [Kind::Camera, Kind::Screen] | ||
| 244 | + .into_iter() | ||
| 245 | + .partition(|kind| self.is_on(*kind)); | ||
| 246 | + let mut rows: Vec<Div> = on | ||
| 247 | + .into_iter() | ||
| 248 | + .map(|kind| self.device_row(entity, me, kind, palette)) | ||
| 249 | + .collect(); | ||
| 250 | + if !off.is_empty() { | ||
| 251 | + rows.push( | ||
| 252 | + div().flex().items_center().gap(px(4.)).children( | ||
| 253 | + off.into_iter() | ||
| 254 | + .map(|kind| start_button(entity, kind, palette)), | ||
| 255 | + ), | ||
| 256 | + ); | ||
| 257 | + } | ||
| 258 | + if let Some(last) = rows.pop() { | ||
| 259 | + rows.push(last.child(self.share_settings_button(entity, palette))); | ||
| 260 | + } | ||
| 261 | + div().flex().flex_col().gap(px(4.)).children(rows) | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + fn device_row(&self, entity: &Entity<Self>, me: Id, kind: Kind, palette: Palette) -> Div { | ||
| 265 | + let tone = match kind { | ||
| 266 | + Kind::Camera => palette.camera, | ||
| 267 | + Kind::Screen => palette.screen, | ||
| 268 | + }; | ||
| 269 | + let stop_tip = match kind { | ||
| 270 | + Kind::Camera => "Turn off camera", | ||
| 271 | + Kind::Screen => "Stop sharing", | ||
| 272 | + }; | ||
| 273 | + let mut row = div() | ||
| 274 | + .h(px(30.)) | ||
| 275 | + .rounded(px(7.)) | ||
| 276 | + .pl(px(8.)) | ||
| 277 | + .pr(px(2.)) | ||
| 278 | + .bg(tone.opacity(0.1)) | ||
| 279 | + .flex() | ||
| 280 | + .items_center() | ||
| 281 | + .gap(px(6.)) | ||
| 282 | + .child( | ||
| 283 | + Icon::new(kind_icon(kind)) | ||
| 284 | + .w(px(14.)) | ||
| 285 | + .h(px(14.)) | ||
| 286 | + .text_color(tone), | ||
| 287 | + ) | ||
| 288 | + .child( | ||
| 289 | + div() | ||
| 290 | + .text_size(text(11.5)) | ||
| 291 | + .text_color(tone) | ||
| 292 | + .child(self.mode_text(kind)), | ||
| 293 | + ); | ||
| 294 | + if let Some(history) = self.chat.waves.share(me).filter(|_| kind == Kind::Screen) { | ||
| 295 | + row = row.child( | ||
| 296 | + div() | ||
| 297 | + .h(px(22.)) | ||
| 298 | + .px(px(6.)) | ||
| 299 | + .rounded(px(6.)) | ||
| 300 | + .bg(tone.opacity(0.12)) | ||
| 301 | + .flex() | ||
| 302 | + .items_center() | ||
| 303 | + .gap(px(4.)) | ||
| 304 | + .child( | ||
| 305 | + Icon::new(IconName::Volume2) | ||
| 306 | + .w(px(14.)) | ||
| 307 | + .h(px(14.)) | ||
| 308 | + .text_color(tone), | ||
| 309 | + ) | ||
| 310 | + .child(wave::mini_wave(history, 10., tone)), | ||
| 311 | + ); | ||
| 312 | + } | ||
| 313 | + row.child(div().flex_1()).child( | ||
| 314 | + icon_button( | ||
| 315 | + format!("dock_stop_{kind:?}"), | ||
| 316 | + palette, | ||
| 317 | + IconName::X, | ||
| 318 | + stop_tip, | ||
| 319 | + toggle_action(entity, kind), | ||
| 320 | + ) | ||
| 321 | + .text_color(palette.danger), | ||
| 322 | + ) | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + fn mode_text(&self, kind: Kind) -> String { | ||
| 326 | + let best = self | ||
| 327 | + .chat | ||
| 328 | + .share_sample | ||
| 329 | + .sending | ||
| 330 | + .iter() | ||
| 331 | + .filter(|(sent, _)| *sent == kind) | ||
| 332 | + .map(|(_, stats)| stats) | ||
| 333 | + .max_by(|a, b| a.fps.total_cmp(&b.fps)); | ||
| 334 | + match best { | ||
| 335 | + Some(stats) => format!( | ||
| 336 | + "{}p{}", | ||
| 337 | + stats.layer.quality.resolution.height(), | ||
| 338 | + stats.layer.quality.fps.value() | ||
| 339 | + ), | ||
| 340 | + None => "…".to_string(), | ||
| 341 | + } | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + fn is_on(&self, kind: Kind) -> bool { | ||
| 345 | + self.network.share_source(kind).is_some() | ||
| 346 | + } | ||
| 347 | +} | ||
| 348 | + | ||
| 349 | +fn start_button(entity: &Entity<Yumush>, kind: Kind, palette: Palette) -> Stateful<Div> { | ||
| 350 | + icon_button( | ||
| 351 | + format!("dock_start_{kind:?}"), | ||
| 352 | + palette, | ||
| 353 | + kind_icon(kind), | ||
| 354 | + match kind { | ||
| 355 | + Kind::Camera => "Turn on camera", | ||
| 356 | + Kind::Screen => "Share screen", | ||
| 357 | + }, | ||
| 358 | + toggle_action(entity, kind), | ||
| 359 | + ) | ||
| 360 | + .flex_1() | ||
| 361 | + .h(px(30.)) | ||
| 362 | + .rounded(px(7.)) | ||
| 363 | + .bg(palette.hover) | ||
| 364 | +} | ||
| 365 | + | ||
| 366 | +fn toggle_action(entity: &Entity<Yumush>, kind: Kind) -> impl Fn(&mut Window, &mut App) + 'static { | ||
| 367 | + let entity = entity.clone(); | ||
| 368 | + move |window: &mut Window, cx: &mut App| match kind { | ||
| 369 | + Kind::Camera => entity.update(cx, |yumush, cx| yumush.toggle_camera(window, cx)), | ||
| 370 | + Kind::Screen => entity.update(cx, |yumush, cx| yumush.toggle_share(window, cx)), | ||
| 371 | + } | ||
| 372 | +} | ||
| 373 | + | ||
| 374 | +fn elapsed_text(since: Instant) -> String { | ||
| 375 | + let seconds = since.elapsed().as_secs(); | ||
| 376 | + let (hours, minutes, seconds) = (seconds / 3600, seconds / 60 % 60, seconds % 60); | ||
| 377 | + match hours { | ||
| 378 | + 0 => format!("{minutes:02}:{seconds:02}"), | ||
| 379 | + _ => format!("{hours}:{minutes:02}:{seconds:02}"), | ||
| 380 | + } | ||
| 381 | +} | ||
crates/client/src/gui/share_view.rsmodified+25 -62
| @@ -395,77 +395,40 @@ impl Yumush { | |||
| 395 | cx.notify(); | 395 | cx.notify(); |
| 396 | } | 396 | } |
| 397 | 397 | ||
| 398 | - pub(super) fn share_controls( | 398 | + pub(super) fn share_settings_button( |
| 399 | &self, | 399 | &self, |
| 400 | entity: &Entity<Self>, | 400 | entity: &Entity<Self>, |
| 401 | palette: Palette, | 401 | palette: Palette, |
| 402 | ) -> impl IntoElement { | 402 | ) -> impl IntoElement { |
| 403 | - let sharing = self.network.sharing(); | ||
| 404 | - let toggle = entity.clone(); | ||
| 405 | let refresh = entity.clone(); | 403 | let refresh = entity.clone(); |
| 406 | let settings = entity.clone(); | 404 | let settings = entity.clone(); |
| 407 | 405 | ||
| 408 | - div() | 406 | + Popover::new("share_settings") |
| 409 | - .flex() | 407 | + .anchor(Anchor::BottomLeft) |
| 410 | - .items_center() | 408 | + .appearance(false) |
| 411 | - .gap(px(2.)) | 409 | + .trigger(Trigger::new( |
| 412 | - .child(camera_view::camera_toggle( | 410 | + div() |
| 413 | - entity, | 411 | + .id("share_settings_button") |
| 414 | - self.network.camera_on(), | 412 | + .on_mouse_down(MouseButton::Left, move |_, _, cx| { |
| 415 | - palette, | 413 | + refresh.update(cx, |yumush, cx| yumush.refresh_share_apps(cx)); |
| 414 | + }) | ||
| 415 | + .tip("Share settings") | ||
| 416 | + .size(px(26.)) | ||
| 417 | + .flex() | ||
| 418 | + .items_center() | ||
| 419 | + .justify_center() | ||
| 420 | + .rounded(px(6.)) | ||
| 421 | + .text_color(palette.muted) | ||
| 422 | + .child(Icon::new(IconName::SlidersHorizontal).w(px(14.)).h(px(14.))), | ||
| 416 | )) | 423 | )) |
| 417 | - .child( | 424 | + .content(move |_, _, cx| { |
| 418 | - icon_button( | 425 | + let entity = settings.clone(); |
| 419 | - if sharing { | 426 | + pop_in( |
| 420 | - "share_toggle_on" | 427 | + "share_settings_card", |
| 421 | - } else { | 428 | + settings_card(&entity, entity.read(cx), palette), |
| 422 | - "share_toggle_off" | 429 | + Anchor::BottomLeft, |
| 423 | - }, | ||
| 424 | - palette, | ||
| 425 | - if sharing { | ||
| 426 | - IconName::ScreenShareOff | ||
| 427 | - } else { | ||
| 428 | - IconName::ScreenShare | ||
| 429 | - }, | ||
| 430 | - if sharing { | ||
| 431 | - "Stop sharing" | ||
| 432 | - } else { | ||
| 433 | - "Share screen" | ||
| 434 | - }, | ||
| 435 | - move |window, cx| { | ||
| 436 | - toggle.update(cx, |yumush, cx| yumush.toggle_share(window, cx)); | ||
| 437 | - }, | ||
| 438 | ) | 430 | ) |
| 439 | - .text_color(if sharing { palette.ok } else { palette.muted }), | 431 | + }) |
| 440 | - ) | ||
| 441 | - .child( | ||
| 442 | - Popover::new("share_settings") | ||
| 443 | - .anchor(Anchor::BottomLeft) | ||
| 444 | - .appearance(false) | ||
| 445 | - .trigger(Trigger::new( | ||
| 446 | - div() | ||
| 447 | - .id("share_settings_button") | ||
| 448 | - .on_mouse_down(MouseButton::Left, move |_, _, cx| { | ||
| 449 | - refresh.update(cx, |yumush, cx| yumush.refresh_share_apps(cx)); | ||
| 450 | - }) | ||
| 451 | - .tip("Share settings") | ||
| 452 | - .size(px(26.)) | ||
| 453 | - .flex() | ||
| 454 | - .items_center() | ||
| 455 | - .justify_center() | ||
| 456 | - .rounded(px(6.)) | ||
| 457 | - .text_color(palette.muted) | ||
| 458 | - .child(Icon::new(IconName::SlidersHorizontal).w(px(14.)).h(px(14.))), | ||
| 459 | - )) | ||
| 460 | - .content(move |_, _, cx| { | ||
| 461 | - let entity = settings.clone(); | ||
| 462 | - pop_in( | ||
| 463 | - "share_settings_card", | ||
| 464 | - settings_card(&entity, entity.read(cx), palette), | ||
| 465 | - Anchor::BottomLeft, | ||
| 466 | - ) | ||
| 467 | - }), | ||
| 468 | - ) | ||
| 469 | } | 432 | } |
| 470 | 433 | ||
| 471 | pub(super) fn inline_viewer(&self, entity: &Entity<Self>, palette: Palette) -> Option<Div> { | 434 | pub(super) fn inline_viewer(&self, entity: &Entity<Self>, palette: Palette) -> Option<Div> { |
crates/client/src/gui/sidebar.rsmodified+140 -206
| @@ -1,3 +1,5 @@ | |||
| 1 | +use std::collections::VecDeque; | ||
| 2 | + | ||
| 1 | use super::text; | 3 | use super::text; |
| 2 | use common::model::Id; | 4 | use common::model::Id; |
| 3 | use common::{ | 5 | use common::{ |
| @@ -8,13 +10,12 @@ use common::{ | |||
| 8 | }; | 10 | }; |
| 9 | use gpui_kit::{ | 11 | use gpui_kit::{ |
| 10 | Anchor, AnimationExt, AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement, | 12 | Anchor, AnimationExt, AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement, |
| 11 | - IntoElement, MouseButton, ParentElement, Pixels, StatefulInteractiveElement, Styled, Window, | 13 | + IntoElement, ParentElement, Pixels, StatefulInteractiveElement, Styled, Window, |
| 12 | assets::IconName, | 14 | assets::IconName, |
| 13 | component::{ | 15 | component::{ |
| 14 | Icon, | 16 | Icon, |
| 15 | input::{Input, InputState}, | 17 | input::{Input, InputState}, |
| 16 | menu::{ContextMenuExt, PopupMenu, PopupMenuItem}, | 18 | menu::{ContextMenuExt, PopupMenu, PopupMenuItem}, |
| 17 | - popover::Popover, | ||
| 18 | }, | 19 | }, |
| 19 | div, | 20 | div, |
| 20 | prelude::FluentBuilder as _, | 21 | prelude::FluentBuilder as _, |
| @@ -22,21 +23,19 @@ use gpui_kit::{ | |||
| 22 | }; | 23 | }; |
| 23 | 24 | ||
| 24 | use super::{ | 25 | use super::{ |
| 25 | - Palette, Tooltip as _, Trigger, Yumush, avatar, | 26 | + Palette, Tooltip as _, Yumush, avatar, |
| 26 | chat::{View, create_community}, | 27 | chat::{View, create_community}, |
| 27 | clickable, community_icon, community_name, entity_action, hoverable, hoverable_with, | 28 | clickable, community_icon, community_name, entity_action, hoverable, hoverable_with, |
| 28 | - input_dialog, motion, pop_in, presence_avatar, | 29 | + input_dialog, motion, presence_avatar, |
| 29 | profile::profile_popover, | 30 | profile::profile_popover, |
| 30 | settings_page::{segment, segment_track}, | 31 | settings_page::{segment, segment_track}, |
| 31 | social::Relation, | 32 | social::Relation, |
| 32 | - voice_stats, | 33 | + wave::mini_wave, |
| 33 | - wave::wave_slot, | ||
| 34 | widget::{bare_input, compact_frame, icon_button}, | 34 | widget::{bare_input, compact_frame, icon_button}, |
| 35 | }; | 35 | }; |
| 36 | 36 | ||
| 37 | const SIDEBAR_WIDTH: f32 = 232.; | 37 | const SIDEBAR_WIDTH: f32 = 232.; |
| 38 | const SIDEBAR_COLLAPSED_WIDTH: f32 = 48.; | 38 | const SIDEBAR_COLLAPSED_WIDTH: f32 = 48.; |
| 39 | -const MEMBERS_HEIGHT: f32 = 160.; | ||
| 40 | 39 | ||
| 41 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | 40 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
| 42 | pub enum SidebarTab { | 41 | pub enum SidebarTab { |
| @@ -136,237 +135,132 @@ impl Yumush { | |||
| 136 | .overflow_y_scroll() | 135 | .overflow_y_scroll() |
| 137 | .child(list), | 136 | .child(list), |
| 138 | ) | 137 | ) |
| 139 | - .children(self.voice_panel(entity, palette)) | 138 | + .children(self.dock(entity, palette)) |
| 140 | .children(self.account_row(entity, palette)) | 139 | .children(self.account_row(entity, palette)) |
| 141 | .into_any_element() | 140 | .into_any_element() |
| 142 | } | 141 | } |
| 143 | 142 | ||
| 144 | - fn voice_panel(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> { | 143 | + fn voice_chip(&self, community_id: Id, palette: Palette) -> AnyElement { |
| 145 | - let community = self.chat.voice_room()?; | 144 | + let ids = self.chat.voice_ids(community_id); |
| 146 | - let tone = voice_stats::quality(&self.chat.voice_samples) | 145 | + let wave = ids.iter().find_map(|id| self.chat.waves.voice(*id)); |
| 147 | - .map_or(palette.ok, |quality| quality.color(palette)); | 146 | + div() |
| 148 | - let stats_entity = entity.clone(); | 147 | + .h(px(18.)) |
| 149 | - let members: Vec<_> = self | 148 | + .px(px(5.)) |
| 150 | - .chat | ||
| 151 | - .voice_ids(community.id) | ||
| 152 | - .iter() | ||
| 153 | - .filter_map(|id| self.chat.author(*id)) | ||
| 154 | - .map(|user| self.voice_member(entity, community.id, user, palette)) | ||
| 155 | - .collect(); | ||
| 156 | - | ||
| 157 | - let controls = div() | ||
| 158 | .flex() | 149 | .flex() |
| 159 | .items_center() | 150 | .items_center() |
| 160 | .gap(px(4.)) | 151 | .gap(px(4.)) |
| 161 | - .child( | 152 | + .rounded(px(4.)) |
| 162 | - clickable("voice_panel_go", palette, go_to_call(entity, community)) | 153 | + .bg(palette.ok.opacity(0.15)) |
| 163 | - .tip("Go to call") | 154 | + .children(wave.map(|history| mini_wave(history, 12., palette.ok))) |
| 164 | - .flex_1() | ||
| 165 | - .min_w_0() | ||
| 166 | - .px(px(4.)) | ||
| 167 | - .py(px(2.)) | ||
| 168 | - .rounded(px(6.)) | ||
| 169 | - .flex() | ||
| 170 | - .items_center() | ||
| 171 | - .gap(px(8.)) | ||
| 172 | - .child( | ||
| 173 | - Icon::new(IconName::AudioLines) | ||
| 174 | - .w(px(16.)) | ||
| 175 | - .h(px(16.)) | ||
| 176 | - .text_color(tone), | ||
| 177 | - ) | ||
| 178 | - .child( | ||
| 179 | - div() | ||
| 180 | - .flex_1() | ||
| 181 | - .min_w_0() | ||
| 182 | - .truncate() | ||
| 183 | - .text_size(text(12.)) | ||
| 184 | - .font_weight(FontWeight::SEMIBOLD) | ||
| 185 | - .text_color(palette.ok) | ||
| 186 | - .child(community_name(community).to_string()), | ||
| 187 | - ), | ||
| 188 | - ) | ||
| 189 | - .child(self.share_controls(entity, palette)) | ||
| 190 | - .child(icon_button( | ||
| 191 | - "voice_panel_leave".to_string(), | ||
| 192 | - palette, | ||
| 193 | - IconName::PhoneOff, | ||
| 194 | - "Leave call", | ||
| 195 | - entity_action(entity, |yumush, _, cx| { | ||
| 196 | - yumush.end_voice(cx); | ||
| 197 | - cx.notify(); | ||
| 198 | - }), | ||
| 199 | - )); | ||
| 200 | - let panel = call_style(div(), palette) | ||
| 201 | - .flex() | ||
| 202 | - .flex_col() | ||
| 203 | - .gap(px(2.)) | ||
| 204 | - .p(px(6.)) | ||
| 205 | - .rounded(px(8.)) | ||
| 206 | .child( | 155 | .child( |
| 207 | div() | 156 | div() |
| 208 | - .id("voice_members") | 157 | + .text_size(text(11.)) |
| 209 | - .max_h(px(MEMBERS_HEIGHT)) | 158 | + .text_color(palette.ok) |
| 210 | - .overflow_y_scroll() | 159 | + .child(ids.len().to_string()), |
| 211 | - .children(members), | ||
| 212 | ) | 160 | ) |
| 213 | - .child(controls); | 161 | + .into_any_element() |
| 162 | + } | ||
| 163 | + | ||
| 164 | + fn call_tree(&self, entity: &Entity<Self>, community_id: Id, palette: Palette) -> Option<Div> { | ||
| 165 | + if self.chat.voice_community() != Some(community_id) { | ||
| 166 | + return None; | ||
| 167 | + } | ||
| 168 | + let members = self | ||
| 169 | + .chat | ||
| 170 | + .voice_ids(community_id) | ||
| 171 | + .iter() | ||
| 172 | + .filter_map(|id| self.chat.author(*id)) | ||
| 173 | + .map(|user| self.call_member(entity, community_id, user, palette)); | ||
| 214 | 174 | ||
| 215 | Some( | 175 | Some( |
| 216 | - Popover::new("voice_stats") | 176 | + div() |
| 217 | - .anchor(Anchor::BottomLeft) | 177 | + .ml(px(18.)) |
| 218 | - .mouse_button(MouseButton::Right) | 178 | + .pl(px(10.)) |
| 219 | - .appearance(false) | 179 | + .border_l_1() |
| 220 | - .trigger(Trigger::new(panel)) | 180 | + .border_color(palette.border) |
| 221 | - .content(move |_, _, cx| { | 181 | + .flex() |
| 222 | - let chat = &stats_entity.read(cx).chat; | 182 | + .flex_col() |
| 223 | - pop_in( | 183 | + .gap(px(1.)) |
| 224 | - "voice_stats_card", | 184 | + .mt(px(2.)) |
| 225 | - voice_stats::stats_card(chat, &stats_entity, palette), | 185 | + .mb(px(4.)) |
| 226 | - Anchor::BottomLeft, | 186 | + .children(members), |
| 227 | - ) | ||
| 228 | - }), | ||
| 229 | ) | 187 | ) |
| 230 | } | 188 | } |
| 231 | 189 | ||
| 232 | - fn voice_member( | 190 | + fn call_member( |
| 233 | &self, | 191 | &self, |
| 234 | entity: &Entity<Self>, | 192 | entity: &Entity<Self>, |
| 235 | community_id: Id, | 193 | community_id: Id, |
| 236 | user: &User, | 194 | user: &User, |
| 237 | palette: Palette, | 195 | palette: Palette, |
| 238 | ) -> impl IntoElement { | 196 | ) -> impl IntoElement { |
| 239 | - let speaking = self.chat.waves.speaking.contains(&user.id); | 197 | + let user_id = user.id; |
| 240 | - let screen = self | 198 | + let speaking = self.chat.waves.speaking.contains(&user_id); |
| 199 | + let wave = speaking.then(|| self.chat.waves.voice(user_id)).flatten(); | ||
| 200 | + let muted = (self.is_me(user_id) | ||
| 201 | + && self.chat.voice_flags().is_some_and(|(muted, _)| muted)) | ||
| 202 | + || self.chat.server_muted.contains(&user_id); | ||
| 203 | + let camera = self | ||
| 241 | .chat | 204 | .chat |
| 242 | - .share_of(community_id, user.id, Kind::Screen) | 205 | + .share_of(community_id, user_id, Kind::Camera) |
| 243 | .is_some(); | 206 | .is_some(); |
| 244 | - let camera = self | 207 | + let screen = self |
| 245 | .chat | 208 | .chat |
| 246 | - .share_of(community_id, user.id, Kind::Camera) | 209 | + .share_of(community_id, user_id, Kind::Screen) |
| 247 | .is_some(); | 210 | .is_some(); |
| 248 | - | ||
| 249 | - let user_id = user.id; | ||
| 250 | - let watch_screen = entity.clone(); | ||
| 251 | - let watch_camera = entity.clone(); | ||
| 252 | let ghost = self.chat.ghost && self.is_me(user_id); | 211 | let ghost = self.chat.ghost && self.is_me(user_id); |
| 253 | 212 | ||
| 254 | - let member = profile_popover( | 213 | + let identity = div() |
| 255 | - format!("voice_member_{user_id}"), | ||
| 256 | - Anchor::BottomLeft, | ||
| 257 | - user, | ||
| 258 | - entity, | ||
| 259 | - div() | ||
| 260 | - .flex() | ||
| 261 | - .items_center() | ||
| 262 | - .gap(px(6.)) | ||
| 263 | - .flex_1() | ||
| 264 | - .min_w_0() | ||
| 265 | - .cursor_pointer() | ||
| 266 | - .child( | ||
| 267 | - avatar(palette, user, px(18.), text(9.), &self.chat.avatars) | ||
| 268 | - .border_2() | ||
| 269 | - .border_color(if speaking { | ||
| 270 | - palette.ok | ||
| 271 | - } else { | ||
| 272 | - palette.ok.opacity(0.) | ||
| 273 | - }), | ||
| 274 | - ) | ||
| 275 | - .child( | ||
| 276 | - div() | ||
| 277 | - .flex_1() | ||
| 278 | - .min_w_0() | ||
| 279 | - .truncate() | ||
| 280 | - .text_size(text(12.)) | ||
| 281 | - .text_color(palette.text) | ||
| 282 | - .child(user.username.clone()), | ||
| 283 | - ) | ||
| 284 | - .when(ghost, |row| { | ||
| 285 | - row.child( | ||
| 286 | - Icon::new(IconName::Ghost) | ||
| 287 | - .w(px(12.)) | ||
| 288 | - .h(px(12.)) | ||
| 289 | - .text_color(palette.muted), | ||
| 290 | - ) | ||
| 291 | - }), | ||
| 292 | - ); | ||
| 293 | - | ||
| 294 | - let row = div() | ||
| 295 | .flex() | 214 | .flex() |
| 296 | .items_center() | 215 | .items_center() |
| 297 | - .gap(px(4.)) | 216 | + .gap(px(6.)) |
| 298 | - .px(px(4.)) | 217 | + .flex_1() |
| 299 | - .py(px(2.)) | 218 | + .min_w_0() |
| 300 | - .rounded(px(6.)) | 219 | + .cursor_pointer() |
| 301 | - .hover(move |style| style.bg(palette.hover)) | 220 | + .child(avatar(palette, user, px(18.), text(9.), &self.chat.avatars)) |
| 302 | - .child(div().flex_1().min_w_0().child(member)) | ||
| 303 | .child( | 221 | .child( |
| 304 | div() | 222 | div() |
| 305 | - .w(px(20.)) | 223 | + .min_w_0() |
| 306 | - .h(px(20.)) | 224 | + .truncate() |
| 307 | - .flex_shrink_0() | 225 | + .text_size(text(12.)) |
| 308 | - .when(camera, |slot| { | 226 | + .text_color(if speaking { palette.text } else { palette.body }) |
| 309 | - slot.child( | 227 | + .when(speaking, |name| name.font_weight(FontWeight::SEMIBOLD)) |
| 310 | - clickable( | 228 | + .child(user.username.clone()), |
| 311 | - format!("voice_camera_{user_id}"), | ||
| 312 | - palette, | ||
| 313 | - move |window, cx| { | ||
| 314 | - watch_camera.update(cx, |yumush, cx| { | ||
| 315 | - yumush.toggle_viewer(user_id, Kind::Camera, window, cx) | ||
| 316 | - }); | ||
| 317 | - }, | ||
| 318 | - ) | ||
| 319 | - .tip("Watch") | ||
| 320 | - .size_full() | ||
| 321 | - .flex() | ||
| 322 | - .items_center() | ||
| 323 | - .justify_center() | ||
| 324 | - .rounded(px(4.)) | ||
| 325 | - .child( | ||
| 326 | - Icon::new(IconName::Video) | ||
| 327 | - .w(px(12.)) | ||
| 328 | - .h(px(12.)) | ||
| 329 | - .text_color(palette.alert), | ||
| 330 | - ), | ||
| 331 | - ) | ||
| 332 | - }), | ||
| 333 | - ) | ||
| 334 | - .child(wave_slot(self.chat.waves.voice(user_id), 12., palette.ok)); | ||
| 335 | - | ||
| 336 | - let stream = screen.then(|| { | ||
| 337 | - clickable( | ||
| 338 | - format!("voice_screen_{user_id}"), | ||
| 339 | - palette, | ||
| 340 | - move |window, cx| { | ||
| 341 | - watch_screen.update(cx, |yumush, cx| { | ||
| 342 | - yumush.toggle_viewer(user_id, Kind::Screen, window, cx) | ||
| 343 | - }); | ||
| 344 | - }, | ||
| 345 | ) | 229 | ) |
| 346 | - .tip("Watch") | 230 | + .children(wave.map(|history| mini_wave(history, 12., palette.ok))) |
| 347 | - .flex() | 231 | + .children((muted && wave.is_none()).then(|| { |
| 348 | - .items_center() | 232 | + Icon::new(IconName::MicOff) |
| 349 | - .gap(px(4.)) | ||
| 350 | - .h(px(20.)) | ||
| 351 | - .pl(px(28.)) | ||
| 352 | - .pr(px(4.)) | ||
| 353 | - .rounded(px(6.)) | ||
| 354 | - .child( | ||
| 355 | - Icon::new(IconName::ScreenShare) | ||
| 356 | .w(px(12.)) | 233 | .w(px(12.)) |
| 357 | .h(px(12.)) | 234 | .h(px(12.)) |
| 358 | - .text_color(palette.alert), | 235 | + .text_color(palette.danger) |
| 359 | - ) | 236 | + })); |
| 360 | - .child(div().flex_1()) | ||
| 361 | - .child(wave_slot(self.chat.waves.share(user_id), 12., palette.ok)) | ||
| 362 | - }); | ||
| 363 | 237 | ||
| 364 | div() | 238 | div() |
| 239 | + .h(px(26.)) | ||
| 240 | + .px(px(6.)) | ||
| 241 | + .rounded(px(6.)) | ||
| 365 | .flex() | 242 | .flex() |
| 366 | - .flex_col() | 243 | + .items_center() |
| 367 | - .when(ghost, |member| member.opacity(0.5)) | 244 | + .gap(px(6.)) |
| 368 | - .child(row) | 245 | + .hover(move |style| style.bg(palette.hover)) |
| 369 | - .children(stream) | 246 | + .when(ghost, |row| row.opacity(0.5)) |
| 247 | + .child(div().flex_1().min_w_0().child(profile_popover( | ||
| 248 | + format!("call_member_{user_id}"), | ||
| 249 | + Anchor::BottomLeft, | ||
| 250 | + user, | ||
| 251 | + entity, | ||
| 252 | + identity, | ||
| 253 | + ))) | ||
| 254 | + .children(camera.then(|| watch_pill(entity, user_id, Kind::Camera, None, palette))) | ||
| 255 | + .children(screen.then(|| { | ||
| 256 | + watch_pill( | ||
| 257 | + entity, | ||
| 258 | + user_id, | ||
| 259 | + Kind::Screen, | ||
| 260 | + self.chat.waves.share(user_id), | ||
| 261 | + palette, | ||
| 262 | + ) | ||
| 263 | + })) | ||
| 370 | } | 264 | } |
| 371 | 265 | ||
| 372 | fn voice_dot(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> { | 266 | fn voice_dot(&self, entity: &Entity<Self>, palette: Palette) -> Option<impl IntoElement> { |
| @@ -572,14 +466,20 @@ impl Yumush { | |||
| 572 | let muted = self.chat.muted.contains(&community.id); | 466 | let muted = self.chat.muted.contains(&community.id); |
| 573 | let can_leave = !active || permission::can_leave(self.actor_rank()); | 467 | let can_leave = !active || permission::can_leave(self.actor_rank()); |
| 574 | 468 | ||
| 575 | - self.sidebar_community_row( | 469 | + let row = self.sidebar_community_row( |
| 576 | entity, | 470 | entity, |
| 577 | community, | 471 | community, |
| 578 | palette, | 472 | palette, |
| 579 | px(16.), | 473 | px(16.), |
| 580 | "community", | 474 | "community", |
| 581 | community_menu(entity, community.id, can_leave, muted), | 475 | community_menu(entity, community.id, can_leave, muted), |
| 582 | - ) | 476 | + ); |
| 477 | + div() | ||
| 478 | + .flex() | ||
| 479 | + .flex_col() | ||
| 480 | + .child(row) | ||
| 481 | + .children(self.call_tree(entity, community.id, palette)) | ||
| 482 | + .into_any_element() | ||
| 583 | }), | 483 | }), |
| 584 | ) | 484 | ) |
| 585 | } | 485 | } |
| @@ -599,6 +499,11 @@ impl Yumush { | |||
| 599 | let community_id = community.id; | 499 | let community_id = community.id; |
| 600 | let select = entity.clone(); | 500 | let select = entity.clone(); |
| 601 | 501 | ||
| 502 | + let trailing = if self.chat.voice_ids(community_id).is_empty() { | ||
| 503 | + unread_badge(palette, muted, unread) | ||
| 504 | + } else { | ||
| 505 | + Some(self.voice_chip(community_id, palette)) | ||
| 506 | + }; | ||
| 602 | let themed = palette.for_community(Some(community), &self.chat.hues); | 507 | let themed = palette.for_community(Some(community), &self.chat.hues); |
| 603 | hoverable_with( | 508 | hoverable_with( |
| 604 | format!("{key}_{}", community.id), | 509 | format!("{key}_{}", community.id), |
| @@ -607,7 +512,7 @@ impl Yumush { | |||
| 607 | active, | 512 | active, |
| 608 | self.community_badge(community, size, text(10.), palette), | 513 | self.community_badge(community, size, text(10.), palette), |
| 609 | community_name(community).to_string(), | 514 | community_name(community).to_string(), |
| 610 | - unread_badge(palette, muted, unread), | 515 | + trailing, |
| 611 | ), | 516 | ), |
| 612 | themed.accent.opacity(0.1), | 517 | themed.accent.opacity(0.1), |
| 613 | ) | 518 | ) |
| @@ -861,8 +766,7 @@ impl Yumush { | |||
| 861 | yumush.show_view(View::Builder, window, cx) | 766 | yumush.show_view(View::Builder, window, cx) |
| 862 | }), | 767 | }), |
| 863 | ) | 768 | ) |
| 864 | - })) | 769 | + })), |
| 865 | - .children(self.voice_controls(entity, palette)), | ||
| 866 | ) | 770 | ) |
| 867 | } | 771 | } |
| 868 | 772 | ||
| @@ -941,6 +845,36 @@ fn go_to_call( | |||
| 941 | }) | 845 | }) |
| 942 | } | 846 | } |
| 943 | 847 | ||
| 848 | +fn watch_pill( | ||
| 849 | + entity: &Entity<Yumush>, | ||
| 850 | + user_id: Id, | ||
| 851 | + kind: Kind, | ||
| 852 | + wave: Option<&VecDeque<f32>>, | ||
| 853 | + palette: Palette, | ||
| 854 | +) -> impl IntoElement { | ||
| 855 | + let (color, icon) = match kind { | ||
| 856 | + Kind::Camera => (palette.camera, IconName::Video), | ||
| 857 | + Kind::Screen => (palette.screen, IconName::ScreenShare), | ||
| 858 | + }; | ||
| 859 | + clickable( | ||
| 860 | + format!("voice_watch_{user_id}_{kind:?}"), | ||
| 861 | + palette, | ||
| 862 | + entity_action(entity, move |yumush, window, cx| { | ||
| 863 | + yumush.toggle_viewer(user_id, kind, window, cx) | ||
| 864 | + }), | ||
| 865 | + ) | ||
| 866 | + .tip("Watch") | ||
| 867 | + .h(px(18.)) | ||
| 868 | + .px(px(5.)) | ||
| 869 | + .flex() | ||
| 870 | + .items_center() | ||
| 871 | + .gap(px(4.)) | ||
| 872 | + .rounded(px(5.)) | ||
| 873 | + .bg(color.opacity(0.12)) | ||
| 874 | + .child(Icon::new(icon).w(px(12.)).h(px(12.)).text_color(color)) | ||
| 875 | + .children(wave.map(|history| mini_wave(history, 10., palette.screen))) | ||
| 876 | +} | ||
| 877 | + | ||
| 944 | fn call_style<E: Styled>(element: E, palette: Palette) -> E { | 878 | fn call_style<E: Styled>(element: E, palette: Palette) -> E { |
| 945 | element | 879 | element |
| 946 | .border_1() | 880 | .border_1() |
crates/client/src/gui/wave.rsmodified+26 -4
| @@ -10,6 +10,7 @@ const GONE: f32 = 0.02; | |||
| 10 | const AUDIBLE: f32 = 0.1; | 10 | const AUDIBLE: f32 = 0.1; |
| 11 | const BAR_WIDTH: f32 = 2.; | 11 | const BAR_WIDTH: f32 = 2.; |
| 12 | const MIN_BAR: f32 = 1.5; | 12 | const MIN_BAR: f32 = 1.5; |
| 13 | +const MINI_BARS: usize = 8; | ||
| 13 | 14 | ||
| 14 | pub struct Wave { | 15 | pub struct Wave { |
| 15 | bars: VecDeque<f32>, | 16 | bars: VecDeque<f32>, |
| @@ -95,19 +96,40 @@ impl Waves { | |||
| 95 | } | 96 | } |
| 96 | 97 | ||
| 97 | pub fn wave_slot(history: Option<&VecDeque<f32>>, size: f32, color: Hsla) -> Div { | 98 | pub fn wave_slot(history: Option<&VecDeque<f32>>, size: f32, color: Hsla) -> Div { |
| 99 | + slot( | ||
| 100 | + spectrum::BANDS, | ||
| 101 | + history.map(|history| history.iter().copied().collect()), | ||
| 102 | + size, | ||
| 103 | + color, | ||
| 104 | + ) | ||
| 105 | +} | ||
| 106 | + | ||
| 107 | +pub fn mini_wave(history: &VecDeque<f32>, size: f32, color: Hsla) -> Div { | ||
| 108 | + let group = history.len().div_ceil(MINI_BARS).max(1); | ||
| 109 | + let bars: Vec<f32> = history | ||
| 110 | + .iter() | ||
| 111 | + .copied() | ||
| 112 | + .collect::<Vec<_>>() | ||
| 113 | + .chunks(group) | ||
| 114 | + .map(|chunk| chunk.iter().copied().fold(0.0, f32::max)) | ||
| 115 | + .collect(); | ||
| 116 | + slot(MINI_BARS, Some(bars), size, color) | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +fn slot(count: usize, bars: Option<Vec<f32>>, size: f32, color: Hsla) -> Div { | ||
| 98 | div() | 120 | div() |
| 99 | .flex_shrink_0() | 121 | .flex_shrink_0() |
| 100 | - .w(px(spectrum::BANDS as f32 * (BAR_WIDTH + 1.))) | 122 | + .w(px(count as f32 * (BAR_WIDTH + 1.) - 1.)) |
| 101 | - .children(history.map(|history| wave(history, size, color))) | 123 | + .children(bars.map(|bars| wave(&bars, size, color))) |
| 102 | } | 124 | } |
| 103 | 125 | ||
| 104 | -fn wave(history: &VecDeque<f32>, size: f32, color: Hsla) -> Div { | 126 | +fn wave(bars: &[f32], size: f32, color: Hsla) -> Div { |
| 105 | div() | 127 | div() |
| 106 | .flex() | 128 | .flex() |
| 107 | .items_center() | 129 | .items_center() |
| 108 | .gap(px(1.)) | 130 | .gap(px(1.)) |
| 109 | .h(px(size)) | 131 | .h(px(size)) |
| 110 | - .children(history.iter().map(|bar| { | 132 | + .children(bars.iter().map(|bar| { |
| 111 | div() | 133 | div() |
| 112 | .w(px(BAR_WIDTH)) | 134 | .w(px(BAR_WIDTH)) |
| 113 | .h(px((size * bar).max(MIN_BAR))) | 135 | .h(px((size * bar).max(MIN_BAR))) |