Sidebar call meter shows the room's total spectrum (all speakers summed
Browse files at this commit3f99fc41586b3136c0b4af73d71f0e99939a592fParent: 935daa5- feat
- sidebar call meter shows the room's total spectrum (all speakers summed
- one speaker's hue, several = paper), also for your own call
- chevron folds your call's member list, meter stays
3 changed files +58 -18
- crates/client/src/gui/chat.rs +2 -0
- crates/client/src/gui/sidebar.rs +45 -18
- crates/client/src/gui/wave.rs +11 -0
crates/client/src/gui/chat.rsmodified+2 -0
| @@ -134,6 +134,7 @@ pub struct Chat { | |||
| 134 | pub(super) selected_community_id: Option<Id>, | 134 | pub(super) selected_community_id: Option<Id>, |
| 135 | pub(super) opened: Option<Community>, | 135 | pub(super) opened: Option<Community>, |
| 136 | pub(super) ghost: bool, | 136 | pub(super) ghost: bool, |
| 137 | + pub(super) call_folded: bool, | ||
| 137 | pub(super) members: Vec<Member>, | 138 | pub(super) members: Vec<Member>, |
| 138 | pub(super) messages: Vec<Message>, | 139 | pub(super) messages: Vec<Message>, |
| 139 | pub(super) pins: Vec<Message>, | 140 | pub(super) pins: Vec<Message>, |
| @@ -377,6 +378,7 @@ impl Chat { | |||
| 377 | selected_community_id: None, | 378 | selected_community_id: None, |
| 378 | opened: None, | 379 | opened: None, |
| 379 | ghost: false, | 380 | ghost: false, |
| 381 | + call_folded: false, | ||
| 380 | members: vec![], | 382 | members: vec![], |
| 381 | bans: vec![], | 383 | bans: vec![], |
| 382 | ban_search, | 384 | ban_search, |
crates/client/src/gui/sidebar.rsmodified+45 -18
| @@ -167,31 +167,33 @@ impl Yumush { | |||
| 167 | .into_any_element() | 167 | .into_any_element() |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | - fn voice_chip(&self, community_id: Id, palette: Palette) -> AnyElement { | 170 | + fn voice_chip(&self, entity: &Entity<Self>, community_id: Id, palette: Palette) -> AnyElement { |
| 171 | let ids = self.chat.voice_ids(community_id); | 171 | let ids = self.chat.voice_ids(community_id); |
| 172 | - let speaker = ids | 172 | + let t = palette.tokens; |
| 173 | + let mut speakers = ids | ||
| 173 | .iter() | 174 | .iter() |
| 174 | - .find(|id| self.chat.waves.speaking.contains(id)) | 175 | + .filter(|id| self.chat.waves.speaking.contains(id)); |
| 175 | - .copied(); | 176 | + let voice = match (speakers.next(), speakers.next()) { |
| 176 | - let wave = speaker.and_then(|id| self.chat.waves.voice(id)); | 177 | + (Some(id), None) => super::parts::Voice::Live(t.person(*id)), |
| 177 | - let voice = match speaker { | 178 | + (Some(_), Some(_)) => super::parts::Voice::Live(t.paper()), |
| 178 | - Some(id) => super::parts::Voice::Live(palette.tokens.person(id)), | 179 | + _ => super::parts::Voice::Quiet, |
| 179 | - None => super::parts::Voice::Quiet, | ||
| 180 | }; | 180 | }; |
| 181 | + let total = self.chat.waves.total(ids); | ||
| 182 | + let own = self.chat.voice_community() == Some(community_id); | ||
| 183 | + let folded = self.chat.call_folded; | ||
| 184 | + let fold = entity.clone(); | ||
| 181 | div() | 185 | div() |
| 182 | .id(format!("voice_chip_{community_id}")) | 186 | .id(format!("voice_chip_{community_id}")) |
| 183 | .tip("In call") | 187 | .tip("In call") |
| 184 | .flex() | 188 | .flex() |
| 185 | .items_center() | 189 | .items_center() |
| 186 | .gap(px(space::XS)) | 190 | .gap(px(space::XS)) |
| 187 | - .when(self.chat.voice_community() != Some(community_id), |this| { | 191 | + .child( |
| 188 | - this.child( | 192 | + div() |
| 189 | - div() | 193 | + .w(px(size::CONTROL)) |
| 190 | - .w(px(size::CONTROL)) | 194 | + .h(px(space::MD)) |
| 191 | - .h(px(space::MD)) | 195 | + .child(super::parts::voice_line(total.as_ref(), voice, t)), |
| 192 | - .child(super::parts::voice_line(wave, voice, palette.tokens)), | 196 | + ) |
| 193 | - ) | ||
| 194 | - }) | ||
| 195 | .when(!self.is_direct(community_id), |this| { | 197 | .when(!self.is_direct(community_id), |this| { |
| 196 | this.child( | 198 | this.child( |
| 197 | div() | 199 | div() |
| @@ -200,11 +202,36 @@ impl Yumush { | |||
| 200 | .child(ids.len().to_string()), | 202 | .child(ids.len().to_string()), |
| 201 | ) | 203 | ) |
| 202 | }) | 204 | }) |
| 205 | + .when(own, |this| { | ||
| 206 | + this.child( | ||
| 207 | + div() | ||
| 208 | + .id(format!("call_fold_{community_id}")) | ||
| 209 | + .flex_none() | ||
| 210 | + .cursor_pointer() | ||
| 211 | + .text_color(t.faint()) | ||
| 212 | + .hover(|style| style.text_color(t.paper())) | ||
| 213 | + .on_click(move |_, _, cx| { | ||
| 214 | + cx.stop_propagation(); | ||
| 215 | + fold.update(cx, |yumush, cx| { | ||
| 216 | + yumush.chat.call_folded = !yumush.chat.call_folded; | ||
| 217 | + cx.notify(); | ||
| 218 | + }); | ||
| 219 | + }) | ||
| 220 | + .child( | ||
| 221 | + Icon::new(if folded { | ||
| 222 | + IconName::ChevronRight | ||
| 223 | + } else { | ||
| 224 | + IconName::ChevronDown | ||
| 225 | + }) | ||
| 226 | + .size(px(size::ICON_SM)), | ||
| 227 | + ), | ||
| 228 | + ) | ||
| 229 | + }) | ||
| 203 | .into_any_element() | 230 | .into_any_element() |
| 204 | } | 231 | } |
| 205 | 232 | ||
| 206 | fn call_tree(&self, entity: &Entity<Self>, community_id: Id, palette: Palette) -> Option<Div> { | 233 | fn call_tree(&self, entity: &Entity<Self>, community_id: Id, palette: Palette) -> Option<Div> { |
| 207 | - if self.chat.voice_community() != Some(community_id) { | 234 | + if self.chat.voice_community() != Some(community_id) || self.chat.call_folded { |
| 208 | return None; | 235 | return None; |
| 209 | } | 236 | } |
| 210 | let members = self | 237 | let members = self |
| @@ -530,7 +557,7 @@ impl Yumush { | |||
| 530 | let trailing = if self.chat.voice_ids(community_id).is_empty() { | 557 | let trailing = if self.chat.voice_ids(community_id).is_empty() { |
| 531 | unread_badge(palette, muted, unread) | 558 | unread_badge(palette, muted, unread) |
| 532 | } else { | 559 | } else { |
| 533 | - Some(self.voice_chip(community_id, palette)) | 560 | + Some(self.voice_chip(entity, community_id, palette)) |
| 534 | }; | 561 | }; |
| 535 | let face = match &community.kind { | 562 | let face = match &community.kind { |
| 536 | CommunityKind::Direct { peer } => Some(presence_avatar( | 563 | CommunityKind::Direct { peer } => Some(presence_avatar( |
crates/client/src/gui/wave.rsmodified+11 -0
| @@ -127,6 +127,17 @@ impl Waves { | |||
| 127 | self.voice.get(&id).map(|wave| &wave.bars) | 127 | self.voice.get(&id).map(|wave| &wave.bars) |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | + pub fn total(&self, ids: &[Id]) -> Option<VecDeque<f32>> { | ||
| 131 | + let mut waves = ids.iter().filter_map(|id| self.voice(*id)); | ||
| 132 | + let first = waves.next()?.clone(); | ||
| 133 | + Some(waves.fold(first, |mut sum, bars| { | ||
| 134 | + sum.iter_mut() | ||
| 135 | + .zip(bars) | ||
| 136 | + .for_each(|(sum, bar)| *sum = (*sum + bar).min(1.)); | ||
| 137 | + sum | ||
| 138 | + })) | ||
| 139 | + } | ||
| 140 | + | ||
| 130 | pub fn share(&self, id: Id) -> Option<&VecDeque<f32>> { | 141 | pub fn share(&self, id: Id) -> Option<&VecDeque<f32>> { |
| 131 | self.share.get(&id).map(|wave| &wave.bars) | 142 | self.share.get(&id).map(|wave| &wave.bars) |
| 132 | } | 143 | } |