BlueGit

ict rusty-teams

fix(calls): controls fold into the more menu when the row does not fit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-13 · 7 weeks ago

Hash
f7e02c4feaaab27360f8119bd7d3d386288dc769
Parent
5a13efe3
8 files changed +410 −45
crates/app/src/call/demo.rs +12 −1
@@ -754,7 +754,10 @@ fn demo_spotlight(rank: u64) -> PublishedState {
754 754 }
755 755
756 756 fn demo_caption(people: &[Person], tick: usize) -> Option<CaptionEntry> {
757 let line = tick / (CAPTION_HOLD_TICKS * 2) % DEMO_CAPTIONS.len();
757 let line = tick / (CAPTION_HOLD_TICKS * 2);
758 if line >= DEMO_CAPTIONS.len() {
759 return None;
760 }
758 761 let within = tick % (CAPTION_HOLD_TICKS * 2);
759 762 let (speaker, text) = DEMO_CAPTIONS[line];
760 763 let words: Vec<&str> = text.split(' ').collect();
@@ -839,6 +842,14 @@ mod tests {
839 842 assert!(roster.iter().all(|entry| entry.mri != DEMO_OWN_MRI));
840 843 }
841 844
845 #[test]
846 fn demo_captions_stop_after_the_last_line() {
847 let people = demo_guests(3);
848 let ticks_per_line = CAPTION_HOLD_TICKS * 2;
849 assert!(demo_caption(&people, ticks_per_line * DEMO_CAPTIONS.len() - 1).is_some());
850 assert!(demo_caption(&people, ticks_per_line * DEMO_CAPTIONS.len()).is_none());
851 }
852
842 853 #[test]
843 854 fn the_demo_ring_names_a_caller_and_a_chat() {
844 855 let ring = demo_ring();
@@ -754,7 +754,10 @@ fn demo_spotlight(rank: u64) -> PublishedState {
754}
754}
755
755
756fn demo_caption(people: &[Person], tick: usize) -> Option<CaptionEntry> {
756fn demo_caption(people: &[Person], tick: usize) -> Option<CaptionEntry> {
757 let line = tick / (CAPTION_HOLD_TICKS * 2) % DEMO_CAPTIONS.len();
757 let line = tick / (CAPTION_HOLD_TICKS * 2);
758 if line >= DEMO_CAPTIONS.len() {
759 return None;
760 }
758 let within = tick % (CAPTION_HOLD_TICKS * 2);
761 let within = tick % (CAPTION_HOLD_TICKS * 2);
759 let (speaker, text) = DEMO_CAPTIONS[line];
762 let (speaker, text) = DEMO_CAPTIONS[line];
760 let words: Vec<&str> = text.split(' ').collect();
763 let words: Vec<&str> = text.split(' ').collect();
@@ -839,6 +842,14 @@ mod tests {
839 assert!(roster.iter().all(|entry| entry.mri != DEMO_OWN_MRI));
842 assert!(roster.iter().all(|entry| entry.mri != DEMO_OWN_MRI));
840 }
843 }
841
844
845 #[test]
846 fn demo_captions_stop_after_the_last_line() {
847 let people = demo_guests(3);
848 let ticks_per_line = CAPTION_HOLD_TICKS * 2;
849 assert!(demo_caption(&people, ticks_per_line * DEMO_CAPTIONS.len() - 1).is_some());
850 assert!(demo_caption(&people, ticks_per_line * DEMO_CAPTIONS.len()).is_none());
851 }
852
842 #[test]
853 #[test]
843 fn the_demo_ring_names_a_caller_and_a_chat() {
854 fn the_demo_ring_names_a_caller_and_a_chat() {
844 let ring = demo_ring();
855 let ring = demo_ring();
crates/app/src/layout_guard.rs +18 −3
@@ -131,7 +131,7 @@ mod frames {
131 131 use crate::user_activity::UserInput;
132 132 use crate::views::call_transcript::TranscriptPanel;
133 133 use crate::views::recap_tab::RECAP_REGION;
134 use crate::views::shell::{AppShell, Startup, bind_keys, install_globals};
134 use crate::views::shell::{AppShell, SIDEBAR_HIDDEN_BELOW, Startup, bind_keys, install_globals};
135 135 use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};
136 136
137 137 const GUARDED: &[&str] = &[
@@ -150,6 +150,8 @@ mod frames {
150 150 "shell/islands/main/call-header",
151 151 "shell/islands/main/call-stage",
152 152 "shell/islands/main/call-controls",
153 "shell/islands/main/call-controls/mic",
154 "shell/islands/main/call-controls/leave",
153 155 ];
154 156 const CALLS_TAGS: &[&str] = &[
155 157 "shell/islands/sidebar/calls-actions",
@@ -173,11 +175,16 @@ mod frames {
173 175 "shell/islands/main/call-stage/share-divider",
174 176 "shell/islands/main/call-stage/share-strip",
175 177 ];
178 const OVERLAY_PANELS: &[&str] = &[CALL_TRANSCRIPT, PEOPLE_PANEL];
179 const OVERLAY_CHROME: &[&str] = &[
180 "shell/islands/main/call-header",
181 "shell/islands/main/call-stage",
182 ];
176 183 const MENU: &str = "popup-menu";
177 184 const OWN_STATUS: &str = "shell/title-bar/own-status";
178 185 const RECAP_TAB: &str = "shell/islands/main/recap-tab";
179 186 const RECAP_MEETING_CHAT: &str = "demo-chat-meeting-standup";
180 const SIZES: [(f32, f32); 2] = [(640., 480.), (1920., 1080.)];
187 const SIZES: [(f32, f32); 3] = [(640., 480.), (1280., 800.), (1920., 1080.)];
181 188 const TOLERANCE: f32 = 0.5;
182 189 const KNOWN_VIOLATIONS: &[&str] = &[];
183 190
@@ -269,9 +276,14 @@ mod frames {
269 276 }
270 277 }
271 278 for (other, other_bounds) in tags {
279 let overlays = |first: &str, second: &str| {
280 OVERLAY_PANELS.contains(&first) && OVERLAY_CHROME.contains(&second)
281 };
272 282 let siblings = path < other
273 283 && parent_of(path).is_some()
274 && parent_of(path) == parent_of(other);
284 && parent_of(path) == parent_of(other)
285 && !overlays(path, other)
286 && !overlays(other, path);
275 287 if siblings && overlaps(*bounds, *other_bounds) {
276 288 found.push((
277 289 format!("{path}:overlaps:{other}"),
@@ -516,6 +528,9 @@ mod frames {
516 528 let mut expected = GUARDED.to_vec();
517 529 if is_call {
518 530 expected.extend(CALL_GUARDED);
531 if width < SIDEBAR_HIDDEN_BELOW {
532 expected.retain(|path| *path != "shell/islands/sidebar");
533 }
519 534 }
520 535 if screen_name == "call-transcript" {
521 536 expected.push(CALL_TRANSCRIPT);
@@ -131,7 +131,7 @@ mod frames {
131 use crate::user_activity::UserInput;
131 use crate::user_activity::UserInput;
132 use crate::views::call_transcript::TranscriptPanel;
132 use crate::views::call_transcript::TranscriptPanel;
133 use crate::views::recap_tab::RECAP_REGION;
133 use crate::views::recap_tab::RECAP_REGION;
134 use crate::views::shell::{AppShell, Startup, bind_keys, install_globals};
134 use crate::views::shell::{AppShell, SIDEBAR_HIDDEN_BELOW, Startup, bind_keys, install_globals};
135 use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};
135 use crate::views::shortcuts::{OpenActivity, OpenCallsTab, OpenChannelsTab, OpenSaved};
136
136
137 const GUARDED: &[&str] = &[
137 const GUARDED: &[&str] = &[
@@ -150,6 +150,8 @@ mod frames {
150 "shell/islands/main/call-header",
150 "shell/islands/main/call-header",
151 "shell/islands/main/call-stage",
151 "shell/islands/main/call-stage",
152 "shell/islands/main/call-controls",
152 "shell/islands/main/call-controls",
153 "shell/islands/main/call-controls/mic",
154 "shell/islands/main/call-controls/leave",
153 ];
155 ];
154 const CALLS_TAGS: &[&str] = &[
156 const CALLS_TAGS: &[&str] = &[
155 "shell/islands/sidebar/calls-actions",
157 "shell/islands/sidebar/calls-actions",
@@ -173,11 +175,16 @@ mod frames {
173 "shell/islands/main/call-stage/share-divider",
175 "shell/islands/main/call-stage/share-divider",
174 "shell/islands/main/call-stage/share-strip",
176 "shell/islands/main/call-stage/share-strip",
175 ];
177 ];
178 const OVERLAY_PANELS: &[&str] = &[CALL_TRANSCRIPT, PEOPLE_PANEL];
179 const OVERLAY_CHROME: &[&str] = &[
180 "shell/islands/main/call-header",
181 "shell/islands/main/call-stage",
182 ];
176 const MENU: &str = "popup-menu";
183 const MENU: &str = "popup-menu";
177 const OWN_STATUS: &str = "shell/title-bar/own-status";
184 const OWN_STATUS: &str = "shell/title-bar/own-status";
178 const RECAP_TAB: &str = "shell/islands/main/recap-tab";
185 const RECAP_TAB: &str = "shell/islands/main/recap-tab";
179 const RECAP_MEETING_CHAT: &str = "demo-chat-meeting-standup";
186 const RECAP_MEETING_CHAT: &str = "demo-chat-meeting-standup";
180 const SIZES: [(f32, f32); 2] = [(640., 480.), (1920., 1080.)];
187 const SIZES: [(f32, f32); 3] = [(640., 480.), (1280., 800.), (1920., 1080.)];
181 const TOLERANCE: f32 = 0.5;
188 const TOLERANCE: f32 = 0.5;
182 const KNOWN_VIOLATIONS: &[&str] = &[];
189 const KNOWN_VIOLATIONS: &[&str] = &[];
183
190
@@ -269,9 +276,14 @@ mod frames {
269 }
276 }
270 }
277 }
271 for (other, other_bounds) in tags {
278 for (other, other_bounds) in tags {
279 let overlays = |first: &str, second: &str| {
280 OVERLAY_PANELS.contains(&first) && OVERLAY_CHROME.contains(&second)
281 };
272 let siblings = path < other
282 let siblings = path < other
273 && parent_of(path).is_some()
283 && parent_of(path).is_some()
274 && parent_of(path) == parent_of(other);
284 && parent_of(path) == parent_of(other)
285 && !overlays(path, other)
286 && !overlays(other, path);
275 if siblings && overlaps(*bounds, *other_bounds) {
287 if siblings && overlaps(*bounds, *other_bounds) {
276 found.push((
288 found.push((
277 format!("{path}:overlaps:{other}"),
289 format!("{path}:overlaps:{other}"),
@@ -516,6 +528,9 @@ mod frames {
516 let mut expected = GUARDED.to_vec();
528 let mut expected = GUARDED.to_vec();
517 if is_call {
529 if is_call {
518 expected.extend(CALL_GUARDED);
530 expected.extend(CALL_GUARDED);
531 if width < SIDEBAR_HIDDEN_BELOW {
532 expected.retain(|path| *path != "shell/islands/sidebar");
533 }
519 }
534 }
520 if screen_name == "call-transcript" {
535 if screen_name == "call-transcript" {
521 expected.push(CALL_TRANSCRIPT);
536 expected.push(CALL_TRANSCRIPT);
crates/app/src/views/call_control_fold.rs added +230 −0
@@ -0,0 +1,230 @@
1 use calling::Reaction;
2 use gpui_kit::assets::IconName;
3 use gpui_kit::component::Icon;
4 use gpui_kit::component::menu::{PopupMenu, PopupMenuItem};
5 use gpui_kit::*;
6
7 use super::call_organizer::CAMERA_MENU_WIDTH;
8 use super::call_view::{CONTROL_SIZE, reaction_glyph};
9 use super::call_view_menu::view_items;
10 use crate::app_state::AppState;
11 use crate::call::CallModel;
12
13 pub(super) const CONTROL_GAP: f32 = 12.;
14 pub(super) const CONTROLS_PADDING: f32 = 16.;
15 const LEAVE_WIDTH: f32 = 116.;
16
17 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
18 pub enum Foldable {
19 View,
20 Reactions,
21 RaiseHand,
22 People,
23 Chat,
24 }
25
26 #[derive(Clone, Debug, Default)]
27 pub struct FoldedControls {
28 pub items: Vec<Foldable>,
29 pub fullscreen: bool,
30 pub people_open: bool,
31 pub chat_open: bool,
32 pub chat_unread: u32,
33 }
34
35 impl FoldedControls {
36 pub fn folds(&self, control: Foldable) -> bool {
37 self.items.contains(&control)
38 }
39 }
40
41 pub fn fixed_controls_width(has_camera_menu: bool, has_more: bool, has_leave_menu: bool) -> f32 {
42 let mut widths = vec![
43 CONTROL_SIZE + CAMERA_MENU_WIDTH,
44 CONTROL_SIZE + if has_camera_menu { CAMERA_MENU_WIDTH } else { 0. },
45 CONTROL_SIZE,
46 LEAVE_WIDTH,
47 ];
48 if has_more {
49 widths.push(CONTROL_SIZE);
50 }
51 if has_leave_menu {
52 widths.push(CONTROL_SIZE);
53 }
54 widths.iter().sum::<f32>() + CONTROL_GAP * (widths.len() - 1) as f32
55 }
56
57 pub fn folded_for_width(available: f32, fixed: f32, present: &[Foldable]) -> Vec<Foldable> {
58 let room = available - 2. * CONTROLS_PADDING - fixed;
59 let fitting = if room <= 0. {
60 0
61 } else {
62 (room / (CONTROL_SIZE + CONTROL_GAP)).floor() as usize
63 };
64 let folded_count = present.len().saturating_sub(fitting);
65 present[..folded_count].to_vec()
66 }
67
68 pub fn folded_items(
69 mut popup: PopupMenu,
70 window: &mut Window,
71 cx: &mut Context<PopupMenu>,
72 app: &Entity<AppState>,
73 model: &CallModel,
74 folded: &FoldedControls,
75 ) -> PopupMenu {
76 if folded.items.is_empty() {
77 return popup;
78 }
79 for item in &folded.items {
80 popup = match item {
81 Foldable::View => view_submenu(popup, window, cx, app, model, folded.fullscreen),
82 Foldable::Reactions => reactions_submenu(popup, window, cx, app, model),
83 Foldable::RaiseHand => hand_item(popup, app, model),
84 Foldable::People => people_item(popup, app, folded.people_open),
85 Foldable::Chat => chat_item(popup, app, folded),
86 };
87 }
88 popup.separator()
89 }
90
91 fn view_submenu(
92 popup: PopupMenu,
93 window: &mut Window,
94 cx: &mut Context<PopupMenu>,
95 app: &Entity<AppState>,
96 model: &CallModel,
97 fullscreen: bool,
98 ) -> PopupMenu {
99 let app = app.clone();
100 let model = model.clone();
101 popup.submenu_with_icon(
102 Some(Icon::new(IconName::LayoutGrid)),
103 "View",
104 window,
105 cx,
106 move |menu, _, _| view_items(menu, &app, &model, fullscreen),
107 )
108 }
109
110 fn reactions_submenu(
111 popup: PopupMenu,
112 window: &mut Window,
113 cx: &mut Context<PopupMenu>,
114 app: &Entity<AppState>,
115 model: &CallModel,
116 ) -> PopupMenu {
117 let app = app.clone();
118 let can_react = model.can_react();
119 popup.submenu_with_icon(
120 Some(Icon::new(IconName::FaceSlightlySmiling)),
121 "Reactions",
122 window,
123 cx,
124 move |mut menu, _, _| {
125 for reaction in Reaction::ALL {
126 let app = app.clone();
127 menu = menu.item(
128 PopupMenuItem::new(format!("{} {}", reaction_glyph(reaction), reaction.name()))
129 .disabled(!can_react)
130 .on_click(move |_, _, cx| {
131 app.update(cx, |state, cx| state.send_call_reaction(reaction, cx))
132 }),
133 );
134 }
135 menu
136 },
137 )
138 }
139
140 fn hand_item(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
141 let app = app.clone();
142 let raised = model.own_hand.is_some();
143 popup.item(
144 PopupMenuItem::new(if raised { "Lower hand" } else { "Raise hand" })
145 .icon(IconName::Hand)
146 .disabled(!model.can_react())
147 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_hand(cx))),
148 )
149 }
150
151 fn people_item(popup: PopupMenu, app: &Entity<AppState>, open: bool) -> PopupMenu {
152 let app = app.clone();
153 popup.item(
154 PopupMenuItem::new(if open { "Close the people list" } else { "Show people" })
155 .icon(IconName::Users)
156 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_people(cx))),
157 )
158 }
159
160 fn chat_item(popup: PopupMenu, app: &Entity<AppState>, folded: &FoldedControls) -> PopupMenu {
161 let app = app.clone();
162 let label = match (folded.chat_open, folded.chat_unread) {
163 (true, _) => "Close the chat".to_owned(),
164 (false, 0) => "Open the chat".to_owned(),
165 (false, unread) => format!("Open the chat ({unread})"),
166 };
167 popup.item(
168 PopupMenuItem::new(label)
169 .icon(IconName::MessageCircle)
170 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx))),
171 )
172 }
173
174 #[cfg(test)]
175 mod tests {
176 use super::{CONTROLS_PADDING, Foldable, fixed_controls_width, folded_for_width};
177
178 const ALL: [Foldable; 5] = [
179 Foldable::View,
180 Foldable::Reactions,
181 Foldable::RaiseHand,
182 Foldable::People,
183 Foldable::Chat,
184 ];
185 const SLOT: f32 = 44. + 12.;
186 const FIXED: f32 = 400.;
187
188 fn width_for(fitting: f32) -> f32 {
189 FIXED + 2. * CONTROLS_PADDING + fitting * SLOT
190 }
191
192 #[test]
193 fn nothing_folds_when_everything_fits() {
194 assert!(folded_for_width(width_for(5.), FIXED, &ALL).is_empty());
195 assert!(folded_for_width(width_for(9.), FIXED, &ALL).is_empty());
196 }
197
198 #[test]
199 fn folds_view_first_then_reactions() {
200 assert_eq!(folded_for_width(width_for(4.), FIXED, &ALL), [Foldable::View]);
201 assert_eq!(
202 folded_for_width(width_for(3.), FIXED, &ALL),
203 [Foldable::View, Foldable::Reactions]
204 );
205 }
206
207 #[test]
208 fn everything_folds_when_only_the_fixed_controls_fit() {
209 assert_eq!(folded_for_width(width_for(0.), FIXED, &ALL), ALL);
210 assert_eq!(folded_for_width(100., FIXED, &ALL), ALL);
211 }
212
213 #[test]
214 fn only_present_controls_are_counted() {
215 let present = [Foldable::View, Foldable::People];
216 assert!(folded_for_width(width_for(2.), FIXED, &present).is_empty());
217 assert_eq!(
218 folded_for_width(width_for(1.), FIXED, &present),
219 [Foldable::View]
220 );
221 }
222
223 #[test]
224 fn fixed_width_counts_optional_controls() {
225 let base = fixed_controls_width(false, false, false);
226 assert_eq!(fixed_controls_width(true, false, false), base + 28.);
227 assert_eq!(fixed_controls_width(false, true, false), base + 44. + 12.);
228 assert_eq!(fixed_controls_width(false, false, true), base + 44. + 12.);
229 }
230 }
@@ -0,0 +1,230 @@
1use calling::Reaction;
2use gpui_kit::assets::IconName;
3use gpui_kit::component::Icon;
4use gpui_kit::component::menu::{PopupMenu, PopupMenuItem};
5use gpui_kit::*;
6
7use super::call_organizer::CAMERA_MENU_WIDTH;
8use super::call_view::{CONTROL_SIZE, reaction_glyph};
9use super::call_view_menu::view_items;
10use crate::app_state::AppState;
11use crate::call::CallModel;
12
13pub(super) const CONTROL_GAP: f32 = 12.;
14pub(super) const CONTROLS_PADDING: f32 = 16.;
15const LEAVE_WIDTH: f32 = 116.;
16
17#[derive(Clone, Copy, Debug, PartialEq, Eq)]
18pub enum Foldable {
19 View,
20 Reactions,
21 RaiseHand,
22 People,
23 Chat,
24}
25
26#[derive(Clone, Debug, Default)]
27pub struct FoldedControls {
28 pub items: Vec<Foldable>,
29 pub fullscreen: bool,
30 pub people_open: bool,
31 pub chat_open: bool,
32 pub chat_unread: u32,
33}
34
35impl FoldedControls {
36 pub fn folds(&self, control: Foldable) -> bool {
37 self.items.contains(&control)
38 }
39}
40
41pub fn fixed_controls_width(has_camera_menu: bool, has_more: bool, has_leave_menu: bool) -> f32 {
42 let mut widths = vec![
43 CONTROL_SIZE + CAMERA_MENU_WIDTH,
44 CONTROL_SIZE + if has_camera_menu { CAMERA_MENU_WIDTH } else { 0. },
45 CONTROL_SIZE,
46 LEAVE_WIDTH,
47 ];
48 if has_more {
49 widths.push(CONTROL_SIZE);
50 }
51 if has_leave_menu {
52 widths.push(CONTROL_SIZE);
53 }
54 widths.iter().sum::<f32>() + CONTROL_GAP * (widths.len() - 1) as f32
55}
56
57pub fn folded_for_width(available: f32, fixed: f32, present: &[Foldable]) -> Vec<Foldable> {
58 let room = available - 2. * CONTROLS_PADDING - fixed;
59 let fitting = if room <= 0. {
60 0
61 } else {
62 (room / (CONTROL_SIZE + CONTROL_GAP)).floor() as usize
63 };
64 let folded_count = present.len().saturating_sub(fitting);
65 present[..folded_count].to_vec()
66}
67
68pub fn folded_items(
69 mut popup: PopupMenu,
70 window: &mut Window,
71 cx: &mut Context<PopupMenu>,
72 app: &Entity<AppState>,
73 model: &CallModel,
74 folded: &FoldedControls,
75) -> PopupMenu {
76 if folded.items.is_empty() {
77 return popup;
78 }
79 for item in &folded.items {
80 popup = match item {
81 Foldable::View => view_submenu(popup, window, cx, app, model, folded.fullscreen),
82 Foldable::Reactions => reactions_submenu(popup, window, cx, app, model),
83 Foldable::RaiseHand => hand_item(popup, app, model),
84 Foldable::People => people_item(popup, app, folded.people_open),
85 Foldable::Chat => chat_item(popup, app, folded),
86 };
87 }
88 popup.separator()
89}
90
91fn view_submenu(
92 popup: PopupMenu,
93 window: &mut Window,
94 cx: &mut Context<PopupMenu>,
95 app: &Entity<AppState>,
96 model: &CallModel,
97 fullscreen: bool,
98) -> PopupMenu {
99 let app = app.clone();
100 let model = model.clone();
101 popup.submenu_with_icon(
102 Some(Icon::new(IconName::LayoutGrid)),
103 "View",
104 window,
105 cx,
106 move |menu, _, _| view_items(menu, &app, &model, fullscreen),
107 )
108}
109
110fn reactions_submenu(
111 popup: PopupMenu,
112 window: &mut Window,
113 cx: &mut Context<PopupMenu>,
114 app: &Entity<AppState>,
115 model: &CallModel,
116) -> PopupMenu {
117 let app = app.clone();
118 let can_react = model.can_react();
119 popup.submenu_with_icon(
120 Some(Icon::new(IconName::FaceSlightlySmiling)),
121 "Reactions",
122 window,
123 cx,
124 move |mut menu, _, _| {
125 for reaction in Reaction::ALL {
126 let app = app.clone();
127 menu = menu.item(
128 PopupMenuItem::new(format!("{} {}", reaction_glyph(reaction), reaction.name()))
129 .disabled(!can_react)
130 .on_click(move |_, _, cx| {
131 app.update(cx, |state, cx| state.send_call_reaction(reaction, cx))
132 }),
133 );
134 }
135 menu
136 },
137 )
138}
139
140fn hand_item(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
141 let app = app.clone();
142 let raised = model.own_hand.is_some();
143 popup.item(
144 PopupMenuItem::new(if raised { "Lower hand" } else { "Raise hand" })
145 .icon(IconName::Hand)
146 .disabled(!model.can_react())
147 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_hand(cx))),
148 )
149}
150
151fn people_item(popup: PopupMenu, app: &Entity<AppState>, open: bool) -> PopupMenu {
152 let app = app.clone();
153 popup.item(
154 PopupMenuItem::new(if open { "Close the people list" } else { "Show people" })
155 .icon(IconName::Users)
156 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_people(cx))),
157 )
158}
159
160fn chat_item(popup: PopupMenu, app: &Entity<AppState>, folded: &FoldedControls) -> PopupMenu {
161 let app = app.clone();
162 let label = match (folded.chat_open, folded.chat_unread) {
163 (true, _) => "Close the chat".to_owned(),
164 (false, 0) => "Open the chat".to_owned(),
165 (false, unread) => format!("Open the chat ({unread})"),
166 };
167 popup.item(
168 PopupMenuItem::new(label)
169 .icon(IconName::MessageCircle)
170 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.toggle_call_chat(cx))),
171 )
172}
173
174#[cfg(test)]
175mod tests {
176 use super::{CONTROLS_PADDING, Foldable, fixed_controls_width, folded_for_width};
177
178 const ALL: [Foldable; 5] = [
179 Foldable::View,
180 Foldable::Reactions,
181 Foldable::RaiseHand,
182 Foldable::People,
183 Foldable::Chat,
184 ];
185 const SLOT: f32 = 44. + 12.;
186 const FIXED: f32 = 400.;
187
188 fn width_for(fitting: f32) -> f32 {
189 FIXED + 2. * CONTROLS_PADDING + fitting * SLOT
190 }
191
192 #[test]
193 fn nothing_folds_when_everything_fits() {
194 assert!(folded_for_width(width_for(5.), FIXED, &ALL).is_empty());
195 assert!(folded_for_width(width_for(9.), FIXED, &ALL).is_empty());
196 }
197
198 #[test]
199 fn folds_view_first_then_reactions() {
200 assert_eq!(folded_for_width(width_for(4.), FIXED, &ALL), [Foldable::View]);
201 assert_eq!(
202 folded_for_width(width_for(3.), FIXED, &ALL),
203 [Foldable::View, Foldable::Reactions]
204 );
205 }
206
207 #[test]
208 fn everything_folds_when_only_the_fixed_controls_fit() {
209 assert_eq!(folded_for_width(width_for(0.), FIXED, &ALL), ALL);
210 assert_eq!(folded_for_width(100., FIXED, &ALL), ALL);
211 }
212
213 #[test]
214 fn only_present_controls_are_counted() {
215 let present = [Foldable::View, Foldable::People];
216 assert!(folded_for_width(width_for(2.), FIXED, &present).is_empty());
217 assert_eq!(
218 folded_for_width(width_for(1.), FIXED, &present),
219 [Foldable::View]
220 );
221 }
222
223 #[test]
224 fn fixed_width_counts_optional_controls() {
225 let base = fixed_controls_width(false, false, false);
226 assert_eq!(fixed_controls_width(true, false, false), base + 28.);
227 assert_eq!(fixed_controls_width(false, true, false), base + 44. + 12.);
228 assert_eq!(fixed_controls_width(false, false, true), base + 44. + 12.);
229 }
230}
crates/app/src/views/call_organizer.rs +26 −11
@@ -12,13 +12,14 @@ use gpui_kit::prelude::FluentBuilder as _;
12 12 use gpui_kit::*;
13 13
14 14 use super::avatar::person_avatar;
15 use super::call_control_fold::{Foldable, FoldedControls, folded_items};
15 16 use super::call_extras::{
16 17 CameraMenu, background_items, effect_items, open_transfer_picker,
17 18 };
18 19 use super::call_record::{record_submenu, transcript_and_settings_items};
19 20 use super::call_people::add_people_item;
20 21 use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
21 use super::widgets::icon;
22 use super::widgets::{Corner, corner_badge, count_badge, icon};
22 23 use crate::app_state::AppState;
23 24 use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus};
24 25 use crate::notice::truncated;
@@ -37,7 +38,7 @@ const FOCUS_RADIUS: f32 = 12.;
37 38 const FOCUS_AVATAR: f32 = 140.;
38 39 const CHIP_HEIGHT: f32 = 24.;
39 40 const MORE_SIZE: f32 = 28.;
40 const CAMERA_MENU_WIDTH: f32 = 28.;
41 pub(super) const CAMERA_MENU_WIDTH: f32 = 28.;
41 42 const NAME_LIMIT: usize = 32;
42 43
43 44 fn dark_text() -> Hsla {
@@ -415,27 +416,40 @@ pub fn with_tile_menu(
415 416 attach_tile_menu(wrapper, app, model, mri, name, own)
416 417 }
417 418
418 pub fn more_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {
419 pub fn more_button(
420 app: &Entity<AppState>,
421 model: &CallModel,
422 folded: &FoldedControls,
423 ) -> Option<AnyElement> {
419 424 let in_meeting = model.kind == crate::call::CallKind::Meeting;
420 425 if !in_meeting && !model.is_one_to_one() {
421 426 return None;
422 427 }
423 428 let app = app.clone();
424 429 let model = model.clone();
430 let folded = folded.clone();
431 let unread = folded.chat_unread;
432 let chat_folded = folded.folds(Foldable::Chat);
425 433 Some(
426 434 Button::new("call-more")
427 435 .ghost()
428 436 .p_0()
429 437 .size(px(CONTROL_SIZE))
430 438 .rounded_full()
431 .child(round_control(
432 "call-more-face",
433 IconName::Ellipsis,
434 theme::surface_raised(),
435 theme::text(),
436 ))
439 .child(
440 round_control(
441 "call-more-face",
442 IconName::Ellipsis,
443 theme::surface_raised(),
444 theme::text(),
445 )
446 .relative()
447 .when(chat_folded && unread > 0, |face| {
448 face.child(corner_badge(Corner::TopRight, 4.).child(count_badge(unread, false)))
449 }),
450 )
437 451 .dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, window, cx| {
438 more_menu(popup, window, cx, &app, &model)
452 more_menu(popup, window, cx, &app, &model, &folded)
439 453 })
440 454 .into_any_element(),
441 455 )
@@ -447,8 +461,9 @@ fn more_menu(
447 461 cx: &mut Context<PopupMenu>,
448 462 app: &Entity<AppState>,
449 463 model: &CallModel,
464 folded: &FoldedControls,
450 465 ) -> PopupMenu {
451 let popup = popup.min_w(px(MENU_WIDTH));
466 let popup = folded_items(popup.min_w(px(MENU_WIDTH)), window, cx, app, model, folded);
452 467 let popup = if model.is_one_to_one() {
453 468 one_to_one_items(popup, app, model)
454 469 } else {
@@ -12,13 +12,14 @@ use gpui_kit::prelude::FluentBuilder as _;
12use gpui_kit::*;
12use gpui_kit::*;
13
13
14use super::avatar::person_avatar;
14use super::avatar::person_avatar;
15use super::call_control_fold::{Foldable, FoldedControls, folded_items};
15use super::call_extras::{
16use super::call_extras::{
16 CameraMenu, background_items, effect_items, open_transfer_picker,
17 CameraMenu, background_items, effect_items, open_transfer_picker,
17};
18};
18use super::call_record::{record_submenu, transcript_and_settings_items};
19use super::call_record::{record_submenu, transcript_and_settings_items};
19use super::call_people::add_people_item;
20use super::call_people::add_people_item;
20use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
21use super::call_view::{BANNER_HEIGHT, CONTROL_SIZE, MENU_WIDTH, round_control};
21use super::widgets::icon;
22use super::widgets::{Corner, corner_badge, count_badge, icon};
22use crate::app_state::AppState;
23use crate::app_state::AppState;
23use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus};
24use crate::call::{CAPTION_SHOWN, CallModel, CaptionPosition, Focus};
24use crate::notice::truncated;
25use crate::notice::truncated;
@@ -37,7 +38,7 @@ const FOCUS_RADIUS: f32 = 12.;
37const FOCUS_AVATAR: f32 = 140.;
38const FOCUS_AVATAR: f32 = 140.;
38const CHIP_HEIGHT: f32 = 24.;
39const CHIP_HEIGHT: f32 = 24.;
39const MORE_SIZE: f32 = 28.;
40const MORE_SIZE: f32 = 28.;
40const CAMERA_MENU_WIDTH: f32 = 28.;
41pub(super) const CAMERA_MENU_WIDTH: f32 = 28.;
41const NAME_LIMIT: usize = 32;
42const NAME_LIMIT: usize = 32;
42
43
43fn dark_text() -> Hsla {
44fn dark_text() -> Hsla {
@@ -415,27 +416,40 @@ pub fn with_tile_menu(
415 attach_tile_menu(wrapper, app, model, mri, name, own)
416 attach_tile_menu(wrapper, app, model, mri, name, own)
416}
417}
417
418
418pub fn more_button(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {
419pub fn more_button(
420 app: &Entity<AppState>,
421 model: &CallModel,
422 folded: &FoldedControls,
423) -> Option<AnyElement> {
419 let in_meeting = model.kind == crate::call::CallKind::Meeting;
424 let in_meeting = model.kind == crate::call::CallKind::Meeting;
420 if !in_meeting && !model.is_one_to_one() {
425 if !in_meeting && !model.is_one_to_one() {
421 return None;
426 return None;
422 }
427 }
423 let app = app.clone();
428 let app = app.clone();
424 let model = model.clone();
429 let model = model.clone();
430 let folded = folded.clone();
431 let unread = folded.chat_unread;
432 let chat_folded = folded.folds(Foldable::Chat);
425 Some(
433 Some(
426 Button::new("call-more")
434 Button::new("call-more")
427 .ghost()
435 .ghost()
428 .p_0()
436 .p_0()
429 .size(px(CONTROL_SIZE))
437 .size(px(CONTROL_SIZE))
430 .rounded_full()
438 .rounded_full()
431 .child(round_control(
439 .child(
432 "call-more-face",
440 round_control(
433 IconName::Ellipsis,
441 "call-more-face",
434 theme::surface_raised(),
442 IconName::Ellipsis,
435 theme::text(),
443 theme::surface_raised(),
436 ))
444 theme::text(),
445 )
446 .relative()
447 .when(chat_folded && unread > 0, |face| {
448 face.child(corner_badge(Corner::TopRight, 4.).child(count_badge(unread, false)))
449 }),
450 )
437 .dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, window, cx| {
451 .dropdown_menu_with_anchor(Anchor::BottomRight, move |popup, window, cx| {
438 more_menu(popup, window, cx, &app, &model)
452 more_menu(popup, window, cx, &app, &model, &folded)
439 })
453 })
440 .into_any_element(),
454 .into_any_element(),
441 )
455 )
@@ -447,8 +461,9 @@ fn more_menu(
447 cx: &mut Context<PopupMenu>,
461 cx: &mut Context<PopupMenu>,
448 app: &Entity<AppState>,
462 app: &Entity<AppState>,
449 model: &CallModel,
463 model: &CallModel,
464 folded: &FoldedControls,
450) -> PopupMenu {
465) -> PopupMenu {
451 let popup = popup.min_w(px(MENU_WIDTH));
466 let popup = folded_items(popup.min_w(px(MENU_WIDTH)), window, cx, app, model, folded);
452 let popup = if model.is_one_to_one() {
467 let popup = if model.is_one_to_one() {
453 one_to_one_items(popup, app, model)
468 one_to_one_items(popup, app, model)
454 } else {
469 } else {
crates/app/src/views/call_view.rs +98 −17
@@ -16,12 +16,15 @@ use gpui_kit::prelude::FluentBuilder as _;
16 16 use gpui_kit::*;
17 17
18 18 use super::avatar::person_avatar;
19 use super::call_control_fold::{
20 CONTROL_GAP, CONTROLS_PADDING, Foldable, FoldedControls, fixed_controls_width, folded_for_width,
21 };
19 22 use super::call_extras::{
20 23 CameraMenu, consent_overlay, consult_banner, hold_panel, recording_chip, return_button,
21 24 room_chip, whiteboard_stage,
22 25 };
23 26 use super::call_health::{health_banner, health_indicator};
24 use super::call_layouts::stage_region;
27 use super::call_layouts::{measured_stage, stage_region};
25 28 use super::call_organizer::{
26 29 camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,
27 30 more_button, pin_chip, spotlight_chip, with_tile_menu,
@@ -64,6 +67,8 @@ pub(super) const BANNER_HEIGHT: f32 = 40.;
64 67 const MAX_WINDOW_ITEMS: usize = 12;
65 68 pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
66 69 pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;
70 const OVERLAY_BELOW: f32 = 720.;
71 const CONTROLS_HEIGHT: f32 = 2. * 16. + CONTROL_SIZE;
67 72 const CHAT_HEADER_HEIGHT: f32 = 48.;
68 73 const REACTION_RISE: f32 = 24.;
69 74 const REACTION_FADE_FROM: f32 = 0.75;
@@ -1108,11 +1113,42 @@ fn own_tile_body(
1108 1113 .into_any_element()
1109 1114 }
1110 1115
1116 fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> FoldedControls {
1117 let model = &call.model;
1118 let has_more = model.kind == CallKind::Meeting || model.is_one_to_one();
1119 if !has_more {
1120 return FoldedControls::default();
1121 }
1122 let mut present = vec![Foldable::View];
1123 if model.has_reaction_controls() {
1124 present.extend([Foldable::Reactions, Foldable::RaiseHand]);
1125 }
1126 if model.kind != CallKind::Test {
1127 present.push(Foldable::People);
1128 }
1129 if call.chat_thread().is_some() {
1130 present.push(Foldable::Chat);
1131 }
1132 let fixed = fixed_controls_width(
1133 model.can_use_camera(),
1134 has_more,
1135 model.kind == CallKind::Meeting,
1136 );
1137 FoldedControls {
1138 items: folded_for_width(measured_stage(call).0, fixed, &present),
1139 fullscreen,
1140 people_open: call.people_open,
1141 chat_open: call.chat_open,
1142 chat_unread: state.call_chat_unread(),
1143 }
1144 }
1145
1111 1146 pub fn render_call_view(
1112 1147 app: &Entity<AppState>,
1113 1148 state: &AppState,
1114 1149 chat: Option<Entity<ConversationView>>,
1115 1150 fullscreen: bool,
1151 island_width: f32,
1116 1152 ) -> Option<AnyElement> {
1117 1153 let call = state.call.as_ref()?;
1118 1154 let model = &call.model;
@@ -1152,15 +1188,18 @@ pub fn render_call_view(
1152 1188 let share_stage = share_stage_element(app, state, call);
1153 1189 let region = stage_region(app, state, call, now, hold, share_stage);
1154 1190
1191 let folded = folded_controls(state, call, fullscreen);
1155 1192 let controls = h_flex()
1156 1193 .w_full()
1157 1194 .flex_none()
1158 1195 .py(px(16.))
1159 .gap(px(12.))
1196 .px(px(CONTROLS_PADDING))
1197 .gap(px(CONTROL_GAP))
1160 1198 .items_center()
1161 1199 .justify_center()
1162 1200 .child(
1163 1201 h_flex()
1202 .debug_selector(|| "shell/islands/main/call-controls/mic".into())
1164 1203 .h(px(CONTROL_SIZE))
1165 1204 .items_center()
1166 1205 .rounded_full()
@@ -1183,19 +1222,30 @@ pub fn render_call_view(
1183 1222 ShareOptions::of(state),
1184 1223 call.share_menu_open,
1185 1224 ))
1186 .when(model.has_reaction_controls(), |row| {
1187 row.child(hand_button(app, model))
1188 .child(reactions_button(app, model))
1189 })
1190 .child(view_button(app, model, fullscreen))
1191 .children(more_button(app, model))
1192 .when(model.kind != CallKind::Test, |row| {
1193 row.child(people_button(app, call.people_open, model.raised_hands()))
1194 })
1195 .when(call.chat_thread().is_some(), |row| {
1196 row.child(chat_button(app, call.chat_open, state.call_chat_unread()))
1225 .when(
1226 model.has_reaction_controls() && !folded.folds(Foldable::RaiseHand),
1227 |row| row.child(hand_button(app, model)),
1228 )
1229 .when(
1230 model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1231 |row| row.child(reactions_button(app, model)),
1232 )
1233 .when(!folded.folds(Foldable::View), |row| {
1234 row.child(view_button(app, model, fullscreen))
1197 1235 })
1198 .child(leave_button(app, model, "call-leave", false))
1236 .children(more_button(app, model, &folded))
1237 .when(
1238 model.kind != CallKind::Test && !folded.folds(Foldable::People),
1239 |row| row.child(people_button(app, call.people_open, model.raised_hands())),
1240 )
1241 .when(
1242 call.chat_thread().is_some() && !folded.folds(Foldable::Chat),
1243 |row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),
1244 )
1245 .child(
1246 leave_button(app, model, "call-leave", false)
1247 .debug_selector(|| "shell/islands/main/call-controls/leave".into()),
1248 )
1199 1249 .when(model.kind == CallKind::Meeting, |row| {
1200 1250 row.child(leave_menu(app, model))
1201 1251 });
@@ -1244,8 +1294,20 @@ pub fn render_call_view(
1244 1294 .children(state.transfer_picker.clone())
1245 1295 .children(options_dialog(app, call))
1246 1296 .children(consent_overlay(app, model));
1297 let panels: Vec<AnyElement> = chat
1298 .map(|chat| chat_panel(app, chat))
1299 .into_iter()
1300 .chain(
1301 call.transcript_open
1302 .then(|| state.transcript_panel.clone())
1303 .flatten()
1304 .map(IntoElement::into_any_element),
1305 )
1306 .chain(people_panel(app, state, call))
1307 .collect();
1247 1308 Some(
1248 1309 h_flex()
1310 .relative()
1249 1311 .when(!fullscreen, |row| {
1250 1312 row.debug_selector(|| "shell/islands/main".into())
1251 1313 })
@@ -1254,13 +1316,32 @@ pub fn render_call_view(
1254 1316 .h_full()
1255 1317 .gap(px(ISLAND_GAP))
1256 1318 .child(column)
1257 .children(chat.map(|chat| chat_panel(app, chat)))
1258 .children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())
1259 .children(people_panel(app, state, call))
1319 .children(side_panels(panels, island_width))
1260 1320 .into_any_element(),
1261 1321 )
1262 1322 }
1263 1323
1324 fn side_panels(panels: Vec<AnyElement>, island_width: f32) -> Vec<AnyElement> {
1325 if panels.is_empty() {
1326 return panels;
1327 }
1328 let panels_width = (CHAT_PANEL_WIDTH + ISLAND_GAP) * panels.len() as f32;
1329 if island_width - panels_width >= OVERLAY_BELOW {
1330 return panels;
1331 }
1332 vec![
1333 h_flex()
1334 .absolute()
1335 .top_0()
1336 .right_0()
1337 .bottom(px(CONTROLS_HEIGHT))
1338 .gap(px(ISLAND_GAP))
1339 .w(px(panels_width.min(island_width)))
1340 .children(panels)
1341 .into_any_element(),
1342 ]
1343 }
1344
1264 1345 fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) -> Stateful<Div> {
1265 1346 let hover_app = app.clone();
1266 1347 div()
@@ -16,12 +16,15 @@ use gpui_kit::prelude::FluentBuilder as _;
16use gpui_kit::*;
16use gpui_kit::*;
17
17
18use super::avatar::person_avatar;
18use super::avatar::person_avatar;
19use super::call_control_fold::{
20 CONTROL_GAP, CONTROLS_PADDING, Foldable, FoldedControls, fixed_controls_width, folded_for_width,
21};
19use super::call_extras::{
22use super::call_extras::{
20 CameraMenu, consent_overlay, consult_banner, hold_panel, recording_chip, return_button,
23 CameraMenu, consent_overlay, consult_banner, hold_panel, recording_chip, return_button,
21 room_chip, whiteboard_stage,
24 room_chip, whiteboard_stage,
22};
25};
23use super::call_health::{health_banner, health_indicator};
26use super::call_health::{health_banner, health_indicator};
24use super::call_layouts::stage_region;
27use super::call_layouts::{measured_stage, stage_region};
25use super::call_organizer::{
28use super::call_organizer::{
26 camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,
29 camera_menu_button, captions_hint_chip, captions_overlay, chevron_button, lobby_banner,
27 more_button, pin_chip, spotlight_chip, with_tile_menu,
30 more_button, pin_chip, spotlight_chip, with_tile_menu,
@@ -64,6 +67,8 @@ pub(super) const BANNER_HEIGHT: f32 = 40.;
64const MAX_WINDOW_ITEMS: usize = 12;
67const MAX_WINDOW_ITEMS: usize = 12;
65pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
68pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
66pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;
69pub(super) const CHAT_PANEL_WIDTH: f32 = 320.;
70const OVERLAY_BELOW: f32 = 720.;
71const CONTROLS_HEIGHT: f32 = 2. * 16. + CONTROL_SIZE;
67const CHAT_HEADER_HEIGHT: f32 = 48.;
72const CHAT_HEADER_HEIGHT: f32 = 48.;
68const REACTION_RISE: f32 = 24.;
73const REACTION_RISE: f32 = 24.;
69const REACTION_FADE_FROM: f32 = 0.75;
74const REACTION_FADE_FROM: f32 = 0.75;
@@ -1108,11 +1113,42 @@ fn own_tile_body(
1108 .into_any_element()
1113 .into_any_element()
1109}
1114}
1110
1115
1116fn folded_controls(state: &AppState, call: &ActiveCall, fullscreen: bool) -> FoldedControls {
1117 let model = &call.model;
1118 let has_more = model.kind == CallKind::Meeting || model.is_one_to_one();
1119 if !has_more {
1120 return FoldedControls::default();
1121 }
1122 let mut present = vec![Foldable::View];
1123 if model.has_reaction_controls() {
1124 present.extend([Foldable::Reactions, Foldable::RaiseHand]);
1125 }
1126 if model.kind != CallKind::Test {
1127 present.push(Foldable::People);
1128 }
1129 if call.chat_thread().is_some() {
1130 present.push(Foldable::Chat);
1131 }
1132 let fixed = fixed_controls_width(
1133 model.can_use_camera(),
1134 has_more,
1135 model.kind == CallKind::Meeting,
1136 );
1137 FoldedControls {
1138 items: folded_for_width(measured_stage(call).0, fixed, &present),
1139 fullscreen,
1140 people_open: call.people_open,
1141 chat_open: call.chat_open,
1142 chat_unread: state.call_chat_unread(),
1143 }
1144}
1145
1111pub fn render_call_view(
1146pub fn render_call_view(
1112 app: &Entity<AppState>,
1147 app: &Entity<AppState>,
1113 state: &AppState,
1148 state: &AppState,
1114 chat: Option<Entity<ConversationView>>,
1149 chat: Option<Entity<ConversationView>>,
1115 fullscreen: bool,
1150 fullscreen: bool,
1151 island_width: f32,
1116) -> Option<AnyElement> {
1152) -> Option<AnyElement> {
1117 let call = state.call.as_ref()?;
1153 let call = state.call.as_ref()?;
1118 let model = &call.model;
1154 let model = &call.model;
@@ -1152,15 +1188,18 @@ pub fn render_call_view(
1152 let share_stage = share_stage_element(app, state, call);
1188 let share_stage = share_stage_element(app, state, call);
1153 let region = stage_region(app, state, call, now, hold, share_stage);
1189 let region = stage_region(app, state, call, now, hold, share_stage);
1154
1190
1191 let folded = folded_controls(state, call, fullscreen);
1155 let controls = h_flex()
1192 let controls = h_flex()
1156 .w_full()
1193 .w_full()
1157 .flex_none()
1194 .flex_none()
1158 .py(px(16.))
1195 .py(px(16.))
1159 .gap(px(12.))
1196 .px(px(CONTROLS_PADDING))
1197 .gap(px(CONTROL_GAP))
1160 .items_center()
1198 .items_center()
1161 .justify_center()
1199 .justify_center()
1162 .child(
1200 .child(
1163 h_flex()
1201 h_flex()
1202 .debug_selector(|| "shell/islands/main/call-controls/mic".into())
1164 .h(px(CONTROL_SIZE))
1203 .h(px(CONTROL_SIZE))
1165 .items_center()
1204 .items_center()
1166 .rounded_full()
1205 .rounded_full()
@@ -1183,19 +1222,30 @@ pub fn render_call_view(
1183 ShareOptions::of(state),
1222 ShareOptions::of(state),
1184 call.share_menu_open,
1223 call.share_menu_open,
1185 ))
1224 ))
1186 .when(model.has_reaction_controls(), |row| {
1225 .when(
1187 row.child(hand_button(app, model))
1226 model.has_reaction_controls() && !folded.folds(Foldable::RaiseHand),
1188 .child(reactions_button(app, model))
1227 |row| row.child(hand_button(app, model)),
1189 })
1228 )
1190 .child(view_button(app, model, fullscreen))
1229 .when(
1191 .children(more_button(app, model))
1230 model.has_reaction_controls() && !folded.folds(Foldable::Reactions),
1192 .when(model.kind != CallKind::Test, |row| {
1231 |row| row.child(reactions_button(app, model)),
1193 row.child(people_button(app, call.people_open, model.raised_hands()))
1232 )
1194 })
1233 .when(!folded.folds(Foldable::View), |row| {
1195 .when(call.chat_thread().is_some(), |row| {
1234 row.child(view_button(app, model, fullscreen))
1196 row.child(chat_button(app, call.chat_open, state.call_chat_unread()))
1197 })
1235 })
1198 .child(leave_button(app, model, "call-leave", false))
1236 .children(more_button(app, model, &folded))
1237 .when(
1238 model.kind != CallKind::Test && !folded.folds(Foldable::People),
1239 |row| row.child(people_button(app, call.people_open, model.raised_hands())),
1240 )
1241 .when(
1242 call.chat_thread().is_some() && !folded.folds(Foldable::Chat),
1243 |row| row.child(chat_button(app, call.chat_open, state.call_chat_unread())),
1244 )
1245 .child(
1246 leave_button(app, model, "call-leave", false)
1247 .debug_selector(|| "shell/islands/main/call-controls/leave".into()),
1248 )
1199 .when(model.kind == CallKind::Meeting, |row| {
1249 .when(model.kind == CallKind::Meeting, |row| {
1200 row.child(leave_menu(app, model))
1250 row.child(leave_menu(app, model))
1201 });
1251 });
@@ -1244,8 +1294,20 @@ pub fn render_call_view(
1244 .children(state.transfer_picker.clone())
1294 .children(state.transfer_picker.clone())
1245 .children(options_dialog(app, call))
1295 .children(options_dialog(app, call))
1246 .children(consent_overlay(app, model));
1296 .children(consent_overlay(app, model));
1297 let panels: Vec<AnyElement> = chat
1298 .map(|chat| chat_panel(app, chat))
1299 .into_iter()
1300 .chain(
1301 call.transcript_open
1302 .then(|| state.transcript_panel.clone())
1303 .flatten()
1304 .map(IntoElement::into_any_element),
1305 )
1306 .chain(people_panel(app, state, call))
1307 .collect();
1247 Some(
1308 Some(
1248 h_flex()
1309 h_flex()
1310 .relative()
1249 .when(!fullscreen, |row| {
1311 .when(!fullscreen, |row| {
1250 row.debug_selector(|| "shell/islands/main".into())
1312 row.debug_selector(|| "shell/islands/main".into())
1251 })
1313 })
@@ -1254,13 +1316,32 @@ pub fn render_call_view(
1254 .h_full()
1316 .h_full()
1255 .gap(px(ISLAND_GAP))
1317 .gap(px(ISLAND_GAP))
1256 .child(column)
1318 .child(column)
1257 .children(chat.map(|chat| chat_panel(app, chat)))
1319 .children(side_panels(panels, island_width))
1258 .children(call.transcript_open.then(|| state.transcript_panel.clone()).flatten())
1259 .children(people_panel(app, state, call))
1260 .into_any_element(),
1320 .into_any_element(),
1261 )
1321 )
1262}
1322}
1263
1323
1324fn side_panels(panels: Vec<AnyElement>, island_width: f32) -> Vec<AnyElement> {
1325 if panels.is_empty() {
1326 return panels;
1327 }
1328 let panels_width = (CHAT_PANEL_WIDTH + ISLAND_GAP) * panels.len() as f32;
1329 if island_width - panels_width >= OVERLAY_BELOW {
1330 return panels;
1331 }
1332 vec![
1333 h_flex()
1334 .absolute()
1335 .top_0()
1336 .right_0()
1337 .bottom(px(CONTROLS_HEIGHT))
1338 .gap(px(ISLAND_GAP))
1339 .w(px(panels_width.min(island_width)))
1340 .children(panels)
1341 .into_any_element(),
1342 ]
1343}
1344
1264fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) -> Stateful<Div> {
1345fn fullscreen_chrome(id: &'static str, app: &Entity<AppState>, content: Div) -> Stateful<Div> {
1265 let hover_app = app.clone();
1346 let hover_app = app.clone();
1266 div()
1347 div()
crates/app/src/views/call_view_menu.rs +1 −1
@@ -66,7 +66,7 @@ fn switch_item(
66 66 .on_click(move |_, _, cx| app.update(cx, |state, cx| toggle(state, cx)))
67 67 }
68 68
69 fn view_items(
69 pub(super) fn view_items(
70 70 popup: PopupMenu,
71 71 app: &Entity<AppState>,
72 72 model: &CallModel,
@@ -66,7 +66,7 @@ fn switch_item(
66 .on_click(move |_, _, cx| app.update(cx, |state, cx| toggle(state, cx)))
66 .on_click(move |_, _, cx| app.update(cx, |state, cx| toggle(state, cx)))
67}
67}
68
68
69fn view_items(
69pub(super) fn view_items(
70 popup: PopupMenu,
70 popup: PopupMenu,
71 app: &Entity<AppState>,
71 app: &Entity<AppState>,
72 model: &CallModel,
72 model: &CallModel,
crates/app/src/views/mod.rs +1 −0
@@ -3,6 +3,7 @@ pub mod adaptive_card;
3 3 pub mod attachment_tray;
4 4 pub mod attachments;
5 5 pub mod avatar;
6 pub mod call_control_fold;
6 7 pub mod call_controls;
7 8 pub mod call_extras;
8 9 pub mod call_health;
@@ -3,6 +3,7 @@ pub mod adaptive_card;
3pub mod attachment_tray;
3pub mod attachment_tray;
4pub mod attachments;
4pub mod attachments;
5pub mod avatar;
5pub mod avatar;
6pub mod call_control_fold;
6pub mod call_controls;
7pub mod call_controls;
7pub mod call_extras;
8pub mod call_extras;
8pub mod call_health;
9pub mod call_health;
crates/app/src/views/shell.rs +24 −12
@@ -13,7 +13,8 @@ use super::forward_dialog::{ForwardDialog, ForwardDialogEvent};
13 13 use super::image_viewer::{ImageViewer, ImageViewerEvent};
14 14 use super::prejoin_view::PrejoinView;
15 15 use super::profile_card::{ProfileCard, ProfileCardEvent};
16 use super::rail::RailView;
16 use gpui_kit::prelude::FluentBuilder as _;
17 use super::rail::{RAIL_WIDTH, RailView};
17 18 use super::saved_panel::{SavedPanel, SavedPanelEvent};
18 19 use super::shortcuts::{
19 20 AcceptCall, DeclineCall, HangUpCall, JoinMeetingFromToast, NextConversation, OpenActivity,
@@ -69,6 +70,7 @@ pub struct Startup {
69 70 }
70 71
71 72 pub const ISLAND_GAP: f32 = 6.;
73 pub const SIDEBAR_HIDDEN_BELOW: f32 = 960.;
72 74
73 75 pub struct UserInputHandle(pub Arc<UserInput>);
74 76
@@ -666,7 +668,7 @@ impl AppShell {
666 668 }
667 669
668 670 impl AppShell {
669 fn islands(&self, call_view: Option<AnyElement>) -> impl IntoElement {
671 fn islands(&self, call_view: Option<AnyElement>, show_sidebar: bool) -> impl IntoElement {
670 672 h_flex()
671 673 .debug_selector(|| "shell/islands".into())
672 674 .flex_1()
@@ -680,14 +682,16 @@ impl AppShell {
680 682 .h_full()
681 683 .flex_none()
682 684 .child(self.rail.clone())
683 .child(
684 self.sidebar.clone().cached(
685 StyleRefinement::default()
686 .w(px(SIDEBAR_WIDTH))
687 .h_full()
688 .flex_none(),
689 ),
690 ),
685 .when(show_sidebar, |group| {
686 group.child(
687 self.sidebar.clone().cached(
688 StyleRefinement::default()
689 .w(px(SIDEBAR_WIDTH))
690 .h_full()
691 .flex_none(),
692 ),
693 )
694 }),
691 695 )
692 696 .child(match (call_view, self.prejoin.clone()) {
693 697 (Some(call_view), _) => call_view,
@@ -739,7 +743,15 @@ impl Render for AppShell {
739 743 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone());
740 744 let state = self.state.read(cx);
741 745 let call_fullscreen = state.call_fullscreen();
742 let call_view = render_call_view(&self.state, state, chat_panel, call_fullscreen)
746 let window_width = f32::from(window.viewport_size().width);
747 let show_sidebar = !(state.viewing_call()
748 && !call_fullscreen
749 && window_width < SIDEBAR_HIDDEN_BELOW);
750 let island_width = window_width
751 - RAIL_WIDTH
752 - if show_sidebar { SIDEBAR_WIDTH } else { 0. }
753 - 2. * ISLAND_GAP;
754 let call_view = render_call_view(&self.state, state, chat_panel, call_fullscreen, island_width)
743 755 .filter(|_| state.viewing_call());
744 756 let (call_view, call_overlay) = match call_view {
745 757 Some(view) if call_fullscreen => (None, Some(render_call_overlay(view))),
@@ -897,7 +909,7 @@ impl Render for AppShell {
897 909 .debug_selector(|| "shell".into())
898 910 .size_full()
899 911 .child(title_bar)
900 .child(self.islands(call_view))
912 .child(self.islands(call_view, show_sidebar))
901 913 .child(status),
902 914 )
903 915 .children(call_mini)
@@ -13,7 +13,8 @@ use super::forward_dialog::{ForwardDialog, ForwardDialogEvent};
13use super::image_viewer::{ImageViewer, ImageViewerEvent};
13use super::image_viewer::{ImageViewer, ImageViewerEvent};
14use super::prejoin_view::PrejoinView;
14use super::prejoin_view::PrejoinView;
15use super::profile_card::{ProfileCard, ProfileCardEvent};
15use super::profile_card::{ProfileCard, ProfileCardEvent};
16use super::rail::RailView;
16use gpui_kit::prelude::FluentBuilder as _;
17use super::rail::{RAIL_WIDTH, RailView};
17use super::saved_panel::{SavedPanel, SavedPanelEvent};
18use super::saved_panel::{SavedPanel, SavedPanelEvent};
18use super::shortcuts::{
19use super::shortcuts::{
19 AcceptCall, DeclineCall, HangUpCall, JoinMeetingFromToast, NextConversation, OpenActivity,
20 AcceptCall, DeclineCall, HangUpCall, JoinMeetingFromToast, NextConversation, OpenActivity,
@@ -69,6 +70,7 @@ pub struct Startup {
69}
70}
70
71
71pub const ISLAND_GAP: f32 = 6.;
72pub const ISLAND_GAP: f32 = 6.;
73pub const SIDEBAR_HIDDEN_BELOW: f32 = 960.;
72
74
73pub struct UserInputHandle(pub Arc<UserInput>);
75pub struct UserInputHandle(pub Arc<UserInput>);
74
76
@@ -666,7 +668,7 @@ impl AppShell {
666}
668}
667
669
668impl AppShell {
670impl AppShell {
669 fn islands(&self, call_view: Option<AnyElement>) -> impl IntoElement {
671 fn islands(&self, call_view: Option<AnyElement>, show_sidebar: bool) -> impl IntoElement {
670 h_flex()
672 h_flex()
671 .debug_selector(|| "shell/islands".into())
673 .debug_selector(|| "shell/islands".into())
672 .flex_1()
674 .flex_1()
@@ -680,14 +682,16 @@ impl AppShell {
680 .h_full()
682 .h_full()
681 .flex_none()
683 .flex_none()
682 .child(self.rail.clone())
684 .child(self.rail.clone())
683 .child(
685 .when(show_sidebar, |group| {
684 self.sidebar.clone().cached(
686 group.child(
685 StyleRefinement::default()
687 self.sidebar.clone().cached(
686 .w(px(SIDEBAR_WIDTH))
688 StyleRefinement::default()
687 .h_full()
689 .w(px(SIDEBAR_WIDTH))
688 .flex_none(),
690 .h_full()
689 ),
691 .flex_none(),
690 ),
692 ),
693 )
694 }),
691 )
695 )
692 .child(match (call_view, self.prejoin.clone()) {
696 .child(match (call_view, self.prejoin.clone()) {
693 (Some(call_view), _) => call_view,
697 (Some(call_view), _) => call_view,
@@ -739,7 +743,15 @@ impl Render for AppShell {
739 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone());
743 let chat_panel = self.call_chat.as_ref().map(|(_, view)| view.clone());
740 let state = self.state.read(cx);
744 let state = self.state.read(cx);
741 let call_fullscreen = state.call_fullscreen();
745 let call_fullscreen = state.call_fullscreen();
742 let call_view = render_call_view(&self.state, state, chat_panel, call_fullscreen)
746 let window_width = f32::from(window.viewport_size().width);
747 let show_sidebar = !(state.viewing_call()
748 && !call_fullscreen
749 && window_width < SIDEBAR_HIDDEN_BELOW);
750 let island_width = window_width
751 - RAIL_WIDTH
752 - if show_sidebar { SIDEBAR_WIDTH } else { 0. }
753 - 2. * ISLAND_GAP;
754 let call_view = render_call_view(&self.state, state, chat_panel, call_fullscreen, island_width)
743 .filter(|_| state.viewing_call());
755 .filter(|_| state.viewing_call());
744 let (call_view, call_overlay) = match call_view {
756 let (call_view, call_overlay) = match call_view {
745 Some(view) if call_fullscreen => (None, Some(render_call_overlay(view))),
757 Some(view) if call_fullscreen => (None, Some(render_call_overlay(view))),
@@ -897,7 +909,7 @@ impl Render for AppShell {
897 .debug_selector(|| "shell".into())
909 .debug_selector(|| "shell".into())
898 .size_full()
910 .size_full()
899 .child(title_bar)
911 .child(title_bar)
900 .child(self.islands(call_view))
912 .child(self.islands(call_view, show_sidebar))
901 .child(status),
913 .child(status),
902 )
914 )
903 .children(call_mini)
915 .children(call_mini)