From b4e61049f1640ece2035604b9e7e6c0ff2c3ee9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 27 Nov 2026 19:41:01 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20grid=20holds=20only=20video?= =?UTF-8?q?=20(captioned=20below,=20letterboxed=20on=20raise),=20people=20?= =?UTF-8?q?without=20a=20camera=20stay=20voice=20lines=20under=20it;=20ful?= =?UTF-8?q?lscreen=20keeps=20the=20voice=20lines=20in=20a=20band=20under?= =?UTF-8?q?=20the=20picture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/gui/camera_view.rs | 207 +++++++++++++++------------ crates/client/src/gui/share_view.rs | 9 +- 2 files changed, 123 insertions(+), 93 deletions(-) diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index df8d037..47eafa2 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -6,17 +6,16 @@ use common::share::{Fps, Kind, Quality, Resolution}; use gpui_kit::{ AnyElement, AppContext as _, Context, Div, Entity, InteractiveElement, IntoElement, ParentElement, StatefulInteractiveElement, Styled, Task, Window, assets::IconName, - component::Icon, div, px, transparent_black, + component::Icon, div, px, }; use super::{ - Palette, Tooltip as _, Yumush, avatar, + Palette, Tooltip as _, Yumush, media_view::into_render_image, notify_error, parts::{Ink, Text, Voice, caption, scrim, voice_line, words}, - style::{radius, size, space, text}, + style::{radius, size, space}, surface::Surface, - text, widget::spawn_warn, }; use crate::share::session::WatchQuality; @@ -214,7 +213,7 @@ impl Yumush { ) -> Option { let shown = match self.chat.stage { Stage::Strip => true, - Stage::Grid => self.chat.viewer.is_some(), + Stage::Grid => self.chat.viewer.is_some() || self.stage_sources().is_empty(), Stage::Hidden => false, }; if !shown || !self.in_stage_chat() { @@ -250,12 +249,15 @@ impl Yumush { } fn voices(&self, palette: Palette) -> Div { - let t = palette.tokens; let ids = self .chat .voice_community() - .map(|community_id| self.chat.voice_ids(community_id)) + .map(|community_id| self.chat.voice_ids(community_id).to_vec()) .unwrap_or_default(); + self.voices_of(&ids, palette) + } + + fn slots(&self, ids: &[Id]) -> (Vec, usize) { let speaking = |id: &Id| self.chat.waves.speaking.contains(id); let mut shown: Vec = ids .iter() @@ -271,11 +273,17 @@ impl Yumush { ); shown.sort_by_key(|id| ids.iter().position(|other| other == id)); let more = ids.len() - shown.len(); - let people = shown + (shown, more) + } + + fn voice_captions(&self, ids: &[Id], palette: Palette) -> Vec
{ + let t = palette.tokens; + let (shown, more) = self.slots(ids); + shown .into_iter() .filter_map(|id| self.chat.author(id)) .map(|user| { - let voice = if speaking(&user.id) { + let voice = if self.chat.waves.speaking.contains(&user.id) { Voice::Live(t.person(user.id)) } else { Voice::Quiet @@ -285,8 +293,15 @@ impl Yumush { voice_line(self.chat.waves.voice(user.id), voice, t), t, ) - .w_full() - }); + }) + .chain( + (more > 0) + .then(|| caption(format!("{more} more"), voice_line(None, Voice::Quiet, t), t)), + ) + .collect() + } + + fn voices_of(&self, ids: &[Id], palette: Palette) -> Div { div() .flex() .flex_col() @@ -294,10 +309,30 @@ impl Yumush { .gap(px(space::MD)) .px(px(space::XL)) .py(px(space::XL)) - .children(people) - .children((more > 0).then(|| { - caption(format!("{more} more"), voice_line(None, Voice::Quiet, t), t).w_full() - })) + .children( + self.voice_captions(ids, palette) + .into_iter() + .map(|caption| caption.w_full()), + ) + } + + pub(super) fn voice_band(&self, palette: Palette) -> Div { + let ids = self + .chat + .voice_community() + .map(|community_id| self.chat.voice_ids(community_id).to_vec()) + .unwrap_or_default(); + div() + .flex() + .flex_shrink_0() + .gap(px(space::XL)) + .px(px(space::XL)) + .py(px(space::LG)) + .children( + self.voice_captions(&ids, palette) + .into_iter() + .map(|caption| caption.flex_1().min_w_0()), + ) } pub(super) fn stage_grid( @@ -317,47 +352,48 @@ impl Yumush { } let community_id = self.chat.voice_community()?; let sources = self.stage_sources(); - let cells: Vec = self + if sources.is_empty() { + return None; + } + let quiet: Vec = self .chat .voice_ids(community_id) .iter() - .map(|&user_id| { - let shared = sources.contains(&(user_id, Kind::Camera)); - grid_cell(entity, self, palette, (user_id, Kind::Camera), shared) - }) - .chain( - sources - .iter() - .filter(|(_, kind)| *kind == Kind::Screen) - .map(|&source| grid_cell(entity, self, palette, source, true)), - ) + .filter(|id| !sources.contains(&(**id, Kind::Camera))) + .copied() .collect(); - let columns = ((cells.len() as f32).sqrt().ceil() as usize).max(1); - let rows = cells.len().div_ceil(columns); - let mut cells = cells.into_iter(); + let columns = ((sources.len() as f32).sqrt().ceil() as usize).max(1); + let rows = sources.len().div_ceil(columns); + let mut cells = sources + .into_iter() + .map(|source| grid_cell(entity, self, palette, source)); Some( div() - .relative() .flex_1() .min_h_0() - .p(px(space::SM)) - .bg(palette.window) .flex() .flex_col() - .gap(px(space::SM)) - .children((0..rows).map(|_| { + .child( div() .flex_1() .min_h_0() + .px(px(space::XL)) + .pt(px(space::XL)) .flex() - .gap(px(space::SM)) - .children((0..columns).map(|_| { - cells - .next() - .unwrap_or_else(|| div().flex_1().into_any_element()) - })) - })), + .flex_col() + .gap(px(space::LG)) + .children((0..rows).map(|_| { + div().flex_1().min_h_0().flex().gap(px(space::LG)).children( + (0..columns).map(|_| { + cells + .next() + .unwrap_or_else(|| div().flex_1().into_any_element()) + }), + ) + })), + ) + .child(self.voices_of(&quiet, palette)), ) } } @@ -505,8 +541,9 @@ fn grid_cell( yumush: &Yumush, palette: Palette, (user_id, kind): (Id, Kind), - shared: bool, ) -> AnyElement { + let t = palette.tokens; + let entity = entity.clone(); let surface = yumush .chat .tiles @@ -514,61 +551,49 @@ fn grid_cell( .filter(|tile| tile.shown) .map(|tile| tile.surface.clone()); let speaking = yumush.chat.waves.speaking.contains(&user_id); - let user = yumush.chat.author(user_id); - let content = match (surface, user) { - (Some(surface), _) => surface.into_any_element(), - (None, Some(user)) => div() - .size_full() - .flex() - .items_center() - .justify_center() - .child(avatar( - palette, - user, - px(size::AVATAR_LG), - text(text::TITLE), - &yumush.chat.avatars, - )) - .into_any_element(), - (None, None) => div().into_any_element(), - }; - - let cell = div() + let name = yumush + .chat + .author(user_id) + .map_or_else(|| user_id.to_string(), |user| user.username.clone()); + + div() .id(format!("grid_{user_id}_{kind:?}")) - .relative() .flex_1() .min_w_0() .min_h_0() - .rounded(px(radius::MD)) - .overflow_hidden() - .bg(gpui_kit::black()) - .border_2() - .border_color(if speaking { - palette.tokens.person(user_id) - } else { - transparent_black() + .flex() + .flex_col() + .gap(px(space::SM)) + .cursor_pointer() + .tip("Watch") + .on_click(move |_, window, cx| { + entity.update(cx, |yumush, cx| { + yumush.toggle_viewer(user_id, kind, window, cx) + }); }) - .child(content) .child( - tile_label(yumush, palette, (user_id, kind)) - .absolute() - .left(px(space::SM)) - .bottom(px(space::SM)), - ); - - if shared { - let entity = entity.clone(); - cell.cursor_pointer() - .tip("Watch") - .on_click(move |_, window, cx| { - entity.update(cx, |yumush, cx| { - yumush.toggle_viewer(user_id, kind, window, cx) - }); - }) - .into_any_element() - } else { - cell.into_any_element() - } + div() + .flex_1() + .min_h_0() + .rounded(px(radius::MD)) + .overflow_hidden() + .bg(t.raise()) + .children(surface), + ) + .child(caption( + name, + voice_line( + yumush.chat.waves.voice(user_id), + if speaking { + Voice::Live(t.person(user_id)) + } else { + Voice::Quiet + }, + t, + ), + t, + )) + .into_any_element() } pub(super) fn tile_label(yumush: &Yumush, palette: Palette, (user_id, _): (Id, Kind)) -> Div { diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index 7c1070c..d906694 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -549,9 +549,14 @@ impl Yumush { .as_ref() .filter(|viewer| viewer.fullscreen && self.chat.view == View::Chat)?; Some( - self.viewer_pane(viewer, entity, palette) + div() .absolute() - .inset_0(), + .inset_0() + .flex() + .flex_col() + .bg(palette.window) + .child(self.viewer_pane(viewer, entity, palette)) + .child(self.voice_band(palette)), ) }