forge
Explore
Log in

Don't you dare go Hollow

Grid holds only video (captioned below, letterboxed on raise), people without a camera stay voice lines under it

Browse files at this commit

b4e61049f1640ece2035604b9e7e6c0ff2c3ee9dAhmet Kaan GümüşParent: 155ff77
  • feat
    • grid holds only video (captioned below, letterboxed on raise), people without a camera stay voice lines under it
    • fullscreen keeps the voice lines in a band under the picture
Show full message
✨ feat: grid holds only video (captioned below, letterboxed on raise), people without a camera stay voice lines under it; fullscreen keeps the voice lines in a band under the picture
crates/client/src/gui/camera_view.rsmodified+116 -91
@@ -6,17 +6,16 @@ use common::share::{Fps, Kind, Quality, Resolution};
6 use gpui_kit::{6 use gpui_kit::{
7 AnyElement, AppContext as _, Context, Div, Entity, InteractiveElement, IntoElement,7 AnyElement, AppContext as _, Context, Div, Entity, InteractiveElement, IntoElement,
8 ParentElement, StatefulInteractiveElement, Styled, Task, Window, assets::IconName,8 ParentElement, StatefulInteractiveElement, Styled, Task, Window, assets::IconName,
9- component::Icon, div, px, transparent_black,9+ component::Icon, div, px,
10 };10 };
11 11
12 use super::{12 use super::{
13- Palette, Tooltip as _, Yumush, avatar,13+ Palette, Tooltip as _, Yumush,
14 media_view::into_render_image,14 media_view::into_render_image,
15 notify_error,15 notify_error,
16 parts::{Ink, Text, Voice, caption, scrim, voice_line, words},16 parts::{Ink, Text, Voice, caption, scrim, voice_line, words},
17- style::{radius, size, space, text},17+ style::{radius, size, space},
18 surface::Surface,18 surface::Surface,
19- text,
20 widget::spawn_warn,19 widget::spawn_warn,
21 };20 };
22 use crate::share::session::WatchQuality;21 use crate::share::session::WatchQuality;
@@ -214,7 +213,7 @@ impl Yumush {
214 ) -> Option<impl IntoElement> {213 ) -> Option<impl IntoElement> {
215 let shown = match self.chat.stage {214 let shown = match self.chat.stage {
216 Stage::Strip => true,215 Stage::Strip => true,
217- Stage::Grid => self.chat.viewer.is_some(),216+ Stage::Grid => self.chat.viewer.is_some() || self.stage_sources().is_empty(),
218 Stage::Hidden => false,217 Stage::Hidden => false,
219 };218 };
220 if !shown || !self.in_stage_chat() {219 if !shown || !self.in_stage_chat() {
@@ -250,12 +249,15 @@ impl Yumush {
250 }249 }
251 250
252 fn voices(&self, palette: Palette) -> Div {251 fn voices(&self, palette: Palette) -> Div {
253- let t = palette.tokens;
254 let ids = self252 let ids = self
255 .chat253 .chat
256 .voice_community()254 .voice_community()
257- .map(|community_id| self.chat.voice_ids(community_id))255+ .map(|community_id| self.chat.voice_ids(community_id).to_vec())
258 .unwrap_or_default();256 .unwrap_or_default();
257+ self.voices_of(&ids, palette)
258+ }
259+
260+ fn slots(&self, ids: &[Id]) -> (Vec<Id>, usize) {
259 let speaking = |id: &Id| self.chat.waves.speaking.contains(id);261 let speaking = |id: &Id| self.chat.waves.speaking.contains(id);
260 let mut shown: Vec<Id> = ids262 let mut shown: Vec<Id> = ids
261 .iter()263 .iter()
@@ -271,11 +273,17 @@ impl Yumush {
271 );273 );
272 shown.sort_by_key(|id| ids.iter().position(|other| other == id));274 shown.sort_by_key(|id| ids.iter().position(|other| other == id));
273 let more = ids.len() - shown.len();275 let more = ids.len() - shown.len();
274- let people = shown276+ (shown, more)
277+ }
278+
279+ fn voice_captions(&self, ids: &[Id], palette: Palette) -> Vec<Div> {
280+ let t = palette.tokens;
281+ let (shown, more) = self.slots(ids);
282+ shown
275 .into_iter()283 .into_iter()
276 .filter_map(|id| self.chat.author(id))284 .filter_map(|id| self.chat.author(id))
277 .map(|user| {285 .map(|user| {
278- let voice = if speaking(&user.id) {286+ let voice = if self.chat.waves.speaking.contains(&user.id) {
279 Voice::Live(t.person(user.id))287 Voice::Live(t.person(user.id))
280 } else {288 } else {
281 Voice::Quiet289 Voice::Quiet
@@ -285,8 +293,15 @@ impl Yumush {
285 voice_line(self.chat.waves.voice(user.id), voice, t),293 voice_line(self.chat.waves.voice(user.id), voice, t),
286 t,294 t,
287 )295 )
288- .w_full()296+ })
289- });297+ .chain(
298+ (more > 0)
299+ .then(|| caption(format!("{more} more"), voice_line(None, Voice::Quiet, t), t)),
300+ )
301+ .collect()
302+ }
303+
304+ fn voices_of(&self, ids: &[Id], palette: Palette) -> Div {
290 div()305 div()
291 .flex()306 .flex()
292 .flex_col()307 .flex_col()
@@ -294,10 +309,30 @@ impl Yumush {
294 .gap(px(space::MD))309 .gap(px(space::MD))
295 .px(px(space::XL))310 .px(px(space::XL))
296 .py(px(space::XL))311 .py(px(space::XL))
297- .children(people)312+ .children(
298- .children((more > 0).then(|| {313+ self.voice_captions(ids, palette)
299- caption(format!("{more} more"), voice_line(None, Voice::Quiet, t), t).w_full()314+ .into_iter()
300- }))315+ .map(|caption| caption.w_full()),
316+ )
317+ }
318+
319+ pub(super) fn voice_band(&self, palette: Palette) -> Div {
320+ let ids = self
321+ .chat
322+ .voice_community()
323+ .map(|community_id| self.chat.voice_ids(community_id).to_vec())
324+ .unwrap_or_default();
325+ div()
326+ .flex()
327+ .flex_shrink_0()
328+ .gap(px(space::XL))
329+ .px(px(space::XL))
330+ .py(px(space::LG))
331+ .children(
332+ self.voice_captions(&ids, palette)
333+ .into_iter()
334+ .map(|caption| caption.flex_1().min_w_0()),
335+ )
301 }336 }
302 337
303 pub(super) fn stage_grid(338 pub(super) fn stage_grid(
@@ -317,47 +352,48 @@ impl Yumush {
317 }352 }
318 let community_id = self.chat.voice_community()?;353 let community_id = self.chat.voice_community()?;
319 let sources = self.stage_sources();354 let sources = self.stage_sources();
320- let cells: Vec<AnyElement> = self355+ if sources.is_empty() {
356+ return None;
357+ }
358+ let quiet: Vec<Id> = self
321 .chat359 .chat
322 .voice_ids(community_id)360 .voice_ids(community_id)
323 .iter()361 .iter()
324- .map(|&user_id| {362+ .filter(|id| !sources.contains(&(**id, Kind::Camera)))
325- let shared = sources.contains(&(user_id, Kind::Camera));363+ .copied()
326- grid_cell(entity, self, palette, (user_id, Kind::Camera), shared)
327- })
328- .chain(
329- sources
330- .iter()
331- .filter(|(_, kind)| *kind == Kind::Screen)
332- .map(|&source| grid_cell(entity, self, palette, source, true)),
333- )
334 .collect();364 .collect();
335- let columns = ((cells.len() as f32).sqrt().ceil() as usize).max(1);365+ let columns = ((sources.len() as f32).sqrt().ceil() as usize).max(1);
336- let rows = cells.len().div_ceil(columns);366+ let rows = sources.len().div_ceil(columns);
337- let mut cells = cells.into_iter();367+ let mut cells = sources
368+ .into_iter()
369+ .map(|source| grid_cell(entity, self, palette, source));
338 370
339 Some(371 Some(
340 div()372 div()
341- .relative()
342 .flex_1()373 .flex_1()
343 .min_h_0()374 .min_h_0()
344- .p(px(space::SM))
345- .bg(palette.window)
346 .flex()375 .flex()
347 .flex_col()376 .flex_col()
348- .gap(px(space::SM))377+ .child(
349- .children((0..rows).map(|_| {
350 div()378 div()
351 .flex_1()379 .flex_1()
352 .min_h_0()380 .min_h_0()
381+ .px(px(space::XL))
382+ .pt(px(space::XL))
353 .flex()383 .flex()
354- .gap(px(space::SM))384+ .flex_col()
355- .children((0..columns).map(|_| {385+ .gap(px(space::LG))
356- cells386+ .children((0..rows).map(|_| {
357- .next()387+ div().flex_1().min_h_0().flex().gap(px(space::LG)).children(
358- .unwrap_or_else(|| div().flex_1().into_any_element())388+ (0..columns).map(|_| {
359- }))389+ cells
360- })),390+ .next()
391+ .unwrap_or_else(|| div().flex_1().into_any_element())
392+ }),
393+ )
394+ })),
395+ )
396+ .child(self.voices_of(&quiet, palette)),
361 )397 )
362 }398 }
363 }399 }
@@ -505,8 +541,9 @@ fn grid_cell(
505 yumush: &Yumush,541 yumush: &Yumush,
506 palette: Palette,542 palette: Palette,
507 (user_id, kind): (Id, Kind),543 (user_id, kind): (Id, Kind),
508- shared: bool,
509 ) -> AnyElement {544 ) -> AnyElement {
545+ let t = palette.tokens;
546+ let entity = entity.clone();
510 let surface = yumush547 let surface = yumush
511 .chat548 .chat
512 .tiles549 .tiles
@@ -514,61 +551,49 @@ fn grid_cell(
514 .filter(|tile| tile.shown)551 .filter(|tile| tile.shown)
515 .map(|tile| tile.surface.clone());552 .map(|tile| tile.surface.clone());
516 let speaking = yumush.chat.waves.speaking.contains(&user_id);553 let speaking = yumush.chat.waves.speaking.contains(&user_id);
517- let user = yumush.chat.author(user_id);554+ let name = yumush
518- let content = match (surface, user) {555+ .chat
519- (Some(surface), _) => surface.into_any_element(),556+ .author(user_id)
520- (None, Some(user)) => div()557+ .map_or_else(|| user_id.to_string(), |user| user.username.clone());
521- .size_full()558+
522- .flex()559+ div()
523- .items_center()
524- .justify_center()
525- .child(avatar(
526- palette,
527- user,
528- px(size::AVATAR_LG),
529- text(text::TITLE),
530- &yumush.chat.avatars,
531- ))
532- .into_any_element(),
533- (None, None) => div().into_any_element(),
534- };
535-
536- let cell = div()
537 .id(format!("grid_{user_id}_{kind:?}"))560 .id(format!("grid_{user_id}_{kind:?}"))
538- .relative()
539 .flex_1()561 .flex_1()
540 .min_w_0()562 .min_w_0()
541 .min_h_0()563 .min_h_0()
542- .rounded(px(radius::MD))564+ .flex()
543- .overflow_hidden()565+ .flex_col()
544- .bg(gpui_kit::black())566+ .gap(px(space::SM))
545- .border_2()567+ .cursor_pointer()
546- .border_color(if speaking {568+ .tip("Watch")
547- palette.tokens.person(user_id)569+ .on_click(move |_, window, cx| {
548- } else {570+ entity.update(cx, |yumush, cx| {
549- transparent_black()571+ yumush.toggle_viewer(user_id, kind, window, cx)
572+ });
550 })573 })
551- .child(content)
552 .child(574 .child(
553- tile_label(yumush, palette, (user_id, kind))575+ div()
554- .absolute()576+ .flex_1()
555- .left(px(space::SM))577+ .min_h_0()
556- .bottom(px(space::SM)),578+ .rounded(px(radius::MD))
557- );579+ .overflow_hidden()
558-580+ .bg(t.raise())
559- if shared {581+ .children(surface),
560- let entity = entity.clone();582+ )
561- cell.cursor_pointer()583+ .child(caption(
562- .tip("Watch")584+ name,
563- .on_click(move |_, window, cx| {585+ voice_line(
564- entity.update(cx, |yumush, cx| {586+ yumush.chat.waves.voice(user_id),
565- yumush.toggle_viewer(user_id, kind, window, cx)587+ if speaking {
566- });588+ Voice::Live(t.person(user_id))
567- })589+ } else {
568- .into_any_element()590+ Voice::Quiet
569- } else {591+ },
570- cell.into_any_element()592+ t,
571- }593+ ),
594+ t,
595+ ))
596+ .into_any_element()
572 }597 }
573 598
574 pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, _): (Id, Kind)) -> Div {599 pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, _): (Id, Kind)) -> Div {
crates/client/src/gui/share_view.rsmodified+7 -2
@@ -549,9 +549,14 @@ impl Yumush {
549 .as_ref()549 .as_ref()
550 .filter(|viewer| viewer.fullscreen && self.chat.view == View::Chat)?;550 .filter(|viewer| viewer.fullscreen && self.chat.view == View::Chat)?;
551 Some(551 Some(
552- self.viewer_pane(viewer, entity, palette)552+ div()
553 .absolute()553 .absolute()
554- .inset_0(),554+ .inset_0()
555+ .flex()
556+ .flex_col()
557+ .bg(palette.window)
558+ .child(self.viewer_pane(viewer, entity, palette))
559+ .child(self.voice_band(palette)),
555 )560 )
556 }561 }
557 562