From 155ff774d419b8118e81b22836cc0b4404591ee4 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:38:23 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20speaker=20slots=20(six=20vo?= =?UTF-8?q?ice=20lines,=20speakers=20take=20a=20slot,=20'N=20more');=20scr?= =?UTF-8?q?eens=20strip=20of=20captioned=20thumbnails=20with=20a=20'+N=20s?= =?UTF-8?q?creens'=20tile=20into=20the=20grid;=20rooms=20with=20unread=20f?= =?UTF-8?q?irst;=20colour=20only=20on=20people=20(speaking=20edges=20in=20?= =?UTF-8?q?their=20hue,=20call=20log=20and=20toggles=20in=20ink)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/src/gui/camera_view.rs | 178 +++++++++++++++--------- crates/client/src/gui/chat.rs | 4 +- crates/client/src/gui/share_view.rs | 2 +- crates/client/src/gui/sidebar.rs | 103 ++++++++------ crates/client/src/gui/voice_settings.rs | 2 +- 5 files changed, 173 insertions(+), 116 deletions(-) diff --git a/crates/client/src/gui/camera_view.rs b/crates/client/src/gui/camera_view.rs index 2b76ff7..df8d037 100644 --- a/crates/client/src/gui/camera_view.rs +++ b/crates/client/src/gui/camera_view.rs @@ -10,7 +10,7 @@ use gpui_kit::{ }; use super::{ - Palette, Tooltip as _, Yumush, avatar, clickable, + Palette, Tooltip as _, Yumush, avatar, media_view::into_render_image, notify_error, parts::{Ink, Text, Voice, caption, scrim, voice_line, words}, @@ -21,12 +21,13 @@ use super::{ }; use crate::share::session::WatchQuality; +const SLOTS: usize = 6; const IDLE_TICK: Duration = Duration::from_millis(250); const FRAME_TICK: Duration = Duration::from_millis(16); const PUMP_STALL: Duration = Duration::from_millis(50); -const STRIP_H: f32 = 206.; -const TILE_W: f32 = 338.; -const TILE_H: f32 = 190.; +const STRIP_MAX: usize = 5; +const TILE_W: f32 = size::THUMB * 1.5; +const TILE_H: f32 = TILE_W * 9. / 16.; pub(super) const TILE_QUALITY: WatchQuality = WatchQuality::Fixed(Quality { resolution: Resolution::P360, @@ -219,22 +220,23 @@ impl Yumush { if !shown || !self.in_stage_chat() { return None; } - let tiles: Vec<_> = self - .stage_sources() - .into_iter() - .map(|source| stage_tile(entity, self, palette, source)) - .collect(); - let strip = (!tiles.is_empty()).then(|| { + let sources = self.stage_sources(); + let more = sources.len().saturating_sub(STRIP_MAX); + let strip = (!sources.is_empty()).then(|| { div() .id("stage_strip") .flex() .flex_shrink_0() - .h(px(STRIP_H)) - .gap(px(space::SM)) + .gap(px(space::LG)) .px(px(space::XL)) - .pb(px(space::SM)) - .overflow_x_scroll() - .children(tiles) + .pb(px(space::LG)) + .children( + sources + .into_iter() + .take(STRIP_MAX) + .map(|source| stage_tile(entity, self, palette, source).into_any_element()), + ) + .children((more > 0).then(|| more_tile(entity, more, palette).into_any_element())) }); Some( @@ -249,16 +251,31 @@ impl Yumush { fn voices(&self, palette: Palette) -> Div { let t = palette.tokens; - let people = self + let ids = self .chat .voice_community() .map(|community_id| self.chat.voice_ids(community_id)) - .unwrap_or_default() + .unwrap_or_default(); + let speaking = |id: &Id| self.chat.waves.speaking.contains(id); + let mut shown: Vec = ids .iter() - .filter_map(|id| self.chat.author(*id)) + .filter(|id| speaking(id)) + .take(SLOTS) + .copied() + .collect(); + shown.extend( + ids.iter() + .filter(|id| !speaking(id)) + .take(SLOTS - shown.len()) + .copied(), + ); + shown.sort_by_key(|id| ids.iter().position(|other| other == id)); + let more = ids.len() - shown.len(); + let people = shown + .into_iter() + .filter_map(|id| self.chat.author(id)) .map(|user| { - let speaking = self.chat.waves.speaking.contains(&user.id); - let voice = if speaking { + let voice = if speaking(&user.id) { Voice::Live(t.person(user.id)) } else { Voice::Quiet @@ -278,6 +295,9 @@ impl Yumush { .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() + })) } pub(super) fn stage_grid( @@ -396,6 +416,7 @@ fn stage_tile( palette: Palette, (user_id, kind): (Id, Kind), ) -> impl IntoElement { + let t = palette.tokens; let entity = entity.clone(); let focused = yumush.is_watching(user_id, kind); let speaking = yumush.chat.waves.speaking.contains(&user_id); @@ -405,57 +426,78 @@ fn stage_tile( .get(&(user_id, kind)) .filter(|tile| tile.shown) .map(|tile| tile.surface.clone()); - 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 name = yumush + .chat + .author(user_id) + .map_or_else(|| user_id.to_string(), |user| user.username.clone()); - clickable( - format!("stage_{user_id}_{kind:?}"), - palette, - move |window, cx| { + div() + .id(format!("stage_{user_id}_{kind:?}")) + .tip("Watch") + .cursor_pointer() + .flex() + .flex_col() + .flex_shrink_0() + .gap(px(space::SM)) + .w(px(TILE_W)) + .on_click(move |_, window, cx| { entity.update(cx, |yumush, cx| { yumush.toggle_viewer(user_id, kind, window, cx) }); - }, - ) - .tip("Watch") - .relative() - .flex_shrink_0() - .w(px(TILE_W)) - .h(px(TILE_H)) - .rounded(px(radius::MD)) - .overflow_hidden() - .bg(gpui_kit::black()) - .border_2() - .border_color(if focused { - palette.accent - } else if speaking { - palette.ok - } else { - transparent_black() - }) - .child(content) - .child( - tile_label(yumush, palette, (user_id, kind)) - .absolute() - .left(px(space::SM)) - .bottom(px(space::SM)), - ) + }) + .child( + div() + .h(px(TILE_H)) + .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 if focused { + Voice::Live(t.paper()) + } else { + Voice::Quiet + }, + t, + ), + t, + )) +} + +fn more_tile(entity: &Entity, more: usize, palette: Palette) -> impl IntoElement { + let t = palette.tokens; + let entity = entity.clone(); + div() + .id("stage_more") + .cursor_pointer() + .flex() + .flex_col() + .flex_shrink_0() + .gap(px(space::SM)) + .w(px(TILE_W)) + .on_click(move |_, _, cx| { + entity.update(cx, |yumush, cx| { + yumush.close_viewer(cx); + yumush.set_stage(Stage::Grid, cx); + }); + }) + .child( + div() + .h(px(TILE_H)) + .flex() + .items_center() + .justify_center() + .rounded(px(radius::MD)) + .bg(t.raise()) + .child(words(format!("+{more}"), Text::Title, Ink::Paper, t)), + ) + .child(caption("screens", voice_line(None, Voice::Quiet, t), t)) } fn grid_cell( @@ -502,7 +544,7 @@ fn grid_cell( .bg(gpui_kit::black()) .border_2() .border_color(if speaking { - palette.ok + palette.tokens.person(user_id) } else { transparent_black() }) diff --git a/crates/client/src/gui/chat.rs b/crates/client/src/gui/chat.rs index 9af485d..ee6e50a 100644 --- a/crates/client/src/gui/chat.rs +++ b/crates/client/src/gui/chat.rs @@ -2852,7 +2852,7 @@ fn render_call( .map_or("unknown", |user| user.username.as_str()); let who = if mine { "You" } else { author }; let (icon, color) = match call { - CallLog::Started | CallLog::Ended { .. } => (IconName::Phone, palette.ok), + CallLog::Started | CallLog::Ended { .. } => (IconName::Phone, palette.muted), CallLog::Declined => (IconName::PhoneOff, palette.danger), CallLog::Missed => (IconName::PhoneMissed, palette.danger), }; @@ -3138,7 +3138,7 @@ fn stats_button(entity: &Entity, palette: Palette, open: bool) -> impl I .justify_center() .rounded(px(radius::MD)) .when(open, |this| this.bg(palette.tokens.press())) - .text_color(if open { palette.ok } else { palette.muted }) + .text_color(if open { palette.text } else { palette.muted }) .child(Icon::new(IconName::Activity).size(px(size::ICON_SM))) } diff --git a/crates/client/src/gui/share_view.rs b/crates/client/src/gui/share_view.rs index 89332b3..7c1070c 100644 --- a/crates/client/src/gui/share_view.rs +++ b/crates/client/src/gui/share_view.rs @@ -935,6 +935,6 @@ fn pick_row( Icon::new(IconName::Check) .size(px(size::ICON_SM)) .flex_shrink_0() - .text_color(palette.ok) + .text_color(palette.text) })) } diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index b870905..f5284ef 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -340,7 +340,7 @@ impl Yumush { .child( Icon::new(IconName::AudioLines) .size(px(size::ICON_SM)) - .text_color(palette.ok), + .text_color(palette.text), ), ) } @@ -476,30 +476,33 @@ impl Yumush { fn communities_list(&self, entity: &Entity, palette: Palette) -> Div { div().flex().flex_col().gap(px(space::XXS)).children( - self.chat - .communities - .iter() - .chain(self.chat.opened.as_ref()) - .filter(|community| matches!(community.kind, CommunityKind::Group)) - .map(|community| { - let active = self.chat.is_selected(community.id); - let muted = self.chat.muted.contains(&community.id); - let can_leave = !active || permission::can_leave(self.actor_rank()); - - let row = self.sidebar_community_row( - entity, - community, - palette, - "community", - community_menu(entity, community.id, can_leave, muted), - ); - div() - .flex() - .flex_col() - .child(row) - .children(self.call_tree(entity, community.id, palette)) - .into_any_element() - }), + self.unread_first( + self.chat + .communities + .iter() + .chain(self.chat.opened.as_ref()) + .filter(|community| matches!(community.kind, CommunityKind::Group)), + ) + .into_iter() + .map(|community| { + let active = self.chat.is_selected(community.id); + let muted = self.chat.muted.contains(&community.id); + let can_leave = !active || permission::can_leave(self.actor_rank()); + + let row = self.sidebar_community_row( + entity, + community, + palette, + "community", + community_menu(entity, community.id, can_leave, muted), + ); + div() + .flex() + .flex_col() + .child(row) + .children(self.call_tree(entity, community.id, palette)) + .into_any_element() + }), ) } @@ -574,26 +577,38 @@ impl Yumush { group("Requests", palette, rows) } - fn direct_rows(&self, entity: &Entity, query: &str, palette: Palette) -> Vec { - self.chat - .communities - .iter() - .filter(|community| community.kind.is_direct()) - .filter(|community| matches_query(community_name(community), query)) - .map(|community| { - let muted = self.chat.muted.contains(&community.id); - let menu_entity = entity.clone(); - let menu_id = community.id; + fn unread_first<'a>(&self, rooms: impl Iterator) -> Vec<&'a Community> { + let mut rooms: Vec<&Community> = rooms.collect(); + rooms.sort_by_key(|community| { + self.chat + .unread + .get(&community.id) + .map_or((true, true), |unread| { + (unread.mentions == 0, unread.messages == 0) + }) + }); + rooms + } - self.sidebar_community_row( - entity, - community, - palette, - "direct", - move |menu, _, _| mute_item(menu, &menu_entity, menu_id, muted), - ) + fn direct_rows(&self, entity: &Entity, query: &str, palette: Palette) -> Vec { + self.unread_first( + self.chat + .communities + .iter() + .filter(|community| community.kind.is_direct()) + .filter(|community| matches_query(community_name(community), query)), + ) + .into_iter() + .map(|community| { + let muted = self.chat.muted.contains(&community.id); + let menu_entity = entity.clone(); + let menu_id = community.id; + + self.sidebar_community_row(entity, community, palette, "direct", move |menu, _, _| { + mute_item(menu, &menu_entity, menu_id, muted) }) - .collect() + }) + .collect() } fn friend_rows(&self, entity: &Entity, query: &str, palette: Palette) -> Vec { @@ -937,7 +952,7 @@ fn watch_pill( palette.muted }), ) - .children(wave.map(|history| mini_wave(history, 10., palette.screen))) + .children(wave.map(|history| mini_wave(history, 10., palette.text))) } pub(super) fn unread_badge( diff --git a/crates/client/src/gui/voice_settings.rs b/crates/client/src/gui/voice_settings.rs index 857dabb..0c3532c 100644 --- a/crates/client/src/gui/voice_settings.rs +++ b/crates/client/src/gui/voice_settings.rs @@ -193,7 +193,7 @@ fn level_bar(level: Option, threshold: f32, palette: Palette) -> Div { ((db - range.start()) / (range.end() - range.start())).clamp(0.0, 1.0) }); let color = if level.is_some_and(|db| db >= threshold) { - palette.ok + palette.text } else { palette.muted };